@shumai-one/shumai 0.3.11 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/bin/chunk-082zg4nr.js +307 -0
  2. package/bin/chunk-09pe07g6.js +7 -0
  3. package/bin/chunk-0qdzjcny.js +2 -0
  4. package/bin/chunk-0z1p2pvf.js +1 -0
  5. package/bin/{chunk-cmd0feyq.js → chunk-116p639c.js} +2 -2
  6. package/bin/{chunk-cyjh5qsk.js → chunk-13ypr8v0.js} +1 -1
  7. package/bin/{chunk-sepsqqdf.js → chunk-16txy3r1.js} +2 -2
  8. package/bin/{chunk-dyen2t1p.js → chunk-1vs91e4q.js} +2 -2
  9. package/bin/chunk-29e0mb43.js +1 -0
  10. package/bin/chunk-2a0egvsg.js +1 -0
  11. package/bin/chunk-2f35h4fn.js +2 -0
  12. package/bin/{chunk-tdp1jjv1.js → chunk-2jsjrqw4.js} +2 -2
  13. package/bin/chunk-2q7ew7yz.js +2 -0
  14. package/bin/{chunk-ps2hw0ps.js → chunk-2sc2jxd3.js} +1 -1
  15. package/bin/chunk-2vc6pw8q.js +2 -0
  16. package/bin/{chunk-f9ydhm8q.js → chunk-3gqdepkd.js} +2 -2
  17. package/bin/chunk-44370df5.js +4 -0
  18. package/bin/chunk-44xtwvd7.js +2 -0
  19. package/bin/{chunk-7t31qfw5.js → chunk-47r5b77s.js} +2 -2
  20. package/bin/chunk-4azttb3w.js +1 -0
  21. package/bin/{chunk-whm06pnc.js → chunk-4ee336e3.js} +1 -1
  22. package/bin/{chunk-qrhf20g2.js → chunk-4k2d8w9w.js} +2 -2
  23. package/bin/{chunk-kcg7d7pk.js → chunk-4yhd7bmp.js} +2 -2
  24. package/bin/chunk-4yybby29.js +2 -0
  25. package/bin/{chunk-0g0gt4bj.js → chunk-5395g4kq.js} +2 -2
  26. package/bin/{chunk-gx410cm2.js → chunk-5bkj2n94.js} +2 -2
  27. package/bin/{chunk-aq7q5e36.js → chunk-5c4h0t33.js} +2 -2
  28. package/bin/{chunk-byjze6hm.js → chunk-6nrynqdw.js} +2 -2
  29. package/bin/chunk-6tv7rm3x.js +2 -0
  30. package/bin/chunk-785kxysj.js +68 -0
  31. package/bin/{chunk-c16vvzdj.js → chunk-78cxvbjd.js} +1 -1
  32. package/bin/chunk-7g2k89gq.js +2 -0
  33. package/bin/chunk-7psq38hv.js +1 -0
  34. package/bin/{chunk-xsqk7ek2.js → chunk-7qzt5nhz.js} +1 -1
  35. package/bin/{chunk-b78s1cxz.js → chunk-7sf0gbbm.js} +2 -2
  36. package/bin/{chunk-9qytehed.js → chunk-7wvw67f3.js} +2 -2
  37. package/bin/chunk-7xcyn1ba.js +2 -0
  38. package/bin/{chunk-vvx62hp4.js → chunk-7zgvmn5q.js} +1 -1
  39. package/bin/{chunk-12r8a5ev.js → chunk-8pfgh13x.js} +2 -2
  40. package/bin/{chunk-xext4yvc.js → chunk-8rcfhfq5.js} +1 -1
  41. package/bin/{chunk-8qg6jjz4.js → chunk-8yt4m2pb.js} +2 -2
  42. package/bin/{chunk-y0k1f3gk.js → chunk-90tbc5f4.js} +2 -2
  43. package/bin/{chunk-mvkqjrcd.js → chunk-92yvt66q.js} +1 -1
  44. package/bin/chunk-93v3tm93.js +1 -0
  45. package/bin/{chunk-s04f76tb.js → chunk-9f83pnfc.js} +2 -2
  46. package/bin/chunk-a5b3aevg.js +2 -0
  47. package/bin/{chunk-0vqefpcw.js → chunk-af6m9p1d.js} +1 -1
  48. package/bin/chunk-ajryg2e2.js +1 -0
  49. package/bin/chunk-axb1f1ae.js +2 -0
  50. package/bin/chunk-b0cqsrse.js +9 -0
  51. package/bin/chunk-b27jgdsf.css +1 -0
  52. package/bin/{chunk-qz3kfrpr.js → chunk-bbar8rsh.js} +1 -1
  53. package/bin/{chunk-8bv8qsb8.js → chunk-be9a7kc6.js} +2 -2
  54. package/bin/{chunk-dwkv3bx5.js → chunk-bkbqvxfv.js} +2 -2
  55. package/bin/chunk-bwyph9a0.js +1 -0
  56. package/bin/{chunk-0xqf53hc.js → chunk-c43nmcfq.js} +1 -1
  57. package/bin/{chunk-4yke5y3z.js → chunk-c97vh5wb.js} +3 -3
  58. package/bin/{chunk-1dzby9bb.js → chunk-cerjktz2.js} +1 -1
  59. package/bin/chunk-cyvx7gcx.js +2 -0
  60. package/bin/{chunk-esa954t1.js → chunk-d6d1j7qq.js} +2 -2
  61. package/bin/{chunk-6edh2e59.js → chunk-d9sh922y.js} +1 -1
  62. package/bin/chunk-dbjc1vxt.js +1 -0
  63. package/bin/{chunk-pz7ms4n2.js → chunk-djkajvn7.js} +1 -1
  64. package/bin/{chunk-s0jy7grq.js → chunk-dyvmwafa.js} +2 -2
  65. package/bin/{chunk-zvjx64p5.js → chunk-ewge52nq.js} +1 -1
  66. package/bin/{chunk-qrnw89xg.js → chunk-f32kxe6c.js} +2 -2
  67. package/bin/{chunk-7anqxpyv.js → chunk-f4d3v0nc.js} +2 -2
  68. package/bin/{chunk-xfzk0mrt.js → chunk-f8ysqfyv.js} +2 -2
  69. package/bin/{chunk-dhhfwbns.js → chunk-fcsar7p0.js} +1 -1
  70. package/bin/{chunk-kbw63gr4.js → chunk-gfdfkqrc.js} +3 -3
  71. package/bin/chunk-gr30nssh.js +1 -0
  72. package/bin/chunk-gtwhwdbs.js +1 -0
  73. package/bin/{chunk-xsgxk1fj.js → chunk-gyaem1t4.js} +1 -1
  74. package/bin/chunk-hk6tvf7b.js +1 -0
  75. package/bin/{chunk-ntqn09r0.js → chunk-hmmzbyy1.js} +2 -2
  76. package/bin/{chunk-s9yzt7s3.js → chunk-hx2mvd20.js} +2 -2
  77. package/bin/chunk-hzz4hsss.js +1 -0
  78. package/bin/{chunk-5nk7y4ec.js → chunk-j10gz94w.js} +2 -2
  79. package/bin/{chunk-p9w4ar11.js → chunk-j5rx3x1q.js} +1 -1
  80. package/bin/{chunk-knh1stxe.js → chunk-j9q9rjvd.js} +2 -2
  81. package/bin/{chunk-ty32j999.js → chunk-jw00fmkp.js} +2 -2
  82. package/bin/chunk-k1f3gj25.js +3 -0
  83. package/bin/{chunk-393g7z2g.js → chunk-k20w9eaz.js} +1 -1
  84. package/bin/{chunk-31f07jzm.js → chunk-kejt7kcr.js} +2 -2
  85. package/bin/{chunk-k1jcdr0n.js → chunk-kkveddbn.js} +1 -1
  86. package/bin/chunk-ktvmxqfg.js +5 -0
  87. package/bin/{chunk-szf2q87p.js → chunk-m49g5tf4.js} +2 -2
  88. package/bin/{chunk-77c2xm0z.js → chunk-me3xj7na.js} +1 -1
  89. package/bin/{chunk-nw03w9pa.js → chunk-mgnxa0vy.js} +1 -1
  90. package/bin/{chunk-fv14er33.js → chunk-mgytr7nc.js} +1 -1
  91. package/bin/chunk-mkb4dycy.js +2 -0
  92. package/bin/chunk-n21a21vx.js +2 -0
  93. package/bin/{chunk-8r2agmv2.js → chunk-n8gsjwht.js} +2 -2
  94. package/bin/{chunk-t2z4qys8.js → chunk-nndzhn3n.js} +1 -1
  95. package/bin/{chunk-ghw914d2.js → chunk-pcxjm1re.js} +2 -2
  96. package/bin/{chunk-3qva5sqr.js → chunk-pg00gkr4.js} +2 -2
  97. package/bin/{chunk-wdgwymdp.js → chunk-pn94h6x7.js} +1 -1
  98. package/bin/chunk-pt51m9h1.js +2 -0
  99. package/bin/{chunk-hpm4razn.js → chunk-px2cvc1n.js} +2 -2
  100. package/bin/{chunk-rr12edz4.js → chunk-q059y3wx.js} +2 -2
  101. package/bin/{chunk-a5ja6d97.js → chunk-q46rc697.js} +1 -1
  102. package/bin/{chunk-sdjss6ja.js → chunk-r6g1srb3.js} +1 -1
  103. package/bin/chunk-r88vwaxc.js +1 -0
  104. package/bin/chunk-r9pzpqst.js +2 -0
  105. package/bin/{chunk-fsj3kxya.js → chunk-rar0gk7s.js} +2 -2
  106. package/bin/chunk-rfrpb986.js +1 -0
  107. package/bin/{chunk-4pj17byj.js → chunk-rfsbzd39.js} +2 -2
  108. package/bin/{chunk-jsqsrcse.js → chunk-s503pcvb.js} +3 -3
  109. package/bin/{chunk-50vzkdc8.js → chunk-s9sgkkjp.js} +1 -1
  110. package/bin/{chunk-12ps84z8.js → chunk-srs9jq8f.js} +2 -2
  111. package/bin/chunk-t77dwtcc.js +2 -0
  112. package/bin/{chunk-res6r4tm.js → chunk-tcqw0q8x.js} +1 -1
  113. package/bin/{chunk-sqy50q9g.js → chunk-thd9zasr.js} +1 -1
  114. package/bin/chunk-tkgpc6c9.js +2 -0
  115. package/bin/{chunk-qh3w5w8e.js → chunk-ts10cfmc.js} +2 -2
  116. package/bin/{chunk-69at8jm8.js → chunk-txkmks1h.js} +1 -1
  117. package/bin/chunk-v9hbssqd.js +3 -0
  118. package/bin/chunk-v9zc56qr.js +1 -0
  119. package/bin/{chunk-v073nwjn.js → chunk-vh7eb7tp.js} +2 -2
  120. package/bin/chunk-w9p59ahz.js +73 -0
  121. package/bin/{chunk-7888x3vz.js → chunk-wfee9d83.js} +3 -3
  122. package/bin/{chunk-r18tcdds.js → chunk-wxsq9zmf.js} +1 -1
  123. package/bin/chunk-wzdnsgwq.js +2 -0
  124. package/bin/chunk-x2nnv4j8.js +1 -0
  125. package/bin/chunk-xxtcmzcv.js +2 -0
  126. package/bin/{chunk-axnvvkdf.js → chunk-xyzmew7g.js} +1 -1
  127. package/bin/{chunk-2s97ngr8.js → chunk-ygsbmfcy.js} +2 -2
  128. package/bin/{chunk-z8crenxd.js → chunk-ym9xavj0.js} +1 -1
  129. package/bin/{chunk-3j47y8ah.js → chunk-z340qkez.js} +1 -1
  130. package/bin/{chunk-6qzcnkgx.js → chunk-za7ga4bf.js} +2 -2
  131. package/bin/{chunk-nzrrvn6c.js → chunk-zqvavykq.js} +2 -2
  132. package/bin/{chunk-f5c9g4y9.js → chunk-zt15ht52.js} +1 -1
  133. package/bin/shumai-app.html +1 -1
  134. package/bin/shumai-app.js +283 -315
  135. package/package.json +7 -7
  136. package/prisma/schema.prisma +1 -1
  137. package/bin/chunk-02b97gsf.js +0 -2
  138. package/bin/chunk-0ash207y.js +0 -2
  139. package/bin/chunk-0j3yb84c.js +0 -1
  140. package/bin/chunk-0wgqr4jg.js +0 -2
  141. package/bin/chunk-1tby7q3f.js +0 -1
  142. package/bin/chunk-3ztat2q9.js +0 -68
  143. package/bin/chunk-48yphy68.js +0 -73
  144. package/bin/chunk-4t2qcxp5.js +0 -1
  145. package/bin/chunk-5dfy6173.js +0 -2
  146. package/bin/chunk-68bfd8x7.js +0 -3
  147. package/bin/chunk-6ts5az6h.js +0 -2
  148. package/bin/chunk-72nj00dp.js +0 -1
  149. package/bin/chunk-8b11b9cj.js +0 -2
  150. package/bin/chunk-8ekjxb5q.js +0 -2
  151. package/bin/chunk-8zar6cc4.js +0 -2
  152. package/bin/chunk-9m9bn55a.js +0 -1
  153. package/bin/chunk-ayr3tsz3.js +0 -2
  154. package/bin/chunk-bthrbggg.js +0 -2
  155. package/bin/chunk-csh1ggtt.js +0 -1
  156. package/bin/chunk-ctx1ms5t.js +0 -2
  157. package/bin/chunk-day0vn14.js +0 -2
  158. package/bin/chunk-e5r6rnt9.js +0 -2
  159. package/bin/chunk-gwzk0fvn.js +0 -2
  160. package/bin/chunk-gx8sz5bw.js +0 -2
  161. package/bin/chunk-gydktfnx.js +0 -2
  162. package/bin/chunk-h5j1dqc0.js +0 -1
  163. package/bin/chunk-h7kyj2g2.js +0 -2
  164. package/bin/chunk-har4xctf.js +0 -2
  165. package/bin/chunk-hks5k0tm.js +0 -7
  166. package/bin/chunk-hv4t9h3e.js +0 -9
  167. package/bin/chunk-kchbbtdm.js +0 -2
  168. package/bin/chunk-mkwrrdme.js +0 -2
  169. package/bin/chunk-mm995mvc.js +0 -2
  170. package/bin/chunk-mz9pthjh.js +0 -2
  171. package/bin/chunk-n2ae527q.js +0 -307
  172. package/bin/chunk-n3xn2ve1.js +0 -1
  173. package/bin/chunk-q3fdffq5.js +0 -1
  174. package/bin/chunk-rd2n0rs6.js +0 -1
  175. package/bin/chunk-sttc4axf.js +0 -1
  176. package/bin/chunk-t6pmgmg2.js +0 -1
  177. package/bin/chunk-txpqhfqw.js +0 -1
  178. package/bin/chunk-vrdbqapq.js +0 -2
  179. package/bin/chunk-vwa17b2r.js +0 -1
  180. package/bin/chunk-wch8ygpt.js +0 -3
  181. package/bin/chunk-wqwvxskj.js +0 -1
  182. package/bin/chunk-wr3q8a9n.js +0 -1
  183. package/bin/chunk-wt01m93x.js +0 -1
  184. package/bin/chunk-xr1wr22v.css +0 -1
  185. package/bin/chunk-y1pnq12c.js +0 -2
  186. /package/bin/{chunk-xg9xscqz.js → chunk-kryt6pg3.js} +0 -0
@@ -0,0 +1,307 @@
1
+ import{H as xS,J as q7,T as RS,U as Dm,V as ri,W as Cm,X as _g,Y as i5,Z as gv}from"./chunk-44xtwvd7.js";import{_ as r7}from"./chunk-44370df5.js";import{if as Pm,jf as e5,kf as Uk,mf as Pg,nf as Ik,of as Gk,qf as Xk,rf as Zk,sf as e8,tf as Kk,uf as Lk,vf as mA}from"./chunk-pt51m9h1.js";import{Af as DS,Bf as ep,Cf as tp,Df as l7,Ef as r5,zf as MS}from"./chunk-kejt7kcr.js";import{Lf as j7}from"./chunk-2q7ew7yz.js";import{Nf as $u,Of as Wu,Pf as Pu}from"./chunk-ktvmxqfg.js";import{lg as f7}from"./chunk-d6d1j7qq.js";import{ng as Qf}from"./chunk-7xcyn1ba.js";import{hh as P8}from"./chunk-ygsbmfcy.js";import{jh as ps}from"./chunk-1vs91e4q.js";import{kh as HS}from"./chunk-16txy3r1.js";import{rh as Qu}from"./chunk-90tbc5f4.js";import{Bh as Kp,Ch as Lp,Dh as Vp,Eh as Yp}from"./chunk-ts10cfmc.js";import{di as Vc,ei as Yc,fi as Jc}from"./chunk-2f35h4fn.js";import{gi as Qi,ii as Zi,ji as $i,ki as Hn,ni as ul,oi as Nh,si as d7,ti as TS}from"./chunk-4k2d8w9w.js";import{Bi as ur,Ci as BS,Di as o7,Ii as Ht,Ji as Jp,Ki as Qp,Li as Zp,Mi as $p,Ni as Wp,Oi as Pp,Pi as e7,Qi as t7,Ri as a7,Ti as n7,Ui as s7,Wi as i7,wi as Yu,zi as Ju}from"./chunk-s503pcvb.js";import{_i as z3}from"./chunk-axb1f1ae.js";import{$i as en,Aj as Ip,Dj as v7,Fl as Xp,Jl as w7,Oj as c7,Pl as Hm,Qj as R3,Ql as Mm,Sj as s5,Sl as Zu,Wl as vn,Xk as Ao,Zj as h7,aj as Zf,ak as pi,al as yo,bj as R,bk as $f,bl as Wf,cj as ie,ck as kS,dk as AS,el as g7,fl as Om,hl as ml,il as So,jk as u7,lk as wA,ml as p7,ok as Bi,pl as Bm,qk as Gp,qm as Oi,rk as m7,tl as Tm,tm as He,um as E3,yl as b7}from"./chunk-w9p59ahz.js";import{rn as Mt,sn as Tt,tn as JR}from"./chunk-txkmks1h.js";var Wi=Tt((oU,A7)=>{var Zc;if(typeof window<"u")Zc=window;else if(typeof global<"u")Zc=global;else if(typeof self<"u")Zc=self;else Zc={};A7.exports=Zc});var U3=Tt((cU,S7)=>{var y7=Array.prototype.slice;S7.exports=H_;function H_(e,t){if(!("length"in e))e=[e];e=y7.call(e);while(e.length){var a=e.shift(),n=t(a);if(n)return n;if(a.childNodes&&a.childNodes.length)e=y7.call(a.childNodes).concat(e)}}});var _7=Tt((hU,C7)=>{C7.exports=D1;function D1(e,t){if(!(this instanceof D1))return new D1(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}D1.prototype.nodeType=8;D1.prototype.nodeName="#comment";D1.prototype.toString=function(){return"[object Comment]"}});var O7=Tt((uU,F7)=>{F7.exports=Pf;function Pf(e,t){if(!(this instanceof Pf))return new Pf(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}Pf.prototype.type="DOMTextNode";Pf.prototype.nodeType=3;Pf.prototype.nodeName="#text";Pf.prototype.toString=function(){return this.data};Pf.prototype.replaceData=function(t,a,n){var s=this.data,i=s.substring(0,t),f=s.substring(t+a,s.length);this.data=i+n+f,this.length=this.data.length}});var I3=Tt((mU,B7)=>{B7.exports=M_;function M_(e){var t=this,a=e.type;if(!e.target)e.target=t;if(!t.listeners)t.listeners={};var n=t.listeners[a];if(n)return n.forEach(function(s){if(e.currentTarget=t,typeof s==="function")s(e);else s.handleEvent(e)});if(t.parentNode)t.parentNode.dispatchEvent(e)}});var G3=Tt((gU,T7)=>{T7.exports=D_;function D_(e,t){var a=this;if(!a.listeners)a.listeners={};if(!a.listeners[e])a.listeners[e]=[];if(a.listeners[e].indexOf(t)===-1)a.listeners[e].push(t)}});var X3=Tt((pU,H7)=>{H7.exports=x_;function x_(e,t){var a=this;if(!a.listeners)return;if(!a.listeners[e])return;var n=a.listeners[e],s=n.indexOf(t);if(s!==-1)n.splice(s,1)}});var R7=Tt((bU,x7)=>{x7.exports=M7;var R_=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function M7(e){switch(e.nodeType){case 3:return K3(e.data);case 8:return"<!--"+e.data+"-->";default:return N_(e)}}function N_(e){var t=[],a=e.tagName;if(e.namespaceURI==="http://www.w3.org/1999/xhtml")a=a.toLowerCase();if(t.push("<"+a+I_(e)+U_(e)),R_.indexOf(a)>-1)t.push(" />");else{if(t.push(">"),e.childNodes.length)t.push.apply(t,e.childNodes.map(M7));else if(e.textContent||e.innerText)t.push(K3(e.textContent||e.innerText));else if(e.innerHTML)t.push(e.innerHTML);t.push("</"+a+">")}return t.join("")}function E_(e,t){var a=typeof e[t];if(t==="style"&&Object.keys(e.style).length>0)return!0;return e.hasOwnProperty(t)&&(a==="string"||a==="boolean"||a==="number")&&t!=="nodeName"&&t!=="className"&&t!=="tagName"&&t!=="textContent"&&t!=="innerText"&&t!=="namespaceURI"&&t!=="innerHTML"}function z_(e){if(typeof e==="string")return e;var t="";return Object.keys(e).forEach(function(a){var n=e[a];a=a.replace(/[A-Z]/g,function(s){return"-"+s.toLowerCase()}),t+=a+":"+n+";"}),t}function U_(e){var t=e.dataset,a=[];for(var n in t)a.push({name:"data-"+n,value:t[n]});return a.length?D7(a):""}function D7(e){var t=[];return e.forEach(function(a){var{name:n,value:s}=a;if(n==="style")s=z_(s);t.push(n+'="'+G_(s)+'"')}),t.length?" "+t.join(" "):""}function I_(e){var t=[];for(var a in e)if(E_(e,a))t.push({name:a,value:e[a]});for(var n in e._attributes)for(var s in e._attributes[n]){var i=e._attributes[n][s],f=(i.prefix?i.prefix+":":"")+s;t.push({name:f,value:i.value})}if(e.className)t.push({name:"class",value:e.className});return t.length?D7(t):""}function K3(e){var t="";if(typeof e==="string")t=e;else if(e)t=e.toString();return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function G_(e){return K3(e).replace(/"/g,"&quot;")}});var V3=Tt((wU,E7)=>{var L3=U3(),X_=I3(),K_=G3(),L_=X3(),V_=R7(),N7="http://www.w3.org/1999/xhtml";E7.exports=wa;function wa(e,t,a){if(!(this instanceof wa))return new wa(e);var n=a===void 0?N7:a||null;if(this.tagName=n===N7?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=n,this._attributes={},this.tagName==="INPUT")this.type="text"}wa.prototype.type="DOMElement";wa.prototype.nodeType=1;wa.prototype.appendChild=function(t){if(t.parentNode)t.parentNode.removeChild(t);return this.childNodes.push(t),t.parentNode=this,t};wa.prototype.replaceChild=function(t,a){if(t.parentNode)t.parentNode.removeChild(t);var n=this.childNodes.indexOf(a);return a.parentNode=null,this.childNodes[n]=t,t.parentNode=this,a};wa.prototype.removeChild=function(t){var a=this.childNodes.indexOf(t);return this.childNodes.splice(a,1),t.parentNode=null,t};wa.prototype.insertBefore=function(t,a){if(t.parentNode)t.parentNode.removeChild(t);var n=a===null||a===void 0?-1:this.childNodes.indexOf(a);if(n>-1)this.childNodes.splice(n,0,t);else this.childNodes.push(t);return t.parentNode=this,t};wa.prototype.setAttributeNS=function(t,a,n){var s=null,i=a,f=a.indexOf(":");if(f>-1)s=a.substr(0,f),i=a.substr(f+1);if(this.tagName==="INPUT"&&a==="type")this.type=n;else{var l=this._attributes[t]||(this._attributes[t]={});l[i]={value:n,prefix:s}}};wa.prototype.getAttributeNS=function(t,a){var n=this._attributes[t],s=n&&n[a]&&n[a].value;if(this.tagName==="INPUT"&&a==="type")return this.type;if(typeof s!=="string")return null;return s};wa.prototype.removeAttributeNS=function(t,a){if(!Object.prototype.hasOwnProperty.call(this._attributes,t))return;var n=this._attributes[t];if(n&&Object.prototype.hasOwnProperty.call(n,a))delete n[a]};wa.prototype.hasAttributeNS=function(t,a){var n=this._attributes[t];return!!n&&a in n};wa.prototype.setAttribute=function(t,a){return this.setAttributeNS(null,t,a)};wa.prototype.getAttribute=function(t){return this.getAttributeNS(null,t)};wa.prototype.removeAttribute=function(t){return this.removeAttributeNS(null,t)};wa.prototype.hasAttribute=function(t){return this.hasAttributeNS(null,t)};wa.prototype.removeEventListener=L_;wa.prototype.addEventListener=K_;wa.prototype.dispatchEvent=X_;wa.prototype.focus=function(){return};wa.prototype.toString=function(){return V_(this)};wa.prototype.getElementsByClassName=function(t){var a=t.split(" "),n=[];return L3(this,function(s){if(s.nodeType===1){var i=s.className||"",f=i.split(" ");if(a.every(function(l){return f.indexOf(l)!==-1}))n.push(s)}}),n};wa.prototype.getElementsByTagName=function(t){t=t.toLowerCase();var a=[];return L3(this.childNodes,function(n){if(n.nodeType===1&&(t==="*"||n.tagName.toLowerCase()===t))a.push(n)}),a};wa.prototype.contains=function(t){return L3(this,function(a){return t===a})||!1}});var U7=Tt((dU,z7)=>{var Y3=V3();z7.exports=Pi;function Pi(e){if(!(this instanceof Pi))return new Pi;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}Pi.prototype.type="DocumentFragment";Pi.prototype.nodeType=11;Pi.prototype.nodeName="#document-fragment";Pi.prototype.appendChild=Y3.prototype.appendChild;Pi.prototype.replaceChild=Y3.prototype.replaceChild;Pi.prototype.removeChild=Y3.prototype.removeChild;Pi.prototype.toString=function(){return this.childNodes.map(function(t){return String(t)}).join("")}});var G7=Tt((jU,I7)=>{I7.exports=J3;function J3(e){}J3.prototype.initEvent=function(t,a,n){this.type=t,this.bubbles=a,this.cancelable=n};J3.prototype.preventDefault=function(){}});var K7=Tt((qU,X7)=>{var Y_=U3(),J_=_7(),Q_=O7(),$c=V3(),Z_=U7(),$_=G7(),W_=I3(),P_=G3(),eF=X3();X7.exports=e9;function e9(){if(!(this instanceof e9))return new e9;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Is=e9.prototype;Is.createTextNode=function(t){return new Q_(t,this)};Is.createElementNS=function(t,a){var n=t===null?null:String(t);return new $c(a,this,n)};Is.createElement=function(t){return new $c(t,this)};Is.createDocumentFragment=function(){return new Z_(this)};Is.createEvent=function(t){return new $_(t)};Is.createComment=function(t){return new J_(t,this)};Is.getElementById=function(t){t=String(t);var a=Y_(this.childNodes,function(n){if(String(n.id)===t)return n});return a||null};Is.getElementsByClassName=$c.prototype.getElementsByClassName;Is.getElementsByTagName=$c.prototype.getElementsByTagName;Is.contains=$c.prototype.contains;Is.removeEventListener=eF;Is.addEventListener=P_;Is.dispatchEvent=W_});var V7=Tt((vU,L7)=>{var tF=K7();L7.exports=new tF});var Q3=Tt((kU,J7)=>{var Y7=typeof global<"u"?global:typeof window<"u"?window:{},aF=V7(),Wc;if(typeof document<"u")Wc=document;else if(Wc=Y7["__GLOBAL_DOCUMENT_CACHE@4"],!Wc)Wc=Y7["__GLOBAL_DOCUMENT_CACHE@4"]=aF;J7.exports=Wc});var Q7=Tt((AU,Y0)=>{function Z3(){return Y0.exports=Z3=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Y0.exports.__esModule=!0,Y0.exports.default=Y0.exports,Z3.apply(null,arguments)}Y0.exports=Z3,Y0.exports.__esModule=!0,Y0.exports.default=Y0.exports});var $7=Tt((yU,Z7)=>{Z7.exports=sF;var nF=Object.prototype.toString;function sF(e){if(!e)return!1;var t=nF.call(e);return t==="[object Function]"||typeof e==="function"&&t!=="[object RegExp]"||typeof window<"u"&&(e===window.setTimeout||e===window.alert||e===window.confirm||e===window.prompt)}});var eb=Tt((SU,P7)=>{function iF(e,t){var a=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(a)return(a=a.call(e)).next.bind(a);if(Array.isArray(e)||(a=fF(e))||t&&e&&typeof e.length==="number"){if(a)e=a;var n=0;return function(){if(n>=e.length)return{done:!0};return{done:!1,value:e[n++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fF(e,t){if(!e)return;if(typeof e==="string")return W7(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);if(a==="Object"&&e.constructor)a=e.constructor.name;if(a==="Map"||a==="Set")return Array.from(e);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return W7(e,t)}function W7(e,t){if(t==null||t>e.length)t=e.length;for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}var lF=function(){function e(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var t=e.prototype;return t.getIsEnabled=function(){return this.enabled_},t.enable=function(){this.enabled_=!0},t.disable=function(){this.enabled_=!1},t.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},t.addInterceptor=function(n,s){if(!this.typeToInterceptorsMap_.has(n))this.typeToInterceptorsMap_.set(n,new Set);var i=this.typeToInterceptorsMap_.get(n);if(i.has(s))return!1;return i.add(s),!0},t.removeInterceptor=function(n,s){var i=this.typeToInterceptorsMap_.get(n);if(i&&i.has(s))return i.delete(s),!0;return!1},t.clearInterceptorsByType=function(n){var s=this.typeToInterceptorsMap_.get(n);if(!s)return!1;return this.typeToInterceptorsMap_.delete(n),this.typeToInterceptorsMap_.set(n,new Set),!0},t.clear=function(){if(!this.typeToInterceptorsMap_.size)return!1;return this.typeToInterceptorsMap_=new Map,!0},t.getForType=function(n){return this.typeToInterceptorsMap_.get(n)||new Set},t.execute=function(n,s){var i=this.getForType(n);for(var f=iF(i),l;!(l=f()).done;){var c=l.value;try{s=c(s)}catch(h){}}return s},e}();P7.exports=lF});var ab=Tt((CU,tb)=>{var rF=function(){function e(){this.maxAttempts_=1,this.delayFactor_=0.1,this.fuzzFactor_=0.1,this.initialDelay_=1000,this.enabled_=!1}var t=e.prototype;return t.getIsEnabled=function(){return this.enabled_},t.enable=function(){this.enabled_=!0},t.disable=function(){this.enabled_=!1},t.reset=function(){this.maxAttempts_=1,this.delayFactor_=0.1,this.fuzzFactor_=0.1,this.initialDelay_=1000,this.enabled_=!1},t.getMaxAttempts=function(){return this.maxAttempts_},t.setMaxAttempts=function(n){this.maxAttempts_=n},t.getDelayFactor=function(){return this.delayFactor_},t.setDelayFactor=function(n){this.delayFactor_=n},t.getFuzzFactor=function(){return this.fuzzFactor_},t.setFuzzFactor=function(n){this.fuzzFactor_=n},t.getInitialDelay=function(){return this.initialDelay_},t.setInitialDelay=function(n){this.initialDelay_=n},t.createRetry=function(n){var s=n===void 0?{}:n,i=s.maxAttempts,f=s.delayFactor,l=s.fuzzFactor,c=s.initialDelay;return new oF({maxAttempts:i||this.maxAttempts_,delayFactor:f||this.delayFactor_,fuzzFactor:l||this.fuzzFactor_,initialDelay:c||this.initialDelay_})},e}(),oF=function(){function e(a){this.maxAttempts_=a.maxAttempts,this.delayFactor_=a.delayFactor,this.fuzzFactor_=a.fuzzFactor,this.currentDelay_=a.initialDelay,this.currentAttempt_=1}var t=e.prototype;return t.moveToNextAttempt=function(){this.currentAttempt_++;var n=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+n},t.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},t.getCurrentDelay=function(){return this.currentDelay_},t.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},t.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},t.getCurrentFuzzedDelay=function(){var n=this.getCurrentMinPossibleDelay(),s=this.getCurrentMaxPossibleDelay();return n+Math.random()*(s-n)},e}();tb.exports=rF});var sb=Tt((_U,nb)=>{var cF=Wi(),hF=function(t,a){if(a===void 0)a=!1;return function(n,s,i){if(n){t(n);return}if(s.statusCode>=400&&s.statusCode<=599){var f=i;if(a)if(cF.TextDecoder){var l=uF(s.headers&&s.headers["content-type"]);try{f=new TextDecoder(l).decode(i)}catch(c){}}else f=String.fromCharCode.apply(null,new Uint8Array(i));t({cause:f});return}t(null,i)}};function uF(e){if(e===void 0)e="";return e.toLowerCase().split(";").reduce(function(t,a){var n=a.split("="),s=n[0],i=n[1];if(s.trim()==="charset")return i.trim();return t},"utf-8")}nb.exports=hF});var rb=Tt((FU,W3)=>{var ib=Wi(),mF=Q7(),gF=$7(),fb=eb(),pF=ab();Ka.httpHandler=sb();Ka.requestInterceptorsStorage=new fb;Ka.responseInterceptorsStorage=new fb;Ka.retryManager=new pF;var bF=function(t){var a={};if(!t)return a;return t.trim().split(`
3
+ `).forEach(function(n){var s=n.indexOf(":"),i=n.slice(0,s).trim().toLowerCase(),f=n.slice(s+1).trim();if(typeof a[i]>"u")a[i]=f;else if(Array.isArray(a[i]))a[i].push(f);else a[i]=[a[i],f]}),a};W3.exports=Ka;W3.exports.default=Ka;Ka.XMLHttpRequest=ib.XMLHttpRequest||qF;Ka.XDomainRequest="withCredentials"in new Ka.XMLHttpRequest?Ka.XMLHttpRequest:ib.XDomainRequest;wF(["get","put","post","patch","head","delete"],function(e){Ka[e==="delete"?"del":e]=function(t,a,n){return a=lb(t,a,n),a.method=e.toUpperCase(),$3(a)}});function wF(e,t){for(var a=0;a<e.length;a++)t(e[a])}function dF(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function lb(e,t,a){var n=e;if(gF(t)){if(a=t,typeof e==="string")n={uri:e}}else n=mF({},t,{uri:e});return n.callback=a,n}function Ka(e,t,a){return t=lb(e,t,a),$3(t)}function $3(e){if(typeof e.callback>"u")throw Error("callback argument missing");if(e.requestType&&Ka.requestInterceptorsStorage.getIsEnabled()){var t={uri:e.uri||e.url,headers:e.headers||{},body:e.body,metadata:e.metadata||{},retry:e.retry,timeout:e.timeout},a=Ka.requestInterceptorsStorage.execute(e.requestType,t);e.uri=a.uri,e.headers=a.headers,e.body=a.body,e.metadata=a.metadata,e.retry=a.retry,e.timeout=a.timeout}var n=!1,s=function(H,N,x){if(!n)n=!0,e.callback(H,N,x)};function i(){if(h.readyState===4&&!Ka.responseInterceptorsStorage.getIsEnabled())setTimeout(c,0)}function f(){var M=void 0;if(h.response)M=h.response;else M=h.responseText||jF(h);if(y)try{M=JSON.parse(M)}catch(H){}return M}function l(M){if(clearTimeout(O),clearTimeout(e.retryTimeout),!(M instanceof Error))M=Error(""+(M||"Unknown XMLHttpRequest Error"));if(M.statusCode=0,!g&&Ka.retryManager.getIsEnabled()&&e.retry&&e.retry.shouldRetry()){e.retryTimeout=setTimeout(function(){e.retry.moveToNextAttempt(),e.xhr=h,$3(e)},e.retry.getCurrentFuzzedDelay());return}if(e.requestType&&Ka.responseInterceptorsStorage.getIsEnabled()){var H={headers:T.headers||{},body:T.body,responseUrl:h.responseURL,responseType:h.responseType},N=Ka.responseInterceptorsStorage.execute(e.requestType,H);T.body=N.body,T.headers=N.headers}return s(M,T)}function c(){if(g)return;var M;if(clearTimeout(O),clearTimeout(e.retryTimeout),e.useXDR&&h.status===void 0)M=200;else M=h.status===1223?204:h.status;var H=T,N=null;if(M!==0){if(H={body:f(),statusCode:M,method:d,headers:{},url:b,rawRequest:h},h.getAllResponseHeaders)H.headers=bF(h.getAllResponseHeaders())}else N=Error("Internal XMLHttpRequest Error");if(e.requestType&&Ka.responseInterceptorsStorage.getIsEnabled()){var x={headers:H.headers||{},body:H.body,responseUrl:h.responseURL,responseType:h.responseType},z=Ka.responseInterceptorsStorage.execute(e.requestType,x);H.body=z.body,H.headers=z.headers}return s(N,H,H.body)}var h=e.xhr||null;if(!h)if(e.cors||e.useXDR)h=new Ka.XDomainRequest;else h=new Ka.XMLHttpRequest;var u,g,b=h.url=e.uri||e.url,d=h.method=e.method||"GET",j=e.body||e.data,A=h.headers=e.headers||{},C=!!e.sync,y=!1,O,T={body:void 0,headers:{},statusCode:0,method:d,url:b,rawRequest:h};if("json"in e&&e.json!==!1){if(y=!0,A.accept||A.Accept||(A.Accept="application/json"),d!=="GET"&&d!=="HEAD")A["content-type"]||A["Content-Type"]||(A["Content-Type"]="application/json"),j=JSON.stringify(e.json===!0?j:e.json)}if(h.onreadystatechange=i,h.onload=c,h.onerror=l,h.onprogress=function(){},h.onabort=function(){g=!0,clearTimeout(e.retryTimeout)},h.ontimeout=l,h.open(d,b,!C,e.username,e.password),!C)h.withCredentials=!!e.withCredentials;if(!C&&e.timeout>0)O=setTimeout(function(){if(g)return;g=!0,h.abort("timeout");var M=Error("XMLHttpRequest timeout");M.code="ETIMEDOUT",l(M)},e.timeout);if(h.setRequestHeader){for(u in A)if(A.hasOwnProperty(u))h.setRequestHeader(u,A[u])}else if(e.headers&&!dF(e.headers))throw Error("Headers cannot be set on an XDomainRequest object");if("responseType"in e)h.responseType=e.responseType;if("beforeSend"in e&&typeof e.beforeSend==="function")e.beforeSend(h);return h.send(j||null),h}function jF(e){try{if(e.responseType==="document")return e.responseXML;var t=e.responseXML&&e.responseXML.documentElement.nodeName==="parsererror";if(e.responseType===""&&!t)return e.responseXML}catch(a){}return null}function qF(){}});var pb=Tt((OU,gb)=>{var ob=Q3(),e6=Object.create||function(){function e(){}return function(t){if(arguments.length!==1)throw Error("Object.create shim only accepts one parameter.");return e.prototype=t,new e}}();function Gs(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}Gs.prototype=e6(Error.prototype);Gs.prototype.constructor=Gs;Gs.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function t6(e){function t(n,s,i,f){return(n|0)*3600+(s|0)*60+(i|0)+(f|0)/1000}var a=e.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);if(!a)return null;if(a[3])return t(a[1],a[2],a[3].replace(":",""),a[4]);else if(a[1]>59)return t(a[1],a[2],0,a[4]);else return t(0,a[1],a[2],a[4])}function eh(){this.values=e6(null)}eh.prototype={set:function(e,t){if(!this.get(e)&&t!=="")this.values[e]=t},get:function(e,t,a){if(a)return this.has(e)?this.values[e]:t[a];return this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,a){for(var n=0;n<a.length;++n)if(t===a[n]){this.set(e,t);break}},integer:function(e,t){if(/^-?\d+$/.test(t))this.set(e,parseInt(t,10))},percent:function(e,t){var a;if(a=t.match(/^([\d]{1,3})(\.[\d]*)?%$/)){if(t=parseFloat(t),t>=0&&t<=100)return this.set(e,t),!0}return!1}};function Pc(e,t,a,n){var s=n?e.split(n):[e];for(var i in s){if(typeof s[i]!=="string")continue;var f=s[i].split(a);if(f.length!==2)continue;var l=f[0].trim(),c=f[1].trim();t(l,c)}}function vF(e,t,a){var n=e;function s(){var l=t6(e);if(l===null)throw new Gs(Gs.Errors.BadTimeStamp,"Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),l}function i(l,c){var h=new eh;Pc(l,function(u,g){switch(u){case"region":for(var b=a.length-1;b>=0;b--)if(a[b].id===g){h.set(u,a[b].region);break}break;case"vertical":h.alt(u,g,["rl","lr"]);break;case"line":var d=g.split(","),j=d[0];if(h.integer(u,j),h.percent(u,j)&&h.set("snapToLines",!1),h.alt(u,j,["auto"]),d.length===2)h.alt("lineAlign",d[1],["start","center","end"]);break;case"position":if(d=g.split(","),h.percent(u,d[0]),d.length===2)h.alt("positionAlign",d[1],["start","center","end"]);break;case"size":h.percent(u,g);break;case"align":h.alt(u,g,["start","center","end","left","right"]);break}},/:/,/\s/),c.region=h.get("region",null),c.vertical=h.get("vertical","");try{c.line=h.get("line","auto")}catch(u){}c.lineAlign=h.get("lineAlign","start"),c.snapToLines=h.get("snapToLines",!0),c.size=h.get("size",100);try{c.align=h.get("align","center")}catch(u){c.align=h.get("align","middle")}try{c.position=h.get("position","auto")}catch(u){c.position=h.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},c.align)}c.positionAlign=h.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},c.align)}function f(){e=e.replace(/^\s+/,"")}if(f(),t.startTime=s(),f(),e.substr(0,3)!=="-->")throw new Gs(Gs.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+n);e=e.substr(3),f(),t.endTime=s(),f(),i(e,t)}var P3=ob.createElement&&ob.createElement("textarea"),kF={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},cb={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},AF={v:"title",lang:"lang"},hb={rt:"ruby"};function mb(e,t){function a(){if(!t)return null;function j(C){return t=t.substr(C.length),C}var A=t.match(/^([^<]*)(<[^>]*>?)?/);return j(A[1]?A[1]:A[2])}function n(j){return P3.innerHTML=j,j=P3.textContent,P3.textContent="",j}function s(j,A){return!hb[A.localName]||hb[A.localName]===j.localName}function i(j,A){var C=kF[j];if(!C)return null;var y=e.document.createElement(C),O=AF[j];if(O&&A)y[O]=A.trim();return y}var f=e.document.createElement("div"),l=f,c,h=[];while((c=a())!==null){if(c[0]==="<"){if(c[1]==="/"){if(h.length&&h[h.length-1]===c.substr(2).replace(">",""))h.pop(),l=l.parentNode;continue}var u=t6(c.substr(1,c.length-2)),g;if(u){g=e.document.createProcessingInstruction("timestamp",u),l.appendChild(g);continue}var b=c.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!b)continue;if(g=i(b[1],b[3]),!g)continue;if(!s(l,g))continue;if(b[2]){var d=b[2].split(".");d.forEach(function(j){var A=/^bg_/.test(j),C=A?j.slice(3):j;if(cb.hasOwnProperty(C)){var y=A?"background-color":"color",O=cb[C];g.style[y]=O}}),g.className=d.join(" ")}h.push(b[1]),l.appendChild(g),l=g;continue}l.appendChild(e.document.createTextNode(n(c)))}return f}var ub=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function yF(e){for(var t=0;t<ub.length;t++){var a=ub[t];if(e>=a[0]&&e<=a[1])return!0}return!1}function SF(e){var t=[],a="",n;if(!e||!e.childNodes)return"ltr";function s(l,c){for(var h=c.childNodes.length-1;h>=0;h--)l.push(c.childNodes[h])}function i(l){if(!l||!l.length)return null;var c=l.pop(),h=c.textContent||c.innerText;if(h){var u=h.match(/^.*(\n|\r)/);if(u)return l.length=0,u[0];return h}if(c.tagName==="ruby")return i(l);if(c.childNodes)return s(l,c),i(l)}s(t,e);while(a=i(t))for(var f=0;f<a.length;f++)if(n=a.charCodeAt(f),yF(n))return"rtl";return"ltr"}function CF(e){if(typeof e.line==="number"&&(e.snapToLines||e.line>=0&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;var t=e.track,a=t.textTrackList,n=0;for(var s=0;s<a.length&&a[s]!==t;s++)if(a[s].mode==="showing")n++;return++n*-1}function a9(){}a9.prototype.applyStyles=function(e,t){t=t||this.div;for(var a in e)if(e.hasOwnProperty(a))t.style[a]=e[a]};a9.prototype.formatStyle=function(e,t){return e===0?0:e+t};function t9(e,t,a){a9.call(this),this.cue=t,this.cueDiv=mb(e,t.text);var n={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:t.vertical===""?"horizontal-tb":t.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(n,this.cueDiv),this.div=e.document.createElement("div"),n={direction:SF(this.cueDiv),writingMode:t.vertical===""?"horizontal-tb":t.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:t.align==="middle"?"center":t.align,font:a.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(n),this.div.appendChild(this.cueDiv);var s=0;switch(t.positionAlign){case"start":case"line-left":s=t.position;break;case"center":s=t.position-t.size/2;break;case"end":case"line-right":s=t.position-t.size;break}if(t.vertical==="")this.applyStyles({left:this.formatStyle(s,"%"),width:this.formatStyle(t.size,"%")});else this.applyStyles({top:this.formatStyle(s,"%"),height:this.formatStyle(t.size,"%")});this.move=function(i){this.applyStyles({top:this.formatStyle(i.top,"px"),bottom:this.formatStyle(i.bottom,"px"),left:this.formatStyle(i.left,"px"),right:this.formatStyle(i.right,"px"),height:this.formatStyle(i.height,"px"),width:this.formatStyle(i.width,"px")})}}t9.prototype=e6(a9.prototype);t9.prototype.constructor=t9;function Wn(e){var t,a,n,s;if(e.div){a=e.div.offsetHeight,n=e.div.offsetWidth,s=e.div.offsetTop;var i=(i=e.div.childNodes)&&(i=i[0])&&i.getClientRects&&i.getClientRects();e=e.div.getBoundingClientRect(),t=i?Math.max(i[0]&&i[0].height||0,e.height/i.length):0}this.left=e.left,this.right=e.right,this.top=e.top||s,this.height=e.height||a,this.bottom=e.bottom||s+(e.height||a),this.width=e.width||n,this.lineHeight=t!==void 0?t:e.lineHeight}Wn.prototype.move=function(e,t){switch(t=t!==void 0?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t;break}};Wn.prototype.overlaps=function(e){return this.left<e.right&&this.right>e.left&&this.top<e.bottom&&this.bottom>e.top};Wn.prototype.overlapsAny=function(e){for(var t=0;t<e.length;t++)if(this.overlaps(e[t]))return!0;return!1};Wn.prototype.within=function(e){return this.top>=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right};Wn.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.left<e.left;case"-x":return this.right>e.right;case"+y":return this.top<e.top;case"-y":return this.bottom>e.bottom}};Wn.prototype.intersectPercentage=function(e){var t=Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left)),a=Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top)),n=t*a;return n/(this.height*this.width)};Wn.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}};Wn.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,a=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,n=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e;var s={left:e.left,right:e.right,top:e.top||n,height:e.height||t,bottom:e.bottom||n+(e.height||t),width:e.width||a};return s};function _F(e,t,a,n){function s(C,y){var O,T=new Wn(C),M=1;for(var H=0;H<y.length;H++){while(C.overlapsOppositeAxis(a,y[H])||C.within(a)&&C.overlapsAny(n))C.move(y[H]);if(C.within(a))return C;var N=C.intersectPercentage(a);if(M>N)O=new Wn(C),M=N;C=new Wn(T)}return O||T}var i=new Wn(t),f=t.cue,l=CF(f),c=[];if(f.snapToLines){var h;switch(f.vertical){case"":c=["+y","-y"],h="height";break;case"rl":c=["+x","-x"],h="width";break;case"lr":c=["-x","+x"],h="width";break}var u=i.lineHeight,g=u*Math.round(l),b=a[h]+u,d=c[0];if(Math.abs(g)>b)g=g<0?-1:1,g*=Math.ceil(b/u)*u;if(l<0)g+=f.vertical===""?a.height:a.width,c=c.reverse();i.move(d,g)}else{var j=i.lineHeight/a.height*100;switch(f.lineAlign){case"center":l-=j/2;break;case"end":l-=j;break}switch(f.vertical){case"":t.applyStyles({top:t.formatStyle(l,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(l,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(l,"%")});break}c=["+y","-x","+x","-y"],i=new Wn(t)}var A=s(i,c);t.move(A.toCSSCompatValues(a))}function x1(){}x1.StringDecoder=function(){return{decode:function(e){if(!e)return"";if(typeof e!=="string")throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};x1.convertCueToDOMTree=function(e,t){if(!e||!t)return null;return mb(e,t)};var FF=0.05,OF="sans-serif",BF="1.5%";x1.processCues=function(e,t,a){if(!e||!t||!a)return null;while(a.firstChild)a.removeChild(a.firstChild);var n=e.document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.right="0",n.style.top="0",n.style.bottom="0",n.style.margin=BF,a.appendChild(n);function s(u){for(var g=0;g<u.length;g++)if(u[g].hasBeenReset||!u[g].displayState)return!0;return!1}if(!s(t)){for(var i=0;i<t.length;i++)n.appendChild(t[i].displayState);return}var f=[],l=Wn.getSimpleBoxPosition(n),c=Math.round(l.height*FF*100)/100,h={font:c+"px "+OF};(function(){var u,g;for(var b=0;b<t.length;b++)g=t[b],u=new t9(e,g,h),n.appendChild(u.div),_F(e,u,l,f),g.displayState=u.div,f.push(Wn.getSimpleBoxPosition(u))})()};x1.Parser=function(e,t,a){if(!a)a=t,t={};if(!t)t={};this.window=e,this.vttjs=t,this.state="INITIAL",this.buffer="",this.decoder=a||new TextDecoder("utf8"),this.regionList=[]};x1.Parser.prototype={reportOrThrowError:function(e){if(e instanceof Gs)this.onparsingerror&&this.onparsingerror(e);else throw e},parse:function(e){var t=this;if(e)t.buffer+=t.decoder.decode(e,{stream:!0});function a(){var u=t.buffer,g=0;while(g<u.length&&u[g]!=="\r"&&u[g]!==`
4
+ `)++g;var b=u.substr(0,g);if(u[g]==="\r")++g;if(u[g]===`
5
+ `)++g;return t.buffer=u.substr(g),b}function n(u){var g=new eh;if(Pc(u,function(d,j){switch(d){case"id":g.set(d,j);break;case"width":g.percent(d,j);break;case"lines":g.integer(d,j);break;case"regionanchor":case"viewportanchor":var A=j.split(",");if(A.length!==2)break;var C=new eh;if(C.percent("x",A[0]),C.percent("y",A[1]),!C.has("x")||!C.has("y"))break;g.set(d+"X",C.get("x")),g.set(d+"Y",C.get("y"));break;case"scroll":g.alt(d,j,["up"]);break}},/=/,/\s/),g.has("id")){var b=new(t.vttjs.VTTRegion||t.window.VTTRegion);b.width=g.get("width",100),b.lines=g.get("lines",3),b.regionAnchorX=g.get("regionanchorX",0),b.regionAnchorY=g.get("regionanchorY",100),b.viewportAnchorX=g.get("viewportanchorX",0),b.viewportAnchorY=g.get("viewportanchorY",100),b.scroll=g.get("scroll",""),t.onregion&&t.onregion(b),t.regionList.push({id:g.get("id"),region:b})}}function s(u){var g=new eh;Pc(u,function(b,d){switch(b){case"MPEGT":g.integer(b+"S",d);break;case"LOCA":g.set(b+"L",t6(d));break}},/[^\d]:/,/,/),t.ontimestampmap&&t.ontimestampmap({MPEGTS:g.get("MPEGTS"),LOCAL:g.get("LOCAL")})}function i(u){if(u.match(/X-TIMESTAMP-MAP/))Pc(u,function(g,b){switch(g){case"X-TIMESTAMP-MAP":s(b);break}},/=/);else Pc(u,function(g,b){switch(g){case"Region":n(b);break}},/:/)}try{var f;if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;f=a();var l=f.match(/^WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Gs(Gs.Errors.BadSignature);t.state="HEADER"}var c=!1;while(t.buffer){if(!/\r\n|\n/.test(t.buffer))return this;if(!c)f=a();else c=!1;switch(t.state){case"HEADER":if(/:/.test(f))i(f);else if(!f)t.state="ID";continue;case"NOTE":if(!f)t.state="ID";continue;case"ID":if(/^NOTE($|[ \t])/.test(f)){t.state="NOTE";break}if(!f)continue;t.cue=new(t.vttjs.VTTCue||t.window.VTTCue)(0,0,"");try{t.cue.align="center"}catch(u){t.cue.align="middle"}if(t.state="CUE",f.indexOf("-->")===-1){t.cue.id=f;continue}case"CUE":try{vF(f,t.cue,t.regionList)}catch(u){t.reportOrThrowError(u),t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var h=f.indexOf("-->")!==-1;if(!f||h&&(c=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue.text)t.cue.text+=`
6
+ `;t.cue.text+=f.replace(/\u2028/g,`
7
+ `).replace(/u2029/g,`
8
+ `);continue;case"BADCUE":if(!f)t.state="ID";continue}}}catch(u){if(t.reportOrThrowError(u),t.state==="CUETEXT"&&t.cue&&t.oncue)t.oncue(t.cue);t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var e=this;try{if(e.buffer+=e.decoder.decode(),e.cue||e.state==="HEADER")e.buffer+=`
9
+
10
+ `,e.parse();if(e.state==="INITIAL")throw new Gs(Gs.Errors.BadSignature)}catch(t){e.reportOrThrowError(t)}return e.onflush&&e.onflush(),this}};gb.exports=x1});var db=Tt((BU,wb)=>{var TF="auto",HF={"":1,lr:1,rl:1},MF={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function DF(e){if(typeof e!=="string")return!1;var t=HF[e.toLowerCase()];return t?e.toLowerCase():!1}function a6(e){if(typeof e!=="string")return!1;var t=MF[e.toLowerCase()];return t?e.toLowerCase():!1}function bb(e,t,a){this.hasBeenReset=!1;var n="",s=!1,i=e,f=t,l=a,c=null,h="",u=!0,g="auto",b="start",d="auto",j="auto",A=100,C="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return n},set:function(y){n=""+y}},pauseOnExit:{enumerable:!0,get:function(){return s},set:function(y){s=!!y}},startTime:{enumerable:!0,get:function(){return i},set:function(y){if(typeof y!=="number")throw TypeError("Start time must be set to a number.");i=y,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return f},set:function(y){if(typeof y!=="number")throw TypeError("End time must be set to a number.");f=y,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return l},set:function(y){l=""+y,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return c},set:function(y){c=y,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return h},set:function(y){var O=DF(y);if(O===!1)throw SyntaxError("Vertical: an invalid or illegal direction string was specified.");h=O,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return u},set:function(y){u=!!y,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return g},set:function(y){if(typeof y!=="number"&&y!==TF)throw SyntaxError("Line: an invalid number or illegal string was specified.");g=y,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return b},set:function(y){var O=a6(y);if(!O)console.warn("lineAlign: an invalid or illegal string was specified.");else b=O,this.hasBeenReset=!0}},position:{enumerable:!0,get:function(){return d},set:function(y){if(y<0||y>100)throw Error("Position must be between 0 and 100.");d=y,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return j},set:function(y){var O=a6(y);if(!O)console.warn("positionAlign: an invalid or illegal string was specified.");else j=O,this.hasBeenReset=!0}},size:{enumerable:!0,get:function(){return A},set:function(y){if(y<0||y>100)throw Error("Size must be between 0 and 100.");A=y,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return C},set:function(y){var O=a6(y);if(!O)throw SyntaxError("align: an invalid or illegal alignment string was specified.");C=O,this.hasBeenReset=!0}}}),this.displayState=void 0}bb.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};wb.exports=bb});var qb=Tt((TU,jb)=>{var xF={"":!0,up:!0};function RF(e){if(typeof e!=="string")return!1;var t=xF[e.toLowerCase()];return t?e.toLowerCase():!1}function th(e){return typeof e==="number"&&(e>=0&&e<=100)}function NF(){var e=100,t=3,a=0,n=100,s=0,i=100,f="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(l){if(!th(l))throw Error("Width must be between 0 and 100.");e=l}},lines:{enumerable:!0,get:function(){return t},set:function(l){if(typeof l!=="number")throw TypeError("Lines must be set to a number.");t=l}},regionAnchorY:{enumerable:!0,get:function(){return n},set:function(l){if(!th(l))throw Error("RegionAnchorX must be between 0 and 100.");n=l}},regionAnchorX:{enumerable:!0,get:function(){return a},set:function(l){if(!th(l))throw Error("RegionAnchorY must be between 0 and 100.");a=l}},viewportAnchorY:{enumerable:!0,get:function(){return i},set:function(l){if(!th(l))throw Error("ViewportAnchorY must be between 0 and 100.");i=l}},viewportAnchorX:{enumerable:!0,get:function(){return s},set:function(l){if(!th(l))throw Error("ViewportAnchorX must be between 0 and 100.");s=l}},scroll:{enumerable:!0,get:function(){return f},set:function(l){var c=RF(l);if(c===!1)console.warn("Scroll: an invalid or illegal string was specified.");else f=c}}})}jb.exports=NF});var kb=Tt((HU,vb)=>{var J0=Wi(),mr=vb.exports={WebVTT:pb(),VTTCue:db(),VTTRegion:qb()};J0.vttjs=mr;J0.WebVTT=mr.WebVTT;var{VTTCue:EF,VTTRegion:zF}=mr,UF=J0.VTTCue,IF=J0.VTTRegion;mr.shim=function(){J0.VTTCue=EF,J0.VTTRegion=zF};mr.restore=function(){J0.VTTCue=UF,J0.VTTRegion=IF};if(!J0.VTTCue)mr.shim()});var nh=Tt((aO)=>{function eO(e,t,a){if(a===void 0)a=Array.prototype;if(e&&typeof a.find==="function")return a.find.call(e,t);for(var n=0;n<e.length;n++)if(Object.prototype.hasOwnProperty.call(e,n)){var s=e[n];if(t.call(void 0,s,n,e))return s}}function p6(e,t){if(t===void 0)t=Object;return t&&typeof t.freeze==="function"?t.freeze(e):e}function tO(e,t){if(e===null||typeof e!=="object")throw TypeError("target is not an object");for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a))e[a]=t[a];return e}var Db=p6({HTML:"text/html",isHTML:function(e){return e===Db.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),xb=p6({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===xb.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});aO.assign=tO;aO.find=eO;aO.freeze=p6;aO.MIME_TYPE=Db;aO.NAMESPACE=xb});var _6=Tt((kO)=>{var Xb=nh(),e0=Xb.find,sh=Xb.NAMESPACE;function rO(e){return e!==""}function oO(e){return e?e.split(/[\t\n\f\r ]+/).filter(rO):[]}function cO(e,t){if(!e.hasOwnProperty(t))e[t]=!0;return e}function Rb(e){if(!e)return[];var t=oO(e);return Object.keys(t.reduce(cO,{}))}function hO(e){return function(t){return e&&e.indexOf(t)!==-1}}function fh(e,t){for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a))t[a]=e[a]}function ds(e,t){var a=e.prototype;if(!(a instanceof t)){let s=function(){};var n=s;s.prototype=t.prototype,s=new s,fh(a,s),e.prototype=a=s}if(a.constructor!=e){if(typeof e!="function")console.error("unknown Class:"+e);a.constructor=e}}var js={},oi=js.ELEMENT_NODE=1,U1=js.ATTRIBUTE_NODE=2,l9=js.TEXT_NODE=3,Kb=js.CDATA_SECTION_NODE=4,Lb=js.ENTITY_REFERENCE_NODE=5,uO=js.ENTITY_NODE=6,b6=js.PROCESSING_INSTRUCTION_NODE=7,w6=js.COMMENT_NODE=8,Vb=js.DOCUMENT_NODE=9,Yb=js.DOCUMENT_TYPE_NODE=10,Q0=js.DOCUMENT_FRAGMENT_NODE=11,mO=js.NOTATION_NODE=12,Kn={},wn={},YU=Kn.INDEX_SIZE_ERR=(wn[1]="Index size error",1),JU=Kn.DOMSTRING_SIZE_ERR=(wn[2]="DOMString size error",2),ws=Kn.HIERARCHY_REQUEST_ERR=(wn[3]="Hierarchy request error",3),QU=Kn.WRONG_DOCUMENT_ERR=(wn[4]="Wrong document",4),gO=Kn.INVALID_CHARACTER_ERR=(wn[5]="Invalid character",5),ZU=Kn.NO_DATA_ALLOWED_ERR=(wn[6]="No data allowed",6),$U=Kn.NO_MODIFICATION_ALLOWED_ERR=(wn[7]="No modification allowed",7),Jb=Kn.NOT_FOUND_ERR=(wn[8]="Not found",8),WU=Kn.NOT_SUPPORTED_ERR=(wn[9]="Not supported",9),Nb=Kn.INUSE_ATTRIBUTE_ERR=(wn[10]="Attribute in use",10),z1=Kn.INVALID_STATE_ERR=(wn[11]="Invalid state",11),PU=Kn.SYNTAX_ERR=(wn[12]="Syntax error",12),eI=Kn.INVALID_MODIFICATION_ERR=(wn[13]="Invalid modification",13),tI=Kn.NAMESPACE_ERR=(wn[14]="Invalid namespace",14),aI=Kn.INVALID_ACCESS_ERR=(wn[15]="Invalid access",15);function na(e,t){if(t instanceof Error)var a=t;else if(a=this,Error.call(this,wn[e]),this.message=wn[e],Error.captureStackTrace)Error.captureStackTrace(this,na);if(a.code=e,t)this.message=this.message+": "+t;return a}na.prototype=Error.prototype;fh(Kn,na);function Z0(){}Z0.prototype={length:0,item:function(e){return e>=0&&e<this.length?this[e]:null},toString:function(e,t,a){var n=!!a&&!!a.requireWellFormed;for(var s=[],i=0;i<this.length;i++)C6(this[i],s,e,t,null,n);return s.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}};function I1(e,t){this._node=e,this._refresh=t,d6(this)}function d6(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var a=e._refresh(e._node);if(fw(e,"length",a.length),!e.$$length||a.length<e.$$length){for(var n=a.length;n in e;n++)if(Object.prototype.hasOwnProperty.call(e,n))delete e[n]}fh(a,e),e._inc=t}}I1.prototype.item=function(e){return d6(this),this[e]||null};ds(I1,Z0);function r9(){}function Qb(e,t){var a=e.length;while(a--)if(e[a]===t)return a}function Eb(e,t,a,n){if(n)t[Qb(t,n)]=a;else t[t.length++]=a;if(e){a.ownerElement=e;var s=e.ownerDocument;if(s)n&&Wb(s,e,n),pO(s,e,a)}}function zb(e,t,a){var n=Qb(t,a);if(n>=0){var s=t.length-1;while(n<s)t[n]=t[++n];if(t.length=s,e){var i=e.ownerDocument;if(i)Wb(i,e,a),a.ownerElement=null}}else throw new na(Jb,Error(e.tagName+"@"+a))}r9.prototype={length:0,item:Z0.prototype.item,getNamedItem:function(e){var t=this.length;while(t--){var a=this[t];if(a.nodeName==e)return a}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new na(Nb);var a=this.getNamedItem(e.nodeName);return Eb(this._ownerElement,this,e,a),a},setNamedItemNS:function(e){var t=e.ownerElement,a;if(t&&t!=this._ownerElement)throw new na(Nb);return a=this.getNamedItemNS(e.namespaceURI,e.localName),Eb(this._ownerElement,this,e,a),a},removeNamedItem:function(e){var t=this.getNamedItem(e);return zb(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var a=this.getNamedItemNS(e,t);return zb(this._ownerElement,this,a),a},getNamedItemNS:function(e,t){var a=this.length;while(a--){var n=this[a];if(n.localName==t&&n.namespaceURI==e)return n}return null}};function Zb(){}Zb.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,a){var n=new lh;if(n.implementation=this,n.childNodes=new Z0,n.doctype=a||null,a)n.appendChild(a);if(t){var s=n.createElementNS(e,t);n.appendChild(s)}return n},createDocumentType:function(e,t,a){var n=new u9;return n.name=e,n.nodeName=e,n.publicId=t||"",n.systemId=a||"",n}};function $t(){}$t.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return c9(this,e,t)},replaceChild:function(e,t){if(c9(this,e,t,ew),t)this.removeChild(t)},removeChild:function(e){return Pb(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(e){return iw(this.ownerDocument||this,this,e)},normalize:function(){bn(this,null,{enter:function(e){var t=e.firstChild;while(t){var a=t.nextSibling;if(a!==null&&a.nodeType===l9&&t.nodeType===l9)e.removeChild(a),t.appendData(a.data);else t=a}return!0}})},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){var t=this;while(t){var a=t._nsMap;if(a){for(var n in a)if(Object.prototype.hasOwnProperty.call(a,n)&&a[n]===e)return n}t=t.nodeType==U1?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){var t=this;while(t){var a=t._nsMap;if(a){if(Object.prototype.hasOwnProperty.call(a,e))return a[e]}t=t.nodeType==U1?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return t==null}};function $b(e){return e=="<"&&"&lt;"||e==">"&&"&gt;"||e=="&"&&"&amp;"||e=='"'&&"&quot;"||"&#"+e.charCodeAt()+";"}fh(js,$t);fh(js,$t.prototype);function o9(e,t){return bn(e,null,{enter:function(a){return t(a)?bn.STOP:!0}})===bn.STOP}function bn(e,t,a){var n=[{node:e,context:t,phase:bn.ENTER}];while(n.length>0){var s=n.pop();if(s.phase===bn.ENTER){var i=a.enter(s.node,s.context);if(i===bn.STOP)return bn.STOP;if(n.push({node:s.node,context:i,phase:bn.EXIT}),i===null||i===void 0)continue;var f=s.node.lastChild;while(f)n.push({node:f,context:i,phase:bn.ENTER}),f=f.previousSibling}else if(a.exit)a.exit(s.node,s.context)}}bn.STOP=Symbol("walkDOM.STOP");bn.ENTER=0;bn.EXIT=1;function lh(){this.ownerDocument=this}function pO(e,t,a){e&&e._inc++;var n=a.namespaceURI;if(n===sh.XMLNS)t._nsMap[a.prefix?a.localName:""]=a.value}function Wb(e,t,a,n){e&&e._inc++;var s=a.namespaceURI;if(s===sh.XMLNS)delete t._nsMap[a.prefix?a.localName:""]}function j6(e,t,a){if(e&&e._inc){e._inc++;var n=t.childNodes;if(a)n[n.length++]=a;else{var s=t.firstChild,i=0;while(s)n[i++]=s,s=s.nextSibling;n.length=i,delete n[n.length]}}}function Pb(e,t){var{previousSibling:a,nextSibling:n}=t;if(a)a.nextSibling=n;else e.firstChild=n;if(n)n.previousSibling=a;else e.lastChild=a;return t.parentNode=null,t.previousSibling=null,t.nextSibling=null,j6(e.ownerDocument,e),t}function bO(e){return e&&(e.nodeType===$t.DOCUMENT_NODE||e.nodeType===$t.DOCUMENT_FRAGMENT_NODE||e.nodeType===$t.ELEMENT_NODE)}function wO(e){return e&&(t0(e)||q6(e)||$0(e)||e.nodeType===$t.DOCUMENT_FRAGMENT_NODE||e.nodeType===$t.COMMENT_NODE||e.nodeType===$t.PROCESSING_INSTRUCTION_NODE)}function $0(e){return e&&e.nodeType===$t.DOCUMENT_TYPE_NODE}function t0(e){return e&&e.nodeType===$t.ELEMENT_NODE}function q6(e){return e&&e.nodeType===$t.TEXT_NODE}function Ub(e,t){var a=e.childNodes||[];if(e0(a,t0)||$0(t))return!1;var n=e0(a,$0);return!(t&&n&&a.indexOf(n)>a.indexOf(t))}function Ib(e,t){var a=e.childNodes||[];function n(i){return t0(i)&&i!==t}if(e0(a,n))return!1;var s=e0(a,$0);return!(t&&s&&a.indexOf(s)>a.indexOf(t))}function dO(e,t,a){if(!bO(e))throw new na(ws,"Unexpected parent node type "+e.nodeType);if(a&&a.parentNode!==e)throw new na(Jb,"child not in parent");if(!wO(t)||$0(t)&&e.nodeType!==$t.DOCUMENT_NODE)throw new na(ws,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function jO(e,t,a){var n=e.childNodes||[],s=t.childNodes||[];if(t.nodeType===$t.DOCUMENT_FRAGMENT_NODE){var i=s.filter(t0);if(i.length>1||e0(s,q6))throw new na(ws,"More than one element or text in fragment");if(i.length===1&&!Ub(e,a))throw new na(ws,"Element in fragment can not be inserted before doctype")}if(t0(t)){if(!Ub(e,a))throw new na(ws,"Only one element can be added and only after doctype")}if($0(t)){if(e0(n,$0))throw new na(ws,"Only one doctype is allowed");var f=e0(n,t0);if(a&&n.indexOf(f)<n.indexOf(a))throw new na(ws,"Doctype can only be inserted before an element");if(!a&&f)throw new na(ws,"Doctype can not be appended since element is present")}}function ew(e,t,a){var n=e.childNodes||[],s=t.childNodes||[];if(t.nodeType===$t.DOCUMENT_FRAGMENT_NODE){var i=s.filter(t0);if(i.length>1||e0(s,q6))throw new na(ws,"More than one element or text in fragment");if(i.length===1&&!Ib(e,a))throw new na(ws,"Element in fragment can not be inserted before doctype")}if(t0(t)){if(!Ib(e,a))throw new na(ws,"Only one element can be added and only after doctype")}if($0(t)){let c=function(h){return $0(h)&&h!==a};var l=c;if(e0(n,c))throw new na(ws,"Only one doctype is allowed");var f=e0(n,t0);if(a&&n.indexOf(f)<n.indexOf(a))throw new na(ws,"Doctype can only be inserted before an element")}}function c9(e,t,a,n){if(dO(e,t,a),e.nodeType===$t.DOCUMENT_NODE)(n||jO)(e,t,a);var s=t.parentNode;if(s)s.removeChild(t);if(t.nodeType===Q0){var i=t.firstChild;if(i==null)return t;var f=t.lastChild}else i=f=t;var l=a?a.previousSibling:e.lastChild;if(i.previousSibling=l,f.nextSibling=a,l)l.nextSibling=i;else e.firstChild=i;if(a==null)e.lastChild=f;else a.previousSibling=f;do{i.parentNode=e;var c=e.ownerDocument||e;ih(i,c)}while(i!==f&&(i=i.nextSibling));if(j6(e.ownerDocument||e,e),t.nodeType==Q0)t.firstChild=t.lastChild=null;return t}function ih(e,t){if(e.ownerDocument===t)return;if(e.ownerDocument=t,e.nodeType===oi&&e.attributes)for(var a=0;a<e.attributes.length;a++){var n=e.attributes.item(a);if(n)n.ownerDocument=t}var s=e.firstChild;while(s)ih(s,t),s=s.nextSibling}function qO(e,t){if(t.parentNode)t.parentNode.removeChild(t);if(t.parentNode=e,t.previousSibling=e.lastChild,t.nextSibling=null,t.previousSibling)t.previousSibling.nextSibling=t;else e.firstChild=t;e.lastChild=t,j6(e.ownerDocument,e,t);var a=e.ownerDocument||e;return ih(t,a),t}lh.prototype={nodeName:"#document",nodeType:Vb,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==Q0){var a=e.firstChild;while(a){var n=a.nextSibling;this.insertBefore(a,t),a=n}return e}if(c9(this,e,t),ih(e,this),this.documentElement===null&&e.nodeType===oi)this.documentElement=e;return e},removeChild:function(e){if(this.documentElement==e)this.documentElement=null;return Pb(this,e)},replaceChild:function(e,t){if(c9(this,e,t,ew),ih(e,this),t)this.removeChild(t);if(t0(e))this.documentElement=e},importNode:function(e,t){return vO(this,e,t)},getElementById:function(e){var t=null;return o9(this.documentElement,function(a){if(a.nodeType==oi){if(a.getAttribute("id")==e)return t=a,!0}}),t},getElementsByClassName:function(e){var t=Rb(e);return new I1(this,function(a){var n=[];if(t.length>0)o9(a.documentElement,function(s){if(s!==a&&s.nodeType===oi){var i=s.getAttribute("class");if(i){var f=e===i;if(!f){var l=Rb(i);f=t.every(hO(l))}if(f)n.push(s)}}});return n})},createElement:function(e){var t=new wr;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new Z0;var a=t.attributes=new r9;return a._ownerElement=t,t},createDocumentFragment:function(){var e=new m9;return e.ownerDocument=this,e.childNodes=new Z0,e},createTextNode:function(e){var t=new v6;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new k6;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){if(e.indexOf("]]>")!==-1)throw new na(gO,'data contains "]]>"');var t=new A6;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var a=new S6;return a.ownerDocument=this,a.tagName=a.nodeName=a.target=e,a.nodeValue=a.data=t,a},createAttribute:function(e){var t=new h9;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new y6;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var a=new wr,n=t.split(":"),s=a.attributes=new r9;if(a.childNodes=new Z0,a.ownerDocument=this,a.nodeName=t,a.tagName=t,a.namespaceURI=e,n.length==2)a.prefix=n[0],a.localName=n[1];else a.localName=t;return s._ownerElement=a,a},createAttributeNS:function(e,t){var a=new h9,n=t.split(":");if(a.ownerDocument=this,a.nodeName=t,a.name=t,a.namespaceURI=e,a.specified=!0,n.length==2)a.prefix=n[0],a.localName=n[1];else a.localName=t;return a}};ds(lh,$t);function wr(){this._nsMap={}}wr.prototype={nodeType:oi,hasAttribute:function(e){return this.getAttributeNode(e)!=null},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var a=this.ownerDocument.createAttribute(e);a.value=a.nodeValue=""+t,this.setAttributeNode(a)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){if(e.nodeType===Q0)return this.insertBefore(e,null);else return qO(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var a=this.getAttributeNodeNS(e,t);a&&this.removeAttributeNode(a)},hasAttributeNS:function(e,t){return this.getAttributeNodeNS(e,t)!=null},getAttributeNS:function(e,t){var a=this.getAttributeNodeNS(e,t);return a&&a.value||""},setAttributeNS:function(e,t,a){var n=this.ownerDocument.createAttributeNS(e,t);n.value=n.nodeValue=""+a,this.setAttributeNode(n)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new I1(this,function(t){var a=[];return o9(t,function(n){if(n!==t&&n.nodeType==oi&&(e==="*"||n.tagName==e))a.push(n)}),a})},getElementsByTagNameNS:function(e,t){return new I1(this,function(a){var n=[];return o9(a,function(s){if(s!==a&&s.nodeType===oi&&(e==="*"||s.namespaceURI===e)&&(t==="*"||s.localName==t))n.push(s)}),n})}};lh.prototype.getElementsByTagName=wr.prototype.getElementsByTagName;lh.prototype.getElementsByTagNameNS=wr.prototype.getElementsByTagNameNS;ds(wr,$t);function h9(){}h9.prototype.nodeType=U1;ds(h9,$t);function rh(){}rh.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw Error(wn[ws])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,a){var n=this.data.substring(0,e),s=this.data.substring(e+t);a=n+a+s,this.nodeValue=this.data=a,this.length=a.length}};ds(rh,$t);function v6(){}v6.prototype={nodeName:"#text",nodeType:l9,splitText:function(e){var t=this.data,a=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var n=this.ownerDocument.createTextNode(a);if(this.parentNode)this.parentNode.insertBefore(n,this.nextSibling);return n}};ds(v6,rh);function k6(){}k6.prototype={nodeName:"#comment",nodeType:w6};ds(k6,rh);function A6(){}A6.prototype={nodeName:"#cdata-section",nodeType:Kb};ds(A6,rh);function u9(){}u9.prototype.nodeType=Yb;ds(u9,$t);function tw(){}tw.prototype.nodeType=mO;ds(tw,$t);function aw(){}aw.prototype.nodeType=uO;ds(aw,$t);function y6(){}y6.prototype.nodeType=Lb;ds(y6,$t);function m9(){}m9.prototype.nodeName="#document-fragment";m9.prototype.nodeType=Q0;ds(m9,$t);function S6(){}S6.prototype.nodeType=b6;ds(S6,$t);function nw(){}nw.prototype.serializeToString=function(e,t,a,n){return sw.call(e,t,a,n)};$t.prototype.toString=sw;function sw(e,t,a){var n=!!a&&!!a.requireWellFormed,s=[],i=this.nodeType==9&&this.documentElement||this,f=i.prefix,l=i.namespaceURI;if(l&&f==null){var f=i.lookupPrefix(l);if(f==null)var c=[{namespace:l,prefix:null}]}return C6(this,s,e,t,c,n),s.join("")}function Gb(e,t,a){var n=e.prefix||"",s=e.namespaceURI;if(!s)return!1;if(n==="xml"&&s===sh.XML||s===sh.XMLNS)return!1;var i=a.length;while(i--){var f=a[i];if(f.prefix===n)return f.namespace!==s}return!0}function f9(e,t,a){e.push(" ",t,'="',a.replace(/[<>&"\t\n\r]/g,$b),'"')}function C6(e,t,a,n,s,i){if(!s)s=[];bn(e,{ns:s,isHTML:a},{enter:function(f,l){var{ns:c,isHTML:h}=l;if(n)if(f=n(f),f){if(typeof f=="string")return t.push(f),null}else return null;switch(f.nodeType){case oi:var u=f.attributes,g=u.length,b=f.tagName;h=sh.isHTML(f.namespaceURI)||h;var d=b;if(!h&&!f.prefix&&f.namespaceURI){var j;for(var A=0;A<u.length;A++)if(u.item(A).name==="xmlns"){j=u.item(A).value;break}if(!j)for(var C=c.length-1;C>=0;C--){var y=c[C];if(y.prefix===""&&y.namespace===f.namespaceURI){j=y.namespace;break}}if(j!==f.namespaceURI)for(var C=c.length-1;C>=0;C--){var y=c[C];if(y.namespace===f.namespaceURI){if(y.prefix)d=y.prefix+":"+b;break}}}t.push("<",d);var O=c.slice();for(var T=0;T<g;T++){var M=u.item(T);if(M.prefix=="xmlns")O.push({prefix:M.localName,namespace:M.value});else if(M.nodeName=="xmlns")O.push({prefix:"",namespace:M.value})}for(var T=0;T<g;T++){var M=u.item(T);if(Gb(M,h,O)){var H=M.prefix||"",N=M.namespaceURI;f9(t,H?"xmlns:"+H:"xmlns",N),O.push({prefix:H,namespace:N})}var x=n?n(M):M;if(x)if(typeof x==="string")t.push(x);else f9(t,x.name,x.value)}if(b===d&&Gb(f,h,O)){var z=f.prefix||"",N=f.namespaceURI;f9(t,z?"xmlns:"+z:"xmlns",N),O.push({prefix:z,namespace:N})}var K=f.firstChild;if(K||h&&!/^(?:meta|link|img|br|hr|input)$/i.test(b)){if(t.push(">"),h&&/^script$/i.test(b)){while(K){if(K.data)t.push(K.data);else C6(K,t,h,n,O.slice(),i);K=K.nextSibling}return t.push("</",b,">"),null}return{ns:O,isHTML:h,tag:d}}else return t.push("/>"),null;case Vb:case Q0:return{ns:c.slice(),isHTML:h,tag:null};case U1:return f9(t,f.name,f.value),null;case l9:return t.push(f.data.replace(/[<&>]/g,$b)),null;case Kb:if(i&&f.data.indexOf("]]>")!==-1)throw new na(z1,'The CDATASection data contains "]]>"');return t.push("<![CDATA[",f.data.replace(/]]>/g,"]]]]><![CDATA[>"),"]]>"),null;case w6:if(i&&f.data.indexOf("-->")!==-1)throw new na(z1,'The comment node data contains "-->"');return t.push("<!--",f.data,"-->"),null;case Yb:if(i){if(f.publicId&&!/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(f.publicId))throw new na(z1,"DocumentType publicId is not a valid PubidLiteral");if(f.systemId&&!/^("[^"]*"|'[^']*')$/.test(f.systemId))throw new na(z1,"DocumentType systemId is not a valid SystemLiteral");if(f.internalSubset&&f.internalSubset.indexOf("]>")!==-1)throw new na(z1,'DocumentType internalSubset contains "]>"')}var{publicId:$,systemId:Q}=f;if(t.push("<!DOCTYPE ",f.name),$){if(t.push(" PUBLIC ",$),Q&&Q!=".")t.push(" ",Q);t.push(">")}else if(Q&&Q!=".")t.push(" SYSTEM ",Q,">");else{var P=f.internalSubset;if(P)t.push(" [",P,"]");t.push(">")}return null;case b6:if(i&&f.data.indexOf("?>")!==-1)throw new na(z1,'The ProcessingInstruction data contains "?>"');return t.push("<?",f.target," ",f.data,"?>"),null;case Lb:return t.push("&",f.nodeName,";"),null;default:return t.push("??",f.nodeName),null}},exit:function(f,l){if(l&&l.tag)t.push("</",l.tag,">")}})}function vO(e,t,a){var n;return bn(t,null,{enter:function(s,i){var f=s.cloneNode(!1);if(f.ownerDocument=e,f.parentNode=null,i===null)n=f;else i.appendChild(f);var l=s.nodeType===U1||a;return l?f:null}}),n}function iw(e,t,a){var n;return bn(t,null,{enter:function(s,i){var f=new s.constructor;for(var l in s)if(Object.prototype.hasOwnProperty.call(s,l)){var c=s[l];if(typeof c!="object"){if(c!=f[l])f[l]=c}}if(s.childNodes)f.childNodes=new Z0;f.ownerDocument=e;var h=a;switch(f.nodeType){case oi:var u=s.attributes,g=f.attributes=new r9,b=u.length;g._ownerElement=f;for(var d=0;d<b;d++)f.setAttributeNode(iw(e,u.item(d),!0));break;case U1:h=!0}if(i!==null)i.appendChild(f);else n=f;return h?f:null}}),n}function fw(e,t,a){e[t]=a}try{if(Object.defineProperty)Object.defineProperty(I1.prototype,"length",{get:function(){return d6(this),this.$$length}}),Object.defineProperty($t.prototype,"textContent",{get:function(){if(this.nodeType===oi||this.nodeType===Q0){var e=[];return bn(this,null,{enter:function(t){if(t.nodeType===oi||t.nodeType===Q0)return!0;if(t.nodeType===b6||t.nodeType===w6)return null;e.push(t.nodeValue)}}),e.join("")}return this.nodeValue},set:function(e){switch(this.nodeType){case oi:case Q0:while(this.firstChild)this.removeChild(this.firstChild);if(e||String(e))this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),fw=function(e,t,a){e["$$"+t]=a}}catch(e){}kO.DocumentType=u9;kO.DOMException=na;kO.DOMImplementation=Zb;kO.Element=wr;kO.Node=$t;kO.NodeList=Z0;kO.walkDOM=bn;kO.XMLSerializer=nw});var ow=Tt((TO)=>{var lw=nh().freeze;TO.XML_ENTITIES=lw({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});TO.HTML_ENTITIES=lw({Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"⁡",Afr:"\uD835\uDD04",afr:"\uD835\uDD1E",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"\uD835\uDD38",aopf:"\uD835\uDD52",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"⁡",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"\uD835\uDC9C",ascr:"\uD835\uDCB6",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"\uD835\uDD05",bfr:"\uD835\uDD1F",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"\uD835\uDD39",bopf:"\uD835\uDD53",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"‵",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"ℬ",bscr:"\uD835\uDCB7",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"ℭ",cfr:"\uD835\uDD20",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"ℂ",copf:"\uD835\uDD54",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"⨯",cross:"✗",Cscr:"\uD835\uDC9E",cscr:"\uD835\uDCB8",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"∪",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"ⅅ",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"\uD835\uDD07",dfr:"\uD835\uDD21",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"\uD835\uDD3B",dopf:"\uD835\uDD55",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"\uD835\uDC9F",dscr:"\uD835\uDCB9",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"ⅇ",efDot:"≒",Efr:"\uD835\uDD08",efr:"\uD835\uDD22",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:" ",emsp13:" ",emsp14:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"\uD835\uDD3C",eopf:"\uD835\uDD56",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"ℰ",escr:"ℯ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",ExponentialE:"ⅇ",exponentiale:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"\uD835\uDD09",ffr:"\uD835\uDD23",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"\uD835\uDD3D",fopf:"\uD835\uDD57",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",Fscr:"ℱ",fscr:"\uD835\uDCBB",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"\uD835\uDD0A",gfr:"\uD835\uDD24",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"\uD835\uDD3E",gopf:"\uD835\uDD58",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"\uD835\uDCA2",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",Gt:"≫",GT:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"ℌ",hfr:"\uD835\uDD25",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"ℍ",hopf:"\uD835\uDD59",horbar:"―",HorizontalLine:"─",Hscr:"ℋ",hscr:"\uD835\uDCBD",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"⁣",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"ℑ",ifr:"\uD835\uDD26",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"ℑ",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"⁣",InvisibleTimes:"⁢",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"\uD835\uDD40",iopf:"\uD835\uDD5A",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"ℐ",iscr:"\uD835\uDCBE",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"\uD835\uDD0D",jfr:"\uD835\uDD27",jmath:"ȷ",Jopf:"\uD835\uDD41",jopf:"\uD835\uDD5B",Jscr:"\uD835\uDCA5",jscr:"\uD835\uDCBF",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"\uD835\uDD0E",kfr:"\uD835\uDD28",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"\uD835\uDD42",kopf:"\uD835\uDD5C",Kscr:"\uD835\uDCA6",kscr:"\uD835\uDCC0",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"\uD835\uDD0F",lfr:"\uD835\uDD29",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"\uD835\uDD43",lopf:"\uD835\uDD5D",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",Lscr:"ℒ",lscr:"\uD835\uDCC1",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",Lt:"≪",LT:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"\uD835\uDD10",mfr:"\uD835\uDD2A",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"\uD835\uDD44",mopf:"\uD835\uDD5E",mp:"∓",Mscr:"ℳ",mscr:"\uD835\uDCC2",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:`
11
+ `,nexist:"∄",nexists:"∄",Nfr:"\uD835\uDD11",nfr:"\uD835\uDD2B",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",nopf:"\uD835\uDD5F",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"\uD835\uDCA9",nscr:"\uD835\uDCC3",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"\uD835\uDD12",ofr:"\uD835\uDD2C",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"\uD835\uDD46",oopf:"\uD835\uDD60",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",Or:"⩔",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"\uD835\uDCAA",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"\uD835\uDD13",pfr:"\uD835\uDD2D",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",Popf:"ℙ",popf:"\uD835\uDD61",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"′",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"\uD835\uDCAB",pscr:"\uD835\uDCC5",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"\uD835\uDD14",qfr:"\uD835\uDD2E",qint:"⨌",Qopf:"ℚ",qopf:"\uD835\uDD62",qprime:"⁗",Qscr:"\uD835\uDCAC",qscr:"\uD835\uDCC6",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"∶",rationals:"ℚ",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"ℜ",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"ℜ",rfr:"\uD835\uDD2F",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"ℝ",ropf:"\uD835\uDD63",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",Rscr:"ℛ",rscr:"\uD835\uDCC7",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"\uD835\uDD16",sfr:"\uD835\uDD30",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"\uD835\uDD4A",sopf:"\uD835\uDD64",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"\uD835\uDCAE",sscr:"\uD835\uDCC8",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"\uD835\uDD17",tfr:"\uD835\uDD31",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:"  ",thinsp:" ",ThinSpace:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",Tilde:"∼",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",Topf:"\uD835\uDD4B",topf:"\uD835\uDD65",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"\uD835\uDCAF",tscr:"\uD835\uDCC9",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"\uD835\uDD18",ufr:"\uD835\uDD32",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"\uD835\uDD4C",uopf:"\uD835\uDD66",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"\uD835\uDCB0",uscr:"\uD835\uDCCA",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"⋁",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"\uD835\uDD19",vfr:"\uD835\uDD33",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"\uD835\uDD4D",vopf:"\uD835\uDD67",vprop:"∝",vrtri:"⊳",Vscr:"\uD835\uDCB1",vscr:"\uD835\uDCCB",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"\uD835\uDD1A",wfr:"\uD835\uDD34",Wopf:"\uD835\uDD4E",wopf:"\uD835\uDD68",wp:"℘",wr:"≀",wreath:"≀",Wscr:"\uD835\uDCB2",wscr:"\uD835\uDCCC",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"\uD835\uDD1B",xfr:"\uD835\uDD35",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"\uD835\uDD4F",xopf:"\uD835\uDD69",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"\uD835\uDCB3",xscr:"\uD835\uDCCD",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"\uD835\uDD1C",yfr:"\uD835\uDD36",YIcy:"Ї",yicy:"ї",Yopf:"\uD835\uDD50",yopf:"\uD835\uDD6A",Yscr:"\uD835\uDCB4",yscr:"\uD835\uDCCE",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"​",Zeta:"Ζ",zeta:"ζ",Zfr:"ℨ",zfr:"\uD835\uDD37",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"ℤ",zopf:"\uD835\uDD6B",Zscr:"\uD835\uDCB5",zscr:"\uD835\uDCCF",zwj:"‍",zwnj:"‌"});TO.entityMap=TO.HTML_ENTITIES});var ww=Tt((IO)=>{var uh=nh().NAMESPACE,F6=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,cw=new RegExp("[\\-\\.0-9"+F6.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),hw=new RegExp("^"+F6.source+cw.source+"*(?::"+F6.source+cw.source+"*)?$"),oh=0,tl=1,G1=2,ch=3,X1=4,K1=5,hh=6,g9=7;function L1(e,t){if(this.message=e,this.locator=t,Error.captureStackTrace)Error.captureStackTrace(this,L1)}L1.prototype=Error();L1.prototype.name=L1.name;function gw(){}gw.prototype={parse:function(e,t,a){var n=this.domBuilder;n.startDocument(),pw(t,t={}),DO(e,t,a,n,this.errorHandler),n.endDocument()}};function DO(e,t,a,n,s){function i(J){if(J>65535){J-=65536;var pe=55296+(J>>10),ne=56320+(J&1023);return String.fromCharCode(pe,ne)}else return String.fromCharCode(J)}function f(J){var pe=J.slice(1,-1);if(Object.hasOwnProperty.call(a,pe))return a[pe];else if(pe.charAt(0)==="#")return i(parseInt(pe.substr(1).replace("x","0x")));else return s.error("entity not found:"+J),J}function l(J){if(J>A){var pe=e.substring(A,J).replace(/&#?\w+;/g,f);b&&c(A),n.characters(pe,0,J-A),A=J}}function c(J,pe){while(J>=u&&(pe=g.exec(e)))h=pe.index,u=h+pe[0].length,b.lineNumber++;b.columnNumber=J-h+1}var h=0,u=0,g=/.*(?:\r\n?|\n)|.*$/g,b=n.locator,d=[{currentNSMap:t}],j={},A=0;while(!0){try{var C=e.indexOf("<",A);if(C<0){if(!e.substr(A).match(/^\s*$/)){var y=n.doc,O=y.createTextNode(e.substr(A));y.appendChild(O),n.currentElement=O}return}if(C>A)l(C);switch(e.charAt(C+1)){case"/":var Q=e.indexOf(">",C+3),T=e.substring(C+2,Q).replace(/[ \t\n\r]+$/g,""),M=d.pop();if(Q<0)T=e.substring(C+2).replace(/[\s<].*/,""),s.error("end tag name: "+T+" is not complete:"+M.tagName),Q=C+1+T.length;else if(T.match(/\s</))T=T.replace(/[\s<].*/,""),s.error("end tag name: "+T+" maybe not complete"),Q=C+1+T.length;var H=M.localNSMap,N=M.tagName==T,x=N||M.tagName&&M.tagName.toLowerCase()==T.toLowerCase();if(x){if(n.endElement(M.uri,M.localName,T),H){for(var z in H)if(Object.prototype.hasOwnProperty.call(H,z))n.endPrefixMapping(z)}if(!N)s.fatalError("end tag name: "+T+" is not match the current start tagName:"+M.tagName)}else d.push(M);Q++;break;case"?":b&&c(C),Q=zO(e,C,n);break;case"!":b&&c(C),Q=EO(e,C,n,s);break;default:b&&c(C);var K=new bw,$=d[d.length-1].currentNSMap,Q=xO(e,C,K,$,f,s),P=K.length;if(!K.closed&&NO(e,Q,K.tagName,j)){if(K.closed=!0,!a.nbsp)s.warning("unclosed xml attribute")}if(b&&P){var te=uw(b,{});for(var ee=0;ee<P;ee++){var L=K[ee];c(L.offset),L.locator=uw(b,{})}if(n.locator=te,mw(K,n,$))d.push(K);n.locator=b}else if(mw(K,n,$))d.push(K);if(uh.isHTML(K.uri)&&!K.closed)Q=RO(e,Q,K.tagName,f,n);else Q++}}catch(J){if(J instanceof L1)throw J;s.error("element parse error: "+J),Q=-1}if(Q>A)A=Q;else l(Math.max(C,A)+1)}}function uw(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function xO(e,t,a,n,s,i){function f(d,j,A){if(a.attributeNames.hasOwnProperty(d))i.fatalError("Attribute "+d+" redefined");a.addValue(d,j.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,s),A)}var l,c,h=++t,u=oh;while(!0){var g=e.charAt(h);switch(g){case"=":if(u===tl)l=e.slice(t,h),u=ch;else if(u===G1)u=ch;else throw Error("attribute equal must after attrName");break;case"'":case'"':if(u===ch||u===tl){if(u===tl)i.warning('attribute value must after "="'),l=e.slice(t,h);if(t=h+1,h=e.indexOf(g,t),h>0)c=e.slice(t,h),f(l,c,t-1),u=K1;else throw Error("attribute value no end '"+g+"' match")}else if(u==X1)c=e.slice(t,h),f(l,c,t),i.warning('attribute "'+l+'" missed start quot('+g+")!!"),t=h+1,u=K1;else throw Error('attribute value must after "="');break;case"/":switch(u){case oh:a.setTagName(e.slice(t,h));case K1:case hh:case g9:u=g9,a.closed=!0;case X1:case tl:break;case G1:a.closed=!0;break;default:throw Error("attribute invalid close char('/')")}break;case"":if(i.error("unexpected end of input"),u==oh)a.setTagName(e.slice(t,h));return h;case">":switch(u){case oh:a.setTagName(e.slice(t,h));case K1:case hh:case g9:break;case X1:case tl:if(c=e.slice(t,h),c.slice(-1)==="/")a.closed=!0,c=c.slice(0,-1);case G1:if(u===G1)c=l;if(u==X1)i.warning('attribute "'+c+'" missed quot(")!'),f(l,c,t);else{if(!uh.isHTML(n[""])||!c.match(/^(?:disabled|checked|selected)$/i))i.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!');f(c,c,t)}break;case ch:throw Error("attribute value missed!!")}return h;case"€":g=" ";default:if(g<=" ")switch(u){case oh:a.setTagName(e.slice(t,h)),u=hh;break;case tl:l=e.slice(t,h),u=G1;break;case X1:var c=e.slice(t,h);i.warning('attribute "'+c+'" missed quot(")!!'),f(l,c,t);case K1:u=hh;break}else switch(u){case G1:var b=a.tagName;if(!uh.isHTML(n[""])||!l.match(/^(?:disabled|checked|selected)$/i))i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!');f(l,l,t),t=h,u=tl;break;case K1:i.warning('attribute space is required"'+l+'"!!');case hh:u=tl,t=h;break;case ch:u=X1,t=h;break;case g9:throw Error("elements closed character '/' and '>' must be connected to")}}h++}}function mw(e,t,a){var n=e.tagName,s=null,g=e.length;while(g--){var i=e[g],f=i.qName,l=i.value,b=f.indexOf(":");if(b>0)var c=i.prefix=f.slice(0,b),h=f.slice(b+1),u=c==="xmlns"&&h;else h=f,c=null,u=f==="xmlns"&&"";if(i.localName=h,u!==!1){if(s==null)s={},pw(a,a={});a[u]=s[u]=l,i.uri=uh.XMLNS,t.startPrefixMapping(u,l)}}var g=e.length;while(g--){i=e[g];var c=i.prefix;if(c){if(c==="xml")i.uri=uh.XML;if(c!=="xmlns")i.uri=a[c||""]}}var b=n.indexOf(":");if(b>0)c=e.prefix=n.slice(0,b),h=e.localName=n.slice(b+1);else c=null,h=e.localName=n;var d=e.uri=a[c||""];if(t.startElement(d,h,n,e),e.closed){if(t.endElement(d,h,n),s){for(c in s)if(Object.prototype.hasOwnProperty.call(s,c))t.endPrefixMapping(c)}}else return e.currentNSMap=a,e.localNSMap=s,!0}function RO(e,t,a,n,s){if(/^(?:script|textarea)$/i.test(a)){var i=e.indexOf("</"+a+">",t),f=e.substring(t+1,i);if(/[&<]/.test(f)){if(/^script$/i.test(a))return s.characters(f,0,f.length),i;return f=f.replace(/&#?\w+;/g,n),s.characters(f,0,f.length),i}}return t+1}function NO(e,t,a,n){var s=n[a];if(s==null){if(s=e.lastIndexOf("</"+a+">"),s<t)s=e.lastIndexOf("</"+a);n[a]=s}return s<t}function pw(e,t){for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a))t[a]=e[a]}function EO(e,t,a,n){var s=e.charAt(t+2);switch(s){case"-":if(e.charAt(t+3)==="-"){var i=e.indexOf("-->",t+4);if(i>t)return a.comment(e,t+4,i-t-4),i+3;else return n.error("Unclosed comment"),-1}else return-1;default:if(e.substr(t+3,6)=="CDATA["){var i=e.indexOf("]]>",t+9);return a.startCDATA(),a.characters(e,t+9,i-t-9),a.endCDATA(),i+3}var f=UO(e,t),l=f.length;if(l>1&&/!doctype/i.test(f[0][0])){var c=f[1][0],h=!1,u=!1;if(l>3){if(/^public$/i.test(f[2][0]))h=f[3][0],u=l>4&&f[4][0];else if(/^system$/i.test(f[2][0]))u=f[3][0]}var g=f[l-1];return a.startDTD(c,h,u),a.endDTD(),g.index+g[0].length}}return-1}function zO(e,t,a){var n=e.indexOf("?>",t);if(n){var s=e.substring(t,n).match(/^<\?(\S*)\s*([\s\S]*?)$/);if(s){var i=s[0].length;return a.processingInstruction(s[1],s[2]),n+2}else return-1}return-1}function bw(){this.attributeNames={}}bw.prototype={setTagName:function(e){if(!hw.test(e))throw Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,a){if(!hw.test(e))throw Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:a}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}};function UO(e,t){var a,n=[],s=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;s.lastIndex=t,s.exec(e);while(a=s.exec(e))if(n.push(a),a[1])return n}IO.XMLReader=gw;IO.ParseError=L1});var yw=Tt((ZO)=>{var KO=nh(),LO=_6(),dw=ow(),vw=ww(),VO=LO.DOMImplementation,jw=KO.NAMESPACE,YO=vw.ParseError,JO=vw.XMLReader;function kw(e){return e.replace(/\r[\n\u0085]/g,`
12
+ `).replace(/[\r\u0085\u2028]/g,`
13
+ `)}function Aw(e){this.options=e||{locator:{}}}Aw.prototype.parseFromString=function(e,t){var a=this.options,n=new JO,s=a.domBuilder||new mh,i=a.errorHandler,f=a.locator,l=a.xmlns||{},c=/\/x?html?$/.test(t),h=c?dw.HTML_ENTITIES:dw.XML_ENTITIES;if(f)s.setDocumentLocator(f);if(n.errorHandler=QO(i,s,f),n.domBuilder=a.domBuilder||s,c)l[""]=jw.HTML;l.xml=l.xml||jw.XML;var u=a.normalizeLineEndings||kw;if(e&&typeof e==="string")n.parse(u(e),l,h);else n.errorHandler.error("invalid doc source");return s.doc};function QO(e,t,a){if(!e){if(t instanceof mh)return t;e=t}var n={},s=e instanceof Function;a=a||{};function i(f){var l=e[f];if(!l&&s)l=e.length==2?function(c){e(f,c)}:e;n[f]=l&&function(c){l("[xmldom "+f+"]\t"+c+O6(a))}||function(){}}return i("warning"),i("error"),i("fatalError"),n}function mh(){this.cdata=!1}function V1(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}mh.prototype={startDocument:function(){if(this.doc=new VO().createDocument(null,null,null),this.locator)this.doc.documentURI=this.locator.systemId},startElement:function(e,t,a,n){var s=this.doc,i=s.createElementNS(e,a||t),f=n.length;p9(this,i),this.currentElement=i,this.locator&&V1(this.locator,i);for(var l=0;l<f;l++){var e=n.getURI(l),c=n.getValue(l),a=n.getQName(l),h=s.createAttributeNS(e,a);this.locator&&V1(n.getLocator(l),h),h.value=h.nodeValue=c,i.setAttributeNode(h)}},endElement:function(e,t,a){var n=this.currentElement,s=n.tagName;this.currentElement=n.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var a=this.doc.createProcessingInstruction(e,t);this.locator&&V1(this.locator,a),p9(this,a)},ignorableWhitespace:function(e,t,a){},characters:function(e,t,a){if(e=qw.apply(this,arguments),e){if(this.cdata)var n=this.doc.createCDATASection(e);else var n=this.doc.createTextNode(e);if(this.currentElement)this.currentElement.appendChild(n);else if(/^\s*$/.test(e))this.doc.appendChild(n);this.locator&&V1(this.locator,n)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){if(this.locator=e)e.lineNumber=0},comment:function(e,t,a){e=qw.apply(this,arguments);var n=this.doc.createComment(e);this.locator&&V1(this.locator,n),p9(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,a){var n=this.doc.implementation;if(n&&n.createDocumentType){var s=n.createDocumentType(e,t,a);this.locator&&V1(this.locator,s),p9(this,s),this.doc.doctype=s}},warning:function(e){console.warn("[xmldom warning]\t"+e,O6(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,O6(this.locator))},fatalError:function(e){throw new YO(e,this.locator)}};function O6(e){if(e)return`
14
+ @`+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function qw(e,t,a){if(typeof e=="string")return e.substr(t,a);else{if(e.length>=t+a||t)return new java.lang.String(e,t,a)+"";return e}}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){mh.prototype[e]=function(){return null}});function p9(e,t){if(!e.currentElement)e.doc.appendChild(t);else e.currentElement.appendChild(t)}ZO.__DOMHandler=mh;ZO.normalizeLineEndings=kw;ZO.DOMParser=Aw});var Xw=Tt((mI,Gw)=>{var Iw=Math.pow(2,32),YB=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),a;if(t.getBigUint64){if(a=t.getBigUint64(0),a<Number.MAX_SAFE_INTEGER)return Number(a);return a}return t.getUint32(0)*Iw+t.getUint32(4)};Gw.exports={getUint64:YB,MAX_UINT32:Iw}});var Vw=Tt((gI,Lw)=>{var Kw=Xw().getUint64,JB=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),a={version:e[0],flags:new Uint8Array(e.subarray(1,4)),references:[],referenceId:t.getUint32(4),timescale:t.getUint32(8)},n=12;if(a.version===0)a.earliestPresentationTime=t.getUint32(n),a.firstOffset=t.getUint32(n+4),n+=8;else a.earliestPresentationTime=Kw(e.subarray(n)),a.firstOffset=Kw(e.subarray(n+8)),n+=16;n+=2;var s=t.getUint16(n);n+=2;for(;s>0;n+=12,s--)a.references.push({referenceType:(e[n]&128)>>>7,referencedSize:t.getUint32(n)&2147483647,subsegmentDuration:t.getUint32(n+4),startsWithSap:!!(e[n+8]&128),sapType:(e[n+8]&112)>>>4,sapDeltaTime:t.getUint32(n+8)&268435455});return a};Lw.exports=JB});var fd=Tt((EI,id)=>{var z6=90000,U6,I6,q9,G6,ad,nd,sd;U6=function(e){return e*z6};I6=function(e,t){return e*t};q9=function(e){return e/z6};G6=function(e,t){return e/t};ad=function(e,t){return U6(G6(e,t))};nd=function(e,t){return I6(q9(e),t)};sd=function(e,t,a){return q9(a?e:e-t)};id.exports={ONE_SECOND_IN_TS:z6,secondsToVideoTs:U6,secondsToAudioTs:I6,videoTsToSeconds:q9,audioTsToSeconds:G6,audioTsToVideoTs:ad,videoTsToAudioTs:nd,metadataTsToSeconds:sd}});var Vk=Tt((PY,t2)=>{Lk();var t8=Mt(en());t2.exports=function(e){function t(r,o,m,w){return new X(r,o,m,w)}function a(){}function n(r){var o="https://react.dev/errors/"+r;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)o+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(r){var o=r,m=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(m=o.return),r=o.return;while(r)}return o.tag===3?m:null}function i(r){if(s(r)!==r)throw Error(n(188))}function f(r){var o=r.alternate;if(!o){if(o=s(r),o===null)throw Error(n(188));return o!==r?null:r}for(var m=r,w=o;;){var S=m.return;if(S===null)break;var F=S.alternate;if(F===null){if(w=S.return,w!==null){m=w;continue}break}if(S.child===F.child){for(F=S.child;F;){if(F===m)return i(S),r;if(F===w)return i(S),o;F=F.sibling}throw Error(n(188))}if(m.return!==w.return)m=S,w=F;else{for(var D=!1,Y=S.child;Y;){if(Y===m){D=!0,m=S,w=F;break}if(Y===w){D=!0,w=S,m=F;break}Y=Y.sibling}if(!D){for(Y=F.child;Y;){if(Y===m){D=!0,m=F,w=S;break}if(Y===w){D=!0,w=F,m=S;break}Y=Y.sibling}if(!D)throw Error(n(189))}}if(m.alternate!==w)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?r:o}function l(r){var o=r.tag;if(o===5||o===26||o===27||o===6)return r;for(r=r.child;r!==null;){if(o=l(r),o!==null)return o;r=r.sibling}return null}function c(r){var o=r.tag;if(o===5||o===26||o===27||o===6)return r;for(r=r.child;r!==null;){if(r.tag!==4&&(o=c(r),o!==null))return o;r=r.sibling}return null}function h(r){if(r===null||typeof r!=="object")return null;return r=sp&&r[sp]||r["@@iterator"],typeof r==="function"?r:null}function u(r){if(r==null)return null;if(typeof r==="function")return r.$$typeof===zS?null:r.displayName||r.name||null;if(typeof r==="string")return r;switch(r){case m1:return"Fragment";case t3:return"Profiler";case ap:return"StrictMode";case n3:return"Suspense";case s3:return"SuspenseList";case f3:return"Activity"}if(typeof r==="object")switch(r.$$typeof){case u1:return"Portal";case Ef:return r.displayName||"Context";case np:return(r._context.displayName||"Context")+".Consumer";case a3:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case i3:return o=r.displayName||null,o!==null?o:u(r.type)||"Memo";case zf:o=r._payload,r=r._init;try{return u(r(o))}catch(m){}}return null}function g(r){return{current:r}}function b(r){0>b1||(r.current=u3[b1],u3[b1]=null,b1--)}function d(r,o){b1++,u3[b1]=r.current,r.current=o}function j(r){return r>>>=0,r===0?32:31-(m_(r)/g_|0)|0}function A(r){var o=r&42;if(o!==0)return o;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function C(r,o,m){var w=r.pendingLanes;if(w===0)return 0;var S=0,F=r.suspendedLanes,D=r.pingedLanes;r=r.warmLanes;var Y=w&134217727;return Y!==0?(w=Y&~F,w!==0?S=A(w):(D&=Y,D!==0?S=A(D):m||(m=Y&~r,m!==0&&(S=A(m))))):(Y=w&~F,Y!==0?S=A(Y):D!==0?S=A(D):m||(m=w&~r,m!==0&&(S=A(m)))),S===0?0:o!==0&&o!==S&&(o&F)===0&&(F=S&-S,m=o&-o,F>=m||F===32&&(m&4194048)!==0)?o:S}function y(r,o){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&o)===0}function O(r,o){switch(r){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5000;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function T(){var r=Fu;return Fu<<=1,(Fu&62914560)===0&&(Fu=4194304),r}function M(r){for(var o=[],m=0;31>m;m++)o.push(r);return o}function H(r,o){r.pendingLanes|=o,o!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function N(r,o,m,w,S,F){var D=r.pendingLanes;r.pendingLanes=m,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=m,r.entangledLanes&=m,r.errorRecoveryDisabledLanes&=m,r.shellSuspendCounter=0;var{entanglements:Y,expirationTimes:ue,hiddenUpdates:ke}=r;for(m=D&~m;0<m;){var Be=31-xs(m),Ce=1<<Be;Y[Be]=0,ue[Be]=-1;var Ne=ke[Be];if(Ne!==null)for(ke[Be]=null,Be=0;Be<Ne.length;Be++){var ht=Ne[Be];ht!==null&&(ht.lane&=-536870913)}m&=~Ce}w!==0&&x(r,w,0),F!==0&&S===0&&r.tag!==0&&(r.suspendedLanes|=F&~(D&~o))}function x(r,o,m){r.pendingLanes|=o,r.suspendedLanes&=~o;var w=31-xs(o);r.entangledLanes|=o,r.entanglements[w]=r.entanglements[w]|1073741824|m&261930}function z(r,o){var m=r.entangledLanes|=o;for(r=r.entanglements;m;){var w=31-xs(m),S=1<<w;S&o|r[w]&o&&(r[w]|=o),m&=~S}}function K(r,o){var m=o&-o;return m=(m&42)!==0?1:$(m),(m&(r.suspendedLanes|o))!==0?0:m}function $(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function Q(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function P(r){if(typeof j_==="function"&&q_(r),Rs&&typeof Rs.setStrictMode==="function")try{Rs.setStrictMode(Dc,r)}catch(o){}}function te(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}function ee(r){if(p3===void 0)try{throw Error()}catch(m){var o=m.stack.trim().match(/\n( *(at )?)/);p3=o&&o[1]||"",Bp=-1<m.stack.indexOf(`
15
+ at`)?" (<anonymous>)":-1<m.stack.indexOf("@")?"@unknown:0:0":""}return`
16
+ `+p3+r+Bp}function L(r,o){if(!r||b3)return"";b3=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(o){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(ht){var Ne=ht}Reflect.construct(r,[],Ce)}else{try{Ce.call()}catch(ht){Ne=ht}r.call(Ce.prototype)}}else{try{throw Error()}catch(ht){Ne=ht}(Ce=r())&&typeof Ce.catch==="function"&&Ce.catch(function(){})}}catch(ht){if(ht&&Ne&&typeof ht.stack==="string")return[ht.stack,Ne.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var S=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");S&&S.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=w.DetermineComponentFrameRoot(),D=F[0],Y=F[1];if(D&&Y){var ue=D.split(`
17
+ `),ke=Y.split(`
18
+ `);for(S=w=0;w<ue.length&&!ue[w].includes("DetermineComponentFrameRoot");)w++;for(;S<ke.length&&!ke[S].includes("DetermineComponentFrameRoot");)S++;if(w===ue.length||S===ke.length)for(w=ue.length-1,S=ke.length-1;1<=w&&0<=S&&ue[w]!==ke[S];)S--;for(;1<=w&&0<=S;w--,S--)if(ue[w]!==ke[S]){if(w!==1||S!==1)do if(w--,S--,0>S||ue[w]!==ke[S]){var Be=`
19
+ `+ue[w].replace(" at new "," at ");return r.displayName&&Be.includes("<anonymous>")&&(Be=Be.replace("<anonymous>",r.displayName)),Be}while(1<=w&&0<=S);break}}}finally{b3=!1,Error.prepareStackTrace=m}return(m=r?r.displayName||r.name:"")?ee(m):""}function J(r,o){switch(r.tag){case 26:case 27:case 5:return ee(r.type);case 16:return ee("Lazy");case 13:return r.child!==o&&o!==null?ee("Suspense Fallback"):ee("Suspense");case 19:return ee("SuspenseList");case 0:case 15:return L(r.type,!1);case 11:return L(r.type.render,!1);case 1:return L(r.type,!0);case 31:return ee("Activity");default:return""}}function pe(r){try{var o="",m=null;do o+=J(r,m),m=r,r=r.return;while(r);return o}catch(w){return`
20
+ Error generating stack: `+w.message+`
21
+ `+w.stack}}function ne(r,o){if(typeof r==="object"&&r!==null){var m=Tp.get(r);if(m!==void 0)return m;return o={value:r,source:o,stack:pe(o)},Tp.set(r,o),o}return{value:r,source:o,stack:pe(o)}}function fe(r,o){d1[j1++]=xc,d1[j1++]=Bu,Bu=r,xc=o}function Ae(r,o,m){ni[si++]=Yi,ni[si++]=Ji,ni[si++]=Uf,Uf=r;var w=Yi;r=Ji;var S=32-xs(w)-1;w&=~(1<<S),m+=1;var F=32-xs(o)+S;if(30<F){var D=S-S%5;F=(w&(1<<D)-1).toString(32),w>>=D,S-=D,Yi=1<<32-xs(o)+S|m<<S|w,Ji=F+r}else Yi=1<<F|m<<S|w,Ji=r}function he(r){r.return!==null&&(fe(r,1),Ae(r,1,0))}function re(r){for(;r===Bu;)Bu=d1[--j1],d1[j1]=null,xc=d1[--j1],d1[j1]=null;for(;r===Uf;)Uf=ni[--si],ni[si]=null,Ji=ni[--si],ni[si]=null,Yi=ni[--si],ni[si]=null}function be(r,o){ni[si++]=Yi,ni[si++]=Ji,ni[si++]=Uf,Yi=o.id,Ji=o.overflow,Uf=r}function Ue(r,o){d(If,o),d(Rc,r),d(On,null),r=GS(o),b(On),d(On,r)}function at(){b(On),b(Rc),b(If)}function Ye(r){r.memoizedState!==null&&d(Tu,r);var o=On.current,m=XS(o,r.type);o!==m&&(d(Rc,r),d(On,m))}function Ie(r){Rc.current===r&&(b(On),b(Rc)),Tu.current===r&&(b(Tu),U0?nr._currentValue=g1:nr._currentValue2=g1)}function mt(r){var o=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw jt(ne(o,r)),w3}function vt(r,o){if(!Xn)throw Error(n(175));XC(r.stateNode,r.type,r.memoizedProps,o,r)||mt(r,!0)}function ga(r){for(Bn=r.return;Bn;)switch(Bn.tag){case 5:case 31:case 13:ii=!1;return;case 27:case 3:ii=!0;return;default:Bn=Bn.return}}function Dt(r){if(!Xn||r!==Bn)return!1;if(!Ft)return ga(r),Ft=!0,!1;var o=r.tag;if(nn?o!==3&&o!==27&&(o!==5||wp(r.type)&&!Su(r.type,r.memoizedProps))&&Sa&&mt(r):o!==3&&(o!==5||wp(r.type)&&!Su(r.type,r.memoizedProps))&&Sa&&mt(r),ga(r),o===13){if(!Xn)throw Error(n(316));if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));Sa=JC(r)}else if(o===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));Sa=YC(r)}else Sa=nn&&o===27?MC(r.type,Sa):Bn?bp(r.stateNode):null;return!0}function ta(){Xn&&(Sa=Bn=null,Ft=!1)}function rn(){var r=Gf;return r!==null&&(gs===null?gs=r:gs.push.apply(gs,r),Gf=null),r}function jt(r){Gf===null?Gf=[r]:Gf.push(r)}function xe(r,o,m){U0?(d(Hu,o._currentValue),o._currentValue=m):(d(Hu,o._currentValue2),o._currentValue2=m)}function ze(r){var o=Hu.current;U0?r._currentValue=o:r._currentValue2=o,b(Hu)}function Qe(r,o,m){for(;r!==null;){var w=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,w!==null&&(w.childLanes|=o)):w!==null&&(w.childLanes&o)!==o&&(w.childLanes|=o),r===m)break;r=r.return}}function nt(r,o,m,w){var S=r.child;S!==null&&(S.return=r);for(;S!==null;){var F=S.dependencies;if(F!==null){var D=S.child;F=F.firstContext;e:for(;F!==null;){var Y=F;F=S;for(var ue=0;ue<o.length;ue++)if(Y.context===o[ue]){F.lanes|=m,Y=F.alternate,Y!==null&&(Y.lanes|=m),Qe(F.return,m,r),w||(D=null);break e}F=Y.next}}else if(S.tag===18){if(D=S.return,D===null)throw Error(n(341));D.lanes|=m,F=D.alternate,F!==null&&(F.lanes|=m),Qe(D,m,r),D=null}else D=S.child;if(D!==null)D.return=S;else for(D=S;D!==null;){if(D===r){D=null;break}if(S=D.sibling,S!==null){S.return=D.return,D=S;break}D=D.return}S=D}}function Ot(r,o,m,w){r=null;for(var S=o,F=!1;S!==null;){if(!F){if((S.flags&524288)!==0)F=!0;else if((S.flags&262144)!==0)break}if(S.tag===10){var D=S.alternate;if(D===null)throw Error(n(387));if(D=D.memoizedProps,D!==null){var Y=S.type;Ns(S.pendingProps.value,D.value)||(r!==null?r.push(Y):r=[Y])}}else if(S===Tu.current){if(D=S.alternate,D===null)throw Error(n(387));D.memoizedState.memoizedState!==S.memoizedState.memoizedState&&(r!==null?r.push(nr):r=[nr])}S=S.return}r!==null&&nt(o,r,m,w),o.flags|=262144}function Ze(r){for(r=r.firstContext;r!==null;){var o=r.context;if(!Ns(U0?o._currentValue:o._currentValue2,r.memoizedValue))return!0;r=r.next}return!1}function Yt(r){sr=r,G0=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function wt(r){return zn(sr,r)}function yn(r,o){return sr===null&&Yt(r),zn(r,o)}function zn(r,o){var m=U0?o._currentValue:o._currentValue2;if(o={context:o,memoizedValue:m,next:null},G0===null){if(r===null)throw Error(n(308));G0=o,r.dependencies={lanes:0,firstContext:o},r.flags|=524288}else G0=G0.next=o;return m}function Ya(){return{controller:new k_,data:new Map,refCount:0}}function Ja(r){r.refCount--,r.refCount===0&&A_(y_,function(){r.controller.abort()})}function Sn(){}function pa(r){r!==q1&&r.next===null&&(q1===null?Mu=q1=r:q1=q1.next=r),Du=!0,d3||(d3=!0,Je())}function Da(r,o){if(!j3&&Du){j3=!0;do{var m=!1;for(var w=Mu;w!==null;){if(!o)if(r!==0){var S=w.pendingLanes;if(S===0)var F=0;else{var{suspendedLanes:D,pingedLanes:Y}=w;F=(1<<31-xs(42|r)+1)-1,F&=S&~(D&~Y),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(m=!0,$e(w,F))}else F=Ct,F=C(w,w===la?F:0,w.cancelPendingCommit!==null||w.timeoutHandle!==ar),(F&3)===0||y(w,F)||(m=!0,$e(w,F));w=w.next}}while(m);j3=!1}}function Os(){ls()}function ls(){Du=d3=!1;var r=0;ir!==0&&WS()&&(r=ir);for(var o=us(),m=null,w=Mu;w!==null;){var S=w.next,F=Bt(w,o);if(F===0)w.next=null,m===null?Mu=S:m.next=S,S===null&&(q1=m);else if(m=w,r!==0||(F&3)!==0)Du=!0;w=S}sn!==0&&sn!==5||Da(r,!1),ir!==0&&(ir=0)}function Bt(r,o){for(var{suspendedLanes:m,pingedLanes:w,expirationTimes:S}=r,F=r.pendingLanes&-62914561;0<F;){var D=31-xs(F),Y=1<<D,ue=S[D];if(ue===-1){if((Y&m)===0||(Y&w)!==0)S[D]=O(Y,o)}else ue<=o&&(r.expiredLanes|=Y);F&=~Y}if(o=la,m=Ct,m=C(r,r===o?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==ar),w=r.callbackNode,m===0||r===o&&(Qt===2||Qt===9)||r.cancelPendingCommit!==null)return w!==null&&w!==null&&m3(w),r.callbackNode=null,r.callbackPriority=0;if((m&3)===0||y(r,m)){if(o=m&-m,o===r.callbackPriority)return o;switch(w!==null&&m3(w),Q(m)){case 2:case 8:m=w_;break;case 32:m=g3;break;case 268435456:m=d_;break;default:m=g3}return w=de.bind(null,r),m=Ou(m,w),r.callbackPriority=o,r.callbackNode=m,o}return w!==null&&w!==null&&m3(w),r.callbackPriority=2,r.callbackNode=null,2}function de(r,o){if(sn!==0&&sn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var m=r.callbackNode;if(z0()&&r.callbackNode!==m)return null;var w=Ct;if(w=C(r,r===la?w:0,r.cancelPendingCommit!==null||r.timeoutHandle!==ar),w===0)return null;return Oc(r,w,o),Bt(r,us()),r.callbackNode!=null&&r.callbackNode===m?de.bind(null,r):null}function $e(r,o){if(z0())return null;Oc(r,o,!0)}function Je(){iC?fC(function(){(At&6)!==0?Ou(Fp,Os):ls()}):Ou(Fp,Os)}function xt(){if(ir===0){var r=v1;r===0&&(r=Cu,Cu<<=1,(Cu&261888)===0&&(Cu=256)),ir=r}return ir}function ka(r,o){if(Nc===null){var m=Nc=[];q3=0,v1=xt(),k1={status:"pending",value:void 0,then:function(w){m.push(w)}}}return q3++,o.then(ia,ia),o}function ia(){if(--q3===0&&Nc!==null){k1!==null&&(k1.status="fulfilled");var r=Nc;Nc=null,v1=0,k1=null;for(var o=0;o<r.length;o++)(0,r[o])()}}function Me(r,o){var m=[],w={status:"pending",value:null,reason:null,then:function(S){m.push(S)}};return r.then(function(){w.status="fulfilled",w.value=o;for(var S=0;S<m.length;S++)(0,m[S])(o)},function(S){w.status="rejected",w.reason=S;for(S=0;S<m.length;S++)(0,m[S])(void 0)}),w}function Re(){var r=fr.current;return r!==null?r:la.pooledCache}function zt(r,o){o===null?d(fr,fr.current):d(fr,o.pool)}function Ua(){var r=Re();return r===null?null:{parent:U0?Ca._currentValue:Ca._currentValue2,pool:r}}function Se(r,o){if(Ns(r,o))return!0;if(typeof r!=="object"||r===null||typeof o!=="object"||o===null)return!1;var m=Object.keys(r),w=Object.keys(o);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var S=m[w];if(!v_.call(o,S)||!Ns(r[S],o[S]))return!1}return!0}function Te(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Xe(r,o,m){switch(m=r[m],m===void 0?r.push(o):m!==o&&(o.then(Sn,Sn),o=m),o.status){case"fulfilled":return o.value;case"rejected":throw r=o.reason,ha(r),r;default:if(typeof o.status==="string")o.then(Sn,Sn);else{if(r=la,r!==null&&100<r.shellSuspendCounter)throw Error(n(482));r=o,r.status="pending",r.then(function(w){if(o.status==="pending"){var S=o;S.status="fulfilled",S.value=w}},function(w){if(o.status==="pending"){var S=o;S.status="rejected",S.reason=w}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw r=o.reason,ha(r),r}throw lr=o,A1}}function Le(r){try{var o=r._init;return o(r._payload)}catch(m){if(m!==null&&typeof m==="object"&&typeof m.then==="function")throw lr=m,A1;throw m}}function Aa(){if(lr===null)throw Error(n(459));var r=lr;return lr=null,r}function ha(r){if(r===A1||r===xu)throw Error(n(483))}function $s(r){var o=Ec;return Ec+=1,y1===null&&(y1=[]),Xe(y1,r,o)}function S0(r,o){o=o.props.ref,r.ref=o!==void 0?o:null}function Kr(r,o){if(o.$$typeof===NS)throw Error(n(525));throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function Vo(r){function o(le,ae){if(r){var ce=le.deletions;ce===null?(le.deletions=[ae],le.flags|=16):ce.push(ae)}}function m(le,ae){if(!r)return null;for(;ae!==null;)o(le,ae),ae=ae.sibling;return null}function w(le){for(var ae=new Map;le!==null;)le.key!==null?ae.set(le.key,le):ae.set(le.index,le),le=le.sibling;return ae}function S(le,ae){return le=oe(le,ae),le.index=0,le.sibling=null,le}function F(le,ae,ce){if(le.index=ce,!r)return le.flags|=1048576,ae;if(ce=le.alternate,ce!==null)return ce=ce.index,ce<ae?(le.flags|=67108866,ae):ce;return le.flags|=67108866,ae}function D(le){return r&&le.alternate===null&&(le.flags|=67108866),le}function Y(le,ae,ce,_e){if(ae===null||ae.tag!==6)return ae=et(ce,le.mode,_e),ae.return=le,ae;return ae=S(ae,ce),ae.return=le,ae}function ue(le,ae,ce,_e){var Pe=ce.type;if(Pe===m1)return Be(le,ae,ce.props.children,_e,ce.key);if(ae!==null&&(ae.elementType===Pe||typeof Pe==="object"&&Pe!==null&&Pe.$$typeof===zf&&Le(Pe)===ae.type))return ae=S(ae,ce.props),S0(ae,ce),ae.return=le,ae;return ae=ge(ce.type,ce.key,ce.props,null,le.mode,_e),S0(ae,ce),ae.return=le,ae}function ke(le,ae,ce,_e){if(ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ce.containerInfo||ae.stateNode.implementation!==ce.implementation)return ae=Fn(ce,le.mode,_e),ae.return=le,ae;return ae=S(ae,ce.children||[]),ae.return=le,ae}function Be(le,ae,ce,_e,Pe){if(ae===null||ae.tag!==7)return ae=Ge(ce,le.mode,_e,Pe),ae.return=le,ae;return ae=S(ae,ce),ae.return=le,ae}function Ce(le,ae,ce){if(typeof ae==="string"&&ae!==""||typeof ae==="number"||typeof ae==="bigint")return ae=et(""+ae,le.mode,ce),ae.return=le,ae;if(typeof ae==="object"&&ae!==null){switch(ae.$$typeof){case Au:return ce=ge(ae.type,ae.key,ae.props,null,le.mode,ce),S0(ce,ae),ce.return=le,ce;case u1:return ae=Fn(ae,le.mode,ce),ae.return=le,ae;case zf:return ae=Le(ae),Ce(le,ae,ce)}if(yu(ae)||h(ae))return ae=Ge(ae,le.mode,ce,null),ae.return=le,ae;if(typeof ae.then==="function")return Ce(le,$s(ae),ce);if(ae.$$typeof===Ef)return Ce(le,yn(le,ae),ce);Kr(le,ae)}return null}function Ne(le,ae,ce,_e){var Pe=ae!==null?ae.key:null;if(typeof ce==="string"&&ce!==""||typeof ce==="number"||typeof ce==="bigint")return Pe!==null?null:Y(le,ae,""+ce,_e);if(typeof ce==="object"&&ce!==null){switch(ce.$$typeof){case Au:return ce.key===Pe?ue(le,ae,ce,_e):null;case u1:return ce.key===Pe?ke(le,ae,ce,_e):null;case zf:return ce=Le(ce),Ne(le,ae,ce,_e)}if(yu(ce)||h(ce))return Pe!==null?null:Be(le,ae,ce,_e,null);if(typeof ce.then==="function")return Ne(le,ae,$s(ce),_e);if(ce.$$typeof===Ef)return Ne(le,ae,yn(le,ce),_e);Kr(le,ce)}return null}function ht(le,ae,ce,_e,Pe){if(typeof _e==="string"&&_e!==""||typeof _e==="number"||typeof _e==="bigint")return le=le.get(ce)||null,Y(ae,le,""+_e,Pe);if(typeof _e==="object"&&_e!==null){switch(_e.$$typeof){case Au:return le=le.get(_e.key===null?ce:_e.key)||null,ue(ae,le,_e,Pe);case u1:return le=le.get(_e.key===null?ce:_e.key)||null,ke(ae,le,_e,Pe);case zf:return _e=Le(_e),ht(le,ae,ce,_e,Pe)}if(yu(_e)||h(_e))return le=le.get(ce)||null,Be(ae,le,_e,Pe,null);if(typeof _e.then==="function")return ht(le,ae,ce,$s(_e),Pe);if(_e.$$typeof===Ef)return ht(le,ae,ce,yn(ae,_e),Pe);Kr(ae,_e)}return null}function Tn(le,ae,ce,_e){for(var Pe=null,_a=null,st=ae,Rt=ae=0,pn=null;st!==null&&Rt<ce.length;Rt++){st.index>Rt?(pn=st,st=null):pn=st.sibling;var Nt=Ne(le,st,ce[Rt],_e);if(Nt===null){st===null&&(st=pn);break}r&&st&&Nt.alternate===null&&o(le,st),ae=F(Nt,ae,Rt),_a===null?Pe=Nt:_a.sibling=Nt,_a=Nt,st=pn}if(Rt===ce.length)return m(le,st),Ft&&fe(le,Rt),Pe;if(st===null){for(;Rt<ce.length;Rt++)st=Ce(le,ce[Rt],_e),st!==null&&(ae=F(st,ae,Rt),_a===null?Pe=st:_a.sibling=st,_a=st);return Ft&&fe(le,Rt),Pe}for(st=w(st);Rt<ce.length;Rt++)pn=ht(st,le,Rt,ce[Rt],_e),pn!==null&&(r&&pn.alternate!==null&&st.delete(pn.key===null?Rt:pn.key),ae=F(pn,ae,Rt),_a===null?Pe=pn:_a.sibling=pn,_a=pn);return r&&st.forEach(function(Jf){return o(le,Jf)}),Ft&&fe(le,Rt),Pe}function Lc(le,ae,ce,_e){if(ce==null)throw Error(n(151));for(var Pe=null,_a=null,st=ae,Rt=ae=0,pn=null,Nt=ce.next();st!==null&&!Nt.done;Rt++,Nt=ce.next()){st.index>Rt?(pn=st,st=null):pn=st.sibling;var Jf=Ne(le,st,Nt.value,_e);if(Jf===null){st===null&&(st=pn);break}r&&st&&Jf.alternate===null&&o(le,st),ae=F(Jf,ae,Rt),_a===null?Pe=Jf:_a.sibling=Jf,_a=Jf,st=pn}if(Nt.done)return m(le,st),Ft&&fe(le,Rt),Pe;if(st===null){for(;!Nt.done;Rt++,Nt=ce.next())Nt=Ce(le,Nt.value,_e),Nt!==null&&(ae=F(Nt,ae,Rt),_a===null?Pe=Nt:_a.sibling=Nt,_a=Nt);return Ft&&fe(le,Rt),Pe}for(st=w(st);!Nt.done;Rt++,Nt=ce.next())Nt=ht(st,le,Rt,Nt.value,_e),Nt!==null&&(r&&Nt.alternate!==null&&st.delete(Nt.key===null?Rt:Nt.key),ae=F(Nt,ae,Rt),_a===null?Pe=Nt:_a.sibling=Nt,_a=Nt);return r&&st.forEach(function(F_){return o(le,F_)}),Ft&&fe(le,Rt),Pe}function hr(le,ae,ce,_e){if(typeof ce==="object"&&ce!==null&&ce.type===m1&&ce.key===null&&(ce=ce.props.children),typeof ce==="object"&&ce!==null){switch(ce.$$typeof){case Au:e:{for(var Pe=ce.key;ae!==null;){if(ae.key===Pe){if(Pe=ce.type,Pe===m1){if(ae.tag===7){m(le,ae.sibling),_e=S(ae,ce.props.children),_e.return=le,le=_e;break e}}else if(ae.elementType===Pe||typeof Pe==="object"&&Pe!==null&&Pe.$$typeof===zf&&Le(Pe)===ae.type){m(le,ae.sibling),_e=S(ae,ce.props),S0(_e,ce),_e.return=le,le=_e;break e}m(le,ae);break}else o(le,ae);ae=ae.sibling}ce.type===m1?(_e=Ge(ce.props.children,le.mode,_e,ce.key),_e.return=le,le=_e):(_e=ge(ce.type,ce.key,ce.props,null,le.mode,_e),S0(_e,ce),_e.return=le,le=_e)}return D(le);case u1:e:{for(Pe=ce.key;ae!==null;){if(ae.key===Pe)if(ae.tag===4&&ae.stateNode.containerInfo===ce.containerInfo&&ae.stateNode.implementation===ce.implementation){m(le,ae.sibling),_e=S(ae,ce.children||[]),_e.return=le,le=_e;break e}else{m(le,ae);break}else o(le,ae);ae=ae.sibling}_e=Fn(ce,le.mode,_e),_e.return=le,le=_e}return D(le);case zf:return ce=Le(ce),hr(le,ae,ce,_e)}if(yu(ce))return Tn(le,ae,ce,_e);if(h(ce)){if(Pe=h(ce),typeof Pe!=="function")throw Error(n(150));return ce=Pe.call(ce),Lc(le,ae,ce,_e)}if(typeof ce.then==="function")return hr(le,ae,$s(ce),_e);if(ce.$$typeof===Ef)return hr(le,ae,yn(le,ce),_e);Kr(le,ce)}return typeof ce==="string"&&ce!==""||typeof ce==="number"||typeof ce==="bigint"?(ce=""+ce,ae!==null&&ae.tag===6?(m(le,ae.sibling),_e=S(ae,ce),_e.return=le,le=_e):(m(le,ae),_e=et(ce,le.mode,_e),_e.return=le,le=_e),D(le)):m(le,ae)}return function(le,ae,ce,_e){try{Ec=0;var Pe=hr(le,ae,ce,_e);return y1=null,Pe}catch(st){if(st===A1||st===xu)throw st;var _a=t(29,st,null,le.mode);return _a.lanes=_e,_a.return=le,_a}finally{}}}function bf(){for(var r=S1,o=k3=S1=0;o<r;){var m=fi[o];fi[o++]=null;var w=fi[o];fi[o++]=null;var S=fi[o];fi[o++]=null;var F=fi[o];if(fi[o++]=null,w!==null&&S!==null){var D=w.pending;D===null?S.next=S:(S.next=D.next,D.next=S),w.pending=S}F!==0&&y2(m,S,F)}}function C0(r,o,m,w){fi[S1++]=r,fi[S1++]=o,fi[S1++]=m,fi[S1++]=w,k3|=w,r.lanes|=w,r=r.alternate,r!==null&&(r.lanes|=w)}function on(r,o,m,w){return C0(r,o,m,w),F0(r)}function _0(r,o){return C0(r,null,null,o),F0(r)}function y2(r,o,m){r.lanes|=m;var w=r.alternate;w!==null&&(w.lanes|=m);for(var S=!1,F=r.return;F!==null;)F.childLanes|=m,w=F.alternate,w!==null&&(w.childLanes|=m),F.tag===22&&(r=F.stateNode,r===null||r._visibility&1||(S=!0)),r=F,F=F.return;return r.tag===3?(F=r.stateNode,S&&o!==null&&(S=31-xs(m),r=F.hiddenUpdates,w=r[S],w===null?r[S]=[o]:w.push(o),o.lane=m|536870912),F):null}function F0(r){if(50<Kc)throw Kc=0,D3=null,Error(n(185));for(var o=r.return;o!==null;)r=o,o=r.return;return r.tag===3?r.stateNode:null}function Bs(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wf(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function St(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Ei(r,o,m){var w=r.updateQueue;if(w===null)return null;if(w=w.shared,(At&2)!==0){var S=w.pending;return S===null?o.next=o:(o.next=S.next,S.next=o),w.pending=o,o=F0(r),y2(r,null,m),o}return C0(r,w,o,m),F0(r)}function zi(r,o,m){if(o=o.updateQueue,o!==null&&(o=o.shared,(m&4194048)!==0)){var w=o.lanes;w&=r.pendingLanes,m|=w,o.lanes=m,z(r,m)}}function df(r,o){var{updateQueue:m,alternate:w}=r;if(w!==null&&(w=w.updateQueue,m===w)){var S=null,F=null;if(m=m.firstBaseUpdate,m!==null){do{var D={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};F===null?S=F=D:F=F.next=D,m=m.next}while(m!==null);F===null?S=F=o:F=F.next=o}else S=F=o;m={baseState:w.baseState,firstBaseUpdate:S,lastBaseUpdate:F,shared:w.shared,callbacks:w.callbacks},r.updateQueue=m;return}r=m.lastBaseUpdate,r===null?m.firstBaseUpdate=o:r.next=o,m.lastBaseUpdate=o}function Sl(){if(A3){var r=k1;if(r!==null)throw r}}function Ts(r,o,m,w){A3=!1;var S=r.updateQueue;Xf=!1;var{firstBaseUpdate:F,lastBaseUpdate:D}=S,Y=S.shared.pending;if(Y!==null){S.shared.pending=null;var ue=Y,ke=ue.next;ue.next=null,D===null?F=ke:D.next=ke,D=ue;var Be=r.alternate;Be!==null&&(Be=Be.updateQueue,Y=Be.lastBaseUpdate,Y!==D&&(Y===null?Be.firstBaseUpdate=ke:Y.next=ke,Be.lastBaseUpdate=ue))}if(F!==null){var Ce=S.baseState;D=0,Be=ke=ue=null,Y=F;do{var Ne=Y.lane&-536870913,ht=Ne!==Y.lane;if(ht?(Ct&Ne)===Ne:(w&Ne)===Ne){Ne!==0&&Ne===v1&&(A3=!0),Be!==null&&(Be=Be.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var Tn=r,Lc=Y;Ne=o;var hr=m;switch(Lc.tag){case 1:if(Tn=Lc.payload,typeof Tn==="function"){Ce=Tn.call(hr,Ce,Ne);break e}Ce=Tn;break e;case 3:Tn.flags=Tn.flags&-65537|128;case 0:if(Tn=Lc.payload,Ne=typeof Tn==="function"?Tn.call(hr,Ce,Ne):Tn,Ne===null||Ne===void 0)break e;Ce=$n({},Ce,Ne);break e;case 2:Xf=!0}}Ne=Y.callback,Ne!==null&&(r.flags|=64,ht&&(r.flags|=8192),ht=S.callbacks,ht===null?S.callbacks=[Ne]:ht.push(Ne))}else ht={lane:Ne,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Be===null?(ke=Be=ht,ue=Ce):Be=Be.next=ht,D|=Ne;if(Y=Y.next,Y===null)if(Y=S.shared.pending,Y===null)break;else ht=Y,Y=ht.next,ht.next=null,S.lastBaseUpdate=ht,S.shared.pending=null}while(1);Be===null&&(ue=Ce),S.baseState=ue,S.firstBaseUpdate=ke,S.lastBaseUpdate=Be,F===null&&(S.shared.lanes=0),Lf|=D,r.lanes=D,r.memoizedState=Ce}}function fa(r,o){if(typeof r!=="function")throw Error(n(191,r));r.call(o)}function Yo(r,o){var m=r.callbacks;if(m!==null)for(r.callbacks=null,r=0;r<m.length;r++)fa(m[r],o)}function Cl(r,o){r=L0,d(Nu,r),d(C1,o),L0=r|o.baseLanes}function Jo(){d(Nu,L0),d(C1,C1.current)}function Qo(){L0=Nu.current,b(C1),b(Nu)}function Ui(r){var o=r.alternate;d(Xa,Xa.current&1),d(Es,r),li===null&&(o===null||C1.current!==null?li=r:o.memoizedState!==null&&(li=r))}function Lr(r){d(Xa,Xa.current),d(Es,r),li===null&&(li=r)}function Vr(r){r.tag===22?(d(Xa,Xa.current),d(Es,r),li===null&&(li=r)):Ws(r)}function Ws(){d(Xa,Xa.current),d(Es,Es.current)}function Un(r){b(Es),li===r&&(li=null),b(Xa)}function Yr(r){for(var o=r;o!==null;){if(o.tag===13){var m=o.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||o3(m)||c3(m)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}function ja(){throw Error(n(321))}function jf(r,o){if(o===null)return!1;for(var m=0;m<o.length&&m<r.length;m++)if(!Ns(r[m],o[m]))return!1;return!0}function qf(r,o,m,w,S,F){return X0=F,gt=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,We.H=r===null||r.memoizedState===null?Dp:y3,or=!1,F=m(w,S),or=!1,_1&&(F=vf(o,m,w,S)),Zo(r),F}function Zo(r){We.H=Uc;var o=aa!==null&&aa.next!==null;if(X0=0,Za=aa=gt=null,Eu=!1,zc=0,F1=null,o)throw Error(n(300));r===null||$a||(r=r.dependencies,r!==null&&Ze(r)&&($a=!0))}function vf(r,o,m,w){gt=r;var S=0;do{if(_1&&(F1=null),zc=0,_1=!1,25<=S)throw Error(n(301));if(S+=1,Za=aa=null,r.updateQueue!=null){var F=r.updateQueue;F.lastEffect=null,F.events=null,F.stores=null,F.memoCache!=null&&(F.memoCache.index=0)}We.H=xp,F=o(m,w)}while(_1);return F}function _l(){var r=We.H,o=r.useState()[0];return o=typeof o.then==="function"?rs(o):o,r=r.useState()[0],(aa!==null?aa.memoizedState:null)!==r&&(gt.flags|=1024),o}function O0(){var r=zu!==0;return zu=0,r}function B0(r,o,m){o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~m}function $o(r){if(Eu){for(r=r.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}Eu=!1}X0=0,Za=aa=gt=null,_1=!1,zc=zu=0,F1=null}function cn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Za===null?gt.memoizedState=Za=r:Za=Za.next=r,Za}function ya(){if(aa===null){var r=gt.alternate;r=r!==null?r.memoizedState:null}else r=aa.next;var o=Za===null?gt.memoizedState:Za.next;if(o!==null)Za=o,aa=r;else{if(r===null){if(gt.alternate===null)throw Error(n(467));throw Error(n(310))}aa=r,r={memoizedState:aa.memoizedState,baseState:aa.baseState,baseQueue:aa.baseQueue,queue:aa.queue,next:null},Za===null?gt.memoizedState=Za=r:Za=Za.next=r}return Za}function Jr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function rs(r){var o=zc;return zc+=1,F1===null&&(F1=[]),r=Xe(F1,r,o),o=gt,(Za===null?o.memoizedState:Za.next)===null&&(o=o.alternate,We.H=o===null||o.memoizedState===null?Dp:y3),r}function T0(r){if(r!==null&&typeof r==="object"){if(typeof r.then==="function")return rs(r);if(r.$$typeof===Ef)return wt(r)}throw Error(n(438,String(r)))}function Wo(r){var o=null,m=gt.updateQueue;if(m!==null&&(o=m.memoCache),o==null){var w=gt.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(o={data:w.data.map(function(S){return S.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),m===null&&(m=Jr(),gt.updateQueue=m),m.memoCache=o,m=o.data[o.index],m===void 0)for(m=o.data[o.index]=Array(r),w=0;w<r;w++)m[w]=ES;return o.index++,m}function Hs(r,o){return typeof o==="function"?o(r):o}function kf(r){var o=ya();return Jn(o,aa,r)}function Jn(r,o,m){var w=r.queue;if(w===null)throw Error(n(311));w.lastRenderedReducer=m;var S=r.baseQueue,F=w.pending;if(F!==null){if(S!==null){var D=S.next;S.next=F.next,F.next=D}o.baseQueue=S=F,w.pending=null}if(F=r.baseState,S===null)r.memoizedState=F;else{o=S.next;var Y=D=null,ue=null,ke=o,Be=!1;do{var Ce=ke.lane&-536870913;if(Ce!==ke.lane?(Ct&Ce)===Ce:(X0&Ce)===Ce){var Ne=ke.revertLane;if(Ne===0)ue!==null&&(ue=ue.next={lane:0,revertLane:0,gesture:null,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null}),Ce===v1&&(Be=!0);else if((X0&Ne)===Ne){ke=ke.next,Ne===v1&&(Be=!0);continue}else Ce={lane:0,revertLane:ke.revertLane,gesture:null,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null},ue===null?(Y=ue=Ce,D=F):ue=ue.next=Ce,gt.lanes|=Ne,Lf|=Ne;Ce=ke.action,or&&m(F,Ce),F=ke.hasEagerState?ke.eagerState:m(F,Ce)}else Ne={lane:Ce,revertLane:ke.revertLane,gesture:ke.gesture,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null},ue===null?(Y=ue=Ne,D=F):ue=ue.next=Ne,gt.lanes|=Ce,Lf|=Ce;ke=ke.next}while(ke!==null&&ke!==o);if(ue===null?D=F:ue.next=Y,!Ns(F,r.memoizedState)&&($a=!0,Be&&(m=k1,m!==null)))throw m;r.memoizedState=F,r.baseState=D,r.baseQueue=ue,w.lastRenderedState=F}return S===null&&(w.lanes=0),[r.memoizedState,w.dispatch]}function Po(r){var o=ya(),m=o.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=r;var{dispatch:w,pending:S}=m,F=o.memoizedState;if(S!==null){m.pending=null;var D=S=S.next;do F=r(F,D.action),D=D.next;while(D!==S);Ns(F,o.memoizedState)||($a=!0),o.memoizedState=F,o.baseQueue===null&&(o.baseState=F),m.lastRenderedState=F}return[F,w]}function Fl(r,o,m){var w=gt,S=ya(),F=Ft;if(F){if(m===void 0)throw Error(n(407));m=m()}else m=o();var D=!Ns((aa||S).memoizedState,m);if(D&&(S.memoizedState=m,$a=!0),S=S.queue,Zr(H0.bind(null,w,S,r),[r]),S.getSnapshot!==o||D||Za!==null&&Za.memoizedState.tag&1){if(w.flags|=2048,yf(9,{destroy:void 0},Ol.bind(null,w,S,m,o),null),la===null)throw Error(n(349));F||(X0&127)!==0||Af(w,o,m)}return m}function Af(r,o,m){r.flags|=16384,r={getSnapshot:o,value:m},o=gt.updateQueue,o===null?(o=Jr(),gt.updateQueue=o,o.stores=[r]):(m=o.stores,m===null?o.stores=[r]:m.push(r))}function Ol(r,o,m,w){o.value=m,o.getSnapshot=w,Qr(o)&&ec(r)}function H0(r,o,m){return m(function(){Qr(o)&&ec(r)})}function Qr(r){var o=r.getSnapshot;r=r.value;try{var m=o();return!Ns(r,m)}catch(w){return!0}}function ec(r){var o=_0(r,2);o!==null&&un(o,r,2)}function Bl(r){var o=cn();if(typeof r==="function"){var m=r;if(r=m(),or){P(!0);try{m()}finally{P(!1)}}}return o.memoizedState=o.baseState=r,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:r},o}function S2(r,o,m,w){return r.baseState=m,Jn(r,aa,typeof w==="function"?w:Hs)}function Q5(r,o,m,w,S){if(M0(r))throw Error(n(485));if(r=o.action,r!==null){var F={payload:S,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(D){F.listeners.push(D)}};We.T!==null?m(!0):F.isTransition=!1,w(F),m=o.pending,m===null?(F.next=o.pending=F,C2(o,F)):(F.next=m.next,o.pending=m.next=F)}}function C2(r,o){var{action:m,payload:w}=o,S=r.state;if(o.isTransition){var F=We.T,D={};We.T=D;try{var Y=m(S,w),ue=We.S;ue!==null&&ue(D,Y),Tl(r,o,Y)}catch(ke){ac(r,o,ke)}finally{F!==null&&D.types!==null&&(F.types=D.types),We.T=F}}else try{F=m(S,w),Tl(r,o,F)}catch(ke){ac(r,o,ke)}}function Tl(r,o,m){m!==null&&typeof m==="object"&&typeof m.then==="function"?m.then(function(w){tc(r,o,w)},function(w){return ac(r,o,w)}):tc(r,o,m)}function tc(r,o,m){o.status="fulfilled",o.value=m,nc(o),r.state=m,o=r.pending,o!==null&&(m=o.next,m===o?r.pending=null:(m=m.next,o.next=m,C2(r,m)))}function ac(r,o,m){var w=r.pending;if(r.pending=null,w!==null){w=w.next;do o.status="rejected",o.reason=m,nc(o),o=o.next;while(o!==w)}r.action=null}function nc(r){r=r.listeners;for(var o=0;o<r.length;o++)(0,r[o])()}function _2(r,o){return o}function sc(r,o){if(Ft){var m=la.formState;if(m!==null){e:{var w=gt;if(Ft){if(Sa){var S=TC(Sa,ii);if(S){Sa=bp(S),w=HC(S);break e}}mt(w)}w=!1}w&&(o=m[0])}}m=cn(),m.memoizedState=m.baseState=o,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_2,lastRenderedState:o},m.queue=w,m=Ul.bind(null,gt,w),w.dispatch=m,w=Bl(!1);var F=Ms.bind(null,gt,!1,w.queue);return w=cn(),S={state:o,dispatch:null,action:r,pending:null},w.queue=S,m=Q5.bind(null,gt,S,F,m),S.dispatch=m,w.memoizedState=r,[o,m,!1]}function F2(r){var o=ya();return Hl(o,aa,r)}function Hl(r,o,m){if(o=Jn(r,o,_2)[0],r=kf(Hs)[0],typeof o==="object"&&o!==null&&typeof o.then==="function")try{var w=rs(o)}catch(D){if(D===A1)throw xu;throw D}else w=o;o=ya();var S=o.queue,F=S.dispatch;return m!==o.memoizedState&&(gt.flags|=2048,yf(9,{destroy:void 0},Ml.bind(null,S,m),null)),[w,F,r]}function Ml(r,o){r.action=o}function ic(r){var o=ya(),m=aa;if(m!==null)return Hl(o,m,r);ya(),o=o.memoizedState,m=ya();var w=m.queue.dispatch;return m.memoizedState=r,[o,w,!1]}function yf(r,o,m,w){return r={tag:r,create:m,deps:w,inst:o,next:null},o=gt.updateQueue,o===null&&(o=Jr(),gt.updateQueue=o),m=o.lastEffect,m===null?o.lastEffect=r.next=r:(w=m.next,m.next=r,r.next=w,o.lastEffect=r),r}function O2(){return ya().memoizedState}function Dl(r,o,m,w){var S=cn();gt.flags|=r,S.memoizedState=yf(1|o,{destroy:void 0},m,w===void 0?null:w)}function xl(r,o,m,w){var S=ya();w=w===void 0?null:w;var F=S.memoizedState.inst;aa!==null&&w!==null&&jf(w,aa.memoizedState.deps)?S.memoizedState=yf(o,F,m,w):(gt.flags|=r,S.memoizedState=yf(1|o,F,m,w))}function B2(r,o){Dl(8390656,8,r,o)}function Zr(r,o){xl(2048,8,r,o)}function Z5(r){gt.flags|=4;var o=gt.updateQueue;if(o===null)o=Jr(),gt.updateQueue=o,o.events=[r];else{var m=o.events;m===null?o.events=[r]:m.push(r)}}function T2(r){var o=ya().memoizedState;return Z5({ref:o,nextImpl:r}),function(){if((At&2)!==0)throw Error(n(440));return o.impl.apply(void 0,arguments)}}function H2(r,o){return xl(4,2,r,o)}function M2(r,o){return xl(4,4,r,o)}function D2(r,o){if(typeof o==="function"){r=r();var m=o(r);return function(){typeof m==="function"?m():o(null)}}if(o!==null&&o!==void 0)return r=r(),o.current=r,function(){o.current=null}}function x2(r,o,m){m=m!==null&&m!==void 0?m.concat([r]):null,xl(4,4,D2.bind(null,o,r),m)}function Rl(){}function R2(r,o){var m=ya();o=o===void 0?null:o;var w=m.memoizedState;if(o!==null&&jf(o,w[1]))return w[0];return m.memoizedState=[r,o],r}function fc(r,o){var m=ya();o=o===void 0?null:o;var w=m.memoizedState;if(o!==null&&jf(o,w[1]))return w[0];if(w=r(),or){P(!0);try{r()}finally{P(!1)}}return m.memoizedState=[w,o],w}function Sf(r,o,m){if(m===void 0||(X0&1073741824)!==0&&(Ct&261930)===0)return r.memoizedState=o;return r.memoizedState=m,r=Fc(),gt.lanes|=r,Lf|=r,m}function N2(r,o,m,w){if(Ns(m,o))return m;if(C1.current!==null)return r=Sf(r,m,w),Ns(r,o)||($a=!0),r;if((X0&42)===0||(X0&1073741824)!==0&&(Ct&261930)===0)return $a=!0,r.memoizedState=m;return r=Fc(),gt.lanes|=r,Lf|=r,o}function E2(r,o,m,w,S){var F=I0();mn(F!==0&&8>F?F:8);var D=We.T,Y={};We.T=Y,Ms(r,!1,o,m);try{var ue=S(),ke=We.S;if(ke!==null&&ke(Y,ue),ue!==null&&typeof ue==="object"&&typeof ue.then==="function"){var Be=Me(ue,w);Cn(r,o,Be,hs(r))}else Cn(r,o,w,hs(r))}catch(Ce){Cn(r,o,{then:function(){},status:"rejected",reason:Ce},hs())}finally{mn(F),D!==null&&Y.types!==null&&(D.types=Y.types),We.T=D}}function z2(r){var o=r.memoizedState;if(o!==null)return o;o={memoizedState:g1,baseState:g1,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:g1},next:null};var m={};return o.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:m},next:null},r.memoizedState=o,r=r.alternate,r!==null&&(r.memoizedState=o),o}function lc(){return wt(nr)}function U2(){return ya().memoizedState}function Nl(){return ya().memoizedState}function El(r){for(var o=r.return;o!==null;){switch(o.tag){case 24:case 3:var m=hs();r=St(m);var w=Ei(o,r,m);w!==null&&(un(w,o,m),zi(w,o,m)),o={cache:Ya()},r.payload=o;return}o=o.return}}function zl(r,o,m){var w=hs();m={lane:w,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},M0(r)?rc(o,m):(m=on(r,o,m,w),m!==null&&(un(m,r,w),I2(m,o,w)))}function Ul(r,o,m){var w=hs();Cn(r,o,m,w)}function Cn(r,o,m,w){var S={lane:w,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null};if(M0(r))rc(o,S);else{var F=r.alternate;if(r.lanes===0&&(F===null||F.lanes===0)&&(F=o.lastRenderedReducer,F!==null))try{var D=o.lastRenderedState,Y=F(D,m);if(S.hasEagerState=!0,S.eagerState=Y,Ns(Y,D))return C0(r,o,S,0),la===null&&bf(),!1}catch(ue){}finally{}if(m=on(r,o,S,w),m!==null)return un(m,r,w),I2(m,o,w),!0}return!1}function Ms(r,o,m,w){if(w={lane:2,revertLane:xt(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},M0(r)){if(o)throw Error(n(479))}else o=on(r,m,w,2),o!==null&&un(o,r,2)}function M0(r){var o=r.alternate;return r===gt||o!==null&&o===gt}function rc(r,o){_1=Eu=!0;var m=r.pending;m===null?o.next=o:(o.next=m.next,m.next=o),r.pending=o}function I2(r,o,m){if((m&4194048)!==0){var w=o.lanes;w&=r.pendingLanes,m|=w,o.lanes=m,z(r,m)}}function oc(r,o,m,w){o=r.memoizedState,m=m(w,o),m=m===null||m===void 0?o:$n({},o,m),r.memoizedState=m,r.lanes===0&&(r.updateQueue.baseState=m)}function G2(r,o,m,w,S,F,D){return r=r.stateNode,typeof r.shouldComponentUpdate==="function"?r.shouldComponentUpdate(w,F,D):o.prototype&&o.prototype.isPureReactComponent?!Se(m,w)||!Se(S,F):!0}function X2(r,o,m,w){r=o.state,typeof o.componentWillReceiveProps==="function"&&o.componentWillReceiveProps(m,w),typeof o.UNSAFE_componentWillReceiveProps==="function"&&o.UNSAFE_componentWillReceiveProps(m,w),o.state!==r&&S3.enqueueReplaceState(o,o.state,null)}function yi(r,o){var m=o;if("ref"in o){m={};for(var w in o)w!=="ref"&&(m[w]=o[w])}if(r=r.defaultProps){m===o&&(m=$n({},m));for(var S in r)m[S]===void 0&&(m[S]=r[S])}return m}function Cf(r,o){try{var m=r.onUncaughtError;m(o.value,{componentStack:o.stack})}catch(w){setTimeout(function(){throw w})}}function _f(r,o,m){try{var w=r.onCaughtError;w(m.value,{componentStack:m.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(S){setTimeout(function(){throw S})}}function Ii(r,o,m){return m=St(m),m.tag=3,m.payload={element:null},m.callback=function(){Cf(r,o)},m}function Il(r){return r=St(r),r.tag=3,r}function Gi(r,o,m,w){var S=m.type.getDerivedStateFromError;if(typeof S==="function"){var F=w.value;r.payload=function(){return S(F)},r.callback=function(){_f(o,m,w)}}var D=m.stateNode;D!==null&&typeof D.componentDidCatch==="function"&&(r.callback=function(){_f(o,m,w),typeof S!=="function"&&(Vf===null?Vf=new Set([this]):Vf.add(this));var Y=w.stack;this.componentDidCatch(w.value,{componentStack:Y!==null?Y:""})})}function $5(r,o,m,w,S){if(m.flags|=32768,w!==null&&typeof w==="object"&&typeof w.then==="function"){if(o=m.alternate,o!==null&&Ot(o,m,S,!0),m=Es.current,m!==null){switch(m.tag){case 31:case 13:return li===null?er():m.alternate===null&&Ra===0&&(Ra=3),m.flags&=-257,m.flags|=65536,m.lanes=S,w===Ru?m.flags|=16384:(o=m.updateQueue,o===null?m.updateQueue=new Set([w]):o.add(w),k(r,w,S)),!1;case 22:return m.flags|=65536,w===Ru?m.flags|=16384:(o=m.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([w])},m.updateQueue=o):(m=o.retryQueue,m===null?o.retryQueue=new Set([w]):m.add(w)),k(r,w,S)),!1}throw Error(n(435,m.tag))}return k(r,w,S),er(),!1}if(Ft)return o=Es.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=S,w!==w3&&(r=Error(n(422),{cause:w}),jt(ne(r,m)))):(w!==w3&&(o=Error(n(423),{cause:w}),jt(ne(o,m))),r=r.current.alternate,r.flags|=65536,S&=-S,r.lanes|=S,w=ne(w,m),S=Ii(r.stateNode,w,S),df(r,S),Ra!==4&&(Ra=2)),!1;var F=Error(n(520),{cause:w});if(F=ne(F,m),Gc===null?Gc=[F]:Gc.push(F),Ra!==4&&(Ra=2),o===null)return!0;w=ne(w,m),m=o;do{switch(m.tag){case 3:return m.flags|=65536,r=S&-S,m.lanes|=r,r=Ii(m.stateNode,w,r),df(m,r),!1;case 1:if(o=m.type,F=m.stateNode,(m.flags&128)===0&&(typeof o.getDerivedStateFromError==="function"||F!==null&&typeof F.componentDidCatch==="function"&&(Vf===null||!Vf.has(F))))return m.flags|=65536,S&=-S,m.lanes|=S,S=Il(S),Gi(S,r,m,w),df(m,S),!1}m=m.return}while(m!==null);return!1}function Qa(r,o,m,w){o.child=r===null?Mp(o,null,m,w):rr(o,r.child,m,w)}function cc(r,o,m,w,S){m=m.render;var F=o.ref;if("ref"in w){var D={};for(var Y in w)Y!=="ref"&&(D[Y]=w[Y])}else D=w;if(Yt(o),w=qf(r,o,m,D,F,S),Y=O0(),r!==null&&!$a)return B0(r,o,S),Ps(r,o,S);return Ft&&Y&&he(o),o.flags|=1,Qa(r,o,w,S),o.child}function $r(r,o,m,w,S){if(r===null){var F=m.type;if(typeof F==="function"&&!W(F)&&F.defaultProps===void 0&&m.compare===null)return o.tag=15,o.type=F,K2(r,o,F,w,S);return r=ge(m.type,null,w,o,o.mode,S),r.ref=o.ref,r.return=o,o.child=r}if(F=r.child,!gc(r,S)){var D=F.memoizedProps;if(m=m.compare,m=m!==null?m:Se,m(D,w)&&r.ref===o.ref)return Ps(r,o,S)}return o.flags|=1,r=oe(F,w),r.ref=o.ref,r.return=o,o.child=r}function K2(r,o,m,w,S){if(r!==null){var F=r.memoizedProps;if(Se(F,w)&&r.ref===o.ref)if($a=!1,o.pendingProps=w=F,gc(r,S))(r.flags&131072)!==0&&($a=!0);else return o.lanes=r.lanes,Ps(r,o,S)}return t1(r,o,m,w,S)}function L2(r,o,m,w){var S=w.children,F=r!==null?r.memoizedState:null;if(r===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),w.mode==="hidden"){if((o.flags&128)!==0){if(F=F!==null?F.baseLanes|m:m,r!==null){w=o.child=r.child;for(S=0;w!==null;)S=S|w.lanes|w.childLanes,w=w.sibling;w=S&~F}else w=0,o.child=null;return Xl(r,o,F,m,w)}if((m&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},r!==null&&zt(o,F!==null?F.cachePool:null),F!==null?Cl(o,F):Jo(),Vr(o);else return w=o.lanes=536870912,Xl(r,o,F!==null?F.baseLanes|m:m,m,w)}else F!==null?(zt(o,F.cachePool),Cl(o,F),Ws(o),o.memoizedState=null):(r!==null&&zt(o,null),Jo(),Ws(o));return Qa(r,o,S,m),o.child}function Gl(r,o){return r!==null&&r.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function Xl(r,o,m,w,S){var F=Re();return F=F===null?null:{parent:U0?Ca._currentValue:Ca._currentValue2,pool:F},o.memoizedState={baseLanes:m,cachePool:F},r!==null&&zt(o,null),Jo(),Vr(o),r!==null&&Ot(r,o,w,!0),o.childLanes=S,null}function Wr(r,o){return o=Yl({mode:o.mode,children:o.children},r.mode),o.ref=r.ref,r.child=o,o.return=r,o}function Pr(r,o,m){return rr(o,r.child,null,m),r=Wr(o,o.pendingProps),r.flags|=2,Un(o),o.memoizedState=null,r}function W5(r,o,m){var w=o.pendingProps,S=(o.flags&128)!==0;if(o.flags&=-129,r===null){if(Ft){if(w.mode==="hidden")return r=Wr(o,w),o.lanes=536870912,Gl(null,r);if(Lr(o),(r=Sa)?(r=IC(r,ii),r!==null&&(o.memoizedState={dehydrated:r,treeContext:Uf!==null?{id:Yi,overflow:Ji}:null,retryLane:536870912,hydrationErrors:null},m=Ga(r),m.return=o,o.child=m,Bn=o,Sa=null)):r=null,r===null)throw mt(o);return o.lanes=536870912,null}return Wr(o,w)}var F=r.memoizedState;if(F!==null){var D=F.dehydrated;if(Lr(o),S)if(o.flags&256)o.flags&=-257,o=Pr(r,o,m);else if(o.memoizedState!==null)o.child=r.child,o.flags|=128,o=null;else throw Error(n(558));else if($a||Ot(r,o,m,!1),S=(m&r.childLanes)!==0,$a||S){if(w=la,w!==null&&(D=K(w,m),D!==0&&D!==F.retryLane))throw F.retryLane=D,_0(r,D),un(w,r,D),C3;er(),o=Pr(r,o,m)}else r=F.treeContext,Xn&&(Sa=RC(D),Bn=o,Ft=!0,Gf=null,ii=!1,r!==null&&be(o,r)),o=Wr(o,w),o.flags|=4096;return o}return r=oe(r.child,{mode:w.mode,children:w.children}),r.ref=o.ref,o.child=r,r.return=o,r}function e1(r,o){var m=o.ref;if(m===null)r!==null&&r.ref!==null&&(o.flags|=4194816);else{if(typeof m!=="function"&&typeof m!=="object")throw Error(n(284));if(r===null||r.ref!==m)o.flags|=4194816}}function t1(r,o,m,w,S){if(Yt(o),m=qf(r,o,m,w,void 0,S),w=O0(),r!==null&&!$a)return B0(r,o,S),Ps(r,o,S);return Ft&&w&&he(o),o.flags|=1,Qa(r,o,m,S),o.child}function Kl(r,o,m,w,S,F){if(Yt(o),o.updateQueue=null,m=vf(o,w,m,S),Zo(r),w=O0(),r!==null&&!$a)return B0(r,o,F),Ps(r,o,F);return Ft&&w&&he(o),o.flags|=1,Qa(r,o,m,F),o.child}function V2(r,o,m,w,S){if(Yt(o),o.stateNode===null){var F=w1,D=m.contextType;typeof D==="object"&&D!==null&&(F=wt(D)),F=new m(w,F),o.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=S3,o.stateNode=F,F._reactInternals=o,F=o.stateNode,F.props=w,F.state=o.memoizedState,F.refs={},Bs(o),D=m.contextType,F.context=typeof D==="object"&&D!==null?wt(D):w1,F.state=o.memoizedState,D=m.getDerivedStateFromProps,typeof D==="function"&&(oc(o,m,D,w),F.state=o.memoizedState),typeof m.getDerivedStateFromProps==="function"||typeof F.getSnapshotBeforeUpdate==="function"||typeof F.UNSAFE_componentWillMount!=="function"&&typeof F.componentWillMount!=="function"||(D=F.state,typeof F.componentWillMount==="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount==="function"&&F.UNSAFE_componentWillMount(),D!==F.state&&S3.enqueueReplaceState(F,F.state,null),Ts(o,w,F,S),Sl(),F.state=o.memoizedState),typeof F.componentDidMount==="function"&&(o.flags|=4194308),w=!0}else if(r===null){F=o.stateNode;var Y=o.memoizedProps,ue=yi(m,Y);F.props=ue;var ke=F.context,Be=m.contextType;D=w1,typeof Be==="object"&&Be!==null&&(D=wt(Be));var Ce=m.getDerivedStateFromProps;Be=typeof Ce==="function"||typeof F.getSnapshotBeforeUpdate==="function",Y=o.pendingProps!==Y,Be||typeof F.UNSAFE_componentWillReceiveProps!=="function"&&typeof F.componentWillReceiveProps!=="function"||(Y||ke!==D)&&X2(o,F,w,D),Xf=!1;var Ne=o.memoizedState;F.state=Ne,Ts(o,w,F,S),Sl(),ke=o.memoizedState,Y||Ne!==ke||Xf?(typeof Ce==="function"&&(oc(o,m,Ce,w),ke=o.memoizedState),(ue=Xf||G2(o,m,ue,w,Ne,ke,D))?(Be||typeof F.UNSAFE_componentWillMount!=="function"&&typeof F.componentWillMount!=="function"||(typeof F.componentWillMount==="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount==="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount==="function"&&(o.flags|=4194308)):(typeof F.componentDidMount==="function"&&(o.flags|=4194308),o.memoizedProps=w,o.memoizedState=ke),F.props=w,F.state=ke,F.context=D,w=ue):(typeof F.componentDidMount==="function"&&(o.flags|=4194308),w=!1)}else{F=o.stateNode,wf(r,o),D=o.memoizedProps,Be=yi(m,D),F.props=Be,Ce=o.pendingProps,Ne=F.context,ke=m.contextType,ue=w1,typeof ke==="object"&&ke!==null&&(ue=wt(ke)),Y=m.getDerivedStateFromProps,(ke=typeof Y==="function"||typeof F.getSnapshotBeforeUpdate==="function")||typeof F.UNSAFE_componentWillReceiveProps!=="function"&&typeof F.componentWillReceiveProps!=="function"||(D!==Ce||Ne!==ue)&&X2(o,F,w,ue),Xf=!1,Ne=o.memoizedState,F.state=Ne,Ts(o,w,F,S),Sl();var ht=o.memoizedState;D!==Ce||Ne!==ht||Xf||r!==null&&r.dependencies!==null&&Ze(r.dependencies)?(typeof Y==="function"&&(oc(o,m,Y,w),ht=o.memoizedState),(Be=Xf||G2(o,m,Be,w,Ne,ht,ue)||r!==null&&r.dependencies!==null&&Ze(r.dependencies))?(ke||typeof F.UNSAFE_componentWillUpdate!=="function"&&typeof F.componentWillUpdate!=="function"||(typeof F.componentWillUpdate==="function"&&F.componentWillUpdate(w,ht,ue),typeof F.UNSAFE_componentWillUpdate==="function"&&F.UNSAFE_componentWillUpdate(w,ht,ue)),typeof F.componentDidUpdate==="function"&&(o.flags|=4),typeof F.getSnapshotBeforeUpdate==="function"&&(o.flags|=1024)):(typeof F.componentDidUpdate!=="function"||D===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=4),typeof F.getSnapshotBeforeUpdate!=="function"||D===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=1024),o.memoizedProps=w,o.memoizedState=ht),F.props=w,F.state=ht,F.context=ue,w=Be):(typeof F.componentDidUpdate!=="function"||D===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=4),typeof F.getSnapshotBeforeUpdate!=="function"||D===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=1024),w=!1)}return F=w,e1(r,o),w=(o.flags&128)!==0,F||w?(F=o.stateNode,m=w&&typeof m.getDerivedStateFromError!=="function"?null:F.render(),o.flags|=1,r!==null&&w?(o.child=rr(o,r.child,null,S),o.child=rr(o,null,m,S)):Qa(r,o,m,S),o.memoizedState=F.state,r=o.child):r=Ps(r,o,S),r}function Y2(r,o,m,w){return ta(),o.flags|=256,Qa(r,o,m,w),o.child}function hc(r){return{baseLanes:r,cachePool:Ua()}}function Ll(r,o,m){return r=r!==null?r.childLanes&~m:0,o&&(r|=Us),r}function J2(r,o,m){var w=o.pendingProps,S=!1,F=(o.flags&128)!==0,D;if((D=F)||(D=r!==null&&r.memoizedState===null?!1:(Xa.current&2)!==0),D&&(S=!0,o.flags&=-129),D=(o.flags&32)!==0,o.flags&=-33,r===null){if(Ft){if(S?Ui(o):Ws(o),(r=Sa)?(r=GC(r,ii),r!==null&&(o.memoizedState={dehydrated:r,treeContext:Uf!==null?{id:Yi,overflow:Ji}:null,retryLane:536870912,hydrationErrors:null},m=Ga(r),m.return=o,o.child=m,Bn=o,Sa=null)):r=null,r===null)throw mt(o);return c3(r)?o.lanes=32:o.lanes=536870912,null}var Y=w.children;if(w=w.fallback,S)return Ws(o),S=o.mode,Y=Yl({mode:"hidden",children:Y},S),w=Ge(w,S,m,null),Y.return=o,w.return=o,Y.sibling=w,o.child=Y,w=o.child,w.memoizedState=hc(m),w.childLanes=Ll(r,D,m),o.memoizedState=_3,Gl(null,w);return Ui(o),Vl(o,Y)}var ue=r.memoizedState;if(ue!==null&&(Y=ue.dehydrated,Y!==null)){if(F)o.flags&256?(Ui(o),o.flags&=-257,o=uc(r,o,m)):o.memoizedState!==null?(Ws(o),o.child=r.child,o.flags|=128,o=null):(Ws(o),Y=w.fallback,S=o.mode,w=Yl({mode:"visible",children:w.children},S),Y=Ge(Y,S,m,null),Y.flags|=2,w.return=o,Y.return=o,w.sibling=Y,o.child=w,rr(o,r.child,null,m),w=o.child,w.memoizedState=hc(m),w.childLanes=Ll(r,D,m),o.memoizedState=_3,o=Gl(null,w));else if(Ui(o),c3(Y))D=OC(Y).digest,w=Error(n(419)),w.stack="",w.digest=D,jt({value:w,source:null,stack:null}),o=uc(r,o,m);else if($a||Ot(r,o,m,!1),D=(m&r.childLanes)!==0,$a||D){if(D=la,D!==null&&(w=K(D,m),w!==0&&w!==ue.retryLane))throw ue.retryLane=w,_0(r,w),un(D,r,w),C3;o3(Y)||er(),o=uc(r,o,m)}else o3(Y)?(o.flags|=192,o.child=r.child,o=null):(r=ue.treeContext,Xn&&(Sa=NC(Y),Bn=o,Ft=!0,Gf=null,ii=!1,r!==null&&be(o,r)),o=Vl(o,w.children),o.flags|=4096);return o}if(S)return Ws(o),Y=w.fallback,S=o.mode,ue=r.child,F=ue.sibling,w=oe(ue,{mode:"hidden",children:w.children}),w.subtreeFlags=ue.subtreeFlags&65011712,F!==null?Y=oe(F,Y):(Y=Ge(Y,S,m,null),Y.flags|=2),Y.return=o,w.return=o,w.sibling=Y,o.child=w,Gl(null,w),w=o.child,Y=r.child.memoizedState,Y===null?Y=hc(m):(S=Y.cachePool,S!==null?(ue=U0?Ca._currentValue:Ca._currentValue2,S=S.parent!==ue?{parent:ue,pool:ue}:S):S=Ua(),Y={baseLanes:Y.baseLanes|m,cachePool:S}),w.memoizedState=Y,w.childLanes=Ll(r,D,m),o.memoizedState=_3,Gl(r.child,w);return Ui(o),m=r.child,r=m.sibling,m=oe(m,{mode:"visible",children:w.children}),m.return=o,m.sibling=null,r!==null&&(D=o.deletions,D===null?(o.deletions=[r],o.flags|=16):D.push(r)),o.child=m,o.memoizedState=null,m}function Vl(r,o){return o=Yl({mode:"visible",children:o},r.mode),o.return=r,r.child=o}function Yl(r,o){return r=t(22,r,null,o),r.lanes=0,r}function uc(r,o,m){return rr(o,r.child,null,m),r=Vl(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function Q2(r,o,m){r.lanes|=o;var w=r.alternate;w!==null&&(w.lanes|=o),Qe(r.return,o,m)}function mc(r,o,m,w,S,F){var D=r.memoizedState;D===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:S,treeForkCount:F}:(D.isBackwards=o,D.rendering=null,D.renderingStartTime=0,D.last=w,D.tail=m,D.tailMode=S,D.treeForkCount=F)}function Z2(r,o,m){var w=o.pendingProps,S=w.revealOrder,F=w.tail;w=w.children;var D=Xa.current,Y=(D&2)!==0;if(Y?(D=D&1|2,o.flags|=128):D&=1,d(Xa,D),Qa(r,o,w,m),w=Ft?xc:0,!Y&&r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Q2(r,m,o);else if(r.tag===19)Q2(r,m,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(S){case"forwards":m=o.child;for(S=null;m!==null;)r=m.alternate,r!==null&&Yr(r)===null&&(S=m),m=m.sibling;m=S,m===null?(S=o.child,o.child=null):(S=m.sibling,m.sibling=null),mc(o,!1,S,m,F,w);break;case"backwards":case"unstable_legacy-backwards":m=null,S=o.child;for(o.child=null;S!==null;){if(r=S.alternate,r!==null&&Yr(r)===null){o.child=S;break}r=S.sibling,S.sibling=m,m=S,S=r}mc(o,!0,m,null,F,w);break;case"together":mc(o,!1,null,null,void 0,w);break;default:o.memoizedState=null}return o.child}function Ps(r,o,m){if(r!==null&&(o.dependencies=r.dependencies),Lf|=o.lanes,(m&o.childLanes)===0)if(r!==null){if(Ot(r,o,m,!1),(m&o.childLanes)===0)return null}else return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){r=o.child,m=oe(r,r.pendingProps),o.child=m;for(m.return=o;r.sibling!==null;)r=r.sibling,m=m.sibling=oe(r,r.pendingProps),m.return=o;m.sibling=null}return o.child}function gc(r,o){if((r.lanes&o)!==0)return!0;return r=r.dependencies,r!==null&&Ze(r)?!0:!1}function $2(r,o,m){switch(o.tag){case 3:Ue(o,o.stateNode.containerInfo),xe(o,Ca,r.memoizedState.cache),ta();break;case 27:case 5:Ye(o);break;case 4:Ue(o,o.stateNode.containerInfo);break;case 10:xe(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Lr(o),null;break;case 13:var w=o.memoizedState;if(w!==null){if(w.dehydrated!==null)return Ui(o),o.flags|=128,null;if((m&o.child.childLanes)!==0)return J2(r,o,m);return Ui(o),r=Ps(r,o,m),r!==null?r.sibling:null}Ui(o);break;case 19:var S=(r.flags&128)!==0;if(w=(m&o.childLanes)!==0,w||(Ot(r,o,m,!1),w=(m&o.childLanes)!==0),S){if(w)return Z2(r,o,m);o.flags|=128}if(S=o.memoizedState,S!==null&&(S.rendering=null,S.tail=null,S.lastEffect=null),d(Xa,Xa.current),w)break;else return null;case 22:return o.lanes=0,L2(r,o,m,o.pendingProps);case 24:xe(o,Ca,r.memoizedState.cache)}return Ps(r,o,m)}function W2(r,o,m){if(r!==null)if(r.memoizedProps!==o.pendingProps)$a=!0;else{if(!gc(r,m)&&(o.flags&128)===0)return $a=!1,$2(r,o,m);$a=(r.flags&131072)!==0?!0:!1}else $a=!1,Ft&&(o.flags&1048576)!==0&&Ae(o,xc,o.index);switch(o.lanes=0,o.tag){case 16:e:{var w=o.pendingProps;if(r=Le(o.elementType),o.type=r,typeof r==="function")W(r)?(w=yi(r,w),o.tag=1,o=V2(null,o,r,w,m)):(o.tag=0,o=t1(null,o,r,w,m));else{if(r!==void 0&&r!==null){var S=r.$$typeof;if(S===a3){o.tag=11,o=cc(null,o,r,w,m);break e}else if(S===i3){o.tag=14,o=$r(null,o,r,w,m);break e}}throw o=u(r)||r,Error(n(306,o,""))}}return o;case 0:return t1(r,o,o.type,o.pendingProps,m);case 1:return w=o.type,S=yi(w,o.pendingProps),V2(r,o,w,S,m);case 3:e:{if(Ue(o,o.stateNode.containerInfo),r===null)throw Error(n(387));var F=o.pendingProps;S=o.memoizedState,w=S.element,wf(r,o),Ts(o,F,null,m);var D=o.memoizedState;if(F=D.cache,xe(o,Ca,F),F!==S.cache&&nt(o,[Ca],m,!0),Sl(),F=D.element,Xn&&S.isDehydrated)if(S={element:F,isDehydrated:!1,cache:D.cache},o.updateQueue.baseState=S,o.memoizedState=S,o.flags&256){o=Y2(r,o,F,m);break e}else if(F!==w){w=ne(Error(n(424)),o),jt(w),o=Y2(r,o,F,m);break e}else for(Xn&&(Sa=xC(o.stateNode.containerInfo),Bn=o,Ft=!0,Gf=null,ii=!0),m=Mp(o,null,F,m),o.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(ta(),F===w){o=Ps(r,o,m);break e}Qa(r,o,F,m)}o=o.child}return o;case 26:if(_i)return e1(r,o),r===null?(m=jp(o.type,null,o.pendingProps,null))?o.memoizedState=m:Ft||(o.stateNode=r_(o.type,o.pendingProps,If.current,o)):o.memoizedState=jp(o.type,r.memoizedProps,o.pendingProps,r.memoizedState),null;case 27:if(nn)return Ye(o),r===null&&nn&&Ft&&(w=o.stateNode=Sp(o.type,o.pendingProps,If.current,On.current,!1),Bn=o,ii=!0,Sa=EC(o.type,w,Sa)),Qa(r,o,o.pendingProps.children,m),e1(r,o),r===null&&(o.flags|=4194304),o.child;case 5:if(r===null&&Ft){if(i_(o.type,o.pendingProps,On.current),S=w=Sa)w=zC(w,o.type,o.pendingProps,ii),w!==null?(o.stateNode=w,Bn=o,Sa=DC(w),ii=!1,S=!0):S=!1;S||mt(o)}return Ye(o),S=o.type,F=o.pendingProps,D=r!==null?r.memoizedProps:null,w=F.children,Su(S,F)?w=null:D!==null&&Su(S,D)&&(o.flags|=32),o.memoizedState!==null&&(S=qf(r,o,_l,null,null,m),U0?nr._currentValue=S:nr._currentValue2=S),e1(r,o),Qa(r,o,w,m),o.child;case 6:if(r===null&&Ft){if(f_(o.pendingProps,On.current),r=m=Sa)m=UC(m,o.pendingProps,ii),m!==null?(o.stateNode=m,Bn=o,Sa=null,r=!0):r=!1;r||mt(o)}return null;case 13:return J2(r,o,m);case 4:return Ue(o,o.stateNode.containerInfo),w=o.pendingProps,r===null?o.child=rr(o,null,w,m):Qa(r,o,w,m),o.child;case 11:return cc(r,o,o.type,o.pendingProps,m);case 7:return Qa(r,o,o.pendingProps,m),o.child;case 8:return Qa(r,o,o.pendingProps.children,m),o.child;case 12:return Qa(r,o,o.pendingProps.children,m),o.child;case 10:return w=o.pendingProps,xe(o,o.type,w.value),Qa(r,o,w.children,m),o.child;case 9:return S=o.type._context,w=o.pendingProps.children,Yt(o),S=wt(S),w=w(S),o.flags|=1,Qa(r,o,w,m),o.child;case 14:return $r(r,o,o.type,o.pendingProps,m);case 15:return K2(r,o,o.type,o.pendingProps,m);case 19:return Z2(r,o,m);case 31:return W5(r,o,m);case 22:return L2(r,o,m,o.pendingProps);case 24:return Yt(o),w=wt(Ca),r===null?(S=Re(),S===null&&(S=la,F=Ya(),S.pooledCache=F,F.refCount++,F!==null&&(S.pooledCacheLanes|=m),S=F),o.memoizedState={parent:w,cache:S},Bs(o),xe(o,Ca,S)):((r.lanes&m)!==0&&(wf(r,o),Ts(o,null,null,m),Sl()),S=r.memoizedState,F=o.memoizedState,S.parent!==w?(S={parent:w,cache:w},o.memoizedState=S,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=S),xe(o,Ca,w)):(w=F.cache,xe(o,Ca,w),w!==S.cache&&nt(o,[Ca],m,!0))),Qa(r,o,o.pendingProps.children,m),o.child;case 29:throw o.pendingProps}throw Error(n(156,o.tag))}function os(r){r.flags|=4}function Ia(r){Vi&&(r.flags|=8)}function a1(r,o){if(r!==null&&r.child===o.child)return!1;if((o.flags&16)!==0)return!0;for(r=o.child;r!==null;){if((r.flags&8218)!==0||(r.subtreeFlags&8218)!==0)return!0;r=r.sibling}return!1}function In(r,o,m,w){if(Gn)for(m=o.child;m!==null;){if(m.tag===5||m.tag===6)l3(r,m.stateNode);else if(!(m.tag===4||nn&&m.tag===27)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===o)break;for(;m.sibling===null;){if(m.return===null||m.return===o)return;m=m.return}m.sibling.return=m.return,m=m.sibling}else if(Vi)for(var S=o.child;S!==null;){if(S.tag===5){var F=S.stateNode;m&&w&&(F=gp(F,S.type,S.memoizedProps)),l3(r,F)}else if(S.tag===6)F=S.stateNode,m&&w&&(F=pp(F,S.memoizedProps)),l3(r,F);else if(S.tag!==4){if(S.tag===22&&S.memoizedState!==null)F=S.child,F!==null&&(F.return=S),In(r,S,!0,!0);else if(S.child!==null){S.child.return=S,S=S.child;continue}}if(S===o)break;for(;S.sibling===null;){if(S.return===null||S.return===o)return;S=S.return}S.sibling.return=S.return,S=S.sibling}}function Ff(r,o,m,w){var S=!1;if(Vi)for(var F=o.child;F!==null;){if(F.tag===5){var D=F.stateNode;m&&w&&(D=gp(D,F.type,F.memoizedProps)),up(r,D)}else if(F.tag===6)D=F.stateNode,m&&w&&(D=pp(D,F.memoizedProps)),up(r,D);else if(F.tag!==4){if(F.tag===22&&F.memoizedState!==null)S=F.child,S!==null&&(S.return=F),Ff(r,F,!0,!0),S=!0;else if(F.child!==null){F.child.return=F,F=F.child;continue}}if(F===o)break;for(;F.sibling===null;){if(F.return===null||F.return===o)return S;F=F.return}F.sibling.return=F.return,F=F.sibling}return S}function P2(r,o){if(Vi&&a1(r,o)){r=o.stateNode;var m=r.containerInfo,w=hp();Ff(w,o,!1,!1),r.pendingChildren=w,os(o),FC(m,w)}}function pc(r,o,m,w){if(Gn)r.memoizedProps!==w&&os(o);else if(Vi){var{stateNode:S,memoizedProps:F}=r;if((r=a1(r,o))||F!==w){var D=On.current;F=_C(S,m,F,w,!r,null),F===S?o.stateNode=S:(Ia(o),fp(F,m,w,D)&&os(o),o.stateNode=F,r&&In(F,o,!1,!1))}else o.stateNode=S}}function ei(r,o,m,w,S){if((r.mode&32)!==0&&(m===null?eC(o,w):tC(o,m,w))){if(r.flags|=16777216,(S&335544128)===S||r3(o,w))if(rp(r.stateNode,o,w))r.flags|=8192;else if(c1())r.flags|=8192;else throw lr=Ru,v3}else r.flags&=-16777217}function bc(r,o){if(c_(o)){if(r.flags|=16777216,!yp(o))if(c1())r.flags|=8192;else throw lr=Ru,v3}else r.flags&=-16777217}function n1(r,o){o!==null&&(r.flags|=4),r.flags&16384&&(o=r.tag!==22?T():536870912,r.lanes|=o,T1|=o)}function Jl(r,o){if(!Ft)switch(r.tailMode){case"hidden":o=r.tail;for(var m=null;o!==null;)o.alternate!==null&&(m=o),o=o.sibling;m===null?r.tail=null:m.sibling=null;break;case"collapsed":m=r.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:w.sibling=null}}function Kt(r){var o=r.alternate!==null&&r.alternate.child===r.child,m=0,w=0;if(o)for(var S=r.child;S!==null;)m|=S.lanes|S.childLanes,w|=S.subtreeFlags&65011712,w|=S.flags&65011712,S.return=r,S=S.sibling;else for(S=r.child;S!==null;)m|=S.lanes|S.childLanes,w|=S.subtreeFlags,w|=S.flags,S.return=r,S=S.sibling;return r.subtreeFlags|=w,r.childLanes=m,o}function P5(r,o,m){var w=o.pendingProps;switch(re(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kt(o),null;case 1:return Kt(o),null;case 3:if(m=o.stateNode,w=null,r!==null&&(w=r.memoizedState.cache),o.memoizedState.cache!==w&&(o.flags|=2048),ze(Ca),at(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),r===null||r.child===null)Dt(o)?os(o):r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,rn());return P2(r,o),Kt(o),null;case 26:if(_i){var{type:S,memoizedState:F}=o;return r===null?(os(o),F!==null?(Kt(o),bc(o,F)):(Kt(o),ei(o,S,null,w,m))):F?F!==r.memoizedState?(os(o),Kt(o),bc(o,F)):(Kt(o),o.flags&=-16777217):(F=r.memoizedProps,Gn?F!==w&&os(o):pc(r,o,S,w),Kt(o),ei(o,S,F,w,m)),null}case 27:if(nn){if(Ie(o),m=If.current,S=o.type,r!==null&&o.stateNode!=null)Gn?r.memoizedProps!==w&&os(o):pc(r,o,S,w);else{if(!w){if(o.stateNode===null)throw Error(n(166));return Kt(o),null}r=On.current,Dt(o)?vt(o,r):(r=Sp(S,w,m,r,!0),o.stateNode=r,os(o))}return Kt(o),null}case 5:if(Ie(o),S=o.type,r!==null&&o.stateNode!=null)pc(r,o,S,w);else{if(!w){if(o.stateNode===null)throw Error(n(166));return Kt(o),null}if(F=On.current,Dt(o))vt(o,F),PC(o.stateNode,S,w,F)&&(o.flags|=64);else{var D=VS(S,w,If.current,F,o);Ia(o),In(D,o,!1,!1),o.stateNode=D,fp(D,S,w,F)&&os(o)}}return Kt(o),ei(o,o.type,r===null?null:r.memoizedProps,o.pendingProps,m),null;case 6:if(r&&o.stateNode!=null)m=r.memoizedProps,Gn?m!==w&&os(o):Vi&&(m!==w?(r=If.current,m=On.current,Ia(o),o.stateNode=lp(w,r,m,o)):o.stateNode=r.stateNode);else{if(typeof w!=="string"&&o.stateNode===null)throw Error(n(166));if(r=If.current,m=On.current,Dt(o)){if(!Xn)throw Error(n(176));if(r=o.stateNode,m=o.memoizedProps,w=null,S=Bn,S!==null)switch(S.tag){case 27:case 5:w=S.memoizedProps}KC(r,m,o,w)||mt(o,!0)}else Ia(o),o.stateNode=lp(w,r,m,o)}return Kt(o),null;case 31:if(m=o.memoizedState,r===null||r.memoizedState!==null){if(w=Dt(o),m!==null){if(r===null){if(!w)throw Error(n(318));if(!Xn)throw Error(n(556));if(r=o.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(557));LC(r,o)}else ta(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Kt(o),r=!1}else m=rn(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=m),r=!0;if(!r){if(o.flags&256)return Un(o),o;return Un(o),null}if((o.flags&128)!==0)throw Error(n(558))}return Kt(o),null;case 13:if(w=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(S=Dt(o),w!==null&&w.dehydrated!==null){if(r===null){if(!S)throw Error(n(318));if(!Xn)throw Error(n(344));if(S=o.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));VC(S,o)}else ta(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Kt(o),S=!1}else S=rn(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=S),S=!0;if(!S){if(o.flags&256)return Un(o),o;return Un(o),null}}if(Un(o),(o.flags&128)!==0)return o.lanes=m,o;return m=w!==null,r=r!==null&&r.memoizedState!==null,m&&(w=o.child,S=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(S=w.alternate.memoizedState.cachePool.pool),F=null,w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(F=w.memoizedState.cachePool.pool),F!==S&&(w.flags|=2048)),m!==r&&m&&(o.child.flags|=8192),n1(o,o.updateQueue),Kt(o),null;case 4:return at(),P2(r,o),r===null&&ZS(o.stateNode.containerInfo),Kt(o),null;case 10:return ze(o.type),Kt(o),null;case 19:if(b(Xa),w=o.memoizedState,w===null)return Kt(o),null;if(S=(o.flags&128)!==0,F=w.rendering,F===null)if(S)Jl(w,!1);else{if(Ra!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(F=Yr(r),F!==null){o.flags|=128,Jl(w,!1),r=F.updateQueue,o.updateQueue=r,n1(o,r),o.subtreeFlags=0,r=m;for(m=o.child;m!==null;)Oe(m,r),m=m.sibling;return d(Xa,Xa.current&1|2),Ft&&fe(o,w.treeForkCount),o.child}r=r.sibling}w.tail!==null&&us()>Xc&&(o.flags|=128,S=!0,Jl(w,!1),o.lanes=4194304)}else{if(!S)if(r=Yr(F),r!==null){if(o.flags|=128,S=!0,r=r.updateQueue,o.updateQueue=r,n1(o,r),Jl(w,!0),w.tail===null&&w.tailMode==="hidden"&&!F.alternate&&!Ft)return Kt(o),null}else 2*us()-w.renderingStartTime>Xc&&m!==536870912&&(o.flags|=128,S=!0,Jl(w,!1),o.lanes=4194304);w.isBackwards?(F.sibling=o.child,o.child=F):(r=w.last,r!==null?r.sibling=F:o.child=F,w.last=F)}if(w.tail!==null)return r=w.tail,w.rendering=r,w.tail=r.sibling,w.renderingStartTime=us(),r.sibling=null,m=Xa.current,d(Xa,S?m&1|2:m&1),Ft&&fe(o,w.treeForkCount),r;return Kt(o),null;case 22:case 23:return Un(o),Qo(),w=o.memoizedState!==null,r!==null?r.memoizedState!==null!==w&&(o.flags|=8192):w&&(o.flags|=8192),w?(m&536870912)!==0&&(o.flags&128)===0&&(Kt(o),o.subtreeFlags&6&&(o.flags|=8192)):Kt(o),m=o.updateQueue,m!==null&&n1(o,m.retryQueue),m=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(m=r.memoizedState.cachePool.pool),w=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(w=o.memoizedState.cachePool.pool),w!==m&&(o.flags|=2048),r!==null&&b(fr),null;case 24:return m=null,r!==null&&(m=r.memoizedState.cache),o.memoizedState.cache!==m&&(o.flags|=2048),ze(Ca),Kt(o),null;case 25:return null;case 30:return null}throw Error(n(156,o.tag))}function e3(r,o){switch(re(o),o.tag){case 1:return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return ze(Ca),at(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 26:case 27:case 5:return Ie(o),null;case 31:if(o.memoizedState!==null){if(Un(o),o.alternate===null)throw Error(n(340));ta()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 13:if(Un(o),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));ta()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return b(Xa),null;case 4:return at(),null;case 10:return ze(o.type),null;case 22:case 23:return Un(o),Qo(),r!==null&&b(fr),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 24:return ze(Ca),null;case 25:return null;default:return null}}function eu(r,o){switch(re(o),o.tag){case 3:ze(Ca),at();break;case 26:case 27:case 5:Ie(o);break;case 4:at();break;case 31:o.memoizedState!==null&&Un(o);break;case 13:Un(o);break;case 19:b(Xa);break;case 10:ze(o.type);break;case 22:case 23:Un(o),Qo(),r!==null&&b(fr);break;case 24:ze(Ca)}}function Ql(r,o){try{var m=o.updateQueue,w=m!==null?m.lastEffect:null;if(w!==null){var S=w.next;m=S;do{if((m.tag&r)===r){w=void 0;var{create:F,inst:D}=m;w=F(),D.destroy=w}m=m.next}while(m!==S)}}catch(Y){v(o,o.return,Y)}}function Si(r,o,m){try{var w=o.updateQueue,S=w!==null?w.lastEffect:null;if(S!==null){var F=S.next;w=F;do{if((w.tag&r)===r){var D=w.inst,Y=D.destroy;if(Y!==void 0){D.destroy=void 0,S=o;var ue=m,ke=Y;try{ke()}catch(Be){v(S,ue,Be)}}}w=w.next}while(w!==F)}}catch(Be){v(o,o.return,Be)}}function tu(r){var o=r.updateQueue;if(o!==null){var m=r.stateNode;try{Yo(o,m)}catch(w){v(r,r.return,w)}}}function Of(r,o,m){m.props=yi(r.type,r.memoizedProps),m.state=r.memoizedState;try{m.componentWillUnmount()}catch(w){v(r,o,w)}}function Bf(r,o){try{var m=r.ref;if(m!==null){switch(r.tag){case 26:case 27:case 5:var w=Tc(r.stateNode);break;case 30:w=r.stateNode;break;default:w=r.stateNode}typeof m==="function"?r.refCleanup=m(w):m.current=w}}catch(S){v(r,o,S)}}function Qn(r,o){var{ref:m,refCleanup:w}=r;if(m!==null)if(typeof w==="function")try{w()}catch(S){v(r,o,S)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof m==="function")try{m(null)}catch(S){v(r,o,S)}else m.current=null}function Tf(r){var{type:o,memoizedProps:m,stateNode:w}=r;try{bC(w,o,m,r)}catch(S){v(r,r.return,S)}}function ba(r,o,m){try{wC(r.stateNode,r.type,m,o,r)}catch(w){v(r,r.return,w)}}function D0(r){return r.tag===5||r.tag===3||(_i?r.tag===26:!1)||(nn?r.tag===27&&p1(r.type):!1)||r.tag===4}function Zl(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||D0(r.return))return null;r=r.return}r.sibling.return=r.return;for(r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(nn&&r.tag===27&&p1(r.type))continue e;if(r.flags&2)continue e;if(r.child===null||r.tag===4)continue e;else r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function wc(r,o,m){var w=r.tag;if(w===5||w===6)r=r.stateNode,o?jC(m,r,o):gC(m,r);else if(w!==4&&(nn&&w===27&&p1(r.type)&&(m=r.stateNode,o=null),r=r.child,r!==null))for(wc(r,o,m),r=r.sibling;r!==null;)wc(r,o,m),r=r.sibling}function s1(r,o,m){var w=r.tag;if(w===5||w===6)r=r.stateNode,o?dC(m,r,o):mC(m,r);else if(w!==4&&(nn&&w===27&&p1(r.type)&&(m=r.stateNode),r=r.child,r!==null))for(s1(r,o,m),r=r.sibling;r!==null;)s1(r,o,m),r=r.sibling}function au(r,o,m){r=r.containerInfo;try{mp(r,m)}catch(w){v(o,o.return,w)}}function nu(r){var{stateNode:o,memoizedProps:m}=r;try{u_(r.type,m,o,r)}catch(w){v(r,r.return,w)}}function su(r,o){KS(r.containerInfo);for(gn=o;gn!==null;)if(r=gn,o=r.child,(r.subtreeFlags&1028)!==0&&o!==null)o.return=r,gn=o;else for(;gn!==null;){r=gn;var m=r.alternate;switch(o=r.flags,r.tag){case 0:if((o&4)!==0&&(o=r.updateQueue,o=o!==null?o.events:null,o!==null))for(var w=0;w<o.length;w++){var S=o[w];S.ref.impl=S.nextImpl}break;case 11:case 15:break;case 1:if((o&1024)!==0&&m!==null){o=void 0,w=r,S=m.memoizedProps,m=m.memoizedState;var F=w.stateNode;try{var D=yi(w.type,S);o=F.getSnapshotBeforeUpdate(D,m),F.__reactInternalSnapshotBeforeUpdate=o}catch(Y){v(w,w.return,Y)}}break;case 3:(o&1024)!==0&&Gn&&CC(r.stateNode.containerInfo);break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((o&1024)!==0)throw Error(n(163))}if(o=r.sibling,o!==null){o.return=r.return,gn=o;break}gn=r.return}}function dc(r,o,m){var w=m.flags;switch(m.tag){case 0:case 11:case 15:Ci(r,m),w&4&&Ql(5,m);break;case 1:if(Ci(r,m),w&4)if(r=m.stateNode,o===null)try{r.componentDidMount()}catch(D){v(m,m.return,D)}else{var S=yi(m.type,o.memoizedProps);o=o.memoizedState;try{r.componentDidUpdate(S,o,r.__reactInternalSnapshotBeforeUpdate)}catch(D){v(m,m.return,D)}}w&64&&tu(m),w&512&&Bf(m,m.return);break;case 3:if(Ci(r,m),w&64&&(w=m.updateQueue,w!==null)){if(r=null,m.child!==null)switch(m.child.tag){case 27:case 5:r=Tc(m.child.stateNode);break;case 1:r=m.child.stateNode}try{Yo(w,r)}catch(D){v(m,m.return,D)}}break;case 27:nn&&o===null&&w&4&&nu(m);case 26:case 5:if(Ci(r,m),o===null){if(w&4)Tf(m);else if(w&64){r=m.type,o=m.memoizedProps,S=m.stateNode;try{QC(S,r,o,m)}catch(D){v(m,m.return,D)}}}w&512&&Bf(m,m.return);break;case 12:Ci(r,m);break;case 31:Ci(r,m),w&4&&f1(r,m);break;case 13:Ci(r,m),w&4&&qc(r,m),w&64&&(w=m.memoizedState,w!==null&&(w=w.dehydrated,w!==null&&(m=E.bind(null,m),BC(w,m))));break;case 22:if(w=m.memoizedState!==null||K0,!w){o=o!==null&&o.memoizedState!==null||Wa,S=K0;var F=Wa;K0=w,(Wa=o)&&!F?ti(r,m,(m.subtreeFlags&8772)!==0):Ci(r,m),K0=S,Wa=F}break;case 30:break;default:Ci(r,m)}}function jc(r){var o=r.alternate;o!==null&&(r.alternate=null,jc(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&PS(o)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function cs(r,o,m){for(m=m.child;m!==null;)i1(r,o,m),m=m.sibling}function i1(r,o,m){if(Rs&&typeof Rs.onCommitFiberUnmount==="function")try{Rs.onCommitFiberUnmount(Dc,m)}catch(F){}switch(m.tag){case 26:if(_i){Wa||Qn(m,o),cs(r,o,m),m.memoizedState?vp(m.memoizedState):m.stateNode&&Ap(m.stateNode);break}case 27:if(nn){Wa||Qn(m,o);var w=Pa,S=ms;p1(m.type)&&(Pa=m.stateNode,ms=!1),cs(r,o,m),Cp(m.stateNode),Pa=w,ms=S;break}case 5:Wa||Qn(m,o);case 6:if(Gn){if(w=Pa,S=ms,Pa=null,cs(r,o,m),Pa=w,ms=S,Pa!==null)if(ms)try{vC(Pa,m.stateNode)}catch(F){v(m,o,F)}else try{qC(Pa,m.stateNode)}catch(F){v(m,o,F)}}else cs(r,o,m);break;case 18:Gn&&Pa!==null&&(ms?a_(Pa,m.stateNode):t_(Pa,m.stateNode));break;case 4:Gn?(w=Pa,S=ms,Pa=m.stateNode.containerInfo,ms=!0,cs(r,o,m),Pa=w,ms=S):(Vi&&au(m.stateNode,m,hp()),cs(r,o,m));break;case 0:case 11:case 14:case 15:Si(2,m,o),Wa||Si(4,m,o),cs(r,o,m);break;case 1:Wa||(Qn(m,o),w=m.stateNode,typeof w.componentWillUnmount==="function"&&Of(m,o,w)),cs(r,o,m);break;case 21:cs(r,o,m);break;case 22:Wa=(w=Wa)||m.memoizedState!==null,cs(r,o,m),Wa=w;break;default:cs(r,o,m)}}function f1(r,o){if(Xn&&o.memoizedState===null&&(r=o.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{$C(r)}catch(m){v(o,o.return,m)}}}function qc(r,o){if(Xn&&o.memoizedState===null&&(r=o.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{WC(r)}catch(m){v(o,o.return,m)}}function vc(r){switch(r.tag){case 31:case 13:case 19:var o=r.stateNode;return o===null&&(o=r.stateNode=new Rp),o;case 22:return r=r.stateNode,o=r._retryCache,o===null&&(o=r._retryCache=new Rp),o;default:throw Error(n(435,r.tag))}}function l1(r,o){var m=vc(r);o.forEach(function(w){if(!m.has(w)){m.add(w);var S=U.bind(null,r,w);w.then(S,S)}})}function xa(r,o){var m=o.deletions;if(m!==null)for(var w=0;w<m.length;w++){var S=m[w],F=r,D=o;if(Gn){var Y=D;e:for(;Y!==null;){switch(Y.tag){case 27:if(nn){if(p1(Y.type)){Pa=Y.stateNode,ms=!1;break e}break}case 5:Pa=Y.stateNode,ms=!1;break e;case 3:case 4:Pa=Y.stateNode.containerInfo,ms=!0;break e}Y=Y.return}if(Pa===null)throw Error(n(160));i1(F,D,S),Pa=null,ms=!1}else i1(F,D,S);F=S.alternate,F!==null&&(F.return=null),S.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)iu(o,r),o=o.sibling}function iu(r,o){var{alternate:m,flags:w}=r;switch(r.tag){case 0:case 11:case 14:case 15:xa(o,r),hn(r),w&4&&(Si(3,r,r.return),Ql(3,r),Si(5,r,r.return));break;case 1:xa(o,r),hn(r),w&512&&(Wa||m===null||Qn(m,m.return)),w&64&&K0&&(r=r.updateQueue,r!==null&&(w=r.callbacks,w!==null&&(m=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=m===null?w:m.concat(w))));break;case 26:if(_i){var S=Fi;if(xa(o,r),hn(r),w&512&&(Wa||m===null||Qn(m,m.return)),w&4){w=m!==null?m.memoizedState:null;var F=r.memoizedState;m===null?F===null?r.stateNode===null?r.stateNode=l_(S,r.type,r.memoizedProps,r):kp(S,r.type,r.stateNode):r.stateNode=qp(S,F,r.memoizedProps):w!==F?(w===null?m.stateNode!==null&&Ap(m.stateNode):vp(w),F===null?kp(S,r.type,r.stateNode):qp(S,F,r.memoizedProps)):F===null&&r.stateNode!==null&&ba(r,r.memoizedProps,m.memoizedProps)}break}case 27:if(nn){xa(o,r),hn(r),w&512&&(Wa||m===null||Qn(m,m.return)),m!==null&&w&4&&ba(r,r.memoizedProps,m.memoizedProps);break}case 5:if(xa(o,r),hn(r),w&512&&(Wa||m===null||Qn(m,m.return)),Gn){if(r.flags&32){S=r.stateNode;try{cp(S)}catch(Ce){v(r,r.return,Ce)}}w&4&&r.stateNode!=null&&(S=r.memoizedProps,ba(r,S,m!==null?m.memoizedProps:S)),w&1024&&(F3=!0)}else Vi&&r.alternate!==null&&(r.alternate.stateNode=r.stateNode);break;case 6:if(xa(o,r),hn(r),w&4&&Gn){if(r.stateNode===null)throw Error(n(162));w=r.memoizedProps,m=m!==null?m.memoizedProps:w,S=r.stateNode;try{pC(S,m,w)}catch(Ce){v(r,r.return,Ce)}}break;case 3:if(_i?(o_(),S=Fi,Fi=h3(o.containerInfo),xa(o,r),Fi=S):xa(o,r),hn(r),w&4){if(Gn&&Xn&&m!==null&&m.memoizedState.isDehydrated)try{ZC(o.containerInfo)}catch(Ce){v(r,r.return,Ce)}if(Vi){w=o.containerInfo,m=o.pendingChildren;try{mp(w,m)}catch(Ce){v(r,r.return,Ce)}}}F3&&(F3=!1,kc(r));break;case 4:_i?(m=Fi,Fi=h3(r.stateNode.containerInfo),xa(o,r),hn(r),Fi=m):(xa(o,r),hn(r)),w&4&&Vi&&au(r.stateNode,r,r.stateNode.pendingChildren);break;case 12:xa(o,r),hn(r);break;case 31:xa(o,r),hn(r),w&4&&(w=r.updateQueue,w!==null&&(r.updateQueue=null,l1(r,w)));break;case 13:xa(o,r),hn(r),r.child.flags&8192&&r.memoizedState!==null!==(m!==null&&m.memoizedState!==null)&&(Lu=us()),w&4&&(w=r.updateQueue,w!==null&&(r.updateQueue=null,l1(r,w)));break;case 22:S=r.memoizedState!==null;var D=m!==null&&m.memoizedState!==null,Y=K0,ue=Wa;if(K0=Y||S,Wa=ue||D,xa(o,r),Wa=ue,K0=Y,hn(r),w&8192&&(o=r.stateNode,o._visibility=S?o._visibility&-2:o._visibility|1,S&&(m===null||D||K0||Wa||x0(r)),Gn)){e:if(m=null,Gn)for(o=r;;){if(o.tag===5||_i&&o.tag===26){if(m===null){D=m=o;try{F=D.stateNode,S?kC(F):yC(D.stateNode,D.memoizedProps)}catch(Ce){v(D,D.return,Ce)}}}else if(o.tag===6){if(m===null){D=o;try{var ke=D.stateNode;S?AC(ke):SC(ke,D.memoizedProps)}catch(Ce){v(D,D.return,Ce)}}}else if(o.tag===18){if(m===null){D=o;try{var Be=D.stateNode;S?n_(Be):s_(D.stateNode)}catch(Ce){v(D,D.return,Ce)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===r)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break e;for(;o.sibling===null;){if(o.return===null||o.return===r)break e;m===o&&(m=null),o=o.return}m===o&&(m=null),o.sibling.return=o.return,o=o.sibling}}w&4&&(w=r.updateQueue,w!==null&&(m=w.retryQueue,m!==null&&(w.retryQueue=null,l1(r,m))));break;case 19:xa(o,r),hn(r),w&4&&(w=r.updateQueue,w!==null&&(r.updateQueue=null,l1(r,w)));break;case 30:break;case 21:break;default:xa(o,r),hn(r)}}function hn(r){var o=r.flags;if(o&2){try{for(var m,w=r.return;w!==null;){if(D0(w)){m=w;break}w=w.return}if(Gn){if(m==null)throw Error(n(160));switch(m.tag){case 27:if(nn){var S=m.stateNode,F=Zl(r);s1(r,F,S);break}case 5:var D=m.stateNode;m.flags&32&&(cp(D),m.flags&=-33);var Y=Zl(r);s1(r,Y,D);break;case 3:case 4:var ue=m.stateNode.containerInfo,ke=Zl(r);wc(r,ke,ue);break;default:throw Error(n(161))}}}catch(Be){v(r,r.return,Be)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function kc(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var o=r;kc(o),o.tag===5&&o.flags&1024&&sC(o.stateNode),r=r.sibling}}function Ci(r,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)dc(r,o.alternate,o),o=o.sibling}function x0(r){for(r=r.child;r!==null;){var o=r;switch(o.tag){case 0:case 11:case 14:case 15:Si(4,o,o.return),x0(o);break;case 1:Qn(o,o.return);var m=o.stateNode;typeof m.componentWillUnmount==="function"&&Of(o,o.return,m),x0(o);break;case 27:nn&&Cp(o.stateNode);case 26:case 5:Qn(o,o.return),x0(o);break;case 22:o.memoizedState===null&&x0(o);break;case 30:x0(o);break;default:x0(o)}r=r.sibling}}function ti(r,o,m){m=m&&(o.subtreeFlags&8772)!==0;for(o=o.child;o!==null;){var w=o.alternate,S=r,F=o,D=F.flags;switch(F.tag){case 0:case 11:case 15:ti(S,F,m),Ql(4,F);break;case 1:if(ti(S,F,m),w=F,S=w.stateNode,typeof S.componentDidMount==="function")try{S.componentDidMount()}catch(ke){v(w,w.return,ke)}if(w=F,S=w.updateQueue,S!==null){var Y=w.stateNode;try{var ue=S.shared.hiddenCallbacks;if(ue!==null)for(S.shared.hiddenCallbacks=null,S=0;S<ue.length;S++)fa(ue[S],Y)}catch(ke){v(w,w.return,ke)}}m&&D&64&&tu(F),Bf(F,F.return);break;case 27:nn&&nu(F);case 26:case 5:ti(S,F,m),m&&w===null&&D&4&&Tf(F),Bf(F,F.return);break;case 12:ti(S,F,m);break;case 31:ti(S,F,m),m&&D&4&&f1(S,F);break;case 13:ti(S,F,m),m&&D&4&&qc(S,F);break;case 22:F.memoizedState===null&&ti(S,F,m),Bf(F,F.return);break;case 30:break;default:ti(S,F,m)}o=o.sibling}}function Ac(r,o){var m=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(m=r.memoizedState.cachePool.pool),r=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(r=o.memoizedState.cachePool.pool),r!==m&&(r!=null&&r.refCount++,m!=null&&Ja(m))}function yc(r,o){r=null,o.alternate!==null&&(r=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==r&&(o.refCount++,r!=null&&Ja(r))}function Zn(r,o,m,w){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)fu(r,o,m,w),o=o.sibling}function fu(r,o,m,w){var S=o.flags;switch(o.tag){case 0:case 11:case 15:Zn(r,o,m,w),S&2048&&Ql(9,o);break;case 1:Zn(r,o,m,w);break;case 3:Zn(r,o,m,w),S&2048&&(r=null,o.alternate!==null&&(r=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==r&&(o.refCount++,r!=null&&Ja(r)));break;case 12:if(S&2048){Zn(r,o,m,w),r=o.stateNode;try{var F=o.memoizedProps,D=F.id,Y=F.onPostCommit;typeof Y==="function"&&Y(D,o.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ue){v(o,o.return,ue)}}else Zn(r,o,m,w);break;case 31:Zn(r,o,m,w);break;case 13:Zn(r,o,m,w);break;case 23:break;case 22:F=o.stateNode,D=o.alternate,o.memoizedState!==null?F._visibility&2?Zn(r,o,m,w):$l(r,o):F._visibility&2?Zn(r,o,m,w):(F._visibility|=2,Hf(r,o,m,w,(o.subtreeFlags&10256)!==0||!1)),S&2048&&Ac(D,o);break;case 24:Zn(r,o,m,w),S&2048&&yc(o.alternate,o);break;default:Zn(r,o,m,w)}}function Hf(r,o,m,w,S){S=S&&((o.subtreeFlags&10256)!==0||!1);for(o=o.child;o!==null;){var F=r,D=o,Y=m,ue=w,ke=D.flags;switch(D.tag){case 0:case 11:case 15:Hf(F,D,Y,ue,S),Ql(8,D);break;case 23:break;case 22:var Be=D.stateNode;D.memoizedState!==null?Be._visibility&2?Hf(F,D,Y,ue,S):$l(F,D):(Be._visibility|=2,Hf(F,D,Y,ue,S)),S&&ke&2048&&Ac(D.alternate,D);break;case 24:Hf(F,D,Y,ue,S),S&&ke&2048&&yc(D.alternate,D);break;default:Hf(F,D,Y,ue,S)}o=o.sibling}}function $l(r,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var m=r,w=o,S=w.flags;switch(w.tag){case 22:$l(m,w),S&2048&&Ac(w.alternate,w);break;case 24:$l(m,w),S&2048&&yc(w.alternate,w);break;default:$l(m,w)}o=o.sibling}}function R0(r,o,m){if(r.subtreeFlags&O1)for(r=r.child;r!==null;)lu(r,o,m),r=r.sibling}function lu(r,o,m){switch(r.tag){case 26:if(R0(r,o,m),r.flags&O1)if(r.memoizedState!==null)h_(m,Fi,r.memoizedState,r.memoizedProps);else{var{stateNode:w,type:S}=r;r=r.memoizedProps,((o&335544128)===o||r3(S,r))&&op(m,w,S,r)}break;case 5:R0(r,o,m),r.flags&O1&&(w=r.stateNode,S=r.type,r=r.memoizedProps,((o&335544128)===o||r3(S,r))&&op(m,w,S,r));break;case 3:case 4:_i?(w=Fi,Fi=h3(r.stateNode.containerInfo),R0(r,o,m),Fi=w):R0(r,o,m);break;case 22:r.memoizedState===null&&(w=r.alternate,w!==null&&w.memoizedState!==null?(w=O1,O1=16777216,R0(r,o,m),O1=w):R0(r,o,m));break;default:R0(r,o,m)}}function ru(r){var o=r.alternate;if(o!==null&&(r=o.child,r!==null)){o.child=null;do o=r.sibling,r.sibling=null,r=o;while(r!==null)}}function Wl(r){var o=r.deletions;if((r.flags&16)!==0){if(o!==null)for(var m=0;m<o.length;m++){var w=o[m];gn=w,cu(w,r)}ru(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)ou(r),r=r.sibling}function ou(r){switch(r.tag){case 0:case 11:case 15:Wl(r),r.flags&2048&&Si(9,r,r.return);break;case 3:Wl(r);break;case 12:Wl(r);break;case 22:var o=r.stateNode;r.memoizedState!==null&&o._visibility&2&&(r.return===null||r.return.tag!==13)?(o._visibility&=-3,r1(r)):Wl(r);break;default:Wl(r)}}function r1(r){var o=r.deletions;if((r.flags&16)!==0){if(o!==null)for(var m=0;m<o.length;m++){var w=o[m];gn=w,cu(w,r)}ru(r)}for(r=r.child;r!==null;){switch(o=r,o.tag){case 0:case 11:case 15:Si(8,o,o.return),r1(o);break;case 22:m=o.stateNode,m._visibility&2&&(m._visibility&=-3,r1(o));break;default:r1(o)}r=r.sibling}}function cu(r,o){for(;gn!==null;){var m=gn;switch(m.tag){case 0:case 11:case 15:Si(8,m,o);break;case 23:case 22:if(m.memoizedState!==null&&m.memoizedState.cachePool!==null){var w=m.memoizedState.cachePool.pool;w!=null&&w.refCount++}break;case 24:Ja(m.memoizedState.cache)}if(w=m.child,w!==null)w.return=m,gn=w;else e:for(m=r;gn!==null;){w=gn;var{sibling:S,return:F}=w;if(jc(w),w===m){gn=null;break e}if(S!==null){S.return=F,gn=S;break e}gn=F}}}function Sc(r){var o=QS(r);if(o!=null){if(typeof o.memoizedProps["data-testname"]!=="string")throw Error(n(364));return o}if(r=lC(r),r===null)throw Error(n(362));return r.stateNode.current}function ai(r,o){var m=r.tag;switch(o.$$typeof){case Uu:if(r.type===o.value)return!0;break;case Iu:e:{o=o.value,r=[r,0];for(m=0;m<r.length;){var w=r[m++],S=w.tag,F=r[m++],D=o[F];if(S!==5&&S!==26&&S!==27||!Mc(w)){for(;D!=null&&ai(w,D);)F++,D=o[F];if(F===o.length){o=!0;break e}else for(w=w.child;w!==null;)r.push(w,F),w=w.sibling}}o=!1}return o;case Gu:if((m===5||m===26||m===27)&&cC(r.stateNode,o.value))return!0;break;case Ku:if(m===5||m===6||m===26||m===27){if(r=oC(r),r!==null&&0<=r.indexOf(o.value))return!0}break;case Xu:if(m===5||m===26||m===27){if(r=r.memoizedProps["data-testname"],typeof r==="string"&&r.toLowerCase()===o.value.toLowerCase())return!0}break;default:throw Error(n(365))}return!1}function Cc(r){switch(r.$$typeof){case Uu:return"<"+(u(r.value)||"Unknown")+">";case Iu:return":has("+(Cc(r)||"")+")";case Gu:return'[role="'+r.value+'"]';case Ku:return'"'+r.value+'"';case Xu:return'[data-testname="'+r.value+'"]';default:throw Error(n(365))}}function hu(r,o){var m=[];r=[r,0];for(var w=0;w<r.length;){var S=r[w++],F=S.tag,D=r[w++],Y=o[D];if(F!==5&&F!==26&&F!==27||!Mc(S)){for(;Y!=null&&ai(S,Y);)D++,Y=o[D];if(D===o.length)m.push(S);else for(S=S.child;S!==null;)r.push(S,D),S=S.sibling}}return m}function _c(r,o){if(!Hc)throw Error(n(363));r=Sc(r),r=hu(r,o),o=[],r=Array.from(r);for(var m=0;m<r.length;){var w=r[m++],S=w.tag;if(S===5||S===26||S===27)Mc(w)||o.push(w.stateNode);else for(w=w.child;w!==null;)r.push(w),w=w.sibling}return o}function hs(){return(At&2)!==0&&Ct!==0?Ct&-Ct:We.T!==null?xt():$S()}function Fc(){if(Us===0)if((Ct&536870912)===0||Ft){var r=_u;_u<<=1,(_u&3932160)===0&&(_u=262144),Us=r}else Us=536870912;return r=Es.current,r!==null&&(r.flags|=32),Us}function un(r,o,m){if(r===la&&(Qt===2||Qt===9)||r.cancelPendingCommit!==null)Mf(r,0),Xi(r,Ct,Us,!1);if(H(r,m),(At&2)===0||r!==la)r===la&&((At&2)===0&&(cr|=m),Ra===4&&Xi(r,Ct,Us,!1)),pa(r)}function Oc(r,o,m){if((At&6)!==0)throw Error(n(327));var w=!m&&(o&127)===0&&(o&r.expiredLanes)===0||y(r,o),S=w?N0(r,o):Ki(r,o,!0),F=w;do{if(S===0){B1&&!w&&Xi(r,o,0,!1);break}else{if(m=r.current.alternate,F&&!o1(m)){S=Ki(r,o,!1),F=!1;continue}if(S===2){if(F=o,r.errorRecoveryDisabledLanes&F)var D=0;else D=r.pendingLanes&-536870913,D=D!==0?D:D&536870912?536870912:0;if(D!==0){o=D;e:{var Y=r;S=Gc;var ue=Xn&&Y.current.memoizedState.isDehydrated;if(ue&&(Mf(Y,D).flags|=256),D=Ki(Y,D,!1),D!==2){if(O3&&!ue){Y.errorRecoveryDisabledLanes|=F,cr|=F,S=4;break e}F=gs,gs=S,F!==null&&(gs===null?gs=F:gs.push.apply(gs,F))}S=D}if(F=!1,S!==2)continue}}if(S===1){Mf(r,0),Xi(r,o,0,!0);break}e:{switch(w=r,F=S,F){case 0:case 1:throw Error(n(345));case 4:if((o&4194048)!==o)break;case 6:Xi(w,o,Us,!Kf);break e;case 2:gs=null;break;case 3:case 5:break;default:throw Error(n(329))}if((o&62914560)===o&&(S=Lu+300-us(),10<S)){if(Xi(w,o,Us,!Kf),C(w,0,!0)!==0)break e;V0=o,w.timeoutHandle=YS(Pl.bind(null,w,m,gs,Vu,T3,o,Us,cr,T1,Kf,F,"Throttled",-0,0),S);break e}Pl(w,m,gs,Vu,T3,o,Us,cr,T1,Kf,F,null,-0,0)}}break}while(1);pa(r)}function Pl(r,o,m,w,S,F,D,Y,ue,ke,Be,Ce,Ne,ht){if(r.timeoutHandle=ar,Ce=o.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce=aC(),lu(o,F,Ce);var Tn=(F&62914560)===F?Lu-us():(F&4194048)===F?Np-us():0;if(Tn=nC(Ce,Tn),Tn!==null){V0=F,r.cancelPendingCommit=Tn(du.bind(null,r,o,F,m,w,S,D,Y,ue,Be,Ce,null,Ne,ht)),Xi(r,F,D,!ke);return}}du(r,o,F,m,w,S,D,Y,ue)}function o1(r){for(var o=r;;){var m=o.tag;if((m===0||m===11||m===15)&&o.flags&16384&&(m=o.updateQueue,m!==null&&(m=m.stores,m!==null)))for(var w=0;w<m.length;w++){var S=m[w],F=S.getSnapshot;S=S.value;try{if(!Ns(F(),S))return!1}catch(D){return!1}}if(m=o.child,o.subtreeFlags&16384&&m!==null)m.return=o,o=m;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function Xi(r,o,m,w){o&=~B3,o&=~cr,r.suspendedLanes|=o,r.pingedLanes&=~o,w&&(r.warmLanes|=o),w=r.expirationTimes;for(var S=o;0<S;){var F=31-xs(S),D=1<<F;w[F]=-1,S&=~D}m!==0&&x(r,m,o)}function uu(){return(At&6)===0?(Da(0,!1),!1):!0}function Bc(){if(yt!==null){if(Qt===0)var r=yt.return;else r=yt,G0=sr=null,$o(r),y1=null,Ec=0,r=yt;for(;r!==null;)eu(r.alternate,r),r=r.return;yt=null}}function Mf(r,o){var m=r.timeoutHandle;m!==ar&&(r.timeoutHandle=ar,JS(m)),m=r.cancelPendingCommit,m!==null&&(r.cancelPendingCommit=null,m()),V0=0,Bc(),la=r,yt=m=oe(r.current,null),Ct=o,Qt=0,zs=null,Kf=!1,B1=y(r,o),O3=!1,T1=Us=B3=cr=Lf=Ra=0,gs=Gc=null,T3=!1,(o&8)!==0&&(o|=o&32);var w=r.entangledLanes;if(w!==0)for(r=r.entanglements,w&=o;0<w;){var S=31-xs(w),F=1<<S;o|=r[S],w&=~F}return L0=o,bf(),m}function mu(r,o){gt=null,We.H=Uc,o===A1||o===xu?(o=Aa(),Qt=3):o===v3?(o=Aa(),Qt=4):Qt=o===C3?8:o!==null&&typeof o==="object"&&typeof o.then==="function"?6:1,zs=o,yt===null&&(Ra=1,Cf(r,ne(o,r.current)))}function c1(){var r=Es.current;return r===null?!0:(Ct&4194048)===Ct?li===null?!0:!1:(Ct&62914560)===Ct||(Ct&536870912)!==0?r===li:!1}function gu(){var r=We.H;return We.H=Uc,r===null?Uc:r}function pu(){var r=We.A;return We.A=C_,r}function er(){Ra=4,Kf||(Ct&4194048)!==Ct&&Es.current!==null||(B1=!0),(Lf&134217727)===0&&(cr&134217727)===0||la===null||Xi(la,Ct,Us,!1)}function Ki(r,o,m){var w=At;At|=2;var S=gu(),F=pu();if(la!==r||Ct!==o)Vu=null,Mf(r,o);o=!1;var D=Ra;e:do try{if(Qt!==0&&yt!==null){var Y=yt,ue=zs;switch(Qt){case 8:Bc(),D=6;break e;case 3:case 2:case 9:case 6:Es.current===null&&(o=!0);var ke=Qt;if(Qt=0,zs=null,E0(r,Y,ue,ke),m&&B1){D=0;break e}break;default:ke=Qt,Qt=0,zs=null,E0(r,Y,ue,ke)}}Ut(),D=Ra;break}catch(Be){mu(r,Be)}while(1);return o&&r.shellSuspendCounter++,G0=sr=null,At=w,We.H=S,We.A=F,yt===null&&(la=null,Ct=0,bf()),D}function Ut(){for(;yt!==null;)Ds(yt)}function N0(r,o){var m=At;At|=2;var w=gu(),S=pu();la!==r||Ct!==o?(Vu=null,Xc=us()+500,Mf(r,o)):B1=y(r,o);e:do try{if(Qt!==0&&yt!==null){o=yt;var F=zs;t:switch(Qt){case 1:Qt=0,zs=null,E0(r,o,F,1);break;case 2:case 9:if(Te(F)){Qt=0,zs=null,bu(o);break}o=function(){Qt!==2&&Qt!==9||la!==r||(Qt=7),pa(r)},F.then(o,o);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:Te(F)?(Qt=0,zs=null,bu(o)):(Qt=0,zs=null,E0(r,o,F,7));break;case 5:var D=null;switch(yt.tag){case 26:D=yt.memoizedState;case 5:case 27:var Y=yt,ue=Y.type,ke=Y.pendingProps;if(D?yp(D):rp(Y.stateNode,ue,ke)){Qt=0,zs=null;var Be=Y.sibling;if(Be!==null)yt=Be;else{var Ce=Y.return;Ce!==null?(yt=Ce,h1(Ce)):yt=null}break t}}Qt=0,zs=null,E0(r,o,F,5);break;case 6:Qt=0,zs=null,E0(r,o,F,6);break;case 8:Bc(),Ra=6;break e;default:throw Error(n(462))}}_n();break}catch(Ne){mu(r,Ne)}while(1);if(G0=sr=null,We.H=w,We.A=S,At=m,yt!==null)return 0;return la=null,Ct=0,bf(),Ra}function _n(){for(;yt!==null&&!p_();)Ds(yt)}function Ds(r){var o=W2(r.alternate,r,L0);r.memoizedProps=r.pendingProps,o===null?h1(r):yt=o}function bu(r){var o=r,m=o.alternate;switch(o.tag){case 15:case 0:o=Kl(m,o,o.pendingProps,o.type,void 0,Ct);break;case 11:o=Kl(m,o,o.pendingProps,o.type.render,o.ref,Ct);break;case 5:$o(o);default:eu(m,o),o=yt=Oe(o,L0),o=W2(m,o,L0)}r.memoizedProps=r.pendingProps,o===null?h1(r):yt=o}function E0(r,o,m,w){G0=sr=null,$o(o),y1=null,Ec=0;var S=o.return;try{if($5(r,S,o,m,Ct)){Ra=1,Cf(r,ne(m,r.current)),yt=null;return}}catch(F){if(S!==null)throw yt=S,F;Ra=1,Cf(r,ne(m,r.current)),yt=null;return}if(o.flags&32768){if(Ft||w===1)r=!0;else if(B1||(Ct&536870912)!==0)r=!1;else if(Kf=r=!0,w===2||w===9||w===3||w===6)w=Es.current,w!==null&&w.tag===13&&(w.flags|=16384);wu(o,r)}else h1(o)}function h1(r){var o=r;do{if((o.flags&32768)!==0){wu(o,Kf);return}r=o.return;var m=P5(o.alternate,o,L0);if(m!==null){yt=m;return}if(o=o.sibling,o!==null){yt=o;return}yt=o=r}while(o!==null);Ra===0&&(Ra=5)}function wu(r,o){do{var m=e3(r.alternate,r);if(m!==null){m.flags&=32767,yt=m;return}if(m=r.return,m!==null&&(m.flags|=32768,m.subtreeFlags=0,m.deletions=null),!o&&(r=r.sibling,r!==null)){yt=r;return}yt=r=m}while(r!==null);Ra=6,yt=null}function du(r,o,m,w,S,F,D,Y,ue){r.cancelPendingCommit=null;do z0();while(sn!==0);if((At&6)!==0)throw Error(n(327));if(o!==null){if(o===r.current)throw Error(n(177));if(F=o.lanes|o.childLanes,F|=k3,N(r,m,F,D,Y,ue),r===la&&(yt=la=null,Ct=0),H1=o,Yf=r,V0=m,H3=F,M3=S,Ep=w,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,G(g3,function(){return p(),null})):(r.callbackNode=null,r.callbackPriority=0),w=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||w){w=We.T,We.T=null,S=I0(),mn(2),D=At,At|=4;try{su(r,o,m)}finally{At=D,mn(S),We.T=w}}sn=1,ju(),qu(),vu()}}function ju(){if(sn===1){sn=0;var r=Yf,o=H1,m=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||m){m=We.T,We.T=null;var w=I0();mn(2);var S=At;At|=4;try{iu(o,r),LS(r.containerInfo)}finally{At=S,mn(w),We.T=m}}r.current=o,sn=2}}function qu(){if(sn===2){sn=0;var r=Yf,o=H1,m=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||m){m=We.T,We.T=null;var w=I0();mn(2);var S=At;At|=4;try{dc(r,o.alternate,o)}finally{At=S,mn(w),We.T=m}}sn=3}}function vu(){if(sn===4||sn===3){sn=0,b_();var r=Yf,o=H1,m=V0,w=Ep;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?sn=5:(sn=0,H1=Yf=null,ku(r,r.pendingLanes));var S=r.pendingLanes;if(S===0&&(Vf=null),Q(m),o=o.stateNode,Rs&&typeof Rs.onCommitFiberRoot==="function")try{Rs.onCommitFiberRoot(Dc,o,void 0,(o.current.flags&128)===128)}catch(ue){}if(w!==null){o=We.T,S=I0(),mn(2),We.T=null;try{for(var F=r.onRecoverableError,D=0;D<w.length;D++){var Y=w[D];F(Y.value,{componentStack:Y.stack})}}finally{We.T=o,mn(S)}}(V0&3)!==0&&z0(),pa(r),S=r.pendingLanes,(m&261930)!==0&&(S&42)!==0?r===D3?Kc++:(Kc=0,D3=r):Kc=0,Xn&&e_(),Da(0,!1)}}function ku(r,o){(r.pooledCacheLanes&=o)===0&&(o=r.pooledCache,o!=null&&(r.pooledCache=null,Ja(o)))}function z0(){return ju(),qu(),vu(),p()}function p(){if(sn!==5)return!1;var r=Yf,o=H3;H3=0;var m=Q(V0),w=32>m?32:m;m=We.T;var S=I0();try{mn(w),We.T=null,w=M3,M3=null;var F=Yf,D=V0;if(sn=0,H1=Yf=null,V0=0,(At&6)!==0)throw Error(n(331));var Y=At;if(At|=4,ou(F.current),fu(F,F.current,D,w),At=Y,Da(0,!1),Rs&&typeof Rs.onPostCommitFiberRoot==="function")try{Rs.onPostCommitFiberRoot(Dc,F)}catch(ue){}return!0}finally{mn(S),We.T=m,ku(r,o)}}function q(r,o,m){o=ne(m,o),o=Ii(r.stateNode,o,2),r=Ei(r,o,2),r!==null&&(H(r,2),pa(r))}function v(r,o,m){if(r.tag===3)q(r,r,m);else for(;o!==null;){if(o.tag===3){q(o,r,m);break}else if(o.tag===1){var w=o.stateNode;if(typeof o.type.getDerivedStateFromError==="function"||typeof w.componentDidCatch==="function"&&(Vf===null||!Vf.has(w))){r=ne(m,r),m=Il(2),w=Ei(o,m,2),w!==null&&(Gi(m,w,o,r),H(w,2),pa(w));break}}o=o.return}}function k(r,o,m){var w=r.pingCache;if(w===null){w=r.pingCache=new __;var S=new Set;w.set(o,S)}else S=w.get(o),S===void 0&&(S=new Set,w.set(o,S));S.has(m)||(O3=!0,S.add(m),r=_.bind(null,r,o,m),o.then(r,r))}function _(r,o,m){var w=r.pingCache;w!==null&&w.delete(o),r.pingedLanes|=r.suspendedLanes&m,r.warmLanes&=~m,la===r&&(Ct&m)===m&&(Ra===4||Ra===3&&(Ct&62914560)===Ct&&300>us()-Lu?(At&2)===0&&Mf(r,0):B3|=m,T1===Ct&&(T1=0)),pa(r)}function B(r,o){o===0&&(o=T()),r=_0(r,o),r!==null&&(H(r,o),pa(r))}function E(r){var o=r.memoizedState,m=0;o!==null&&(m=o.retryLane),B(r,m)}function U(r,o){var m=0;switch(r.tag){case 31:case 13:var{stateNode:w,memoizedState:S}=r;S!==null&&(m=S.retryLane);break;case 19:w=r.stateNode;break;case 22:w=r.stateNode._retryCache;break;default:throw Error(n(314))}w!==null&&w.delete(o),B(r,m)}function G(r,o){return Ou(r,o)}function X(r,o,m,w){this.tag=r,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function W(r){return r=r.prototype,!(!r||!r.isReactComponent)}function oe(r,o){var m=r.alternate;return m===null?(m=t(r.tag,o,r.key,r.mode),m.elementType=r.elementType,m.type=r.type,m.stateNode=r.stateNode,m.alternate=r,r.alternate=m):(m.pendingProps=o,m.type=r.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=r.flags&65011712,m.childLanes=r.childLanes,m.lanes=r.lanes,m.child=r.child,m.memoizedProps=r.memoizedProps,m.memoizedState=r.memoizedState,m.updateQueue=r.updateQueue,o=r.dependencies,m.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},m.sibling=r.sibling,m.index=r.index,m.ref=r.ref,m.refCleanup=r.refCleanup,m}function Oe(r,o){r.flags&=65011714;var m=r.alternate;return m===null?(r.childLanes=0,r.lanes=o,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=m.childLanes,r.lanes=m.lanes,r.child=m.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=m.memoizedProps,r.memoizedState=m.memoizedState,r.updateQueue=m.updateQueue,r.type=m.type,o=m.dependencies,r.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),r}function ge(r,o,m,w,S,F){var D=0;if(w=r,typeof r==="function")W(r)&&(D=1);else if(typeof r==="string")D=_i&&nn?dp(r,m,On.current)?26:_p(r)?27:5:_i?dp(r,m,On.current)?26:5:nn?_p(r)?27:5:5;else e:switch(r){case f3:return r=t(31,m,o,S),r.elementType=f3,r.lanes=F,r;case m1:return Ge(m.children,S,F,o);case ap:D=8,S|=24;break;case t3:return r=t(12,m,o,S|2),r.elementType=t3,r.lanes=F,r;case n3:return r=t(13,m,o,S),r.elementType=n3,r.lanes=F,r;case s3:return r=t(19,m,o,S),r.elementType=s3,r.lanes=F,r;default:if(typeof r==="object"&&r!==null)switch(r.$$typeof){case Ef:D=10;break e;case np:D=9;break e;case a3:D=11;break e;case i3:D=14;break e;case zf:D=16,w=null;break e}D=29,m=Error(n(130,r===null?"null":typeof r,"")),w=null}return o=t(D,m,o,S),o.elementType=r,o.type=w,o.lanes=F,o}function Ge(r,o,m,w){return r=t(7,r,w,o),r.lanes=m,r}function et(r,o,m){return r=t(6,r,null,o),r.lanes=m,r}function Ga(r){var o=t(18,null,null,0);return o.stateNode=r,o}function Fn(r,o,m){return o=t(4,r.children!==null?r.children:[],r.key,o),o.lanes=m,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function Li(r,o,m,w,S,F,D,Y,ue){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=ar,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=M(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=M(0),this.hiddenUpdates=M(null),this.identifierPrefix=w,this.onUncaughtError=S,this.onCaughtError=F,this.onRecoverableError=D,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ue,this.incompleteTransitions=new Map}function Df(r,o,m,w,S,F,D,Y,ue,ke,Be,Ce){return r=new Li(r,o,m,D,ue,ke,Be,Ce,Y),o=1,F===!0&&(o|=24),F=t(3,null,null,o),r.current=F,F.stateNode=r,o=Ya(),o.refCount++,r.pooledCache=o,o.refCount++,F.memoizedState={element:w,isDehydrated:m,cache:o},Bs(F),r}function xf(r){if(!r)return w1;return r=w1,r}function Rf(r){var o=r._reactInternals;if(o===void 0){if(typeof r.render==="function")throw Error(n(188));throw r=Object.keys(r).join(","),Error(n(268,r))}return r=f(o),r=r!==null?l(r):null,r===null?null:Tc(r.stateNode)}function Nf(r,o,m,w,S,F){S=xf(S),w.context===null?w.context=S:w.pendingContext=S,w=St(o),w.payload={element:m},F=F===void 0?null:F,F!==null&&(w.callback=F),m=Ei(r,w,o),m!==null&&(un(m,r,o),zi(m,r,o))}function tr(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var m=r.retryLane;r.retryLane=m!==0&&m<o?m:o}}function Jt(r,o){tr(r,o),(r=r.alternate)&&tr(r,o)}var ct={},$n=Object.assign,NS=Symbol.for("react.element"),Au=Symbol.for("react.transitional.element"),u1=Symbol.for("react.portal"),m1=Symbol.for("react.fragment"),ap=Symbol.for("react.strict_mode"),t3=Symbol.for("react.profiler"),np=Symbol.for("react.consumer"),Ef=Symbol.for("react.context"),a3=Symbol.for("react.forward_ref"),n3=Symbol.for("react.suspense"),s3=Symbol.for("react.suspense_list"),i3=Symbol.for("react.memo"),zf=Symbol.for("react.lazy"),f3=Symbol.for("react.activity"),ES=Symbol.for("react.memo_cache_sentinel"),sp=Symbol.iterator,zS=Symbol.for("react.client.reference"),yu=Array.isArray,We=t8.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,US=e.rendererVersion,IS=e.rendererPackageName,ip=e.extraDevToolsConfig,Tc=e.getPublicInstance,GS=e.getRootHostContext,XS=e.getChildHostContext,KS=e.prepareForCommit,LS=e.resetAfterCommit,VS=e.createInstance;e.cloneMutableInstance;var{appendInitialChild:l3,finalizeInitialChildren:fp,shouldSetTextContent:Su,createTextInstance:lp}=e;e.cloneMutableTextInstance;var{scheduleTimeout:YS,cancelTimeout:JS,noTimeout:ar,isPrimaryRenderer:U0}=e;e.warnsIfNotActing;var{supportsMutation:Gn,supportsPersistence:Vi,supportsHydration:Xn,getInstanceFromNode:QS}=e;e.beforeActiveInstanceBlur;var ZS=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var{setCurrentUpdatePriority:mn,getCurrentUpdatePriority:I0,resolveUpdatePriority:$S}=e;e.trackSchedulerEvent,e.resolveEventType,e.resolveEventTimeStamp;var{shouldAttemptEagerTransition:WS,detachDeletedInstance:PS}=e;e.requestPostPaintCallback;var{maySuspendCommit:eC,maySuspendCommitOnUpdate:tC,maySuspendCommitInSyncRender:r3,preloadInstance:rp,startSuspendingCommit:aC,suspendInstance:op}=e;e.suspendOnActiveViewTransition;var nC=e.waitForCommitToBeReady;e.getSuspendedCommitReason;var{NotPendingTransition:g1,HostTransitionContext:nr,resetFormInstance:sC}=e;e.bindToConsole;var{supportsMicrotasks:iC,scheduleMicrotask:fC,supportsTestSelectors:Hc,findFiberRoot:lC,getBoundingRect:rC,getTextContent:oC,isHiddenSubtree:Mc,matchAccessibilityRole:cC,setFocusIfFocusable:hC,setupIntersectionObserver:uC,appendChild:mC,appendChildToContainer:gC,commitTextUpdate:pC,commitMount:bC,commitUpdate:wC,insertBefore:dC,insertInContainerBefore:jC,removeChild:qC,removeChildFromContainer:vC,resetTextContent:cp,hideInstance:kC,hideTextInstance:AC,unhideInstance:yC,unhideTextInstance:SC}=e;e.cancelViewTransitionName,e.cancelRootViewTransitionName,e.restoreRootViewTransitionName,e.cloneRootViewTransitionContainer,e.removeRootViewTransitionClone,e.measureClonedInstance,e.hasInstanceChanged,e.hasInstanceAffectedParent,e.startViewTransition,e.startGestureTransition,e.stopViewTransition,e.getCurrentGestureOffset,e.createViewTransitionInstance;var CC=e.clearContainer;e.createFragmentInstance,e.updateFragmentInstanceFiber,e.commitNewChildToFragmentInstance,e.deleteChildFromFragmentInstance;var{cloneInstance:_C,createContainerChildSet:hp,appendChildToContainerChildSet:up,finalizeContainerChildren:FC,replaceContainerChildren:mp,cloneHiddenInstance:gp,cloneHiddenTextInstance:pp,isSuspenseInstancePending:o3,isSuspenseInstanceFallback:c3,getSuspenseInstanceFallbackErrorDetails:OC,registerSuspenseInstanceRetry:BC,canHydrateFormStateMarker:TC,isFormStateMarkerMatching:HC,getNextHydratableSibling:bp,getNextHydratableSiblingAfterSingleton:MC,getFirstHydratableChild:DC,getFirstHydratableChildWithinContainer:xC,getFirstHydratableChildWithinActivityInstance:RC,getFirstHydratableChildWithinSuspenseInstance:NC,getFirstHydratableChildWithinSingleton:EC,canHydrateInstance:zC,canHydrateTextInstance:UC,canHydrateActivityInstance:IC,canHydrateSuspenseInstance:GC,hydrateInstance:XC,hydrateTextInstance:KC,hydrateActivityInstance:LC,hydrateSuspenseInstance:VC,getNextHydratableInstanceAfterActivityInstance:YC,getNextHydratableInstanceAfterSuspenseInstance:JC,commitHydratedInstance:QC,commitHydratedContainer:ZC,commitHydratedActivityInstance:$C,commitHydratedSuspenseInstance:WC,finalizeHydratedChildren:PC,flushHydrationEvents:e_}=e;e.clearActivityBoundary;var t_=e.clearSuspenseBoundary;e.clearActivityBoundaryFromContainer;var{clearSuspenseBoundaryFromContainer:a_,hideDehydratedBoundary:n_,unhideDehydratedBoundary:s_,shouldDeleteUnhydratedTailInstances:wp}=e;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var{validateHydratableInstance:i_,validateHydratableTextInstance:f_,supportsResources:_i,isHostHoistableType:dp,getHoistableRoot:h3,getResource:jp,acquireResource:qp,releaseResource:vp,hydrateHoistable:l_,mountHoistable:kp,unmountHoistable:Ap,createHoistableInstance:r_,prepareToCommitHoistables:o_,mayResourceSuspendCommit:c_,preloadResource:yp,suspendResource:h_,supportsSingletons:nn,resolveSingletonInstance:Sp,acquireSingletonInstance:u_,releaseSingletonInstance:Cp,isHostSingletonType:_p,isSingletonScope:p1}=e,u3=[],b1=-1,w1={},xs=Math.clz32?Math.clz32:j,m_=Math.log,g_=Math.LN2,Cu=256,_u=262144,Fu=4194304,Ou=e8,m3=Gk,p_=Kk,b_=Xk,us=Pm,Fp=Uk,w_=Ik,g3=Pg,d_=e5,j_=void 0,q_=void 0,Dc=null,Rs=null,Ns=typeof Object.is==="function"?Object.is:te,Op=typeof reportError==="function"?reportError:function(r){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r==="object"&&r!==null&&typeof r.message==="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(o))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",r);return}console.error(r)},v_=Object.prototype.hasOwnProperty,p3,Bp,b3=!1,Tp=new WeakMap,d1=[],j1=0,Bu=null,xc=0,ni=[],si=0,Uf=null,Yi=1,Ji="",On=g(null),Rc=g(null),If=g(null),Tu=g(null),Bn=null,Sa=null,Ft=!1,Gf=null,ii=!1,w3=Error(n(519)),Hu=g(null),sr=null,G0=null,k_=typeof AbortController<"u"?AbortController:function(){var r=[],o=this.signal={aborted:!1,addEventListener:function(m,w){r.push(w)}};this.abort=function(){o.aborted=!0,r.forEach(function(m){return m()})}},A_=e8,y_=Pg,Ca={$$typeof:Ef,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},Mu=null,q1=null,d3=!1,Du=!1,j3=!1,ir=0,Nc=null,q3=0,v1=0,k1=null,Hp=We.S;We.S=function(r,o){Np=us(),typeof o==="object"&&o!==null&&typeof o.then==="function"&&ka(r,o),Hp!==null&&Hp(r,o)};var fr=g(null),A1=Error(n(460)),v3=Error(n(474)),xu=Error(n(542)),Ru={then:function(){}},lr=null,y1=null,Ec=0,rr=Vo(!0),Mp=Vo(!1),fi=[],S1=0,k3=0,Xf=!1,A3=!1,C1=g(null),Nu=g(0),Es=g(null),li=null,Xa=g(0),X0=0,gt=null,aa=null,Za=null,Eu=!1,_1=!1,or=!1,zu=0,zc=0,F1=null,S_=0,Uc={readContext:wt,use:T0,useCallback:ja,useContext:ja,useEffect:ja,useImperativeHandle:ja,useLayoutEffect:ja,useInsertionEffect:ja,useMemo:ja,useReducer:ja,useRef:ja,useState:ja,useDebugValue:ja,useDeferredValue:ja,useTransition:ja,useSyncExternalStore:ja,useId:ja,useHostTransitionStatus:ja,useFormState:ja,useActionState:ja,useOptimistic:ja,useMemoCache:ja,useCacheRefresh:ja};Uc.useEffectEvent=ja;var Dp={readContext:wt,use:T0,useCallback:function(r,o){return cn().memoizedState=[r,o===void 0?null:o],r},useContext:wt,useEffect:B2,useImperativeHandle:function(r,o,m){m=m!==null&&m!==void 0?m.concat([r]):null,Dl(4194308,4,D2.bind(null,o,r),m)},useLayoutEffect:function(r,o){return Dl(4194308,4,r,o)},useInsertionEffect:function(r,o){Dl(4,2,r,o)},useMemo:function(r,o){var m=cn();o=o===void 0?null:o;var w=r();if(or){P(!0);try{r()}finally{P(!1)}}return m.memoizedState=[w,o],w},useReducer:function(r,o,m){var w=cn();if(m!==void 0){var S=m(o);if(or){P(!0);try{m(o)}finally{P(!1)}}}else S=o;return w.memoizedState=w.baseState=S,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:S},w.queue=r,r=r.dispatch=zl.bind(null,gt,r),[w.memoizedState,r]},useRef:function(r){var o=cn();return r={current:r},o.memoizedState=r},useState:function(r){r=Bl(r);var o=r.queue,m=Ul.bind(null,gt,o);return o.dispatch=m,[r.memoizedState,m]},useDebugValue:Rl,useDeferredValue:function(r,o){var m=cn();return Sf(m,r,o)},useTransition:function(){var r=Bl(!1);return r=E2.bind(null,gt,r.queue,!0,!1),cn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,o,m){var w=gt,S=cn();if(Ft){if(m===void 0)throw Error(n(407));m=m()}else{if(m=o(),la===null)throw Error(n(349));(Ct&127)!==0||Af(w,o,m)}S.memoizedState=m;var F={value:m,getSnapshot:o};return S.queue=F,B2(H0.bind(null,w,F,r),[r]),w.flags|=2048,yf(9,{destroy:void 0},Ol.bind(null,w,F,m,o),null),m},useId:function(){var r=cn(),o=la.identifierPrefix;if(Ft){var m=Ji,w=Yi;m=(w&~(1<<32-xs(w)-1)).toString(32)+m,o="_"+o+"R_"+m,m=zu++,0<m&&(o+="H"+m.toString(32)),o+="_"}else m=S_++,o="_"+o+"r_"+m.toString(32)+"_";return r.memoizedState=o},useHostTransitionStatus:lc,useFormState:sc,useActionState:sc,useOptimistic:function(r){var o=cn();o.memoizedState=o.baseState=r;var m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=m,o=Ms.bind(null,gt,!0,m),m.dispatch=o,[r,o]},useMemoCache:Wo,useCacheRefresh:function(){return cn().memoizedState=El.bind(null,gt)},useEffectEvent:function(r){var o=cn(),m={impl:r};return o.memoizedState=m,function(){if((At&2)!==0)throw Error(n(440));return m.impl.apply(void 0,arguments)}}},y3={readContext:wt,use:T0,useCallback:R2,useContext:wt,useEffect:Zr,useImperativeHandle:x2,useInsertionEffect:H2,useLayoutEffect:M2,useMemo:fc,useReducer:kf,useRef:O2,useState:function(){return kf(Hs)},useDebugValue:Rl,useDeferredValue:function(r,o){var m=ya();return N2(m,aa.memoizedState,r,o)},useTransition:function(){var r=kf(Hs)[0],o=ya().memoizedState;return[typeof r==="boolean"?r:rs(r),o]},useSyncExternalStore:Fl,useId:U2,useHostTransitionStatus:lc,useFormState:F2,useActionState:F2,useOptimistic:function(r,o){var m=ya();return S2(m,aa,r,o)},useMemoCache:Wo,useCacheRefresh:Nl};y3.useEffectEvent=T2;var xp={readContext:wt,use:T0,useCallback:R2,useContext:wt,useEffect:Zr,useImperativeHandle:x2,useInsertionEffect:H2,useLayoutEffect:M2,useMemo:fc,useReducer:Po,useRef:O2,useState:function(){return Po(Hs)},useDebugValue:Rl,useDeferredValue:function(r,o){var m=ya();return aa===null?Sf(m,r,o):N2(m,aa.memoizedState,r,o)},useTransition:function(){var r=Po(Hs)[0],o=ya().memoizedState;return[typeof r==="boolean"?r:rs(r),o]},useSyncExternalStore:Fl,useId:U2,useHostTransitionStatus:lc,useFormState:ic,useActionState:ic,useOptimistic:function(r,o){var m=ya();if(aa!==null)return S2(m,aa,r,o);return m.baseState=r,[r,m.queue.dispatch]},useMemoCache:Wo,useCacheRefresh:Nl};xp.useEffectEvent=T2;var S3={enqueueSetState:function(r,o,m){r=r._reactInternals;var w=hs(),S=St(w);S.payload=o,m!==void 0&&m!==null&&(S.callback=m),o=Ei(r,S,w),o!==null&&(un(o,r,w),zi(o,r,w))},enqueueReplaceState:function(r,o,m){r=r._reactInternals;var w=hs(),S=St(w);S.tag=1,S.payload=o,m!==void 0&&m!==null&&(S.callback=m),o=Ei(r,S,w),o!==null&&(un(o,r,w),zi(o,r,w))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var m=hs(),w=St(m);w.tag=2,o!==void 0&&o!==null&&(w.callback=o),o=Ei(r,w,m),o!==null&&(un(o,r,m),zi(o,r,m))}},C3=Error(n(461)),$a=!1,_3={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},K0=!1,Wa=!1,F3=!1,Rp=typeof WeakSet==="function"?WeakSet:Set,gn=null,Pa=null,ms=!1,Fi=null,O1=8192,C_={getCacheForType:function(r){var o=wt(Ca),m=o.data.get(r);return m===void 0&&(m=r(),o.data.set(r,m)),m},cacheSignal:function(){return wt(Ca).controller.signal}},Uu=0,Iu=1,Gu=2,Xu=3,Ku=4;if(typeof Symbol==="function"&&Symbol.for){var Ic=Symbol.for;Uu=Ic("selector.component"),Iu=Ic("selector.has_pseudo_class"),Gu=Ic("selector.role"),Xu=Ic("selector.test_id"),Ku=Ic("selector.text")}var __=typeof WeakMap==="function"?WeakMap:Map,At=0,la=null,yt=null,Ct=0,Qt=0,zs=null,Kf=!1,B1=!1,O3=!1,L0=0,Ra=0,Lf=0,cr=0,B3=0,Us=0,T1=0,Gc=null,gs=null,T3=!1,Lu=0,Np=0,Xc=1/0,Vu=null,Vf=null,sn=0,Yf=null,H1=null,V0=0,H3=0,M3=null,Ep=null,Kc=0,D3=null;return ct.attemptContinuousHydration=function(r){if(r.tag===13||r.tag===31){var o=_0(r,67108864);o!==null&&un(o,r,67108864),Jt(r,67108864)}},ct.attemptHydrationAtCurrentPriority=function(r){if(r.tag===13||r.tag===31){var o=hs();o=$(o);var m=_0(r,o);m!==null&&un(m,r,o),Jt(r,o)}},ct.attemptSynchronousHydration=function(r){switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var o=A(r.pendingLanes);if(o!==0){r.pendingLanes|=2;for(r.entangledLanes|=2;o;){var m=1<<31-xs(o);r.entanglements[1]|=m,o&=~m}pa(r),(At&6)===0&&(Xc=us()+500,Da(0,!1))}}break;case 31:case 13:o=_0(r,2),o!==null&&un(o,r,2),uu(),Jt(r,2)}},ct.batchedUpdates=function(r,o){return r(o)},ct.createComponentSelector=function(r){return{$$typeof:Uu,value:r}},ct.createContainer=function(r,o,m,w,S,F,D,Y,ue,ke){return Df(r,o,!1,null,m,w,F,null,D,Y,ue,ke)},ct.createHasPseudoClassSelector=function(r){return{$$typeof:Iu,value:r}},ct.createHydrationContainer=function(r,o,m,w,S,F,D,Y,ue,ke,Be,Ce,Ne,ht){return r=Df(m,w,!0,r,S,F,Y,ht,ue,ke,Be,Ce),r.context=xf(null),m=r.current,w=hs(),w=$(w),S=St(w),S.callback=o!==void 0&&o!==null?o:null,Ei(m,S,w),o=w,r.current.lanes=o,H(r,o),pa(r),r},ct.createPortal=function(r,o,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u1,key:w==null?null:""+w,children:r,containerInfo:o,implementation:m}},ct.createRoleSelector=function(r){return{$$typeof:Gu,value:r}},ct.createTestNameSelector=function(r){return{$$typeof:Xu,value:r}},ct.createTextSelector=function(r){return{$$typeof:Ku,value:r}},ct.defaultOnCaughtError=function(r){console.error(r)},ct.defaultOnRecoverableError=function(r){Op(r)},ct.defaultOnUncaughtError=function(r){Op(r)},ct.deferredUpdates=function(r){var o=We.T,m=I0();try{return mn(32),We.T=null,r()}finally{mn(m),We.T=o}},ct.discreteUpdates=function(r,o,m,w,S){var F=We.T,D=I0();try{return mn(2),We.T=null,r(o,m,w,S)}finally{mn(D),We.T=F,At===0&&(Xc=us()+500)}},ct.findAllNodes=_c,ct.findBoundingRects=function(r,o){if(!Hc)throw Error(n(363));o=_c(r,o),r=[];for(var m=0;m<o.length;m++)r.push(rC(o[m]));for(o=r.length-1;0<o;o--){m=r[o];for(var w=m.x,S=w+m.width,F=m.y,D=F+m.height,Y=o-1;0<=Y;Y--)if(o!==Y){var ue=r[Y],ke=ue.x,Be=ke+ue.width,Ce=ue.y,Ne=Ce+ue.height;if(w>=ke&&F>=Ce&&S<=Be&&D<=Ne){r.splice(o,1);break}else if(!(w!==ke||m.width!==ue.width||Ne<F||Ce>D)){Ce>F&&(ue.height+=Ce-F,ue.y=F),Ne<D&&(ue.height=D-Ce),r.splice(o,1);break}else if(!(F!==Ce||m.height!==ue.height||Be<w||ke>S)){ke>w&&(ue.width+=ke-w,ue.x=w),Be<S&&(ue.width=S-ke),r.splice(o,1);break}}}return r},ct.findHostInstance=Rf,ct.findHostInstanceWithNoPortals=function(r){return r=f(r),r=r!==null?c(r):null,r===null?null:Tc(r.stateNode)},ct.findHostInstanceWithWarning=function(r){return Rf(r)},ct.flushPassiveEffects=z0,ct.flushSyncFromReconciler=function(r){var o=At;At|=1;var m=We.T,w=I0();try{if(mn(2),We.T=null,r)return r()}finally{mn(w),We.T=m,At=o,(At&6)===0&&Da(0,!1)}},ct.flushSyncWork=uu,ct.focusWithin=function(r,o){if(!Hc)throw Error(n(363));r=Sc(r),o=hu(r,o),o=Array.from(o);for(r=0;r<o.length;){var m=o[r++],w=m.tag;if(!Mc(m)){if((w===5||w===26||w===27)&&hC(m.stateNode))return!0;for(m=m.child;m!==null;)o.push(m),m=m.sibling}}return!1},ct.getFindAllNodesFailureDescription=function(r,o){if(!Hc)throw Error(n(363));var m=0,w=[];r=[Sc(r),0];for(var S=0;S<r.length;){var F=r[S++],D=F.tag,Y=r[S++],ue=o[Y];if(D!==5&&D!==26&&D!==27||!Mc(F)){if(ai(F,ue)&&(w.push(Cc(ue)),Y++,Y>m&&(m=Y)),Y<o.length)for(F=F.child;F!==null;)r.push(F,Y),F=F.sibling}}if(m<o.length){for(r=[];m<o.length;m++)r.push(Cc(o[m]));return`findAllNodes was able to match part of the selector:
22
+ `+(w.join(" > ")+`
23
+
24
+ No matching component was found for:
25
+ `)+r.join(" > ")}return null},ct.getPublicRootInstance=function(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 27:case 5:return Tc(r.child.stateNode);default:return r.child.stateNode}},ct.injectIntoDevTools=function(){var r={bundleType:0,version:US,rendererPackageName:IS,currentDispatcherRef:We,reconcilerVersion:"19.2.0"};if(ip!==null&&(r.rendererConfig=ip),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")r=!1;else{var o=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(o.isDisabled||!o.supportsFiber)r=!0;else{try{Dc=o.inject(r),Rs=o}catch(m){}r=o.checkDCE?!0:!1}}return r},ct.isAlreadyRendering=function(){return(At&6)!==0},ct.observeVisibleRects=function(r,o,m,w){if(!Hc)throw Error(n(363));r=_c(r,o);var S=uC(r,m,w).disconnect;return{disconnect:function(){S()}}},ct.shouldError=function(){return null},ct.shouldSuspend=function(){return!1},ct.startHostTransition=function(r,o,m,w){if(r.tag!==5)throw Error(n(476));var S=z2(r).queue;E2(r,S,o,g1,m===null?a:function(){var F=z2(r);return F.next===null&&(F=r.alternate.memoizedState),Cn(r,F.next.queue,{},hs()),m(w)})},ct.updateContainer=function(r,o,m,w){var S=o.current,F=hs();return Nf(S,F,r,o,m,w),F},ct.updateContainerSync=function(r,o,m,w){return Nf(o.current,2,r,o,m,w),2},ct};t2.exports.default=t2.exports;Object.defineProperty(t2.exports,"__esModule",{value:!0})});var cA=Tt((jJ,oA)=>{var w0=Mt(en());oA.exports=function(t,a,n){let s=w0.useRef("loading"),i=w0.useRef(),[f,l]=w0.useState(0),c=w0.useRef(),h=w0.useRef(),u=w0.useRef();if(c.current!==t||h.current!==a||u.current!==n)s.current="loading",i.current=void 0,c.current=t,h.current=a,u.current=n;return w0.useLayoutEffect(function(){if(!t)return;var g=document.createElement("img");function b(){g.decode().catch(()=>{}).finally(()=>{s.current="loaded",i.current=g,l(Math.random())})}function d(){s.current="failed",i.current=void 0,l(Math.random())}return g.addEventListener("load",b),g.addEventListener("error",d),a&&(g.crossOrigin=a),n&&(g.referrerPolicy=n),g.src=t,function(){g.removeEventListener("load",b),g.removeEventListener("error",d)}},[t,a,n]),[i.current,s.current]}});function gz(e){if(!e||e.length<2)return null;let t=[...e].sort((a,n)=>n.version-a.version);return{left:t[0],right:t[1]}}function zp(e,t){return Math.max(0,Math.min(e,Math.max(0,t-1)))}var Ni=Mt(en(),1);var M1=Mt(en(),1);var O_=(e)=>ie("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[R("circle",{cx:"12",cy:"12",r:"10"}),R("path",{d:"m9 12 2 2 4-4"})]}),B_=(e)=>ie("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",...e,children:[R("circle",{cx:"12",cy:"12",r:"10"}),R("path",{d:"m9 12 2 2 4-4",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Up={__CHAT__:"Generating...",__AUTOFILL__:"Autofilling metadata...",__EMBEDDING__:"Generating embeddings...",__RUNNING__:"Generating..."},x3=({teamId:e,message:t,isReply:a,hasReplies:n,isLastReply:s,getUser:i,onReply:f,isSelected:l,onSelect:c,frameRate:h,startTimecode:u,formatTimestamp:g})=>{let b=t,d=!!b.annotations&&Array.isArray(b.annotations)&&b.annotations.length>0,j=b.creator,A=!!b.sessionId&&!!b.message&&b.message in Up,C=b.message&&Up[b.message]||"Generating...",[y,O]=M1.default.useState(!1),[T,M]=M1.default.useState(null),{videoTimeDisplayMode:H}=Qf(),N=M1.default.useMemo(()=>{if(b.second===null||b.second===void 0)return"";if(g)return g(b.second);if(!h)return"";let fe=Math.round(b.second*h);return ri(fe,h,H,u)},[b.second,h,H,u,g]),{data:x}=Ju({queryKey:["teams",e,"me"],queryFn:async()=>{let fe=await Ht.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!fe.ok)throw Error("Failed to fetch current member info");return await fe.json()},enabled:!!e,staleTime:300000}),z=x?.role==="owner",K=Yu(),{mutate:$}=ur({mutationFn:async()=>{let fe=await Ht.api.comments[":commentId"].complete.$post({param:{commentId:b.id},json:{isCompleted:!b.isCompleted}});if(!fe.ok)throw Error("Failed to update comment completion status");return await fe.json()},onSuccess:()=>{K.invalidateQueries({predicate:(fe)=>fe.queryKey.includes("comments")})}}),[Q,P]=M1.default.useState(!1),{mutate:te,isPending:ee}=ur({mutationFn:async()=>{let fe=await Ht.api.comments[":commentId"].$delete({param:{commentId:b.id}});if(!fe.ok)throw Error("Failed to delete comment");return await fe.json()},onSuccess:()=>{K.invalidateQueries({predicate:(fe)=>fe.queryKey.includes("comments")}),P(!1)}}),L=M1.default.useMemo(()=>{if(!x)return!1;if(x.role==="owner")return!0;if(b.creator?.id===x.id)return!0;return!1},[x,b.creator?.id]),J=(fe)=>{return fe.split(/(<@[a-zA-Z0-9_-]+>)/g).map((he,re)=>{if(he.match(/^<@[a-zA-Z0-9_-]+>$/)){let be=he.slice(2,-1),Ue=b.mentions?.find((at)=>at.id===be)||i(be);return ie("span",{className:"text-primary font-medium hover:underline cursor-pointer",children:["@",Ue?.name||"Unknown"]},re)}return R("span",{children:he},re)})},pe=(fe)=>{return fe.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},ne=()=>{f(b)};return ie("div",{onClick:c,className:`relative flex gap-4 ${a?"mt-[-1px]":"mt-3"} mr-3 group p-3 py-4 border transition-all duration-200 cursor-pointer ${a?s?"rounded-b-xl rounded-t-none":"rounded-none":n?"rounded-t-xl rounded-b-none":"rounded-xl"} ${l?"z-20 border-blue-500/40 dark:border-blue-400/40 bg-blue-500/10 dark:bg-blue-400/10 shadow-sm":"z-10 border-transparent bg-foreground/2 dark:bg-foreground/10 hover:bg-foreground/4 dark:hover:bg-foreground/15"}`,children:[ie("div",{className:"flex flex-col items-center shrink-0 w-8 relative",children:[a&&R("div",{className:"absolute top-[-1rem] h-8 w-0.5 bg-foreground/10 left-1/2 -translate-x-1/2 z-0"}),(n&&!a||a&&!s)&&R("div",{className:"absolute top-4 bottom-[-1rem] w-0.5 bg-foreground/10 left-1/2 -translate-x-1/2 z-0"}),ie(Vc,{className:"z-10 relative",children:[j?.image&&R(Yc,{src:j.image,alt:j.name||"",className:"object-cover"}),R(Jc,{className:"bg-rose-400 text-black",children:j?.name?.[0]?.toUpperCase()||"U"})]})]}),ie("div",{className:"flex-1 min-w-0",children:[ie("div",{className:"flex items-center justify-between w-full mb-1",children:[ie("div",{className:"flex items-center gap-2",children:[R("span",{className:"font-semibold text-sm",children:j?.name||"Unknown"}),R("span",{className:"text-xs text-gray-400",children:new Date(b.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),L&&R("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:ie(Qi,{modal:!1,children:[R(Zi,{asChild:!0,children:R(Oi,{size:"icon-xs",variant:"ghost",className:"h-6 w-6 cursor-pointer",onClick:(fe)=>fe.stopPropagation(),children:R(Ip,{className:"h-4 w-4 text-foreground/70"})})}),R($i,{align:"end",onClick:(fe)=>fe.stopPropagation(),children:ie(Hn,{className:"text-destructive focus:text-destructive cursor-pointer",onClick:(fe)=>{fe.stopPropagation(),P(!0)},children:[R(Xp,{className:"mr-2 h-4 w-4"}),R("span",{children:He.delete()})]})})]})})]}),ie("div",{className:"flow-root mt-1",children:[b.second!==null&&b.second!==void 0&&h&&R("div",{className:"float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-mono font-bold flex items-center gap-1",children:N}),d&&R("div",{className:"float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-1 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-bold flex items-center gap-1",title:"Contains drawing annotations",children:R(Qu,{className:"w-3.5 h-3.5"})}),A?ie("div",{className:"space-y-2",children:[R(ps,{className:"h-4 w-3/4"}),R(ps,{className:"h-4 w-1/2"}),R("span",{className:"text-xs text-muted-foreground animate-pulse",children:C})]}):b.sessionId?R("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:R(f7,{children:pe(b.message)})}):R("div",{className:"text-sm leading-[1.8] whitespace-pre-wrap break-words text-wrap break-all",children:J(b.message)})]}),b.attachments&&b.attachments.length>0&&R("div",{className:"flex flex-col gap-1.5 mt-3 w-full max-w-full overflow-hidden",children:b.attachments.map((fe)=>{let Ae=fe.url?.split("/").pop()?.split("?")[0]||"file",he=decodeURIComponent(Ae),re=l7(he);return ie("div",{className:`group relative flex items-center w-full max-w-full rounded-lg border border-border bg-card hover:bg-muted/40 transition-colors overflow-hidden ${re?"h-18 p-1.5 gap-2.5 cursor-pointer":"h-9 px-2.5 gap-2.5"}`,onClick:()=>{if(re)M({url:fe.url,name:he});else window.open(fe.url,"_blank","noreferrer")},children:[re?R("div",{className:"h-full aspect-square rounded-md overflow-hidden bg-muted/40 shrink-0",children:R("img",{src:fe.url,alt:he,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-200"})}):R(Gp,{className:"w-4 h-4 text-muted-foreground shrink-0"}),R("div",{className:"min-w-0 flex-1 overflow-hidden",children:R("p",{className:"text-xs font-medium text-foreground truncate block w-full",title:he,children:he})}),R("a",{href:fe.url,target:"_blank",rel:"noreferrer",download:he,className:"p-1 text-muted-foreground hover:text-foreground shrink-0 rounded-md hover:bg-muted transition-colors opacity-0 group-hover:opacity-100",onClick:(be)=>be.stopPropagation(),title:He.download(),children:R(Bi,{className:"w-3.5 h-3.5"})})]},fe.id)})}),b.sessionId&&ie("div",{className:"mt-3 pt-2 border-t border-foreground/5 flex items-center justify-between text-xs text-muted-foreground/60",children:[R("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground/80",children:"Created by Agent"}),z&&R(Oi,{variant:"outline",size:"xs",onClick:()=>O(!0),className:"cursor-pointer border-violet-500/20 text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 hover:text-violet-700 hover:border-violet-500/30 font-semibold",children:"Logs"})]}),ie("div",{className:"mt-2 flex items-center justify-between w-full",children:[R("button",{onClick:ne,className:"text-xs font-medium text-gray-500 hover:text-blue-600 flex items-center gap-1 cursor-pointer",children:He.reply()}),R(Kp,{children:ie(Lp,{children:[R(Vp,{asChild:!0,children:R("button",{onClick:(fe)=>{fe.stopPropagation(),$()},className:`flex items-center justify-center p-1 rounded-full transition-colors cursor-pointer ${b.isCompleted?"text-green-500 hover:text-green-600 hover:bg-green-500/10":"text-gray-400 hover:text-green-500 hover:bg-green-500/10"}`,children:b.isCompleted?R(B_,{className:"w-5 h-5"}):R(O_,{className:"w-5 h-5"})})}),R(Yp,{children:b.isCompleted?He.mark_as_incomplete():He.mark_as_complete()})]})})]})]}),R(r7,{sessionId:b.sessionId,open:y,onOpenChange:O}),R(Jp,{open:Q,onOpenChange:P,children:ie(Qp,{onClick:(fe)=>fe.stopPropagation(),children:[ie(Zp,{children:[R(Wp,{children:He.delete_comment_confirm()}),R(Pp,{children:He.delete_comment_description()})]}),ie($p,{children:[R(t7,{disabled:ee,onClick:(fe)=>{fe.stopPropagation(),P(!1)},children:He.cancel()}),R(e7,{className:"bg-destructive hover:bg-destructive/90 text-white",disabled:ee,onClick:(fe)=>{fe.stopPropagation(),te()},children:He.delete()})]})]})}),R(a7,{open:!!T,onOpenChange:(fe)=>!fe&&M(null),children:ie(n7,{className:"w-auto max-w-[80vw] sm:max-w-[80vw] max-h-[80vh] p-2 sm:p-3 bg-background/95 backdrop-blur-sm border-border flex flex-col items-center justify-center overflow-hidden",onClick:(fe)=>fe.stopPropagation(),children:[R(s7,{className:"sr-only",children:R(i7,{children:T?.name||"Image Preview"})}),T&&ie("div",{className:"flex flex-col items-center justify-center max-w-[80vw] max-h-[80vh] overflow-hidden",children:[R("img",{src:T.url,alt:T.name,className:"max-w-[80vw] max-h-[calc(80vh-2.5rem)] w-auto h-auto object-contain rounded-md"}),R("p",{className:"text-xs text-muted-foreground truncate max-w-full px-2 pt-1.5 text-center",children:T.name})]})]})})]})};var bs=o7((e,t)=>({isDrawing:!1,currentTool:"arrow",currentColor:"#ef4444",annotations:[],history:[[]],historyIndex:0,setIsDrawing:(a)=>e({isDrawing:a}),setTool:(a)=>e({currentTool:a}),setColor:(a)=>e({currentColor:a}),addAnnotation:(a)=>{let{annotations:n,history:s,historyIndex:i}=t(),f=[...n,a],l=s.slice(0,i+1);l.push(f),e({annotations:f,history:l,historyIndex:l.length-1})},setAnnotations:(a)=>{e({annotations:a,history:[a],historyIndex:0})},undo:()=>{let{historyIndex:a,history:n}=t();if(a>0){let s=a-1;e({annotations:n[s],historyIndex:s})}},redo:()=>{let{historyIndex:a,history:n}=t();if(a<n.length-1){let s=a+1;e({annotations:n[s],historyIndex:s})}},reset:()=>e({isDrawing:!1,currentTool:"arrow",annotations:[],history:[[]],historyIndex:0})}));var ra=Mt(en(),1);var T_=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#000000","#ffffff"],N3=ra.default.forwardRef(({projectId:e,onSendMessage:t,replyingTo:a,onCancelReply:n,initialText:s="",hideAnnotationControl:i=!1,disableMentions:f=!1,currentTime:l,frameRate:c,startTimecode:h,formatTimestamp:u,onTyping:g},b)=>{let[d,j]=ra.useState([]),[A,C]=ra.useState(null),[y,O]=ra.useState(!0),{videoTimeDisplayMode:T}=Qf(),M=ra.default.useMemo(()=>{if(l===void 0)return"";if(u)return u(l);if(!c)return"";let de=Math.round(l*c);return ri(de,c,T,h)},[l,c,T,h,u]),{teamId:H,ensureTeamIdForProject:N}=d7(),{members:x,loading:z,fetchMembers:K,fetchProjectMembers:$}=j7();ra.useEffect(()=>{if(e&&!H)N(e)},[e,H,N]);let{isDrawing:Q,setIsDrawing:P,currentTool:te,setTool:ee,currentColor:L,setColor:J,undo:pe,redo:ne,history:fe,historyIndex:Ae,annotations:he,reset:re}=bs(),[be,Ue]=ra.useState(!1),[at,Ye]=ra.useState(""),[Ie,mt]=ra.useState(0),[vt,ga]=ra.useState({bots:!1,users:!1}),[Dt,ta]=ra.useState(!1),rn=ra.default.useMemo(()=>{if(!y||l===void 0||!u&&!c||Dt)return"";if(T==="timecode")return"pl-[120px]";return"pl-[85px]"},[y,l,c,Dt,T]),jt=ra.useRef(null),xe=ra.useRef(null),ze=ra.useRef(null),Qe=ra.useRef(null),{mutateAsync:nt}=ur({mutationFn:async({projectId:de,data:$e})=>{let Je=await Ht.api.projects[":projectId"].attachments.$post({param:{projectId:de},json:$e});if(!Je.ok)throw Error("Failed to create attachment");return await Je.json()}});ra.useEffect(()=>{if(s&&jt.current){jt.current.innerText=s,ta(!!s.trim()),jt.current.focus();let de=document.createRange(),$e=window.getSelection();de.selectNodeContents(jt.current),de.collapse(!1),$e?.removeAllRanges(),$e?.addRange(de)}},[s]),ra.useEffect(()=>{if(a&&jt.current){jt.current.focus();let de=document.createRange(),$e=window.getSelection();de.selectNodeContents(jt.current),de.collapse(!1),$e?.removeAllRanges(),$e?.addRange(de)}},[a]),ra.useEffect(()=>{return()=>{P(!1)}},[P]);let Ot=x.filter((de)=>de.type==="agent"&&de.name?.toLowerCase().startsWith(at.toLowerCase())).map((de)=>({type:"user",data:de})),Ze=x.filter((de)=>de.type!=="agent"&&de.name?.toLowerCase().startsWith(at.toLowerCase())).map((de)=>({type:"user",data:de})),Yt=[...vt.bots?[]:Ot,...vt.users?[]:Ze];ra.useEffect(()=>{mt(0)},[at,be,vt]),ra.useEffect(()=>{Qe.current?.querySelector(`[data-index="${Ie}"]`)?.scrollIntoView({block:"nearest"})},[Ie]);let wt=(de)=>{return de.split(" ").map(($e)=>$e[0]).slice(0,2).join("").toUpperCase()},yn=()=>{if(!jt.current)return;if(ta(!!jt.current.innerText.trim()),g?.(),f){Ue(!1),ze.current=null;return}let de=window.getSelection();if(!de||de.rangeCount===0)return;let $e=de.getRangeAt(0),Je=$e.startContainer,xt=$e.startOffset;if(Je.nodeType===Node.TEXT_NODE){let ia=(Je.textContent||"").slice(0,xt),Me=ia.lastIndexOf("@");if(Me!==-1){let Re=Me===0,zt=ia[Me-1];if(Re||/\s/.test(zt)){let Se=ia.slice(Me+1);if(!/\s/.test(Se)){if(Ye(Se),Ue(!0),e)$(e,!0,!0);else if(H)K(H,!0,!0);let Te=document.createRange();Te.setStart(Je,Me),Te.setEnd(Je,xt),ze.current=Te;return}}}}Ue(!1),ze.current=null},zn=(de)=>{if(!ze.current||!jt.current)return;let $e=ze.current;$e.deleteContents();let Je=document.createElement("span");Je.contentEditable="false",Je.dataset.type="mention",Je.dataset.id=de.data.id,Je.className="inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5",Je.innerText=`@${de.data.name}`,$e.insertNode(Je);let xt=document.createTextNode(" ");Je.after(xt);let ka=document.createRange(),ia=window.getSelection();ka.setStartAfter(xt),ka.collapse(!0),ia?.removeAllRanges(),ia?.addRange(ka),Ue(!1),ze.current=null,ta(!0),jt.current.focus()},Ya=(de)=>{if(de.nativeEvent.isComposing)return;if(be&&Yt.length>0){if(de.key==="ArrowUp"){de.preventDefault(),mt(($e)=>$e>0?$e-1:Yt.length-1);return}if(de.key==="ArrowDown"){de.preventDefault(),mt(($e)=>$e<Yt.length-1?$e+1:0);return}if(de.key==="Enter"||de.key==="Tab"){de.preventDefault(),zn(Yt[Ie]);return}if(de.key==="Escape"){de.preventDefault(),Ue(!1);return}}if(de.key==="Enter"&&!de.shiftKey)de.preventDefault(),pa()},Ja=ra.useCallback(async(de)=>{if(!de.target.files)return;let $e=Array.from(de.target.files);for(let Je of $e){let xt=`${Date.now()}-${Je.name}`,ka={id:xt,file:Je,progress:0};j((ia)=>[...ia,ka]);try{let ia=await nt({projectId:e,data:{fileName:Je.name,contentType:Je.type,size:Je.size}});if(ia.uploadUrl&&ia.id)await fetch(ia.uploadUrl,{method:"PUT",body:Je,headers:{"Content-Type":Je.type}}),j((Me)=>Me.map((Re)=>Re.id===xt?{...Re,progress:100,attachmentId:ia.id}:Re))}catch(ia){j((Me)=>Me.map((Re)=>Re.id===xt?{...Re,error:ia instanceof Error?ia.message:"Upload failed"}:Re))}}if(xe.current)xe.current.value=""},[e,nt]),Sn=(de)=>{j(($e)=>$e.filter((Je)=>Je.id!==de))},pa=()=>{if(!jt.current)return;if(d.some((xt)=>!xt.attachmentId&&!xt.error))return;let $e=d.map((xt)=>xt.attachmentId).filter((xt)=>!!xt),Je="";if(jt.current.childNodes.forEach((xt)=>{if(xt.nodeType===Node.TEXT_NODE)Je+=xt.textContent;else if(xt.nodeType===Node.ELEMENT_NODE){let ka=xt;if(ka.dataset.type==="mention")Je+=`<@${ka.dataset.id}>`;else if(ka.tagName==="BR")Je+=`
26
+ `;else if(ka.tagName==="DIV"||ka.tagName==="P")Je+=`
27
+ `+ka.innerText;else Je+=ka.innerText}}),Je=Je.trim(),!Je&&$e.length===0&&he.length===0)return;if(t(Je,$e,he,a?.id,y?l:void 0),jt.current.innerHTML="",ta(!1),j([]),C(null),P(!1),re(),Ue(!1),n)n()},Da=d.some((de)=>!de.attachmentId&&!de.error),Os=d.some((de)=>!!de.attachmentId),ls=Dt||Os||he.length>0,Bt=d.length>0||!!a;return ie("div",{ref:b,className:"relative flex flex-col w-full border border-foreground/35 rounded-3xl shadow-sm transition-all duration-200",children:[R("style",{children:`
28
+ [contenteditable]:empty:before {
29
+ content: attr(data-placeholder);
30
+ color: #9ca3af;
31
+ cursor: text;
32
+ }
33
+ `}),be&&(z||Ot.length>0||Ze.length>0)&&R("div",{className:"absolute bottom-full left-4 mb-2 w-64 rounded-xl shadow-lg border border-border overflow-hidden z-20 bg-popover text-popover-foreground animate-in fade-in slide-in-from-bottom-2 duration-200",children:R("div",{ref:Qe,className:"h-64 overflow-y-auto",children:z?ie("div",{className:"p-2 space-y-4 animate-pulse",children:[ie("div",{className:"space-y-2",children:[R("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:R(ps,{className:"h-3 w-16"})}),ie("div",{className:"flex items-center gap-2 px-3 py-2",children:[R(ps,{className:"w-6 h-6 rounded-full"}),R(ps,{className:"h-4 w-28"})]}),ie("div",{className:"flex items-center gap-2 px-3 py-2",children:[R(ps,{className:"w-6 h-6 rounded-full"}),R(ps,{className:"h-4 w-20"})]})]}),ie("div",{className:"space-y-2",children:[R("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:R(ps,{className:"h-3 w-16"})}),ie("div",{className:"flex items-center gap-2 px-3 py-2",children:[R(ps,{className:"w-6 h-6 rounded-full"}),R(ps,{className:"h-4 w-32"})]}),ie("div",{className:"flex items-center gap-2 px-3 py-2",children:[R(ps,{className:"w-6 h-6 rounded-full"}),R(ps,{className:"h-4 w-24"})]})]})]}):ie(Zf,{children:[Ot.length>0&&ie(Zf,{children:[ie("button",{onClick:(de)=>{de.preventDefault(),de.stopPropagation(),ga(($e)=>({...$e,bots:!$e.bots}))},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors",children:[R("span",{children:"Agents"}),R($f,{className:`w-3 h-3 transition-transform ${vt.bots?"-rotate-90":""}`})]}),!vt.bots&&Ot.map((de,$e)=>{let Je=$e;return ie("button",{"data-index":Je,onClick:()=>zn(de),onMouseEnter:()=>mt(Je),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left ${Je===Ie?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[ie(Vc,{className:"w-6 h-6",children:[de.type==="user"&&de.data.image&&R(Yc,{src:de.data.image,alt:de.data.name,className:"object-cover"}),R(Jc,{className:"text-[10px] bg-purple-400 text-black font-semibold",children:wt(de.data.name)})]}),R("span",{className:"text-sm",children:de.data.name})]},de.data.id)})]}),Ze.length>0&&ie(Zf,{children:[ie("button",{onClick:(de)=>{de.preventDefault(),de.stopPropagation(),ga(($e)=>({...$e,users:!$e.users}))},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors",children:[R("span",{children:"Members"}),R($f,{className:`w-3 h-3 transition-transform ${vt.users?"-rotate-90":""}`})]}),!vt.users&&Ze.map((de,$e)=>{let Je=(vt.bots?0:Ot.length)+$e;return ie("button",{"data-index":Je,onClick:()=>zn(de),onMouseEnter:()=>mt(Je),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left ${Je===Ie?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[ie(Vc,{className:"w-6 h-6",children:[de.type==="user"&&de.data.image&&R(Yc,{src:de.data.image,alt:de.data.name,className:"object-cover"}),R(Jc,{className:"text-[10px] bg-blue-400 text-black font-semibold",children:wt(de.data.name)})]}),R("span",{className:"text-sm",children:de.data.name})]},de.data.id)})]})]})})}),Bt&&ie("div",{className:"flex flex-col gap-2 p-3 pb-0 animate-in fade-in slide-in-from-bottom-2 duration-200",children:[a&&ie("div",{className:"flex items-center justify-between bg-muted p-2 px-3 rounded-lg border border-border",children:[R("div",{className:"text-xs text-muted-foreground truncate mr-2",children:He.reply_to_message({message:a.message||""})}),R("button",{onClick:n,className:"text-muted-foreground hover:text-foreground p-1 rounded-full hover:bg-muted-foreground/10 shrink-0",children:R(Zu,{className:"w-3.5 h-3.5"})})]}),d.length>0&&R("div",{className:"flex gap-3 overflow-x-auto py-2 px-1 scrollbar-hide",children:d.map((de)=>ie("div",{className:"relative group flex-shrink-0",children:[ie("div",{className:"w-16 h-16 rounded-lg border border-gray-200 overflow-hidden bg-gray-50 flex items-center justify-center",children:[de.file.type.startsWith("image/")?R("img",{src:URL.createObjectURL(de.file),alt:"preview",onClick:()=>C(de.file),className:`w-full h-full object-cover ${!de.attachmentId?"opacity-50":""}`}):R(m7,{className:"w-8 h-8 text-gray-400"}),Da&&!de.attachmentId&&!de.error&&R("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:R(q7,{progress:de.progress,className:"w-10 h-10"})})]}),R("button",{onClick:()=>Sn(de.id),className:"absolute -top-1.5 -right-1.5 bg-gray-500 text-white rounded-full p-0.5 shadow-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500 z-10",children:R(Zu,{className:"w-3 h-3"})}),R("span",{className:"text-[10px] text-gray-500 mt-1 block max-w-[4rem] truncate text-center",children:de.file.name})]},de.id))})]}),ie("div",{onClick:()=>jt.current?.focus(),className:"w-full px-4 pt-1 pb-1 cursor-text flow-root max-h-60 overflow-y-auto",children:[y&&l!==void 0&&c!==void 0&&R("div",{onClick:(de)=>{de.stopPropagation(),jt.current?.focus()},className:"float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-0.5 mt-3 mr-2 rounded-sm text-xs font-mono font-bold flex items-center gap-1 cursor-text",children:M}),R("div",{ref:jt,contentEditable:!0,suppressContentEditableWarning:!0,onInput:yn,onKeyDown:Ya,"data-placeholder":a?He.reply_placeholder():He.message_placeholder(),className:`bg-transparent border-none focus:ring-0 resize-none min-h-[40px] leading-relaxed py-2 focus:outline-none block ${rn}`})]}),ie("div",{className:"flex justify-between items-center px-2 pb-2",children:[Q?ie("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide w-full mr-2",children:[R(Oi,{onClick:()=>{P(!1),re()},variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer text-gray-500 hover:text-gray-700 hover:bg-gray-100 mr-2",title:"Back",children:R(c7,{className:"w-4 h-4"})}),R("div",{className:"h-4 w-px bg-gray-300 mx-1"}),R("button",{onClick:()=>ee("arrow"),className:`p-1.5 rounded hover:bg-gray-100 ${te==="arrow"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Arrow",children:R(R3,{size:16,className:"rotate-45"})}),R("button",{onClick:()=>ee("line"),className:`p-1.5 rounded hover:bg-gray-100 ${te==="line"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Line",children:R(Wf,{size:16,className:"-rotate-45"})}),R("button",{onClick:()=>ee("box"),className:`p-1.5 rounded hover:bg-gray-100 ${te==="box"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Box",children:R(b7,{size:16})}),R("button",{onClick:()=>ee("freehand"),className:`p-1.5 rounded hover:bg-gray-100 ${te==="freehand"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Freehand",children:R(h7,{size:16})}),R("div",{className:"h-4 w-px bg-gray-300 mx-1"}),ie($u,{children:[R(Wu,{asChild:!0,children:ie("button",{className:"flex items-center gap-1 p-1 rounded hover:bg-gray-100",children:[R("div",{className:"w-4 h-4 rounded-full border border-gray-200",style:{backgroundColor:L}}),R($f,{size:12,className:"text-gray-500"})]})}),R(Pu,{className:"w-auto p-2",align:"center",side:"top",children:R("div",{className:"flex items-center gap-1",children:T_.map((de)=>R("button",{onClick:()=>J(de),className:`w-6 h-6 rounded-full border border-gray-200 transition-transform hover:scale-110 ${L===de?"ring-2 ring-blue-500 ring-offset-1":""}`,style:{backgroundColor:de}},de))})})]}),R("div",{className:"h-4 w-px bg-gray-300 mx-1"}),R("button",{onClick:pe,disabled:Ae<=0,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:R(w7,{size:16})}),R("button",{onClick:ne,disabled:Ae>=fe.length-1,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:R(p7,{size:16})})]}):ie("div",{className:"flex items-center gap-1",children:[R("input",{type:"file",ref:xe,className:"hidden",multiple:!0,onChange:Ja}),l!==void 0&&c!==void 0&&R(Oi,{onClick:()=>O(!y),variant:y?"secondary":"ghost",size:"icon",className:`p-2 rounded-full cursor-pointer ${y?"text-blue-600 bg-blue-50 dark:bg-blue-900/20":""}`,title:y?He.disable_timestamp():He.enable_timestamp(),children:R(u7,{className:"w-4 h-4"})}),R(Oi,{onClick:()=>xe.current?.click(),className:"p-2 rounded-full cursor-pointer",variant:"ghost",size:"icon",title:He.attach_files(),children:R(g7,{className:"w-4 h-4"})}),!i&&R(Oi,{onClick:()=>P(!0),variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer",title:He.toggle_annotation(),children:R(Qu,{className:"w-4 h-4"})})]}),R("button",{onClick:pa,disabled:!ls||Da,className:`p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 ${ls&&!Da?"bg-blue-600 text-white shadow-md hover:bg-blue-700 hover:shadow-lg transform hover:-translate-y-0.5":"bg-gray-400 cursor-not-allowed"}`,children:R(R3,{className:"w-4 h-4"})})]}),A&&ie("div",{className:"fixed inset-0 z-[100] bg-black/95 flex flex-col items-center justify-center p-4 animate-in fade-in duration-200",onClick:()=>C(null),children:[R("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white hover:bg-white/20 rounded-full p-2 transition-colors z-50",children:R(Zu,{className:"w-8 h-8"})}),R("div",{className:"w-full h-full flex items-center justify-center p-2",children:R("img",{src:URL.createObjectURL(A),alt:"Enlarged view",className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:(de)=>{de.stopPropagation(),C(null)}})}),R("div",{className:"absolute bottom-6 text-white text-sm font-medium bg-black/50 px-4 py-2 rounded-full backdrop-blur-sm",children:A.name})]})]})});N3.displayName="ChatInput";var Qc=Mt(en(),1);function k7({isOpen:e,onClose:t,onSuccess:a,children:n}){let[s,i]=Qc.useState(""),[f,l]=Qc.useState(""),[c,h]=Qc.useState(!1),[u,g]=Qc.useState(null);return ie($u,{open:e,onOpenChange:(d)=>!d&&t(),children:[R(Wu,{asChild:!0,children:n}),R(Pu,{className:"w-80",align:"end",side:"top",children:ie("form",{onSubmit:async(d)=>{d.preventDefault(),h(!0),g(null);try{let j=await Ht.api.identify.$post({json:{username:s,email:f}});if(!j.ok){let C=await j.json();throw Error(C.error||"Failed to identify")}let{id:A}=await j.json();localStorage.setItem("guest_user_id",A),a(A),t()}catch(j){g(j.message)}finally{h(!1)}},className:"space-y-4",children:[ie("div",{className:"space-y-2",children:[R("h4",{className:"font-medium leading-none",children:He.enter_your_details()}),R("p",{className:"text-sm text-muted-foreground",children:He.provide_name_email_for_comment()})]}),ie("div",{className:"grid gap-2",children:[ie("div",{className:"grid gap-1",children:[R(z3,{htmlFor:"name",children:He.name()}),R(E3,{id:"name",value:s,onChange:(d)=>i(d.target.value),placeholder:He.name_placeholder(),size:32,required:!0})]}),ie("div",{className:"grid gap-1",children:[R(z3,{htmlFor:"email",children:He.email()}),R(E3,{id:"email",type:"email",value:f,onChange:(d)=>l(d.target.value),placeholder:He.email_field_placeholder(),required:!0})]}),u&&R("p",{className:"text-xs text-destructive",children:u})]}),ie("div",{className:"flex justify-end gap-2",children:[R(Oi,{type:"button",variant:"outline",size:"sm",onClick:t,children:He.cancel()}),ie(Oi,{type:"submit",size:"sm",disabled:c,children:[c&&R(v7,{className:"mr-2 h-3 w-3 animate-spin"}),He.confirm()]})]})]})})]})}var pt=Mt(en(),1);var V=Mt(Wi(),1),ye=Mt(Q3(),1),B4=Mt(rb(),1),s4=Mt(kb(),1);function Fa(){return Fa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Fa.apply(null,arguments)}var R1=Mt(Wi(),1),Ab="https://example.com",GF=function(t,a){if(/^[a-z]+:/i.test(a))return a;if(/^data:/.test(t))t=R1.default.location&&R1.default.location.href||"";var n=/^\/\//.test(t),s=!R1.default.location&&!/\/\//i.test(t);t=new R1.default.URL(t,R1.default.location||Ab);var i=new URL(a,t);if(s)return i.href.slice(Ab.length);else if(n)return i.href.slice(i.protocol.length);return i.href},N1=GF;var n9=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(n,s){if(!this.listeners[n])this.listeners[n]=[];this.listeners[n].push(s)},t.off=function(n,s){if(!this.listeners[n])return!1;var i=this.listeners[n].indexOf(s);return this.listeners[n]=this.listeners[n].slice(0),this.listeners[n].splice(i,1),i>-1},t.trigger=function(n){var s=this.listeners[n];if(!s)return;if(arguments.length===2){var i=s.length;for(var f=0;f<i;++f)s[f].call(this,arguments[1])}else{var l=Array.prototype.slice.call(arguments,1),c=s.length;for(var h=0;h<c;++h)s[h].apply(this,l)}},t.dispose=function(){this.listeners={}},t.pipe=function(n){this.on("data",function(s){n.push(s)})},e}();var n6=Mt(Wi(),1),XF=function(t){return n6.default.atob?n6.default.atob(t):Buffer.from(t,"base64").toString("binary")};function ah(e){var t=XF(e),a=new Uint8Array(t.length);for(var n=0;n<t.length;n++)a[n]=t.charCodeAt(n);return a}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class Sb extends n9{constructor(){super();this.buffer=""}push(e){let t;this.buffer+=e,t=this.buffer.indexOf(`
34
+ `);for(;t>-1;t=this.buffer.indexOf(`
35
+ `))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}var KF=String.fromCharCode(9),s6=function(e){let t=/([0-9.]*)?@?([0-9.]*)?/.exec(e||""),a={};if(t[1])a.length=parseInt(t[1],10);if(t[2])a.offset=parseInt(t[2],10);return a},LF=function(){return new RegExp("(?:^|,)("+'(?:[^=]*)=(?:"[^"]*"|[^,]*)'+")")},Pn=function(e){let t={};if(!e)return t;let a=e.split(LF()),n=a.length,s;while(n--){if(a[n]==="")continue;s=/([^=]*)=(.*)/.exec(a[n]).slice(1),s[0]=s[0].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^['"](.*)['"]$/g,"$1"),t[s[0]]=s[1]}return t},yb=(e)=>{let t=e.split("x"),a={};if(t[0])a.width=parseInt(t[0],10);if(t[1])a.height=parseInt(t[1],10);return a};class Cb extends n9{constructor(){super();this.customParsers=[],this.tagMappers=[]}push(e){let t,a;if(e=e.trim(),e.length===0)return;if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((s,i)=>{let f=i(e);if(f===e)return s;return s.concat([f])},[e]).forEach((s)=>{for(let i=0;i<this.customParsers.length;i++)if(this.customParsers[i].call(this,s))return;if(s.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:s.slice(1)});return}if(s=s.replace("\r",""),t=/^#EXTM3U/.exec(s),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(s),t){if(a={type:"tag",tagType:"inf"},t[1])a.duration=parseFloat(t[1]);if(t[2])a.title=t[2];this.trigger("data",a);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(s),t){if(a={type:"tag",tagType:"targetduration"},t[1])a.duration=parseInt(t[1],10);this.trigger("data",a);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(s),t){if(a={type:"tag",tagType:"version"},t[1])a.version=parseInt(t[1],10);this.trigger("data",a);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){if(a={type:"tag",tagType:"media-sequence"},t[1])a.number=parseInt(t[1],10);this.trigger("data",a);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){if(a={type:"tag",tagType:"discontinuity-sequence"},t[1])a.number=parseInt(t[1],10);this.trigger("data",a);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(s),t){if(a={type:"tag",tagType:"playlist-type"},t[1])a.playlistType=t[1];this.trigger("data",a);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(s),t){a=Fa(s6(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",a);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(s),t){if(a={type:"tag",tagType:"allow-cache"},t[1])a.allowed=!/NO/.test(t[1]);this.trigger("data",a);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"map"},t[1]){let i=Pn(t[1]);if(i.URI)a.uri=i.URI;if(i.BYTERANGE)a.byterange=s6(i.BYTERANGE)}this.trigger("data",a);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"stream-inf"},t[1]){if(a.attributes=Pn(t[1]),a.attributes.RESOLUTION)a.attributes.RESOLUTION=yb(a.attributes.RESOLUTION);if(a.attributes.BANDWIDTH)a.attributes.BANDWIDTH=parseInt(a.attributes.BANDWIDTH,10);if(a.attributes["FRAME-RATE"])a.attributes["FRAME-RATE"]=parseFloat(a.attributes["FRAME-RATE"]);if(a.attributes["PROGRAM-ID"])a.attributes["PROGRAM-ID"]=parseInt(a.attributes["PROGRAM-ID"],10)}this.trigger("data",a);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"media"},t[1])a.attributes=Pn(t[1]);this.trigger("data",a);return}if(t=/^#EXT-X-ENDLIST/.exec(s),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"program-date-time"},t[1])a.dateTimeString=t[1],a.dateTimeObject=new Date(t[1]);this.trigger("data",a);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"key"},t[1]){if(a.attributes=Pn(t[1]),a.attributes.IV){if(a.attributes.IV.substring(0,2).toLowerCase()==="0x")a.attributes.IV=a.attributes.IV.substring(2);a.attributes.IV=a.attributes.IV.match(/.{8}/g),a.attributes.IV[0]=parseInt(a.attributes.IV[0],16),a.attributes.IV[1]=parseInt(a.attributes.IV[1],16),a.attributes.IV[2]=parseInt(a.attributes.IV[2],16),a.attributes.IV[3]=parseInt(a.attributes.IV[3],16),a.attributes.IV=new Uint32Array(a.attributes.IV)}}this.trigger("data",a);return}if(t=/^#EXT-X-START:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"start"},t[1])a.attributes=Pn(t[1]),a.attributes["TIME-OFFSET"]=parseFloat(a.attributes["TIME-OFFSET"]),a.attributes.PRECISE=/YES/.test(a.attributes.PRECISE);this.trigger("data",a);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(s),t){if(a={type:"tag",tagType:"cue-out-cont"},t[1])a.data=t[1];else a.data="";this.trigger("data",a);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(s),t){if(a={type:"tag",tagType:"cue-out"},t[1])a.data=t[1];else a.data="";this.trigger("data",a);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(s),t){if(a={type:"tag",tagType:"cue-in"},t[1])a.data=t[1];else a.data="";this.trigger("data",a);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(s),t&&t[1]){if(a={type:"tag",tagType:"skip"},a.attributes=Pn(t[1]),a.attributes.hasOwnProperty("SKIPPED-SEGMENTS"))a.attributes["SKIPPED-SEGMENTS"]=parseInt(a.attributes["SKIPPED-SEGMENTS"],10);if(a.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES"))a.attributes["RECENTLY-REMOVED-DATERANGES"]=a.attributes["RECENTLY-REMOVED-DATERANGES"].split(KF);this.trigger("data",a);return}if(t=/^#EXT-X-PART:(.*)$/.exec(s),t&&t[1]){if(a={type:"tag",tagType:"part"},a.attributes=Pn(t[1]),["DURATION"].forEach(function(i){if(a.attributes.hasOwnProperty(i))a.attributes[i]=parseFloat(a.attributes[i])}),["INDEPENDENT","GAP"].forEach(function(i){if(a.attributes.hasOwnProperty(i))a.attributes[i]=/YES/.test(a.attributes[i])}),a.attributes.hasOwnProperty("BYTERANGE"))a.attributes.byterange=s6(a.attributes.BYTERANGE);this.trigger("data",a);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(s),t&&t[1]){a={type:"tag",tagType:"server-control"},a.attributes=Pn(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(i){if(a.attributes.hasOwnProperty(i))a.attributes[i]=parseFloat(a.attributes[i])}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(i){if(a.attributes.hasOwnProperty(i))a.attributes[i]=/YES/.test(a.attributes[i])}),this.trigger("data",a);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(s),t&&t[1]){a={type:"tag",tagType:"part-inf"},a.attributes=Pn(t[1]),["PART-TARGET"].forEach(function(i){if(a.attributes.hasOwnProperty(i))a.attributes[i]=parseFloat(a.attributes[i])}),this.trigger("data",a);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(s),t&&t[1]){a={type:"tag",tagType:"preload-hint"},a.attributes=Pn(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(i){if(a.attributes.hasOwnProperty(i)){a.attributes[i]=parseInt(a.attributes[i],10);let f=i==="BYTERANGE-LENGTH"?"length":"offset";a.attributes.byterange=a.attributes.byterange||{},a.attributes.byterange[f]=a.attributes[i],delete a.attributes[i]}}),this.trigger("data",a);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(s),t&&t[1]){a={type:"tag",tagType:"rendition-report"},a.attributes=Pn(t[1]),["LAST-MSN","LAST-PART"].forEach(function(i){if(a.attributes.hasOwnProperty(i))a.attributes[i]=parseInt(a.attributes[i],10)}),this.trigger("data",a);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(s),t&&t[1]){a={type:"tag",tagType:"daterange"},a.attributes=Pn(t[1]),["ID","CLASS"].forEach(function(f){if(a.attributes.hasOwnProperty(f))a.attributes[f]=String(a.attributes[f])}),["START-DATE","END-DATE"].forEach(function(f){if(a.attributes.hasOwnProperty(f))a.attributes[f]=new Date(a.attributes[f])}),["DURATION","PLANNED-DURATION"].forEach(function(f){if(a.attributes.hasOwnProperty(f))a.attributes[f]=parseFloat(a.attributes[f])}),["END-ON-NEXT"].forEach(function(f){if(a.attributes.hasOwnProperty(f))a.attributes[f]=/YES/i.test(a.attributes[f])}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(f){if(a.attributes.hasOwnProperty(f))a.attributes[f]=a.attributes[f].toString(16)});let i=/^X-([A-Z]+-)+[A-Z]+$/;for(let f in a.attributes){if(!i.test(f))continue;let l=/[0-9A-Fa-f]{6}/g.test(a.attributes[f]),c=/^\d+(\.\d+)?$/.test(a.attributes[f]);a.attributes[f]=l?a.attributes[f].toString(16):c?parseFloat(a.attributes[f]):String(a.attributes[f])}this.trigger("data",a);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(s),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(s),t){a={type:"tag",tagType:"content-steering"},a.attributes=Pn(t[1]),this.trigger("data",a);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(s),t){if(a={type:"tag",tagType:"i-frame-playlist"},a.attributes=Pn(t[1]),a.attributes.URI)a.uri=a.attributes.URI;if(a.attributes.BANDWIDTH)a.attributes.BANDWIDTH=parseInt(a.attributes.BANDWIDTH,10);if(a.attributes.RESOLUTION)a.attributes.RESOLUTION=yb(a.attributes.RESOLUTION);if(a.attributes["AVERAGE-BANDWIDTH"])a.attributes["AVERAGE-BANDWIDTH"]=parseInt(a.attributes["AVERAGE-BANDWIDTH"],10);if(a.attributes["FRAME-RATE"])a.attributes["FRAME-RATE"]=parseFloat(a.attributes["FRAME-RATE"]);this.trigger("data",a);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(s),t){a={type:"tag",tagType:"define"},a.attributes=Pn(t[1]),this.trigger("data",a);return}this.trigger("data",{type:"tag",data:s.slice(4)})})}addParser({expression:e,customType:t,dataParser:a,segment:n}){if(typeof a!=="function")a=(s)=>s;this.customParsers.push((s)=>{if(e.exec(s))return this.trigger("data",{type:"custom",data:a(s),customType:t,segment:n}),!0})}addTagMapper({expression:e,map:t}){let a=(n)=>{if(e.test(n))return t(n);return n};this.tagMappers.push(a)}}var VF=(e)=>e.toLowerCase().replace(/-(\w)/g,(t)=>t[1].toUpperCase()),el=function(e){let t={};return Object.keys(e).forEach(function(a){t[VF(a)]=e[a]}),t},i6=function(e){let{serverControl:t,targetDuration:a,partTargetDuration:n}=e;if(!t)return;let s="#EXT-X-SERVER-CONTROL",i="holdBack",f="partHoldBack",l=a&&a*3,c=n&&n*2;if(a&&!t.hasOwnProperty(i))t[i]=l,this.trigger("info",{message:`${s} defaulting HOLD-BACK to targetDuration * 3 (${l}).`});if(l&&t[i]<l)this.trigger("warn",{message:`${s} clamping HOLD-BACK (${t[i]}) to targetDuration * 3 (${l})`}),t[i]=l;if(n&&!t.hasOwnProperty(f))t[f]=n*3,this.trigger("info",{message:`${s} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${t[f]}).`});if(n&&t[f]<c)this.trigger("warn",{message:`${s} clamping PART-HOLD-BACK (${t[f]}) to partTargetDuration * 2 (${c}).`}),t[f]=c};class f6 extends n9{constructor(e={}){super();this.lineStream=new Sb,this.parseStream=new Cb,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;let t=this,a=[],n={},s,i,f=!1,l=function(){},c={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},h="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",u=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let g=0,b=0,d={};this.on("end",()=>{if(n.uri||!n.parts&&!n.preloadHints)return;if(!n.map&&s)n.map=s;if(!n.key&&i)n.key=i;if(!n.timeline&&typeof u==="number")n.timeline=u;this.manifest.preloadSegment=n}),this.parseStream.on("data",function(j){let A,C;if(t.manifest.definitions)for(let y in t.manifest.definitions){if(j.uri)j.uri=j.uri.replace(`{$${y}}`,t.manifest.definitions[y]);if(j.attributes){for(let O in j.attributes)if(typeof j.attributes[O]==="string")j.attributes[O]=j.attributes[O].replace(`{$${y}}`,t.manifest.definitions[y])}}({tag(){({version(){if(j.version)this.manifest.version=j.version},"allow-cache"(){if(this.manifest.allowCache=j.allowed,!("allowed"in j))this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0},byterange(){let y={};if("length"in j){if(n.byterange=y,y.length=j.length,!("offset"in j))j.offset=g}if("offset"in j)n.byterange=y,y.offset=j.offset;g=y.offset+y.length},endlist(){this.manifest.endList=!0},inf(){if(!("mediaSequence"in this.manifest))this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"});if(!("discontinuitySequence"in this.manifest))this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"});if(j.title)n.title=j.title;if(j.duration>0)n.duration=j.duration;if(j.duration===0)n.duration=0.01,this.trigger("info",{message:"updating zero segment duration to a small value"});this.manifest.segments=a},key(){if(!j.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(j.attributes.METHOD==="NONE"){i=null;return}if(!j.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(j.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:j.attributes};return}if(j.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:j.attributes.URI};return}if(j.attributes.KEYFORMAT===h){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(j.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(j.attributes.METHOD==="SAMPLE-AES-CENC")this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"});if(j.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(j.attributes.KEYID&&j.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:j.attributes.KEYFORMAT,keyId:j.attributes.KEYID.substring(2)},pssh:ah(j.attributes.URI.split(",")[1])};return}if(!j.attributes.METHOD)this.trigger("warn",{message:"defaulting key method to AES-128"});if(i={method:j.attributes.METHOD||"AES-128",uri:j.attributes.URI},typeof j.attributes.IV<"u")i.iv=j.attributes.IV},"media-sequence"(){if(!isFinite(j.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+j.number});return}this.manifest.mediaSequence=j.number},"discontinuity-sequence"(){if(!isFinite(j.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+j.number});return}this.manifest.discontinuitySequence=j.number,u=j.number},"playlist-type"(){if(!/VOD|EVENT/.test(j.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+j.playlist});return}this.manifest.playlistType=j.playlistType},map(){if(s={},j.uri)s.uri=j.uri;if(j.byterange)s.byterange=j.byterange;if(i)s.key=i},"stream-inf"(){if(this.manifest.playlists=a,this.manifest.mediaGroups=this.manifest.mediaGroups||c,!j.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}if(!n.attributes)n.attributes={};Fa(n.attributes,j.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||c,!(j.attributes&&j.attributes.TYPE&&j.attributes["GROUP-ID"]&&j.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}let y=this.manifest.mediaGroups[j.attributes.TYPE];if(y[j.attributes["GROUP-ID"]]=y[j.attributes["GROUP-ID"]]||{},A=y[j.attributes["GROUP-ID"]],C={default:/yes/i.test(j.attributes.DEFAULT)},C.default)C.autoselect=!0;else C.autoselect=/yes/i.test(j.attributes.AUTOSELECT);if(j.attributes.LANGUAGE)C.language=j.attributes.LANGUAGE;if(j.attributes.URI)C.uri=j.attributes.URI;if(j.attributes["INSTREAM-ID"])C.instreamId=j.attributes["INSTREAM-ID"];if(j.attributes.CHARACTERISTICS)C.characteristics=j.attributes.CHARACTERISTICS;if(j.attributes.FORCED)C.forced=/yes/i.test(j.attributes.FORCED);A[j.attributes.NAME]=C},discontinuity(){u+=1,n.discontinuity=!0,this.manifest.discontinuityStarts.push(a.length)},"program-date-time"(){if(typeof this.manifest.dateTimeString>"u")this.manifest.dateTimeString=j.dateTimeString,this.manifest.dateTimeObject=j.dateTimeObject;n.dateTimeString=j.dateTimeString,n.dateTimeObject=j.dateTimeObject;let{lastProgramDateTime:y}=this;if(this.lastProgramDateTime=new Date(j.dateTimeString).getTime(),y===null)this.manifest.segments.reduceRight((O,T)=>{return T.programDateTime=O-T.duration*1000,T.programDateTime},this.lastProgramDateTime)},targetduration(){if(!isFinite(j.duration)||j.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+j.duration});return}this.manifest.targetDuration=j.duration,i6.call(this,this.manifest)},start(){if(!j.attributes||isNaN(j.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:j.attributes["TIME-OFFSET"],precise:j.attributes.PRECISE}},"cue-out"(){n.cueOut=j.data},"cue-out-cont"(){n.cueOutCont=j.data},"cue-in"(){n.cueIn=j.data},skip(){this.manifest.skip=el(j.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",j.attributes,["SKIPPED-SEGMENTS"])},part(){f=!0;let y=this.manifest.segments.length,O=el(j.attributes);if(n.parts=n.parts||[],n.parts.push(O),O.byterange){if(!O.byterange.hasOwnProperty("offset"))O.byterange.offset=b;b=O.byterange.offset+O.byterange.length}let T=n.parts.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PART #${T} for segment #${y}`,j.attributes,["URI","DURATION"]),this.manifest.renditionReports)this.manifest.renditionReports.forEach((M,H)=>{if(!M.hasOwnProperty("lastPart"))this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${H} lacks required attribute(s): LAST-PART`})})},"server-control"(){let y=this.manifest.serverControl=el(j.attributes);if(!y.hasOwnProperty("canBlockReload"))y.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"});if(i6.call(this,this.manifest),y.canSkipDateranges&&!y.hasOwnProperty("canSkipUntil"))this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){let y=this.manifest.segments.length,O=el(j.attributes),T=O.type&&O.type==="PART";if(n.preloadHints=n.preloadHints||[],n.preloadHints.push(O),O.byterange){if(!O.byterange.hasOwnProperty("offset")){if(O.byterange.offset=T?b:0,T)b=O.byterange.offset+O.byterange.length}}let M=n.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${M} for segment #${y}`,j.attributes,["TYPE","URI"]),!O.type)return;for(let H=0;H<n.preloadHints.length-1;H++){let N=n.preloadHints[H];if(!N.type)continue;if(N.type===O.type)this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${M} for segment #${y} has the same TYPE ${O.type} as preload hint #${H}`})}},"rendition-report"(){let y=el(j.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(y);let O=this.manifest.renditionReports.length-1,T=["LAST-MSN","URI"];if(f)T.push("LAST-PART");this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${O}`,j.attributes,T)},"part-inf"(){if(this.manifest.partInf=el(j.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",j.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget)this.manifest.partTargetDuration=this.manifest.partInf.partTarget;i6.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(el(j.attributes));let y=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${y}`,j.attributes,["ID","START-DATE"]);let O=this.manifest.dateRanges[y];if(O.endDate&&O.startDate&&new Date(O.endDate)<new Date(O.startDate))this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"});if(O.duration&&O.duration<0)this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"});if(O.plannedDuration&&O.plannedDuration<0)this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});let T=!!O.endOnNext;if(T&&!O.class)this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"});if(T&&(O.duration||O.endDate))this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"});if(O.duration&&O.endDate){let H=O.startDate.getTime()+O.duration*1000;this.manifest.dateRanges[y].endDate=new Date(H)}if(!d[O.id])d[O.id]=O;else{for(let H in d[O.id])if(!!O[H]&&JSON.stringify(d[O.id][H])!==JSON.stringify(O[H])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}let M=this.manifest.dateRanges.findIndex((H)=>H.id===O.id);this.manifest.dateRanges[M]=Fa(this.manifest.dateRanges[M],O),d[O.id]=Fa(d[O.id],O),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=el(j.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",j.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};let y=(O,T)=>{if(O in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${O}`});return}this.manifest.definitions[O]=T};if("QUERYPARAM"in j.attributes){if("NAME"in j.attributes||"IMPORT"in j.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}let O=this.params.get(j.attributes.QUERYPARAM);if(!O){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${j.attributes.QUERYPARAM}`});return}y(j.attributes.QUERYPARAM,decodeURIComponent(O));return}if("NAME"in j.attributes){if("IMPORT"in j.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in j.attributes)||typeof j.attributes.VALUE!=="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${j.attributes.NAME}`});return}y(j.attributes.NAME,j.attributes.VALUE);return}if("IMPORT"in j.attributes){if(!this.mainDefinitions[j.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${j.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}y(j.attributes.IMPORT,this.mainDefinitions[j.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:j.attributes,uri:j.uri,timeline:u}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",j.attributes,["BANDWIDTH","URI"])}}[j.tagType]||l).call(t)},uri(){if(n.uri=j.uri,a.push(n),this.manifest.targetDuration&&!("duration"in n))this.trigger("warn",{message:"defaulting segment duration to the target duration"}),n.duration=this.manifest.targetDuration;if(i)n.key=i;if(n.timeline=u,s)n.map=s;if(b=0,this.lastProgramDateTime!==null)n.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=n.duration*1000;n={}},comment(){},custom(){if(j.segment)n.custom=n.custom||{},n.custom[j.customType]=j.data;else this.manifest.custom=this.manifest.custom||{},this.manifest.custom[j.customType]=j.data}})[j.type].call(t)})}requiredCompatibilityversion(e,t){if(e<t||!e)this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,a){let n=[];if(a.forEach(function(s){if(!t.hasOwnProperty(s))n.push(s)}),n.length)this.trigger("warn",{message:`${e} lacks required attribute(s): ${n.join(", ")}`})}push(e){this.lineStream.push(e)}end(){if(this.lineStream.push(`
36
+ `),this.manifest.dateRanges.length&&this.lastProgramDateTime===null)this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"});this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var gr=Mt(Wi(),1),pr={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},YF=["video","audio","text"],_b=["Video","Audio","Text"],l6=function(t){if(!t)return t;return t.replace(/avc1\.(\d+)\.(\d+)/i,function(a,n,s){var i=("00"+Number(n).toString(16)).slice(-2),f=("00"+Number(s).toString(16)).slice(-2);return"avc1."+i+"00"+f})};var Ti=function(t){if(t===void 0)t="";var a=t.split(","),n=[];return a.forEach(function(s){s=s.trim();var i;if(YF.forEach(function(f){var l=pr[f].exec(s.toLowerCase());if(!l||l.length<=1)return;i=f;var c=s.substring(0,l[1].length),h=s.replace(c,"");n.push({type:c,details:h,mediaType:f})}),!i)n.push({type:s,details:"",mediaType:"unknown"})}),n},Fb=function(t,a){if(!t.mediaGroups.AUDIO||!a)return null;var n=t.mediaGroups.AUDIO[a];if(!n)return null;for(var s in n){var i=n[s];if(i.default&&i.playlists)return Ti(i.playlists[0].attributes.CODECS)}return null};var r6=function(t){if(t===void 0)t="";return pr.audio.test(t.trim().toLowerCase())},JF=function(t){if(t===void 0)t="";return pr.text.test(t.trim().toLowerCase())},br=function(t){if(!t||typeof t!=="string")return;var a=t.toLowerCase().split(",").map(function(i){return l6(i.trim())}),n="video";if(a.length===1&&r6(a[0]))n="audio";else if(a.length===1&&JF(a[0]))n="application";var s="mp4";if(a.every(function(i){return pr.mp4.test(i)}))s="mp4";else if(a.every(function(i){return pr.webm.test(i)}))s="webm";else if(a.every(function(i){return pr.ogg.test(i)}))s="ogg";return n+"/"+s+';codecs="'+t+'"'},E1=function(t,a){if(t===void 0)t="";if(a===void 0)a=!1;return gr.default.MediaSource&&gr.default.MediaSource.isTypeSupported&&gr.default.MediaSource.isTypeSupported(br(t))||a&&gr.default.ManagedMediaSource&&gr.default.ManagedMediaSource.isTypeSupported&&gr.default.ManagedMediaSource.isTypeSupported(br(t))||!1},s9=function(t){if(t===void 0)t="";return t.toLowerCase().split(",").every(function(a){a=a.trim();for(var n=0;n<_b.length;n++){var s=_b[n];if(pr["muxer"+s].test(a))return!0}return!1})},o6="mp4a.40.2",Ob="avc1.4d400d";var QF=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,ZF=/^application\/dash\+xml/i,c6=function(t){if(QF.test(t))return"hls";if(ZF.test(t))return"dash";if(t==="application/vnd.videojs.vhs+json")return"vhs-json";return null};var Bb=Mt(Wi(),1);var $F=function(t){return t.toString(2).length},WF=function(t){return Math.ceil($F(t)/8)};var u6=function(t){if(ArrayBuffer.isView==="function")return ArrayBuffer.isView(t);return t&&t.buffer instanceof ArrayBuffer},PF=function(t){return u6(t)},Ke=function(t){if(t instanceof Uint8Array)return t;if(!Array.isArray(t)&&!PF(t)&&!(t instanceof ArrayBuffer))if(typeof t!=="number"||typeof t==="number"&&t!==t)t=0;else t=[t];return new Uint8Array(t&&t.buffer||t,t&&t.byteOffset||0,t&&t.byteLength||0)};var Mn=Bb.default.BigInt||Number,h6=[Mn("0x1"),Mn("0x100"),Mn("0x10000"),Mn("0x1000000"),Mn("0x100000000"),Mn("0x10000000000"),Mn("0x1000000000000"),Mn("0x100000000000000"),Mn("0x10000000000000000")],XU=function(){var e=new Uint16Array([65484]),t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(t[0]===255)return"big";if(t[0]===204)return"little";return"unknown"}();var m6=function(t,a){var n=a===void 0?{}:a,s=n.signed,i=s===void 0?!1:s,f=n.le,l=f===void 0?!1:f;t=Ke(t);var c=l?"reduce":"reduceRight",h=t[c]?t[c]:Array.prototype[c],u=h.call(t,function(b,d,j){var A=l?j:Math.abs(j+1-t.length);return b+Mn(d)*h6[A]},Mn(0));if(i){var g=h6[t.length]/Mn(2)-Mn(1);if(u=Mn(u),u>g)u-=g,u-=g,u-=Mn(2)}return Number(u)},Tb=function(t,a){var n=a===void 0?{}:a,s=n.le,i=s===void 0?!1:s;if(typeof t!=="bigint"&&typeof t!=="number"||typeof t==="number"&&t!==t)t=0;t=Mn(t);var f=WF(t),l=new Uint8Array(new ArrayBuffer(f));for(var c=0;c<f;c++){var h=i?c:Math.abs(c+1-l.length);if(l[h]=Number(t/h6[c]&Mn(255)),t<0)l[h]=Math.abs(~l[h]),l[h]-=c===0?1:2}return l},g6=function(t){if(!t)return"";t=Array.prototype.slice.call(t);var a=String.fromCharCode.apply(null,Ke(t));try{return decodeURIComponent(escape(a))}catch(n){}return a},i9=function(t,a){if(typeof t!=="string"&&t&&typeof t.toString==="function")t=t.toString();if(typeof t!=="string")return new Uint8Array;if(!a)t=unescape(encodeURIComponent(t));var n=new Uint8Array(t.length);for(var s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n},Hb=function(){for(var t=arguments.length,a=Array(t),n=0;n<t;n++)a[n]=arguments[n];if(a=a.filter(function(l){return l&&(l.byteLength||l.length)&&typeof l!=="string"}),a.length<=1)return Ke(a[0]);var s=a.reduce(function(l,c,h){return l+(c.byteLength||c.length)},0),i=new Uint8Array(s),f=0;return a.forEach(function(l){l=Ke(l),i.set(l,f),f+=l.byteLength}),i},Zt=function(t,a,n){var s=n===void 0?{}:n,i=s.offset,f=i===void 0?0:i,l=s.mask,c=l===void 0?[]:l;t=Ke(t),a=Ke(a);var h=a.every?a.every:Array.prototype.every;return a.length&&t.length-f>=a.length&&h.call(a,function(u,g){var b=c[g]?c[g]&t[f+g]:t[f+g];return u===b})};var es=Mt(Wi(),1);var Mb=function(t,a,n){a.forEach(function(s){for(var i in t.mediaGroups[s])for(var f in t.mediaGroups[s][i]){var l=t.mediaGroups[s][i][f];n(l,s,i,f)}})};var Sw=_6();var{DOMImplementation:eB,XMLSerializer:tB}=Sw,B6=yw().DOMParser;/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */var Cw=(e)=>{return!!e&&typeof e==="object"},dn=(...e)=>{return e.reduce((t,a)=>{if(typeof a!=="object")return t;return Object.keys(a).forEach((n)=>{if(Array.isArray(t[n])&&Array.isArray(a[n]))t[n]=t[n].concat(a[n]);else if(Cw(t[n])&&Cw(a[n]))t[n]=dn(t[n],a[n]);else t[n]=a[n]}),t},{})},Mw=(e)=>Object.keys(e).map((t)=>e[t]),aB=(e,t)=>{let a=[];for(let n=e;n<t;n++)a.push(n);return a},J1=(e)=>e.reduce((t,a)=>t.concat(a),[]),Dw=(e)=>{if(!e.length)return[];let t=[];for(let a=0;a<e.length;a++)t.push(e[a]);return t},nB=(e,t)=>e.reduce((a,n,s)=>{if(n[t])a.push(s);return a},[]),sB=(e,t)=>{return Mw(e.reduce((a,n)=>{return n.forEach((s)=>{a[t(s)]=s}),a},{}))},Q1={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"},gh=({baseUrl:e="",source:t="",range:a="",indexRange:n=""})=>{let s={uri:t,resolvedUri:N1(e||"",t)};if(a||n){let f=(a?a:n).split("-"),l=es.default.BigInt?es.default.BigInt(f[0]):parseInt(f[0],10),c=es.default.BigInt?es.default.BigInt(f[1]):parseInt(f[1],10);if(l<Number.MAX_SAFE_INTEGER&&typeof l==="bigint")l=Number(l);if(c<Number.MAX_SAFE_INTEGER&&typeof c==="bigint")c=Number(c);let h;if(typeof c==="bigint"||typeof l==="bigint")h=es.default.BigInt(c)-es.default.BigInt(l)+es.default.BigInt(1);else h=c-l+1;if(typeof h==="bigint"&&h<Number.MAX_SAFE_INTEGER)h=Number(h);s.byterange={length:h,offset:l}}return s},iB=(e)=>{let t;if(typeof e.offset==="bigint"||typeof e.length==="bigint")t=es.default.BigInt(e.offset)+es.default.BigInt(e.length)-es.default.BigInt(1);else t=e.offset+e.length-1;return`${e.offset}-${t}`},_w=(e)=>{if(e&&typeof e!=="number")e=parseInt(e,10);if(isNaN(e))return null;return e},fB={static(e){let{duration:t,timescale:a=1,sourceDuration:n,periodDuration:s}=e,i=_w(e.endNumber),f=t/a;if(typeof i==="number")return{start:0,end:i};if(typeof s==="number")return{start:0,end:s/f};return{start:0,end:n/f}},dynamic(e){let{NOW:t,clientOffset:a,availabilityStartTime:n,timescale:s=1,duration:i,periodStart:f=0,minimumUpdatePeriod:l=0,timeShiftBufferDepth:c=1/0}=e,h=_w(e.endNumber),u=(t+a)/1000,g=n+f,d=u+l-g,j=Math.ceil(d*s/i),A=Math.floor((u-g-c)*s/i),C=Math.floor((u-g)*s/i);return{start:Math.max(0,A),end:typeof h==="number"?h:Math.min(j,C)}}},lB=(e)=>(t)=>{let{duration:a,timescale:n=1,periodStart:s,startNumber:i=1}=e;return{number:i+t,duration:a/n,timeline:s,time:t*a}},H6=(e)=>{let{type:t,duration:a,timescale:n=1,periodDuration:s,sourceDuration:i}=e,{start:f,end:l}=fB[t](e),c=aB(f,l).map(lB(e));if(t==="static"){let h=c.length-1,u=typeof s==="number"?s:i;c[h].duration=u-a/n*h}return c},xw=(e)=>{let{baseUrl:t,initialization:a={},sourceDuration:n,indexRange:s="",periodStart:i,presentationTime:f,number:l=0,duration:c}=e;if(!t)throw Error(Q1.NO_BASE_URL);let h=gh({baseUrl:t,source:a.sourceURL,range:a.range}),u=gh({baseUrl:t,source:t,indexRange:s});if(u.map=h,c){let g=H6(e);if(g.length)u.duration=g[0].duration,u.timeline=g[0].timeline}else if(n)u.duration=n,u.timeline=i;return u.presentationTime=f||i,u.number=l,[u]},b9=(e,t,a)=>{let n=e.sidx.map?e.sidx.map:null,s=e.sidx.duration,i=e.timeline||0,f=e.sidx.byterange,l=f.offset+f.length,c=t.timescale,h=t.references.filter((C)=>C.referenceType!==1),u=[],g=e.endList?"static":"dynamic",b=e.sidx.timeline,d=b,j=e.mediaSequence||0,A;if(typeof t.firstOffset==="bigint")A=es.default.BigInt(l)+t.firstOffset;else A=l+t.firstOffset;for(let C=0;C<h.length;C++){let y=t.references[C],O=y.referencedSize,T=y.subsegmentDuration,M;if(typeof A==="bigint")M=A+es.default.BigInt(O)-es.default.BigInt(1);else M=A+O-1;let H=`${A}-${M}`,x=xw({baseUrl:a,timescale:c,timeline:i,periodStart:b,presentationTime:d,number:j,duration:T,sourceDuration:s,indexRange:H,type:g})[0];if(n)x.map=n;if(u.push(x),typeof A==="bigint")A+=es.default.BigInt(O);else A+=O;d+=T/c,j++}return e.segments=u,e},rB=["AUDIO","SUBTITLES"],oB=0.016666666666666666,Rw=(e)=>{return sB(e,({timeline:t})=>t).sort((t,a)=>t.timeline>a.timeline?1:-1)},cB=(e,t)=>{for(let a=0;a<e.length;a++)if(e[a].attributes.NAME===t)return e[a];return null},Fw=(e)=>{let t=[];return Mb(e,rB,(a,n,s,i)=>{t=t.concat(a.playlists||[])}),t},Ow=({playlist:e,mediaSequence:t})=>{e.mediaSequence=t,e.segments.forEach((a,n)=>{a.number=e.mediaSequence+n})},hB=({oldPlaylists:e,newPlaylists:t,timelineStarts:a})=>{t.forEach((n)=>{n.discontinuitySequence=a.findIndex(function({timeline:c}){return c===n.timeline});let s=cB(e,n.attributes.NAME);if(!s)return;if(n.sidx)return;let i=n.segments[0],f=s.segments.findIndex(function(c){return Math.abs(c.presentationTime-i.presentationTime)<oB});if(f===-1){if(Ow({playlist:n,mediaSequence:s.mediaSequence+s.segments.length}),n.segments[0].discontinuity=!0,n.discontinuityStarts.unshift(0),!s.segments.length&&n.timeline>s.timeline||s.segments.length&&n.timeline>s.segments[s.segments.length-1].timeline)n.discontinuitySequence--;return}if(s.segments[f].discontinuity&&!i.discontinuity)i.discontinuity=!0,n.discontinuityStarts.unshift(0),n.discontinuitySequence--;Ow({playlist:n,mediaSequence:s.segments[f].number})})},uB=({oldManifest:e,newManifest:t})=>{let a=e.playlists.concat(Fw(e)),n=t.playlists.concat(Fw(t));return t.timelineStarts=Rw([e.timelineStarts,t.timelineStarts]),hB({oldPlaylists:a,newPlaylists:n,timelineStarts:t.timelineStarts}),t},ph=(e)=>e&&e.uri+"-"+iB(e.byterange),T6=(e)=>{let t=e.reduce(function(n,s){if(!n[s.attributes.baseUrl])n[s.attributes.baseUrl]=[];return n[s.attributes.baseUrl].push(s),n},{}),a=[];return Object.values(t).forEach((n)=>{let s=Mw(n.reduce((i,f)=>{let l=f.attributes.id+(f.attributes.lang||"");if(!i[l])i[l]=f,i[l].attributes.timelineStarts=[];else{if(f.segments){if(f.segments[0])f.segments[0].discontinuity=!0;i[l].segments.push(...f.segments)}if(f.attributes.contentProtection)i[l].attributes.contentProtection=f.attributes.contentProtection}return i[l].attributes.timelineStarts.push({start:f.attributes.periodStart,timeline:f.attributes.periodStart}),i},{}));a=a.concat(s)}),a.map((n)=>{return n.discontinuityStarts=nB(n.segments||[],"discontinuity"),n})},M6=(e,t)=>{let a=ph(e.sidx),n=a&&t[a]&&t[a].sidx;if(n)b9(e,n,e.sidx.resolvedUri);return e},mB=(e,t={})=>{if(!Object.keys(t).length)return e;for(let a in e)e[a]=M6(e[a],t);return e},gB=({attributes:e,segments:t,sidx:a,mediaSequence:n,discontinuitySequence:s,discontinuityStarts:i},f)=>{let l={attributes:{NAME:e.id,BANDWIDTH:e.bandwidth,CODECS:e.codecs,["PROGRAM-ID"]:1},uri:"",endList:e.type==="static",timeline:e.periodStart,resolvedUri:e.baseUrl||"",targetDuration:e.duration,discontinuitySequence:s,discontinuityStarts:i,timelineStarts:e.timelineStarts,mediaSequence:n,segments:t};if(e.contentProtection)l.contentProtection=e.contentProtection;if(e.serviceLocation)l.attributes.serviceLocation=e.serviceLocation;if(a)l.sidx=a;if(f)l.attributes.AUDIO="audio",l.attributes.SUBTITLES="subs";return l},pB=({attributes:e,segments:t,mediaSequence:a,discontinuityStarts:n,discontinuitySequence:s})=>{if(typeof t>"u")t=[{uri:e.baseUrl,timeline:e.periodStart,resolvedUri:e.baseUrl||"",duration:e.sourceDuration,number:0}],e.duration=e.sourceDuration;let i={NAME:e.id,BANDWIDTH:e.bandwidth,["PROGRAM-ID"]:1};if(e.codecs)i.CODECS=e.codecs;let f={attributes:i,uri:"",endList:e.type==="static",timeline:e.periodStart,resolvedUri:e.baseUrl||"",targetDuration:e.duration,timelineStarts:e.timelineStarts,discontinuityStarts:n,discontinuitySequence:s,mediaSequence:a,segments:t};if(e.serviceLocation)f.attributes.serviceLocation=e.serviceLocation;return f},bB=(e,t={},a=!1)=>{let n,s=e.reduce((i,f)=>{let l=f.attributes.role&&f.attributes.role.value||"",c=f.attributes.lang||"",h=f.attributes.label||"main";if(c&&!f.attributes.label){let g=l?` (${l})`:"";h=`${f.attributes.lang}${g}`}if(!i[h])i[h]={language:c,autoselect:!0,default:l==="main",playlists:[],uri:""};let u=M6(gB(f,a),t);if(i[h].playlists.push(u),typeof n>"u"&&l==="main")n=f,n.default=!0;return i},{});if(!n){let i=Object.keys(s)[0];s[i].default=!0}return s},wB=(e,t={})=>{return e.reduce((a,n)=>{let s=n.attributes.label||n.attributes.lang||"text",i=n.attributes.lang||"und";if(!a[s])a[s]={language:i,default:!1,autoselect:!1,playlists:[],uri:""};return a[s].playlists.push(M6(pB(n),t)),a},{})},dB=(e)=>e.reduce((t,a)=>{if(!a)return t;return a.forEach((n)=>{let{channel:s,language:i}=n;if(t[i]={autoselect:!1,default:!1,instreamId:s,language:i},n.hasOwnProperty("aspectRatio"))t[i].aspectRatio=n.aspectRatio;if(n.hasOwnProperty("easyReader"))t[i].easyReader=n.easyReader;if(n.hasOwnProperty("3D"))t[i]["3D"]=n["3D"]}),t},{}),jB=({attributes:e,segments:t,sidx:a,discontinuityStarts:n})=>{let s={attributes:{NAME:e.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:e.width,height:e.height},CODECS:e.codecs,BANDWIDTH:e.bandwidth,["PROGRAM-ID"]:1},uri:"",endList:e.type==="static",timeline:e.periodStart,resolvedUri:e.baseUrl||"",targetDuration:e.duration,discontinuityStarts:n,timelineStarts:e.timelineStarts,segments:t};if(e.frameRate)s.attributes["FRAME-RATE"]=e.frameRate;if(e.contentProtection)s.contentProtection=e.contentProtection;if(e.serviceLocation)s.attributes.serviceLocation=e.serviceLocation;if(a)s.sidx=a;return s},qB=({attributes:e})=>e.mimeType==="video/mp4"||e.mimeType==="video/webm"||e.contentType==="video",vB=({attributes:e})=>e.mimeType==="audio/mp4"||e.mimeType==="audio/webm"||e.contentType==="audio",kB=({attributes:e})=>e.mimeType==="text/vtt"||e.contentType==="text",AB=(e,t)=>{e.forEach((a)=>{if(a.mediaSequence=0,a.discontinuitySequence=t.findIndex(function({timeline:n}){return n===a.timeline}),!a.segments)return;a.segments.forEach((n,s)=>{n.number=s})})},Bw=(e)=>{if(!e)return[];return Object.keys(e).reduce((t,a)=>{let n=e[a];return t.concat(n.playlists)},[])},yB=({dashPlaylists:e,locations:t,contentSteering:a,sidxMapping:n={},previousManifest:s,eventStream:i})=>{if(!e.length)return{};let{sourceDuration:f,type:l,suggestedPresentationDelay:c,minimumUpdatePeriod:h}=e[0].attributes,u=T6(e.filter(qB)).map(jB),g=T6(e.filter(vB)),b=T6(e.filter(kB)),d=e.map((M)=>M.attributes.captionServices).filter(Boolean),j={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},["CLOSED-CAPTIONS"]:{},SUBTITLES:{}},uri:"",duration:f,playlists:mB(u,n)};if(h>=0)j.minimumUpdatePeriod=h*1000;if(t)j.locations=t;if(a)j.contentSteering=a;if(l==="dynamic")j.suggestedPresentationDelay=c;if(i&&i.length>0)j.eventStream=i;let A=j.playlists.length===0,C=g.length?bB(g,n,A):null,y=b.length?wB(b,n):null,O=u.concat(Bw(C),Bw(y)),T=O.map(({timelineStarts:M})=>M);if(j.timelineStarts=Rw(T),AB(O,j.timelineStarts),C)j.mediaGroups.AUDIO.audio=C;if(y)j.mediaGroups.SUBTITLES.subs=y;if(d.length)j.mediaGroups["CLOSED-CAPTIONS"].cc=dB(d);if(s)return uB({oldManifest:s,newManifest:j});return j},SB=(e,t,a)=>{let{NOW:n,clientOffset:s,availabilityStartTime:i,timescale:f=1,periodStart:l=0,minimumUpdatePeriod:c=0}=e,h=(n+s)/1000,u=i+l,b=h+c-u;return Math.ceil((b*f-t)/a)},Nw=(e,t)=>{let{type:a,minimumUpdatePeriod:n=0,media:s="",sourceDuration:i,timescale:f=1,startNumber:l=1,periodStart:c}=e,h=[],u=-1;for(let g=0;g<t.length;g++){let b=t[g],d=b.d,j=b.r||0,A=b.t||0;if(u<0)u=A;if(A&&A>u)u=A;let C;if(j<0){let T=g+1;if(T===t.length)if(a==="dynamic"&&n>0&&s.indexOf("$Number$")>0)C=SB(e,u,d);else C=(i*f-u)/d;else C=(t[T].t-u)/d}else C=j+1;let y=l+h.length+C,O=l+h.length;while(O<y)h.push({number:O,duration:d/f,time:u,timeline:c}),u+=d,O++}return h},CB=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,_B=(e)=>(t,a,n,s)=>{if(t==="$$")return"$";if(typeof e[a]>"u")return t;let i=""+e[a];if(a==="RepresentationID")return i;if(!n)s=1;else s=parseInt(s,10);if(i.length>=s)return i;return`${Array(s-i.length+1).join("0")}${i}`},Tw=(e,t)=>e.replace(CB,_B(t)),FB=(e,t)=>{if(!e.duration&&!t)return[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodStart}];if(e.duration)return H6(e);return Nw(e,t)},OB=(e,t)=>{let a={RepresentationID:e.id,Bandwidth:e.bandwidth||0},{initialization:n={sourceURL:"",range:""}}=e,s=gh({baseUrl:e.baseUrl,source:Tw(n.sourceURL,a),range:n.range});return FB(e,t).map((f)=>{a.Number=f.number,a.Time=f.time;let l=Tw(e.media||"",a),c=e.timescale||1,h=e.presentationTimeOffset||0,u=e.periodStart+(f.time-h)/c;return{uri:l,timeline:f.timeline,duration:f.duration,resolvedUri:N1(e.baseUrl||"",l),map:s,number:f.number,presentationTime:u}})},BB=(e,t)=>{let{baseUrl:a,initialization:n={}}=e,s=gh({baseUrl:a,source:n.sourceURL,range:n.range}),i=gh({baseUrl:a,source:t.media,range:t.mediaRange});return i.map=s,i},TB=(e,t)=>{let{duration:a,segmentUrls:n=[],periodStart:s}=e;if(!a&&!t||a&&t)throw Error(Q1.SEGMENT_TIME_UNSPECIFIED);let i=n.map((c)=>BB(e,c)),f;if(a)f=H6(e);if(t)f=Nw(e,t);return f.map((c,h)=>{if(i[h]){let u=i[h],g=e.timescale||1,b=e.presentationTimeOffset||0;return u.timeline=c.timeline,u.duration=c.duration,u.number=c.number,u.presentationTime=s+(c.time-b)/g,u}}).filter((c)=>c)},HB=({attributes:e,segmentInfo:t})=>{let a,n;if(t.template)n=OB,a=dn(e,t.template);else if(t.base)n=xw,a=dn(e,t.base);else if(t.list)n=TB,a=dn(e,t.list);let s={attributes:e};if(!n)return s;let i=n(a,t.segmentTimeline);if(a.duration){let{duration:f,timescale:l=1}=a;a.duration=f/l}else if(i.length)a.duration=i.reduce((f,l)=>{return Math.max(f,Math.ceil(l.duration))},0);else a.duration=0;if(s.attributes=a,s.segments=i,t.base&&a.indexRange)s.sidx=i[0],s.segments=[];return s},MB=(e)=>e.map(HB),qa=(e,t)=>Dw(e.childNodes).filter(({tagName:a})=>a===t),bh=(e)=>e.textContent.trim(),DB=(e)=>{return parseFloat(e.split("/").reduce((t,a)=>t/a))},Y1=(e)=>{let l=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(e);if(!l)return 0;let[c,h,u,g,b,d]=l.slice(1);return parseFloat(c||0)*31536000+parseFloat(h||0)*2592000+parseFloat(u||0)*86400+parseFloat(g||0)*3600+parseFloat(b||0)*60+parseFloat(d||0)},xB=(e)=>{if(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(e))e+="Z";return Date.parse(e)},Hw={mediaPresentationDuration(e){return Y1(e)},availabilityStartTime(e){return xB(e)/1000},minimumUpdatePeriod(e){return Y1(e)},suggestedPresentationDelay(e){return Y1(e)},type(e){return e},timeShiftBufferDepth(e){return Y1(e)},start(e){return Y1(e)},width(e){return parseInt(e,10)},height(e){return parseInt(e,10)},bandwidth(e){return parseInt(e,10)},frameRate(e){return DB(e)},startNumber(e){return parseInt(e,10)},timescale(e){return parseInt(e,10)},presentationTimeOffset(e){return parseInt(e,10)},duration(e){let t=parseInt(e,10);if(isNaN(t))return Y1(e);return t},d(e){return parseInt(e,10)},t(e){return parseInt(e,10)},r(e){return parseInt(e,10)},presentationTime(e){return parseInt(e,10)},DEFAULT(e){return e}},tn=(e)=>{if(!(e&&e.attributes))return{};return Dw(e.attributes).reduce((t,a)=>{let n=Hw[a.name]||Hw.DEFAULT;return t[a.name]=n(a.value),t},{})},RB={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},w9=(e,t)=>{if(!t.length)return e;return J1(e.map(function(a){return t.map(function(n){let s=bh(n),i=N1(a.baseUrl,s),f=dn(tn(n),{baseUrl:i});if(i!==s&&!f.serviceLocation&&a.serviceLocation)f.serviceLocation=a.serviceLocation;return f})}))},D6=(e)=>{let t=qa(e,"SegmentTemplate")[0],a=qa(e,"SegmentList")[0],n=a&&qa(a,"SegmentURL").map((g)=>dn({tag:"SegmentURL"},tn(g))),s=qa(e,"SegmentBase")[0],i=a||t,f=i&&qa(i,"SegmentTimeline")[0],l=a||s||t,c=l&&qa(l,"Initialization")[0],h=t&&tn(t);if(h&&c)h.initialization=c&&tn(c);else if(h&&h.initialization)h.initialization={sourceURL:h.initialization};let u={template:h,segmentTimeline:f&&qa(f,"S").map((g)=>tn(g)),list:a&&dn(tn(a),{segmentUrls:n,initialization:tn(c)}),base:s&&dn(tn(s),{initialization:tn(c)})};return Object.keys(u).forEach((g)=>{if(!u[g])delete u[g]}),u},NB=(e,t,a)=>(n)=>{let s=qa(n,"BaseURL"),i=w9(t,s),f=dn(e,tn(n)),l=D6(n);return i.map((c)=>{return{segmentInfo:dn(a,l),attributes:dn(f,c)}})},EB=(e)=>{return e.reduce((t,a)=>{let n=tn(a);if(n.schemeIdUri)n.schemeIdUri=n.schemeIdUri.toLowerCase();let s=RB[n.schemeIdUri];if(s){t[s]={attributes:n};let i=qa(a,"cenc:pssh")[0];if(i){let f=bh(i);t[s].pssh=f&&ah(f)}}return t},{})},zB=(e)=>{if(e.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof e.value!=="string"?[]:e.value.split(";")).map((a)=>{let n,s;if(s=a,/^CC\d=/.test(a))[n,s]=a.split("=");else if(/^CC\d$/.test(a))n=a;return{channel:n,language:s}});else if(e.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof e.value!=="string"?[]:e.value.split(";")).map((a)=>{let n={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(a)){let[s,i=""]=a.split("=");n.channel=s,n.language=a,i.split(",").forEach((f)=>{let[l,c]=f.split(":");if(l==="lang")n.language=c;else if(l==="er")n.easyReader=Number(c);else if(l==="war")n.aspectRatio=Number(c);else if(l==="3D")n["3D"]=Number(c)})}else n.language=a;if(n.channel)n.channel="SERVICE"+n.channel;return n})},UB=(e)=>{return J1(qa(e.node,"EventStream").map((t)=>{let a=tn(t),n=a.schemeIdUri;return qa(t,"Event").map((s)=>{let i=tn(s),f=i.presentationTime||0,l=a.timescale||1,c=i.duration||0,h=f/l+e.attributes.start;return{schemeIdUri:n,value:a.value,id:i.id,start:h,end:h+c/l,messageData:bh(s)||i.messageData,contentEncoding:a.contentEncoding,presentationTimeOffset:a.presentationTimeOffset||0}})}))},IB=(e,t,a)=>(n)=>{let s=tn(n),i=w9(t,qa(n,"BaseURL")),f=qa(n,"Role")[0],l={role:tn(f)},c=dn(e,s,l),h=qa(n,"Accessibility")[0],u=zB(tn(h));if(u)c=dn(c,{captionServices:u});let g=qa(n,"Label")[0];if(g&&g.childNodes.length){let C=g.childNodes[0].nodeValue.trim();c=dn(c,{label:C})}let b=EB(qa(n,"ContentProtection"));if(Object.keys(b).length)c=dn(c,{contentProtection:b});let d=D6(n),j=qa(n,"Representation"),A=dn(a,d);return J1(j.map(NB(c,i,A)))},GB=(e,t)=>(a,n)=>{let s=w9(t,qa(a.node,"BaseURL")),i=dn(e,{periodStart:a.attributes.start});if(typeof a.attributes.duration==="number")i.periodDuration=a.attributes.duration;let f=qa(a.node,"AdaptationSet"),l=D6(a.node);return J1(f.map(IB(i,s,l)))},XB=(e,t)=>{if(e.length>1)t({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"});if(!e.length)return null;let a=dn({serverURL:bh(e[0])},tn(e[0]));return a.queryBeforeStart=a.queryBeforeStart==="true",a},KB=({attributes:e,priorPeriodAttributes:t,mpdType:a})=>{if(typeof e.start==="number")return e.start;if(t&&typeof t.start==="number"&&typeof t.duration==="number")return t.start+t.duration;if(!t&&a==="static")return 0;return null},LB=(e,t={})=>{let{manifestUri:a="",NOW:n=Date.now(),clientOffset:s=0,eventHandler:i=function(){}}=t,f=qa(e,"Period");if(!f.length)throw Error(Q1.INVALID_NUMBER_OF_PERIOD);let l=qa(e,"Location"),c=tn(e),h=w9([{baseUrl:a}],qa(e,"BaseURL")),u=qa(e,"ContentSteering");if(c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=n,c.clientOffset=s,l.length)c.locations=l.map(bh);let g=[];return f.forEach((b,d)=>{let j=tn(b),A=g[d-1];j.start=KB({attributes:j,priorPeriodAttributes:A?A.attributes:null,mpdType:c.type}),g.push({node:b,attributes:j})}),{locations:c.locations,contentSteeringInfo:XB(u,i),representationInfo:J1(g.map(GB(c,h))),eventStream:J1(g.map(UB))}},Ew=(e)=>{if(e==="")throw Error(Q1.DASH_EMPTY_MANIFEST);let t=new B6,a,n;try{a=t.parseFromString(e,"application/xml"),n=a&&a.documentElement.tagName==="MPD"?a.documentElement:null}catch(s){}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw Error(Q1.DASH_INVALID_XML);return n},VB=(e)=>{let t=qa(e,"UTCTiming")[0];if(!t)return null;let a=tn(t);switch(a.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":a.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":a.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":a.method="DIRECT",a.value=Date.parse(a.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw Error(Q1.UNSUPPORTED_UTC_TIMING_SCHEME)}return a};var zw=(e,t={})=>{let a=LB(Ew(e),t),n=MB(a.representationInfo);return yB({dashPlaylists:n,locations:a.locations,contentSteering:a.contentSteeringInfo,sidxMapping:t.sidxMapping,previousManifest:t.previousManifest,eventStream:a.eventStream})},Uw=(e)=>VB(Ew(e));var Zd=Mt(Vw(),1);var QB=Ke([73,68,51]),ZB=function(t,a){if(a===void 0)a=0;t=Ke(t);var n=t[a+5],s=t[a+6]<<21|t[a+7]<<14|t[a+8]<<7|t[a+9],i=(n&16)>>4;if(i)return s+20;return s+10},dr=function e(t,a){if(a===void 0)a=0;if(t=Ke(t),t.length-a<10||!Zt(t,QB,{offset:a}))return a;return a+=ZB(t,a),e(t,a)};var qI=new Uint8Array([79,112,117,115,72,101,97,100]);var Jw=function(t){if(typeof t==="string")return i9(t);if(typeof t==="number")return t;return t},tT=function(t){if(!Array.isArray(t))return[Jw(t)];return t.map(function(a){return Jw(a)})},x6,Qw=function(t){t=Ke(t);var a=[],n=0;while(t.length>n){var s=t[n],i=0,f=0;f++;var l=t[f];f++;while(l&128)i=(l&127)<<7,l=t[f],f++;i+=l&127;for(var c=0;c<x6.length;c++){var h=x6[c],u=h.id,g=h.parser;if(s===u){a.push(g(t.subarray(f,f+i)));break}}n+=i+f}return a};x6=[{id:3,parser:function(t){var a={tag:3,id:t[0]<<8|t[1],flags:t[2],size:3,dependsOnEsId:0,ocrEsId:0,descriptors:[],url:""};if(a.flags&128)a.dependsOnEsId=t[a.size]<<8|t[a.size+1],a.size+=2;if(a.flags&64){var n=t[a.size];a.url=g6(t.subarray(a.size+1,a.size+1+n)),a.size+=n}if(a.flags&32)a.ocrEsId=t[a.size]<<8|t[a.size+1],a.size+=2;return a.descriptors=Qw(t.subarray(a.size))||[],a}},{id:4,parser:function(t){var a={tag:4,oti:t[0],streamType:t[1],bufferSize:t[2]<<16|t[3]<<8|t[4],maxBitrate:t[5]<<24|t[6]<<16|t[7]<<8|t[8],avgBitrate:t[9]<<24|t[10]<<16|t[11]<<8|t[12],descriptors:Qw(t.subarray(13))};return a}},{id:5,parser:function(t){return{tag:5,bytes:t}}},{id:6,parser:function(t){return{tag:6,bytes:t}}}];var Zw=function e(t,a,n){if(n===void 0)n=!1;a=tT(a),t=Ke(t);var s=[];if(!a.length)return s;var i=0;while(i<t.length){var f=(t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3])>>>0,l=t.subarray(i+4,i+8);if(f===0)break;var c=i+f;if(c>t.length){if(n)break;c=t.length}var h=t.subarray(i+8,c);if(Zt(l,a[0]))if(a.length===1)s.push(h);else s.push.apply(s,e(h,a.slice(1),n));i=c}return s};var wh={EBML:Ke([26,69,223,163]),DocType:Ke([66,130]),Segment:Ke([24,83,128,103]),SegmentInfo:Ke([21,73,169,102]),Tracks:Ke([22,84,174,107]),Track:Ke([174]),TrackNumber:Ke([215]),DefaultDuration:Ke([35,227,131]),TrackEntry:Ke([174]),TrackType:Ke([131]),FlagDefault:Ke([136]),CodecID:Ke([134]),CodecPrivate:Ke([99,162]),VideoTrack:Ke([224]),AudioTrack:Ke([225]),Cluster:Ke([31,67,182,117]),Timestamp:Ke([231]),TimestampScale:Ke([42,215,177]),BlockGroup:Ke([160]),BlockDuration:Ke([155]),Block:Ke([161]),SimpleBlock:Ke([163])},R6=[128,64,32,16,8,4,2,1],aT=function(t){var a=1;for(var n=0;n<R6.length;n++){if(t&R6[n])break;a++}return a},d9=function(t,a,n,s){if(n===void 0)n=!0;if(s===void 0)s=!1;var i=aT(t[a]),f=t.subarray(a,a+i);if(n)f=Array.prototype.slice.call(t,a,a+i),f[0]^=R6[i-1];return{length:i,value:m6(f,{signed:s}),bytes:f}},$w=function e(t){if(typeof t==="string")return t.match(/.{1,2}/g).map(function(a){return e(a)});if(typeof t==="number")return Tb(t);return t},nT=function(t){if(!Array.isArray(t))return[$w(t)];return t.map(function(a){return $w(a)})},sT=function e(t,a,n){if(n>=a.length)return a.length;var s=d9(a,n,!1);if(Zt(t.bytes,s.bytes))return n;var i=d9(a,n+s.length);return e(t,a,n+i.length+i.value+s.length)},N6=function e(t,a){a=nT(a),t=Ke(t);var n=[];if(!a.length)return n;var s=0;while(s<t.length){var i=d9(t,s,!1),f=d9(t,s+i.length),l=s+i.length+f.length;if(f.value===127){if(f.value=sT(i,t,l),f.value!==t.length)f.value-=l}var c=l+f.value>t.length?t.length:l+f.value,h=t.subarray(l,c);if(Zt(a[0],i.bytes))if(a.length===1)n.push(h);else n=n.concat(e(h,a.slice(1)));var u=i.length+f.length+h.length;s+=u}return n};var iT=Ke([0,0,0,1]),fT=Ke([0,0,1]),lT=Ke([0,0,3]),rT=function(t){var a=[],n=1;while(n<t.length-2){if(Zt(t.subarray(n,n+3),lT))a.push(n+2),n++;n++}if(a.length===0)return t;var s=t.length-a.length,i=new Uint8Array(s),f=0;for(n=0;n<s;f++,n++){if(f===a[0])f++,a.shift();i[n]=t[f]}return i},Ww=function(t,a,n,s){if(s===void 0)s=1/0;t=Ke(t),n=[].concat(n);var i=0,f,l=0;while(i<t.length&&(l<s||f)){var c=void 0;if(Zt(t.subarray(i),iT))c=4;else if(Zt(t.subarray(i),fT))c=3;if(!c){i++;continue}if(l++,f)return rT(t.subarray(f,i));var h=void 0;if(a==="h264")h=t[i+c]&31;else if(a==="h265")h=t[i+c]>>1&63;if(n.indexOf(h)!==-1)f=i+c;i+=c+(a==="h264"?1:2)}return t.subarray(0,0)},Pw=function(t,a,n){return Ww(t,"h264",a,n)},ed=function(t,a,n){return Ww(t,"h265",a,n)};var ts={webm:Ke([119,101,98,109]),matroska:Ke([109,97,116,114,111,115,107,97]),flac:Ke([102,76,97,67]),ogg:Ke([79,103,103,83]),ac3:Ke([11,119]),riff:Ke([82,73,70,70]),avi:Ke([65,86,73]),wav:Ke([87,65,86,69]),"3gp":Ke([102,116,121,112,51,103]),mp4:Ke([102,116,121,112]),fmp4:Ke([115,116,121,112]),mov:Ke([102,116,121,112,113,116]),moov:Ke([109,111,111,118]),moof:Ke([109,111,111,102])},Z1={aac:function(t){var a=dr(t);return Zt(t,[255,16],{offset:a,mask:[255,22]})},mp3:function(t){var a=dr(t);return Zt(t,[255,2],{offset:a,mask:[255,6]})},webm:function(t){var a=N6(t,[wh.EBML,wh.DocType])[0];return Zt(a,ts.webm)},mkv:function(t){var a=N6(t,[wh.EBML,wh.DocType])[0];return Zt(a,ts.matroska)},mp4:function(t){if(Z1["3gp"](t)||Z1.mov(t))return!1;if(Zt(t,ts.mp4,{offset:4})||Zt(t,ts.fmp4,{offset:4}))return!0;if(Zt(t,ts.moof,{offset:4})||Zt(t,ts.moov,{offset:4}))return!0},mov:function(t){return Zt(t,ts.mov,{offset:4})},"3gp":function(t){return Zt(t,ts["3gp"],{offset:4})},ac3:function(t){var a=dr(t);return Zt(t,ts.ac3,{offset:a})},ts:function(t){if(t.length<189&&t.length>=1)return t[0]===71;var a=0;while(a+188<t.length&&a<188){if(t[a]===71&&t[a+188]===71)return!0;a+=1}return!1},flac:function(t){var a=dr(t);return Zt(t,ts.flac,{offset:a})},ogg:function(t){return Zt(t,ts.ogg)},avi:function(t){return Zt(t,ts.riff)&&Zt(t,ts.avi,{offset:8})},wav:function(t){return Zt(t,ts.riff)&&Zt(t,ts.wav,{offset:8})},h264:function(t){return Pw(t,7,3).length},h265:function(t){return ed(t,[32,33],3).length}},E6=Object.keys(Z1).filter(function(e){return e!=="ts"&&e!=="h264"&&e!=="h265"}).concat(["ts","h264","h265"]);E6.forEach(function(e){var t=Z1[e];Z1[e]=function(a){return t(Ke(a))}});var oT=Z1,j9=function(t){t=Ke(t);for(var a=0;a<E6.length;a++){var n=E6[a];if(oT[n](t))return n}return""},td=function(t){return Zw(t,["moof"]).length>0};var fl=Mt(fd(),1),i4="8.23.7",P0={},rl=function(e,t){if(P0[e]=P0[e]||[],t)P0[e]=P0[e].concat(t);return P0[e]},cT=function(e,t){rl(e,t)},$d=function(e,t){let a=rl(e).indexOf(t);if(a<=-1)return!1;return P0[e]=P0[e].slice(),P0[e].splice(a,1),!0},hT=function(e,t){rl(e,[].concat(t).map((a)=>{let n=(...s)=>{return $d(e,n),a(...s)};return n}))},F9={prefixed:!0},S9=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],ld=S9[0],vh;for(let e=0;e<S9.length;e++)if(S9[e][1]in ye.default){vh=S9[e];break}if(vh){for(let e=0;e<vh.length;e++)F9[ld[e]]=vh[e];F9.prefixed=vh[0]!==ld[0]}var qs=[],uT=(e,t,a)=>(n,s,i)=>{let f=t.levels[s],l=new RegExp(`^(${f})$`),c=e;if(n!=="log")i.unshift(n.toUpperCase()+":");if(a)c=`%c${e}`,i.unshift(a);if(i.unshift(c+":"),qs){qs.push([].concat(i));let u=qs.length-1000;qs.splice(0,u>0?u:0)}if(!V.default.console)return;let h=V.default.console[n];if(!h&&n==="debug")h=V.default.console.info||V.default.console.log;if(!h||!f||!l.test(n))return;h[Array.isArray(i)?"apply":"call"](V.default.console,i)};function f4(e,t=":",a=""){let n="info",s;function i(...f){s("log",n,f)}return s=uT(e,i,a),i.createLogger=(f,l,c)=>{let h=l!==void 0?l:t,u=c!==void 0?c:a,g=`${e} ${h} ${f}`;return f4(g,h,u)},i.createNewLogger=(f,l,c)=>{return f4(f,l,c)},i.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:n},i.level=(f)=>{if(typeof f==="string"){if(!i.levels.hasOwnProperty(f))throw Error(`"${f}" in not a valid log level`);n=f}return n},i.history=()=>qs?[].concat(qs):[],i.history.filter=(f)=>{return(qs||[]).filter((l)=>{return new RegExp(`.*${f}.*`).test(l[0])})},i.history.clear=()=>{if(qs)qs.length=0},i.history.disable=()=>{if(qs!==null)qs.length=0,qs=null},i.history.enable=()=>{if(qs===null)qs=[]},i.error=(...f)=>s("error",n,f),i.warn=(...f)=>s("warn",n,f),i.debug=(...f)=>s("debug",n,f),i}var qt=f4("VIDEOJS"),Wd=qt.createLogger,mT=Object.prototype.toString,Pd=function(e){return r0(e)?Object.keys(e):[]};function to(e,t){Pd(e).forEach((a)=>t(e[a],a))}function ej(e,t,a=0){return Pd(e).reduce((n,s)=>t(n,e[s],s),a)}function r0(e){return!!e&&typeof e==="object"}function co(e){return r0(e)&&mT.call(e)==="[object Object]"&&e.constructor===Object}function sa(...e){let t={};return e.forEach((a)=>{if(!a)return;to(a,(n,s)=>{if(!co(n)){t[s]=n;return}if(!co(t[s]))t[s]={};t[s]=sa(t[s],n)})}),t}function tj(e={}){let t=[];for(let a in e)if(e.hasOwnProperty(a)){let n=e[a];t.push(n)}return t}function Q9(e,t,a,n=!0){let s=(f)=>Object.defineProperty(e,t,{value:f,enumerable:!0,writable:!0}),i={configurable:!0,enumerable:!0,get(){let f=a();return s(f),f}};if(n)i.set=s;return Object.defineProperty(e,t,i)}var gT=Object.freeze({__proto__:null,each:to,reduce:ej,isObject:r0,isPlain:co,merge:sa,values:tj,defineLazyProperty:Q9}),T4=!1,aj=null,Mi=!1,nj,sj=!1,ao=!1,no=!1,o0=!1,H4=null,Z9=null,pT=Boolean(V.default.cast&&V.default.cast.framework&&V.default.cast.framework.CastReceiverContext),ij=null,O9=!1,$9=!1,B9=!1,W9=!1,T9=!1,H9=!1,M9=!1,Fh=Boolean(po()&&(("ontouchstart"in V.default)||V.default.navigator.maxTouchPoints||V.default.DocumentTouch&&V.default.document instanceof V.default.DocumentTouch)),al=V.default.navigator&&V.default.navigator.userAgentData;if(al&&al.platform&&al.brands)Mi=al.platform==="Android",ao=Boolean(al.brands.find((e)=>e.brand==="Microsoft Edge")),no=Boolean(al.brands.find((e)=>e.brand==="Chromium")),o0=!ao&&no,H4=Z9=(al.brands.find((e)=>e.brand==="Chromium")||{}).version||null,$9=al.platform==="Windows";if(!no){let e=V.default.navigator&&V.default.navigator.userAgent||"";T4=/iPod/i.test(e),aj=function(){let t=e.match(/OS (\d+)_/i);if(t&&t[1])return t[1];return null}(),Mi=/Android/i.test(e),nj=function(){let t=e.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;let a=t[1]&&parseFloat(t[1]),n=t[2]&&parseFloat(t[2]);if(a&&n)return parseFloat(t[1]+"."+t[2]);else if(a)return a;return null}(),sj=/Firefox/i.test(e),ao=/Edg/i.test(e),no=/Chrome/i.test(e)||/CriOS/i.test(e),o0=!ao&&no,H4=Z9=function(){let t=e.match(/(Chrome|CriOS)\/(\d+)/);if(t&&t[2])return parseFloat(t[2]);return null}(),ij=function(){let t=/MSIE\s(\d+)\.\d/.exec(e),a=t&&parseFloat(t[1]);if(!a&&/Trident\/7.0/i.test(e)&&/rv:11.0/.test(e))a=11;return a}(),T9=/Tizen/i.test(e),H9=/Web0S/i.test(e),M9=T9||H9,O9=/Safari/i.test(e)&&!o0&&!Mi&&!ao&&!M9,$9=/Windows/i.test(e),B9=/iPad/i.test(e)||O9&&Fh&&!/iPhone/i.test(e),W9=/iPhone/i.test(e)&&!B9}var Ln=W9||B9||T4,P9=(O9||Ln)&&!o0,fj=Object.freeze({__proto__:null,get IS_IPOD(){return T4},get IOS_VERSION(){return aj},get IS_ANDROID(){return Mi},get ANDROID_VERSION(){return nj},get IS_FIREFOX(){return sj},get IS_EDGE(){return ao},get IS_CHROMIUM(){return no},get IS_CHROME(){return o0},get CHROMIUM_VERSION(){return H4},get CHROME_VERSION(){return Z9},IS_CHROMECAST_RECEIVER:pT,get IE_VERSION(){return ij},get IS_SAFARI(){return O9},get IS_WINDOWS(){return $9},get IS_IPAD(){return B9},get IS_IPHONE(){return W9},get IS_TIZEN(){return T9},get IS_WEBOS(){return H9},get IS_SMART_TV(){return M9},TOUCH_ENABLED:Fh,IS_IOS:Ln,IS_ANY_SAFARI:P9});function rd(e){return typeof e==="string"&&Boolean(e.trim())}function bT(e){if(e.indexOf(" ")>=0)throw Error("class has illegal whitespace characters")}function po(){return ye.default===V.default.document}function bo(e){return r0(e)&&e.nodeType===1}function lj(){try{return V.default.parent!==V.default.self}catch(e){return!0}}function rj(e){return function(t,a){if(!rd(t))return ye.default[e](null);if(rd(a))a=ye.default.querySelector(a);let n=bo(a)?a:ye.default;return n[e]&&n[e](t)}}function tt(e="div",t={},a={},n){let s=ye.default.createElement(e);if(Object.getOwnPropertyNames(t).forEach(function(i){let f=t[i];if(i==="textContent")hl(s,f);else if(s[i]!==f||i==="tabIndex")s[i]=f}),Object.getOwnPropertyNames(a).forEach(function(i){s.setAttribute(i,a[i])}),n)M4(s,n);return s}function hl(e,t){if(typeof e.textContent>"u")e.innerText=t;else e.textContent=t;return e}function l4(e,t){if(t.firstChild)t.insertBefore(e,t.firstChild);else t.appendChild(e)}function Ah(e,t){return bT(t),e.classList.contains(t)}function yr(e,...t){return e.classList.add(...t.reduce((a,n)=>a.concat(n.split(/\s+/)),[])),e}function em(e,...t){if(!e)return qt.warn("removeClass was called with an element that doesn't exist"),null;return e.classList.remove(...t.reduce((a,n)=>a.concat(n.split(/\s+/)),[])),e}function oj(e,t,a){if(typeof a==="function")a=a(e,t);if(typeof a!=="boolean")a=void 0;return t.split(/\s+/).forEach((n)=>e.classList.toggle(n,a)),e}function cj(e,t){Object.getOwnPropertyNames(t).forEach(function(a){let n=t[a];if(n===null||typeof n>"u"||n===!1)e.removeAttribute(a);else e.setAttribute(a,n===!0?"":n)})}function sl(e){let t={},a=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(e&&e.attributes&&e.attributes.length>0){let n=e.attributes;for(let s=n.length-1;s>=0;s--){let i=n[s].name,f=n[s].value;if(a.includes(i))f=f!==null?!0:!1;t[i]=f}}return t}function hj(e,t){return e.getAttribute(t)}function ho(e,t,a){e.setAttribute(t,a)}function tm(e,t){e.removeAttribute(t)}function uj(){ye.default.body.focus(),ye.default.onselectstart=function(){return!1}}function mj(){ye.default.onselectstart=function(){return!0}}function uo(e){if(e&&e.getBoundingClientRect&&e.parentNode){let t=e.getBoundingClientRect(),a={};if(["bottom","height","left","right","top","width"].forEach((n)=>{if(t[n]!==void 0)a[n]=t[n]}),!a.height)a.height=parseFloat(mo(e,"height"));if(!a.width)a.width=parseFloat(mo(e,"width"));return a}}function Oh(e){if(!e||e&&!e.offsetParent)return{left:0,top:0,width:0,height:0};let{offsetWidth:t,offsetHeight:a}=e,n=0,s=0;while(e.offsetParent&&e!==ye.default[F9.fullscreenElement])n+=e.offsetLeft,s+=e.offsetTop,e=e.offsetParent;return{left:n,top:s,width:t,height:a}}function am(e,t){let a={x:0,y:0};if(Ln){let u=e;while(u&&u.nodeName.toLowerCase()!=="html"){let g=mo(u,"transform");if(/^matrix/.test(g)){let b=g.slice(7,-1).split(/,\s/).map(Number);a.x+=b[4],a.y+=b[5]}else if(/^matrix3d/.test(g)){let b=g.slice(9,-1).split(/,\s/).map(Number);a.x+=b[12],a.y+=b[13]}if(u.assignedSlot&&u.assignedSlot.parentElement&&V.default.WebKitCSSMatrix){let b=V.default.getComputedStyle(u.assignedSlot.parentElement).transform,d=new V.default.WebKitCSSMatrix(b);a.x+=d.m41,a.y+=d.m42}u=u.parentNode||u.host}}let n={},s=Oh(t.target),i=Oh(e),f=i.width,l=i.height,c=t.offsetY-(i.top-s.top),h=t.offsetX-(i.left-s.left);if(t.changedTouches){if(h=t.changedTouches[0].pageX-i.left,c=t.changedTouches[0].pageY+i.top,Ln)h-=a.x,c-=a.y}return n.y=1-Math.max(0,Math.min(1,c/l)),n.x=Math.max(0,Math.min(1,h/f)),n}function gj(e){return r0(e)&&e.nodeType===3}function nm(e){while(e.firstChild)e.removeChild(e.firstChild);return e}function pj(e){if(typeof e==="function")e=e();return(Array.isArray(e)?e:[e]).map((t)=>{if(typeof t==="function")t=t();if(bo(t)||gj(t))return t;if(typeof t==="string"&&/\S/.test(t))return ye.default.createTextNode(t)}).filter((t)=>t)}function M4(e,t){return pj(t).forEach((a)=>e.appendChild(a)),e}function bj(e,t){return M4(nm(e),t)}function Bh(e){if(e.button===void 0&&e.buttons===void 0)return!0;if(e.button===0&&e.buttons===void 0)return!0;if(e.type==="mouseup"&&e.button===0&&e.buttons===0)return!0;if(e.type==="mousedown"&&e.button===0&&e.buttons===0)return!0;if(e.button!==0||e.buttons!==1)return!1;return!0}var ol=rj("querySelector"),wj=rj("querySelectorAll");function mo(e,t){if(!e||!t)return"";if(typeof V.default.getComputedStyle==="function"){let a;try{a=V.default.getComputedStyle(e)}catch(n){return""}return a?a.getPropertyValue(t)||a[t]:""}return""}function dj(e){[...ye.default.styleSheets].forEach((t)=>{try{let a=[...t.cssRules].map((s)=>s.cssText).join(""),n=ye.default.createElement("style");n.textContent=a,e.document.head.appendChild(n)}catch(a){let n=ye.default.createElement("link");n.rel="stylesheet",n.type=t.type,n.media=t.media.mediaText,n.href=t.href,e.document.head.appendChild(n)}})}var jj=Object.freeze({__proto__:null,isReal:po,isEl:bo,isInFrame:lj,createEl:tt,textContent:hl,prependTo:l4,hasClass:Ah,addClass:yr,removeClass:em,toggleClass:oj,setAttributes:cj,getAttributes:sl,getAttribute:hj,setAttribute:ho,removeAttribute:tm,blockTextSelection:uj,unblockTextSelection:mj,getBoundingClientRect:uo,findPosition:Oh,getPointerPosition:am,isTextNode:gj,emptyEl:nm,normalizeContent:pj,appendContent:M4,insertContent:bj,isSingleLeftClick:Bh,$:ol,$$:wj,computedStyle:mo,copyStyleSheetsToWindow:dj}),qj=!1,r4,wT=function(){if(r4.options.autoSetup===!1)return;let e=Array.prototype.slice.call(ye.default.getElementsByTagName("video")),t=Array.prototype.slice.call(ye.default.getElementsByTagName("audio")),a=Array.prototype.slice.call(ye.default.getElementsByTagName("video-js")),n=e.concat(t,a);if(n&&n.length>0)for(let s=0,i=n.length;s<i;s++){let f=n[s];if(f&&f.getAttribute){if(f.player===void 0){if(f.getAttribute("data-setup")!==null)r4(f)}}else{o4(1);break}}else if(!qj)o4(1)};function o4(e,t){if(!po())return;if(t)r4=t;V.default.setTimeout(wT,e)}function c4(){qj=!0,V.default.removeEventListener("load",c4)}if(po())if(ye.default.readyState==="complete")c4();else V.default.addEventListener("load",c4);var vj=function(e){let t=ye.default.createElement("style");return t.className=e,t},kj=function(e,t){if(e.styleSheet)e.styleSheet.cssText=t;else e.textContent=t},ns=new WeakMap,dT=3,jT=dT;function ui(){return jT++}function od(e,t){if(!ns.has(e))return;let a=ns.get(e);if(a.handlers[t].length===0){if(delete a.handlers[t],e.removeEventListener)e.removeEventListener(t,a.dispatcher,!1);else if(e.detachEvent)e.detachEvent("on"+t,a.dispatcher)}if(Object.getOwnPropertyNames(a.handlers).length<=0)delete a.handlers,delete a.dispatcher,delete a.disabled;if(Object.getOwnPropertyNames(a).length===0)ns.delete(e)}function D4(e,t,a,n){a.forEach(function(s){e(t,s,n)})}function sm(e){if(e.fixed_)return e;function t(){return!0}function a(){return!1}if(!e||!e.isPropagationStopped||!e.isImmediatePropagationStopped){let n=e||V.default.event;e={};let s=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(let i in n)if(!s.includes(i)){if(!(i==="returnValue"&&n.preventDefault))e[i]=n[i]}if(!e.target)e.target=e.srcElement||ye.default;if(!e.relatedTarget)e.relatedTarget=e.fromElement===e.target?e.toElement:e.fromElement;if(e.preventDefault=function(){if(n.preventDefault)n.preventDefault();e.returnValue=!1,n.returnValue=!1,e.defaultPrevented=!0},e.defaultPrevented=!1,e.stopPropagation=function(){if(n.stopPropagation)n.stopPropagation();e.cancelBubble=!0,n.cancelBubble=!0,e.isPropagationStopped=t},e.isPropagationStopped=a,e.stopImmediatePropagation=function(){if(n.stopImmediatePropagation)n.stopImmediatePropagation();e.isImmediatePropagationStopped=t,e.stopPropagation()},e.isImmediatePropagationStopped=a,e.clientX!==null&&e.clientX!==void 0){let i=ye.default.documentElement,f=ye.default.body;e.pageX=e.clientX+(i&&i.scrollLeft||f&&f.scrollLeft||0)-(i&&i.clientLeft||f&&f.clientLeft||0),e.pageY=e.clientY+(i&&i.scrollTop||f&&f.scrollTop||0)-(i&&i.clientTop||f&&f.clientTop||0)}if(e.which=e.charCode||e.keyCode,e.button!==null&&e.button!==void 0)e.button=e.button&1?0:e.button&4?1:e.button&2?2:0}return e.fixed_=!0,e}var v9,qT=function(){if(typeof v9!=="boolean"){v9=!1;try{let e=Object.defineProperty({},"passive",{get(){v9=!0}});V.default.addEventListener("test",null,e),V.default.removeEventListener("test",null,e)}catch(e){}}return v9},vT=["touchstart","touchmove"];function Ls(e,t,a){if(Array.isArray(t))return D4(Ls,e,t,a);if(!ns.has(e))ns.set(e,{});let n=ns.get(e);if(!n.handlers)n.handlers={};if(!n.handlers[t])n.handlers[t]=[];if(!a.guid)a.guid=ui();if(n.handlers[t].push(a),!n.dispatcher)n.disabled=!1,n.dispatcher=function(s,i){if(n.disabled)return;s=sm(s);let f=n.handlers[s.type];if(f){let l=f.slice(0);for(let c=0,h=l.length;c<h;c++)if(s.isImmediatePropagationStopped())break;else try{l[c].call(e,s,i)}catch(u){qt.error(u)}}};if(n.handlers[t].length===1){if(e.addEventListener){let s=!1;if(qT()&&vT.indexOf(t)>-1)s={passive:!0};e.addEventListener(t,n.dispatcher,s)}else if(e.attachEvent)e.attachEvent("on"+t,n.dispatcher)}}function Vn(e,t,a){if(!ns.has(e))return;let n=ns.get(e);if(!n.handlers)return;if(Array.isArray(t))return D4(Vn,e,t,a);let s=function(f,l){n.handlers[l]=[],od(f,l)};if(t===void 0){for(let f in n.handlers)if(Object.prototype.hasOwnProperty.call(n.handlers||{},f))s(e,f);return}let i=n.handlers[t];if(!i)return;if(!a){s(e,t);return}if(a.guid){for(let f=0;f<i.length;f++)if(i[f].guid===a.guid)i.splice(f--,1)}od(e,t)}function wo(e,t,a){let n=ns.has(e)?ns.get(e):{},s=e.parentNode||e.ownerDocument;if(typeof t==="string")t={type:t,target:e};else if(!t.target)t.target=e;if(t=sm(t),n.dispatcher)n.dispatcher.call(e,t,a);if(s&&!t.isPropagationStopped()&&t.bubbles===!0)wo.call(null,s,t,a);else if(!s&&!t.defaultPrevented&&t.target&&t.target[t.type]){if(!ns.has(t.target))ns.set(t.target,{});let i=ns.get(t.target);if(t.target[t.type]){if(i.disabled=!0,typeof t.target[t.type]==="function")t.target[t.type]();i.disabled=!1}}return!t.defaultPrevented}function im(e,t,a){if(Array.isArray(t))return D4(im,e,t,a);let n=function(){Vn(e,t,n),a.apply(this,arguments)};n.guid=a.guid=a.guid||ui(),Ls(e,t,n)}function x4(e,t,a){let n=function(){Vn(e,t,n),a.apply(this,arguments)};n.guid=a.guid=a.guid||ui(),Ls(e,t,n)}var kT=Object.freeze({__proto__:null,fixEvent:sm,on:Ls,off:Vn,trigger:wo,one:im,any:x4}),mi=30,ua=function(e,t,a){if(!t.guid)t.guid=ui();let n=t.bind(e);return n.guid=a?a+"_"+t.guid:t.guid,n},c0=function(e,t){let a=V.default.performance.now();return function(...s){let i=V.default.performance.now();if(i-a>=t)e(...s),a=i}},Aj=function(e,t,a,n=V.default){let s,i=()=>{n.clearTimeout(s),s=null},f=function(){let l=this,c=arguments,h=function(){if(s=null,h=null,!a)e.apply(l,c)};if(!s&&a)e.apply(l,c);n.clearTimeout(s),s=n.setTimeout(h,t)};return f.cancel=i,f},AT=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:mi,bind_:ua,throttle:c0,debounce:Aj}),dh;class ys{on(e,t){let a=this.addEventListener;this.addEventListener=()=>{},Ls(this,e,t),this.addEventListener=a}off(e,t){Vn(this,e,t)}one(e,t){let a=this.addEventListener;this.addEventListener=()=>{},im(this,e,t),this.addEventListener=a}any(e,t){let a=this.addEventListener;this.addEventListener=()=>{},x4(this,e,t),this.addEventListener=a}trigger(e){let t=e.type||e;if(typeof e==="string")e={type:t};if(e=sm(e),this.allowedEvents_[t]&&this["on"+t])this["on"+t](e);wo(this,e)}queueTrigger(e){if(!dh)dh=new Map;let t=e.type||e,a=dh.get(this);if(!a)a=new Map,dh.set(this,a);let n=a.get(t);a.delete(t),V.default.clearTimeout(n);let s=V.default.setTimeout(()=>{if(a.delete(t),a.size===0)a=null,dh.delete(this);this.trigger(e)},0);a.set(t,s)}}ys.prototype.allowedEvents_={};ys.prototype.addEventListener=ys.prototype.on;ys.prototype.removeEventListener=ys.prototype.off;ys.prototype.dispatchEvent=ys.prototype.trigger;var fm=(e)=>{if(typeof e.name==="function")return e.name();if(typeof e.name==="string")return e.name;if(e.name_)return e.name_;if(e.constructor&&e.constructor.name)return e.constructor.name;return typeof e},tf=(e)=>e instanceof ys||!!e.eventBusEl_&&["on","one","off","trigger"].every((t)=>typeof e[t]==="function"),yT=(e,t)=>{if(tf(e))t();else{if(!e.eventedCallbacks)e.eventedCallbacks=[];e.eventedCallbacks.push(t)}},h4=(e)=>typeof e==="string"&&/\S/.test(e)||Array.isArray(e)&&!!e.length,D9=(e,t,a)=>{if(!e||!e.nodeName&&!tf(e))throw Error(`Invalid target for ${fm(t)}#${a}; must be a DOM node or evented object.`)},yj=(e,t,a)=>{if(!h4(e))throw Error(`Invalid event type for ${fm(t)}#${a}; must be a non-empty string or array.`)},Sj=(e,t,a)=>{if(typeof e!=="function")throw Error(`Invalid listener for ${fm(t)}#${a}; must be a function.`)},X6=(e,t,a)=>{let n=t.length<3||t[0]===e||t[0]===e.eventBusEl_,s,i,f;if(n){if(s=e.eventBusEl_,t.length>=3)t.shift();[i,f]=t}else s=t[0],i=t[1],f=t[2];return D9(s,e,a),yj(i,e,a),Sj(f,e,a),f=ua(e,f),{isTargetingSelf:n,target:s,type:i,listener:f}},jr=(e,t,a,n)=>{if(D9(e,e,t),e.nodeName)kT[t](e,a,n);else e[t](a,n)},ST={on(...e){let{isTargetingSelf:t,target:a,type:n,listener:s}=X6(this,e,"on");if(jr(a,"on",n,s),!t){let i=()=>this.off(a,n,s);i.guid=s.guid;let f=()=>this.off("dispose",i);f.guid=s.guid,jr(this,"on","dispose",i),jr(a,"on","dispose",f)}},one(...e){let{isTargetingSelf:t,target:a,type:n,listener:s}=X6(this,e,"one");if(t)jr(a,"one",n,s);else{let i=(...f)=>{this.off(a,n,i),s.apply(null,f)};i.guid=s.guid,jr(a,"one",n,i)}},any(...e){let{isTargetingSelf:t,target:a,type:n,listener:s}=X6(this,e,"any");if(t)jr(a,"any",n,s);else{let i=(...f)=>{this.off(a,n,i),s.apply(null,f)};i.guid=s.guid,jr(a,"any",n,i)}},off(e,t,a){if(!e||h4(e))Vn(this.eventBusEl_,e,t);else{let n=e,s=t;if(D9(n,this,"off"),yj(s,this,"off"),Sj(a,this,"off"),a=ua(this,a),this.off("dispose",a),n.nodeName)Vn(n,s,a),Vn(n,"dispose",a);else if(tf(n))n.off(s,a),n.off("dispose",a)}},trigger(e,t){D9(this.eventBusEl_,this,"trigger");let a=e&&typeof e!=="string"?e.type:e;if(!h4(a))throw Error(`Invalid event type for ${fm(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return wo(this.eventBusEl_,e,t)}};function R4(e,t={}){let{eventBusKey:a}=t;if(a){if(!e[a].nodeName)throw Error(`The eventBusKey "${a}" does not refer to an element.`);e.eventBusEl_=e[a]}else e.eventBusEl_=tt("span",{className:"vjs-event-bus"});if(Object.assign(e,ST),e.eventedCallbacks)e.eventedCallbacks.forEach((n)=>{n()});return e.on("dispose",()=>{e.off(),[e,e.el_,e.eventBusEl_].forEach(function(n){if(n&&ns.has(n))ns.delete(n)}),V.default.setTimeout(()=>{e.eventBusEl_=null},0)}),e}var CT={state:{},setState(e){if(typeof e==="function")e=e();let t;if(to(e,(a,n)=>{if(this.state[n]!==a)t=t||{},t[n]={from:this.state[n],to:a};this.state[n]=a}),t&&tf(this))this.trigger({changes:t,type:"statechanged"});return t}};function Cj(e,t){if(Object.assign(e,CT),e.state=Object.assign({},e.state,t),typeof e.handleStateChanged==="function"&&tf(e))e.on("statechanged",e.handleStateChanged);return e}var yh=function(e){if(typeof e!=="string")return e;return e.replace(/./,(t)=>t.toLowerCase())},Na=function(e){if(typeof e!=="string")return e;return e.replace(/./,(t)=>t.toUpperCase())},_j=function(e,t){return Na(e)===Na(t)},_T=Object.freeze({__proto__:null,toLowerCase:yh,toTitleCase:Na,titleCaseEquals:_j});class me{constructor(e,t,a){if(!e&&this.play)this.player_=e=this;else this.player_=e;if(this.isDisposed_=!1,this.parentComponent_=null,this.options_=sa({},this.options_),t=this.options_=sa(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){let n=e&&e.id&&e.id()||"no_player";this.id_=`${n}_component_${ui()}`}if(this.name_=t.name||null,t.el)this.el_=t.el;else if(t.createEl!==!1)this.el_=this.createEl();if(t.className&&this.el_)t.className.split(" ").forEach((n)=>this.addClass(n));if(["on","off","one","any","trigger"].forEach((n)=>{this[n]=void 0}),t.evented!==!1)R4(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange);if(Cj(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1)this.initChildren();if(this.ready(a),t.reportTouchActivity!==!1)this.enableTouchActivity()}dispose(e={}){if(this.isDisposed_)return;if(this.readyQueue_)this.readyQueue_.length=0;if(this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_){for(let t=this.children_.length-1;t>=0;t--)if(this.children_[t].dispose)this.children_[t].dispose()}if(this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_){if(this.el_.parentNode)if(e.restoreEl)this.el_.parentNode.replaceChild(e.restoreEl,this.el_);else this.el_.parentNode.removeChild(this.el_);this.el_=null}this.player_=null}isDisposed(){return Boolean(this.isDisposed_)}player(){return this.player_}options(e){if(!e)return this.options_;return this.options_=sa(this.options_,e),this.options_}el(){return this.el_}createEl(e,t,a){return tt(e,t,a)}localize(e,t,a=e){let n=this.player_.language&&this.player_.language(),s=this.player_.languages&&this.player_.languages(),i=s&&s[n],f=n&&n.split("-")[0],l=s&&s[f],c=a;if(i&&i[e])c=i[e];else if(l&&l[e])c=l[e];if(t)c=c.replace(/\{(\d+)\}/g,function(h,u){let g=t[u-1],b=g;if(typeof g>"u")b=h;return b});return c}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(!e)return;return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((a,n)=>a.concat(n),[]);let t=this;for(let a=0;a<e.length;a++)if(t=t.getChild(e[a]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;let a="http://www.w3.org/2000/svg",n=tt("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),s=ye.default.createElementNS(a,"svg");s.setAttributeNS(null,"viewBox","0 0 512 512");let i=ye.default.createElementNS(a,"use");if(s.appendChild(i),i.setAttributeNS(null,"href",`#vjs-icon-${e}`),n.appendChild(s),this.iconIsSet_)t.replaceChild(n,t.querySelector(".vjs-icon-placeholder"));else t.appendChild(n);return this.iconIsSet_=!0,n}addChild(e,t={},a=this.children_.length){let n,s;if(typeof e==="string"){s=Na(e);let i=t.componentClass||s;t.name=s;let f=me.getComponent(i);if(!f)throw Error(`Component ${i} does not exist`);if(typeof f!=="function")return null;n=new f(this.player_||this,t)}else n=e;if(n.parentComponent_)n.parentComponent_.removeChild(n);if(this.children_.splice(a,0,n),n.parentComponent_=this,typeof n.id==="function")this.childIndex_[n.id()]=n;if(s=s||n.name&&Na(n.name()),s)this.childNameIndex_[s]=n,this.childNameIndex_[yh(s)]=n;if(typeof n.el==="function"&&n.el()){let i=null;if(this.children_[a+1]){if(this.children_[a+1].el_)i=this.children_[a+1].el_;else if(bo(this.children_[a+1]))i=this.children_[a+1]}this.contentEl().insertBefore(n.el(),i)}return n}removeChild(e){if(typeof e==="string")e=this.getChild(e);if(!e||!this.children_)return;let t=!1;for(let n=this.children_.length-1;n>=0;n--)if(this.children_[n]===e){t=!0,this.children_.splice(n,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[Na(e.name())]=null,this.childNameIndex_[yh(e.name())]=null;let a=e.el();if(a&&a.parentNode===this.contentEl())this.contentEl().removeChild(e.el())}initChildren(){let e=this.options_.children;if(e){let t=this.options_,a=(i)=>{let{name:f,opts:l}=i;if(t[f]!==void 0)l=t[f];if(l===!1)return;if(l===!0)l={};l.playerOptions=this.options_.playerOptions;let c=this.addChild(f,l);if(c)this[f]=c},n,s=me.getComponent("Tech");if(Array.isArray(e))n=e;else n=Object.keys(e);n.concat(Object.keys(this.options_).filter(function(i){return!n.some(function(f){if(typeof f==="string")return i===f;return i===f.name})})).map((i)=>{let f,l;if(typeof i==="string")f=i,l=e[f]||this.options_[f]||{};else f=i.name,l=i;return{name:f,opts:l}}).filter((i)=>{let f=me.getComponent(i.opts.componentClass||Na(i.name));return f&&!s.isTech(f)}).forEach(a)}}buildCSSClass(){return""}ready(e,t=!1){if(!e)return;if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}if(t)e.call(this);else this.setTimeout(e,1)}triggerReady(){this.isReady_=!0,this.setTimeout(function(){let e=this.readyQueue_;if(this.readyQueue_=[],e&&e.length>0)e.forEach(function(t){t.call(this)},this);this.trigger("ready")},1)}$(e,t){return ol(e,t||this.contentEl())}$$(e,t){return wj(e,t||this.contentEl())}hasClass(e){return Ah(this.el_,e)}addClass(...e){yr(this.el_,...e)}removeClass(...e){em(this.el_,...e)}toggleClass(e,t){oj(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return hj(this.el_,e)}setAttribute(e,t){ho(this.el_,e,t)}removeAttribute(e){tm(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,a){if(t!==void 0){if(t===null||t!==t)t=0;if((""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1)this.el_.style[e]=t;else if(t==="auto")this.el_.style[e]="";else this.el_.style[e]=t+"px";if(!a)this.trigger("componentresize");return}if(!this.el_)return 0;let n=this.el_.style[e],s=n.indexOf("px");if(s!==-1)return parseInt(n.slice(0,s),10);return parseInt(this.el_["offset"+Na(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw Error("currentDimension only accepts width or height value");if(t=mo(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){let a=`offset${Na(e)}`;t=this.el_[a]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){let e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},a={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:a}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){if(this.player_){if(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))e.stopPropagation();this.player_.handleKeyDown(e)}}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null,a=10,n=200,s;this.on("touchstart",function(f){if(f.touches.length===1)t={pageX:f.touches[0].pageX,pageY:f.touches[0].pageY},e=V.default.performance.now(),s=!0}),this.on("touchmove",function(f){if(f.touches.length>1)s=!1;else if(t){let l=f.touches[0].pageX-t.pageX,c=f.touches[0].pageY-t.pageY;if(Math.sqrt(l*l+c*c)>a)s=!1}});let i=function(){s=!1};this.on("touchleave",i),this.on("touchcancel",i),this.on("touchend",function(f){if(t=null,s===!0){if(V.default.performance.now()-e<n)f.preventDefault(),this.trigger("tap")}})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;let e=ua(this.player(),this.player().reportUserActivity),t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});let a=function(n){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",a),this.on("touchcancel",a)}setTimeout(e,t){var a;return e=ua(this,e),this.clearTimersOnDispose_(),a=V.default.setTimeout(()=>{if(this.setTimeoutIds_.has(a))this.setTimeoutIds_.delete(a);e()},t),this.setTimeoutIds_.add(a),a}clearTimeout(e){if(this.setTimeoutIds_.has(e))this.setTimeoutIds_.delete(e),V.default.clearTimeout(e);return e}setInterval(e,t){e=ua(this,e),this.clearTimersOnDispose_();let a=V.default.setInterval(e,t);return this.setIntervalIds_.add(a),a}clearInterval(e){if(this.setIntervalIds_.has(e))this.setIntervalIds_.delete(e),V.default.clearInterval(e);return e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=ua(this,e),t=V.default.requestAnimationFrame(()=>{if(this.rafIds_.has(t))this.rafIds_.delete(t);e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){if(this.namedRafs_.has(e))this.cancelNamedAnimationFrame(e);this.clearTimersOnDispose_(),t=ua(this,t);let a=this.requestAnimationFrame(()=>{if(t(),this.namedRafs_.has(e))this.namedRafs_.delete(e)});return this.namedRafs_.set(e,a),e}cancelNamedAnimationFrame(e){if(!this.namedRafs_.has(e))return;this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e)}cancelAnimationFrame(e){if(this.rafIds_.has(e))this.rafIds_.delete(e),V.default.cancelAnimationFrame(e);return e}clearTimersOnDispose_(){if(this.clearingTimersOnDispose_)return;this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((a,n)=>this[t](n))}),this.clearingTimersOnDispose_=!1})}getIsDisabled(){return Boolean(this.el_.disabled)}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(s){let i=V.default.getComputedStyle(s,null),f=i.getPropertyValue("visibility");return i.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(f)}function a(s){if(!t(s.parentElement))return!1;if(!t(s)||s.style.opacity==="0"||V.default.getComputedStyle(s).height==="0px"||V.default.getComputedStyle(s).width==="0px")return!1;return!0}function n(s){if(s.offsetWidth+s.offsetHeight+s.getBoundingClientRect().height+s.getBoundingClientRect().width===0)return!1;let i={x:s.getBoundingClientRect().left+s.offsetWidth/2,y:s.getBoundingClientRect().top+s.offsetHeight/2};if(i.x<0)return!1;if(i.x>(ye.default.documentElement.clientWidth||V.default.innerWidth))return!1;if(i.y<0)return!1;if(i.y>(ye.default.documentElement.clientHeight||V.default.innerHeight))return!1;let f=ye.default.elementFromPoint(i.x,i.y);while(f){if(f===s)return!0;if(f.parentNode)f=f.parentNode;else return!1}}if(!e)e=this.el();if(n(e)&&a(e)&&(!e.parentElement||e.tabIndex>=0))return!0;return!1}static registerComponent(e,t){if(typeof e!=="string"||!e)throw Error(`Illegal component name, "${e}"; must be a non-empty string.`);let a=me.getComponent("Tech"),n=a&&a.isTech(t),s=me===t||me.prototype.isPrototypeOf(t.prototype);if(n||!s){let f;if(n)f="techs must be registered using Tech.registerTech()";else f="must be a Component subclass";throw Error(`Illegal component, "${e}"; ${f}.`)}if(e=Na(e),!me.components_)me.components_={};let i=me.getComponent("Player");if(e==="Player"&&i&&i.players){let f=i.players,l=Object.keys(f);if(f&&l.length>0){for(let c=0;c<l.length;c++)if(f[l[c]]!==null)throw Error("Can not register Player component after player has been created.")}}return me.components_[e]=t,me.components_[yh(e)]=t,t}static getComponent(e){if(!e||!me.components_)return;return me.components_[e]}}me.registerComponent("Component",me);function FT(e,t,a){if(typeof t!=="number"||t<0||t>a)throw Error(`Failed to execute '${e}' on 'TimeRanges': The index provided (${t}) is non-numeric or out of bounds (0-${a}).`)}function cd(e,t,a,n){return FT(e,n,a.length-1),a[n][t]}function K6(e){let t;if(e===void 0||e.length===0)t={length:0,start(){throw Error("This TimeRanges object is empty")},end(){throw Error("This TimeRanges object is empty")}};else t={length:e.length,start:cd.bind(null,"start",0,e),end:cd.bind(null,"end",1,e)};if(V.default.Symbol&&V.default.Symbol.iterator)t[V.default.Symbol.iterator]=()=>(e||[]).values();return t}function Hi(e,t){if(Array.isArray(e))return K6(e);else if(e===void 0||t===void 0)return K6();return K6([[e,t]])}var Fj=function(e,t){e=e<0?0:e;let a=Math.floor(e%60),n=Math.floor(e/60%60),s=Math.floor(e/3600),i=Math.floor(t/60%60),f=Math.floor(t/3600);if(isNaN(e)||e===1/0)s=n=a="-";return s=s>0||f>0?s+":":"",n=((s||i>=10)&&n<10?"0"+n:n)+":",a=a<10?"0"+a:a,s+n+a},N4=Fj;function Oj(e){N4=e}function Bj(){N4=Fj}function _r(e,t=e){return N4(e,t)}var OT=Object.freeze({__proto__:null,createTimeRanges:Hi,createTimeRange:Hi,setFormatTime:Oj,resetFormatTime:Bj,formatTime:_r});function Tj(e,t){let a=0,n,s;if(!t)return 0;if(!e||!e.length)e=Hi(0,0);for(let i=0;i<e.length;i++){if(n=e.start(i),s=e.end(i),s>t)s=t;a+=s-n}return a/t}function Ba(e){if(e instanceof Ba)return e;if(typeof e==="number")this.code=e;else if(typeof e==="string")this.message=e;else if(r0(e)){if(typeof e.code==="number")this.code=e.code;Object.assign(this,e)}if(!this.message)this.message=Ba.defaultMessages[this.code]||""}Ba.prototype.code=0;Ba.prototype.message="";Ba.prototype.status=null;Ba.prototype.metadata=null;Ba.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Ba.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Ba.MEDIA_ERR_CUSTOM=0;Ba.prototype.MEDIA_ERR_CUSTOM=0;Ba.MEDIA_ERR_ABORTED=1;Ba.prototype.MEDIA_ERR_ABORTED=1;Ba.MEDIA_ERR_NETWORK=2;Ba.prototype.MEDIA_ERR_NETWORK=2;Ba.MEDIA_ERR_DECODE=3;Ba.prototype.MEDIA_ERR_DECODE=3;Ba.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Ba.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Ba.MEDIA_ERR_ENCRYPTED=5;Ba.prototype.MEDIA_ERR_ENCRYPTED=5;function Sh(e){return e!==void 0&&e!==null&&typeof e.then==="function"}function s0(e){if(Sh(e))e.then(null,(t)=>{})}var u4=function(e){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((a,n,s)=>{if(e[n])a[n]=e[n];return a},{cues:e.cues&&Array.prototype.map.call(e.cues,function(a){return{startTime:a.startTime,endTime:a.endTime,text:a.text,id:a.id}})})},BT=function(e){let t=e.$$("track"),a=Array.prototype.map.call(t,(s)=>s.track);return Array.prototype.map.call(t,function(s){let i=u4(s.track);if(s.src)i.src=s.src;return i}).concat(Array.prototype.filter.call(e.textTracks(),function(s){return a.indexOf(s)===-1}).map(u4))},TT=function(e,t){return e.forEach(function(a){let n=t.addRemoteTextTrack(a).track;if(!a.src&&a.cues)a.cues.forEach((s)=>n.addCue(s))}),t.textTracks()},m4={textTracksToJson:BT,jsonToTextTracks:TT,trackToJson:u4},L6="vjs-modal-dialog";class Fr extends me{constructor(e,t){super(e,t);this.handleKeyDown_=(a)=>this.handleKeyDown(a),this.close_=(a)=>this.close(a),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=tt("div",{className:`${L6}-content`},{role:"document"}),this.descEl_=tt("p",{className:`${L6}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),hl(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${L6} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");if(this.closeable())e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.");return e}open(){if(this.opened_){if(this.options_.fillAlways)this.fill();return}let e=this.player();if(this.trigger("beforemodalopen"),this.opened_=!0,this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)this.fill();if(this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_)e.pause();this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){if(typeof e==="boolean")this[e?"open":"close"]();return this.opened_}close(){if(!this.opened_)return;let e=this.player();if(this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen)e.play();if(this.off("keydown",this.handleKeyDown_),this.hadControls_)e.controls(!0);if(this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary)this.dispose()}closeable(e){if(typeof e==="boolean"){let t=this.closeable_=!!e,a=this.getChild("closeButton");if(t&&!a){let n=this.contentEl_;this.contentEl_=this.el_,a=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=n,this.on(a,"close",this.close_)}if(!t&&a)this.off(a,"close",this.close_),this.removeChild(a),a.dispose()}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){let t=this.contentEl(),a=t.parentNode,n=t.nextSibling;if(this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,a.removeChild(t),this.empty(),bj(t,e),this.trigger("modalfill"),n)a.insertBefore(t,n);else a.appendChild(t);let s=this.getChild("closeButton");if(s)a.appendChild(s.el_);this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),nm(this.contentEl()),this.trigger("modalempty")}content(e){if(typeof e<"u")this.content_=e;return this.content_}conditionalFocus_(){let e=ye.default.activeElement,t=this.player_.el_;if(this.previouslyActiveEl_=null,t.contains(e)||t===e)this.previouslyActiveEl_=e,this.focus()}conditionalBlur_(){if(this.previouslyActiveEl_)this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let t=this.focusableEls_(),a=this.el_.querySelector(":focus"),n;for(let s=0;s<t.length;s++)if(a===t[s]){n=s;break}if(ye.default.activeElement===this.el_)n=0;if(e.shiftKey&&n===0)t[t.length-1].focus(),e.preventDefault();else if(!e.shiftKey&&n===t.length-1)t[0].focus(),e.preventDefault()}focusableEls_(){let e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,(t)=>{return(t instanceof V.default.HTMLAnchorElement||t instanceof V.default.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof V.default.HTMLInputElement||t instanceof V.default.HTMLSelectElement||t instanceof V.default.HTMLTextAreaElement||t instanceof V.default.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof V.default.HTMLIFrameElement||t instanceof V.default.HTMLObjectElement||t instanceof V.default.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable")})}}Fr.prototype.options_={pauseOnOpen:!0,temporary:!0};me.registerComponent("ModalDialog",Fr);class cl extends ys{constructor(e=[]){super();this.tracks_=[];for(let t=0;t<e.length;t++)this.addTrack(e[t])}get length(){return this.tracks_.length}addTrack(e){let t=this.tracks_.length;if(!(""+t in this))Object.defineProperty(this,t,{get(){return this.tracks_[t]}});if(this.tracks_.indexOf(e)===-1)this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this});if(e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},tf(e))e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let a=0,n=this.length;a<n;a++)if(this[a]===e){if(t=this[a],t.off)t.off();this.tracks_.splice(a,1);break}if(!t)return;this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let a=0,n=this.length;a<n;a++){let s=this[a];if(s.id===e){t=s;break}}return t}}cl.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(let e in cl.prototype.allowedEvents_)cl.prototype["on"+e]=null;var V6=function(e,t){for(let a=0;a<e.length;a++){if(!Object.keys(e[a]).length||t.id===e[a].id)continue;e[a].enabled=!1}};class E4 extends cl{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){V6(e,e[t]);break}super(e);this.changing_=!1}addTrack(e){if(e.enabled)V6(this,e);if(super.addTrack(e),!e.addEventListener)return;e.enabledChange_=()=>{if(this.changing_)return;this.changing_=!0,V6(this,e),this.changing_=!1,this.trigger("change")},e.addEventListener("enabledchange",e.enabledChange_)}removeTrack(e){if(super.removeTrack(e),e.removeEventListener&&e.enabledChange_)e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null}}var Y6=function(e,t){for(let a=0;a<e.length;a++){if(!Object.keys(e[a]).length||t.id===e[a].id)continue;e[a].selected=!1}};class z4 extends cl{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Y6(e,e[t]);break}super(e);this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){if(e.selected)Y6(this,e);if(super.addTrack(e),!e.addEventListener)return;e.selectedChange_=()=>{if(this.changing_)return;this.changing_=!0,Y6(this,e),this.changing_=!1,this.trigger("change")},e.addEventListener("selectedchange",e.selectedChange_)}removeTrack(e){if(super.removeTrack(e),e.removeEventListener&&e.selectedChange_)e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null}}class lm extends cl{addTrack(e){if(super.addTrack(e),!this.queueChange_)this.queueChange_=()=>this.queueTrigger("change");if(!this.triggerSelectedlanguagechange)this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange");if(e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1)e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){if(super.removeTrack(e),e.removeEventListener){if(this.queueChange_)e.removeEventListener("modechange",this.queueChange_);if(this.selectedlanguagechange_)e.removeEventListener("modechange",this.triggerSelectedlanguagechange_)}}toJSON(){return this.tracks_.map((e)=>e.toJSON())}}class Hj{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,a=e.length;t<a;t++)this.addTrackElement_(e[t])}addTrackElement_(e){let t=this.trackElements_.length;if(!(""+t in this))Object.defineProperty(this,t,{get(){return this.trackElements_[t]}});if(this.trackElements_.indexOf(e)===-1)this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let a=0,n=this.trackElements_.length;a<n;a++)if(e===this.trackElements_[a].track){t=this.trackElements_[a];break}return t}removeTrackElement_(e){for(let t=0,a=this.trackElements_.length;t<a;t++)if(e===this.trackElements_[t]){if(this.trackElements_[t].track&&typeof this.trackElements_[t].track.off==="function")this.trackElements_[t].track.off();if(typeof this.trackElements_[t].off==="function")this.trackElements_[t].off();this.trackElements_.splice(t,1);break}}}class x9{constructor(e){x9.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){let t=this.length||0,a=0,n=e.length;this.cues_=e,this.length_=e.length;let s=function(i){if(!(""+i in this))Object.defineProperty(this,""+i,{get(){return this.cues_[i]}})};if(t<n){a=t;for(;a<n;a++)s.call(this,a)}}getCueById(e){let t=null;for(let a=0,n=this.length;a<n;a++){let s=this[a];if(s.id===e){t=s;break}}return t}}var HT={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},MT={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},DT={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},hd={disabled:"disabled",hidden:"hidden",showing:"showing"};class rm extends ys{constructor(e={}){super();let t={id:e.id||"vjs_track_"+ui(),kind:e.kind||"",language:e.language||""},a=e.label||"";for(let n in t)Object.defineProperty(this,n,{get(){return t[n]},set(){}});Object.defineProperty(this,"label",{get(){return a},set(n){if(n!==a)a=n,this.trigger("labelchange")}})}}var U4=function(e){return new URL(e,ye.default.baseURI)},Mj=function(e){return new URL(e,ye.default.baseURI).href},I4=function(e){if(typeof e==="string"){let a=e.split("?")[0].replace(/\/+$/,"").match(/\.([^.\/]+)$/);return a?a[1].toLowerCase():""}return""},om=function(e,t=V.default.location){return U4(e).origin!==t.origin},xT=Object.freeze({__proto__:null,parseUrl:U4,getAbsoluteURL:Mj,getFileExtension:I4,isCrossOrigin:om}),ud=function(e,t){let a=new V.default.WebVTT.Parser(V.default,V.default.vttjs,V.default.WebVTT.StringDecoder()),n=[];if(a.oncue=function(s){t.addCue(s)},a.onparsingerror=function(s){n.push(s)},a.onflush=function(){t.trigger({type:"loadeddata",target:t})},a.parse(e),n.length>0){if(V.default.console&&V.default.console.groupCollapsed)V.default.console.groupCollapsed(`Text Track parsing errors for ${t.src}`);if(n.forEach((s)=>qt.error(s)),V.default.console&&V.default.console.groupEnd)V.default.console.groupEnd()}a.flush()},md=function(e,t){let a={uri:e},n=om(e);if(n)a.cors=n;let s=t.tech_.crossOrigin()==="use-credentials";if(s)a.withCredentials=s;B4.default(a,ua(this,function(i,f,l){if(i)return qt.error(i,f);if(t.loaded_=!0,typeof V.default.WebVTT!=="function"){if(t.tech_)t.tech_.any(["vttjsloaded","vttjserror"],(c)=>{if(c.type==="vttjserror"){qt.error(`vttjs failed to load, stopping trying to process ${t.src}`);return}return ud(l,t)})}else ud(l,t)}))};class jo extends rm{constructor(e={}){if(!e.tech)throw Error("A tech was not provided.");let t=sa(e,{kind:DT[e.kind]||"subtitles",language:e.language||e.srclang||""}),a=hd[t.mode]||"disabled",n=t.default;if(t.kind==="metadata"||t.kind==="chapters")a="hidden";super(t);this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;let s=new x9(this.cues_),i=new x9(this.activeCues_),f=!1;this.timeupdateHandler=ua(this,function(c={}){if(this.tech_.isDisposed())return;if(!this.tech_.isReady_){if(c.type!=="timeupdate")this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler);return}if(this.activeCues=this.activeCues,f)this.trigger("cuechange"),f=!1;if(c.type!=="timeupdate")this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler)});let l=()=>{this.stopTracking()};if(this.tech_.one("dispose",l),a!=="disabled")this.startTracking();if(Object.defineProperties(this,{default:{get(){return n},set(){}},mode:{get(){return a},set(c){if(!hd[c])return;if(a===c)return;if(a=c,!this.preload_&&a!=="disabled"&&this.cues.length===0)md(this.src,this);if(this.stopTracking(),a!=="disabled")this.startTracking();this.trigger("modechange")}},cues:{get(){if(!this.loaded_)return null;return s},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return i;let c=this.tech_.currentTime(),h=[];for(let u=0,g=this.cues.length;u<g;u++){let b=this.cues[u];if(b.startTime<=c&&b.endTime>=c)h.push(b)}if(f=!1,h.length!==this.activeCues_.length)f=!0;else for(let u=0;u<h.length;u++)if(this.activeCues_.indexOf(h[u])===-1)f=!0;return this.activeCues_=h,i.setCues_(this.activeCues_),i},set(){}}}),t.src){if(this.src=t.src,!this.preload_)this.loaded_=!0;if(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")md(this.src,this)}else this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){if(this.rvf_)this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0;this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new V.default.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(let n in e)if(!(n in t))t[n]=e[n];t.id=e.id,t.originalCue_=e}let a=this.tech_.textTracks();for(let n=0;n<a.length;n++)if(a[n]!==this)a[n].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}toJSON(){return m4.trackToJson(this)}removeCue(e){let t=this.cues_.length;while(t--){let a=this.cues_[t];if(a===e||a.originalCue_&&a.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}jo.prototype.allowedEvents_={cuechange:"cuechange"};class G4 extends rm{constructor(e={}){let t=sa(e,{kind:MT[e.kind]||""});super(t);let a=!1;if(Object.defineProperty(this,"enabled",{get(){return a},set(n){if(typeof n!=="boolean"||n===a)return;a=n,this.trigger("enabledchange")}}),t.enabled)this.enabled=t.enabled;this.loaded_=!0}}class X4 extends rm{constructor(e={}){let t=sa(e,{kind:HT[e.kind]||""});super(t);let a=!1;if(Object.defineProperty(this,"selected",{get(){return a},set(n){if(typeof n!=="boolean"||n===a)return;a=n,this.trigger("selectedchange")}}),t.selected)this.selected=t.selected}}class af extends ys{constructor(e={}){super();let t,a=new jo(e);this.kind=a.kind,this.src=a.src,this.srclang=a.language,this.label=a.label,this.default=a.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return a}}}),t=af.NONE,a.addEventListener("loadeddata",()=>{t=af.LOADED,this.trigger({type:"load",target:this})})}}af.prototype.allowedEvents_={load:"load"};af.NONE=0;af.LOADING=1;af.LOADED=2;af.ERROR=3;var hi={audio:{ListClass:E4,TrackClass:G4,capitalName:"Audio"},video:{ListClass:z4,TrackClass:X4,capitalName:"Video"},text:{ListClass:lm,TrackClass:jo,capitalName:"Text"}};Object.keys(hi).forEach(function(e){hi[e].getterName=`${e}Tracks`,hi[e].privateName=`${e}Tracks_`});var go={remoteText:{ListClass:lm,TrackClass:jo,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:Hj,TrackClass:af,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},as=Object.assign({},hi,go);go.names=Object.keys(go);hi.names=Object.keys(hi);as.names=[].concat(go.names).concat(hi.names);function RT(e,t,a,n,s={}){let i=e.textTracks();if(s.kind=t,a)s.label=a;if(n)s.language=n;s.tech=e;let f=new as.text.TrackClass(s);return i.addTrack(f),f}class ut extends me{constructor(e={},t=function(){}){e.reportTouchActivity=!1;super(null,e,t);if(this.onDurationChange_=(a)=>this.onDurationChange(a),this.trackProgress_=(a)=>this.trackProgress(a),this.trackCurrentTime_=(a)=>this.trackCurrentTime(a),this.stopTrackingCurrentTime_=(a)=>this.stopTrackingCurrentTime(a),this.disposeSourceHandler_=(a)=>this.disposeSourceHandler(a),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),as.names.forEach((a)=>{let n=as[a];if(e&&e[n.getterName])this[n.privateName]=e[n.getterName]}),!this.featuresProgressEvents)this.manualProgressOn();if(!this.featuresTimeupdateEvents)this.manualTimeUpdatesOn();if(["Text","Audio","Video"].forEach((a)=>{if(e[`native${a}Tracks`]===!1)this[`featuresNative${a}Tracks`]=!1}),e.nativeCaptions===!1||e.nativeTextTracks===!1)this.featuresNativeTextTracks=!1;else if(e.nativeCaptions===!0||e.nativeTextTracks===!0)this.featuresNativeTextTracks=!0;if(!this.featuresNativeTextTracks)this.emulateTextTracks();if(this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new as.text.ListClass,this.initTrackListeners(),!e.nativeControlsForTouch)this.emitTapEvents();if(this.constructor)this.name_=this.constructor.name||"Unknown Tech"}triggerSourceset(e){if(!this.isReady_)this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1));this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(ua(this,function(){let t=this.bufferedPercent();if(this.bufferedPercent_!==t)this.trigger("progress");if(this.bufferedPercent_=t,t===1)this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return Hi(0,0)}bufferedPercent(){return Tj(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){if(this.currentTimeInterval)this.stopTrackingCurrentTime();this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){if(this.clearTracks(hi.names),this.manualProgress)this.manualProgressOff();if(this.manualTimeUpdates)this.manualTimeUpdatesOff();super.dispose()}clearTracks(e){e=[].concat(e),e.forEach((t)=>{let a=this[`${t}Tracks`]()||[],n=a.length;while(n--){let s=a[n];if(t==="text")this.removeRemoteTextTrack(s);a.removeTrack(s)}})}cleanupAutoTextTracks(){let e=this.autoRemoteTextTracks_||[],t=e.length;while(t--){let a=e[t];this.removeRemoteTextTrack(a)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){if(e!==void 0)this.error_=new Ba(e),this.trigger("error");return this.error_}played(){if(this.hasStarted_)return Hi(0,0);return Hi()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){if(this.manualTimeUpdates)this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){hi.names.forEach((e)=>{let t=hi[e],a=()=>{this.trigger(`${e}trackchange`)},n=this[t.getterName]();n.addEventListener("removetrack",a),n.addEventListener("addtrack",a),this.on("dispose",()=>{n.removeEventListener("removetrack",a),n.removeEventListener("addtrack",a)})})}addWebVttScript_(){if(V.default.WebVTT)return;if(ye.default.body.contains(this.el())){if(!this.options_["vtt.js"]&&co(s4.default)&&Object.keys(s4.default).length>0){this.trigger("vttjsloaded");return}let e=ye.default.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),V.default.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){let e=this.textTracks(),t=this.remoteTextTracks(),a=(f)=>e.addTrack(f.track),n=(f)=>e.removeTrack(f.track);t.on("addtrack",a),t.on("removetrack",n),this.addWebVttScript_();let s=()=>this.trigger("texttrackchange"),i=()=>{s();for(let f=0;f<e.length;f++){let l=e[f];if(l.removeEventListener("cuechange",s),l.mode==="showing")l.addEventListener("cuechange",s)}};i(),e.addEventListener("change",i),e.addEventListener("addtrack",i),e.addEventListener("removetrack",i),this.on("dispose",function(){t.off("addtrack",a),t.off("removetrack",n),e.removeEventListener("change",i),e.removeEventListener("addtrack",i),e.removeEventListener("removetrack",i);for(let f=0;f<e.length;f++)e[f].removeEventListener("cuechange",s)})}addTextTrack(e,t,a){if(!e)throw Error("TextTrack kind is required but was not provided");return RT(this,e,t,a)}createRemoteTextTrack(e){let t=sa(e,{tech:this});return new go.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){let a=this.createRemoteTextTrack(e);if(typeof t!=="boolean")t=!1;if(this.remoteTextTrackEls().addTrackElement_(a),this.remoteTextTracks().addTrack(a.track),t===!1)this.ready(()=>this.autoRemoteTextTracks_.addTrack(a.track));return a}removeRemoteTextTrack(e){let t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){let t=ui();if(!this.isReady_||this.paused())this.queuedHanders_.add(t),this.one("playing",()=>{if(this.queuedHanders_.has(t))this.queuedHanders_.delete(t),e()});else this.requestNamedAnimationFrame(t,e);return t}cancelVideoFrameCallback(e){if(this.queuedHanders_.has(e))this.queuedHanders_.delete(e);else this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return ut.canPlayType(e.type)}static isTech(e){return e.prototype instanceof ut||e instanceof ut||e===ut}static registerTech(e,t){if(!ut.techs_)ut.techs_={};if(!ut.isTech(t))throw Error(`Tech ${e} must be a Tech`);if(!ut.canPlayType)throw Error("Techs must have a static canPlayType method on them");if(!ut.canPlaySource)throw Error("Techs must have a static canPlaySource method on them");if(e=Na(e),ut.techs_[e]=t,ut.techs_[yh(e)]=t,e!=="Tech")ut.defaultTechOrder_.push(e);return t}static getTech(e){if(!e)return;if(ut.techs_&&ut.techs_[e])return ut.techs_[e];if(e=Na(e),V.default&&V.default.videojs&&V.default.videojs[e])return qt.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),V.default.videojs[e]}}as.names.forEach(function(e){let t=as[e];ut.prototype[t.getterName]=function(){return this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName]}});ut.prototype.featuresVolumeControl=!0;ut.prototype.featuresMuteControl=!0;ut.prototype.featuresFullscreenResize=!1;ut.prototype.featuresPlaybackRate=!1;ut.prototype.featuresProgressEvents=!1;ut.prototype.featuresSourceset=!1;ut.prototype.featuresTimeupdateEvents=!1;ut.prototype.featuresNativeTextTracks=!1;ut.prototype.featuresVideoFrameCallback=!1;ut.withSourceHandlers=function(e){e.registerSourceHandler=function(a,n){let s=e.sourceHandlers;if(!s)s=e.sourceHandlers=[];if(n===void 0)n=s.length;s.splice(n,0,a)},e.canPlayType=function(a){let n=e.sourceHandlers||[],s;for(let i=0;i<n.length;i++)if(s=n[i].canPlayType(a),s)return s;return""},e.selectSourceHandler=function(a,n){let s=e.sourceHandlers||[],i;for(let f=0;f<s.length;f++)if(i=s[f].canHandleSource(a,n),i)return s[f];return null},e.canPlaySource=function(a,n){let s=e.selectSourceHandler(a,n);if(s)return s.canHandleSource(a,n);return""},["seekable","seeking","duration"].forEach(function(a){let n=this[a];if(typeof n!=="function")return;this[a]=function(){if(this.sourceHandler_&&this.sourceHandler_[a])return this.sourceHandler_[a].apply(this.sourceHandler_,arguments);return n.apply(this,arguments)}},e.prototype),e.prototype.setSource=function(a){let n=e.selectSourceHandler(a,this.options_);if(!n)if(e.nativeSourceHandler)n=e.nativeSourceHandler;else qt.error("No source handler found for the current source.");if(this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),n!==e.nativeSourceHandler)this.currentSource_=a;this.sourceHandler_=n.handleSource(a,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},e.prototype.disposeSourceHandler=function(){if(this.currentSource_)this.clearTracks(["audio","video"]),this.currentSource_=null;if(this.cleanupAutoTextTracks(),this.sourceHandler_){if(this.sourceHandler_.dispose)this.sourceHandler_.dispose();this.sourceHandler_=null}}};me.registerComponent("Tech",ut);ut.registerTech("Tech",ut);ut.defaultTechOrder_=[];var Sr={},R9={},N9={};function NT(e,t){Sr[e]=Sr[e]||[],Sr[e].push(t)}function ET(e,t,a){e.setTimeout(()=>qr(t,Sr[t.type],a,e),1)}function zT(e,t){e.forEach((a)=>a.setTech&&a.setTech(t))}function UT(e,t,a){return e.reduceRight(K4(a),t[a]())}function IT(e,t,a,n){return t[a](e.reduce(K4(a),n))}function gd(e,t,a,n=null){let s="call"+Na(a),i=e.reduce(K4(s),n),f=i===N9,l=f?null:t[a](i);return KT(e,a,l,f),l}var GT={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},XT={setCurrentTime:1,setMuted:1,setVolume:1},pd={play:1,pause:1};function K4(e){return(t,a)=>{if(t===N9)return N9;if(a[e])return a[e](t);return t}}function KT(e,t,a,n){for(let s=e.length-1;s>=0;s--){let i=e[s];if(i[t])i[t](n,a)}}function LT(e){if(R9.hasOwnProperty(e.id()))delete R9[e.id()]}function VT(e,t){let a=R9[e.id()],n=null;if(a===void 0||a===null)return n=t(e),R9[e.id()]=[[t,n]],n;for(let s=0;s<a.length;s++){let[i,f]=a[s];if(i!==t)continue;n=f}if(n===null)n=t(e),a.push([t,n]);return n}function qr(e={},t=[],a,n,s=[],i=!1){let[f,...l]=t;if(typeof f==="string")qr(e,Sr[f],a,n,s,i);else if(f){let c=VT(n,f);if(!c.setSource)return s.push(c),qr(e,l,a,n,s,i);c.setSource(Object.assign({},e),function(h,u){if(h)return qr(e,l,a,n,s,i);s.push(c),qr(u,e.type===u.type?l:Sr[u.type],a,n,s,i)})}else if(l.length)qr(e,l,a,n,s,i);else if(i)a(e,s);else qr(e,Sr["*"],a,n,s,!0)}var YT={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},E9=function(e=""){let t=I4(e);return YT[t.toLowerCase()]||""},JT=(e,t)=>{if(!t)return"";if(e.cache_.source.src===t&&e.cache_.source.type)return e.cache_.source.type;let a=e.cache_.sources.filter((s)=>s.src===t);if(a.length)return a[0].type;let n=e.$$("source");for(let s=0;s<n.length;s++){let i=n[s];if(i.type&&i.src&&i.src===t)return i.type}return E9(t)},Dj=function(e){if(Array.isArray(e)){let t=[];e.forEach(function(a){if(a=Dj(a),Array.isArray(a))t=t.concat(a);else if(r0(a))t.push(a)}),e=t}else if(typeof e==="string"&&e.trim())e=[bd({src:e})];else if(r0(e)&&typeof e.src==="string"&&e.src&&e.src.trim())e=[bd(e)];else e=[];return e};function bd(e){if(!e.type){let t=E9(e.src);if(t)e.type=t}return e}var QT=`<svg xmlns="http://www.w3.org/2000/svg">
37
+ <defs>
38
+ <symbol viewBox="0 0 48 48" id="vjs-icon-play">
39
+ <path d="M16 10v28l22-14z"></path>
40
+ </symbol>
41
+ <symbol viewBox="0 0 48 48" id="vjs-icon-pause">
42
+ <path d="M12 38h8V10h-8v28zm16-28v28h8V10h-8z"></path>
43
+ </symbol>
44
+ <symbol viewBox="0 0 48 48" id="vjs-icon-audio">
45
+ <path d="M24 2C14.06 2 6 10.06 6 20v14c0 3.31 2.69 6 6 6h6V24h-8v-4c0-7.73 6.27-14 14-14s14 6.27 14 14v4h-8v16h6c3.31 0 6-2.69 6-6V20c0-9.94-8.06-18-18-18z"></path>
46
+ </symbol>
47
+ <symbol viewBox="0 0 48 48" id="vjs-icon-captions">
48
+ <path d="M38 8H10c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM22 22h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2zm14 0h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2z"></path>
49
+ </symbol>
50
+ <symbol viewBox="0 0 48 48" id="vjs-icon-subtitles">
51
+ <path d="M40 8H8c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM8 24h8v4H8v-4zm20 12H8v-4h20v4zm12 0h-8v-4h8v4zm0-8H20v-4h20v4z"></path>
52
+ </symbol>
53
+ <symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-enter">
54
+ <path d="M14 28h-4v10h10v-4h-6v-6zm-4-8h4v-6h6v-4H10v10zm24 14h-6v4h10V28h-4v6zm-6-24v4h6v6h4V10H28z"></path>
55
+ </symbol>
56
+ <symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-exit">
57
+ <path d="M10 32h6v6h4V28H10v4zm6-16h-6v4h10V10h-4v6zm12 22h4v-6h6v-4H28v10zm4-22v-6h-4v10h10v-4h-6z"></path>
58
+ </symbol>
59
+ <symbol viewBox="0 0 48 48" id="vjs-icon-play-circle">
60
+ <path d="M20 33l12-9-12-9v18zm4-29C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>
61
+ </symbol>
62
+ <symbol viewBox="0 0 48 48" id="vjs-icon-volume-mute">
63
+ <path d="M33 24c0-3.53-2.04-6.58-5-8.05v4.42l4.91 4.91c.06-.42.09-.85.09-1.28zm5 0c0 1.88-.41 3.65-1.08 5.28l3.03 3.03C41.25 29.82 42 27 42 24c0-8.56-5.99-15.72-14-17.54v4.13c5.78 1.72 10 7.07 10 13.41zM8.55 6L6 8.55 15.45 18H6v12h8l10 10V26.55l8.51 8.51c-1.34 1.03-2.85 1.86-4.51 2.36v4.13a17.94 17.94 0 0 0 7.37-3.62L39.45 42 42 39.45l-18-18L8.55 6zM24 8l-4.18 4.18L24 16.36V8z"></path>
64
+ </symbol>
65
+ <symbol viewBox="0 0 48 48" id="vjs-icon-volume-low">
66
+ <path d="M14 18v12h8l10 10V8L22 18h-8z"></path>
67
+ </symbol>
68
+ <symbol viewBox="0 0 48 48" id="vjs-icon-volume-medium">
69
+ <path d="M37 24c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zm-27-6v12h8l10 10V8L18 18h-8z"></path>
70
+ </symbol>
71
+ <symbol viewBox="0 0 48 48" id="vjs-icon-volume-high">
72
+ <path d="M6 18v12h8l10 10V8L14 18H6zm27 6c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zM28 6.46v4.13c5.78 1.72 10 7.07 10 13.41s-4.22 11.69-10 13.41v4.13c8.01-1.82 14-8.97 14-17.54S36.01 8.28 28 6.46z"></path>
73
+ </symbol>
74
+ <symbol viewBox="0 0 48 48" id="vjs-icon-spinner">
75
+ <path d="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64 4.51l7.33 12.69.11-.2zm24.28-3c-1.84-5.85-6.3-10.52-11.99-12.68L23.77 18h19.31zm.52 2H28.62l.58 1 9.53 16.5C41.99 33.94 44 29.21 44 24c0-1.37-.14-2.71-.4-4zm-26.53 4l-7.8-13.5C6.01 14.06 4 18.79 4 24c0 1.37.14 2.71.4 4h14.98l-2.31-4zM4.92 30c1.84 5.85 6.3 10.52 11.99 12.68L24.23 30H4.92zm22.54 0l-7.8 13.51c1.4.31 2.85.49 4.34.49 4.8 0 9.19-1.69 12.64-4.51L29.31 26.8 27.46 30z"></path>
76
+ </symbol>
77
+ <symbol viewBox="0 0 24 24" id="vjs-icon-hd">
78
+ <path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm2-6h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1h-4V9zm1.5 4.5h2v-3h-2v3z"></path>
79
+ </symbol>
80
+ <symbol viewBox="0 0 48 48" id="vjs-icon-chapters">
81
+ <path d="M6 26h4v-4H6v4zm0 8h4v-4H6v4zm0-16h4v-4H6v4zm8 8h28v-4H14v4zm0 8h28v-4H14v4zm0-20v4h28v-4H14z"></path>
82
+ </symbol>
83
+ <symbol viewBox="0 0 40 40" id="vjs-icon-downloading">
84
+ <path d="M18.208 36.875q-3.208-.292-5.979-1.729-2.771-1.438-4.812-3.729-2.042-2.292-3.188-5.229-1.146-2.938-1.146-6.23 0-6.583 4.334-11.416 4.333-4.834 10.833-5.5v3.166q-5.167.75-8.583 4.646Q6.25 14.75 6.25 19.958q0 5.209 3.396 9.104 3.396 3.896 8.562 4.646zM20 28.417L11.542 20l2.083-2.083 4.917 4.916v-11.25h2.916v11.25l4.875-4.916L28.417 20zm1.792 8.458v-3.167q1.833-.25 3.541-.958 1.709-.708 3.167-1.875l2.333 2.292q-1.958 1.583-4.25 2.541-2.291.959-4.791 1.167zm6.791-27.792q-1.541-1.125-3.25-1.854-1.708-.729-3.541-1.021V3.042q2.5.25 4.77 1.208 2.271.958 4.271 2.5zm4.584 21.584l-2.25-2.25q1.166-1.5 1.854-3.209.687-1.708.937-3.541h3.209q-.292 2.5-1.229 4.791-.938 2.292-2.521 4.209zm.541-12.417q-.291-1.833-.958-3.562-.667-1.73-1.833-3.188l2.375-2.208q1.541 1.916 2.458 4.208.917 2.292 1.167 4.75z"></path>
85
+ </symbol>
86
+ <symbol viewBox="0 0 48 48" id="vjs-icon-file-download">
87
+ <path d="M10.8 40.55q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h26.35v-7.7h3.4v7.7q0 1.4-1 2.4t-2.4 1zM24 32.1L13.9 22.05l2.45-2.45 5.95 5.95V7.15h3.4v18.4l5.95-5.95 2.45 2.45z"></path>
88
+ </symbol>
89
+ <symbol viewBox="0 0 48 48" id="vjs-icon-file-download-done">
90
+ <path d="M9.8 40.5v-3.45h28.4v3.45zm9.2-9.05L7.4 19.85l2.45-2.35L19 26.65l19.2-19.2 2.4 2.4z"></path>
91
+ </symbol>
92
+ <symbol viewBox="0 0 48 48" id="vjs-icon-file-download-off">
93
+ <path d="M4.9 4.75L43.25 43.1 41 45.3l-4.75-4.75q-.05.05-.075.025-.025-.025-.075-.025H10.8q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h22.05l-7-7-1.85 1.8L13.9 21.9l1.85-1.85L2.7 7zm26.75 14.7l2.45 2.45-3.75 3.8-2.45-2.5zM25.7 7.15V21.1l-3.4-3.45V7.15z"></path>
94
+ </symbol>
95
+ <symbol viewBox="0 0 48 48" id="vjs-icon-share">
96
+ <path d="M36 32.17c-1.52 0-2.89.59-3.93 1.54L17.82 25.4c.11-.45.18-.92.18-1.4s-.07-.95-.18-1.4l14.1-8.23c1.07 1 2.5 1.62 4.08 1.62 3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6c0 .48.07.95.18 1.4l-14.1 8.23c-1.07-1-2.5-1.62-4.08-1.62-3.31 0-6 2.69-6 6s2.69 6 6 6c1.58 0 3.01-.62 4.08-1.62l14.25 8.31c-.1.42-.16.86-.16 1.31A5.83 5.83 0 1 0 36 32.17z"></path>
97
+ </symbol>
98
+ <symbol viewBox="0 0 48 48" id="vjs-icon-cog">
99
+ <path d="M38.86 25.95c.08-.64.14-1.29.14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3.49-.84.24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91.37-.99.84l-.75 5.3a14.8 14.8 0 0 0-3.38 1.97L9.9 10.1a1 1 0 0 0-1.22.43l-4 6.93c-.25.43-.14.97.24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31.14 1.95l-4.22 3.31c-.38.3-.49.84-.24 1.28l4 6.93c.25.43.77.61 1.22.43l4.98-2.01c1.03.79 2.16 1.46 3.38 1.97l.75 5.3c.08.47.49.84.99.84h8c.5 0 .91-.37.99-.84l.75-5.3a14.8 14.8 0 0 0 3.38-1.97l4.98 2.01a1 1 0 0 0 1.22-.43l4-6.93c.25-.43.14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path>
100
+ </symbol>
101
+ <symbol viewBox="0 0 48 48" id="vjs-icon-square">
102
+ <path d="M36 8H12c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zm0 28H12V12h24v24z"></path>
103
+ </symbol>
104
+ <symbol viewBox="0 0 48 48" id="vjs-icon-circle">
105
+ <circle cx="24" cy="24" r="20"></circle>
106
+ </symbol>
107
+ <symbol viewBox="0 0 48 48" id="vjs-icon-circle-outline">
108
+ <path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>
109
+ </symbol>
110
+ <symbol viewBox="0 0 48 48" id="vjs-icon-circle-inner-circle">
111
+ <path d="M24 4C12.97 4 4 12.97 4 24s8.97 20 20 20 20-8.97 20-20S35.03 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16zm6-16c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6 6 2.69 6 6z"></path>
112
+ </symbol>
113
+ <symbol viewBox="0 0 48 48" id="vjs-icon-cancel">
114
+ <path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm10 27.17L31.17 34 24 26.83 16.83 34 14 31.17 21.17 24 14 16.83 16.83 14 24 21.17 31.17 14 34 16.83 26.83 24 34 31.17z"></path>
115
+ </symbol>
116
+ <symbol viewBox="0 0 48 48" id="vjs-icon-replay">
117
+ <path d="M24 10V2L14 12l10 10v-8c6.63 0 12 5.37 12 12s-5.37 12-12 12-12-5.37-12-12H8c0 8.84 7.16 16 16 16s16-7.16 16-16-7.16-16-16-16z"></path>
118
+ </symbol>
119
+ <symbol viewBox="0 0 48 48" id="vjs-icon-repeat">
120
+ <path d="M14 14h20v6l8-8-8-8v6H10v12h4v-8zm20 20H14v-6l-8 8 8 8v-6h24V26h-4v8z"></path>
121
+ </symbol>
122
+ <symbol viewBox="0 96 48 48" id="vjs-icon-replay-5">
123
+ <path d="M17.689 98l-8.697 8.696 8.697 8.697 2.486-2.485-4.32-4.319h1.302c4.93 0 9.071 1.722 12.424 5.165 3.352 3.443 5.029 7.638 5.029 12.584h3.55c0-2.958-.553-5.73-1.658-8.313-1.104-2.583-2.622-4.841-4.555-6.774-1.932-1.932-4.19-3.45-6.773-4.555-2.584-1.104-5.355-1.657-8.313-1.657H15.5l4.615-4.615zm-8.08 21.659v13.861h11.357v5.008H9.609V143h12.7c.834 0 1.55-.298 2.146-.894.596-.597.895-1.31.895-2.145v-7.781c0-.835-.299-1.55-.895-2.147a2.929 2.929 0 0 0-2.147-.894h-8.227v-5.096H25.35v-4.384z"></path>
124
+ </symbol>
125
+ <symbol viewBox="0 96 48 48" id="vjs-icon-replay-10">
126
+ <path d="M42.315 125.63c0-4.997-1.694-9.235-5.08-12.713-3.388-3.479-7.571-5.218-12.552-5.218h-1.315l4.363 4.363-2.51 2.51-8.787-8.786L25.221 97l2.45 2.45-4.662 4.663h1.375c2.988 0 5.788.557 8.397 1.673 2.61 1.116 4.892 2.65 6.844 4.602 1.953 1.953 3.487 4.234 4.602 6.844 1.116 2.61 1.674 5.41 1.674 8.398zM8.183 142v-19.657H3.176V117.8h9.643V142zm13.63 0c-1.156 0-2.127-.393-2.912-1.178-.778-.778-1.168-1.746-1.168-2.902v-16.04c0-1.156.393-2.127 1.178-2.912.779-.779 1.746-1.168 2.902-1.168h7.696c1.156 0 2.126.392 2.911 1.177.779.78 1.168 1.747 1.168 2.903v16.04c0 1.156-.392 2.127-1.177 2.912-.779.779-1.746 1.168-2.902 1.168zm.556-4.636h6.583v-15.02H22.37z"></path>
127
+ </symbol>
128
+ <symbol viewBox="0 96 48 48" id="vjs-icon-replay-30">
129
+ <path d="M26.047 97l-8.733 8.732 8.733 8.733 2.496-2.494-4.336-4.338h1.307c4.95 0 9.108 1.73 12.474 5.187 3.367 3.458 5.051 7.668 5.051 12.635h3.565c0-2.97-.556-5.751-1.665-8.346-1.109-2.594-2.633-4.862-4.574-6.802-1.94-1.941-4.208-3.466-6.803-4.575-2.594-1.109-5.375-1.664-8.345-1.664H23.85l4.634-4.634zM2.555 117.531v4.688h10.297v5.25H5.873v4.687h6.979v5.156H2.555V142H13.36c1.061 0 1.95-.395 2.668-1.186.718-.79 1.076-1.772 1.076-2.94v-16.218c0-1.168-.358-2.149-1.076-2.94-.717-.79-1.607-1.185-2.668-1.185zm22.482.14c-1.149 0-2.11.39-2.885 1.165-.78.78-1.172 1.744-1.172 2.893v15.943c0 1.149.388 2.11 1.163 2.885.78.78 1.745 1.172 2.894 1.172h7.649c1.148 0 2.11-.388 2.884-1.163.78-.78 1.17-1.745 1.17-2.894v-15.943c0-1.15-.386-2.111-1.16-2.885-.78-.78-1.746-1.172-2.894-1.172zm.553 4.518h6.545v14.93H25.59z"></path>
130
+ </symbol>
131
+ <symbol viewBox="0 96 48 48" id="vjs-icon-forward-5">
132
+ <path d="M29.508 97l-2.431 2.43 4.625 4.625h-1.364c-2.965 0-5.742.554-8.332 1.66-2.589 1.107-4.851 2.629-6.788 4.566-1.937 1.937-3.458 4.2-4.565 6.788-1.107 2.59-1.66 5.367-1.66 8.331h3.557c0-4.957 1.68-9.16 5.04-12.611 3.36-3.45 7.51-5.177 12.451-5.177h1.304l-4.326 4.33 2.49 2.49 8.715-8.716zm-9.783 21.61v13.89h11.382v5.018H19.725V142h12.727a2.93 2.93 0 0 0 2.15-.896 2.93 2.93 0 0 0 .896-2.15v-7.798c0-.837-.299-1.554-.896-2.152a2.93 2.93 0 0 0-2.15-.896h-8.245V123h11.29v-4.392z"></path>
133
+ </symbol>
134
+ <symbol viewBox="0 96 48 48" id="vjs-icon-forward-10">
135
+ <path d="M23.119 97l-2.386 2.383 4.538 4.538h-1.339c-2.908 0-5.633.543-8.173 1.63-2.54 1.085-4.76 2.577-6.66 4.478-1.9 1.9-3.392 4.12-4.478 6.66-1.085 2.54-1.629 5.264-1.629 8.172h3.49c0-4.863 1.648-8.986 4.944-12.372 3.297-3.385 7.368-5.078 12.216-5.078h1.279l-4.245 4.247 2.443 2.442 8.55-8.55zm-9.52 21.45v4.42h4.871V142h4.513v-23.55zm18.136 0c-1.125 0-2.066.377-2.824 1.135-.764.764-1.148 1.709-1.148 2.834v15.612c0 1.124.38 2.066 1.139 2.824.764.764 1.708 1.145 2.833 1.145h7.489c1.125 0 2.066-.378 2.824-1.136.764-.764 1.145-1.709 1.145-2.833v-15.612c0-1.125-.378-2.067-1.136-2.825-.764-.764-1.708-1.145-2.833-1.145zm.54 4.42h6.408v14.617h-6.407z"></path>
136
+ </symbol>
137
+ <symbol viewBox="0 96 48 48" id="vjs-icon-forward-30">
138
+ <path d="M25.549 97l-2.437 2.434 4.634 4.635H26.38c-2.97 0-5.753.555-8.347 1.664-2.594 1.109-4.861 2.633-6.802 4.574-1.94 1.94-3.465 4.207-4.574 6.802-1.109 2.594-1.664 5.377-1.664 8.347h3.565c0-4.967 1.683-9.178 5.05-12.636 3.366-3.458 7.525-5.187 12.475-5.187h1.307l-4.335 4.338 2.495 2.494 8.732-8.732zm-11.553 20.53v4.689h10.297v5.249h-6.978v4.688h6.978v5.156H13.996V142h10.808c1.06 0 1.948-.395 2.666-1.186.718-.79 1.077-1.771 1.077-2.94v-16.217c0-1.169-.36-2.15-1.077-2.94-.718-.79-1.605-1.186-2.666-1.186zm21.174.168c-1.149 0-2.11.389-2.884 1.163-.78.78-1.172 1.745-1.172 2.894v15.942c0 1.15.388 2.11 1.162 2.885.78.78 1.745 1.17 2.894 1.17h7.649c1.149 0 2.11-.386 2.885-1.16.78-.78 1.17-1.746 1.17-2.895v-15.942c0-1.15-.387-2.11-1.161-2.885-.78-.78-1.745-1.172-2.894-1.172zm.552 4.516h6.542v14.931h-6.542z"></path>
139
+ </symbol>
140
+ <symbol viewBox="0 0 512 512" id="vjs-icon-audio-description">
141
+ <g fill-rule="evenodd"><path d="M227.29 381.351V162.993c50.38-1.017 89.108-3.028 117.631 17.126 27.374 19.342 48.734 56.965 44.89 105.325-4.067 51.155-41.335 94.139-89.776 98.475-24.085 2.155-71.972 0-71.972 0s-.84-1.352-.773-2.568m48.755-54.804c31.43 1.26 53.208-16.633 56.495-45.386 4.403-38.51-21.188-63.552-58.041-60.796v103.612c-.036 1.466.575 2.22 1.546 2.57"></path><path d="M383.78 381.328c13.336 3.71 17.387-11.06 23.215-21.408 12.722-22.571 22.294-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.226 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M425.154 381.328c13.336 3.71 17.384-11.061 23.215-21.408 12.721-22.571 22.291-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.511c-.586 3.874 2.226 7.315 3.866 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M466.26 381.328c13.337 3.71 17.385-11.061 23.216-21.408 12.722-22.571 22.292-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.225 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894M4.477 383.005H72.58l18.573-28.484 64.169-.135s.065 19.413.065 28.62h48.756V160.307h-58.816c-5.653 9.537-140.85 222.697-140.85 222.697zm152.667-145.282v71.158l-40.453-.27 40.453-70.888z"></path></g>
142
+ </symbol>
143
+ <symbol viewBox="0 0 48 48" id="vjs-icon-next-item">
144
+ <path d="M12 36l17-12-17-12v24zm20-24v24h4V12h-4z"></path>
145
+ </symbol>
146
+ <symbol viewBox="0 0 48 48" id="vjs-icon-previous-item">
147
+ <path d="M12 12h4v24h-4zm7 12l17 12V12z"></path>
148
+ </symbol>
149
+ <symbol viewBox="0 0 48 48" id="vjs-icon-shuffle">
150
+ <path d="M21.17 18.34L10.83 8 8 10.83l10.34 10.34 2.83-2.83zM29 8l4.09 4.09L8 37.17 10.83 40l25.09-25.09L40 19V8H29zm.66 18.83l-2.83 2.83 6.26 6.26L29 40h11V29l-4.09 4.09-6.25-6.26z"></path>
151
+ </symbol>
152
+ <symbol viewBox="0 0 48 48" id="vjs-icon-cast">
153
+ <path d="M42 6H6c-2.21 0-4 1.79-4 4v6h4v-6h36v28H28v4h14c2.21 0 4-1.79 4-4V10c0-2.21-1.79-4-4-4zM2 36v6h6c0-3.31-2.69-6-6-6zm0-8v4c5.52 0 10 4.48 10 10h4c0-7.73-6.27-14-14-14zm0-8v4c9.94 0 18 8.06 18 18h4c0-12.15-9.85-22-22-22z"></path>
154
+ </symbol>
155
+ <symbol viewBox="0 0 48 48" id="vjs-icon-picture-in-picture-enter">
156
+ <path d="M38 22H22v11.99h16V22zm8 16V9.96C46 7.76 44.2 6 42 6H6C3.8 6 2 7.76 2 9.96V38c0 2.2 1.8 4 4 4h36c2.2 0 4-1.8 4-4zm-4 .04H6V9.94h36v28.1z"></path>
157
+ </symbol>
158
+ <symbol viewBox="0 0 22 18" id="vjs-icon-picture-in-picture-exit">
159
+ <path d="M18 4H4v10h14V4zm4 12V1.98C22 .88 21.1 0 20 0H2C.9 0 0 .88 0 1.98V16c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zm-2 .02H2V1.97h18v14.05z"></path>
160
+ <path fill="none" d="M-1-3h24v24H-1z"></path>
161
+ </symbol>
162
+ <symbol viewBox="0 0 1792 1792" id="vjs-icon-facebook">
163
+ <path d="M1343 12v264h-157q-86 0-116 36t-30 108v189h293l-39 296h-254v759H734V905H479V609h255V391q0-186 104-288.5T1115 0q147 0 228 12z"></path>
164
+ </symbol>
165
+ <symbol viewBox="0 0 1792 1792" id="vjs-icon-linkedin">
166
+ <path d="M477 625v991H147V625h330zm21-306q1 73-50.5 122T312 490h-2q-82 0-132-49t-50-122q0-74 51.5-122.5T314 148t133 48.5T498 319zm1166 729v568h-329v-530q0-105-40.5-164.5T1168 862q-63 0-105.5 34.5T999 982q-11 30-11 81v553H659q2-399 2-647t-1-296l-1-48h329v144h-2q20-32 41-56t56.5-52 87-43.5T1285 602q171 0 275 113.5t104 332.5z"></path>
167
+ </symbol>
168
+ <symbol viewBox="0 0 1200 1227" id="vjs-icon-twitter">
169
+ <path d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z"/>
170
+ </symbol>
171
+ <symbol viewBox="0 0 1792 1792" id="vjs-icon-tumblr">
172
+ <path d="M1328 1329l80 237q-23 35-111 66t-177 32q-104 2-190.5-26T787 1564t-95-106-55.5-120-16.5-118V676H452V461q72-26 129-69.5t91-90 58-102 34-99T779 12q1-5 4.5-8.5T791 0h244v424h333v252h-334v518q0 30 6.5 56t22.5 52.5 49.5 41.5 81.5 14q78-2 134-29z"></path>
173
+ </symbol>
174
+ <symbol viewBox="0 0 1792 1792" id="vjs-icon-pinterest">
175
+ <path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>
176
+ </symbol>
177
+ </defs>
178
+ </svg>`,wd=T9?10009:H9?461:8,$1={codes:{play:415,pause:19,ff:417,rw:412,back:wd},names:{415:"play",19:"pause",417:"ff",412:"rw",[wd]:"back"},isEventKey(e,t){if(t=t.toLowerCase(),this.names[e.keyCode]&&this.names[e.keyCode]===t)return!0;return!1},getEventName(e){if(this.names[e.keyCode])return this.names[e.keyCode];else if(this.codes[e.code]){let t=this.codes[e.code];return this.names[t]}return null}},dd=5;class xj extends ys{constructor(e){super();this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){if(this.isListening_)return;if(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay)this.player_.errorDisplay.on("aftermodalfill",()=>{if(this.updateFocusableComponents(),this.focusableComponents.length)if(this.focusableComponents.length>1)this.focusableComponents[1].focus();else this.focusableComponents[0].focus()})}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){let t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();let a=t.key.substring(5).toLowerCase();this.move(a)}else if($1.isEventKey(t,"play")||$1.isEventKey(t,"pause")||$1.isEventKey(t,"ff")||$1.isEventKey(t,"rw")){t.preventDefault();let a=$1.getEventName(t);this.performMediaAction_(a)}else if($1.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable==="function"&&e.target.closeable())t.preventDefault(),e.target.close()}performMediaAction_(e){if(this.player_)switch(e){case"play":if(this.player_.paused())this.player_.play();break;case"pause":if(!this.player_.paused())this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+dd);break;case"rw":this.userSeek_(this.player_.currentTime()-dd);break}}userSeek_(e){if(this.player_.liveTracker&&this.player_.liveTracker.isLive())this.player_.liveTracker.nextSeekedFromUser();this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){let t=e.relatedTarget,a=null,n=this.getCurrentComponent(e.target);if(t){if(a=Boolean(t.closest(".video-js")),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_)this.searchForTrackSelect_()}if(!e.currentTarget.contains(e.relatedTarget)&&!a||!t){if(n&&n.name()==="CloseButton")this.refocusComponent();else if(this.pause(),n&&n.el())this.lastFocusedComponent_=n}}handlePlayerFocus_(){if(this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable())this.resume()}updateFocusableComponents(){let e=this.player_,t=[];function a(n){for(let s of n){if(s.hasOwnProperty("el_")&&s.getIsFocusable()&&s.getIsAvailableToBeFocused(s.el()))t.push(s);if(s.hasOwnProperty("children_")&&s.children_.length>0)a(s.children_)}}return e.children_.forEach((n)=>{if(n.hasOwnProperty("el_")){if(n.getIsFocusable&&n.getIsAvailableToBeFocused&&n.getIsFocusable()&&n.getIsAvailableToBeFocused(n.el())){t.push(n);return}else if(n.hasOwnProperty("children_")&&n.children_.length>0)a(n.children_);else if(n.hasOwnProperty("items")&&n.items.length>0)a(n.items);else if(this.findSuitableDOMChild(n))t.push(n)}if(n.name_==="ErrorDisplay"&&n.opened_){let s=n.el_.querySelector(".vjs-errors-ok-button-container");if(s)s.querySelectorAll("button").forEach((f,l)=>{t.push({name:()=>{return"ModalButton"+(l+1)},el:()=>f,getPositions:()=>{let c=f.getBoundingClientRect(),h={x:c.x,y:c.y,width:c.width,height:c.height,top:c.top,right:c.right,bottom:c.bottom,left:c.left},u={x:c.left+c.width/2,y:c.top+c.height/2,width:0,height:0,top:c.top+c.height/2,right:c.left+c.width/2,bottom:c.top+c.height/2,left:c.left+c.width/2};return{boundingClientRect:h,center:u}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:(c)=>!0,focus:()=>f.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(a){if(e.getIsFocusable(a)&&e.getIsAvailableToBeFocused(a))return a;for(let n=0;n<a.children.length;n++){let s=a.children[n],i=t(s);if(i)return i}return null}if(e.el())return t(e.el());return null}getCurrentComponent(e){this.updateFocusableComponents();let t=e||document.activeElement;if(this.focusableComponents.length){for(let a of this.focusableComponents)if(a.el()===t)return a}}add(e){let t=[...this.focusableComponents];if(e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el()))t.push(e);this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){if(this.focusableComponents.length>0)this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}move(e){let t=this.getCurrentComponent();if(!t)return;let a=t.getPositions(),n=this.focusableComponents.filter((i)=>i!==t&&this.isInDirection_(a.boundingClientRect,i.getPositions().boundingClientRect,e)),s=this.findBestCandidate_(a.center,n,e);if(s)this.focus(s);else this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,a){let n=1/0,s=null;for(let i of t){let f=i.getPositions().center,l=this.calculateDistance_(e,f,a);if(l<n)n=l,s=i}return s}isInDirection_(e,t,a){switch(a){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){if(!this.player_.userActive())this.player_.userActive(!0);this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){if(typeof e!=="object")return;if(e.getIsAvailableToBeFocused(e.el()))e.focus();else if(this.findSuitableDOMChild(e))this.findSuitableDOMChild(e).focus()}calculateDistance_(e,t,a){let n=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y),i;switch(a){case"right":case"left":i=n+s*100;break;case"up":i=s*2+n*0.5;break;case"down":i=s*5+n;break;default:i=n+s}return i}searchForTrackSelect_(){let e=this;for(let t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class Rj extends me{constructor(e,t,a){let n=sa({createEl:!1},t);super(e,n,a);if(!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let s=0,i=t.playerOptions.techOrder;s<i.length;s++){let f=Na(i[s]),l=ut.getTech(f);if(!f)l=me.getComponent(f);if(l&&l.isSupported()){e.loadTech_(f);break}}else e.src(t.playerOptions.sources)}}me.registerComponent("MediaLoader",Rj);class Mh extends me{constructor(e,t){super(e,t);if(this.options_.controlText)this.controlText(this.options_.controlText);this.handleMouseOver_=(a)=>this.handleMouseOver(a),this.handleMouseOut_=(a)=>this.handleMouseOut(a),this.handleClick_=(a)=>this.handleClick(a),this.handleKeyDown_=(a)=>this.handleKeyDown(a),this.emitTapEvents(),this.enable()}createEl(e="div",t={},a={}){if(t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button")qt.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`);a=Object.assign({role:"button"},a),this.tabIndex_=t.tabIndex;let n=tt(e,t,a);if(!this.player_.options_.experimentalSvgIcons)n.appendChild(tt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0}));return this.createControlTextEl(n),n}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){if(this.controlTextEl_=tt("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e)e.appendChild(this.controlTextEl_);return this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";let a=this.localize(e);if(this.controlText_=e,hl(this.controlTextEl_,a),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes)t.setAttribute("title",a)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){if(!this.enabled_){if(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u")this.el_.setAttribute("tabIndex",this.tabIndex_);this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_)}}disable(){if(this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u")this.el_.removeAttribute("tabIndex");this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){if(this.options_.clickHandler)this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.trigger("click");else super.handleKeyDown(e)}}me.registerComponent("ClickableComponent",Mh);class z9 extends Mh{constructor(e,t){super(e,t);this.update(),this.update_=(a)=>this.update(a),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return tt("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u"){if(this.$("img"))return this.$("img").crossOrigin;else if(this.player_.tech_&&this.player_.tech_.isReady_)return this.player_.crossOrigin();return this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null}if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}if(this.$("img"))this.$("img").crossOrigin=e;return}update(e){let t=this.player().poster();if(this.setSrc(t),t)this.show();else this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}if(!this.$("img"))this.el_.appendChild(tt("picture",{className:"vjs-poster",tabIndex:-1},{},tt("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""})));this.$("img").src=e}handleClick(e){if(!this.player_.controls())return;if(this.player_.tech(!0))this.player_.tech(!0).focus();if(this.player_.paused())s0(this.player_.play());else this.player_.pause()}}z9.prototype.crossorigin=z9.prototype.crossOrigin;me.registerComponent("PosterImage",z9);var ci="#222",jd="#ccc",ZT={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function J6(e,t){let a;if(e.length===4)a=e[1]+e[1]+e[2]+e[2]+e[3]+e[3];else if(e.length===7)a=e.slice(1);else throw Error("Invalid color code provided, "+e+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(a.slice(0,2),16)+","+parseInt(a.slice(2,4),16)+","+parseInt(a.slice(4,6),16)+","+t+")"}function a0(e,t,a){try{e.style[t]=a}catch(n){return}}function qd(e){return e?`${e}px`:""}class Nj extends me{constructor(e,t,a){super(e,t,a);let n=(i)=>this.updateDisplay(i),s=(i)=>{this.updateDisplayOverlay(),this.updateDisplay(i)};e.on("loadstart",(i)=>this.toggleDisplay(i)),e.on("useractive",n),e.on("userinactive",n),e.on("texttrackchange",n),e.on("loadedmetadata",(i)=>{this.updateDisplayOverlay(),this.preselectTrack(i)}),e.ready(ua(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",s),e.on("playerresize",s);let i=V.default.screen.orientation||V.default,f=V.default.screen.orientation?"change":"orientationchange";i.addEventListener(f,s),e.on("dispose",()=>i.removeEventListener(f,s));let l=this.options_.playerOptions.tracks||[];for(let c=0;c<l.length;c++)this.player_.addRemoteTextTrack(l[c],!0);this.preselectTrack()}))}preselectTrack(){let e={captions:1,subtitles:1},t=this.player_.textTracks(),a=this.player_.cache_.selectedLanguage,n,s,i;for(let f=0;f<t.length;f++){let l=t[f];if(a&&a.enabled&&a.language&&a.language===l.language&&l.kind in e){if(l.kind===a.kind)i=l;else if(!i)i=l}else if(a&&!a.enabled)i=null,n=null,s=null;else if(l.default){if(l.kind==="descriptions"&&!n)n=l;else if(l.kind in e&&!s)s=l}}if(i)i.mode="showing";else if(s)s.mode="showing";else if(n)n.mode="showing"}toggleDisplay(){if(this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks)this.hide();else this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){if(typeof V.default.WebVTT==="function")V.default.WebVTT.processCues(V.default,[],this.el_)}updateDisplay(){let e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){let i=[];for(let f=0;f<e.length;++f){let l=e[f];if(l.mode!=="showing")continue;i.push(l)}this.updateForTrack(i);return}let a=null,n=null,s=e.length;while(s--){let i=e[s];if(i.mode==="showing")if(i.kind==="descriptions")a=i;else n=i}if(n){if(this.getAttribute("aria-live")!=="off")this.setAttribute("aria-live","off");this.updateForTrack(n)}else if(a){if(this.getAttribute("aria-live")!=="assertive")this.setAttribute("aria-live","assertive");this.updateForTrack(a)}if(!(V.default.CSS!==void 0&&V.default.CSS.supports("inset","10px"))){let i=this.el_,f=i.querySelectorAll(".vjs-text-track-cue"),l=this.player_.controlBar.el_.getBoundingClientRect().height,c=this.player_.el_.getBoundingClientRect().height;if(i.style="",a0(i,"position","relative"),a0(i,"height",c-l+"px"),a0(i,"top","unset"),M9)a0(i,"bottom",c+"px");else a0(i,"bottom","0px");if(f.length>0)f.forEach((h)=>{if(h.style.inset){let u=h.style.inset.split(" ");if(u.length===3)Object.assign(h.style,{top:u[0],right:u[1],bottom:u[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!(V.default.CSS!==void 0&&V.default.CSS.supports("inset-inline: 10px")))return;let e=this.player_.currentWidth(),t=this.player_.currentHeight(),a=e/t,n=this.player_.videoWidth()/this.player_.videoHeight(),s=0,i=0;if(Math.abs(a-n)>0.1)if(a>n)s=Math.round((e-t*n)/2);else i=Math.round((t-e/n)/2);a0(this.el_,"insetInline",qd(s)),a0(this.el_,"insetBlock",qd(i))}updateDisplayState(e){let t=this.player_.textTrackSettings.getValues(),a=e.activeCues,n=a.length;while(n--){let s=a[n];if(!s)continue;let i=s.displayState;if(t.color)i.firstChild.style.color=t.color;if(t.textOpacity)a0(i.firstChild,"color",J6(t.color||"#fff",t.textOpacity));if(t.backgroundColor)i.firstChild.style.backgroundColor=t.backgroundColor;if(t.backgroundOpacity)a0(i.firstChild,"backgroundColor",J6(t.backgroundColor||"#000",t.backgroundOpacity));if(t.windowColor)if(t.windowOpacity)a0(i,"backgroundColor",J6(t.windowColor,t.windowOpacity));else i.style.backgroundColor=t.windowColor;if(t.edgeStyle){if(t.edgeStyle==="dropshadow")i.firstChild.style.textShadow=`2px 2px 3px ${ci}, 2px 2px 4px ${ci}, 2px 2px 5px ${ci}`;else if(t.edgeStyle==="raised")i.firstChild.style.textShadow=`1px 1px ${ci}, 2px 2px ${ci}, 3px 3px ${ci}`;else if(t.edgeStyle==="depressed")i.firstChild.style.textShadow=`1px 1px ${jd}, 0 1px ${jd}, -1px -1px ${ci}, 0 -1px ${ci}`;else if(t.edgeStyle==="uniform")i.firstChild.style.textShadow=`0 0 4px ${ci}, 0 0 4px ${ci}, 0 0 4px ${ci}, 0 0 4px ${ci}`}if(t.fontPercent&&t.fontPercent!==1){let f=V.default.parseFloat(i.style.fontSize);i.style.fontSize=f*t.fontPercent+"px",i.style.height="auto",i.style.top="auto"}if(t.fontFamily&&t.fontFamily!=="default")if(t.fontFamily==="small-caps")i.firstChild.style.fontVariant="small-caps";else i.firstChild.style.fontFamily=ZT[t.fontFamily]}}updateForTrack(e){if(!Array.isArray(e))e=[e];if(typeof V.default.WebVTT!=="function"||e.every((a)=>{return!a.activeCues}))return;let t=[];for(let a=0;a<e.length;++a){let n=e[a];for(let s=0;s<n.activeCues.length;++s)t.push(n.activeCues[s])}V.default.WebVTT.processCues(V.default,t,this.el_);for(let a=0;a<e.length;++a){let n=e[a];for(let s=0;s<n.activeCues.length;++s){let i=n.activeCues[s].displayState;if(yr(i,"vjs-text-track-cue","vjs-text-track-cue-"+(n.language?n.language:a)),n.language)ho(i,"lang",n.language)}if(this.player_.textTrackSettings)this.updateDisplayState(n)}}}me.registerComponent("TextTrackDisplay",Nj);class Ej extends me{createEl(){let e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),a=tt("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),n=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return n.appendChild(a),n}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}me.registerComponent("LoadingSpinner",Ej);class Dn extends Mh{createEl(e,t={},a={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),a=Object.assign({type:"button"},a);let n=tt(e,t,a);if(!this.player_.options_.experimentalSvgIcons)n.appendChild(tt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0}));return this.createControlTextEl(n),n}addChild(e,t={}){let a=this.constructor.name;return qt.warn(`Adding an actionable (user controllable) child to a Button (${a}) is not supported; use a ClickableComponent instead.`),me.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}me.registerComponent("Button",Dn);class L4 extends Dn{constructor(e,t){super(e,t);this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",(a)=>this.handleMouseDown(a))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){let t=this.player_.play();if(e.type==="tap"||this.mouseused_&&"clientX"in e&&"clientY"in e){if(s0(t),this.player_.tech(!0))this.player_.tech(!0).focus();return}let a=this.player_.getChild("controlBar"),n=a&&a.getChild("playToggle");if(!n){this.player_.tech(!0).focus();return}let s=()=>n.focus();if(Sh(t))t.then(s,()=>{});else this.setTimeout(s,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}L4.prototype.controlText_="Play Video";me.registerComponent("BigPlayButton",L4);class zj extends Dn{constructor(e,t){super(e,t);this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),this.trigger("click");else super.handleKeyDown(e)}}me.registerComponent("CloseButton",zj);class V4 extends Dn{constructor(e,t={}){super(e,t);if(t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",(a)=>this.handlePlay(a)),this.on(e,"pause",(a)=>this.handlePause(a)),t.replay)this.on(e,"ended",(a)=>this.handleEnded(a))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){if(this.player_.paused())s0(this.player_.play());else this.player_.pause()}handleSeeked(e){if(this.removeClass("vjs-ended"),this.player_.paused())this.handlePause(e);else this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",(t)=>this.handleSeeked(t))}}V4.prototype.controlText_="Play";me.registerComponent("PlayToggle",V4);class Or extends me{constructor(e,t){super(e,t);this.on(e,["timeupdate","ended","seeking"],(a)=>this.update(a)),this.updateTextNode_()}createEl(){let e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),a=tt("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(a),this.contentEl_=tt("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){if(!this.player_.options_.enableSmoothSeeking&&e.type==="seeking")return;this.updateContent(e)}updateTextNode_(e=0){if(e=_r(e),this.formattedTime_===e)return;this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;if(t&&this.contentEl_.firstChild!==t)t=null,qt.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.");if(this.textNode_=ye.default.createTextNode(this.formattedTime_),!this.textNode_)return;if(t)this.contentEl_.replaceChild(this.textNode_,t);else this.contentEl_.appendChild(this.textNode_)})}updateContent(e){}}Or.prototype.labelText_="Time";Or.prototype.controlText_="Time";me.registerComponent("TimeDisplay",Or);class cm extends Or{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;if(this.player_.ended())t=this.player_.duration();else if(e&&e.target&&typeof e.target.pendingSeekTime==="function"&&e.target.pendingSeekTime()!==null)t=e.target.pendingSeekTime();else t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();this.updateTextNode_(t)}}cm.prototype.labelText_="Current Time";cm.prototype.controlText_="Current Time";me.registerComponent("CurrentTimeDisplay",cm);class hm extends Or{constructor(e,t){super(e,t);let a=(n)=>this.updateContent(n);this.on(e,"durationchange",a),this.on(e,"loadstart",a),this.on(e,"loadedmetadata",a)}buildCSSClass(){return"vjs-duration"}updateContent(e){let t=this.player_.duration();this.updateTextNode_(t)}}hm.prototype.labelText_="Duration";hm.prototype.controlText_="Duration";me.registerComponent("DurationDisplay",hm);class Uj extends me{createEl(){let e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),a=super.createEl("span",{textContent:"/"});return t.appendChild(a),e.appendChild(t),e}}me.registerComponent("TimeDivider",Uj);class um extends Or{constructor(e,t){super(e,t);this.on(e,"durationchange",(a)=>this.updateContent(a))}buildCSSClass(){return"vjs-remaining-time"}createEl(){let e=super.createEl();if(this.options_.displayNegative!==!1)e.insertBefore(tt("span",{},{"aria-hidden":!0},"-"),this.contentEl_);return e}updateContent(e){if(typeof this.player_.duration()!=="number")return;let t;if(this.player_.ended())t=0;else if(this.player_.remainingTimeDisplay)t=this.player_.remainingTimeDisplay();else t=this.player_.remainingTime();this.updateTextNode_(t)}}um.prototype.labelText_="Remaining Time";um.prototype.controlText_="Remaining Time";me.registerComponent("RemainingTimeDisplay",um);class Ij extends me{constructor(e,t){super(e,t);this.updateShowing(),this.on(this.player(),"durationchange",(a)=>this.updateShowing(a))}createEl(){let e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=tt("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(tt("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(ye.default.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){if(this.player().duration()===1/0)this.show();else this.hide()}}me.registerComponent("LiveDisplay",Ij);class Y4 extends Dn{constructor(e,t){super(e,t);if(this.updateLiveEdgeStatus(),this.player_.liveTracker)this.updateLiveEdgeStatusHandler_=(a)=>this.updateLiveEdgeStatus(a),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_)}createEl(){let e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=tt("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){if(!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge())this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live");else this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live")}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){if(this.player_.liveTracker)this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_);this.textEl_=null,super.dispose()}}Y4.prototype.controlText_="Seek to live, currently playing live";me.registerComponent("SeekToLive",Y4);function Dh(e,t,a){return e=Number(e),Math.min(a,Math.max(t,isNaN(e)?t:e))}var $T=Object.freeze({__proto__:null,clamp:Dh});class mm extends me{constructor(e,t){super(e,t);this.handleMouseDown_=(a)=>this.handleMouseDown(a),this.handleMouseUp_=(a)=>this.handleMouseUp(a),this.handleKeyDown_=(a)=>this.handleKeyDown(a),this.handleClick_=(a)=>this.handleClick(a),this.handleMouseMove_=(a)=>this.handleMouseMove(a),this.update_=(a)=>this.update(a),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){if(this.enabled())return;if(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent)this.on(this.player_,this.playerEvent,this.update);this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0}disable(){if(!this.enabled())return;let e=this.bar.el_.ownerDocument;if(this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent)this.off(this.player_,this.playerEvent,this.update);this.enabled_=!1}createEl(e,t={},a={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),a=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},a),super.createEl(e,t,a)}handleMouseDown(e){let t=this.bar.el_.ownerDocument;if(e.type==="mousedown")e.preventDefault();if(e.type==="touchstart"&&!o0)e.preventDefault();uj(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){let t=this.bar.el_.ownerDocument;mj(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;let e=this.getProgress();if(e===this.progress_)return e;return this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{let t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"}),e}getProgress(){return Number(Dh(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){let t=am(this.el_,e);if(this.vertical())return t.y;return t.x}handleKeyDown(e){let t=this.options_.playerOptions.spatialNavigation,a=t&&t.enabled,n=t&&t.horizontalSeek;if(a)if(n&&e.key==="ArrowLeft"||!n&&e.key==="ArrowDown")e.preventDefault(),e.stopPropagation(),this.stepBack();else if(n&&e.key==="ArrowRight"||!n&&e.key==="ArrowUp")e.preventDefault(),e.stopPropagation(),this.stepForward();else{if(this.pendingSeekTime())this.pendingSeekTime(null),this.userSeek_(this.player_.currentTime());super.handleKeyDown(e)}else if(e.key==="ArrowLeft"||e.key==="ArrowDown")e.preventDefault(),e.stopPropagation(),this.stepBack();else if(e.key==="ArrowUp"||e.key==="ArrowRight")e.preventDefault(),e.stopPropagation(),this.stepForward();else super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;if(this.vertical_=!!e,this.vertical_)this.addClass("vjs-slider-vertical");else this.addClass("vjs-slider-horizontal")}}me.registerComponent("Slider",mm);var Q6=(e,t)=>Dh(e/t*100,0,100).toFixed(2)+"%";class Gj extends me{constructor(e,t){super(e,t);this.partEls_=[],this.on(e,"progress",(a)=>this.update(a))}createEl(){let e=super.createEl("div",{className:"vjs-load-progress"}),t=tt("span",{className:"vjs-control-text"}),a=tt("span",{textContent:this.localize("Loaded")}),n=ye.default.createTextNode(": ");return this.percentageEl_=tt("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(a),t.appendChild(n),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{let t=this.player_.liveTracker,a=this.player_.buffered(),n=t&&t.isLive()?t.seekableEnd():this.player_.duration(),s=this.player_.bufferedEnd(),i=this.partEls_,f=Q6(s,n);if(this.percent_!==f)this.el_.style.width=f,hl(this.percentageEl_,f),this.percent_=f;for(let l=0;l<a.length;l++){let c=a.start(l),h=a.end(l),u=i[l];if(!u)u=this.el_.appendChild(tt()),i[l]=u;if(u.dataset.start===c&&u.dataset.end===h)continue;u.dataset.start=c,u.dataset.end=h,u.style.left=Q6(c,s),u.style.width=Q6(h-c,s)}for(let l=i.length;l>a.length;l--)this.el_.removeChild(i[l-1]);i.length=a.length})}}me.registerComponent("LoadProgressBar",Gj);class Xj extends me{constructor(e,t){super(e,t);this.update=c0(ua(this,this.update),mi)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,a){let n=Oh(this.el_),s=uo(this.player_.el()),i=e.width*t;if(!s||!n)return;let f=e.left-s.left+i,l=e.width-i+(s.right-e.right);if(!l)l=e.width-i,f=i;let c=n.width/2;if(f<c)c+=c-f;else if(l<c)c=l;if(c<0)c=0;else if(c>n.width)c=n.width;c=Math.round(c),this.el_.style.right=`-${c}px`,this.write(a)}write(e){hl(this.el_,e)}updateTime(e,t,a,n){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let s,i=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){let f=this.player_.liveTracker.liveWindow(),l=f-t*f;s=(l<1?"":"-")+_r(l,f)}else s=_r(a,i);if(this.update(e,t,s),n)n()})}}me.registerComponent("TimeTooltip",Xj);class gm extends me{constructor(e,t){super(e,t);this.setIcon("circle"),this.update=c0(ua(this,this.update),mi)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t,a){let n=this.getChild("timeTooltip");if(!n)return;let s=a&&a.target&&typeof a.target.pendingSeekTime==="function"?a.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,t,s)}}gm.prototype.options_={children:[]};if(!Ln&&!Mi)gm.prototype.options_.children.push("timeTooltip");me.registerComponent("PlayProgressBar",gm);class J4 extends me{constructor(e,t){super(e,t);this.update=c0(ua(this,this.update),mi)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){let a=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,a,()=>{this.el_.style.left=`${e.width*t}px`})}}J4.prototype.options_={children:["timeTooltip"]};me.registerComponent("MouseTimeDisplay",J4);class pm extends mm{constructor(e,t){t=sa(pm.prototype.options_,t),t.children=[...t.children];let a=e.options_.disableSeekWhileScrubbingOnMobile&&(Ln||Mi)||e.options_.disableSeekWhileScrubbingOnSTV;if(!Ln&&!Mi||a)t.children.splice(1,0,"mouseTimeDisplay");super(e,t);this.shouldDisableSeekWhileScrubbing_=a,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){if(this.update_=ua(this,this.update),this.update=c0(this.update_,mi),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker)this.on(this.player_.liveTracker,"liveedgechange",this.update);if(this.updateInterval=null,this.enableIntervalHandler_=(e)=>this.enableInterval_(e),this.disableIntervalHandler_=(e)=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in ye.default&&"visibilityState"in ye.default)this.on(ye.default,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){if(ye.default.visibilityState==="hidden")this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e);else{if(!this.player_.ended()&&!this.player_.paused())this.enableInterval_();this.update()}}enableInterval_(){if(this.updateInterval)return;this.updateInterval=this.setInterval(this.update,mi)}disableInterval_(e){if(this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended")return;if(!this.updateInterval)return;this.clearInterval(this.updateInterval),this.updateInterval=null}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(ye.default.visibilityState==="hidden")return;let t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{let a=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),n=this.player_.liveTracker,s=this.player_.duration();if(n&&n.isLive())s=this.player_.liveTracker.liveCurrentTime();if(this.percent_!==t)this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t;if(this.currentTime_!==a||this.duration_!==s)this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[_r(a,s),_r(s,s)],"{1} of {2}")),this.currentTime_=a,this.duration_=s;if(this.bar)this.bar.update(uo(this.el()),this.getProgress(),e)}),t}userSeek_(e){if(this.player_.liveTracker&&this.player_.liveTracker.isLive())this.player_.liveTracker.nextSeekedFromUser();this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}pendingSeekTime(e){if(e!==void 0)if(e!==null){let t=this.player_.duration();this.pendingSeekTime_=Math.max(0,Math.min(e,t))}else this.pendingSeekTime_=null;return this.pendingSeekTime_}getPercent(){if(this.pendingSeekTime()!==null)return this.pendingSeekTime()/this.player_.duration();let e=this.getCurrentTime_(),t,a=this.player_.liveTracker;if(a&&a.isLive()){if(t=(e-a.seekableStart())/a.liveWindow(),a.atLiveEdge())t=1}else t=e/this.player_.duration();return t}handleMouseDown(e){if(!Bh(e))return;if(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),!this.shouldDisableSeekWhileScrubbing_)this.player_.pause();super.handleMouseDown(e)}handleMouseMove(e,t=!1){if(!Bh(e)||isNaN(this.player_.duration()))return;if(!t&&!this.player_.scrubbing())this.player_.scrubbing(!0);let a,n=this.calculateDistance(e),s=this.player_.liveTracker;if(!s||!s.isLive()){if(a=n*this.player_.duration(),a===this.player_.duration())a=a-0.1}else{if(n>=0.99){s.seekToLiveEdge();return}let i=s.seekableStart(),f=s.liveCurrentTime();if(a=i+n*s.liveWindow(),a>=f)a=f;if(a<=i)a=i+0.1;if(a===1/0)return}if(this.shouldDisableSeekWhileScrubbing_)this.pendingSeekTime(a);else this.userSeek_(a);if(this.player_.options_.enableSmoothSeeking)this.update()}enable(){super.enable();let e=this.getChild("mouseTimeDisplay");if(!e)return;e.show()}disable(){super.disable();let e=this.getChild("mouseTimeDisplay");if(!e)return;e.hide()}handleMouseUp(e){if(super.handleMouseUp(e),e)e.stopPropagation();if(this.player_.scrubbing(!1),this.pendingSeekTime()!==null)this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null);if(this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying)s0(this.player_.play());else this.update_()}handlePendingSeek_(e){if(!this.player_.paused())this.player_.pause();let t=this.pendingSeekTime()!==null?this.pendingSeekTime():this.player_.currentTime();this.pendingSeekTime(t+e),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}stepForward(){if(this.shouldDisableSeekWhileScrubbing_)this.handlePendingSeek_(this.options().stepSeconds);else this.userSeek_(this.player_.currentTime()+this.options().stepSeconds)}stepBack(){if(this.shouldDisableSeekWhileScrubbing_)this.handlePendingSeek_(-this.options().stepSeconds);else this.userSeek_(this.player_.currentTime()-this.options().stepSeconds)}handleAction(e){if(this.pendingSeekTime()!==null)this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null);if(this.player_.paused())this.player_.play();else this.player_.pause()}handleKeyDown(e){let t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")if(e.preventDefault(),e.stopPropagation(),t&&t.isLive())this.userSeek_(t.liveCurrentTime());else this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();let a=parseInt(e.key,10)*0.1;if(t&&t.isLive())this.userSeek_(t.seekableStart()+t.liveWindow()*a);else this.userSeek_(this.player_.duration()*a)}else if(e.key==="PageDown")e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-this.options().stepSeconds*this.options().pageMultiplier);else if(e.key==="PageUp")e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+this.options().stepSeconds*this.options().pageMultiplier);else super.handleKeyDown(e)}dispose(){if(this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker)this.off(this.player_.liveTracker,"liveedgechange",this.update);if(this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in ye.default&&"visibilityState"in ye.default)this.off(ye.default,"visibilitychange",this.toggleVisibility_);super.dispose()}}pm.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar",stepSeconds:5,pageMultiplier:12};me.registerComponent("SeekBar",pm);class Q4 extends me{constructor(e,t){super(e,t);this.handleMouseMove=c0(ua(this,this.handleMouseMove),mi),this.throttledHandleMouseSeek=c0(ua(this,this.handleMouseSeek),mi),this.handleMouseUpHandler_=(a)=>this.handleMouseUp(a),this.handleMouseDownHandler_=(a)=>this.handleMouseDown(a),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){let t=this.getChild("seekBar");if(!t)return;let a=t.getChild("playProgressBar"),n=t.getChild("mouseTimeDisplay");if(!a&&!n)return;let s=t.el(),i=Oh(s),f=am(s,e).x;if(f=Dh(f,0,1),n)n.update(i,f);if(a)a.update(i,t.getProgress())}handleMouseSeek(e){let t=this.getChild("seekBar");if(t)t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach((e)=>e.disable&&e.disable()),!this.enabled())return;if(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing()){let e=this.getChild("seekBar");if(this.player_.scrubbing(!1),e.videoWasPlaying)s0(this.player_.play())}}enable(){if(this.children().forEach((e)=>e.enable&&e.enable()),this.enabled())return;this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0}removeListenersAddedOnMousedownAndTouchstart(){let e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){let t=this.el_.ownerDocument,a=this.getChild("seekBar");if(a)a.handleMouseDown(e);this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){let t=this.getChild("seekBar");if(t)t.handleMouseUp(e);this.removeListenersAddedOnMousedownAndTouchstart()}}Q4.prototype.options_={children:["seekBar"]};me.registerComponent("ProgressControl",Q4);class Z4 extends Dn{constructor(e,t){super(e,t);this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],(a)=>this.handlePictureInPictureChange(a)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],(a)=>this.handlePictureInPictureEnabledChange(a)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}if(this.player_.isInPictureInPicture())this.player_.exitPictureInPicture();this.hide()}handlePictureInPictureEnabledChange(){if(ye.default.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in V.default)this.enable();else this.disable()}handlePictureInPictureChange(e){if(this.player_.isInPictureInPicture())this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture");else this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture");this.handlePictureInPictureEnabledChange()}handleClick(e){if(!this.player_.isInPictureInPicture())this.player_.requestPictureInPicture();else this.player_.exitPictureInPicture()}show(){if(typeof ye.default.exitPictureInPicture!=="function")return;super.show()}}Z4.prototype.controlText_="Picture-in-Picture";me.registerComponent("PictureInPictureToggle",Z4);class $4 extends Dn{constructor(e,t){super(e,t);if(this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",(a)=>this.handleFullscreenChange(a)),ye.default[e.fsApi_.fullscreenEnabled]===!1)this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){if(this.player_.isFullscreen())this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit");else this.controlText("Fullscreen"),this.setIcon("fullscreen-enter")}handleClick(e){if(!this.player_.isFullscreen())this.player_.requestFullscreen();else this.player_.exitFullscreen()}}$4.prototype.controlText_="Fullscreen";me.registerComponent("FullscreenToggle",$4);var WT=function(e,t){if(t.tech_&&!t.tech_.featuresVolumeControl)e.addClass("vjs-hidden");e.on(t,"loadstart",function(){if(!t.tech_.featuresVolumeControl)e.addClass("vjs-hidden");else e.removeClass("vjs-hidden")})};class Kj extends me{createEl(){let e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}me.registerComponent("VolumeLevel",Kj);class Lj extends me{constructor(e,t){super(e,t);this.update=c0(ua(this,this.update),mi)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,a,n){if(!a){let s=uo(this.el_),i=uo(this.player_.el()),f=e.width*t;if(!i||!s)return;let l=e.left-i.left+f,c=e.width-f+(i.right-e.right),h=s.width/2;if(l<h)h+=h-l;else if(c<h)h=c;if(h<0)h=0;else if(h>s.width)h=s.width;this.el_.style.right=`-${h}px`}this.write(`${n}%`)}write(e){hl(this.el_,e)}updateVolume(e,t,a,n,s){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{if(this.update(e,t,a,n.toFixed(0)),s)s()})}}me.registerComponent("VolumeLevelTooltip",Lj);class W4 extends me{constructor(e,t){super(e,t);this.update=c0(ua(this,this.update),mi)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,a){let n=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,a,n,()=>{if(a)this.el_.style.bottom=`${e.height*t}px`;else this.el_.style.left=`${e.width*t}px`})}}W4.prototype.options_={children:["volumeLevelTooltip"]};me.registerComponent("MouseVolumeLevelDisplay",W4);class xh extends mm{constructor(e,t){super(e,t);this.on("slideractive",(a)=>this.updateLastVolume_(a)),this.on(e,"volumechange",(a)=>this.updateARIAAttributes(a)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){if(!Bh(e))return;super.handleMouseDown(e)}handleMouseMove(e){let t=this.getChild("mouseVolumeLevelDisplay");if(t){let a=this.el(),n=uo(a),s=this.vertical(),i=am(a,e);i=s?i.y:i.x,i=Dh(i,0,1),t.update(n,i,s)}if(!Bh(e))return;this.checkMuted(),this.player_.volume(this.calculateDistance(e))}checkMuted(){if(this.player_.muted())this.player_.muted(!1)}getPercent(){if(this.player_.muted())return 0;return this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+0.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-0.1)}updateARIAAttributes(e){let t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){let e=this.player_.volume();this.one("sliderinactive",()=>{if(this.player_.volume()===0)this.player_.lastVolume_(e)})}}xh.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};if(!Ln&&!Mi)xh.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");xh.prototype.playerEvent="volumechange";me.registerComponent("VolumeBar",xh);class P4 extends me{constructor(e,t={}){if(t.vertical=t.vertical||!1,typeof t.volumeBar>"u"||co(t.volumeBar))t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical;super(e,t);WT(this,e),this.throttledHandleMouseMove=c0(ua(this,this.handleMouseMove),mi),this.handleMouseUpHandler_=(a)=>this.handleMouseUp(a),this.on("mousedown",(a)=>this.handleMouseDown(a)),this.on("touchstart",(a)=>this.handleMouseDown(a)),this.on("mousemove",(a)=>this.handleMouseMove(a)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";if(this.options_.vertical)e="vjs-volume-vertical";return super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){let t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){let t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}P4.prototype.options_={children:["volumeBar"]};me.registerComponent("VolumeControl",P4);var PT=function(e,t){if(t.tech_&&!t.tech_.featuresMuteControl)e.addClass("vjs-hidden");e.on(t,"loadstart",function(){if(!t.tech_.featuresMuteControl)e.addClass("vjs-hidden");else e.removeClass("vjs-hidden")})};class eg extends Dn{constructor(e,t){super(e,t);PT(this,e),this.on(e,["loadstart","volumechange"],(a)=>this.update(a))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){let t=this.player_.volume(),a=this.player_.lastVolume_();if(t===0){let n=a<0.1?0.1:a;this.player_.volume(n),this.player_.muted(!1)}else this.player_.muted(this.player_.muted()?!1:!0)}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){let e=this.player_.volume(),t=3;if(this.setIcon("volume-high"),Ln&&this.player_.tech_&&this.player_.tech_.el_)this.player_.muted(this.player_.tech_.el_.muted);if(e===0||this.player_.muted())this.setIcon("volume-mute"),t=0;else if(e<0.33)this.setIcon("volume-low"),t=1;else if(e<0.67)this.setIcon("volume-medium"),t=2;em(this.el_,[0,1,2,3].reduce((a,n)=>a+`${n?" ":""}vjs-vol-${n}`,"")),yr(this.el_,`vjs-vol-${t}`)}updateControlText_(){let t=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";if(this.controlText()!==t)this.controlText(t)}}eg.prototype.controlText_="Mute";me.registerComponent("MuteToggle",eg);class tg extends me{constructor(e,t={}){if(typeof t.inline<"u")t.inline=t.inline;else t.inline=!0;if(typeof t.volumeControl>"u"||co(t.volumeControl))t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline;super(e,t);this.handleKeyPressHandler_=(a)=>this.handleKeyPress(a),this.on(e,["loadstart"],(a)=>this.volumePanelState_(a)),this.on(this.muteToggle,"keyup",(a)=>this.handleKeyPress(a)),this.on(this.volumeControl,"keyup",(a)=>this.handleVolumeControlKeyUp(a)),this.on("keydown",(a)=>this.handleKeyPress(a)),this.on("mouseover",(a)=>this.handleMouseOver(a)),this.on("mouseout",(a)=>this.handleMouseOut(a)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){if(this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden"))this.addClass("vjs-hidden");if(this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden"))this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";if(!this.options_.inline)e="vjs-volume-panel-vertical";return super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){if(e.key==="Escape")this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),Ls(ye.default,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Vn(ye.default,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){if(e.key==="Escape")this.handleMouseOut()}}tg.prototype.options_={children:["muteToggle","volumeControl"]};me.registerComponent("VolumePanel",tg);class ag extends Dn{constructor(e,t){super(e,t);if(this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime))this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show();else this.hide()}getSkipForwardTime(){let e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;let t=this.player_.currentTime(),a=this.player_.liveTracker,n=a&&a.isLive()?a.seekableEnd():this.player_.duration(),s;if(t+this.skipTime<=n)s=t+this.skipTime;else s=n;this.player_.currentTime(s)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}ag.prototype.controlText_="Skip Forward";me.registerComponent("SkipForward",ag);class ng extends Dn{constructor(e,t){super(e,t);if(this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime))this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show();else this.hide()}getSkipBackwardTime(){let e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){let t=this.player_.currentTime(),a=this.player_.liveTracker,n=a&&a.isLive()&&a.seekableStart(),s;if(n&&t-this.skipTime<=n)s=n;else if(t>=this.skipTime)s=t-this.skipTime;else s=0;this.player_.currentTime(s)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}ng.prototype.controlText_="Skip Backward";me.registerComponent("SkipBackward",ng);class sg extends me{constructor(e,t){super(e,t);if(t)this.menuButton_=t.menuButton;this.focusedChild_=-1,this.on("keydown",(a)=>this.handleKeyDown(a)),this.boundHandleBlur_=(a)=>this.handleBlur(a),this.boundHandleTapClick_=(a)=>this.handleTapClick(a)}addEventListenerForItem(e){if(!(e instanceof me))return;this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_)}removeEventListenerForItem(e){if(!(e instanceof me))return;this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_)}removeChild(e){if(typeof e==="string")e=this.getChild(e);this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){let t=this.addChild(e);if(t)this.addEventListenerForItem(t)}createEl(){let e=this.options_.contentElType||"ul";this.contentEl_=tt(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");let t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),Ls(t,"click",function(a){a.preventDefault(),a.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){let t=e.relatedTarget||ye.default.activeElement;if(!this.children().some((a)=>{return a.el()===t})){let a=this.menuButton_;if(a&&a.buttonPressed_&&t!==a.el().firstChild)a.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();let t=this.children();if(!Array.isArray(t))return;let a=t.filter((n)=>n.el()===e.target)[0];if(!a)return;if(a.name()!=="CaptionSettingsMenuItem")this.menuButton_.focus()}}handleKeyDown(e){if(e.key==="ArrowLeft"||e.key==="ArrowDown")e.preventDefault(),e.stopPropagation(),this.stepForward();else if(e.key==="ArrowRight"||e.key==="ArrowUp")e.preventDefault(),e.stopPropagation(),this.stepBack()}stepForward(){let e=0;if(this.focusedChild_!==void 0)e=this.focusedChild_+1;this.focus(e)}stepBack(){let e=0;if(this.focusedChild_!==void 0)e=this.focusedChild_-1;this.focus(e)}focus(e=0){let t=this.children().slice();if(t.length&&t[0].hasClass("vjs-menu-title"))t.shift();if(t.length>0){if(e<0)e=0;else if(e>=t.length)e=t.length-1;this.focusedChild_=e,t[e].el_.focus()}}}me.registerComponent("Menu",sg);class bm extends me{constructor(e,t={}){super(e,t);this.menuButton_=new Dn(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");let a=Dn.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+a,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;let n=(s)=>this.handleClick(s);this.handleMenuKeyUp_=(s)=>this.handleMenuKeyUp(s),this.on(this.menuButton_,"tap",n),this.on(this.menuButton_,"click",n),this.on(this.menuButton_,"keydown",(s)=>this.handleKeyDown(s)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),Ls(ye.default,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",(s)=>this.handleMouseLeave(s)),this.on("keydown",(s)=>this.handleSubmenuKeyDown(s))}update(){let e=this.createMenu();if(this.menu)this.menu.dispose(),this.removeChild(this.menu);if(this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_)this.hide(),this.menu.contentEl_.removeAttribute("role");else this.show(),this.menu.contentEl_.setAttribute("role","menu")}createMenu(){let e=new sg(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){let t=tt("li",{className:"vjs-menu-title",textContent:Na(this.options_.title),tabIndex:-1}),a=new me(this.player_,{el:t});e.addItem(a)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){return super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";if(this.options_.inline===!0)e+="-inline";else e+="-popup";let t=Dn.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";if(this.options_.inline===!0)e+="-inline";else e+="-popup";return`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){if(this.buttonPressed_)this.unpressButton();else this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),Vn(ye.default,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){if(e.key==="Escape"||e.key==="Tab"){if(this.buttonPressed_)this.unpressButton();if(!e.key==="Tab")e.preventDefault(),this.menuButton_.focus()}else if(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)){if(!this.buttonPressed_)e.preventDefault(),this.pressButton()}}handleMenuKeyUp(e){if(e.key==="Escape"||e.key==="Tab")this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){if(e.key==="Escape"||e.key==="Tab"){if(this.buttonPressed_)this.unpressButton();if(!e.key==="Tab")e.preventDefault(),this.menuButton_.focus()}}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),Ln&&lj())return;this.menu.focus()}}unpressButton(){if(this.enabled_)this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false")}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}me.registerComponent("MenuButton",bm);class wm extends bm{constructor(e,t){let a=t.tracks;super(e,t);if(this.items.length<=1)this.hide();if(!a)return;let n=ua(this,this.update);a.addEventListener("removetrack",n),a.addEventListener("addtrack",n),a.addEventListener("labelchange",n),this.player_.on("ready",n),this.player_.on("dispose",function(){a.removeEventListener("removetrack",n),a.removeEventListener("addtrack",n),a.removeEventListener("labelchange",n)})}}me.registerComponent("TrackButton",wm);class qo extends Mh{constructor(e,t){super(e,t);if(this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable)if(this.multiSelectable)this.el_.setAttribute("role","menuitemcheckbox");else this.el_.setAttribute("role","menuitemradio");else this.el_.setAttribute("role","menuitem")}createEl(e,t,a){this.nonIconControl=!0;let n=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),a),s=tt("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});if(this.player_.options_.experimentalSvgIcons)n.appendChild(s);else n.replaceChild(s,n.querySelector(".vjs-icon-placeholder"));return n}handleKeyDown(e){if(!["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key))super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){if(this.selectable)if(e)this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0;else this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1}}me.registerComponent("MenuItem",qo);class vo extends qo{constructor(e,t){let a=t.track,n=e.textTracks();t.label=a.label||a.language||"Unknown",t.selected=a.mode==="showing";super(e,t);this.track=a,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);let s=(...f)=>{this.handleTracksChange.apply(this,f)},i=(...f)=>{this.handleSelectedLanguageChange.apply(this,f)};if(e.on(["loadstart","texttrackchange"],s),n.addEventListener("change",s),n.addEventListener("selectedlanguagechange",i),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],s),n.removeEventListener("change",s),n.removeEventListener("selectedlanguagechange",i)}),n.onchange===void 0){let f;this.on(["tap","click"],function(){if(typeof V.default.Event!=="object")try{f=new V.default.Event("change")}catch(l){}if(!f)f=ye.default.createEvent("Event"),f.initEvent("change",!0,!0);n.dispatchEvent(f)})}this.handleTracksChange()}handleClick(e){let t=this.track,a=this.player_.textTracks();if(super.handleClick(e),!a)return;for(let n=0;n<a.length;n++){let s=a[n];if(this.kinds.indexOf(s.kind)===-1)continue;if(s===t){if(s.mode!=="showing")s.mode="showing"}else if(s.mode!=="disabled")s.mode="disabled"}}handleTracksChange(e){let t=this.track.mode==="showing";if(t!==this.isSelected_)this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){let t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}me.registerComponent("TextTrackMenuItem",vo);class ig extends vo{constructor(e,t){if(t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},!t.kinds)t.kinds=[t.kind];if(t.label)t.track.label=t.label;else t.track.label=t.kinds.join(" and ")+" off";t.selectable=!0,t.multiSelectable=!1;super(e,t)}handleTracksChange(e){let t=this.player().textTracks(),a=!0;for(let n=0,s=t.length;n<s;n++){let i=t[n];if(this.options_.kinds.indexOf(i.kind)>-1&&i.mode==="showing"){a=!1;break}}if(a!==this.isSelected_)this.selected(a)}handleSelectedLanguageChange(e){let t=this.player().textTracks(),a=!0;for(let n=0,s=t.length;n<s;n++){let i=t[n];if(["captions","descriptions","subtitles"].indexOf(i.kind)>-1&&i.mode==="showing"){a=!1;break}}if(a)this.player_.cache_.selectedLanguage={enabled:!1}}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}me.registerComponent("OffTextTrackMenuItem",ig);class Br extends wm{constructor(e,t={}){t.tracks=e.textTracks();super(e,t)}createItems(e=[],t=vo){let a;if(this.label_)a=`${this.label_} off`;e.push(new ig(this.player_,{kinds:this.kinds_,kind:this.kind_,label:a})),this.hideThreshold_+=1;let n=this.player_.textTracks();if(!Array.isArray(this.kinds_))this.kinds_=[this.kind_];for(let s=0;s<n.length;s++){let i=n[s];if(this.kinds_.indexOf(i.kind)>-1){let f=new t(this.player_,{track:i,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});f.addClass(`vjs-${i.kind}-menu-item`),e.push(f)}}return e}}me.registerComponent("TextTrackButton",Br);class fg extends qo{constructor(e,t){let{track:a,cue:n}=t,s=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=n.text,t.selected=n.startTime<=s&&s<n.endTime;super(e,t);this.track=a,this.cue=n}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}me.registerComponent("ChaptersTrackMenuItem",fg);class dm extends Br{constructor(e,t,a){super(e,t,a);this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach((n)=>{n.selected(this.track_.activeCues[0]===n.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;let t=this.findChaptersTrack();if(t!==this.track_)this.setTrack(t),super.update();else if(!this.items||t&&t.cues&&t.cues.length!==this.items.length)super.update()}setTrack(e){if(this.track_===e)return;if(!this.updateHandler_)this.updateHandler_=this.update.bind(this);if(this.track_){let t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);if(t)t.removeEventListener("load",this.updateHandler_);this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";let t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);if(t)t.addEventListener("load",this.updateHandler_);this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}findChaptersTrack(){let e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){let a=e[t];if(a.kind===this.kind_)return a}}getMenuCaption(){if(this.track_&&this.track_.label)return this.track_.label;return this.localize(Na(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){let e=[];if(!this.track_)return e;let t=this.track_.cues;if(!t)return e;for(let a=0,n=t.length;a<n;a++){let s=t[a],i=new fg(this.player_,{track:this.track_,cue:s});e.push(i)}return e}}dm.prototype.kind_="chapters";dm.prototype.controlText_="Chapters";me.registerComponent("ChaptersButton",dm);class jm extends Br{constructor(e,t,a){super(e,t,a);this.setIcon("audio-description");let n=e.textTracks(),s=ua(this,this.handleTracksChange);n.addEventListener("change",s),this.on("dispose",function(){n.removeEventListener("change",s)})}handleTracksChange(e){let t=this.player().textTracks(),a=!1;for(let n=0,s=t.length;n<s;n++){let i=t[n];if(i.kind!==this.kind_&&i.mode==="showing"){a=!0;break}}if(a)this.disable();else this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}jm.prototype.kind_="descriptions";jm.prototype.controlText_="Descriptions";me.registerComponent("DescriptionsButton",jm);class qm extends Br{constructor(e,t,a){super(e,t,a);this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}qm.prototype.kind_="subtitles";qm.prototype.controlText_="Subtitles";me.registerComponent("SubtitlesButton",qm);class vm extends vo{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem";super(e,t);this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}me.registerComponent("CaptionSettingsMenuItem",vm);class km extends Br{constructor(e,t,a){super(e,t,a);this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];if(!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings"))e.push(new vm(this.player_,{kind:this.kind_})),this.hideThreshold_+=1;return super.createItems(e)}}km.prototype.kind_="captions";km.prototype.controlText_="Captions";me.registerComponent("CaptionsButton",km);class lg extends vo{createEl(e,t,a){let n=super.createEl(e,t,a),s=n.querySelector(".vjs-menu-item-text");if(this.options_.track.kind==="captions"){if(this.player_.options_.experimentalSvgIcons)this.setIcon("captions",n);else s.appendChild(tt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0}));s.appendChild(tt("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))}return n}}me.registerComponent("SubsCapsMenuItem",lg);class Am extends Br{constructor(e,t={}){super(e,t);if(this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1)this.label_="captions",this.setIcon("captions");this.menuButton_.controlText(Na(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];if(!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings"))e.push(new vm(this.player_,{kind:this.label_})),this.hideThreshold_+=1;return e=super.createItems(e,lg),e}}Am.prototype.kinds_=["captions","subtitles"];Am.prototype.controlText_="Subtitles";me.registerComponent("SubsCapsButton",Am);class rg extends qo{constructor(e,t){let a=t.track,n=e.audioTracks();t.label=a.label||a.language||"Unknown",t.selected=a.enabled;super(e,t);this.track=a,this.addClass(`vjs-${a.kind}-menu-item`);let s=(...i)=>{this.handleTracksChange.apply(this,i)};n.addEventListener("change",s),this.on("dispose",()=>{n.removeEventListener("change",s)})}createEl(e,t,a){let n=super.createEl(e,t,a),s=n.querySelector(".vjs-menu-item-text");if(["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0)s.appendChild(tt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),s.appendChild(tt("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}));return n}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){let t=this.player_.audioTracks();for(let a=0;a<t.length;a++){let n=t[a];if(n===this.track)continue;n.enabled=n===this.track}}}handleTracksChange(e){this.selected(this.track.enabled)}}me.registerComponent("AudioTrackMenuItem",rg);class og extends wm{constructor(e,t={}){t.tracks=e.audioTracks();super(e,t);this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;let t=this.player_.audioTracks();for(let a=0;a<t.length;a++){let n=t[a];e.push(new rg(this.player_,{track:n,selectable:!0,multiSelectable:!1}))}return e}}og.prototype.controlText_="Audio Track";me.registerComponent("AudioTrackButton",og);class ym extends qo{constructor(e,t){let a=t.rate,n=parseFloat(a,10);t.label=a,t.selected=n===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1;super(e,t);this.label=a,this.rate=n,this.on(e,"ratechange",(s)=>this.update(s))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ym.prototype.contentElType="button";me.registerComponent("PlaybackRateMenuItem",ym);class cg extends bm{constructor(e,t){super(e,t);this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",(a)=>this.updateVisibility(a)),this.on(e,"ratechange",(a)=>this.updateLabel(a)),this.on(e,"playbackrateschange",(a)=>this.handlePlaybackRateschange(a))}createEl(){let e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=tt("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){let e=this.playbackRates(),t=[];for(let a=e.length-1;a>=0;a--)t.push(new ym(this.player(),{rate:e[a]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){let e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){if(this.playbackRateSupported())this.removeClass("vjs-hidden");else this.addClass("vjs-hidden")}updateLabel(e){if(this.playbackRateSupported())this.labelEl_.textContent=this.player().playbackRate()+"x"}}cg.prototype.controlText_="Playback Rate";me.registerComponent("PlaybackRateMenuButton",cg);class hg extends me{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},a={}){if(!t.className)t.className=this.buildCSSClass();return super.createEl(e,t,a)}}me.registerComponent("Spacer",hg);class Vj extends hg{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}me.registerComponent("CustomControlSpacer",Vj);class ug extends me{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}ug.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};me.registerComponent("ControlBar",ug);class mg extends Fr{constructor(e,t){super(e,t);this.on(e,"error",(a)=>{this.open(a)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){let e=this.player().error();return e?this.localize(e.message):""}}mg.prototype.options_=Object.assign({},Fr.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});me.registerComponent("ErrorDisplay",mg);class gg extends me{constructor(e,t={}){super(e,t);this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),tt("select",{id:this.options_.id},{},this.options_.SelectOptions.map((t)=>{let a=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${ui()}`)+"-"+t[1].replace(/\W+/g,""),n=tt("option",{id:a,value:this.localize(t[0]),textContent:this.localize(t[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${a}`),n}))}}me.registerComponent("TextTrackSelect",gg);class ll extends me{constructor(e,t={}){super(e,t);let a=tt("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(a);let n=this.options_.selects;for(let s of n){let i=this.options_.selectConfigs[s],f=i.className,l=i.id.replace("%s",this.options_.id_),c=null,h=`vjs_select_${ui()}`;if(this.options_.type==="colors"){c=tt("span",{className:f});let g=tt("label",{id:l,className:"vjs-label",textContent:this.localize(i.label)});g.setAttribute("for",h),c.appendChild(g)}let u=new gg(e,{SelectOptions:i.options,legendId:this.options_.legendId,id:h,labelId:l});if(this.addChild(u),this.options_.type==="colors")c.appendChild(u.el()),this.el().appendChild(c)}}createEl(){return tt("fieldset",{className:this.options_.className})}}me.registerComponent("TextTrackFieldset",ll);class pg extends me{constructor(e,t={}){super(e,t);let a=this.options_.textTrackComponentid,n=new ll(e,{id_:a,legendId:`captions-text-legend-${a}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(n);let s=new ll(e,{id_:a,legendId:`captions-background-${a}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(s);let i=new ll(e,{id_:a,legendId:`captions-window-${a}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(i)}createEl(){return tt("div",{className:"vjs-track-settings-colors"})}}me.registerComponent("TextTrackSettingsColors",pg);class bg extends me{constructor(e,t={}){super(e,t);let a=this.options_.textTrackComponentid,n=new ll(e,{id_:a,legendId:`captions-font-size-${a}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(n);let s=new ll(e,{id_:a,legendId:`captions-edge-style-${a}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(s);let i=new ll(e,{id_:a,legendId:`captions-font-family-${a}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(i)}createEl(){return tt("div",{className:"vjs-track-settings-font"})}}me.registerComponent("TextTrackSettingsFont",bg);class wg extends me{constructor(e,t={}){super(e,t);let a=new Dn(e,{controlText:this.localize("restore all settings to the default values"),className:"vjs-default-button"});a.el().classList.remove("vjs-control","vjs-button"),a.el().textContent=this.localize("Reset"),this.addChild(a);let n=this.localize("Done"),s=new Dn(e,{controlText:n,className:"vjs-done-button"});s.el().classList.remove("vjs-control","vjs-button"),s.el().textContent=n,this.addChild(s)}createEl(){return tt("div",{className:"vjs-track-settings-controls"})}}me.registerComponent("TrackSettingsControls",wg);var Z6="vjs-text-track-settings",vd=["#000","Black"],kd=["#00F","Blue"],Ad=["#0FF","Cyan"],yd=["#0F0","Green"],Sd=["#F0F","Magenta"],Cd=["#F00","Red"],_d=["#FFF","White"],Fd=["#FF0","Yellow"],$6=["1","Opaque"],W6=["0.5","Semi-Transparent"],Od=["0","Transparent"],il={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[vd,_d,Cd,yd,kd,Fd,Sd,Ad],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[$6,W6,Od],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[_d,vd,Cd,yd,kd,Fd,Sd,Ad],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:(e)=>e==="1.00"?null:Number(e)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[$6,W6],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[Od,W6,$6],className:"vjs-window-opacity vjs-opacity"}};il.windowColor.options=il.backgroundColor.options;function Yj(e,t){if(t)e=t(e);if(e&&e!=="none")return e}function eH(e,t){let a=e.options[e.options.selectedIndex].value;return Yj(a,t)}function tH(e,t,a){if(!t)return;for(let n=0;n<e.options.length;n++)if(Yj(e.options[n].value,a)===t){e.selectedIndex=n;break}}class Jj extends Fr{constructor(e,t){t.temporary=!1;super(e,t);if(this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=tt("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0)this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings;if(this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings)this.restoreSettings()}renderModalComponents(e){let t=new pg(e,{textTrackComponentid:this.id_,selectConfigs:il,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);let a=new bg(e,{textTrackComponentid:this.id_,selectConfigs:il,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(a);let n=new wg(e);this.addChild(n)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),to(il,(e)=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return ej(il,(e,t,a)=>{let n=eH(this.$(t.selector),t.parser);if(n!==void 0)e[a]=n;return e},{})}setValues(e){to(il,(t,a)=>{tH(this.$(t.selector),e[a],t.parser)})}setDefaults(){to(il,(e)=>{let t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(V.default.localStorage.getItem(Z6))}catch(t){qt.warn(t)}if(e)this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;let e=this.getValues();try{if(Object.keys(e).length)V.default.localStorage.setItem(Z6,JSON.stringify(e));else V.default.localStorage.removeItem(Z6)}catch(t){qt.warn(t)}}updateDisplay(){let e=this.player_.getChild("textTrackDisplay");if(e)e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}me.registerComponent("TextTrackSettings",Jj);class Qj extends me{constructor(e,t){let a=t.ResizeObserver||V.default.ResizeObserver;if(t.ResizeObserver===null)a=!1;let n=sa({createEl:!a,reportTouchActivity:!1},t);super(e,n);if(this.ResizeObserver=t.ResizeObserver||V.default.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=Aj(()=>{this.resizeHandler()},100,!1,this),a)this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el());else this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;let s=this.debouncedHandler_,i=this.unloadListener_=function(){Vn(this,"resize",s),Vn(this,"unload",i),i=null};Ls(this.el_.contentWindow,"unload",i),Ls(this.el_.contentWindow,"resize",s)},this.one("load",this.loadListener_)}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){if(!this.player_||!this.player_.trigger)return;this.player_.trigger("playerresize")}dispose(){if(this.debouncedHandler_)this.debouncedHandler_.cancel();if(this.resizeObserver_){if(this.player_.el())this.resizeObserver_.unobserve(this.player_.el());this.resizeObserver_.disconnect()}if(this.loadListener_)this.off("load",this.loadListener_);if(this.el_&&this.el_.contentWindow&&this.unloadListener_)this.unloadListener_.call(this.el_.contentWindow);this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}me.registerComponent("ResizeManager",Qj);var aH={trackingThreshold:20,liveTolerance:15};class Zj extends me{constructor(e,t){let a=sa(aH,t,{createEl:!1});super(e,a);this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=(n)=>this.handlePlay(n),this.handleFirstTimeupdate_=(n)=>this.handleFirstTimeupdate(n),this.handleSeeked_=(n)=>this.handleSeeked(n),this.seekToLiveEdge_=(n)=>this.seekToLiveEdge(n),this.reset_(),this.on(this.player_,"durationchange",(n)=>this.handleDurationchange(n)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){let e=this.player_.seekable();if(!e||!e.length)return;let t=Number(V.default.performance.now().toFixed(4)),a=this.lastTime_===-1?0:(t-this.lastTime_)/1000;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+a;let n=this.liveCurrentTime(),s=this.player_.currentTime(),i=this.player_.paused()||this.seekedBehindLive_||Math.abs(n-s)>this.options_.liveTolerance;if(!this.timeupdateSeen_||n===1/0)i=!1;if(i!==this.behindLiveEdge_)this.behindLiveEdge_=i,this.trigger("liveedgechange")}handleDurationchange(){this.toggleTracking()}toggleTracking(){if(this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold){if(this.player_.options_.liveui)this.player_.addClass("vjs-liveui");this.startTracking()}else this.player_.removeClass("vjs-liveui"),this.stopTracking()}startTracking(){if(this.isTracking())return;if(!this.timeupdateSeen_)this.timeupdateSeen_=this.player_.hasStarted();if(this.trackingInterval_=this.setInterval(this.trackLiveHandler_,mi),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),!this.timeupdateSeen_)this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_);else this.on(this.player_,"seeked",this.handleSeeked_)}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){let e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){if(!this.isTracking())return;this.reset_(),this.trigger("liveedgechange")}seekableEnd(){let e=this.player_.seekable(),t=[],a=e?e.length:0;while(a--)t.push(e.end(a));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){let e=this.player_.seekable(),t=[],a=e?e.length:0;while(a--)t.push(e.start(a));return t.length?t.sort()[0]:0}liveWindow(){let e=this.liveCurrentTime();if(e===1/0)return 0;return e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){let e=this.seekableEnd();if(this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_)this.pastSeekEnd_=0;return this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_==="number"}seekToLiveEdge(){if(this.seekedBehindLive_=!1,this.atLiveEdge())return;this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime())}dispose(){this.stopTracking(),super.dispose()}}me.registerComponent("LiveTracker",Zj);class $j extends me{constructor(e,t){super(e,t);this.on("statechanged",(a)=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:tt("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${ui()}`}),description:tt("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${ui()}`})},tt("div",{className:"vjs-title-bar"},{},tj(this.els))}updateDom_(){let e=this.player_.tech_,t=e&&e.el_,a={title:"aria-labelledby",description:"aria-describedby"};if(["title","description"].forEach((n)=>{let s=this.state[n],i=this.els[n],f=a[n];if(nm(i),s)hl(i,s);if(t){if(t.removeAttribute(f),s)t.setAttribute(f,i.id)}}),this.state.title||this.state.description)this.show();else this.hide()}update(e){this.setState(e)}dispose(){let e=this.player_.tech_,t=e&&e.el_;if(t)t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby");super.dispose(),this.els=null}}me.registerComponent("TitleBar",$j);var nH={initialDisplay:4000,position:[],takeFocus:!1};class Wj extends Dn{constructor(e,t){t=sa(nH,t);super(e,t);this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],(a)=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map((e)=>`vjs-${e}`).join(" ")}`}createEl(){let e=tt("button",{},{type:"button",class:this.buildCSSClass()},tt("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){if(super.show(),this.addClass("force-display"),this.options_.takeFocus)this.el().focus({preventScroll:!0});this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}me.registerComponent("TransientButton",Wj);var g4=(e)=>{let t=e.el();if(t.hasAttribute("src"))return e.triggerSourceset(t.src),!0;let a=e.$$("source"),n=[],s="";if(!a.length)return!1;for(let i=0;i<a.length;i++){let f=a[i].src;if(f&&n.indexOf(f)===-1)n.push(f)}if(!n.length)return!1;if(n.length===1)s=n[0];return e.triggerSourceset(s),!0},sH=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(e){let t=ye.default.createElement(this.nodeName.toLowerCase());t.innerHTML=e;let a=ye.default.createDocumentFragment();while(t.childNodes.length)a.appendChild(t.childNodes[0]);return this.innerText="",V.default.Element.prototype.appendChild.call(this,a),this.innerHTML}}),Pj=(e,t)=>{let a={};for(let n=0;n<e.length;n++)if(a=Object.getOwnPropertyDescriptor(e[n],t),a&&a.set&&a.get)break;return a.enumerable=!0,a.configurable=!0,a},iH=(e)=>Pj([e.el(),V.default.HTMLMediaElement.prototype,V.default.Element.prototype,sH],"innerHTML"),Bd=function(e){let t=e.el();if(t.resetSourceWatch_)return;let a={},n=iH(e),s=(i)=>(...f)=>{let l=i.apply(t,f);return g4(e),l};["append","appendChild","insertAdjacentHTML"].forEach((i)=>{if(!t[i])return;a[i]=t[i],t[i]=s(a[i])}),Object.defineProperty(t,"innerHTML",sa(n,{set:s(n.set)})),t.resetSourceWatch_=()=>{t.resetSourceWatch_=null,Object.keys(a).forEach((i)=>{t[i]=a[i]}),Object.defineProperty(t,"innerHTML",n)},e.one("sourceset",t.resetSourceWatch_)},fH=Object.defineProperty({},"src",{get(){if(this.hasAttribute("src"))return Mj(V.default.Element.prototype.getAttribute.call(this,"src"));return""},set(e){return V.default.Element.prototype.setAttribute.call(this,"src",e),e}}),lH=(e)=>Pj([e.el(),V.default.HTMLMediaElement.prototype,fH],"src"),rH=function(e){if(!e.featuresSourceset)return;let t=e.el();if(t.resetSourceset_)return;let a=lH(e),n=t.setAttribute,s=t.load;if(Object.defineProperty(t,"src",sa(a,{set:(i)=>{let f=a.set.call(t,i);return e.triggerSourceset(t.src),f}})),t.setAttribute=(i,f)=>{let l=n.call(t,i,f);if(/src/i.test(i))e.triggerSourceset(t.src);return l},t.load=()=>{let i=s.call(t);if(!g4(e))e.triggerSourceset(""),Bd(e);return i},t.currentSrc)e.triggerSourceset(t.currentSrc);else if(!g4(e))Bd(e);t.resetSourceset_=()=>{if(t.resetSourceset_=null,t.load=s,t.setAttribute=n,Object.defineProperty(t,"src",a),t.resetSourceWatch_)t.resetSourceWatch_()}};class De extends ut{constructor(e,t){super(e,t);let a=e.source,n=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",a&&(this.el_.currentSrc!==a.src||e.tag&&e.tag.initNetworkState_===3))this.setSource(a);else this.handleLateInit_(this.el_);if(e.enableSourceset)this.setupSourcesetHandling_();if(this.isScrubbing_=!1,this.el_.hasChildNodes()){let s=this.el_.childNodes,i=s.length,f=[];while(i--){let l=s[i];if(l.nodeName.toLowerCase()==="track"){if(!this.featuresNativeTextTracks)f.push(l);else if(this.remoteTextTrackEls().addTrackElement_(l),this.remoteTextTracks().addTrack(l.track),this.textTracks().addTrack(l.track),!n&&!this.el_.hasAttribute("crossorigin")&&om(l.src))n=!0}}for(let l=0;l<f.length;l++)this.el_.removeChild(f[l])}if(this.proxyNativeTracks_(),this.featuresNativeTextTracks&&n)qt.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
179
+ This may prevent text tracks from loading.`);if(this.restoreMetadataTracksInIOSNativePlayer_(),(Fh||W9)&&e.nativeControlsForTouch===!0)this.setControls(!0);this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){if(this.el_&&this.el_.resetSourceset_)this.el_.resetSourceset_();De.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){rH(this)}restoreMetadataTracksInIOSNativePlayer_(){let e=this.textTracks(),t,a=()=>{t=[];for(let s=0;s<e.length;s++){let i=e[s];if(i.kind==="metadata")t.push({track:i,storedMode:i.mode})}};a(),e.addEventListener("change",a),this.on("dispose",()=>e.removeEventListener("change",a));let n=()=>{for(let s=0;s<t.length;s++){let i=t[s];if(i.track.mode==="disabled"&&i.track.mode!==i.storedMode)i.track.mode=i.storedMode}e.removeEventListener("change",n)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",a),e.removeEventListener("change",n),e.addEventListener("change",n)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",a),e.addEventListener("change",a),e.removeEventListener("change",n)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;let a=e.toLowerCase();if(this[`${a}TracksListeners_`])Object.keys(this[`${a}TracksListeners_`]).forEach((n)=>{this.el()[`${a}Tracks`].removeEventListener(n,this[`${a}TracksListeners_`][n])});this[`featuresNative${e}Tracks`]=!t,this[`${a}TracksListeners_`]=null,this.proxyNativeTracksForType_(a)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){let t=hi[e],a=this.el()[t.getterName],n=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!a||!a.addEventListener)return;let s={change:(f)=>{let l={type:"change",target:n,currentTarget:n,srcElement:n};if(n.trigger(l),e==="text")this[go.remoteText.getterName]().trigger(l)},addtrack(f){n.addTrack(f.track)},removetrack(f){n.removeTrack(f.track)}},i=function(){let f=[];for(let l=0;l<n.length;l++){let c=!1;for(let h=0;h<a.length;h++)if(a[h]===n[l]){c=!0;break}if(!c)f.push(n[l])}while(f.length)n.removeTrack(f.shift())};this[t.getterName+"Listeners_"]=s,Object.keys(s).forEach((f)=>{let l=s[f];a.addEventListener(f,l),this.on("dispose",(c)=>a.removeEventListener(f,l))}),this.on("loadstart",i),this.on("dispose",(f)=>this.off("loadstart",i))}proxyNativeTracks_(){hi.names.forEach((e)=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){let a=e.cloneNode(!0);if(e.parentNode)e.parentNode.insertBefore(a,e);De.disposeMediaElement(e),e=a}else{e=ye.default.createElement("video");let a=this.options_.tag&&sl(this.options_.tag),n=sa({},a);if(!Fh||this.options_.nativeControlsForTouch!==!0)delete n.controls;cj(e,Object.assign(n,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}if(typeof this.options_.preload<"u")ho(e,"preload",this.options_.preload);if(this.options_.disablePictureInPicture!==void 0)e.disablePictureInPicture=this.options_.disablePictureInPicture;let t=["loop","muted","playsinline","autoplay"];for(let a=0;a<t.length;a++){let n=t[a],s=this.options_[n];if(typeof s<"u"){if(s)ho(e,n,n);else tm(e,n);e[n]=s}}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let a=!1,n=function(){a=!0};this.on("loadstart",n);let s=function(){if(!a)this.trigger("loadstart")};this.on("loadedmetadata",s),this.ready(function(){if(this.off("loadstart",n),this.off("loadedmetadata",s),!a)this.trigger("loadstart")});return}let t=["loadstart"];if(t.push("loadedmetadata"),e.readyState>=2)t.push("loadeddata");if(e.readyState>=3)t.push("canplay");if(e.readyState>=4)t.push("canplaythrough");this.ready(function(){t.forEach(function(a){this.trigger(a)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{if(this.isScrubbing_&&this.el_.fastSeek&&P9)this.el_.fastSeek(e);else this.el_.currentTime=e}catch(t){qt(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Mi&&o0&&this.el_.currentTime===0){let e=()=>{if(this.el_.currentTime>0){if(this.el_.duration===1/0)this.trigger("durationchange");this.off("timeupdate",e)}};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;let e=function(){if(this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls())this.el_.controls=!1},t=function(){if("webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture")this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0})};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen==="function"}enterFullScreen(){let e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)s0(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){if(this.featuresVideoFrameCallback&&!this.el_.webkitKeys)return this.el_.requestVideoFrameCallback(e);return super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){if(this.featuresVideoFrameCallback&&!this.el_.webkitKeys)this.el_.cancelVideoFrameCallback(e);else super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return qt.error("Invalid source URL."),!1;let a={src:e};if(t)a.type=t;let n=tt("source",{},a);return this.el_.appendChild(n),!0}removeSourceElement(e){if(!e)return qt.error("Source URL is required to remove the source element."),!1;let t=this.el_.querySelectorAll("source");for(let a of t)if(a.src===e)return this.el_.removeChild(a),!0;return qt.warn(`No matching source element found with src: ${e}`),!1}reset(){De.resetMediaElement(this.el_)}currentSrc(){if(this.currentSource_)return this.currentSource_.src;return this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,a){if(!this.featuresNativeTextTracks)return super.addTextTrack(e,t,a);return this.el_.addTextTrack(e,t,a)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);let t=ye.default.createElement("track");if(e.kind)t.kind=e.kind;if(e.label)t.label=e.label;if(e.language||e.srclang)t.srclang=e.language||e.srclang;if(e.default)t.default=e.default;if(e.id)t.id=e.id;if(e.src)t.src=e.src;return t}addRemoteTextTrack(e,t){let a=super.addRemoteTextTrack(e,t);if(this.featuresNativeTextTracks)this.el().appendChild(a);return a}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){let t=this.$$("track"),a=t.length;while(a--)if(e===t[a]||e===t[a].track)this.el().removeChild(t[a])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality==="function")return this.el().getVideoPlaybackQuality();let e={};if(typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u")e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount;if(V.default.performance)e.creationTime=V.default.performance.now();return e}}Q9(De,"TEST_VID",function(){if(!po())return;let e=ye.default.createElement("video"),t=ye.default.createElement("track");return t.kind="captions",t.srclang="en",t.label="English",e.appendChild(t),e});De.isSupported=function(){try{De.TEST_VID.volume=0.5}catch(e){return!1}return!!(De.TEST_VID&&De.TEST_VID.canPlayType)};De.canPlayType=function(e){return De.TEST_VID.canPlayType(e)};De.canPlaySource=function(e,t){return De.canPlayType(e.type)};De.canControlVolume=function(){try{let e=De.TEST_VID.volume;De.TEST_VID.volume=e/2+0.1;let t=e!==De.TEST_VID.volume;if(t&&Ln)return V.default.setTimeout(()=>{if(De&&De.prototype)De.prototype.featuresVolumeControl=e!==De.TEST_VID.volume}),!1;return t}catch(e){return!1}};De.canMuteVolume=function(){try{let e=De.TEST_VID.muted;if(De.TEST_VID.muted=!e,De.TEST_VID.muted)ho(De.TEST_VID,"muted","muted");else tm(De.TEST_VID,"muted","muted");return e!==De.TEST_VID.muted}catch(e){return!1}};De.canControlPlaybackRate=function(){if(Mi&&o0&&Z9<58)return!1;try{let e=De.TEST_VID.playbackRate;return De.TEST_VID.playbackRate=e/2+0.1,e!==De.TEST_VID.playbackRate}catch(e){return!1}};De.canOverrideAttributes=function(){try{let e=()=>{};Object.defineProperty(ye.default.createElement("video"),"src",{get:e,set:e}),Object.defineProperty(ye.default.createElement("audio"),"src",{get:e,set:e}),Object.defineProperty(ye.default.createElement("video"),"innerHTML",{get:e,set:e}),Object.defineProperty(ye.default.createElement("audio"),"innerHTML",{get:e,set:e})}catch(e){return!1}return!0};De.supportsNativeTextTracks=function(){return P9||Ln&&o0};De.supportsNativeVideoTracks=function(){return!!(De.TEST_VID&&De.TEST_VID.videoTracks)};De.supportsNativeAudioTracks=function(){return!!(De.TEST_VID&&De.TEST_VID.audioTracks)};De.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([e,t]){Q9(De.prototype,e,()=>De[t](),!0)});De.prototype.featuresVolumeControl=De.canControlVolume();De.prototype.movingMediaElementInDOM=!Ln;De.prototype.featuresFullscreenResize=!0;De.prototype.featuresProgressEvents=!0;De.prototype.featuresTimeupdateEvents=!0;De.prototype.featuresVideoFrameCallback=!!(De.TEST_VID&&De.TEST_VID.requestVideoFrameCallback);De.disposeMediaElement=function(e){if(!e)return;if(e.parentNode)e.parentNode.removeChild(e);while(e.hasChildNodes())e.removeChild(e.firstChild);if(e.removeAttribute("src"),typeof e.load==="function")(function(){try{e.load()}catch(t){}})()};De.resetMediaElement=function(e){if(!e)return;let t=e.querySelectorAll("source"),a=t.length;while(a--)e.removeChild(t[a]);if(e.removeAttribute("src"),typeof e.load==="function")(function(){try{e.load()}catch(n){}})()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(e){De.prototype[e]=function(){return this.el_[e]||this.el_.hasAttribute(e)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(e){De.prototype["set"+Na(e)]=function(t){if(this.el_[e]=t,t)this.el_.setAttribute(e,e);else this.el_.removeAttribute(e)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(e){De.prototype[e]=function(){return this.el_[e]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(e){De.prototype["set"+Na(e)]=function(t){this.el_[e]=t}});["pause","load","play"].forEach(function(e){De.prototype[e]=function(){return this.el_[e]()}});ut.withSourceHandlers(De);De.nativeSourceHandler={};De.nativeSourceHandler.canPlayType=function(e){try{return De.TEST_VID.canPlayType(e)}catch(t){return""}};De.nativeSourceHandler.canHandleSource=function(e,t){if(e.type)return De.nativeSourceHandler.canPlayType(e.type);else if(e.src){let a=I4(e.src);return De.nativeSourceHandler.canPlayType(`video/${a}`)}return""};De.nativeSourceHandler.handleSource=function(e,t,a){t.setSrc(e.src)};De.nativeSourceHandler.dispose=function(){};De.registerSourceHandler(De.nativeSourceHandler);ut.registerTech("Html5",De);var eq=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],P6={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},p4=["tiny","xsmall","small","medium","large","xlarge","huge"],C9={};p4.forEach((e)=>{let t=e.charAt(0)==="x"?`x-${e.substring(1)}`:e;C9[e]=`vjs-layout-${t}`});var oH={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class Lt extends me{constructor(e,t,a){if(e.id=e.id||t.id||`vjs_video_${ui()}`,t=Object.assign(Lt.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){let i=e.closest("[lang]");if(i)t.language=i.getAttribute("lang")}super(null,t,a);if(this.boundDocumentFullscreenChange_=(i)=>this.documentFullscreenChange_(i),this.boundFullWindowOnEscKey_=(i)=>this.fullWindowOnEscKey(i),this.boundUpdateStyleEl_=(i)=>this.updateStyleEl_(i),this.boundApplyInitTime_=(i)=>this.applyInitTime_(i),this.boundUpdateCurrentBreakpoint_=(i)=>this.updateCurrentBreakpoint_(i),this.boundHandleTechClick_=(i)=>this.handleTechClick_(i),this.boundHandleTechDoubleClick_=(i)=>this.handleTechDoubleClick_(i),this.boundHandleTechTouchStart_=(i)=>this.handleTechTouchStart_(i),this.boundHandleTechTouchMove_=(i)=>this.handleTechTouchMove_(i),this.boundHandleTechTouchEnd_=(i)=>this.handleTechTouchEnd_(i),this.boundHandleTechTap_=(i)=>this.handleTechTap_(i),this.boundUpdatePlayerHeightOnAudioOnlyMode_=(i)=>this.updatePlayerHeightOnAudioOnlyMode_(i),this.isFullscreen_=!1,this.log=Wd(this.id_),this.fsApi_=F9,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&sl(e),this.language(this.options_.language),t.languages){let i={};Object.getOwnPropertyNames(t.languages).forEach(function(f){i[f.toLowerCase()]=t.languages[f]}),this.languages_=i}else this.languages_=Lt.prototype.options_.languages;if(this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay"))this.autoplay(!0);else this.autoplay(this.options_.autoplay);if(t.plugins)Object.keys(t.plugins).forEach((i)=>{if(typeof this[i]!=="function")throw Error(`plugin "${i}" does not exist`)});if(this.scrubbing_=!1,this.el_=this.createEl(),R4(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen)Ls(ye.default,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_);if(this.fluid_)this.on(["playerreset","resize"],this.boundUpdateStyleEl_);let n=sa(this.options_);if(t.plugins)Object.keys(t.plugins).forEach((i)=>{this[i](t.plugins[i])});if(t.debug)this.debug(!0);if(this.options_.playerOptions=n,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){let f=new V.default.DOMParser().parseFromString(QT,"image/svg+xml");if(f.querySelector("parsererror"))qt.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{let c=f.documentElement;c.style.display="none",this.el_.appendChild(c),this.addClass("vjs-svg-icons-enabled")}}if(this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls())this.addClass("vjs-controls-enabled");else this.addClass("vjs-controls-disabled");if(this.el_.setAttribute("role","region"),this.isAudio())this.el_.setAttribute("aria-label",this.localize("Audio Player"));else this.el_.setAttribute("aria-label",this.localize("Video Player"));if(this.isAudio())this.addClass("vjs-audio");if(t.spatialNavigation&&t.spatialNavigation.enabled)this.spatialNavigation=new xj(this),this.addClass("vjs-spatial-navigation-enabled");if(Fh)this.addClass("vjs-touch-enabled");if(!Ln)this.addClass("vjs-workinghover");Lt.players[this.id_]=this;let s=i4.split(".")[0];this.addClass(`vjs-v${s}`),this.userActive(!0),this.reportUserActivity(),this.one("play",(i)=>this.listenForUserActivity_(i)),this.on("keydown",(i)=>this.handleKeyDown(i)),this.on("languagechange",(i)=>this.handleLanguagechange(i)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){if(this.trigger("dispose"),this.off("dispose"),Vn(ye.default,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Vn(ye.default,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode)this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null;if(Lt.players[this.id_]=null,this.tag&&this.tag.player)this.tag.player=null;if(this.el_&&this.el_.player)this.el_.player=null;if(this.tech_)this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_="";if(this.playerElIngest_)this.playerElIngest_=null;if(this.tag)this.tag=null;LT(this),as.names.forEach((e)=>{let t=as[e],a=this[t.getterName]();if(a&&a.off)a.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,a=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player"),n=this.tag.tagName.toLowerCase()==="video-js";if(a)t=this.el_=e.parentNode;else if(!n)t=this.el_=super.createEl("div");let s=sl(e);if(n){t=this.el_=e,e=this.tag=ye.default.createElement("video");while(t.children.length)e.appendChild(t.firstChild);if(!Ah(t,"video-js"))yr(t,"video-js");t.appendChild(e),a=this.playerElIngest_=t,Object.keys(t).forEach((l)=>{try{e[l]=t[l]}catch(c){}})}if(e.setAttribute("tabindex","-1"),s.tabindex="-1",o0&&$9)e.setAttribute("role","application"),s.role="application";if(e.removeAttribute("width"),e.removeAttribute("height"),"width"in s)delete s.width;if("height"in s)delete s.height;Object.getOwnPropertyNames(s).forEach(function(l){if(!(n&&l==="class"))t.setAttribute(l,s[l]);if(n)e.setAttribute(l,s[l])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");let i=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter((l)=>fj[l]).map((l)=>{return"vjs-device-"+l.substring(3).toLowerCase().replace(/\_/g,"-")});if(this.addClass(...i),V.default.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=vj("vjs-styles-dimensions");let l=ol(".vjs-styles-defaults"),c=ol("head");c.insertBefore(this.styleEl_,l?l.nextSibling:c.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);let f=e.getElementsByTagName("a");for(let l=0;l<f.length;l++){let c=f.item(l);yr(c,"vjs-hidden"),c.setAttribute("hidden","hidden")}if(e.initNetworkState_=e.networkState,e.parentNode&&!a)e.parentNode.insertBefore(t,e);return l4(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){qt.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}if(this.techCall_("setCrossOrigin",e),this.posterImage)this.posterImage.crossOrigin(e);return}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){let a=e+"_";if(t===void 0)return this[a]||0;if(t===""||t==="auto"){this[a]=void 0,this.updateStyleEl_();return}let n=parseFloat(t);if(isNaN(n)){qt.error(`Improper value "${t}" supplied for for ${e}`);return}this[a]=n,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;if(this.fluid_=!!e,tf(this))this.off(["playerreset","resize"],this.boundUpdateStyleEl_);if(e)this.addClass("vjs-fluid"),this.fill(!1),yT(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)});else this.removeClass("vjs-fluid");this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;if(this.fill_=!!e,e)this.addClass("vjs-fill"),this.fluid(!1);else this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(V.default.VIDEOJS_NO_DYNAMIC_STYLE===!0){let f=typeof this.width_==="number"?this.width_:this.options_.width,l=typeof this.height_==="number"?this.height_:this.options_.height,c=this.tech_&&this.tech_.el();if(c){if(f>=0)c.width=f;if(l>=0)c.height=l}return}let e,t,a,n;if(this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto")a=this.aspectRatio_;else if(this.videoWidth()>0)a=this.videoWidth()+":"+this.videoHeight();else a="16:9";let s=a.split(":"),i=s[1]/s[0];if(this.width_!==void 0)e=this.width_;else if(this.height_!==void 0)e=this.height_/i;else e=this.videoWidth()||300;if(this.height_!==void 0)t=this.height_;else t=e*i;if(/^[^a-zA-Z]/.test(this.id()))n="dimensions-"+this.id();else n=this.id()+"-dimensions";this.addClass(n),kj(this.styleEl_,`
180
+ .${n} {
181
+ width: ${e}px;
182
+ height: ${t}px;
183
+ }
184
+
185
+ .${n}.vjs-fluid:not(.vjs-audio-only-mode) {
186
+ padding-top: ${i*100}%;
187
+ }
188
+ `)}loadTech_(e,t){if(this.tech_)this.unloadTech_();let a=Na(e),n=e.charAt(0).toLowerCase()+e.slice(1);if(a!=="Html5"&&this.tag)ut.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null;this.techName_=a,this.isReady_=!1;let s=this.autoplay();if(typeof this.autoplay()==="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)s=!1;let i={source:t,autoplay:s,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${n}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};if(as.names.forEach((l)=>{let c=as[l];i[c.getterName]=this[c.privateName]}),Object.assign(i,this.options_[a]),Object.assign(i,this.options_[n]),Object.assign(i,this.options_[e.toLowerCase()]),this.tag)i.tag=this.tag;if(t&&t.src===this.cache_.src&&this.cache_.currentTime>0)i.startTime=this.cache_.currentTime;let f=ut.getTech(e);if(!f)throw Error(`No Tech named '${a}' exists! '${a}' should be registered using videojs.registerTech()'`);if(this.tech_=new f(i),this.tech_.ready(ua(this,this.handleTechReady_),!0),m4.jsonToTextTracks(this.textTracksJson_||[],this.tech_),eq.forEach((l)=>{this.on(this.tech_,l,(c)=>this[`handleTech${Na(l)}_`](c))}),Object.keys(P6).forEach((l)=>{this.on(this.tech_,l,(c)=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${P6[l]}_`].bind(this),event:c});return}this[`handleTech${P6[l]}_`](c)})}),this.on(this.tech_,"loadstart",(l)=>this.handleTechLoadStart_(l)),this.on(this.tech_,"sourceset",(l)=>this.handleTechSourceset_(l)),this.on(this.tech_,"waiting",(l)=>this.handleTechWaiting_(l)),this.on(this.tech_,"ended",(l)=>this.handleTechEnded_(l)),this.on(this.tech_,"seeking",(l)=>this.handleTechSeeking_(l)),this.on(this.tech_,"play",(l)=>this.handleTechPlay_(l)),this.on(this.tech_,"pause",(l)=>this.handleTechPause_(l)),this.on(this.tech_,"durationchange",(l)=>this.handleTechDurationChange_(l)),this.on(this.tech_,"fullscreenchange",(l,c)=>this.handleTechFullscreenChange_(l,c)),this.on(this.tech_,"fullscreenerror",(l,c)=>this.handleTechFullscreenError_(l,c)),this.on(this.tech_,"enterpictureinpicture",(l)=>this.handleTechEnterPictureInPicture_(l)),this.on(this.tech_,"leavepictureinpicture",(l)=>this.handleTechLeavePictureInPicture_(l)),this.on(this.tech_,"error",(l)=>this.handleTechError_(l)),this.on(this.tech_,"posterchange",(l)=>this.handleTechPosterChange_(l)),this.on(this.tech_,"textdata",(l)=>this.handleTechTextData_(l)),this.on(this.tech_,"ratechange",(l)=>this.handleTechRateChange_(l)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls())this.addTechControlsListeners_();if(this.tech_.el().parentNode!==this.el()&&(a!=="Html5"||!this.tag))l4(this.tech_.el(),this.el());if(this.tag)this.tag.player=null,this.tag=null}unloadTech_(){if(as.names.forEach((e)=>{let t=as[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=m4.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_)this.poster_="",this.trigger("posterchange");this.isPosterFromTech_=!1}tech(e){if(e===void 0)qt.warn(`Using the tech directly can be dangerous. I hope you know what you're doing.
189
+ See https://github.com/videojs/video.js/issues/2617 for more info.
190
+ `);return this.tech_}version(){return{"video.js":i4}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){if(this.triggerReady(),this.cache_.volume)this.techCall_("setVolume",this.cache_.volume);this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){if(this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),!this.paused())this.trigger("loadstart");else this.hasStarted(!1),this.trigger("loadstart");this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!=="string")return;let t=()=>{let n=this.muted();this.muted(!0);let s=()=>{this.muted(n)};this.playTerminatedQueue_.push(s);let i=this.play();if(!Sh(i))return;return i.catch((f)=>{throw s(),Error(`Rejection at manualAutoplay. Restoring muted value. ${f?f:""}`)})},a;if(e==="any"&&!this.muted()){if(a=this.play(),Sh(a))a=a.catch(t)}else if(e==="muted"&&!this.muted())a=t();else a=this.play();if(!Sh(a))return;return a.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,a="";if(typeof t!=="string")t=e.src,a=e.type;if(this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!a)a=JT(this,t);this.cache_.source=sa({},e,{src:t,type:a});let n=this.cache_.sources.filter((l)=>l.src&&l.src===t),s=[],i=this.$$("source"),f=[];for(let l=0;l<i.length;l++){let c=sl(i[l]);if(s.push(c),c.src&&c.src===t)f.push(c.src)}if(f.length&&!n.length)this.cache_.sources=s;else if(!n.length)this.cache_.sources=[this.cache_.source];this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=(s)=>this.updateSourceCaches_(s),a=this.currentSource().src,n=e.src;if(a&&!/^blob:/.test(a)&&/^blob:/.test(n)){if(!this.lastSource_||this.lastSource_.tech!==n&&this.lastSource_.player!==a)t=()=>{}}if(t(n),!e.src)this.tech_.any(["sourceset","loadstart"],(s)=>{if(s.type==="sourceset")return;let i=this.techGet_("currentSrc");this.lastSource_.tech=i,this.updateSourceCaches_(i)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;if(e===this.hasStarted_)return;if(this.hasStarted_=e,this.hasStarted_)this.addClass("vjs-has-started");else this.removeClass("vjs-has-started")}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){if(this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0)this.queuedCallbacks_.forEach((e)=>e.callback(e.event)),this.queuedCallbacks_=[];this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");let e=this.currentTime(),t=()=>{if(e!==this.currentTime())this.removeClass("vjs-waiting"),this.off("timeupdate",t)};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){if(this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop)this.currentTime(0),this.play();else if(!this.paused())this.pause();this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){if(!this.controls_)return;if(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)if(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click==="function")this.options_.userActions.click.call(this,e);else if(this.paused())s0(this.play());else this.pause()}handleTechDoubleClick_(e){if(!this.controls_)return;if(!Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),(a)=>a.contains(e.target))){if(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)if(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick==="function")this.options_.userActions.doubleClick.call(this,e);else if(this.isInPictureInPicture()&&!ye.default.pictureInPictureElement)this.exitPictureInPicture();else if(this.isFullscreen())this.exitFullscreen();else this.requestFullscreen()}}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){if(this.userWasActive)this.reportUserActivity()}handleTechTouchEnd_(e){if(e.cancelable)e.preventDefault()}toggleFullscreenClass_(){if(this.isFullscreen())this.addClass("vjs-fullscreen");else this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){let t=e.target.player;if(t&&t!==this)return;let a=this.el(),n=ye.default[this.fsApi_.fullscreenElement]===a;if(!n&&a.matches)n=a.matches(":"+this.fsApi_.fullscreen);this.isFullscreen(n)}handleTechFullscreenChange_(e,t){if(t){if(t.nativeIOSFullscreen)this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")});this.isFullscreen(t.isFullscreen)}}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){if(this.isInPictureInPicture())this.addClass("vjs-picture-in-picture");else this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){let e=this.tech_.error();if(e)this.error(e)}handleTechTextData_(){let e=null;if(arguments.length>1)e=arguments[1];this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in XT)return IT(this.middleware_,this.tech_,e,t);else if(e in pd)return gd(this.middleware_,this.tech_,e,t);try{if(this.tech_)this.tech_[e](t)}catch(a){throw qt(a),a}},!0)}techGet_(e){if(!this.tech_||!this.tech_.isReady_)return;if(e in GT)return UT(this.middleware_,this.tech_,e);else if(e in pd)return gd(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){if(this.tech_[e]===void 0)throw qt(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t;if(t.name==="TypeError")throw qt(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t;throw qt(t),t}}play(){return new Promise((e)=>{this.play_(e)})}play_(e=s0){this.playCallbacks_.push(e);let t=Boolean(!this.changingSrc_&&(this.src()||this.currentSrc())),a=Boolean(P9||Ln);if(this.waitToPlay_)this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null;if(!this.isReady_||!t){if(this.waitToPlay_=(i)=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&a)this.load();return}let n=this.techGet_("play");if(a&&this.hasClass("vjs-ended"))this.resetProgressBar_();if(n===null)this.runPlayTerminatedQueue_();else this.runPlayCallbacks_(n)}runPlayTerminatedQueue_(){let e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){let t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(a){a(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")===!1?!1:!0}played(){return this.techGet_("played")||Hi(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;if(this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e)this.addClass("vjs-scrubbing");else this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0)e=0;if(!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}if(this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e))this.cache_.currentTime=Number(e)}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;if(e=parseFloat(e),e<0)e=1/0;if(e!==this.cache_.duration){if(this.cache_.duration=e,e===1/0)this.addClass("vjs-live");else this.removeClass("vjs-live");if(!isNaN(e))this.trigger("durationchange")}}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");if(!e||!e.length)e=Hi(0,0);return e}seekable(){let e=this.techGet_("seekable");if(!e||!e.length)e=Hi(0,0);return e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return Tj(this.buffered(),this.duration())}bufferedEnd(){let e=this.buffered(),t=this.duration(),a=e.end(e.length-1);if(a>t)a=t;return a}volume(e){let t;if(e!==void 0){if(t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0)this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){if(e!==void 0)this.techCall_("setDefaultMuted",e);return this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){let t=this.isFullscreen_;if(this.isFullscreen_=Boolean(e),this.isFullscreen_!==t&&this.fsApi_.prefixed)this.trigger("fullscreenchange");this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){if(this.isInPictureInPicture())this.exitPictureInPicture();let t=this;return new Promise((a,n)=>{function s(){t.off("fullscreenerror",f),t.off("fullscreenchange",i)}function i(){s(),a()}function f(c,h){s(),n(h)}t.one("fullscreenchange",i),t.one("fullscreenerror",f);let l=t.requestFullscreenHelper_(e);if(l)l.then(s,s),l.then(a,n)})}requestFullscreenHelper_(e){let t;if(!this.fsApi_.prefixed){if(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0)t=e}if(this.fsApi_.requestFullscreen){let a=this.el_[this.fsApi_.requestFullscreen](t);if(a)a.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1));return a}else if(this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow===!0)this.techCall_("enterFullScreen");else this.enterFullWindow()}exitFullscreen(){let e=this;return new Promise((t,a)=>{function n(){e.off("fullscreenerror",i),e.off("fullscreenchange",s)}function s(){n(),t()}function i(l,c){n(),a(c)}e.one("fullscreenchange",s),e.one("fullscreenerror",i);let f=e.exitFullscreenHelper_();if(f)f.then(n,n),f.then(t,a)})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){let e=ye.default[this.fsApi_.exitFullscreen]();if(e)s0(e.then(()=>this.isFullscreen(!1)));return e}else if(this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow===!0)this.techCall_("exitFullScreen");else this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=ye.default.documentElement.style.overflow,Ls(ye.default,"keydown",this.boundFullWindowOnEscKey_),ye.default.documentElement.style.overflow="hidden",yr(ye.default.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){if(e.key==="Escape"){if(this.isFullscreen()===!0)if(!this.isFullWindow)this.exitFullscreen();else this.exitFullWindow()}}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Vn(ye.default,"keydown",this.boundFullWindowOnEscKey_),ye.default.documentElement.style.overflow=this.docOrigOverflow,em(ye.default.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&V.default.documentPictureInPicture){let e=ye.default.createElement(this.el().tagName);if(e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage)e.appendChild(this.posterImage.el().cloneNode(!0));if(this.titleBar)e.appendChild(this.titleBar.el().cloneNode(!0));return e.appendChild(tt("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),V.default.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then((t)=>{return dj(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",(a)=>{let n=a.target.querySelector(".video-js");e.parentNode.replaceChild(n,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t})}if("pictureInPictureEnabled"in ye.default&&this.disablePictureInPicture()===!1)return this.techGet_("requestPictureInPicture");return Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(V.default.documentPictureInPicture&&V.default.documentPictureInPicture.window)return V.default.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in ye.default)return ye.default.exitPictureInPicture()}handleKeyDown(e){let{userActions:t}=this.options_;if(!t||!t.hotkeys)return;if(((n)=>{let s=n.tagName.toLowerCase();if(n.isContentEditable)return!0;let i=["button","checkbox","hidden","radio","reset","submit"];if(s==="input")return i.indexOf(n.type)===-1;return["textarea"].indexOf(s)!==-1})(this.el_.ownerDocument.activeElement))return;if(typeof t.hotkeys==="function")t.hotkeys.call(this,e);else this.handleHotkeys(e)}handleHotkeys(e){let t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:a=(i)=>e.key.toLowerCase()==="f",muteKey:n=(i)=>e.key.toLowerCase()==="m",playPauseKey:s=(i)=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(a.call(this,e)){e.preventDefault(),e.stopPropagation();let i=me.getComponent("FullscreenToggle");if(ye.default[this.fsApi_.fullscreenEnabled]!==!1)i.prototype.handleClick.call(this,e)}else if(n.call(this,e))e.preventDefault(),e.stopPropagation(),me.getComponent("MuteToggle").prototype.handleClick.call(this,e);else if(s.call(this,e))e.preventDefault(),e.stopPropagation(),me.getComponent("PlayToggle").prototype.handleClick.call(this,e)}canPlayType(e){let t;for(let a=0,n=this.options_.techOrder;a<n.length;a++){let s=n[a],i=ut.getTech(s);if(!i)i=me.getComponent(s);if(!i){qt.error(`The "${s}" tech is undefined. Skipped browser support check for that tech.`);continue}if(i.isSupported()){if(t=i.canPlayType(e),t)return t}}return""}selectSource(e){let t=this.options_.techOrder.map((f)=>{return[f,ut.getTech(f)]}).filter(([f,l])=>{if(l)return l.isSupported();return qt.error(`The "${f}" tech is undefined. Skipped browser support check for that tech.`),!1}),a=function(f,l,c){let h;return f.some((u)=>{return l.some((g)=>{if(h=c(u,g),h)return!0})}),h},n,s=(f)=>(l,c)=>f(c,l),i=([f,l],c)=>{if(l.canPlaySource(c,this.options_[f.toLowerCase()]))return{source:c,tech:f}};if(this.options_.sourceOrder)n=a(e,t,s(i));else n=a(t,e,i);return n||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";if(this.resetRetryOnError_)this.resetRetryOnError_();let a=Dj(e);if(!a.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,!t)this.cache_.sources=a;if(this.updateSourceCaches_(a[0]),ET(this,a[0],(n,s)=>{if(this.middleware_=s,!t)this.cache_.sources=a;if(this.updateSourceCaches_(n),this.src_(n)){if(a.length>1)return this.handleSrc_(a.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}zT(s,this.tech_)}),a.length>1){let n=()=>{this.error(null),this.handleSrc_(a.slice(1),!0)},s=()=>{this.off("error",n)};this.one("error",n),this.one("playing",s),this.resetRetryOnError_=()=>{this.off("error",n),this.off("playing",s)}}}src(e){return this.handleSrc_(e,!1)}src_(e){let t=this.selectSource([e]);if(!t)return!0;if(!_j(t.tech,this.techName_))return this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1;return this.ready(function(){if(this.tech_.constructor.prototype.hasOwnProperty("setSource"))this.techCall_("setSource",e);else this.techCall_("src",e.src);this.changingSrc_=!1},!0),!1}addSourceElement(e,t){if(!this.tech_)return!1;return this.tech_.addSourceElement(e,t)}removeSourceElement(e){if(!this.tech_)return!1;return this.tech_.removeSourceElement(e)}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{let e=this.play();s0(e.then(()=>this.doReset_()))}}doReset_(){if(this.tech_)this.tech_.clearTracks("text");if(this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar)this.titleBar.update({title:void 0,description:void 0});if(tf(this))this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);let{currentTimeDisplay:e,durationDisplay:t,progressControl:a,remainingTimeDisplay:n}=this.controlBar||{},{seekBar:s}=a||{};if(e)e.updateContent();if(t)t.updateContent();if(n)n.updateContent();if(s){if(s.update(),s.loadProgressBar)s.loadProgressBar.update()}}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){let e=this.currentSource(),t=[];if(Object.keys(e).length!==0)t.push(e);return this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;if(typeof e==="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay)this.options_.autoplay=e,this.manualAutoplay_(typeof e==="string"?e:"play"),t=!1;else if(!e)this.options_.autoplay=!1;else this.options_.autoplay=!0;if(t=typeof t>"u"?this.options_.autoplay:t,this.tech_)this.techCall_("setAutoplay",t)}playsinline(e){if(e!==void 0)this.techCall_("setPlaysinline",e),this.options_.playsinline=e;return this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;if(!e)e="";if(e===this.poster_)return;this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange")}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){let e=this.tech_.poster()||"";if(e!==this.poster_)this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange")}}controls(e){if(e===void 0)return!!this.controls_;if(e=!!e,this.controls_===e)return;if(this.controls_=e,this.usingNativeControls())this.techCall_("setControls",e);if(this.controls_){if(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),!this.usingNativeControls())this.addTechControlsListeners_()}else if(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),!this.usingNativeControls())this.removeTechControlsListeners_()}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;if(e=!!e,this.usingNativeControls_===e)return;if(this.usingNativeControls_=e,this.usingNativeControls_)this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols");else this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")}error(e){if(e===void 0)return this.error_||null;if(rl("beforeerror").forEach((t)=>{let a=t(this,e);if(!(r0(a)&&!Array.isArray(a)||typeof a==="string"||typeof a==="number"||a===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=a}),this.options_.suppressNotSupportedError&&e&&e.code===4){let t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){if(this.error_=null,this.removeClass("vjs-error"),this.errorDisplay)this.errorDisplay.close();return}this.error_=new Ba(e),this.addClass("vjs-error"),qt.error(`(CODE:${this.error_.code} ${Ba.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),rl("error").forEach((t)=>t(this,this.error_));return}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e===this.userActive_)return;if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}if(this.tech_)this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()});this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}listenForUserActivity_(){let e,t,a,n=ua(this,this.reportUserActivity),s=function(u){if(u.screenX!==t||u.screenY!==a)t=u.screenX,a=u.screenY,n()},i=function(){n(),this.clearInterval(e),e=this.setInterval(n,250)},f=function(u){n(),this.clearInterval(e)};this.on("mousedown",i),this.on("mousemove",s),this.on("mouseup",f),this.on("mouseleave",f);let l=this.getChild("controlBar");if(l&&!Ln&&!Mi)l.on("mouseenter",function(u){if(this.player().options_.inactivityTimeout!==0)this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout;this.player().options_.inactivityTimeout=0}),l.on("mouseleave",function(u){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout});this.on("keydown",n),this.on("keyup",n);let c,h=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(c);let u=this.options_.inactivityTimeout;if(u<=0)return;c=this.setTimeout(function(){if(!this.userActivity_)this.userActive(!1)},u)};this.setInterval(h,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}if(this.tech_&&this.tech_.featuresPlaybackRate)return this.cache_.lastPlaybackRate||this.techGet_("playbackRate");return 1}defaultPlaybackRate(e){if(e!==void 0)return this.techCall_("setDefaultPlaybackRate",e);if(this.tech_&&this.tech_.featuresPlaybackRate)return this.techGet_("defaultPlaybackRate");return 1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){let e=this.getChild("ControlBar");if(!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight())return;this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight)}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");let e=this.children(),t=this.getChild("ControlBar"),a=t&&t.currentHeight();e.forEach((n)=>{if(n===t)return;if(n.el_&&!n.hasClass("vjs-hidden"))n.hide(),this.audioOnlyCache_.hiddenChildren.push(n)}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=a,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(a),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach((e)=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!=="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){let t=[];if(this.isInPictureInPicture())t.push(this.exitPictureInPicture());if(this.isFullscreen())t.push(this.exitFullscreen());if(this.audioPosterMode())t.push(this.audioPosterMode(!1));return Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){if(typeof e!=="boolean"||e===this.audioPosterMode_)return this.audioPosterMode_;if(this.audioPosterMode_=e,e){if(this.audioOnlyMode())return this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()});return Promise.resolve().then(()=>{this.enablePosterModeUI_()})}return Promise.resolve().then(()=>{this.disablePosterModeUI_()})}addTextTrack(e,t,a){if(this.tech_)return this.tech_.addTextTrack(e,t,a)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(!t)t=e;if(this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;if(this.language_!==String(e).toLowerCase()){if(this.language_=String(e).toLowerCase(),tf(this))this.trigger("languagechange")}}languages(){return sa(Lt.prototype.options_.languages,this.languages_)}toJSON(){let e=sa(this.options_),t=e.tracks;e.tracks=[];for(let a=0;a<t.length;a++){let n=t[a];n=sa(n),n.player=void 0,e.tracks[a]=n}return e}createModal(e,t){t=t||{},t.content=e||"";let a=new Fr(this,t);return this.addChild(a),a.on("dispose",()=>{this.removeChild(a)}),a.open(),a}updateCurrentBreakpoint_(){if(!this.responsive())return;let e=this.currentBreakpoint(),t=this.currentWidth();for(let a=0;a<p4.length;a++){let n=p4[a],s=this.breakpoints_[n];if(t<=s){if(e===n)return;if(e)this.removeClass(C9[e]);this.addClass(C9[n]),this.breakpoint_=n;break}}}removeCurrentBreakpoint_(){let e=this.currentBreakpointClass();if(this.breakpoint_="",e)this.removeClass(e)}breakpoints(e){if(e===void 0)return Object.assign(this.breakpoints_);return this.breakpoint_="",this.breakpoints_=Object.assign({},oH,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_)}responsive(e){if(e===void 0)return this.responsive_;e=Boolean(e);let t=this.responsive_;if(e===t)return;if(this.responsive_=e,e)this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_();else this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_();return e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return C9[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!=="object")return;let a=this.crossOrigin();this.reset(),this.cache_.media=sa(e);let{artist:n,artwork:s,description:i,poster:f,src:l,textTracks:c,title:h}=this.cache_.media;if(!s&&f)this.cache_.media.artwork=[{src:f,type:E9(f)}];if(a)this.crossOrigin(a);if(l)this.src(l);if(f)this.poster(f);if(Array.isArray(c))c.forEach((u)=>this.addRemoteTextTrack(u,!1));if(this.titleBar)this.titleBar.update({title:h,description:i||n||""});this.ready(t)}getMedia(){if(!this.cache_.media){let e=this.poster(),t=this.currentSources(),a=Array.prototype.map.call(this.remoteTextTracks(),(s)=>({kind:s.kind,label:s.label,language:s.language,src:s.src})),n={src:t,textTracks:a};if(e)n.poster=e,n.artwork=[{src:n.poster,type:E9(n.poster)}];return n}return sa(this.cache_.media)}static getTagSettings(e){let t={sources:[],tracks:[]},a=sl(e),n=a["data-setup"];if(Ah(e,"vjs-fill"))a.fill=!0;if(Ah(e,"vjs-fluid"))a.fluid=!0;if(n!==null)try{Object.assign(a,JSON.parse(n||"{}"))}catch(s){qt.error("data-setup",s)}if(Object.assign(t,a),e.hasChildNodes()){let s=e.childNodes;for(let i=0,f=s.length;i<f;i++){let l=s[i],c=l.nodeName.toLowerCase();if(c==="source")t.sources.push(sl(l));else if(c==="track")t.tracks.push(sl(l))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;if(e)this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0;else this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;if(!Array.isArray(e))return;if(!e.every((t)=>typeof t==="number"))return;this.cache_.playbackRates=e,this.trigger("playbackrateschange")}}Lt.prototype.videoTracks=()=>{};Lt.prototype.audioTracks=()=>{};Lt.prototype.textTracks=()=>{};Lt.prototype.remoteTextTracks=()=>{};Lt.prototype.remoteTextTrackEls=()=>{};as.names.forEach(function(e){let t=as[e];Lt.prototype[t.getterName]=function(){if(this.tech_)return this.tech_[t.getterName]();return this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName]}});Lt.prototype.crossorigin=Lt.prototype.crossOrigin;Lt.players={};var jh=V.default.navigator;Lt.prototype.options_={techOrder:ut.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2000,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:jh&&(jh.languages&&jh.languages[0]||jh.userLanguage||jh.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1,disableSeekWhileScrubbingOnSTV:!1};eq.forEach(function(e){Lt.prototype[`handleTech${Na(e)}_`]=function(){return this.trigger(e)}});me.registerComponent("Player",Lt);var U9="plugin",so="activePlugins_",P1={},I9=(e)=>P1.hasOwnProperty(e),_9=(e)=>I9(e)?P1[e]:void 0,tq=(e,t)=>{e[so]=e[so]||{},e[so][t]=!0},G9=(e,t,a)=>{let n=(a?"before":"")+"pluginsetup";e.trigger(n,t),e.trigger(n+":"+t.name,t)},cH=function(e,t){let a=function(){G9(this,{name:e,plugin:t,instance:null},!0);let n=t.apply(this,arguments);return tq(this,e),G9(this,{name:e,plugin:t,instance:n}),n};return Object.keys(t).forEach(function(n){a[n]=t[n]}),a},Td=(e,t)=>{return t.prototype.name=e,function(...a){G9(this,{name:e,plugin:t,instance:null},!0);let n=new t(...[this,...a]);return this[e]=()=>n,G9(this,n.getEventHash()),n}};class As{constructor(e){if(this.constructor===As)throw Error("Plugin must be sub-classed; not directly instantiated.");if(this.player=e,!this.log)this.log=this.player.log.createLogger(this.name);R4(this),delete this.trigger,Cj(this,this.constructor.defaultState),tq(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return wo(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){let{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[so][e]=!1,this.player=this.state=null,t[e]=Td(e,P1[e])}static isBasic(e){let t=typeof e==="string"?_9(e):e;return typeof t==="function"&&!As.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!=="string")throw Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(I9(e))qt.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(Lt.prototype.hasOwnProperty(e))throw Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!=="function")throw Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);if(P1[e]=t,e!==U9)if(As.isBasic(t))Lt.prototype[e]=cH(e,t);else Lt.prototype[e]=Td(e,t);return t}static deregisterPlugin(e){if(e===U9)throw Error("Cannot de-register base plugin.");if(I9(e))delete P1[e],delete Lt.prototype[e]}static getPlugins(e=Object.keys(P1)){let t;return e.forEach((a)=>{let n=_9(a);if(n)t=t||{},t[a]=n}),t}static getPluginVersion(e){let t=_9(e);return t&&t.VERSION||""}}As.getPlugin=_9;As.BASE_PLUGIN_NAME=U9;As.registerPlugin(U9,As);Lt.prototype.usingPlugin=function(e){return!!this[so]&&this[so][e]===!0};Lt.prototype.hasPlugin=function(e){return!!I9(e)};function hH(e,t){let a=!1;return function(...n){if(!a)qt.warn(e);return a=!0,t.apply(this,n)}}function Di(e,t,a,n){return hH(`${t} is deprecated and will be removed in ${e}.0; please use ${a} instead.`,n)}var uH={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"},aq=(e)=>e.indexOf("#")===0?e.slice(1):e;function se(e,t,a){let n=se.getPlayer(e);if(n){if(t)qt.warn(`Player "${e}" is already initialised. Options will not be applied.`);if(a)n.ready(a);return n}let s=typeof e==="string"?ol("#"+aq(e)):e;if(!bo(s))throw TypeError("The element or ID supplied is not valid. (videojs)");let f=("getRootNode"in s?s.getRootNode()instanceof V.default.ShadowRoot:!1)?s.getRootNode():s.ownerDocument.body;if(!s.ownerDocument.defaultView||!f.contains(s))qt.warn("The element supplied is not included in the DOM");if(t=t||{},t.restoreEl===!0)t.restoreEl=(s.parentNode&&s.parentNode.hasAttribute&&s.parentNode.hasAttribute("data-vjs-player")?s.parentNode:s).cloneNode(!0);return rl("beforesetup").forEach((c)=>{let h=c(s,sa(t));if(!r0(h)||Array.isArray(h)){qt.error("please return an object in beforesetup hooks");return}t=sa(t,h)}),n=new(me.getComponent("Player"))(s,t,a),rl("setup").forEach((c)=>c(n)),n}se.hooks_=P0;se.hooks=rl;se.hook=cT;se.hookOnce=hT;se.removeHook=$d;if(V.default.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&po()){let e=ol(".vjs-styles-defaults");if(!e){e=vj("vjs-styles-defaults");let t=ol("head");if(t)t.insertBefore(e,t.firstChild);kj(e,`
191
+ .video-js {
192
+ width: 300px;
193
+ height: 150px;
194
+ }
195
+
196
+ .vjs-fluid:not(.vjs-audio-only-mode) {
197
+ padding-top: 56.25%
198
+ }
199
+ `)}}o4(1,se);se.VERSION=i4;se.options=Lt.prototype.options_;se.getPlayers=()=>Lt.players;se.getPlayer=(e)=>{let t=Lt.players,a;if(typeof e==="string"){let n=aq(e),s=t[n];if(s)return s;a=ol("#"+n)}else a=e;if(bo(a)){let{player:n,playerId:s}=a;if(n||t[s])return n||t[s]}};se.getAllPlayers=()=>Object.keys(Lt.players).map((e)=>Lt.players[e]).filter(Boolean);se.players=Lt.players;se.getComponent=me.getComponent;se.registerComponent=(e,t)=>{if(ut.isTech(t))qt.warn(`The ${e} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`);return me.registerComponent.call(me,e,t)};se.getTech=ut.getTech;se.registerTech=ut.registerTech;se.use=NT;Object.defineProperty(se,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(se.middleware,"TERMINATOR",{value:N9,writeable:!1,enumerable:!0});se.browser=fj;se.obj=gT;se.mergeOptions=Di(9,"videojs.mergeOptions","videojs.obj.merge",sa);se.defineLazyProperty=Di(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",Q9);se.bind=Di(9,"videojs.bind","native Function.prototype.bind",ua);se.registerPlugin=As.registerPlugin;se.deregisterPlugin=As.deregisterPlugin;se.plugin=(e,t)=>{return qt.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),As.registerPlugin(e,t)};se.getPlugins=As.getPlugins;se.getPlugin=As.getPlugin;se.getPluginVersion=As.getPluginVersion;se.addLanguage=function(e,t){return e=(""+e).toLowerCase(),se.options.languages=sa(se.options.languages,{[e]:t}),se.options.languages[e]};se.log=qt;se.createLogger=Wd;se.time=OT;se.createTimeRange=Di(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Hi);se.createTimeRanges=Di(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Hi);se.formatTime=Di(9,"videojs.formatTime","videojs.time.formatTime",_r);se.setFormatTime=Di(9,"videojs.setFormatTime","videojs.time.setFormatTime",Oj);se.resetFormatTime=Di(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",Bj);se.parseUrl=Di(9,"videojs.parseUrl","videojs.url.parseUrl",U4);se.isCrossOrigin=Di(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",om);se.EventTarget=ys;se.any=x4;se.on=Ls;se.one=im;se.off=Vn;se.trigger=wo;se.xhr=B4.default;se.TrackList=cl;se.TextTrack=jo;se.TextTrackList=lm;se.AudioTrack=G4;se.AudioTrackList=E4;se.VideoTrack=X4;se.VideoTrackList=z4;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach((e)=>{se[e]=function(){return qt.warn(`videojs.${e}() is deprecated; use videojs.dom.${e}() instead`),jj[e].apply(null,arguments)}});se.computedStyle=Di(9,"videojs.computedStyle","videojs.dom.computedStyle",mo);se.dom=jj;se.fn=AT;se.num=$T;se.str=_T;se.url=xT;se.Error=uH;/*! @name videojs-contrib-quality-levels @version 4.1.0 @license Apache-2.0 */class nq{constructor(e){let t=this;return t.id=e.id,t.label=t.id,t.width=e.width,t.height=e.height,t.bitrate=e.bandwidth,t.frameRate=e.frameRate,t.enabled_=e.enabled,Object.defineProperty(t,"enabled",{get(){return t.enabled_()},set(a){t.enabled_(a)}}),t}}class Th extends se.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}}),Object.defineProperty(e,"length",{get(){return e.levels_.length}}),e[Symbol.iterator]=()=>e.levels_.values(),e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;let a=this.levels_.length;if(t=new nq(e),!(""+a in this))Object.defineProperty(this,a,{get(){return this.levels_[a]}});return this.levels_.push(t),this.trigger({qualityLevel:t,type:"addqualitylevel"}),t}removeQualityLevel(e){let t=null;for(let a=0,n=this.length;a<n;a++)if(this[a]===e){if(t=this.levels_.splice(a,1)[0],this.selectedIndex_===a)this.selectedIndex_=-1;else if(this.selectedIndex_>a)this.selectedIndex_--;break}if(t)this.trigger({qualityLevel:e,type:"removequalitylevel"});return t}getQualityLevelById(e){for(let t=0,a=this.length;t<a;t++){let n=this[t];if(n.id===e)return n}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}Th.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(let e in Th.prototype.allowedEvents_)Th.prototype["on"+e]=null;var sq="4.1.0",mH=function(e,t){let a=e.qualityLevels,n=new Th,s=function(){n.dispose(),e.qualityLevels=a,e.off("dispose",s)};return e.on("dispose",s),e.qualityLevels=()=>n,e.qualityLevels.VERSION=sq,n},iq=function(e){return mH(this,se.obj.merge({},e))};se.registerPlugin("qualityLevels",iq);iq.VERSION=sq;/*! @name @videojs/http-streaming @version 3.17.3 @license Apache-2.0 */var vs=N1,X9=(e,t)=>{if(t&&t.responseURL&&e!==t.responseURL)return t.responseURL;return e},gi=(e)=>{if(se.log.debug)return se.log.debug.bind(se,"VHS:",`${e} >`);return function(){}};function Vt(...e){let t=se.obj||se;return(t.merge||t.mergeOptions).apply(t,e)}function qn(...e){let t=se.time||se;return(t.createTimeRanges||t.createTimeRanges).apply(t,e)}function gH(e){if(e.length===0)return"Buffered Ranges are empty";let t=`Buffered Ranges:
200
+ `;for(let a=0;a<e.length;a++){let n=e.start(a),s=e.end(a);t+=`${n} --> ${s}. Duration (${s-n})
201
+ `}return t}var i0=0.03333333333333333,f0=i0*3,fq=function(e,t){let a=[],n;if(e&&e.length){for(n=0;n<e.length;n++)if(t(e.start(n),e.end(n)))a.push([e.start(n),e.end(n)])}return qn(a)},eo=function(e,t){return fq(e,function(a,n){return a-f0<=t&&n+f0>=t})},k9=function(e,t){return fq(e,function(a){return a-i0>=t})},pH=function(e){if(e.length<2)return qn();let t=[];for(let a=1;a<e.length;a++){let n=e.end(a-1),s=e.start(a);t.push([n,s])}return qn(t)},bH=function(e,t){let a=null,n=null,s=0,i=[],f=[];if(!e||!e.length||!t||!t.length)return qn();let l=e.length;while(l--)i.push({time:e.start(l),type:"start"}),i.push({time:e.end(l),type:"end"});l=t.length;while(l--)i.push({time:t.start(l),type:"start"}),i.push({time:t.end(l),type:"end"});i.sort(function(c,h){return c.time-h.time});for(l=0;l<i.length;l++){if(i[l].type==="start"){if(s++,s===2)a=i[l].time}else if(i[l].type==="end"){if(s--,s===1)n=i[l].time}if(a!==null&&n!==null)f.push([a,n]),a=null,n=null}return qn(f)},lq=(e)=>{let t=[];if(!e||!e.length)return"";for(let a=0;a<e.length;a++)t.push(e.start(a)+" => "+e.end(a));return t.join(", ")},wH=function(e,t,a=1){return((e.length?e.end(e.length-1):0)-t)/a},kr=(e)=>{let t=[];for(let a=0;a<e.length;a++)t.push({start:e.start(a),end:e.end(a)});return t},dH=function(e,t){if(e===t)return!1;if(!e&&t||!t&&e)return!0;if(e.length!==t.length)return!0;for(let a=0;a<e.length;a++)if(e.start(a)!==t.start(a)||e.end(a)!==t.end(a))return!0;return!1},e4=function(e){if(!e||!e.length||!e.end)return;return e.end(e.length-1)},dg=function(e,t){let a=0;if(!e||!e.length)return a;for(let n=0;n<e.length;n++){let s=e.start(n),i=e.end(n);if(t>i)continue;if(t>s&&t<=i){a+=i-t;continue}a+=i-s}return a},jg=(e,t)=>{if(!t.preload)return t.duration;let a=0;return(t.parts||[]).forEach(function(n){a+=n.duration}),(t.preloadHints||[]).forEach(function(n){if(n.type==="PART")a+=e.partTargetDuration}),a},b4=(e)=>(e.segments||[]).reduce((t,a,n)=>{if(a.parts)a.parts.forEach(function(s,i){t.push({duration:s.duration,segmentIndex:n,partIndex:i,part:s,segment:a})});else t.push({duration:a.duration,segmentIndex:n,partIndex:null,segment:a,part:null});return t},[]),rq=(e)=>{let t=e.segments&&e.segments.length&&e.segments[e.segments.length-1];return t&&t.parts||[]},oq=({preloadSegment:e})=>{if(!e)return;let{parts:t,preloadHints:a}=e,n=(a||[]).reduce((s,i)=>s+(i.type==="PART"?1:0),0);return n+=t&&t.length?t.length:0,n},cq=(e,t)=>{if(t.endList)return 0;if(e&&e.suggestedPresentationDelay)return e.suggestedPresentationDelay;let a=rq(t).length>0;if(a&&t.serverControl&&t.serverControl.partHoldBack)return t.serverControl.partHoldBack;else if(a&&t.partTargetDuration)return t.partTargetDuration*3;else if(t.serverControl&&t.serverControl.holdBack)return t.serverControl.holdBack;else if(t.targetDuration)return t.targetDuration*3;return 0},jH=function(e,t){let a=0,n=t-e.mediaSequence,s=e.segments[n];if(s){if(typeof s.start<"u")return{result:s.start,precise:!0};if(typeof s.end<"u")return{result:s.end-s.duration,precise:!0}}while(n--){if(s=e.segments[n],typeof s.end<"u")return{result:a+s.end,precise:!0};if(a+=jg(e,s),typeof s.start<"u")return{result:a+s.start,precise:!0}}return{result:a,precise:!1}},qH=function(e,t){let a=0,n,s=t-e.mediaSequence;for(;s<e.segments.length;s++){if(n=e.segments[s],typeof n.start<"u")return{result:n.start-a,precise:!0};if(a+=jg(e,n),typeof n.end<"u")return{result:n.end-a,precise:!0}}return{result:-1,precise:!1}},hq=function(e,t,a){if(typeof t>"u")t=e.mediaSequence+e.segments.length;if(t<e.mediaSequence)return 0;let n=jH(e,t);if(n.precise)return n.result;let s=qH(e,t);if(s.precise)return s.result;return n.result+a},uq=function(e,t,a){if(!e)return 0;if(typeof a!=="number")a=0;if(typeof t>"u"){if(e.totalDuration)return e.totalDuration;if(!e.endList)return V.default.Infinity}return hq(e,t,a)},Ch=function({defaultDuration:e,durationList:t,startIndex:a,endIndex:n}){let s=0;if(a>n)[a,n]=[n,a];if(a<0){for(let i=a;i<Math.min(0,n);i++)s+=e;a=0}for(let i=a;i<n;i++)s+=t[i].duration;return s},mq=function(e,t,a,n){if(!e||!e.segments)return null;if(e.endList)return uq(e);if(t===null)return null;t=t||0;let s=hq(e,e.mediaSequence+e.segments.length,t);if(a)n=typeof n==="number"?n:cq(null,e),s-=n;return Math.max(0,s)},vH=function(e,t,a){let s=t||0,i=mq(e,t,!0,a);if(i===null)return qn();if(i<s)i=s;return qn(s,i)},kH=function({playlist:e,currentTime:t,startingSegmentIndex:a,startingPartIndex:n,startTime:s,exactManifestTimings:i}){let f=t-s,l=b4(e),c=0;for(let h=0;h<l.length;h++){let u=l[h];if(a!==u.segmentIndex)continue;if(typeof n==="number"&&typeof u.partIndex==="number"&&n!==u.partIndex)continue;c=h;break}if(f<0){if(c>0)for(let h=c-1;h>=0;h--){let u=l[h];if(f+=u.duration,i){if(f<0)continue}else if(f+i0<=0)continue;return{partIndex:u.partIndex,segmentIndex:u.segmentIndex,startTime:s-Ch({defaultDuration:e.targetDuration,durationList:l,startIndex:c,endIndex:h})}}return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:t}}if(c<0){for(let h=c;h<0;h++)if(f-=e.targetDuration,f<0)return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:t};c=0}for(let h=c;h<l.length;h++){let u=l[h];f-=u.duration;let g=u.duration>i0,b=f===0,d=g&&f+i0>=0;if(b||d){if(h!==l.length-1)continue}if(i){if(f>0)continue}else if(f-i0>=0)continue;return{partIndex:u.partIndex,segmentIndex:u.segmentIndex,startTime:s+Ch({defaultDuration:e.targetDuration,durationList:l,startIndex:c,endIndex:h})}}return{segmentIndex:l[l.length-1].segmentIndex,partIndex:l[l.length-1].partIndex,startTime:t}},gq=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},qg=function(e){return e.excludeUntil&&e.excludeUntil===1/0},Sm=function(e){let t=gq(e);return!e.disabled&&!t},AH=function(e){return e.disabled},yH=function(e){for(let t=0;t<e.segments.length;t++)if(e.segments[t].key)return!0;return!1},pq=function(e,t){return t.attributes&&t.attributes[e]},SH=function(e,t,a,n=0){if(!pq("BANDWIDTH",a))return NaN;return(e*a.attributes.BANDWIDTH-n*8)/t},w4=(e,t)=>{if(e.playlists.length===1)return!0;let a=t.attributes.BANDWIDTH||Number.MAX_VALUE;return e.playlists.filter((n)=>{if(!Sm(n))return!1;return(n.attributes.BANDWIDTH||0)<a}).length===0},vg=(e,t)=>{if(!e&&!t||!e&&t||e&&!t)return!1;if(e===t)return!0;if(e.id&&t.id&&e.id===t.id)return!0;if(e.resolvedUri&&t.resolvedUri&&e.resolvedUri===t.resolvedUri)return!0;if(e.uri&&t.uri&&e.uri===t.uri)return!0;return!1},Hd=function(e,t){let a=e&&e.mediaGroups&&e.mediaGroups.AUDIO||{},n=!1;for(let s in a){for(let i in a[s])if(n=t(a[s][i]),n)break;if(n)break}return!!n},Rh=(e)=>{if(!e||!e.playlists||!e.playlists.length)return Hd(e,(a)=>a.playlists&&a.playlists.length||a.uri);for(let t=0;t<e.playlists.length;t++){let a=e.playlists[t],n=a.attributes&&a.attributes.CODECS;if(n&&n.split(",").every((i)=>r6(i)))continue;if(Hd(e,(i)=>vg(a,i)))continue;return!1}return!0},ks={liveEdgeDelay:cq,duration:uq,seekable:vH,getMediaInfoForTime:kH,isEnabled:Sm,isDisabled:AH,isExcluded:gq,isIncompatible:qg,playlistEnd:mq,isAes:yH,hasAttribute:pq,estimateSegmentRequestTime:SH,isLowestEnabledRendition:w4,isAudioOnly:Rh,playlistMatch:vg,segmentDurationWithParts:jg},{log:bq}=se,io=(e,t)=>{return`${e}-${t}`},wq=(e,t,a)=>{return`placeholder-uri-${e}-${t}-${a}`},CH=({onwarn:e,oninfo:t,manifestString:a,customTagParsers:n=[],customTagMappers:s=[],llhls:i})=>{let f=new f6;if(e)f.on("warn",e);if(t)f.on("info",t);n.forEach((h)=>f.addParser(h)),s.forEach((h)=>f.addTagMapper(h)),f.push(a),f.end();let l=f.manifest;if(!i){if(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(h){if(l.hasOwnProperty(h))delete l[h]}),l.segments)l.segments.forEach(function(h){["parts","preloadHints"].forEach(function(u){if(h.hasOwnProperty(u))delete h[u]})})}if(!l.targetDuration){let h=10;if(l.segments&&l.segments.length)h=l.segments.reduce((u,g)=>Math.max(u,g.duration),0);if(e)e({message:`manifest has no targetDuration defaulting to ${h}`});l.targetDuration=h}let c=rq(l);if(c.length&&!l.partTargetDuration){let h=c.reduce((u,g)=>Math.max(u,g.duration),0);if(e)e({message:`manifest has no partTargetDuration defaulting to ${h}`}),bq.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.");l.partTargetDuration=h}return l},ko=(e,t)=>{if(!e.mediaGroups)return;["AUDIO","SUBTITLES"].forEach((a)=>{if(!e.mediaGroups[a])return;for(let n in e.mediaGroups[a])for(let s in e.mediaGroups[a][n]){let i=e.mediaGroups[a][n][s];t(i,a,n,s)}})},dq=({playlist:e,uri:t,id:a})=>{if(e.id=a,e.playlistErrors_=0,t)e.uri=t;e.attributes=e.attributes||{}},_H=(e)=>{let t=e.playlists.length;while(t--){let a=e.playlists[t];if(dq({playlist:a,id:io(t,a.uri)}),a.resolvedUri=vs(e.uri,a.uri),e.playlists[a.id]=a,e.playlists[a.uri]=a,!a.attributes.BANDWIDTH)bq.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},FH=(e)=>{ko(e,(t)=>{if(t.uri)t.resolvedUri=vs(e.uri,t.uri)})},OH=(e,t)=>{let a=io(0,t),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:V.default.location.href,resolvedUri:V.default.location.href,playlists:[{uri:t,id:a,resolvedUri:t,attributes:{}}]};return n.playlists[a]=n.playlists[0],n.playlists[t]=n.playlists[0],n},jq=(e,t,a=wq)=>{e.uri=t;for(let s=0;s<e.playlists.length;s++)if(!e.playlists[s].uri){let i=`placeholder-uri-${s}`;e.playlists[s].uri=i}let n=Rh(e);ko(e,(s,i,f,l)=>{if(!s.playlists||!s.playlists.length){if(n&&i==="AUDIO"&&!s.uri)for(let c=0;c<e.playlists.length;c++){let h=e.playlists[c];if(h.attributes&&h.attributes.AUDIO&&h.attributes.AUDIO===f)return}s.playlists=[Fa({},s)]}s.playlists.forEach(function(c,h){let u=a(i,f,l,c),g=io(h,u);if(c.uri)c.resolvedUri=c.resolvedUri||vs(e.uri,c.uri);else c.uri=h===0?u:g,c.resolvedUri=c.uri;c.id=c.id||g,c.attributes=c.attributes||{},e.playlists[c.id]=c,e.playlists[c.uri]=c})}),_H(e),FH(e)};class d4{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null)return;if(!e.length)return;let[t]=e;if(t.programDateTime===void 0)return;this.offset_=t.programDateTime/1000}setPendingDateRanges(e=[]){if(!e.length)return;let[t]=e,a=t.startDate.getTime();this.trimProcessedDateRanges_(a),this.pendingDateRanges_=e.reduce((n,s)=>{return n.set(s.id,s),n},new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];let e={},t=[];this.pendingDateRanges_.forEach((a,n)=>{if(this.processedDateRanges_.has(n))return;if(a.startTime=a.startDate.getTime()/1000-this.offset_,a.processDateRange=()=>this.processDateRange(a),t.push(a),!a.class)return;if(e[a.class]){let s=e[a.class].push(a);a.classListIndex=s-1}else e[a.class]=[a],a.classListIndex=0});for(let a of t){let n=e[a.class]||[];if(a.endDate)a.endTime=a.endDate.getTime()/1000-this.offset_;else if(a.endOnNext&&n[a.classListIndex+1])a.endTime=n[a.classListIndex+1].startTime;else if(a.duration)a.endTime=a.startTime+a.duration;else if(a.plannedDuration)a.endTime=a.startTime+a.plannedDuration;else a.endTime=a.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((a,n)=>{if(a.startDate.getTime()<e)this.processedDateRanges_.delete(n)})}}var qq=22,Cr=({requestType:e,request:t,error:a,parseFailure:n})=>{let s=t.status<200||t.status>299,i=t.status>=400&&t.status<=499,f={uri:t.uri,requestType:e},l=s&&!i||n;if(a&&i)f.error=Fa({},a),f.errorType=se.Error.NetworkRequestFailed;else if(t.aborted)f.errorType=se.Error.NetworkRequestAborted;else if(t.timedout)f.errorType=se.Error.NetworkRequestTimeout;else if(l){let c=n?se.Error.NetworkBodyParserFailed:se.Error.NetworkBadStatus;f.errorType=c,f.status=t.status,f.headers=t.headers}return f},BH=gi("CodecUtils"),vq=function(e){let t=e.attributes||{};if(t.CODECS)return Ti(t.CODECS)},kq=(e,t)=>{let a=t.attributes||{};return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&a.AUDIO&&e.mediaGroups.AUDIO[a.AUDIO]},TH=(e,t)=>{if(!kq(e,t))return!0;let a=t.attributes||{},n=e.mediaGroups.AUDIO[a.AUDIO];for(let s in n)if(!n[s].uri&&!n[s].playlists)return!0;return!1},Hh=function(e){let t={};return e.forEach(({mediaType:a,type:n,details:s})=>{t[a]=t[a]||[],t[a].push(l6(`${n}${s}`))}),Object.keys(t).forEach(function(a){if(t[a].length>1){BH(`multiple ${a} codecs found as attributes: ${t[a].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),t[a]=null;return}t[a]=t[a][0]}),t},Md=function(e){let t=0;if(e.audio)t++;if(e.video)t++;return t},_h=function(e,t){let a=t.attributes||{},n=Hh(vq(t)||[]);if(kq(e,t)&&!n.audio){if(!TH(e,t)){let s=Hh(Fb(e,a.AUDIO)||[]);if(s.audio)n.audio=s.audio}}return n},{EventTarget:HH}=se,MH=(e,t)=>{if(t.endList||!t.serverControl)return e;let a={};if(t.serverControl.canBlockReload){let{preloadSegment:n}=t,s=t.mediaSequence+t.segments.length;if(n){let i=n.parts||[],f=oq(t)-1;if(f>-1&&f!==i.length-1)a._HLS_part=f;if(f>-1||i.length)s--}a._HLS_msn=s}if(t.serverControl&&t.serverControl.canSkipUntil)a._HLS_skip=t.serverControl.canSkipDateranges?"v2":"YES";if(Object.keys(a).length){let n=new V.default.URL(e);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(s){if(!a.hasOwnProperty(s))return;n.searchParams.set(s,a[s])}),e=n.toString()}return e},DH=(e,t)=>{if(!e)return t;let a=Vt(e,t);if(e.preloadHints&&!t.preloadHints)delete a.preloadHints;if(e.parts&&!t.parts)delete a.parts;else if(e.parts&&t.parts){for(let n=0;n<t.parts.length;n++)if(e.parts&&e.parts[n])a.parts[n]=Vt(e.parts[n],t.parts[n])}if(!e.skipped&&t.skipped)a.skipped=!1;if(e.preload&&!t.preload)a.preload=!1;return a},xH=(e,t,a)=>{let n=e.slice(),s=t.slice();a=a||0;let i=[],f;for(let l=0;l<s.length;l++){let c=n[l+a],h=s[l];if(c)f=c.map||f,i.push(DH(c,h));else{if(f&&!h.map)h.map=f;i.push(h)}}return i},Aq=(e,t)=>{if(!e.resolvedUri&&e.uri)e.resolvedUri=vs(t,e.uri);if(e.key&&!e.key.resolvedUri)e.key.resolvedUri=vs(t,e.key.uri);if(e.map&&!e.map.resolvedUri)e.map.resolvedUri=vs(t,e.map.uri);if(e.map&&e.map.key&&!e.map.key.resolvedUri)e.map.key.resolvedUri=vs(t,e.map.key.uri);if(e.parts&&e.parts.length)e.parts.forEach((a)=>{if(a.resolvedUri)return;a.resolvedUri=vs(t,a.uri)});if(e.preloadHints&&e.preloadHints.length)e.preloadHints.forEach((a)=>{if(a.resolvedUri)return;a.resolvedUri=vs(t,a.uri)})},yq=function(e){let t=e.segments||[],a=e.preloadSegment;if(a&&a.parts&&a.parts.length){if(a.preloadHints){for(let n=0;n<a.preloadHints.length;n++)if(a.preloadHints[n].type==="MAP")return t}a.duration=e.targetDuration,a.preload=!0,t.push(a)}return t},Sq=(e,t)=>e===t||e.segments&&t.segments&&e.segments.length===t.segments.length&&e.endList===t.endList&&e.mediaSequence===t.mediaSequence&&e.preloadSegment===t.preloadSegment,j4=(e,t,a=Sq)=>{let n=Vt(e,{}),s=n.playlists[t.id];if(!s)return null;if(a(s,t))return null;t.segments=yq(t);let i=Vt(s,t);if(i.preloadSegment&&!t.preloadSegment)delete i.preloadSegment;if(s.segments){if(t.skip){t.segments=t.segments||[];for(let f=0;f<t.skip.skippedSegments;f++)t.segments.unshift({skipped:!0})}i.segments=xH(s.segments,t.segments,t.mediaSequence-s.mediaSequence)}i.segments.forEach((f)=>{Aq(f,i.resolvedUri)});for(let f=0;f<n.playlists.length;f++)if(n.playlists[f].id===t.id)n.playlists[f]=i;return n.playlists[t.id]=i,n.playlists[t.uri]=i,ko(e,(f,l,c,h)=>{if(!f.playlists)return;for(let u=0;u<f.playlists.length;u++)if(t.id===f.playlists[u].id)f.playlists[u]=i}),n},q4=(e,t)=>{let a=e.segments||[],n=a[a.length-1],s=n&&n.parts&&n.parts[n.parts.length-1],i=s&&s.duration||n&&n.duration;if(t&&i)return i*1000;return(e.partTargetDuration||e.targetDuration||10)*500},Dd=(e,t,a)=>{if(!e)return;let n=[];return e.forEach((s)=>{if(!s.attributes)return;let{BANDWIDTH:i,RESOLUTION:f,CODECS:l}=s.attributes;n.push({id:s.id,bandwidth:i,resolution:f,codecs:l})}),{type:t,isLive:a,renditions:n}};class Ar extends HH{constructor(e,t,a={}){super();if(!e)throw Error("A non-empty playlist URL or object is required");this.logger_=gi("PlaylistLoader");let{withCredentials:n=!1}=a;this.src=e,this.vhs_=t,this.withCredentials=n,this.addDateRangesToTextTrack_=a.addDateRangesToTextTrack;let s=t.options_;this.customTagParsers=s&&s.customTagParsers||[],this.customTagMappers=s&&s.customTagMappers||[],this.llhls=s&&s.llhls,this.dateRangesStorage_=new d4,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){let e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);let t=this.dateRangesStorage_.getDateRangesToProcess();if(!t.length||!this.addDateRangesToTextTrack_)return;this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;let e=this.media(),t=vs(this.main.uri,e.uri);if(this.llhls)t=MH(t,e);this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(a,n)=>{if(!this.request)return;if(a)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})})}playlistRequestError(e,t,a){let{uri:n,id:s}=t;if(this.request=null,a)this.state=a;this.error={playlist:this.main.playlists[s],status:e.status,message:`HLS playlist request error at URL: ${n}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:Cr({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{let a=CH({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls});if(!a.playlists||!a.playlists.length)return a;return this.excludeAudioOnlyVariants(a.playlists),a}catch(a){this.error=a,this.error.metadata={errorType:se.Error.StreamingHlsPlaylistParserError,error:a}}}excludeAudioOnlyVariants(e){let t=(a)=>{let n=a.attributes||{},{width:s,height:i}=n.RESOLUTION||{};if(s&&i)return!0;let f=vq(a)||[],l=Hh(f);return Boolean(l.video)};if(e.some(t))e.forEach((a)=>{if(!t(a))a.excludeUntil=1/0})}haveMetadata({playlistString:e,playlistObject:t,url:a,id:n}){this.request=null,this.state="HAVE_METADATA";let s={playlistInfo:{type:"media",uri:a}};this.trigger({type:"playlistparsestart",metadata:s});let i=t||this.parseManifest_({url:a,manifestString:e});i.lastRequest=Date.now(),dq({playlist:i,uri:a,id:n});let f=j4(this.main,i);if(this.targetDuration=i.partTargetDuration||i.targetDuration,this.pendingMedia_=null,f)this.main=f,this.media_=this.main.playlists[n];else this.trigger("playlistunchanged");this.updateMediaUpdateTimeout_(q4(this.media(),!!f)),s.parsedPlaylist=Dd(this.main.playlists,s.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:s}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),V.default.clearTimeout(this.mediaUpdateTimeout),V.default.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new d4,this.off()}stopRequest(){if(this.request){let e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw Error("Cannot switch media playlist from "+this.state);if(typeof e==="string"){if(!this.main.playlists[e])throw Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(V.default.clearTimeout(this.finalRenditionTimeout),t){let f=(e.partTargetDuration||e.targetDuration)/2*1000||5000;this.finalRenditionTimeout=V.default.setTimeout(this.media.bind(this,e,!1),f);return}let a=this.state,n=!this.media_||e.id!==this.media_.id,s=this.main.playlists[e.id];if(s&&s.endList||e.endList&&e.segments.length){if(this.request)this.request.onreadystatechange=null,this.request.abort(),this.request=null;if(this.state="HAVE_METADATA",this.media_=e,n)if(this.trigger("mediachanging"),a==="HAVE_MAIN_MANIFEST")this.trigger("loadedmetadata");else this.trigger("mediachange");return}if(this.updateMediaUpdateTimeout_(q4(e,!0)),!n)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}if(this.media_)this.trigger("mediachanging");this.pendingMedia_=e;let i={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:i}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(f,l)=>{if(!this.request)return;if(e.lastRequest=Date.now(),e.resolvedUri=X9(e.resolvedUri,l),f)return this.playlistRequestError(this.request,e,a);if(this.trigger({type:"playlistrequestcomplete",metadata:i}),this.haveMetadata({playlistString:l.responseText,url:e.uri,id:e.id}),a==="HAVE_MAIN_MANIFEST")this.trigger("loadedmetadata");else this.trigger("mediachange")})}pause(){if(this.mediaUpdateTimeout)V.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;if(this.stopRequest(),this.state==="HAVE_NOTHING")this.started=!1;if(this.state==="SWITCHING_MEDIA")if(this.media_)this.state="HAVE_METADATA";else this.state="HAVE_MAIN_MANIFEST";else if(this.state==="HAVE_CURRENT_METADATA")this.state="HAVE_METADATA"}load(e){if(this.mediaUpdateTimeout)V.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;let t=this.media();if(e){let a=t?(t.partTargetDuration||t.targetDuration)/2*1000:5000;this.mediaUpdateTimeout=V.default.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},a);return}if(!this.started){this.start();return}if(t&&!t.endList)this.trigger("mediaupdatetimeout");else this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){if(this.mediaUpdateTimeout)V.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;if(!this.media()||this.media().endList)return;this.mediaUpdateTimeout=V.default.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e)}start(){if(this.started=!0,typeof this.src==="object"){if(!this.src.uri)this.src.uri=V.default.location.href;this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}let e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,a)=>{if(!this.request)return;if(this.request=null,t){if(this.error={status:a.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:a.responseText,code:2,metadata:Cr({requestType:a.requestType,request:a,error:t})},this.state==="HAVE_NOTHING")this.started=!1;return this.trigger("error")}this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=X9(this.src,a),this.trigger({type:"playlistparsestart",metadata:e});let n=this.parseManifest_({manifestString:a.responseText,url:this.src});e.parsedPlaylist=Dd(n.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(n)})}srcUri(){return typeof this.src==="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){if(this.main=e,jq(this.main,this.srcUri()),e.playlists.forEach((a)=>{a.segments=yq(a),a.segments.forEach((n)=>{Aq(n,a.resolvedUri)})}),this.trigger("loadedplaylist"),!this.request)this.media(this.main.playlists[0]);return}let t=this.srcUri()||V.default.location.href;this.main=OH(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){let a=this.main,n=e.ID,s=a.playlists.length;while(s--){let i=a.playlists[s];if(i.attributes["PATHWAY-ID"]===n){let{resolvedUri:f,id:l}=i;if(t){let c=this.createCloneURI_(i.resolvedUri,e),h=io(n,c),u=this.createCloneAttributes_(n,i.attributes),g=this.createClonePlaylist_(i,h,e,u);a.playlists[s]=g,a.playlists[h]=g,a.playlists[c]=g}else a.playlists.splice(s,1);delete a.playlists[l],delete a.playlists[f]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){let a=this.main,n=e.ID;if(["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((s)=>{if(!a.mediaGroups[s]||!a.mediaGroups[s][n])return;for(let i in a.mediaGroups[s])if(i===n){for(let f in a.mediaGroups[s][i])a.mediaGroups[s][i][f].playlists.forEach((c,h)=>{let u=a.playlists[c.id],g=u.id,b=u.resolvedUri;delete a.playlists[g],delete a.playlists[b]});delete a.mediaGroups[s][i]}}),t)this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){let a=this.main,n=a.playlists.length,s=this.createCloneURI_(t.resolvedUri,e),i=io(e.ID,s),f=this.createCloneAttributes_(e.ID,t.attributes),l=this.createClonePlaylist_(t,i,e,f);a.playlists[n]=l,a.playlists[i]=l,a.playlists[s]=l,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){let t=e.ID,a=e["BASE-ID"],n=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((s)=>{if(!n.mediaGroups[s]||n.mediaGroups[s][t])return;for(let i in n.mediaGroups[s]){if(i===a)n.mediaGroups[s][t]={};else continue;for(let f in n.mediaGroups[s][i]){let l=n.mediaGroups[s][i][f];n.mediaGroups[s][t][f]=Fa({},l);let c=n.mediaGroups[s][t][f],h=this.createCloneURI_(l.resolvedUri,e);c.resolvedUri=h,c.uri=h,c.playlists=[],l.playlists.forEach((u,g)=>{let b=n.playlists[u.id],d=wq(s,t,f),j=io(t,d);if(b&&!n.playlists[j]){let A=this.createClonePlaylist_(b,j,e),C=A.resolvedUri;n.playlists[j]=A,n.playlists[C]=A}c.playlists[g]=this.createClonePlaylist_(u,j,e)})}}})}createClonePlaylist_(e,t,a,n){let s=this.createCloneURI_(e.resolvedUri,a),i={resolvedUri:s,uri:s,id:t};if(e.segments)i.segments=[];if(n)i.attributes=n;return Vt(e,i)}createCloneURI_(e,t){let a=new URL(e);a.hostname=t["URI-REPLACEMENT"].HOST;let n=t["URI-REPLACEMENT"].PARAMS;for(let s of Object.keys(n))a.searchParams.set(s,n[s]);return a.href}createCloneAttributes_(e,t){let a={["PATHWAY-ID"]:e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((n)=>{if(t[n])a[n]=e}),a}getKeyIdSet(e){let t=new Set;if(!e||!e.contentProtection)return t;for(let a in e.contentProtection)if(e.contentProtection[a]&&e.contentProtection[a].attributes&&e.contentProtection[a].attributes.keyId){let n=e.contentProtection[a].attributes.keyId;t.add(n.toLowerCase())}return t}}var v4=function(e,t,a,n){let s=e.responseType==="arraybuffer"?e.response:e.responseText;if(!t&&s){if(e.responseTime=Date.now(),e.roundTripTime=e.responseTime-e.requestTime,e.bytesReceived=s.byteLength||s.length,!e.bandwidth)e.bandwidth=Math.floor(e.bytesReceived/e.roundTripTime*8*1000)}if(a.headers)e.responseHeaders=a.headers;if(t&&t.code==="ETIMEDOUT")e.timedout=!0;if(!t&&!e.aborted&&a.statusCode!==200&&a.statusCode!==206&&a.statusCode!==0)t=Error("XHR Failed with a response of: "+(e&&(s||e.responseText)));n(t,e)},RH=(e,t)=>{if(!e||!e.size)return;let a=t;return e.forEach((n)=>{a=n(a)}),a},NH=(e,t,a,n)=>{if(!e||!e.size)return;e.forEach((s)=>{s(t,a,n)})},Cq=function(){let e=function t(a,n){a=Vt({timeout:45000},a);let s=t.beforeRequest||se.Vhs.xhr.beforeRequest,i=t._requestCallbackSet||se.Vhs.xhr._requestCallbackSet||new Set,f=t._responseCallbackSet||se.Vhs.xhr._responseCallbackSet;if(s&&typeof s==="function")se.log.warn("beforeRequest is deprecated, use onRequest instead."),i.add(s);let l=se.Vhs.xhr.original===!0?se.xhr:se.Vhs.xhr,c=RH(i,a);i.delete(s);let h=l(c||a,function(g,b){return NH(f,h,g,b),v4(h,g,b,n)}),u=h.abort;return h.abort=function(){return h.aborted=!0,u.apply(h,arguments)},h.uri=a.uri,h.requestType=a.requestType,h.requestTime=Date.now(),h};return e.original=!0,e},EH=function(e){let t,a=e.offset;if(typeof e.offset==="bigint"||typeof e.length==="bigint")t=V.default.BigInt(e.offset)+V.default.BigInt(e.length)-V.default.BigInt(1);else t=e.offset+e.length-1;return"bytes="+a+"-"+t},k4=function(e){let t={};if(e.byterange)t.Range=EH(e.byterange);return t},zH=function(e,t){return e.start(t)+"-"+e.end(t)},UH=function(e,t){let a=e.toString(16);return"00".substring(0,2-a.length)+a+(t%2?" ":"")},IH=function(e){if(e>=32&&e<126)return String.fromCharCode(e);return"."},_q=function(e){let t={};return Object.keys(e).forEach((a)=>{let n=e[a];if(u6(n))t[a]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength};else t[a]=n}),t},K9=function(e){let t=e.byterange||{length:1/0,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")},Fq=function(e){return e.resolvedUri},Oq=(e)=>{let t=Array.prototype.slice.call(e),a=16,n="",s,i;for(let f=0;f<t.length/16;f++)s=t.slice(f*16,f*16+16).map(UH).join(""),i=t.slice(f*16,f*16+16).map(IH).join(""),n+=s+" "+i+`
202
+ `;return n},GH=({bytes:e})=>Oq(e),XH=(e)=>{let t="",a;for(a=0;a<e.length;a++)t+=zH(e,a)+" ";return t},KH=Object.freeze({__proto__:null,createTransferableMessage:_q,initSegmentId:K9,segmentKeyId:Fq,hexDump:Oq,tagDump:GH,textRanges:XH}),Bq=0.25,LH=(e,t)=>{if(!t.dateTimeObject)return null;let a=t.videoTimingInfo.transmuxerPrependedSeconds,s=t.videoTimingInfo.transmuxedPresentationStart+a,i=e-s;return new Date(t.dateTimeObject.getTime()+i*1000)},VH=(e)=>{return e.transmuxedPresentationEnd-e.transmuxedPresentationStart-e.transmuxerPrependedSeconds},YH=(e,t)=>{let a;try{a=new Date(e)}catch(c){return null}if(!t||!t.segments||t.segments.length===0)return null;let n=t.segments[0];if(a<new Date(n.dateTimeObject))return null;for(let c=0;c<t.segments.length-1;c++){n=t.segments[c];let h=new Date(t.segments[c+1].dateTimeObject);if(a<h)break}let s=t.segments[t.segments.length-1],i=s.dateTimeObject,f=s.videoTimingInfo?VH(s.videoTimingInfo):s.duration+s.duration*Bq,l=new Date(i.getTime()+f*1000);if(a>l)return null;if(a>new Date(i))n=s;return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:ks.duration(t,t.mediaSequence+t.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"}},JH=(e,t)=>{if(!t||!t.segments||t.segments.length===0)return null;let a=0,n;for(let i=0;i<t.segments.length;i++)if(n=t.segments[i],a=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:a+n.duration,e<=a)break;let s=t.segments[t.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<e)return null;if(e>a){if(e>a+s.duration*Bq)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:a-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},QH=(e,t)=>{let a,n;try{a=new Date(e),n=new Date(t)}catch(f){}let s=a.getTime();return(n.getTime()-s)/1000},ZH=(e)=>{if(!e.segments||e.segments.length===0)return!1;for(let t=0;t<e.segments.length;t++)if(!e.segments[t].dateTimeObject)return!1;return!0},$H=({playlist:e,time:t=void 0,callback:a})=>{if(!a)throw Error("getProgramTime: callback must be provided");if(!e||t===void 0)return a({message:"getProgramTime: playlist and time must be provided"});let n=JH(t,e);if(!n)return a({message:"valid programTime was not found"});if(n.type==="estimate")return a({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:n.estimatedStart});let s={mediaSeconds:t},i=LH(t,n.segment);if(i)s.programDateTime=i.toISOString();return a(null,s)},Tq=({programTime:e,playlist:t,retryCount:a=2,seekTo:n,pauseAfterSeek:s=!0,tech:i,callback:f})=>{if(!f)throw Error("seekToProgramTime: callback must be provided");if(typeof e>"u"||!t||!n)return f({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!i.hasStarted_)return f({message:"player must be playing a live stream to start buffering"});if(!ZH(t))return f({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});let l=YH(e,t);if(!l)return f({message:`${e} was not found in the stream`});let c=l.segment,h=QH(c.dateTimeObject,e);if(l.type==="estimate"){if(a===0)return f({message:`${e} is not buffered yet. Try again`});n(l.estimatedStart+h),i.one("seeked",()=>{Tq({programTime:e,playlist:t,retryCount:a-1,seekTo:n,pauseAfterSeek:s,tech:i,callback:f})});return}let u=c.start+h,g=()=>{return f(null,i.currentTime())};if(i.one("seeked",g),s)i.pause();n(u)},t4=(e,t)=>{if(e.readyState===4)return t();return},WH=(e,t,a,n)=>{let s=[],i,f=!1,l=function(g,b,d,j){return b.abort(),f=!0,a(g,b,d,j)},c=function(g,b){if(f)return;if(g)return g.metadata=Cr({requestType:n,request:b,error:g}),l(g,b,"",s);let d=b.responseText.substring(s&&s.byteLength||0,b.responseText.length);if(s=Hb(s,i9(d,!0)),i=i||dr(s),s.length<10||i&&s.length<i+2)return t4(b,()=>l(g,b,"",s));let j=j9(s);if(j==="ts"&&s.length<188)return t4(b,()=>l(g,b,"",s));if(!j&&s.length<376)return t4(b,()=>l(g,b,"",s));return l(null,b,j,s)},u=t({uri:e,beforeSend(g){g.overrideMimeType("text/plain; charset=x-user-defined"),g.addEventListener("progress",function({total:b,loaded:d}){return v4(g,null,{statusCode:g.status},c)})}},function(g,b){return v4(u,g,b,c)});return u},{EventTarget:PH}=se,xd=function(e,t){if(!Sq(e,t))return!1;if(e.sidx&&t.sidx&&(e.sidx.offset!==t.sidx.offset||e.sidx.length!==t.sidx.length))return!1;else if(!e.sidx&&t.sidx||e.sidx&&!t.sidx)return!1;if(e.segments&&!t.segments||!e.segments&&t.segments)return!1;if(!e.segments&&!t.segments)return!0;for(let a=0;a<e.segments.length;a++){let n=e.segments[a],s=t.segments[a];if(n.uri!==s.uri)return!1;if(!n.byterange&&!s.byterange)continue;let i=n.byterange,f=s.byterange;if(i&&!f||!i&&f)return!1;if(i.offset!==f.offset||i.length!==f.length)return!1}return!0},eM=(e,t,a,n)=>{let s=n.attributes.NAME||a;return`placeholder-uri-${e}-${t}-${s}`},tM=({mainXml:e,srcUrl:t,clientOffset:a,sidxMapping:n,previousManifest:s})=>{let i=zw(e,{manifestUri:t,clientOffset:a,sidxMapping:n,previousManifest:s});return jq(i,t,eM),i},aM=(e,t)=>{ko(e,(a,n,s,i)=>{if(!t.mediaGroups[n][s]||!(i in t.mediaGroups[n][s]))delete e.mediaGroups[n][s][i]})},nM=(e,t,a)=>{let n=!0,s=Vt(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod,timelineStarts:t.timelineStarts});for(let i=0;i<t.playlists.length;i++){let f=t.playlists[i];if(f.sidx){let c=ph(f.sidx);if(a&&a[c]&&a[c].sidx)b9(f,a[c].sidx,f.sidx.resolvedUri)}let l=j4(s,f,xd);if(l)s=l,n=!1}if(ko(t,(i,f,l,c)=>{if(i.playlists&&i.playlists.length){let h=i.playlists[0].id,u=j4(s,i.playlists[0],xd);if(u){if(s=u,!(c in s.mediaGroups[f][l]))s.mediaGroups[f][l][c]=i;s.mediaGroups[f][l][c].playlists[0]=s.playlists[h],n=!1}}}),aM(s,t),t.minimumUpdatePeriod!==e.minimumUpdatePeriod)n=!1;if(n)return null;return s},sM=(e,t)=>{return(Boolean(!e.map&&!t.map)||Boolean(e.map&&t.map&&e.map.byterange.offset===t.map.byterange.offset&&e.map.byterange.length===t.map.byterange.length))&&e.uri===t.uri&&e.byterange.offset===t.byterange.offset&&e.byterange.length===t.byterange.length},Rd=(e,t)=>{let a={};for(let n in e){let i=e[n].sidx;if(i){let f=ph(i);if(!t[f])break;let l=t[f].sidxInfo;if(sM(l,i))a[f]=t[f]}}return a},iM=(e,t)=>{let n=Rd(e.playlists,t);return ko(e,(s,i,f,l)=>{if(s.playlists&&s.playlists.length){let c=s.playlists;n=Vt(n,Rd(c,t))}}),n};class L9 extends PH{constructor(e,t,a={},n){super();if(this.isPaused_=!0,this.mainPlaylistLoader_=n||this,!n)this.isMain_=!0;let{withCredentials:s=!1}=a;if(this.vhs_=t,this.withCredentials=s,this.addMetadataToTextTrack=a.addMetadataToTextTrack,!e)throw Error("A non-empty playlist URL or object is required");if(this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=gi("DashPlaylistLoader"),this.isMain_)this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={};else this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,a){if(!this.request)return!0;if(this.request=null,e){if(this.error=typeof e==="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},a)this.state=a;return this.trigger("error"),!0}}addSidxSegments_(e,t,a){let n=e.sidx&&ph(e.sidx);if(!e.sidx||!n||this.mainPlaylistLoader_.sidxMapping_[n]){V.default.clearTimeout(this.mediaRequest_),this.mediaRequest_=V.default.setTimeout(()=>a(!1),0);return}let s=X9(e.sidx.resolvedUri),i=(l,c)=>{if(this.requestErrored_(l,c,t))return;let h=this.mainPlaylistLoader_.sidxMapping_,{requestType:u}=c,g;try{g=Zd.default(Ke(c.response).subarray(8))}catch(b){b.metadata=Cr({requestType:u,request:c,parseFailure:!0}),this.requestErrored_(b,c,t);return}return h[n]={sidxInfo:e.sidx,sidx:g},b9(e,g,e.sidx.resolvedUri),a(!0)},f="dash-sidx";this.request=WH(s,this.vhs_.xhr,(l,c,h,u)=>{if(l)return i(l,c);if(!h||h!=="mp4"){let d=h||"unknown";return i({status:c.status,message:`Unsupported ${d} container type for sidx segment at URL: ${s}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},c)}let{offset:g,length:b}=e.sidx.byterange;if(u.length>=b+g)return i(l,{response:u.subarray(g,g+b),status:c.status,uri:c.uri});this.request=this.vhs_.xhr({uri:s,responseType:"arraybuffer",requestType:"dash-sidx",headers:k4({byterange:e.sidx.byterange})},i)},f)}dispose(){if(this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},V.default.clearTimeout(this.minimumUpdatePeriodTimeout_),V.default.clearTimeout(this.mediaRequest_),V.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_)this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null;this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){let e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw Error("Cannot switch media playlist from "+this.state);let t=this.state;if(typeof e==="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}let a=!this.media_||e.id!==this.media_.id;if(a&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){if(this.state="HAVE_METADATA",this.media_=e,a)this.trigger("mediachanging"),this.trigger("mediachange");return}if(!a)return;if(this.media_)this.trigger("mediachanging");this.addSidxSegments_(e,t,(n)=>{this.haveMetadata({startingState:t,playlist:e})})}haveMetadata({startingState:e,playlist:t}){if(this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,V.default.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST")this.trigger("loadedmetadata");else this.trigger("mediachange")}pause(){if(this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_)this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null;if(this.stopRequest(),V.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_)V.default.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null;if(this.state==="HAVE_NOTHING")this.started=!1}load(e){this.isPaused_=!1,V.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;let t=this.media();if(e){let a=t?t.targetDuration/2*1000:5000;this.mediaUpdateTimeout=V.default.setTimeout(()=>this.load(),a);return}if(!this.started){this.start();return}if(t&&!t.endList){if(this.isMain_&&!this.minimumUpdatePeriodTimeout_)this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_();this.trigger("mediaupdatetimeout")}else this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){V.default.clearTimeout(this.mediaRequest_),this.mediaRequest_=V.default.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{if(this.haveMain_(),!this.hasPendingRequest()&&!this.media_)this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){let t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(a,n)=>{if(a){let{requestType:i}=n;a.metadata=Cr({requestType:i,request:n,error:a})}if(this.requestErrored_(a,n)){if(this.state==="HAVE_NOTHING")this.started=!1;return}this.trigger({type:"manifestrequestcomplete",metadata:t});let s=n.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date)this.mainLoaded_=Date.parse(n.responseHeaders.date);else this.mainLoaded_=Date.now();if(this.mainPlaylistLoader_.srcUrl=X9(this.mainPlaylistLoader_.srcUrl,n),s){this.handleMain_(),this.syncClientServerClock_(()=>{return e(n,s)});return}return e(n,s)})}syncClientServerClock_(e){let t=Uw(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:vs(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(a,n)=>{if(!this.request)return;if(a){let{requestType:i}=n;return this.error.metadata=Cr({requestType:i,request:n,error:a}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let s;if(t.method==="HEAD")if(!n.responseHeaders||!n.responseHeaders.date)s=this.mainLoaded_;else s=Date.parse(n.responseHeaders.date);else s=Date.parse(n.responseText);this.mainPlaylistLoader_.clientOffset_=s-Date.now(),e()})}haveMain_(){if(this.state="HAVE_MAIN_MANIFEST",this.isMain_)this.trigger("loadedplaylist");else if(!this.media_)this.media(this.childPlaylist_)}handleMain_(){V.default.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;let e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let a;try{a=tM({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(s){this.error=s,this.error.metadata={errorType:se.Error.StreamingDashManifestParserError,error:s},this.trigger("error")}if(e)a=nM(e,a,this.mainPlaylistLoader_.sidxMapping_);this.mainPlaylistLoader_.main=a?a:e;let n=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(n&&n!==this.mainPlaylistLoader_.srcUrl)this.mainPlaylistLoader_.srcUrl=n;if(!e||a&&a.minimumUpdatePeriod!==e.minimumUpdatePeriod)this.updateMinimumUpdatePeriodTimeout_();if(this.addEventStreamToMetadataTrack_(a),a){let{duration:s,endList:i}=a,f=[];a.playlists.forEach((c)=>{f.push({id:c.id,bandwidth:c.attributes.BANDWIDTH,resolution:c.attributes.RESOLUTION,codecs:c.attributes.CODECS})});let l={duration:s,isLive:!i,renditions:f};t.parsedManifest=l,this.trigger({type:"manifestparsecomplete",metadata:t})}return Boolean(a)}updateMinimumUpdatePeriodTimeout_(){let e=this.mainPlaylistLoader_;if(e.createMupOnMedia_)e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null;if(e.minimumUpdatePeriodTimeout_)V.default.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null;let t=e.main&&e.main.minimumUpdatePeriod;if(t===0)if(e.media())t=e.media().targetDuration*1000;else e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_);if(typeof t!=="number"||t<=0){if(t<0)this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){let t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=V.default.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{if(!t)return;if(this.media_)this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id];this.mainPlaylistLoader_.sidxMapping_=iM(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,(a)=>{this.refreshMedia_(this.media().id)})})}refreshMedia_(e){if(!e)throw Error("refreshMedia_ must take a media id");if(this.media_&&this.isMain_)this.handleMain_();let t=this.mainPlaylistLoader_.main.playlists,a=!this.media_||this.media_!==t[e];if(a)this.media_=t[e];else this.trigger("playlistunchanged");if(!this.mediaUpdateTimeout){let n=()=>{if(this.media().endList)return;this.mediaUpdateTimeout=V.default.setTimeout(()=>{this.trigger("mediaupdatetimeout"),n()},q4(this.media(),Boolean(a)))};n()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){let t=this.mainPlaylistLoader_.main.eventStream.map((a)=>{return{cueTime:a.start,frames:[{data:a.messageData}]}});this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){let t=new Set;for(let a in e.contentProtection){let n=e.contentProtection[a].attributes["cenc:default_KID"];if(n)t.add(n.replace(/-/g,"").toLowerCase())}return t}}}var jn={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30},fM=(e)=>{let t=new Uint8Array(new ArrayBuffer(e.length));for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a);return t.buffer},Hq=function(e){return e.on=e.addEventListener,e.off=e.removeEventListener,e},lM=function(e){try{return URL.createObjectURL(new Blob([e],{type:"application/javascript"}))}catch(t){let a=new BlobBuilder;return a.append(e),URL.createObjectURL(a.getBlob())}},Mq=function(e){return function(){let t=lM(e),a=Hq(new Worker(t));a.objURL=t;let n=a.terminate;return a.on=a.addEventListener,a.off=a.removeEventListener,a.terminate=function(){return URL.revokeObjectURL(t),n.call(this)},a}},Dq=function(e){return`var browserWorkerPolyFill = ${Hq.toString()};
203
+ browserWorkerPolyFill(self);
204
+ `+e},xq=function(e){return e.toString().replace(/^function.+?{/,"").slice(0,-1)},rM=Dq(xq(function(){var e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=function(){this.init=function(){var p={};this.on=function(q,v){if(!p[q])p[q]=[];p[q]=p[q].concat(v)},this.off=function(q,v){var k;if(!p[q])return!1;return k=p[q].indexOf(v),p[q]=p[q].slice(),p[q].splice(k,1),k>-1},this.trigger=function(q){var v,k,_,B;if(v=p[q],!v)return;if(arguments.length===2){_=v.length;for(k=0;k<_;++k)v[k].call(this,arguments[1])}else{B=[],k=arguments.length;for(k=1;k<arguments.length;++k)B.push(arguments[k]);_=v.length;for(k=0;k<_;++k)v[k].apply(this,B)}},this.dispose=function(){p={}}}};t.prototype.pipe=function(p){return this.on("data",function(q){p.push(q)}),this.on("done",function(q){p.flush(q)}),this.on("partialdone",function(q){p.partialFlush(q)}),this.on("endedtimeline",function(q){p.endTimeline(q)}),this.on("reset",function(q){p.reset(q)}),p},t.prototype.push=function(p){this.trigger("data",p)},t.prototype.flush=function(p){this.trigger("done",p)},t.prototype.partialFlush=function(p){this.trigger("partialdone",p)},t.prototype.endTimeline=function(p){this.trigger("endedtimeline",p)},t.prototype.reset=function(p){this.trigger("reset",p)};var a=t,n=Math.pow(2,32),s=function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v;if(q.getBigUint64){if(v=q.getBigUint64(0),v<Number.MAX_SAFE_INTEGER)return Number(v);return v}return q.getUint32(0)*n+q.getUint32(4)},i={getUint64:s,MAX_UINT32:n},f=i.MAX_UINT32,l,c,h,u,g,b,d,j,A,C,y,O,T,M,H,N,x,z,K,$,Q,P,te,ee,L,J,pe,ne,fe,Ae,he,re,be,Ue,at,Ye;(function(){var p;if(te={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},typeof Uint8Array>"u")return;for(p in te)if(te.hasOwnProperty(p))te[p]=[p.charCodeAt(0),p.charCodeAt(1),p.charCodeAt(2),p.charCodeAt(3)];ee=new Uint8Array([105,115,111,109]),J=new Uint8Array([97,118,99,49]),L=new Uint8Array([0,0,0,1]),pe=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]),ne=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]),fe={video:pe,audio:ne},re=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),he=new Uint8Array([0,0,0,0,0,0,0,0]),be=new Uint8Array([0,0,0,0,0,0,0,0]),Ue=be,at=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ye=be,Ae=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])})(),l=function(p){var q=[],v=0,k,_,B;for(k=1;k<arguments.length;k++)q.push(arguments[k]);k=q.length;while(k--)v+=q[k].byteLength;_=new Uint8Array(v+8),B=new DataView(_.buffer,_.byteOffset,_.byteLength),B.setUint32(0,_.byteLength),_.set(p,4);for(k=0,v=8;k<q.length;k++)_.set(q[k],v),v+=q[k].byteLength;return _},c=function(){return l(te.dinf,l(te.dref,re))},h=function(p){return l(te.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,p.audioobjecttype<<3|p.samplingfrequencyindex>>>1,p.samplingfrequencyindex<<7|p.channelcount<<3,6,1,2]))},u=function(){return l(te.ftyp,ee,L,ee,J)},N=function(p){return l(te.hdlr,fe[p])},g=function(p){return l(te.mdat,p)},H=function(p){var q=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,p.duration>>>24&255,p.duration>>>16&255,p.duration>>>8&255,p.duration&255,85,196,0,0]);if(p.samplerate)q[12]=p.samplerate>>>24&255,q[13]=p.samplerate>>>16&255,q[14]=p.samplerate>>>8&255,q[15]=p.samplerate&255;return l(te.mdhd,q)},M=function(p){return l(te.mdia,H(p),N(p.type),d(p))},b=function(p){return l(te.mfhd,new Uint8Array([0,0,0,0,(p&4278190080)>>24,(p&16711680)>>16,(p&65280)>>8,p&255]))},d=function(p){return l(te.minf,p.type==="video"?l(te.vmhd,Ae):l(te.smhd,he),c(),z(p))},j=function(p,q){var v=[],k=q.length;while(k--)v[k]=$(q[k]);return l.apply(null,[te.moof,b(p)].concat(v))},A=function(p){var q=p.length,v=[];while(q--)v[q]=O(p[q]);return l.apply(null,[te.moov,y(4294967295)].concat(v).concat(C(p)))},C=function(p){var q=p.length,v=[];while(q--)v[q]=Q(p[q]);return l.apply(null,[te.mvex].concat(v))},y=function(p){var q=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(p&4278190080)>>24,(p&16711680)>>16,(p&65280)>>8,p&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return l(te.mvhd,q)},x=function(p){var q=p.samples||[],v=new Uint8Array(4+q.length),k,_;for(_=0;_<q.length;_++)k=q[_].flags,v[_+4]=k.dependsOn<<4|k.isDependedOn<<2|k.hasRedundancy;return l(te.sdtp,v)},z=function(p){return l(te.stbl,K(p),l(te.stts,Ye),l(te.stsc,Ue),l(te.stsz,at),l(te.stco,be))},function(){var p,q;K=function(v){return l(te.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),v.type==="video"?p(v):q(v))},p=function(v){var k=v.sps||[],_=v.pps||[],B=[],E=[],U,G;for(U=0;U<k.length;U++)B.push((k[U].byteLength&65280)>>>8),B.push(k[U].byteLength&255),B=B.concat(Array.prototype.slice.call(k[U]));for(U=0;U<_.length;U++)E.push((_[U].byteLength&65280)>>>8),E.push(_[U].byteLength&255),E=E.concat(Array.prototype.slice.call(_[U]));if(G=[te.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,(v.width&65280)>>8,v.width&255,(v.height&65280)>>8,v.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(te.avcC,new Uint8Array([1,v.profileIdc,v.profileCompatibility,v.levelIdc,255].concat([k.length],B,[_.length],E))),l(te.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],v.sarRatio){var X=v.sarRatio[0],W=v.sarRatio[1];G.push(l(te.pasp,new Uint8Array([(X&4278190080)>>24,(X&16711680)>>16,(X&65280)>>8,X&255,(W&4278190080)>>24,(W&16711680)>>16,(W&65280)>>8,W&255])))}return l.apply(null,G)},q=function(v){return l(te.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(v.channelcount&65280)>>8,v.channelcount&255,(v.samplesize&65280)>>8,v.samplesize&255,0,0,0,0,(v.samplerate&65280)>>8,v.samplerate&255,0,0]),h(v))}}(),T=function(p){var q=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(p.id&4278190080)>>24,(p.id&16711680)>>16,(p.id&65280)>>8,p.id&255,0,0,0,0,(p.duration&4278190080)>>24,(p.duration&16711680)>>16,(p.duration&65280)>>8,p.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(p.width&65280)>>8,p.width&255,0,0,(p.height&65280)>>8,p.height&255,0,0]);return l(te.tkhd,q)},$=function(p){var q,v,k,_,B,E,U;if(q=l(te.tfhd,new Uint8Array([0,0,0,58,(p.id&4278190080)>>24,(p.id&16711680)>>16,(p.id&65280)>>8,p.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),E=Math.floor(p.baseMediaDecodeTime/f),U=Math.floor(p.baseMediaDecodeTime%f),v=l(te.tfdt,new Uint8Array([1,0,0,0,E>>>24&255,E>>>16&255,E>>>8&255,E&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255])),B=92,p.type==="audio")return k=P(p,B),l(te.traf,q,v,k);return _=x(p),k=P(p,_.length+B),l(te.traf,q,v,k,_)},O=function(p){return p.duration=p.duration||4294967295,l(te.trak,T(p),M(p))},Q=function(p){var q=new Uint8Array([0,0,0,0,(p.id&4278190080)>>24,(p.id&16711680)>>16,(p.id&65280)>>8,p.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);if(p.type!=="video")q[q.length-1]=0;return l(te.trex,q)},function(){var p,q,v;v=function(k,_){var B=0,E=0,U=0,G=0;if(k.length){if(k[0].duration!==void 0)B=1;if(k[0].size!==void 0)E=2;if(k[0].flags!==void 0)U=4;if(k[0].compositionTimeOffset!==void 0)G=8}return[0,0,B|E|U|G,1,(k.length&4278190080)>>>24,(k.length&16711680)>>>16,(k.length&65280)>>>8,k.length&255,(_&4278190080)>>>24,(_&16711680)>>>16,(_&65280)>>>8,_&255]},q=function(k,_){var B,E,U,G,X,W;G=k.samples||[],_+=20+16*G.length,U=v(G,_),E=new Uint8Array(U.length+G.length*16),E.set(U),B=U.length;for(W=0;W<G.length;W++)X=G[W],E[B++]=(X.duration&4278190080)>>>24,E[B++]=(X.duration&16711680)>>>16,E[B++]=(X.duration&65280)>>>8,E[B++]=X.duration&255,E[B++]=(X.size&4278190080)>>>24,E[B++]=(X.size&16711680)>>>16,E[B++]=(X.size&65280)>>>8,E[B++]=X.size&255,E[B++]=X.flags.isLeading<<2|X.flags.dependsOn,E[B++]=X.flags.isDependedOn<<6|X.flags.hasRedundancy<<4|X.flags.paddingValue<<1|X.flags.isNonSyncSample,E[B++]=X.flags.degradationPriority&61440,E[B++]=X.flags.degradationPriority&15,E[B++]=(X.compositionTimeOffset&4278190080)>>>24,E[B++]=(X.compositionTimeOffset&16711680)>>>16,E[B++]=(X.compositionTimeOffset&65280)>>>8,E[B++]=X.compositionTimeOffset&255;return l(te.trun,E)},p=function(k,_){var B,E,U,G,X,W;G=k.samples||[],_+=20+8*G.length,U=v(G,_),B=new Uint8Array(U.length+G.length*8),B.set(U),E=U.length;for(W=0;W<G.length;W++)X=G[W],B[E++]=(X.duration&4278190080)>>>24,B[E++]=(X.duration&16711680)>>>16,B[E++]=(X.duration&65280)>>>8,B[E++]=X.duration&255,B[E++]=(X.size&4278190080)>>>24,B[E++]=(X.size&16711680)>>>16,B[E++]=(X.size&65280)>>>8,B[E++]=X.size&255;return l(te.trun,B)},P=function(k,_){if(k.type==="audio")return p(k,_);return q(k,_)}}();var Ie={ftyp:u,mdat:g,moof:j,moov:A,initSegment:function(p){var q=u(),v=A(p),k;return k=new Uint8Array(q.byteLength+v.byteLength),k.set(q),k.set(v,q.byteLength),k}},mt=function(p){var q,v,k=[],_=[];_.byteLength=0,_.nalCount=0,_.duration=0,k.byteLength=0;for(q=0;q<p.length;q++)if(v=p[q],v.nalUnitType==="access_unit_delimiter_rbsp"){if(k.length)k.duration=v.dts-k.dts,_.byteLength+=k.byteLength,_.nalCount+=k.length,_.duration+=k.duration,_.push(k);k=[v],k.byteLength=v.data.byteLength,k.pts=v.pts,k.dts=v.dts}else{if(v.nalUnitType==="slice_layer_without_partitioning_rbsp_idr")k.keyFrame=!0;k.duration=v.dts-k.dts,k.byteLength+=v.data.byteLength,k.push(v)}if(_.length&&(!k.duration||k.duration<=0))k.duration=_[_.length-1].duration;return _.byteLength+=k.byteLength,_.nalCount+=k.length,_.duration+=k.duration,_.push(k),_},vt=function(p){var q,v,k=[],_=[];k.byteLength=0,k.nalCount=0,k.duration=0,k.pts=p[0].pts,k.dts=p[0].dts,_.byteLength=0,_.nalCount=0,_.duration=0,_.pts=p[0].pts,_.dts=p[0].dts;for(q=0;q<p.length;q++)if(v=p[q],v.keyFrame){if(k.length)_.push(k),_.byteLength+=k.byteLength,_.nalCount+=k.nalCount,_.duration+=k.duration;k=[v],k.nalCount=v.length,k.byteLength=v.byteLength,k.pts=v.pts,k.dts=v.dts,k.duration=v.duration}else k.duration+=v.duration,k.nalCount+=v.length,k.byteLength+=v.byteLength,k.push(v);if(_.length&&k.duration<=0)k.duration=_[_.length-1].duration;return _.byteLength+=k.byteLength,_.nalCount+=k.nalCount,_.duration+=k.duration,_.push(k),_},ga=function(p){var q;if(!p[0][0].keyFrame&&p.length>1)q=p.shift(),p.byteLength-=q.byteLength,p.nalCount-=q.nalCount,p[0][0].dts=q.dts,p[0][0].pts=q.pts,p[0][0].duration+=q.duration;return p},Dt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},ta=function(p,q){var v=Dt();if(v.dataOffset=q,v.compositionTimeOffset=p.pts-p.dts,v.duration=p.duration,v.size=4*p.length,v.size+=p.byteLength,p.keyFrame)v.flags.dependsOn=2,v.flags.isNonSyncSample=0;return v},rn=function(p,q){var v,k,_,B,E,U=q||0,G=[];for(v=0;v<p.length;v++){B=p[v];for(k=0;k<B.length;k++)E=B[k],_=ta(E,U),U+=_.size,G.push(_)}return G},jt=function(p){var q,v,k,_,B,E,U=0,G=p.byteLength,X=p.nalCount,W=G+4*X,oe=new Uint8Array(W),Oe=new DataView(oe.buffer);for(q=0;q<p.length;q++){_=p[q];for(v=0;v<_.length;v++){B=_[v];for(k=0;k<B.length;k++)E=B[k],Oe.setUint32(U,E.data.byteLength),U+=4,oe.set(E.data,U),U+=E.data.byteLength}}return oe},xe=function(p,q){var v,k=q||0,_=[];return v=ta(p,k),_.push(v),_},ze=function(p){var q,v,k=0,_=p.byteLength,B=p.length,E=_+4*B,U=new Uint8Array(E),G=new DataView(U.buffer);for(q=0;q<p.length;q++)v=p[q],G.setUint32(k,v.data.byteLength),k+=4,U.set(v.data,k),k+=v.data.byteLength;return U},Qe={groupNalsIntoFrames:mt,groupFramesIntoGops:vt,extendFirstKeyFrame:ga,generateSampleTable:rn,concatenateNalData:jt,generateSampleTableForFrame:xe,concatenateNalDataForFrame:ze},nt=[33,16,5,32,164,27],Ot=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],Ze=function(p){var q=[];while(p--)q.push(0);return q},Yt=function(p){return Object.keys(p).reduce(function(q,v){return q[v]=new Uint8Array(p[v].reduce(function(k,_){return k.concat(_)},[])),q},{})},wt,yn=function(){if(!wt){var p={96000:[nt,[227,64],Ze(154),[56]],88200:[nt,[231],Ze(170),[56]],64000:[nt,[248,192],Ze(240),[56]],48000:[nt,[255,192],Ze(268),[55,148,128],Ze(54),[112]],44100:[nt,[255,192],Ze(268),[55,163,128],Ze(84),[112]],32000:[nt,[255,192],Ze(268),[55,234],Ze(226),[112]],24000:[nt,[255,192],Ze(268),[55,255,128],Ze(268),[111,112],Ze(126),[224]],16000:[nt,[255,192],Ze(268),[55,255,128],Ze(268),[111,255],Ze(269),[223,108],Ze(195),[1,192]],12000:[Ot,Ze(268),[3,127,248],Ze(268),[6,255,240],Ze(268),[13,255,224],Ze(268),[27,253,128],Ze(259),[56]],11025:[Ot,Ze(268),[3,127,248],Ze(268),[6,255,240],Ze(268),[13,255,224],Ze(268),[27,255,192],Ze(268),[55,175,128],Ze(108),[112]],8000:[Ot,Ze(268),[3,121,16],Ze(47),[7]]};wt=Yt(p)}return wt},zn=90000,Ya,Ja,Sn,pa,Da,Os,ls;Ya=function(p){return p*zn},Ja=function(p,q){return p*q},Sn=function(p){return p/zn},pa=function(p,q){return p/q},Da=function(p,q){return Ya(pa(p,q))},Os=function(p,q){return Ja(Sn(p),q)},ls=function(p,q,v){return Sn(v?p:p-q)};var Bt={ONE_SECOND_IN_TS:zn,secondsToVideoTs:Ya,secondsToAudioTs:Ja,videoTsToSeconds:Sn,audioTsToSeconds:pa,audioTsToVideoTs:Da,videoTsToAudioTs:Os,metadataTsToSeconds:ls},de=yn,$e=Bt,Je=function(p){var q,v,k=0;for(q=0;q<p.length;q++)v=p[q],k+=v.data.byteLength;return k},xt=function(p,q,v,k){var _,B=0,E=0,U=0,G=0,X,W,oe;if(!q.length)return;if(_=$e.audioTsToVideoTs(p.baseMediaDecodeTime,p.samplerate),B=Math.ceil($e.ONE_SECOND_IN_TS/(p.samplerate/1024)),v&&k)E=_-Math.max(v,k),U=Math.floor(E/B),G=U*B;if(U<1||G>$e.ONE_SECOND_IN_TS/2)return;if(X=de()[p.samplerate],!X)X=q[0].data;for(W=0;W<U;W++)oe=q[0],q.splice(0,0,{data:X,dts:oe.dts-B,pts:oe.pts-B});return p.baseMediaDecodeTime-=Math.floor($e.videoTsToAudioTs(G,p.samplerate)),G},ka=function(p,q,v){if(q.minSegmentDts>=v)return p;return q.minSegmentDts=1/0,p.filter(function(k){if(k.dts>=v)return q.minSegmentDts=Math.min(q.minSegmentDts,k.dts),q.minSegmentPts=q.minSegmentDts,!0;return!1})},ia=function(p){var q,v,k=[];for(q=0;q<p.length;q++)v=p[q],k.push({size:v.data.byteLength,duration:1024});return k},Me=function(p){var q,v,k=0,_=new Uint8Array(Je(p));for(q=0;q<p.length;q++)v=p[q],_.set(v.data,k),k+=v.data.byteLength;return _},Re={prefixWithSilence:xt,trimAdtsFramesByEarliestDts:ka,generateSampleTable:ia,concatenateFrameData:Me},zt=Bt.ONE_SECOND_IN_TS,Ua=function(p,q){if(typeof q.pts==="number"){if(p.timelineStartInfo.pts===void 0)p.timelineStartInfo.pts=q.pts;if(p.minSegmentPts===void 0)p.minSegmentPts=q.pts;else p.minSegmentPts=Math.min(p.minSegmentPts,q.pts);if(p.maxSegmentPts===void 0)p.maxSegmentPts=q.pts;else p.maxSegmentPts=Math.max(p.maxSegmentPts,q.pts)}if(typeof q.dts==="number"){if(p.timelineStartInfo.dts===void 0)p.timelineStartInfo.dts=q.dts;if(p.minSegmentDts===void 0)p.minSegmentDts=q.dts;else p.minSegmentDts=Math.min(p.minSegmentDts,q.dts);if(p.maxSegmentDts===void 0)p.maxSegmentDts=q.dts;else p.maxSegmentDts=Math.max(p.maxSegmentDts,q.dts)}},Se=function(p){delete p.minSegmentDts,delete p.maxSegmentDts,delete p.minSegmentPts,delete p.maxSegmentPts},Te=function(p,q){var v,k,_=p.minSegmentDts;if(!q)_-=p.timelineStartInfo.dts;if(v=p.timelineStartInfo.baseMediaDecodeTime,v+=_,v=Math.max(0,v),p.type==="audio")k=p.samplerate/zt,v*=k,v=Math.floor(v);return v},Xe={clearDtsInfo:Se,calculateTrackBaseMediaDecodeTime:Te,collectDtsInfo:Ua},Le=4,Aa=128,ha=function(p){var q=0,v={payloadType:-1,payloadSize:0},k=0,_=0;while(q<p.byteLength){if(p[q]===Aa)break;while(p[q]===255)k+=255,q++;k+=p[q++];while(p[q]===255)_+=255,q++;if(_+=p[q++],!v.payload&&k===Le){var B=String.fromCharCode(p[q+3],p[q+4],p[q+5],p[q+6]);if(B==="GA94"){v.payloadType=k,v.payloadSize=_,v.payload=p.subarray(q,q+_);break}else v.payload=void 0}q+=_,k=0,_=0}return v},$s=function(p){if(p.payload[0]!==181)return null;if((p.payload[1]<<8|p.payload[2])!==49)return null;if(String.fromCharCode(p.payload[3],p.payload[4],p.payload[5],p.payload[6])!=="GA94")return null;if(p.payload[7]!==3)return null;return p.payload.subarray(8,p.payload.length-1)},S0=function(p,q){var v=[],k,_,B,E;if(!(q[0]&64))return v;_=q[0]&31;for(k=0;k<_;k++)if(B=k*3,E={type:q[B+2]&3,pts:p},q[B+2]&4)E.ccData=q[B+3]<<8|q[B+4],v.push(E);return v},Kr=function(p){var q=p.byteLength,v=[],k=1,_,B;while(k<q-2)if(p[k]===0&&p[k+1]===0&&p[k+2]===3)v.push(k+2),k+=2;else k++;if(v.length===0)return p;_=q-v.length,B=new Uint8Array(_);var E=0;for(k=0;k<_;E++,k++){if(E===v[0])E++,v.shift();B[k]=p[E]}return B},Vo={parseSei:ha,parseUserData:$s,parseCaptionPackets:S0,discardEmulationPreventionBytes:Kr,USER_DATA_REGISTERED_ITU_T_T35:Le},bf=a,C0=Vo,on=function(p){if(p=p||{},on.prototype.init.call(this),this.parse708captions_=typeof p.parse708captions==="boolean"?p.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new fa(0,0),new fa(0,1),new fa(1,0),new fa(1,1)],this.parse708captions_)this.cc708Stream_=new St({captionServices:p.captionServices});if(this.reset(),this.ccStreams_.forEach(function(q){q.on("data",this.trigger.bind(this,"data")),q.on("partialdone",this.trigger.bind(this,"partialdone")),q.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_)this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done"))};on.prototype=new bf,on.prototype.push=function(p){var q,v,k;if(p.nalUnitType!=="sei_rbsp")return;if(q=C0.parseSei(p.escapedRBSP),!q.payload)return;if(q.payloadType!==C0.USER_DATA_REGISTERED_ITU_T_T35)return;if(v=C0.parseUserData(q),!v)return;if(p.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(p.dts===this.latestDts_&&this.ignoreNextEqualDts_){if(this.numSameDts_--,!this.numSameDts_)this.ignoreNextEqualDts_=!1;return}if(k=C0.parseCaptionPackets(p.pts,v),this.captionPackets_=this.captionPackets_.concat(k),this.latestDts_!==p.dts)this.numSameDts_=0;this.numSameDts_++,this.latestDts_=p.dts},on.prototype.flushCCStreams=function(p){this.ccStreams_.forEach(function(q){return p==="flush"?q.flush():q.partialFlush()},this)},on.prototype.flushStream=function(p){if(!this.captionPackets_.length){this.flushCCStreams(p);return}this.captionPackets_.forEach(function(q,v){q.presortIndex=v}),this.captionPackets_.sort(function(q,v){if(q.pts===v.pts)return q.presortIndex-v.presortIndex;return q.pts-v.pts}),this.captionPackets_.forEach(function(q){if(q.type<2)this.dispatchCea608Packet(q);else this.dispatchCea708Packet(q)},this),this.captionPackets_.length=0,this.flushCCStreams(p)},on.prototype.flush=function(){return this.flushStream("flush")},on.prototype.partialFlush=function(){return this.flushStream("partialFlush")},on.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(p){p.reset()})},on.prototype.dispatchCea608Packet=function(p){if(this.setsTextOrXDSActive(p))this.activeCea608Channel_[p.type]=null;else if(this.setsChannel1Active(p))this.activeCea608Channel_[p.type]=0;else if(this.setsChannel2Active(p))this.activeCea608Channel_[p.type]=1;if(this.activeCea608Channel_[p.type]===null)return;this.ccStreams_[(p.type<<1)+this.activeCea608Channel_[p.type]].push(p)},on.prototype.setsChannel1Active=function(p){return(p.ccData&30720)===4096},on.prototype.setsChannel2Active=function(p){return(p.ccData&30720)===6144},on.prototype.setsTextOrXDSActive=function(p){return(p.ccData&28928)===256||(p.ccData&30974)===4138||(p.ccData&30974)===6186},on.prototype.dispatchCea708Packet=function(p){if(this.parse708captions_)this.cc708Stream_.push(p)};var _0={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},y2=function(p){var q=_0[p]||p;if(p&4096&&p===q)return"";return String.fromCharCode(q)},F0=function(p){return 32<=p&&p<=127||160<=p&&p<=255},Bs=function(p){this.windowNum=p,this.reset()};Bs.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},Bs.prototype.getText=function(){return this.rows.join(`
205
+ `)},Bs.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},Bs.prototype.newLine=function(p){if(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow==="function")this.beforeRowOverflow(p);if(this.rows.length>0)this.rows.push(""),this.rowIdx++;while(this.rows.length>this.virtualRowCount)this.rows.shift(),this.rowIdx--},Bs.prototype.isEmpty=function(){if(this.rows.length===0)return!0;else if(this.rows.length===1)return this.rows[0]==="";return!1},Bs.prototype.addText=function(p){this.rows[this.rowIdx]+=p},Bs.prototype.backspace=function(){if(!this.isEmpty()){var p=this.rows[this.rowIdx];this.rows[this.rowIdx]=p.substr(0,p.length-1)}};var wf=function(p,q,v){if(this.serviceNum=p,this.text="",this.currentWindow=new Bs(-1),this.windows=[],this.stream=v,typeof q==="string")this.createTextDecoder(q)};wf.prototype.init=function(p,q){this.startPts=p;for(var v=0;v<8;v++)if(this.windows[v]=new Bs(v),typeof q==="function")this.windows[v].beforeRowOverflow=q},wf.prototype.setCurrentWindow=function(p){this.currentWindow=this.windows[p]},wf.prototype.createTextDecoder=function(p){if(typeof TextDecoder>"u")this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(p)}catch(q){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+p+" encoding. "+q})}};var St=function(p){p=p||{},St.prototype.init.call(this);var q=this,v=p.captionServices||{},k={},_;Object.keys(v).forEach((B)=>{if(_=v[B],/^SERVICE/.test(B))k[B]=_.encoding}),this.serviceEncodings=k,this.current708Packet=null,this.services={},this.push=function(B){if(B.type===3)q.new708Packet(),q.add708Bytes(B);else{if(q.current708Packet===null)q.new708Packet();q.add708Bytes(B)}}};St.prototype=new bf,St.prototype.new708Packet=function(){if(this.current708Packet!==null)this.push708Packet();this.current708Packet={data:[],ptsVals:[]}},St.prototype.add708Bytes=function(p){var q=p.ccData,v=q>>>8,k=q&255;this.current708Packet.ptsVals.push(p.pts),this.current708Packet.data.push(v),this.current708Packet.data.push(k)},St.prototype.push708Packet=function(){var p=this.current708Packet,q=p.data,v=null,k=null,_=0,B=q[_++];p.seq=B>>6,p.sizeCode=B&63;for(;_<q.length;_++){if(B=q[_++],v=B>>5,k=B&31,v===7&&k>0)B=q[_++],v=B;if(this.pushServiceBlock(v,_,k),k>0)_+=k-1}},St.prototype.pushServiceBlock=function(p,q,v){var k,_=q,B=this.current708Packet.data,E=this.services[p];if(!E)E=this.initService(p,_);for(;_<q+v&&_<B.length;_++)if(k=B[_],F0(k))_=this.handleText(_,E);else if(k===24)_=this.multiByteCharacter(_,E);else if(k===16)_=this.extendedCommands(_,E);else if(128<=k&&k<=135)_=this.setCurrentWindow(_,E);else if(152<=k&&k<=159)_=this.defineWindow(_,E);else if(k===136)_=this.clearWindows(_,E);else if(k===140)_=this.deleteWindows(_,E);else if(k===137)_=this.displayWindows(_,E);else if(k===138)_=this.hideWindows(_,E);else if(k===139)_=this.toggleWindows(_,E);else if(k===151)_=this.setWindowAttributes(_,E);else if(k===144)_=this.setPenAttributes(_,E);else if(k===145)_=this.setPenColor(_,E);else if(k===146)_=this.setPenLocation(_,E);else if(k===143)E=this.reset(_,E);else if(k===8)E.currentWindow.backspace();else if(k===12)E.currentWindow.clearText();else if(k===13)E.currentWindow.pendingNewLine=!0;else if(k===14)E.currentWindow.clearText();else if(k===141)_++},St.prototype.extendedCommands=function(p,q){var v=this.current708Packet.data,k=v[++p];if(F0(k))p=this.handleText(p,q,{isExtended:!0});return p},St.prototype.getPts=function(p){return this.current708Packet.ptsVals[Math.floor(p/2)]},St.prototype.initService=function(p,q){var k="SERVICE"+p,v=this,k,_;if(k in this.serviceEncodings)_=this.serviceEncodings[k];return this.services[p]=new wf(p,_,v),this.services[p].init(this.getPts(q),function(B){v.flushDisplayed(B,v.services[p])}),this.services[p]},St.prototype.handleText=function(p,q,v){var k=v&&v.isExtended,_=v&&v.isMultiByte,B=this.current708Packet.data,E=k?4096:0,U=B[p],G=B[p+1],X=q.currentWindow,W,oe;function Oe(ge){return ge.map((Ge)=>{return("0"+(Ge&255).toString(16)).slice(-2)}).join("")}if(_)oe=[U,G],p++;else oe=[U];if(q.textDecoder_&&!k)W=q.textDecoder_.decode(new Uint8Array(oe));else if(_){let ge=Oe(oe);W=String.fromCharCode(parseInt(ge,16))}else W=y2(E|U);if(X.pendingNewLine&&!X.isEmpty())X.newLine(this.getPts(p));return X.pendingNewLine=!1,X.addText(W),p},St.prototype.multiByteCharacter=function(p,q){var v=this.current708Packet.data,k=v[p+1],_=v[p+2];if(F0(k)&&F0(_))p=this.handleText(++p,q,{isMultiByte:!0});return p},St.prototype.setCurrentWindow=function(p,q){var v=this.current708Packet.data,k=v[p],_=k&7;return q.setCurrentWindow(_),p},St.prototype.defineWindow=function(p,q){var v=this.current708Packet.data,k=v[p],_=k&7;q.setCurrentWindow(_);var B=q.currentWindow;return k=v[++p],B.visible=(k&32)>>5,B.rowLock=(k&16)>>4,B.columnLock=(k&8)>>3,B.priority=k&7,k=v[++p],B.relativePositioning=(k&128)>>7,B.anchorVertical=k&127,k=v[++p],B.anchorHorizontal=k,k=v[++p],B.anchorPoint=(k&240)>>4,B.rowCount=k&15,k=v[++p],B.columnCount=k&63,k=v[++p],B.windowStyle=(k&56)>>3,B.penStyle=k&7,B.virtualRowCount=B.rowCount+1,p},St.prototype.setWindowAttributes=function(p,q){var v=this.current708Packet.data,k=v[p],_=q.currentWindow.winAttr;return k=v[++p],_.fillOpacity=(k&192)>>6,_.fillRed=(k&48)>>4,_.fillGreen=(k&12)>>2,_.fillBlue=k&3,k=v[++p],_.borderType=(k&192)>>6,_.borderRed=(k&48)>>4,_.borderGreen=(k&12)>>2,_.borderBlue=k&3,k=v[++p],_.borderType+=(k&128)>>5,_.wordWrap=(k&64)>>6,_.printDirection=(k&48)>>4,_.scrollDirection=(k&12)>>2,_.justify=k&3,k=v[++p],_.effectSpeed=(k&240)>>4,_.effectDirection=(k&12)>>2,_.displayEffect=k&3,p},St.prototype.flushDisplayed=function(p,q){var v=[];for(var k=0;k<8;k++)if(q.windows[k].visible&&!q.windows[k].isEmpty())v.push(q.windows[k].getText());q.endPts=p,q.text=v.join(`
206
+
207
+ `),this.pushCaption(q),q.startPts=p},St.prototype.pushCaption=function(p){if(p.text!=="")this.trigger("data",{startPts:p.startPts,endPts:p.endPts,text:p.text,stream:"cc708_"+p.serviceNum}),p.text="",p.startPts=p.endPts},St.prototype.displayWindows=function(p,q){var v=this.current708Packet.data,k=v[++p],_=this.getPts(p);this.flushDisplayed(_,q);for(var B=0;B<8;B++)if(k&1<<B)q.windows[B].visible=1;return p},St.prototype.hideWindows=function(p,q){var v=this.current708Packet.data,k=v[++p],_=this.getPts(p);this.flushDisplayed(_,q);for(var B=0;B<8;B++)if(k&1<<B)q.windows[B].visible=0;return p},St.prototype.toggleWindows=function(p,q){var v=this.current708Packet.data,k=v[++p],_=this.getPts(p);this.flushDisplayed(_,q);for(var B=0;B<8;B++)if(k&1<<B)q.windows[B].visible^=1;return p},St.prototype.clearWindows=function(p,q){var v=this.current708Packet.data,k=v[++p],_=this.getPts(p);this.flushDisplayed(_,q);for(var B=0;B<8;B++)if(k&1<<B)q.windows[B].clearText();return p},St.prototype.deleteWindows=function(p,q){var v=this.current708Packet.data,k=v[++p],_=this.getPts(p);this.flushDisplayed(_,q);for(var B=0;B<8;B++)if(k&1<<B)q.windows[B].reset();return p},St.prototype.setPenAttributes=function(p,q){var v=this.current708Packet.data,k=v[p],_=q.currentWindow.penAttr;return k=v[++p],_.textTag=(k&240)>>4,_.offset=(k&12)>>2,_.penSize=k&3,k=v[++p],_.italics=(k&128)>>7,_.underline=(k&64)>>6,_.edgeType=(k&56)>>3,_.fontStyle=k&7,p},St.prototype.setPenColor=function(p,q){var v=this.current708Packet.data,k=v[p],_=q.currentWindow.penColor;return k=v[++p],_.fgOpacity=(k&192)>>6,_.fgRed=(k&48)>>4,_.fgGreen=(k&12)>>2,_.fgBlue=k&3,k=v[++p],_.bgOpacity=(k&192)>>6,_.bgRed=(k&48)>>4,_.bgGreen=(k&12)>>2,_.bgBlue=k&3,k=v[++p],_.edgeRed=(k&48)>>4,_.edgeGreen=(k&12)>>2,_.edgeBlue=k&3,p},St.prototype.setPenLocation=function(p,q){var v=this.current708Packet.data,k=v[p],_=q.currentWindow.penLoc;return q.currentWindow.pendingNewLine=!0,k=v[++p],_.row=k&15,k=v[++p],_.column=k&63,p},St.prototype.reset=function(p,q){var v=this.getPts(p);return this.flushDisplayed(v,q),this.initService(q.serviceNum,p)};var Ei={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},zi=function(p){if(p===null)return"";return p=Ei[p]||p,String.fromCharCode(p)},df=14,Sl=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ts=function(){var p=[],q=df+1;while(q--)p.push({text:"",indent:0,offset:0});return p},fa=function(p,q){fa.prototype.init.call(this),this.field_=p||0,this.dataChannel_=q||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(v){var k,_,B,E,U;if(k=v.ccData&32639,k===this.lastControlCode_){this.lastControlCode_=null;return}if((k&61440)===4096)this.lastControlCode_=k;else if(k!==this.PADDING_)this.lastControlCode_=null;if(B=k>>>8,E=k&255,k===this.PADDING_)return;else if(k===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(k===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(v.pts),this.flushDisplayed(v.pts),_=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=_,this.startPts_=v.pts;else if(k===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(v.pts);else if(k===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(v.pts);else if(k===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(v.pts);else if(k===this.CARRIAGE_RETURN_)this.clearFormatting(v.pts),this.flushDisplayed(v.pts),this.shiftRowsUp_(),this.startPts_=v.pts;else if(k===this.BACKSPACE_)if(this.mode_==="popOn")this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1);else this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(k===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(v.pts),this.displayed_=Ts();else if(k===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ts();else if(k===this.RESUME_DIRECT_CAPTIONING_){if(this.mode_!=="paintOn")this.flushDisplayed(v.pts),this.displayed_=Ts();this.mode_="paintOn",this.startPts_=v.pts}else if(this.isSpecialCharacter(B,E))B=(B&3)<<8,U=zi(B|E),this[this.mode_](v.pts,U),this.column_++;else if(this.isExtCharacter(B,E)){if(this.mode_==="popOn")this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1);else this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);B=(B&3)<<8,U=zi(B|E),this[this.mode_](v.pts,U),this.column_++}else if(this.isMidRowCode(B,E)){if(this.clearFormatting(v.pts),this[this.mode_](v.pts," "),this.column_++,(E&14)===14)this.addFormatting(v.pts,["i"]);if((E&1)===1)this.addFormatting(v.pts,["u"])}else if(this.isOffsetControlCode(B,E)){let X=E&3;this.nonDisplayed_[this.row_].offset=X,this.column_+=X}else if(this.isPAC(B,E)){var G=Sl.indexOf(k&7968);if(this.mode_==="rollUp"){if(G-this.rollUpRows_+1<0)G=this.rollUpRows_-1;this.setRollUp(v.pts,G)}if(G!==this.row_&&G>=0&&G<=14)this.clearFormatting(v.pts),this.row_=G;if(E&1&&this.formatting_.indexOf("u")===-1)this.addFormatting(v.pts,["u"]);if((k&16)===16){let X=(k&14)>>1;this.column_=X*4,this.nonDisplayed_[this.row_].indent+=X}if(this.isColorPAC(E)){if((E&14)===14)this.addFormatting(v.pts,["i"])}}else if(this.isNormalChar(B)){if(E===0)E=null;U=zi(B),U+=zi(E),this[this.mode_](v.pts,U),this.column_+=U.length}}};fa.prototype=new bf,fa.prototype.flushDisplayed=function(p){let q=(k)=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+k+"."})},v=[];if(this.displayed_.forEach((k,_)=>{if(k&&k.text&&k.text.length){try{k.text=k.text.trim()}catch(B){q(_)}if(k.text.length)v.push({text:k.text,line:_+1,position:10+Math.min(70,k.indent*10)+k.offset*2.5})}else if(k===void 0||k===null)q(_)}),v.length)this.trigger("data",{startPts:this.startPts_,endPts:p,content:v,stream:this.name_})},fa.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ts(),this.nonDisplayed_=Ts(),this.lastControlCode_=null,this.column_=0,this.row_=df,this.rollUpRows_=2,this.formatting_=[]},fa.prototype.setConstants=function(){if(this.dataChannel_===0)this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23;else if(this.dataChannel_===1)this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31;this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},fa.prototype.isSpecialCharacter=function(p,q){return p===this.EXT_&&q>=48&&q<=63},fa.prototype.isExtCharacter=function(p,q){return(p===this.EXT_+1||p===this.EXT_+2)&&q>=32&&q<=63},fa.prototype.isMidRowCode=function(p,q){return p===this.EXT_&&q>=32&&q<=47},fa.prototype.isOffsetControlCode=function(p,q){return p===this.OFFSET_&&q>=33&&q<=35},fa.prototype.isPAC=function(p,q){return p>=this.BASE_&&p<this.BASE_+8&&q>=64&&q<=127},fa.prototype.isColorPAC=function(p){return p>=64&&p<=79||p>=96&&p<=127},fa.prototype.isNormalChar=function(p){return p>=32&&p<=127},fa.prototype.setRollUp=function(p,q){if(this.mode_!=="rollUp")this.row_=df,this.mode_="rollUp",this.flushDisplayed(p),this.nonDisplayed_=Ts(),this.displayed_=Ts();if(q!==void 0&&q!==this.row_)for(var v=0;v<this.rollUpRows_;v++)this.displayed_[q-v]=this.displayed_[this.row_-v],this.displayed_[this.row_-v]={text:"",indent:0,offset:0};if(q===void 0)q=this.row_;this.topRow_=q-this.rollUpRows_+1},fa.prototype.addFormatting=function(p,q){this.formatting_=this.formatting_.concat(q);var v=q.reduce(function(k,_){return k+"<"+_+">"},"");this[this.mode_](p,v)},fa.prototype.clearFormatting=function(p){if(!this.formatting_.length)return;var q=this.formatting_.reverse().reduce(function(v,k){return v+"</"+k+">"},"");this.formatting_=[],this[this.mode_](p,q)},fa.prototype.popOn=function(p,q){var v=this.nonDisplayed_[this.row_].text;v+=q,this.nonDisplayed_[this.row_].text=v},fa.prototype.rollUp=function(p,q){var v=this.displayed_[this.row_].text;v+=q,this.displayed_[this.row_].text=v},fa.prototype.shiftRowsUp_=function(){var p;for(p=0;p<this.topRow_;p++)this.displayed_[p]={text:"",indent:0,offset:0};for(p=this.row_+1;p<df+1;p++)this.displayed_[p]={text:"",indent:0,offset:0};for(p=this.topRow_;p<this.row_;p++)this.displayed_[p]=this.displayed_[p+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},fa.prototype.paintOn=function(p,q){var v=this.displayed_[this.row_].text;v+=q,this.displayed_[this.row_].text=v};var Yo={CaptionStream:on,Cea608Stream:fa,Cea708Stream:St},Cl={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Jo=a,Qo=8589934592,Ui=4294967296,Lr="shared",Vr=function(p,q){var v=1;if(p>q)v=-1;while(Math.abs(q-p)>Ui)p+=v*Qo;return p},Ws=function(p){var q,v;Ws.prototype.init.call(this),this.type_=p||Lr,this.push=function(k){if(k.type==="metadata"){this.trigger("data",k);return}if(this.type_!==Lr&&k.type!==this.type_)return;if(v===void 0)v=k.dts;k.dts=Vr(k.dts,v),k.pts=Vr(k.pts,v),q=k.dts,this.trigger("data",k)},this.flush=function(){v=q,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){v=void 0,q=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Ws.prototype=new Jo;var Un={TimestampRolloverStream:Ws,handleRollover:Vr},Yr=(p,q,v)=>{if(!p)return-1;var k=v;for(;k<p.length;k++)if(p[k]===q)return k;return-1},ja={typedArrayIndexOf:Yr},jf=ja.typedArrayIndexOf,qf={Iso88591:0,Utf16:1,Utf16be:2,Utf8:3},Zo=function(p,q,v){var k,_="";for(k=q;k<v;k++)_+="%"+("00"+p[k].toString(16)).slice(-2);return _},vf=function(p,q,v){return decodeURIComponent(Zo(p,q,v))},_l=function(p,q,v){return unescape(Zo(p,q,v))},O0=function(p){return p[0]<<21|p[1]<<14|p[2]<<7|p[3]},B0={APIC:function(p){var q=1,v,k,_="-->";if(p.data[0]!==qf.Utf8)return;if(v=jf(p.data,0,q),v<0)return;if(p.mimeType=_l(p.data,q,v),q=v+1,p.pictureType=p.data[q],q++,k=jf(p.data,0,q),k<0)return;if(p.description=vf(p.data,q,k),q=k+1,p.mimeType===_)p.url=_l(p.data,q,p.data.length);else p.pictureData=p.data.subarray(q,p.data.length)},"T*":function(p){if(p.data[0]!==qf.Utf8)return;p.value=vf(p.data,1,p.data.length).replace(/\0*$/,""),p.values=p.value.split("\x00")},TXXX:function(p){var q;if(p.data[0]!==qf.Utf8)return;if(q=jf(p.data,0,1),q===-1)return;p.description=vf(p.data,1,q),p.value=vf(p.data,q+1,p.data.length).replace(/\0*$/,""),p.data=p.value},"W*":function(p){p.url=_l(p.data,0,p.data.length).replace(/\0.*$/,"")},WXXX:function(p){var q;if(p.data[0]!==qf.Utf8)return;if(q=jf(p.data,0,1),q===-1)return;p.description=vf(p.data,1,q),p.url=_l(p.data,q+1,p.data.length).replace(/\0.*$/,"")},PRIV:function(p){var q;for(q=0;q<p.data.length;q++)if(p.data[q]===0){p.owner=_l(p.data,0,q);break}p.privateData=p.data.subarray(q+1),p.data=p.privateData}},$o=function(p){var q,v,k=10,_=0,B=[];if(p.length<10||p[0]!==73||p[1]!==68||p[2]!==51)return;_=O0(p.subarray(6,10)),_+=10;var E=p[5]&64;if(E)k+=4,k+=O0(p.subarray(10,14)),_-=O0(p.subarray(16,20));do{if(q=O0(p.subarray(k+4,k+8)),q<1)break;v=String.fromCharCode(p[k],p[k+1],p[k+2],p[k+3]);var U={id:v,data:p.subarray(k+10,k+q+10)};if(U.key=U.id,B0[U.id])B0[U.id](U);else if(U.id[0]==="T")B0["T*"](U);else if(U.id[0]==="W")B0["W*"](U);B.push(U),k+=10,k+=q}while(k<_);return B},cn={parseId3Frames:$o,parseSyncSafeInteger:O0,frameParsers:B0},ya=a,Jr=Cl,rs=cn,T0;T0=function(p){var q={descriptor:p&&p.descriptor},v=0,k=[],_=0,B;if(T0.prototype.init.call(this),this.dispatchType=Jr.METADATA_STREAM_TYPE.toString(16),q.descriptor)for(B=0;B<q.descriptor.length;B++)this.dispatchType+=("00"+q.descriptor[B].toString(16)).slice(-2);this.push=function(E){var U,G,X,W,oe,Oe;if(E.type!=="timed-metadata")return;if(E.dataAlignmentIndicator)_=0,k.length=0;if(k.length===0&&(E.data.length<10||E.data[0]!==73||E.data[1]!==68||E.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(k.push(E),_+=E.data.byteLength,k.length===1)v=rs.parseSyncSafeInteger(E.data.subarray(6,10)),v+=10;if(_<v)return;U={data:new Uint8Array(v),frames:[],pts:k[0].pts,dts:k[0].dts};for(oe=0;oe<v;)U.data.set(k[0].data.subarray(0,v-oe),oe),oe+=k[0].data.byteLength,_-=k[0].data.byteLength,k.shift();if(G=10,U.data[5]&64)G+=4,G+=rs.parseSyncSafeInteger(U.data.subarray(10,14)),v-=rs.parseSyncSafeInteger(U.data.subarray(16,20));do{if(X=rs.parseSyncSafeInteger(U.data.subarray(G+4,G+8)),X<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(Oe=String.fromCharCode(U.data[G],U.data[G+1],U.data[G+2],U.data[G+3]),W={id:Oe,data:U.data.subarray(G+10,G+X+10)},W.key=W.id,rs.frameParsers[W.id])rs.frameParsers[W.id](W);else if(W.id[0]==="T")rs.frameParsers["T*"](W);else if(W.id[0]==="W")rs.frameParsers["W*"](W);if(W.owner==="com.apple.streaming.transportStreamTimestamp"){var ge=W.data,Ge=(ge[3]&1)<<30|ge[4]<<22|ge[5]<<14|ge[6]<<6|ge[7]>>>2;if(Ge*=4,Ge+=ge[7]&3,W.timeStamp=Ge,U.pts===void 0&&U.dts===void 0)U.pts=W.timeStamp,U.dts=W.timeStamp;this.trigger("timestamp",W)}U.frames.push(W),G+=10,G+=X}while(G<v);this.trigger("data",U)}},T0.prototype=new ya;var Wo=T0,Hs=a,kf=Yo,Jn=Cl,Po=Un.TimestampRolloverStream,Fl,Af,Ol,H0=188,Qr=71;Fl=function(){var p=new Uint8Array(H0),q=0;Fl.prototype.init.call(this),this.push=function(v){var k=0,_=H0,B;if(q)B=new Uint8Array(v.byteLength+q),B.set(p.subarray(0,q)),B.set(v,q),q=0;else B=v;while(_<B.byteLength){if(B[k]===Qr&&B[_]===Qr){this.trigger("data",B.subarray(k,_)),k+=H0,_+=H0;continue}k++,_++}if(k<B.byteLength)p.set(B.subarray(k),0),q=B.byteLength-k},this.flush=function(){if(q===H0&&p[0]===Qr)this.trigger("data",p),q=0;this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){q=0,this.trigger("reset")}},Fl.prototype=new Hs,Af=function(){var p,q,v,k;Af.prototype.init.call(this),k=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,p=function(_,B){var E=0;if(B.payloadUnitStartIndicator)E+=_[E]+1;if(B.type==="pat")q(_.subarray(E),B);else v(_.subarray(E),B)},q=function(_,B){B.section_number=_[7],B.last_section_number=_[8],k.pmtPid=(_[10]&31)<<8|_[11],B.pmtPid=k.pmtPid},v=function(_,B){var E,U,G,X;if(!(_[5]&1))return;k.programMapTable={video:null,audio:null,"timed-metadata":{}},E=(_[1]&15)<<8|_[2],U=3+E-4,G=(_[10]&15)<<8|_[11],X=12+G;while(X<U){var W=_[X],oe=(_[X+1]&31)<<8|_[X+2];if(W===Jn.H264_STREAM_TYPE&&k.programMapTable.video===null)k.programMapTable.video=oe;else if(W===Jn.ADTS_STREAM_TYPE&&k.programMapTable.audio===null)k.programMapTable.audio=oe;else if(W===Jn.METADATA_STREAM_TYPE)k.programMapTable["timed-metadata"][oe]=W;X+=((_[X+3]&15)<<8|_[X+4])+5}B.programMapTable=k.programMapTable},this.push=function(_){var B={},E=4;if(B.payloadUnitStartIndicator=!!(_[1]&64),B.pid=_[1]&31,B.pid<<=8,B.pid|=_[2],(_[3]&48)>>>4>1)E+=_[E]+1;if(B.pid===0)B.type="pat",p(_.subarray(E),B),this.trigger("data",B);else if(B.pid===this.pmtPid){B.type="pmt",p(_.subarray(E),B),this.trigger("data",B);while(this.packetsWaitingForPmt.length)this.processPes_.apply(this,this.packetsWaitingForPmt.shift())}else if(this.programMapTable===void 0)this.packetsWaitingForPmt.push([_,E,B]);else this.processPes_(_,E,B)},this.processPes_=function(_,B,E){if(E.pid===this.programMapTable.video)E.streamType=Jn.H264_STREAM_TYPE;else if(E.pid===this.programMapTable.audio)E.streamType=Jn.ADTS_STREAM_TYPE;else E.streamType=this.programMapTable["timed-metadata"][E.pid];E.type="pes",E.data=_.subarray(B),this.trigger("data",E)}},Af.prototype=new Hs,Af.STREAM_TYPES={h264:27,adts:15},Ol=function(){var p=this,q=!1,v={data:[],size:0},k={data:[],size:0},_={data:[],size:0},B,E=function(G,X){var W;let oe=G[0]<<16|G[1]<<8|G[2];if(X.data=new Uint8Array,oe!==1)return;if(X.packetLength=6+(G[4]<<8|G[5]),X.dataAlignmentIndicator=(G[6]&4)!==0,W=G[7],W&192){if(X.pts=(G[9]&14)<<27|(G[10]&255)<<20|(G[11]&254)<<12|(G[12]&255)<<5|(G[13]&254)>>>3,X.pts*=4,X.pts+=(G[13]&6)>>>1,X.dts=X.pts,W&64)X.dts=(G[14]&14)<<27|(G[15]&255)<<20|(G[16]&254)<<12|(G[17]&255)<<5|(G[18]&254)>>>3,X.dts*=4,X.dts+=(G[18]&6)>>>1}X.data=G.subarray(9+G[8])},U=function(G,X,W){var oe=new Uint8Array(G.size),Oe={type:X},ge=0,Ge=0,et=!1,Ga;if(!G.data.length||G.size<9)return;Oe.trackId=G.data[0].pid;for(ge=0;ge<G.data.length;ge++)Ga=G.data[ge],oe.set(Ga.data,Ge),Ge+=Ga.data.byteLength;if(E(oe,Oe),et=X==="video"||Oe.packetLength<=G.size,W||et)G.size=0,G.data.length=0;if(et)p.trigger("data",Oe)};Ol.prototype.init.call(this),this.push=function(G){({pat:function(){},pes:function(){var X,W;switch(G.streamType){case Jn.H264_STREAM_TYPE:X=v,W="video";break;case Jn.ADTS_STREAM_TYPE:X=k,W="audio";break;case Jn.METADATA_STREAM_TYPE:X=_,W="timed-metadata";break;default:return}if(G.payloadUnitStartIndicator)U(X,W,!0);X.data.push(G),X.size+=G.data.byteLength},pmt:function(){var X={type:"metadata",tracks:[]};if(B=G.programMapTable,B.video!==null)X.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.video,codec:"avc",type:"video"});if(B.audio!==null)X.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.audio,codec:"adts",type:"audio"});q=!0,p.trigger("data",X)}})[G.type]()},this.reset=function(){v.size=0,v.data.length=0,k.size=0,k.data.length=0,this.trigger("reset")},this.flushStreams_=function(){U(v,"video"),U(k,"audio"),U(_,"timed-metadata")},this.flush=function(){if(!q&&B){var G={type:"metadata",tracks:[]};if(B.video!==null)G.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.video,codec:"avc",type:"video"});if(B.audio!==null)G.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.audio,codec:"adts",type:"audio"});p.trigger("data",G)}q=!1,this.flushStreams_(),this.trigger("done")}},Ol.prototype=new Hs;var ec={PAT_PID:0,MP2T_PACKET_LENGTH:H0,TransportPacketStream:Fl,TransportParseStream:Af,ElementaryStream:Ol,TimestampRolloverStream:Po,CaptionStream:kf.CaptionStream,Cea608Stream:kf.Cea608Stream,Cea708Stream:kf.Cea708Stream,MetadataStream:Wo};for(var Bl in Jn)if(Jn.hasOwnProperty(Bl))ec[Bl]=Jn[Bl];var S2=ec,Q5=a,C2=Bt.ONE_SECOND_IN_TS,Tl,tc=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350];Tl=function(p){var q,v=0;Tl.prototype.init.call(this),this.skipWarn_=function(k,_){this.trigger("log",{level:"warn",message:`adts skiping bytes ${k} to ${_} in frame ${v} outside syncword`})},this.push=function(k){var _=0,B,E,U,G,X;if(!p)v=0;if(k.type!=="audio")return;if(q&&q.length)U=q,q=new Uint8Array(U.byteLength+k.data.byteLength),q.set(U),q.set(k.data,U.byteLength);else q=k.data;var W;while(_+7<q.length){if(q[_]!==255||(q[_+1]&246)!==240){if(typeof W!=="number")W=_;_++;continue}if(typeof W==="number")this.skipWarn_(W,_),W=null;if(E=(~q[_+1]&1)*2,B=(q[_+3]&3)<<11|q[_+4]<<3|(q[_+5]&224)>>5,G=((q[_+6]&3)+1)*1024,X=G*C2/tc[(q[_+2]&60)>>>2],q.byteLength-_<B)break;this.trigger("data",{pts:k.pts+v*X,dts:k.dts+v*X,sampleCount:G,audioobjecttype:(q[_+2]>>>6&3)+1,channelcount:(q[_+2]&1)<<2|(q[_+3]&192)>>>6,samplerate:tc[(q[_+2]&60)>>>2],samplingfrequencyindex:(q[_+2]&60)>>>2,samplesize:16,data:q.subarray(_+7+E,_+B)}),v++,_+=B}if(typeof W==="number")this.skipWarn_(W,_),W=null;q=q.subarray(_)},this.flush=function(){v=0,this.trigger("done")},this.reset=function(){q=void 0,this.trigger("reset")},this.endTimeline=function(){q=void 0,this.trigger("endedtimeline")}},Tl.prototype=new Q5;var ac=Tl,nc;nc=function(p){var q=p.byteLength,v=0,k=0;this.length=function(){return 8*q},this.bitsAvailable=function(){return 8*q+k},this.loadWord=function(){var _=p.byteLength-q,B=new Uint8Array(4),E=Math.min(4,q);if(E===0)throw Error("no bytes available");B.set(p.subarray(_,_+E)),v=new DataView(B.buffer).getUint32(0),k=E*8,q-=E},this.skipBits=function(_){var B;if(k>_)v<<=_,k-=_;else _-=k,B=Math.floor(_/8),_-=B*8,q-=B,this.loadWord(),v<<=_,k-=_},this.readBits=function(_){var B=Math.min(k,_),E=v>>>32-B;if(k-=B,k>0)v<<=B;else if(q>0)this.loadWord();if(B=_-B,B>0)return E<<B|this.readBits(B);return E},this.skipLeadingZeros=function(){var _;for(_=0;_<k;++_)if((v&2147483648>>>_)!==0)return v<<=_,k-=_,_;return this.loadWord(),_+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var _=this.skipLeadingZeros();return this.readBits(_+1)-1},this.readExpGolomb=function(){var _=this.readUnsignedExpGolomb();if(1&_)return 1+_>>>1;return-1*(_>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var _2=nc,sc=a,F2=_2,Hl,Ml,ic;Ml=function(){var p=0,q,v;Ml.prototype.init.call(this),this.push=function(k){var _;if(!v)v=k.data;else _=new Uint8Array(v.byteLength+k.data.byteLength),_.set(v),_.set(k.data,v.byteLength),v=_;var B=v.byteLength;for(;p<B-3;p++)if(v[p+2]===1){q=p+5;break}while(q<B)switch(v[q]){case 0:if(v[q-1]!==0){q+=2;break}else if(v[q-2]!==0){q++;break}if(p+3!==q-2)this.trigger("data",v.subarray(p+3,q-2));do q++;while(v[q]!==1&&q<B);p=q-2,q+=3;break;case 1:if(v[q-1]!==0||v[q-2]!==0){q+=3;break}this.trigger("data",v.subarray(p+3,q-2)),p=q-2,q+=3;break;default:q+=3;break}v=v.subarray(p),q-=p,p=0},this.reset=function(){v=null,p=0,this.trigger("reset")},this.flush=function(){if(v&&v.byteLength>3)this.trigger("data",v.subarray(p+3));v=null,p=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Ml.prototype=new sc,ic={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Hl=function(){var p=new Ml,q,v,k,_,B,E,U;Hl.prototype.init.call(this),q=this,this.push=function(G){if(G.type!=="video")return;v=G.trackId,k=G.pts,_=G.dts,p.push(G)},p.on("data",function(G){var X={trackId:v,pts:k,dts:_,data:G,nalUnitTypeCode:G[0]&31};switch(X.nalUnitTypeCode){case 5:X.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:X.nalUnitType="sei_rbsp",X.escapedRBSP=B(G.subarray(1));break;case 7:X.nalUnitType="seq_parameter_set_rbsp",X.escapedRBSP=B(G.subarray(1)),X.config=E(X.escapedRBSP);break;case 8:X.nalUnitType="pic_parameter_set_rbsp";break;case 9:X.nalUnitType="access_unit_delimiter_rbsp";break}q.trigger("data",X)}),p.on("done",function(){q.trigger("done")}),p.on("partialdone",function(){q.trigger("partialdone")}),p.on("reset",function(){q.trigger("reset")}),p.on("endedtimeline",function(){q.trigger("endedtimeline")}),this.flush=function(){p.flush()},this.partialFlush=function(){p.partialFlush()},this.reset=function(){p.reset()},this.endTimeline=function(){p.endTimeline()},U=function(G,X){var W=8,oe=8,Oe,ge;for(Oe=0;Oe<G;Oe++){if(oe!==0)ge=X.readExpGolomb(),oe=(W+ge+256)%256;W=oe===0?W:oe}},B=function(G){var X=G.byteLength,W=[],oe=1,Oe,ge;while(oe<X-2)if(G[oe]===0&&G[oe+1]===0&&G[oe+2]===3)W.push(oe+2),oe+=2;else oe++;if(W.length===0)return G;Oe=X-W.length,ge=new Uint8Array(Oe);var Ge=0;for(oe=0;oe<Oe;Ge++,oe++){if(Ge===W[0])Ge++,W.shift();ge[oe]=G[Ge]}return ge},E=function(G){var X=0,W=0,oe=0,Oe=0,ge,Ge,et,Ga,Fn,Li,Df,xf,Rf,Nf,tr,Jt=[1,1],ct,$n;if(ge=new F2(G),Ge=ge.readUnsignedByte(),Ga=ge.readUnsignedByte(),et=ge.readUnsignedByte(),ge.skipUnsignedExpGolomb(),ic[Ge]){if(Fn=ge.readUnsignedExpGolomb(),Fn===3)ge.skipBits(1);if(ge.skipUnsignedExpGolomb(),ge.skipUnsignedExpGolomb(),ge.skipBits(1),ge.readBoolean()){tr=Fn!==3?8:12;for($n=0;$n<tr;$n++)if(ge.readBoolean())if($n<6)U(16,ge);else U(64,ge)}}if(ge.skipUnsignedExpGolomb(),Li=ge.readUnsignedExpGolomb(),Li===0)ge.readUnsignedExpGolomb();else if(Li===1){ge.skipBits(1),ge.skipExpGolomb(),ge.skipExpGolomb(),Df=ge.readUnsignedExpGolomb();for($n=0;$n<Df;$n++)ge.skipExpGolomb()}if(ge.skipUnsignedExpGolomb(),ge.skipBits(1),xf=ge.readUnsignedExpGolomb(),Rf=ge.readUnsignedExpGolomb(),Nf=ge.readBits(1),Nf===0)ge.skipBits(1);if(ge.skipBits(1),ge.readBoolean())X=ge.readUnsignedExpGolomb(),W=ge.readUnsignedExpGolomb(),oe=ge.readUnsignedExpGolomb(),Oe=ge.readUnsignedExpGolomb();if(ge.readBoolean()){if(ge.readBoolean()){switch(ct=ge.readUnsignedByte(),ct){case 1:Jt=[1,1];break;case 2:Jt=[12,11];break;case 3:Jt=[10,11];break;case 4:Jt=[16,11];break;case 5:Jt=[40,33];break;case 6:Jt=[24,11];break;case 7:Jt=[20,11];break;case 8:Jt=[32,11];break;case 9:Jt=[80,33];break;case 10:Jt=[18,11];break;case 11:Jt=[15,11];break;case 12:Jt=[64,33];break;case 13:Jt=[160,99];break;case 14:Jt=[4,3];break;case 15:Jt=[3,2];break;case 16:Jt=[2,1];break;case 255:{Jt=[ge.readUnsignedByte()<<8|ge.readUnsignedByte(),ge.readUnsignedByte()<<8|ge.readUnsignedByte()];break}}if(Jt)Jt[0]/Jt[1]}}return{profileIdc:Ge,levelIdc:et,profileCompatibility:Ga,width:(xf+1)*16-X*2-W*2,height:(2-Nf)*(Rf+1)*16-oe*2-Oe*2,sarRatio:Jt}}},Hl.prototype=new sc;var yf={H264Stream:Hl,NalByteStream:Ml},O2=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],Dl=function(p,q){var v=p[q+6]<<21|p[q+7]<<14|p[q+8]<<7|p[q+9],k=p[q+5],_=(k&16)>>4;if(v=v>=0?v:0,_)return v+20;return v+10},xl=function(p,q){if(p.length-q<10||p[q]!==73||p[q+1]!==68||p[q+2]!==51)return q;return q+=Dl(p,q),xl(p,q)},B2=function(p){var q=xl(p,0);return p.length>=q+2&&(p[q]&255)===255&&(p[q+1]&240)===240&&(p[q+1]&22)===16},Zr=function(p){return p[0]<<21|p[1]<<14|p[2]<<7|p[3]},Z5=function(p,q,v){var k,_="";for(k=q;k<v;k++)_+="%"+("00"+p[k].toString(16)).slice(-2);return _},T2=function(p,q,v){return unescape(Z5(p,q,v))},H2=function(p,q){var v=(p[q+5]&224)>>5,k=p[q+4]<<3,_=p[q+3]&6144;return _|k|v},M2=function(p,q){if(p[q]===73&&p[q+1]===68&&p[q+2]===51)return"timed-metadata";else if(p[q]&!0&&(p[q+1]&240)===240)return"audio";return null},D2=function(p){var q=0;while(q+5<p.length){if(p[q]!==255||(p[q+1]&246)!==240){q++;continue}return O2[(p[q+2]&60)>>>2]}return null},x2=function(p){var q,v,k,_;if(q=10,p[5]&64)q+=4,q+=Zr(p.subarray(10,14));do{if(v=Zr(p.subarray(q+4,q+8)),v<1)return null;if(_=String.fromCharCode(p[q],p[q+1],p[q+2],p[q+3]),_==="PRIV"){k=p.subarray(q+10,q+v+10);for(var B=0;B<k.byteLength;B++)if(k[B]===0){var E=T2(k,0,B);if(E==="com.apple.streaming.transportStreamTimestamp"){var U=k.subarray(B+1),G=(U[3]&1)<<30|U[4]<<22|U[5]<<14|U[6]<<6|U[7]>>>2;return G*=4,G+=U[7]&3,G}break}}q+=10,q+=v}while(q<p.byteLength);return null},Rl={isLikelyAacData:B2,parseId3TagSize:Dl,parseAdtsSize:H2,parseType:M2,parseSampleRate:D2,parseAacTimestamp:x2},R2=a,fc=Rl,Sf;Sf=function(){var p=new Uint8Array,q=0;Sf.prototype.init.call(this),this.setTimestamp=function(v){q=v},this.push=function(v){var k=0,_=0,B,E,U,G;if(p.length)G=p.length,p=new Uint8Array(v.byteLength+G),p.set(p.subarray(0,G)),p.set(v,G);else p=v;while(p.length-_>=3){if(p[_]===73&&p[_+1]===68&&p[_+2]===51){if(p.length-_<10)break;if(k=fc.parseId3TagSize(p,_),_+k>p.length)break;E={type:"timed-metadata",data:p.subarray(_,_+k)},this.trigger("data",E),_+=k;continue}else if((p[_]&255)===255&&(p[_+1]&240)===240){if(p.length-_<7)break;if(k=fc.parseAdtsSize(p,_),_+k>p.length)break;U={type:"audio",data:p.subarray(_,_+k),pts:q,dts:q},this.trigger("data",U),_+=k;continue}_++}if(B=p.length-_,B>0)p=p.subarray(_);else p=new Uint8Array},this.reset=function(){p=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){p=new Uint8Array,this.trigger("endedtimeline")}},Sf.prototype=new R2;var N2=Sf,E2=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],z2=E2,lc=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],U2=lc,Nl=a,El=Ie,zl=Qe,Ul=Re,Cn=Xe,Ms=S2,M0=Bt,rc=ac,I2=yf.H264Stream,oc=N2,G2=Rl.isLikelyAacData,X2=Bt.ONE_SECOND_IN_TS,yi=z2,Cf=U2,_f,Ii,Il,Gi,$5=function(p,q){q.stream=p,this.trigger("log",q)},Qa=function(p,q){var v=Object.keys(q);for(var k=0;k<v.length;k++){var _=v[k];if(_==="headOfPipeline"||!q[_].on)continue;q[_].on("log",$5.bind(p,_))}},cc=function(p,q){var v;if(p.length!==q.length)return!1;for(v=0;v<p.length;v++)if(p[v]!==q[v])return!1;return!0},$r=function(p,q,v,k,_,B){var E=v-q,U=k-q,G=_-v;return{start:{dts:p,pts:p+E},end:{dts:p+U,pts:p+G},prependedContentDuration:B,baseMediaDecodeTime:p}};Ii=function(p,q){var v=[],k,_=0,B=0,E=1/0;q=q||{},k=q.firstSequenceNumber||0,Ii.prototype.init.call(this),this.push=function(U){if(Cn.collectDtsInfo(p,U),p)yi.forEach(function(G){p[G]=U[G]});v.push(U)},this.setEarliestDts=function(U){_=U},this.setVideoBaseMediaDecodeTime=function(U){E=U},this.setAudioAppendStart=function(U){B=U},this.flush=function(){var U,G,X,W,oe,Oe,ge;if(v.length===0){this.trigger("done","AudioSegmentStream");return}if(U=Ul.trimAdtsFramesByEarliestDts(v,p,_),p.baseMediaDecodeTime=Cn.calculateTrackBaseMediaDecodeTime(p,q.keepOriginalTimestamps),ge=Ul.prefixWithSilence(p,U,B,E),p.samples=Ul.generateSampleTable(U),X=El.mdat(Ul.concatenateFrameData(U)),v=[],G=El.moof(k,[p]),W=new Uint8Array(G.byteLength+X.byteLength),k++,W.set(G),W.set(X,G.byteLength),Cn.clearDtsInfo(p),oe=Math.ceil(X2*1024/p.samplerate),U.length)Oe=U.length*oe,this.trigger("segmentTimingInfo",$r(M0.audioTsToVideoTs(p.baseMediaDecodeTime,p.samplerate),U[0].dts,U[0].pts,U[0].dts+Oe,U[0].pts+Oe,ge||0)),this.trigger("timingInfo",{start:U[0].pts,end:U[0].pts+Oe});this.trigger("data",{track:p,boxes:W}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Cn.clearDtsInfo(p),v=[],this.trigger("reset")}},Ii.prototype=new Nl,_f=function(p,q){var v,k=[],_=[],B,E;q=q||{},v=q.firstSequenceNumber||0,_f.prototype.init.call(this),delete p.minPTS,this.gopCache_=[],this.push=function(U){if(Cn.collectDtsInfo(p,U),U.nalUnitType==="seq_parameter_set_rbsp"&&!B)B=U.config,p.sps=[U.data],Cf.forEach(function(G){p[G]=B[G]},this);if(U.nalUnitType==="pic_parameter_set_rbsp"&&!E)E=U.data,p.pps=[U.data];k.push(U)},this.flush=function(){var U,G,X,W,oe,Oe,ge=0,Ge,et;while(k.length){if(k[0].nalUnitType==="access_unit_delimiter_rbsp")break;k.shift()}if(k.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(U=zl.groupNalsIntoFrames(k),X=zl.groupFramesIntoGops(U),!X[0][0].keyFrame)if(G=this.getGopForFusion_(k[0],p),G)ge=G.duration,X.unshift(G),X.byteLength+=G.byteLength,X.nalCount+=G.nalCount,X.pts=G.pts,X.dts=G.dts,X.duration+=G.duration;else X=zl.extendFirstKeyFrame(X);if(_.length){var Ga;if(q.alignGopsAtEnd)Ga=this.alignGopsAtEnd_(X);else Ga=this.alignGopsAtStart_(X);if(!Ga){this.gopCache_.unshift({gop:X.pop(),pps:p.pps,sps:p.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),k=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Cn.clearDtsInfo(p),X=Ga}Cn.collectDtsInfo(p,X),p.samples=zl.generateSampleTable(X),oe=El.mdat(zl.concatenateNalData(X)),p.baseMediaDecodeTime=Cn.calculateTrackBaseMediaDecodeTime(p,q.keepOriginalTimestamps),this.trigger("processedGopsInfo",X.map(function(Fn){return{pts:Fn.pts,dts:Fn.dts,byteLength:Fn.byteLength}})),Ge=X[0],et=X[X.length-1],this.trigger("segmentTimingInfo",$r(p.baseMediaDecodeTime,Ge.dts,Ge.pts,et.dts+et.duration,et.pts+et.duration,ge)),this.trigger("timingInfo",{start:X[0].pts,end:X[X.length-1].pts+X[X.length-1].duration}),this.gopCache_.unshift({gop:X.pop(),pps:p.pps,sps:p.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),k=[],this.trigger("baseMediaDecodeTime",p.baseMediaDecodeTime),this.trigger("timelineStartInfo",p.timelineStartInfo),W=El.moof(v,[p]),Oe=new Uint8Array(W.byteLength+oe.byteLength),v++,Oe.set(W),Oe.set(oe,W.byteLength),this.trigger("data",{track:p,boxes:Oe}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),k=[],this.gopCache_.length=0,_.length=0,this.trigger("reset")},this.resetStream_=function(){Cn.clearDtsInfo(p),B=void 0,E=void 0},this.getGopForFusion_=function(U){var G=45000,X=1e4,W=1/0,oe,Oe,ge,Ge,et;for(et=0;et<this.gopCache_.length;et++){if(Ge=this.gopCache_[et],ge=Ge.gop,!(p.pps&&cc(p.pps[0],Ge.pps[0]))||!(p.sps&&cc(p.sps[0],Ge.sps[0])))continue;if(ge.dts<p.timelineStartInfo.dts)continue;if(oe=U.dts-ge.dts-ge.duration,oe>=-X&&oe<=G){if(!Oe||W>oe)Oe=Ge,W=oe}}if(Oe)return Oe.gop;return null},this.alignGopsAtStart_=function(U){var G,X,W,oe,Oe,ge,Ge,et;Oe=U.byteLength,ge=U.nalCount,Ge=U.duration,G=X=0;while(G<_.length&&X<U.length){if(W=_[G],oe=U[X],W.pts===oe.pts)break;if(oe.pts>W.pts){G++;continue}X++,Oe-=oe.byteLength,ge-=oe.nalCount,Ge-=oe.duration}if(X===0)return U;if(X===U.length)return null;return et=U.slice(X),et.byteLength=Oe,et.duration=Ge,et.nalCount=ge,et.pts=et[0].pts,et.dts=et[0].dts,et},this.alignGopsAtEnd_=function(U){var G,X,W,oe,Oe,ge;G=_.length-1,X=U.length-1,Oe=null,ge=!1;while(G>=0&&X>=0){if(W=_[G],oe=U[X],W.pts===oe.pts){ge=!0;break}if(W.pts>oe.pts){G--;continue}if(G===_.length-1)Oe=X;X--}if(!ge&&Oe===null)return null;var Ge;if(ge)Ge=X;else Ge=Oe;if(Ge===0)return U;var et=U.slice(Ge),Ga=et.reduce(function(Fn,Li){return Fn.byteLength+=Li.byteLength,Fn.duration+=Li.duration,Fn.nalCount+=Li.nalCount,Fn},{byteLength:0,duration:0,nalCount:0});return et.byteLength=Ga.byteLength,et.duration=Ga.duration,et.nalCount=Ga.nalCount,et.pts=et[0].pts,et.dts=et[0].dts,et},this.alignGopsWith=function(U){_=U}},_f.prototype=new Nl,Gi=function(p,q){if(this.numberOfTracks=0,this.metadataStream=q,p=p||{},typeof p.remux<"u")this.remuxTracks=!!p.remux;else this.remuxTracks=!0;if(typeof p.keepOriginalTimestamps==="boolean")this.keepOriginalTimestamps=p.keepOriginalTimestamps;else this.keepOriginalTimestamps=!1;this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,Gi.prototype.init.call(this),this.push=function(v){if(v.content||v.text)return this.pendingCaptions.push(v);if(v.frames)return this.pendingMetadata.push(v);if(this.pendingTracks.push(v.track),this.pendingBytes+=v.boxes.byteLength,v.track.type==="video")this.videoTrack=v.track,this.pendingBoxes.push(v.boxes);if(v.track.type==="audio")this.audioTrack=v.track,this.pendingBoxes.unshift(v.boxes)}},Gi.prototype=new Nl,Gi.prototype.flush=function(p){var q=0,v={captions:[],captionStreams:{},metadata:[],info:{}},k,_,B,E=0,U;if(this.pendingTracks.length<this.numberOfTracks){if(p!=="VideoSegmentStream"&&p!=="AudioSegmentStream")return;else if(this.remuxTracks)return;else if(this.pendingTracks.length===0){if(this.emittedTracks++,this.emittedTracks>=this.numberOfTracks)this.trigger("done"),this.emittedTracks=0;return}}if(this.videoTrack)E=this.videoTrack.timelineStartInfo.pts,Cf.forEach(function(G){v.info[G]=this.videoTrack[G]},this);else if(this.audioTrack)E=this.audioTrack.timelineStartInfo.pts,yi.forEach(function(G){v.info[G]=this.audioTrack[G]},this);if(this.videoTrack||this.audioTrack){if(this.pendingTracks.length===1)v.type=this.pendingTracks[0].type;else v.type="combined";this.emittedTracks+=this.pendingTracks.length,B=El.initSegment(this.pendingTracks),v.initSegment=new Uint8Array(B.byteLength),v.initSegment.set(B),v.data=new Uint8Array(this.pendingBytes);for(U=0;U<this.pendingBoxes.length;U++)v.data.set(this.pendingBoxes[U],q),q+=this.pendingBoxes[U].byteLength;for(U=0;U<this.pendingCaptions.length;U++)k=this.pendingCaptions[U],k.startTime=M0.metadataTsToSeconds(k.startPts,E,this.keepOriginalTimestamps),k.endTime=M0.metadataTsToSeconds(k.endPts,E,this.keepOriginalTimestamps),v.captionStreams[k.stream]=!0,v.captions.push(k);for(U=0;U<this.pendingMetadata.length;U++)_=this.pendingMetadata[U],_.cueTime=M0.metadataTsToSeconds(_.pts,E,this.keepOriginalTimestamps),v.metadata.push(_);v.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",v);for(U=0;U<v.captions.length;U++)k=v.captions[U],this.trigger("caption",k);for(U=0;U<v.metadata.length;U++)_=v.metadata[U],this.trigger("id3Frame",_)}if(this.emittedTracks>=this.numberOfTracks)this.trigger("done"),this.emittedTracks=0},Gi.prototype.setRemux=function(p){this.remuxTracks=p},Il=function(p){var q=this,v=!0,k,_;Il.prototype.init.call(this),p=p||{},this.baseMediaDecodeTime=p.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var B={};this.transmuxPipeline_=B,B.type="aac",B.metadataStream=new Ms.MetadataStream,B.aacStream=new oc,B.audioTimestampRolloverStream=new Ms.TimestampRolloverStream("audio"),B.timedMetadataTimestampRolloverStream=new Ms.TimestampRolloverStream("timed-metadata"),B.adtsStream=new rc,B.coalesceStream=new Gi(p,B.metadataStream),B.headOfPipeline=B.aacStream,B.aacStream.pipe(B.audioTimestampRolloverStream).pipe(B.adtsStream),B.aacStream.pipe(B.timedMetadataTimestampRolloverStream).pipe(B.metadataStream).pipe(B.coalesceStream),B.metadataStream.on("timestamp",function(E){B.aacStream.setTimestamp(E.timeStamp)}),B.aacStream.on("data",function(E){if(E.type!=="timed-metadata"&&E.type!=="audio"||B.audioSegmentStream)return;_=_||{timelineStartInfo:{baseMediaDecodeTime:q.baseMediaDecodeTime},codec:"adts",type:"audio"},B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new Ii(_,p),B.audioSegmentStream.on("log",q.getLogTrigger_("audioSegmentStream")),B.audioSegmentStream.on("timingInfo",q.trigger.bind(q,"audioTimingInfo")),B.adtsStream.pipe(B.audioSegmentStream).pipe(B.coalesceStream),q.trigger("trackinfo",{hasAudio:!!_,hasVideo:!!k})}),B.coalesceStream.on("data",this.trigger.bind(this,"data")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),Qa(this,B)},this.setupTsPipeline=function(){var B={};this.transmuxPipeline_=B,B.type="ts",B.metadataStream=new Ms.MetadataStream,B.packetStream=new Ms.TransportPacketStream,B.parseStream=new Ms.TransportParseStream,B.elementaryStream=new Ms.ElementaryStream,B.timestampRolloverStream=new Ms.TimestampRolloverStream,B.adtsStream=new rc,B.h264Stream=new I2,B.captionStream=new Ms.CaptionStream(p),B.coalesceStream=new Gi(p,B.metadataStream),B.headOfPipeline=B.packetStream,B.packetStream.pipe(B.parseStream).pipe(B.elementaryStream).pipe(B.timestampRolloverStream),B.timestampRolloverStream.pipe(B.h264Stream),B.timestampRolloverStream.pipe(B.adtsStream),B.timestampRolloverStream.pipe(B.metadataStream).pipe(B.coalesceStream),B.h264Stream.pipe(B.captionStream).pipe(B.coalesceStream),B.elementaryStream.on("data",function(E){var U;if(E.type==="metadata"){U=E.tracks.length;while(U--)if(!k&&E.tracks[U].type==="video")k=E.tracks[U],k.timelineStartInfo.baseMediaDecodeTime=q.baseMediaDecodeTime;else if(!_&&E.tracks[U].type==="audio")_=E.tracks[U],_.timelineStartInfo.baseMediaDecodeTime=q.baseMediaDecodeTime;if(k&&!B.videoSegmentStream)B.coalesceStream.numberOfTracks++,B.videoSegmentStream=new _f(k,p),B.videoSegmentStream.on("log",q.getLogTrigger_("videoSegmentStream")),B.videoSegmentStream.on("timelineStartInfo",function(G){if(_&&!p.keepOriginalTimestamps)_.timelineStartInfo=G,B.audioSegmentStream.setEarliestDts(G.dts-q.baseMediaDecodeTime)}),B.videoSegmentStream.on("processedGopsInfo",q.trigger.bind(q,"gopInfo")),B.videoSegmentStream.on("segmentTimingInfo",q.trigger.bind(q,"videoSegmentTimingInfo")),B.videoSegmentStream.on("baseMediaDecodeTime",function(G){if(_)B.audioSegmentStream.setVideoBaseMediaDecodeTime(G)}),B.videoSegmentStream.on("timingInfo",q.trigger.bind(q,"videoTimingInfo")),B.h264Stream.pipe(B.videoSegmentStream).pipe(B.coalesceStream);if(_&&!B.audioSegmentStream)B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new Ii(_,p),B.audioSegmentStream.on("log",q.getLogTrigger_("audioSegmentStream")),B.audioSegmentStream.on("timingInfo",q.trigger.bind(q,"audioTimingInfo")),B.audioSegmentStream.on("segmentTimingInfo",q.trigger.bind(q,"audioSegmentTimingInfo")),B.adtsStream.pipe(B.audioSegmentStream).pipe(B.coalesceStream);q.trigger("trackinfo",{hasAudio:!!_,hasVideo:!!k})}}),B.coalesceStream.on("data",this.trigger.bind(this,"data")),B.coalesceStream.on("id3Frame",function(E){E.dispatchType=B.metadataStream.dispatchType,q.trigger("id3Frame",E)}),B.coalesceStream.on("caption",this.trigger.bind(this,"caption")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),Qa(this,B)},this.setBaseMediaDecodeTime=function(B){var E=this.transmuxPipeline_;if(!p.keepOriginalTimestamps)this.baseMediaDecodeTime=B;if(_){if(_.timelineStartInfo.dts=void 0,_.timelineStartInfo.pts=void 0,Cn.clearDtsInfo(_),E.audioTimestampRolloverStream)E.audioTimestampRolloverStream.discontinuity()}if(k){if(E.videoSegmentStream)E.videoSegmentStream.gopCache_=[];k.timelineStartInfo.dts=void 0,k.timelineStartInfo.pts=void 0,Cn.clearDtsInfo(k),E.captionStream.reset()}if(E.timestampRolloverStream)E.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(B){if(_)this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(B)},this.setRemux=function(B){var E=this.transmuxPipeline_;if(p.remux=B,E&&E.coalesceStream)E.coalesceStream.setRemux(B)},this.alignGopsWith=function(B){if(k&&this.transmuxPipeline_.videoSegmentStream)this.transmuxPipeline_.videoSegmentStream.alignGopsWith(B)},this.getLogTrigger_=function(B){var E=this;return function(U){U.stream=B,E.trigger("log",U)}},this.push=function(B){if(v){var E=G2(B);if(E&&this.transmuxPipeline_.type!=="aac")this.setupAacPipeline();else if(!E&&this.transmuxPipeline_.type!=="ts")this.setupTsPipeline();v=!1}this.transmuxPipeline_.headOfPipeline.push(B)},this.flush=function(){v=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){if(this.transmuxPipeline_.headOfPipeline)this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){if(this.transmuxPipeline_.captionStream)this.transmuxPipeline_.captionStream.reset()}},Il.prototype=new Nl;var K2={Transmuxer:Il,VideoSegmentStream:_f,AudioSegmentStream:Ii,AUDIO_PROPERTIES:yi,VIDEO_PROPERTIES:Cf,generateSegmentTimingInfo:$r},L2=function(p){return p>>>0},Gl=function(p){return("00"+p.toString(16)).slice(-2)},Xl={toUnsigned:L2,toHexString:Gl},Wr=function(p){var q="";return q+=String.fromCharCode(p[0]),q+=String.fromCharCode(p[1]),q+=String.fromCharCode(p[2]),q+=String.fromCharCode(p[3]),q},Pr=Wr,W5=Xl.toUnsigned,e1=Pr,t1=function(p,q){var v=[],k,_,B,E,U;if(!q.length)return null;for(k=0;k<p.byteLength;){if(_=W5(p[k]<<24|p[k+1]<<16|p[k+2]<<8|p[k+3]),B=e1(p.subarray(k+4,k+8)),E=_>1?k+_:p.byteLength,B===q[0]){if(q.length===1)v.push(p.subarray(k+8,E));else if(U=t1(p.subarray(k+8,E),q.slice(1)),U.length)v=v.concat(U)}k=E}return v},Kl=t1,V2=Xl.toUnsigned,Y2=i.getUint64,hc=function(p){var q={version:p[0],flags:new Uint8Array(p.subarray(1,4))};if(q.version===1)q.baseMediaDecodeTime=Y2(p.subarray(4));else q.baseMediaDecodeTime=V2(p[4]<<24|p[5]<<16|p[6]<<8|p[7]);return q},Ll=hc,J2=function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:p[0],flags:new Uint8Array(p.subarray(1,4)),trackId:q.getUint32(4)},k=v.flags[2]&1,_=v.flags[2]&2,B=v.flags[2]&8,E=v.flags[2]&16,U=v.flags[2]&32,G=v.flags[0]&65536,X=v.flags[0]&131072,W;if(W=8,k)W+=4,v.baseDataOffset=q.getUint32(12),W+=4;if(_)v.sampleDescriptionIndex=q.getUint32(W),W+=4;if(B)v.defaultSampleDuration=q.getUint32(W),W+=4;if(E)v.defaultSampleSize=q.getUint32(W),W+=4;if(U)v.defaultSampleFlags=q.getUint32(W);if(G)v.durationIsEmpty=!0;if(!k&&X)v.baseDataOffsetIsMoof=!0;return v},Vl=J2,Yl=i.getUint64,uc=function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:p[0],flags:new Uint8Array(p.subarray(1,4)),references:[],referenceId:q.getUint32(4),timescale:q.getUint32(8)},k=12;if(v.version===0)v.earliestPresentationTime=q.getUint32(k),v.firstOffset=q.getUint32(k+4),k+=8;else v.earliestPresentationTime=Yl(p.subarray(k)),v.firstOffset=Yl(p.subarray(k+8)),k+=16;k+=2;var _=q.getUint16(k);k+=2;for(;_>0;k+=12,_--)v.references.push({referenceType:(p[k]&128)>>>7,referencedSize:q.getUint32(k)&2147483647,subsegmentDuration:q.getUint32(k+4),startsWithSap:!!(p[k+8]&128),sapType:(p[k+8]&112)>>>4,sapDeltaTime:q.getUint32(k+8)&268435455});return v},Q2=uc,mc=function(p){return{isLeading:(p[0]&12)>>>2,dependsOn:p[0]&3,isDependedOn:(p[1]&192)>>>6,hasRedundancy:(p[1]&48)>>>4,paddingValue:(p[1]&14)>>>1,isNonSyncSample:p[1]&1,degradationPriority:p[2]<<8|p[3]}},Z2=mc,Ps=Z2,gc=function(p){var q={version:p[0],flags:new Uint8Array(p.subarray(1,4)),samples:[]},v=new DataView(p.buffer,p.byteOffset,p.byteLength),k=q.flags[2]&1,_=q.flags[2]&4,B=q.flags[1]&1,E=q.flags[1]&2,U=q.flags[1]&4,G=q.flags[1]&8,X=v.getUint32(4),W=8,oe;if(k)q.dataOffset=v.getInt32(W),W+=4;if(_&&X){if(oe={flags:Ps(p.subarray(W,W+4))},W+=4,B)oe.duration=v.getUint32(W),W+=4;if(E)oe.size=v.getUint32(W),W+=4;if(G){if(q.version===1)oe.compositionTimeOffset=v.getInt32(W);else oe.compositionTimeOffset=v.getUint32(W);W+=4}q.samples.push(oe),X--}while(X--){if(oe={},B)oe.duration=v.getUint32(W),W+=4;if(E)oe.size=v.getUint32(W),W+=4;if(U)oe.flags=Ps(p.subarray(W,W+4)),W+=4;if(G){if(q.version===1)oe.compositionTimeOffset=v.getInt32(W);else oe.compositionTimeOffset=v.getUint32(W);W+=4}q.samples.push(oe)}return q},$2=gc,W2=i,os=W2.getUint64,Ia,a1,In=function(p){return new Date(p*1000-2082844800000)},Ff=Pr,P2=Kl,pc=function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v=[],k,_;for(k=0;k+4<p.length;k+=_){if(_=q.getUint32(k),k+=4,_<=0){v.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(p[k]&31){case 1:v.push("slice_layer_without_partitioning_rbsp");break;case 5:v.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:v.push("sei_rbsp");break;case 7:v.push("seq_parameter_set_rbsp");break;case 8:v.push("pic_parameter_set_rbsp");break;case 9:v.push("access_unit_delimiter_rbsp");break;default:v.push("UNKNOWN NAL - "+p[k]&31);break}}return v},ei={avc1:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength);return{dataReferenceIndex:q.getUint16(6),width:q.getUint16(24),height:q.getUint16(26),horizresolution:q.getUint16(28)+q.getUint16(30)/16,vertresolution:q.getUint16(32)+q.getUint16(34)/16,frameCount:q.getUint16(40),depth:q.getUint16(74),config:Ia(p.subarray(78,p.byteLength))}},avcC:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={configurationVersion:p[0],avcProfileIndication:p[1],profileCompatibility:p[2],avcLevelIndication:p[3],lengthSizeMinusOne:p[4]&3,sps:[],pps:[]},k=p[5]&31,_,B,E,U;E=6;for(U=0;U<k;U++)B=q.getUint16(E),E+=2,v.sps.push(new Uint8Array(p.subarray(E,E+B))),E+=B;_=p[E],E++;for(U=0;U<_;U++)B=q.getUint16(E),E+=2,v.pps.push(new Uint8Array(p.subarray(E,E+B))),E+=B;return v},btrt:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength);return{bufferSizeDB:q.getUint32(0),maxBitrate:q.getUint32(4),avgBitrate:q.getUint32(8)}},edts:function(q){return{boxes:Ia(q)}},elst:function(q){var v=new DataView(q.buffer,q.byteOffset,q.byteLength),k={version:v.getUint8(0),flags:new Uint8Array(q.subarray(1,4)),edits:[]},_=v.getUint32(4),B;for(B=8;_;_--)if(k.version===0)k.edits.push({segmentDuration:v.getUint32(B),mediaTime:v.getInt32(B+4),mediaRate:v.getUint16(B+8)+v.getUint16(B+10)/65536}),B+=12;else k.edits.push({segmentDuration:os(q.subarray(B)),mediaTime:os(q.subarray(B+8)),mediaRate:v.getUint16(B+16)+v.getUint16(B+18)/65536}),B+=20;return k},esds:function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),esId:p[6]<<8|p[7],streamPriority:p[8]&31,decoderConfig:{objectProfileIndication:p[11],streamType:p[12]>>>2&63,bufferSize:p[13]<<16|p[14]<<8|p[15],maxBitrate:p[16]<<24|p[17]<<16|p[18]<<8|p[19],avgBitrate:p[20]<<24|p[21]<<16|p[22]<<8|p[23],decoderConfigDescriptor:{tag:p[24],length:p[25],audioObjectType:p[26]>>>3&31,samplingFrequencyIndex:(p[26]&7)<<1|p[27]>>>7&1,channelConfiguration:p[27]>>>3&15}}}},ftyp:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={majorBrand:Ff(p.subarray(0,4)),minorVersion:q.getUint32(4),compatibleBrands:[]},k=8;while(k<p.byteLength)v.compatibleBrands.push(Ff(p.subarray(k,k+4))),k+=4;return v},dinf:function(p){return{boxes:Ia(p)}},dref:function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),dataReferences:Ia(p.subarray(8))}},hdlr:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4)),handlerType:Ff(p.subarray(8,12)),name:""},k=8;for(k=24;k<p.byteLength;k++){if(p[k]===0){k++;break}v.name+=String.fromCharCode(p[k])}return v.name=decodeURIComponent(escape(v.name)),v},mdat:function(p){return{byteLength:p.byteLength,nals:pc(p)}},mdhd:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v=4,k,_={version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4)),language:""};if(_.version===1)v+=4,_.creationTime=In(q.getUint32(v)),v+=8,_.modificationTime=In(q.getUint32(v)),v+=4,_.timescale=q.getUint32(v),v+=8,_.duration=q.getUint32(v);else _.creationTime=In(q.getUint32(v)),v+=4,_.modificationTime=In(q.getUint32(v)),v+=4,_.timescale=q.getUint32(v),v+=4,_.duration=q.getUint32(v);return v+=4,k=q.getUint16(v),_.language+=String.fromCharCode((k>>10)+96),_.language+=String.fromCharCode(((k&992)>>5)+96),_.language+=String.fromCharCode((k&31)+96),_},mdia:function(p){return{boxes:Ia(p)}},mfhd:function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),sequenceNumber:p[4]<<24|p[5]<<16|p[6]<<8|p[7]}},minf:function(p){return{boxes:Ia(p)}},mp4a:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={dataReferenceIndex:q.getUint16(6),channelcount:q.getUint16(16),samplesize:q.getUint16(18),samplerate:q.getUint16(24)+q.getUint16(26)/65536};if(p.byteLength>28)v.streamDescriptor=Ia(p.subarray(28))[0];return v},moof:function(p){return{boxes:Ia(p)}},moov:function(p){return{boxes:Ia(p)}},mvex:function(p){return{boxes:Ia(p)}},mvhd:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v=4,k={version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4))};if(k.version===1)v+=4,k.creationTime=In(q.getUint32(v)),v+=8,k.modificationTime=In(q.getUint32(v)),v+=4,k.timescale=q.getUint32(v),v+=8,k.duration=q.getUint32(v);else k.creationTime=In(q.getUint32(v)),v+=4,k.modificationTime=In(q.getUint32(v)),v+=4,k.timescale=q.getUint32(v),v+=4,k.duration=q.getUint32(v);return v+=4,k.rate=q.getUint16(v)+q.getUint16(v+2)/16,v+=4,k.volume=q.getUint8(v)+q.getUint8(v+1)/8,v+=2,v+=2,v+=8,k.matrix=new Uint32Array(p.subarray(v,v+36)),v+=36,v+=24,k.nextTrackId=q.getUint32(v),k},pdin:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength);return{version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4)),rate:q.getUint32(4),initialDelay:q.getUint32(8)}},sdtp:function(p){var q={version:p[0],flags:new Uint8Array(p.subarray(1,4)),samples:[]},v;for(v=4;v<p.byteLength;v++)q.samples.push({dependsOn:(p[v]&48)>>4,isDependedOn:(p[v]&12)>>2,hasRedundancy:p[v]&3});return q},sidx:Q2,smhd:function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),balance:p[4]+p[5]/256}},stbl:function(p){return{boxes:Ia(p)}},ctts:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4)),compositionOffsets:[]},k=q.getUint32(4),_;for(_=8;k;_+=8,k--)v.compositionOffsets.push({sampleCount:q.getUint32(_),sampleOffset:q[v.version===0?"getUint32":"getInt32"](_+4)});return v},stss:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4)),syncSamples:[]},k=q.getUint32(4),_;for(_=8;k;_+=4,k--)v.syncSamples.push(q.getUint32(_));return v},stco:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:p[0],flags:new Uint8Array(p.subarray(1,4)),chunkOffsets:[]},k=q.getUint32(4),_;for(_=8;k;_+=4,k--)v.chunkOffsets.push(q.getUint32(_));return v},stsc:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v=q.getUint32(4),k={version:p[0],flags:new Uint8Array(p.subarray(1,4)),sampleToChunks:[]},_;for(_=8;v;_+=12,v--)k.sampleToChunks.push({firstChunk:q.getUint32(_),samplesPerChunk:q.getUint32(_+4),sampleDescriptionIndex:q.getUint32(_+8)});return k},stsd:function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),sampleDescriptions:Ia(p.subarray(8))}},stsz:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:p[0],flags:new Uint8Array(p.subarray(1,4)),sampleSize:q.getUint32(4),entries:[]},k;for(k=12;k<p.byteLength;k+=4)v.entries.push(q.getUint32(k));return v},stts:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v={version:p[0],flags:new Uint8Array(p.subarray(1,4)),timeToSamples:[]},k=q.getUint32(4),_;for(_=8;k;_+=8,k--)v.timeToSamples.push({sampleCount:q.getUint32(_),sampleDelta:q.getUint32(_+4)});return v},styp:function(p){return ei.ftyp(p)},tfdt:Ll,tfhd:Vl,tkhd:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength),v=4,k={version:q.getUint8(0),flags:new Uint8Array(p.subarray(1,4))};if(k.version===1)v+=4,k.creationTime=In(q.getUint32(v)),v+=8,k.modificationTime=In(q.getUint32(v)),v+=4,k.trackId=q.getUint32(v),v+=4,v+=8,k.duration=q.getUint32(v);else k.creationTime=In(q.getUint32(v)),v+=4,k.modificationTime=In(q.getUint32(v)),v+=4,k.trackId=q.getUint32(v),v+=4,v+=4,k.duration=q.getUint32(v);return v+=4,v+=8,k.layer=q.getUint16(v),v+=2,k.alternateGroup=q.getUint16(v),v+=2,k.volume=q.getUint8(v)+q.getUint8(v+1)/8,v+=2,v+=2,k.matrix=new Uint32Array(p.subarray(v,v+36)),v+=36,k.width=q.getUint16(v)+q.getUint16(v+2)/65536,v+=4,k.height=q.getUint16(v)+q.getUint16(v+2)/65536,k},traf:function(p){return{boxes:Ia(p)}},trak:function(p){return{boxes:Ia(p)}},trex:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength);return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),trackId:q.getUint32(4),defaultSampleDescriptionIndex:q.getUint32(8),defaultSampleDuration:q.getUint32(12),defaultSampleSize:q.getUint32(16),sampleDependsOn:p[20]&3,sampleIsDependedOn:(p[21]&192)>>6,sampleHasRedundancy:(p[21]&48)>>4,samplePaddingValue:(p[21]&14)>>1,sampleIsDifferenceSample:!!(p[21]&1),sampleDegradationPriority:q.getUint16(22)}},trun:$2,"url ":function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4))}},vmhd:function(p){var q=new DataView(p.buffer,p.byteOffset,p.byteLength);return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),graphicsmode:q.getUint16(4),opcolor:new Uint16Array([q.getUint16(6),q.getUint16(8),q.getUint16(10)])}}};Ia=function(p){var q=0,v=[],k,_,B,E,U,G=new ArrayBuffer(p.length),X=new Uint8Array(G);for(var W=0;W<p.length;++W)X[W]=p[W];k=new DataView(G);while(q<p.byteLength)_=k.getUint32(q),B=Ff(p.subarray(q+4,q+8)),E=_>1?q+_:p.byteLength,U=(ei[B]||function(oe){return{data:oe}})(p.subarray(q+8,E)),U.size=_,U.type=B,v.push(U),q=E;return v},a1=function(p,q){var v;return q=q||0,v=Array(q*2+1).join(" "),p.map(function(k,_){return v+k.type+`
208
+ `+Object.keys(k).filter(function(B){return B!=="type"&&B!=="boxes"}).map(function(B){var E=v+" "+B+": ",U=k[B];if(U instanceof Uint8Array||U instanceof Uint32Array){var G=Array.prototype.slice.call(new Uint8Array(U.buffer,U.byteOffset,U.byteLength)).map(function(X){return" "+("00"+X.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);if(!G)return E+"<>";if(G.length===1)return E+"<"+G.join("").slice(1)+">";return E+`<
209
+ `+G.map(function(X){return v+" "+X}).join(`
210
+ `)+`
211
+ `+v+" >"}return E+JSON.stringify(U,null,2).split(`
212
+ `).map(function(X,W){if(W===0)return X;return v+" "+X}).join(`
213
+ `)}).join(`
214
+ `)+(k.boxes?`
215
+ `+a1(k.boxes,q+1):"")}).join(`
216
+ `)};var bc={inspect:Ia,textify:a1,parseType:Ff,findBox:P2,parseTraf:ei.traf,parseTfdt:ei.tfdt,parseHdlr:ei.hdlr,parseTfhd:ei.tfhd,parseTrun:ei.trun,parseSidx:ei.sidx},n1=function(p){var q=0,v=String.fromCharCode(p[q]),k="";while(v!=="\x00")k+=v,q++,v=String.fromCharCode(p[q]);return k+=v,k},Jl={uint8ToCString:n1},Kt=Jl.uint8ToCString,P5=i.getUint64,e3=function(p){var q=4,v=p[0],k,_,B,E,U,G,X,W;if(v===0){k=Kt(p.subarray(q)),q+=k.length,_=Kt(p.subarray(q)),q+=_.length;var oe=new DataView(p.buffer);B=oe.getUint32(q),q+=4,U=oe.getUint32(q),q+=4,G=oe.getUint32(q),q+=4,X=oe.getUint32(q),q+=4}else if(v===1){var oe=new DataView(p.buffer);B=oe.getUint32(q),q+=4,E=P5(p.subarray(q)),q+=8,G=oe.getUint32(q),q+=4,X=oe.getUint32(q),q+=4,k=Kt(p.subarray(q)),q+=k.length,_=Kt(p.subarray(q)),q+=_.length}W=new Uint8Array(p.subarray(q,p.byteLength));var Oe={scheme_id_uri:k,value:_,timescale:B?B:1,presentation_time:E,presentation_time_delta:U,event_duration:G,id:X,message_data:W};return Ql(v,Oe)?Oe:void 0},eu=function(p,q,v,k){return p||p===0?p/q:k+v/q},Ql=function(p,q){var v=q.scheme_id_uri!=="\x00",k=p===0&&Si(q.presentation_time_delta)&&v,_=p===1&&Si(q.presentation_time)&&v;return!(p>1)&&k||_},Si=function(p){return p!==void 0||p!==null},tu={parseEmsgBox:e3,scaleTime:eu},Of;if(typeof window<"u")Of=window;else if(typeof e<"u")Of=e;else if(typeof self<"u")Of=self;else Of={};var Bf=Of,Qn=Xl.toUnsigned,Tf=Xl.toHexString,ba=Kl,D0=Pr,Zl=tu,wc=Vl,s1=$2,au=Ll,nu=i.getUint64,su,dc,jc,cs,i1,f1,qc,vc=Bf,l1=cn.parseId3Frames;su=function(p){var q={},v=ba(p,["moov","trak"]);return v.reduce(function(k,_){var B,E,U,G,X;if(B=ba(_,["tkhd"])[0],!B)return null;if(E=B[0],U=E===0?12:20,G=Qn(B[U]<<24|B[U+1]<<16|B[U+2]<<8|B[U+3]),X=ba(_,["mdia","mdhd"])[0],!X)return null;return E=X[0],U=E===0?12:20,k[G]=Qn(X[U]<<24|X[U+1]<<16|X[U+2]<<8|X[U+3]),k},q)},dc=function(p,q){var v=ba(q,["moof","traf"]),k=v.reduce(function(_,B){var E=ba(B,["tfhd"])[0],U=Qn(E[4]<<24|E[5]<<16|E[6]<<8|E[7]),G=p[U]||90000,X=ba(B,["tfdt"])[0],W=new DataView(X.buffer,X.byteOffset,X.byteLength),oe;if(X[0]===1)oe=nu(X.subarray(4,12));else oe=W.getUint32(4);let Oe;if(typeof oe==="bigint")Oe=oe/vc.BigInt(G);else if(typeof oe==="number"&&!isNaN(oe))Oe=oe/G;if(Oe<Number.MAX_SAFE_INTEGER)Oe=Number(Oe);if(Oe<_)_=Oe;return _},1/0);return typeof k==="bigint"||isFinite(k)?k:0},jc=function(p,q){var v=ba(q,["moof","traf"]),k=0,_=0,B;if(v&&v.length){var E=ba(v[0],["tfhd"])[0],U=ba(v[0],["trun"])[0],G=ba(v[0],["tfdt"])[0];if(E){var X=wc(E);B=X.trackId}if(G){var W=au(G);k=W.baseMediaDecodeTime}if(U){var oe=s1(U);if(oe.samples&&oe.samples.length)_=oe.samples[0].compositionTimeOffset||0}}var Oe=p[B]||90000;if(typeof k==="bigint")_=vc.BigInt(_),Oe=vc.BigInt(Oe);var ge=(k+_)/Oe;if(typeof ge==="bigint"&&ge<Number.MAX_SAFE_INTEGER)ge=Number(ge);return ge},cs=function(p){var q=ba(p,["moov","trak"]),v=[];return q.forEach(function(k){var _=ba(k,["mdia","hdlr"]),B=ba(k,["tkhd"]);_.forEach(function(E,U){var G=D0(E.subarray(8,12)),X=B[U],W,oe,Oe;if(G==="vide")W=new DataView(X.buffer,X.byteOffset,X.byteLength),oe=W.getUint8(0),Oe=oe===0?W.getUint32(12):W.getUint32(20),v.push(Oe)})}),v},f1=function(p){var q=p[0],v=q===0?12:20;return Qn(p[v]<<24|p[v+1]<<16|p[v+2]<<8|p[v+3])},i1=function(p){var q=ba(p,["moov","trak"]),v=[];return q.forEach(function(k){var _={},B=ba(k,["tkhd"])[0],E,U;if(B)E=new DataView(B.buffer,B.byteOffset,B.byteLength),U=E.getUint8(0),_.id=U===0?E.getUint32(12):E.getUint32(20);var G=ba(k,["mdia","hdlr"])[0];if(G){var X=D0(G.subarray(8,12));if(X==="vide")_.type="video";else if(X==="soun")_.type="audio";else _.type=X}var W=ba(k,["mdia","minf","stbl","stsd"])[0];if(W){var oe=W.subarray(8);_.codec=D0(oe.subarray(4,8));var Oe=ba(oe,[_.codec])[0],ge,Ge;if(Oe)if(/^[asm]vc[1-9]$/i.test(_.codec))if(ge=Oe.subarray(78),Ge=D0(ge.subarray(4,8)),Ge==="avcC"&&ge.length>11)_.codec+=".",_.codec+=Tf(ge[9]),_.codec+=Tf(ge[10]),_.codec+=Tf(ge[11]);else _.codec="avc1.4d400d";else if(/^mp4[a,v]$/i.test(_.codec))if(ge=Oe.subarray(28),Ge=D0(ge.subarray(4,8)),Ge==="esds"&&ge.length>20&&ge[19]!==0)_.codec+="."+Tf(ge[19]),_.codec+="."+Tf(ge[20]>>>2&63).replace(/^0/,"");else _.codec="mp4a.40.2";else _.codec=_.codec.toLowerCase()}var et=ba(k,["mdia","mdhd"])[0];if(et)_.timescale=f1(et);v.push(_)}),v},qc=function(p,q=0){var v=ba(p,["emsg"]);return v.map((k)=>{var _=Zl.parseEmsgBox(new Uint8Array(k)),B=l1(_.message_data);return{cueTime:Zl.scaleTime(_.presentation_time,_.timescale,_.presentation_time_delta,q),duration:Zl.scaleTime(_.event_duration,_.timescale),frames:B}})};var xa={findBox:ba,parseType:D0,timescale:su,startTime:dc,compositionStartTime:jc,videoTrackIds:cs,tracks:i1,getTimescaleFromMediaHeader:f1,getEmsgID3:qc};let{parseTrun:iu}=bc,{findBox:hn}=xa;var kc=Bf,Ci=function(p){var q=hn(p,["moof","traf"]),v=hn(p,["mdat"]),k=[];return v.forEach(function(_,B){var E=q[B];k.push({mdat:_,traf:E})}),k},x0=function(p,q,v){var k=q,_=v.defaultSampleDuration||0,B=v.defaultSampleSize||0,E=v.trackId,U=[];return p.forEach(function(G){var X=iu(G),W=X.samples;W.forEach(function(oe){if(oe.duration===void 0)oe.duration=_;if(oe.size===void 0)oe.size=B;if(oe.trackId=E,oe.dts=k,oe.compositionTimeOffset===void 0)oe.compositionTimeOffset=0;if(typeof k==="bigint")oe.pts=k+kc.BigInt(oe.compositionTimeOffset),k+=kc.BigInt(oe.duration);else oe.pts=k+oe.compositionTimeOffset,k+=oe.duration}),U=U.concat(W)}),U},ti={getMdatTrafPairs:Ci,parseSamples:x0},Ac=Vo.discardEmulationPreventionBytes,yc=Yo.CaptionStream,Zn=Kl,fu=Ll,Hf=Vl,{getMdatTrafPairs:$l,parseSamples:R0}=ti,lu=function(p,q){var v=p;for(var k=0;k<q.length;k++){var _=q[k];if(v<_.size)return _;v-=_.size}return null},ru=function(p,q,v){var k=new DataView(p.buffer,p.byteOffset,p.byteLength),_={logs:[],seiNals:[]},B,E,U,G;for(E=0;E+4<p.length;E+=U){if(U=k.getUint32(E),E+=4,U<=0)continue;switch(p[E]&31){case 6:var X=p.subarray(E+1,E+1+U),W=lu(E,q);if(B={nalUnitType:"sei_rbsp",size:U,data:X,escapedRBSP:Ac(X),trackId:v},W)B.pts=W.pts,B.dts=W.dts,G=W;else if(G)B.pts=G.pts,B.dts=G.dts;else{_.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+E+" for trackId "+v+". See mux.js#223."});break}_.seiNals.push(B);break}}return _},Wl=function(p,q){var v={},k=$l(p);return k.forEach(function(_){var{mdat:B,traf:E}=_,U=Zn(E,["tfhd"]),G=Hf(U[0]),X=G.trackId,W=Zn(E,["tfdt"]),oe=W.length>0?fu(W[0]).baseMediaDecodeTime:0,Oe=Zn(E,["trun"]),ge,Ge;if(q===X&&Oe.length>0){if(ge=R0(Oe,oe,G),Ge=ru(B,ge,X),!v[X])v[X]={seiNals:[],logs:[]};v[X].seiNals=v[X].seiNals.concat(Ge.seiNals),v[X].logs=v[X].logs.concat(Ge.logs)}}),v},ou=function(p,q,v){var k;if(q===null)return null;k=Wl(p,q);var _=k[q]||{};return{seiNals:_.seiNals,logs:_.logs,timescale:v}},r1=function(){var p=!1,q,v,k,_,B,E;this.isInitialized=function(){return p},this.init=function(U){q=new yc,p=!0,E=U?U.isPartial:!1,q.on("data",function(G){G.startTime=G.startPts/_,G.endTime=G.endPts/_,B.captions.push(G),B.captionStreams[G.stream]=!0}),q.on("log",function(G){B.logs.push(G)})},this.isNewInit=function(U,G){if(U&&U.length===0||G&&typeof G==="object"&&Object.keys(G).length===0)return!1;return k!==U[0]||_!==G[k]},this.parse=function(U,G,X){var W;if(!this.isInitialized())return null;else if(!G||!X)return null;else if(this.isNewInit(G,X))k=G[0],_=X[k];else if(k===null||!_)return v.push(U),null;while(v.length>0){var oe=v.shift();this.parse(oe,G,X)}if(W=ou(U,k,_),W&&W.logs)B.logs=B.logs.concat(W.logs);if(W===null||!W.seiNals){if(B.logs.length)return{logs:B.logs,captions:[],captionStreams:[]};return null}return this.pushNals(W.seiNals),this.flushStream(),B},this.pushNals=function(U){if(!this.isInitialized()||!U||U.length===0)return null;U.forEach(function(G){q.push(G)})},this.flushStream=function(){if(!this.isInitialized())return null;if(!E)q.flush();else q.partialFlush()},this.clearParsedCaptions=function(){B.captions=[],B.captionStreams={},B.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;q.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){if(v=[],k=null,_=null,!B)B={captions:[],captionStreams:{},logs:[]};else this.clearParsedCaptions();this.resetCaptionStream()},this.reset()},cu=r1;let{parseTfdt:Sc}=bc,ai=Kl,{getTimescaleFromMediaHeader:Cc}=xa,{parseSamples:hu,getMdatTrafPairs:_c}=ti;var Fc=function(){let p=90000;this.init=function(q){let v=ai(q,["moov","trak","mdia","mdhd"])[0];if(v)p=Cc(v)},this.parseSegment=function(q){let v=[],k=_c(q),_=0;return k.forEach(function(B){let{mdat:E,traf:U}=B,G=ai(U,["tfdt"])[0],X=ai(U,["tfhd"])[0],W=ai(U,["trun"]);if(G)_=Sc(G).baseMediaDecodeTime;if(W.length&&X){let oe=hu(W,_,X),Oe=0;oe.forEach(function(ge){let et=new TextDecoder("utf-8"),Ga=E.slice(Oe,Oe+ge.size);if(ai(Ga,["vtte"])[0]){Oe+=ge.size;return}ai(Ga,["vttc"]).forEach(function(Df){let xf=ai(Df,["payl"])[0],Rf=ai(Df,["sttg"])[0],Nf=ge.pts/p,tr=(ge.pts+ge.duration)/p,Jt,ct;if(xf)try{Jt=et.decode(xf)}catch($n){console.error($n)}if(Rf)try{ct=et.decode(Rf)}catch($n){console.error($n)}if(ge.duration&&Jt)v.push({cueText:Jt,start:Nf,end:tr,settings:ct})}),Oe+=ge.size})}}),v}},un=Cl,Oc=function(p){var q=p[1]&31;return q<<=8,q|=p[2],q},Pl=function(p){return!!(p[1]&64)},o1=function(p){var q=0;if((p[3]&48)>>>4>1)q+=p[4]+1;return q},Xi=function(p,q){var v=Oc(p);if(v===0)return"pat";else if(v===q)return"pmt";else if(q)return"pes";return null},uu=function(p){var q=Pl(p),v=4+o1(p);if(q)v+=p[v]+1;return(p[v+10]&31)<<8|p[v+11]},Bc=function(p){var q={},v=Pl(p),k=4+o1(p);if(v)k+=p[k]+1;if(!(p[k+5]&1))return;var _,B,E;_=(p[k+1]&15)<<8|p[k+2],B=3+_-4,E=(p[k+10]&15)<<8|p[k+11];var U=12+E;while(U<B){var G=k+U;q[(p[G+1]&31)<<8|p[G+2]]=p[G],U+=((p[G+3]&15)<<8|p[G+4])+5}return q},Mf=function(p,q){var v=Oc(p),k=q[v];switch(k){case un.H264_STREAM_TYPE:return"video";case un.ADTS_STREAM_TYPE:return"audio";case un.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},mu=function(p){var q=Pl(p);if(!q)return null;var v=4+o1(p);if(v>=p.byteLength)return null;var k=null,_;if(_=p[v+7],_&192){if(k={},k.pts=(p[v+9]&14)<<27|(p[v+10]&255)<<20|(p[v+11]&254)<<12|(p[v+12]&255)<<5|(p[v+13]&254)>>>3,k.pts*=4,k.pts+=(p[v+13]&6)>>>1,k.dts=k.pts,_&64)k.dts=(p[v+14]&14)<<27|(p[v+15]&255)<<20|(p[v+16]&254)<<12|(p[v+17]&255)<<5|(p[v+18]&254)>>>3,k.dts*=4,k.dts+=(p[v+18]&6)>>>1}return k},c1=function(p){switch(p){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},gu=function(p){var q=4+o1(p),v=p.subarray(q),k=0,_=0,B=!1,E;for(;_<v.byteLength-3;_++)if(v[_+2]===1){k=_+5;break}while(k<v.byteLength)switch(v[k]){case 0:if(v[k-1]!==0){k+=2;break}else if(v[k-2]!==0){k++;break}if(_+3!==k-2){if(E=c1(v[_+3]&31),E==="slice_layer_without_partitioning_rbsp_idr")B=!0}do k++;while(v[k]!==1&&k<v.length);_=k-2,k+=3;break;case 1:if(v[k-1]!==0||v[k-2]!==0){k+=3;break}if(E=c1(v[_+3]&31),E==="slice_layer_without_partitioning_rbsp_idr")B=!0;_=k-2,k+=3;break;default:k+=3;break}if(v=v.subarray(_),k-=_,_=0,v&&v.byteLength>3){if(E=c1(v[_+3]&31),E==="slice_layer_without_partitioning_rbsp_idr")B=!0}return B},pu={parseType:Xi,parsePat:uu,parsePmt:Bc,parsePayloadUnitStartIndicator:Pl,parsePesType:Mf,parsePesTime:mu,videoPacketContainsKeyFrame:gu},er=Cl,Ki=Un.handleRollover,Ut={};Ut.ts=pu,Ut.aac=Rl;var N0=Bt.ONE_SECOND_IN_TS,_n=188,Ds=71,bu=function(p,q){var v=0,k=_n,_,B;while(k<p.byteLength){if(p[v]===Ds&&p[k]===Ds){switch(_=p.subarray(v,k),B=Ut.ts.parseType(_,q.pid),B){case"pat":q.pid=Ut.ts.parsePat(_);break;case"pmt":var E=Ut.ts.parsePmt(_);q.table=q.table||{},Object.keys(E).forEach(function(U){q.table[U]=E[U]});break}v+=_n,k+=_n;continue}v++,k++}},E0=function(p,q,v){var k=0,_=_n,B,E,U,G,X,W=!1;while(_<=p.byteLength){if(p[k]===Ds&&(p[_]===Ds||_===p.byteLength)){switch(B=p.subarray(k,_),E=Ut.ts.parseType(B,q.pid),E){case"pes":if(U=Ut.ts.parsePesType(B,q.table),G=Ut.ts.parsePayloadUnitStartIndicator(B),U==="audio"&&G){if(X=Ut.ts.parsePesTime(B),X)X.type="audio",v.audio.push(X),W=!0}break}if(W)break;k+=_n,_+=_n;continue}k++,_++}_=p.byteLength,k=_-_n,W=!1;while(k>=0){if(p[k]===Ds&&(p[_]===Ds||_===p.byteLength)){switch(B=p.subarray(k,_),E=Ut.ts.parseType(B,q.pid),E){case"pes":if(U=Ut.ts.parsePesType(B,q.table),G=Ut.ts.parsePayloadUnitStartIndicator(B),U==="audio"&&G){if(X=Ut.ts.parsePesTime(B),X)X.type="audio",v.audio.push(X),W=!0}break}if(W)break;k-=_n,_-=_n;continue}k--,_--}},h1=function(p,q,v){var k=0,_=_n,B,E,U,G,X,W,oe,Oe,ge=!1,Ge={data:[],size:0};while(_<p.byteLength){if(p[k]===Ds&&p[_]===Ds){switch(B=p.subarray(k,_),E=Ut.ts.parseType(B,q.pid),E){case"pes":if(U=Ut.ts.parsePesType(B,q.table),G=Ut.ts.parsePayloadUnitStartIndicator(B),U==="video"){if(G&&!ge){if(X=Ut.ts.parsePesTime(B),X)X.type="video",v.video.push(X),ge=!0}if(!v.firstKeyFrame){if(G){if(Ge.size!==0){W=new Uint8Array(Ge.size),oe=0;while(Ge.data.length)Oe=Ge.data.shift(),W.set(Oe,oe),oe+=Oe.byteLength;if(Ut.ts.videoPacketContainsKeyFrame(W)){var et=Ut.ts.parsePesTime(W);if(et)v.firstKeyFrame=et,v.firstKeyFrame.type="video";else console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}Ge.size=0}}Ge.data.push(B),Ge.size+=B.byteLength}}break}if(ge&&v.firstKeyFrame)break;k+=_n,_+=_n;continue}k++,_++}_=p.byteLength,k=_-_n,ge=!1;while(k>=0){if(p[k]===Ds&&p[_]===Ds){switch(B=p.subarray(k,_),E=Ut.ts.parseType(B,q.pid),E){case"pes":if(U=Ut.ts.parsePesType(B,q.table),G=Ut.ts.parsePayloadUnitStartIndicator(B),U==="video"&&G){if(X=Ut.ts.parsePesTime(B),X)X.type="video",v.video.push(X),ge=!0}break}if(ge)break;k-=_n,_-=_n;continue}k--,_--}},wu=function(p,q){if(p.audio&&p.audio.length){var v=q;if(typeof v>"u"||isNaN(v))v=p.audio[0].dts;p.audio.forEach(function(B){B.dts=Ki(B.dts,v),B.pts=Ki(B.pts,v),B.dtsTime=B.dts/N0,B.ptsTime=B.pts/N0})}if(p.video&&p.video.length){var k=q;if(typeof k>"u"||isNaN(k))k=p.video[0].dts;if(p.video.forEach(function(B){B.dts=Ki(B.dts,k),B.pts=Ki(B.pts,k),B.dtsTime=B.dts/N0,B.ptsTime=B.pts/N0}),p.firstKeyFrame){var _=p.firstKeyFrame;_.dts=Ki(_.dts,k),_.pts=Ki(_.pts,k),_.dtsTime=_.dts/N0,_.ptsTime=_.pts/N0}}},du=function(p){var q=!1,v=0,k=null,_=null,B=0,E=0,U;while(p.length-E>=3){var G=Ut.aac.parseType(p,E);switch(G){case"timed-metadata":if(p.length-E<10){q=!0;break}if(B=Ut.aac.parseId3TagSize(p,E),B>p.length){q=!0;break}if(_===null)U=p.subarray(E,E+B),_=Ut.aac.parseAacTimestamp(U);E+=B;break;case"audio":if(p.length-E<7){q=!0;break}if(B=Ut.aac.parseAdtsSize(p,E),B>p.length){q=!0;break}if(k===null)U=p.subarray(E,E+B),k=Ut.aac.parseSampleRate(U);v++,E+=B;break;default:E++;break}if(q)return null}if(k===null||_===null)return null;var X=N0/k,W={audio:[{type:"audio",dts:_,pts:_},{type:"audio",dts:_+v*1024*X,pts:_+v*1024*X}]};return W},ju=function(p){var q={pid:null,table:null},v={};bu(p,q);for(var k in q.table)if(q.table.hasOwnProperty(k)){var _=q.table[k];switch(_){case er.H264_STREAM_TYPE:if(v.video=[],h1(p,q,v),v.video.length===0)delete v.video;break;case er.ADTS_STREAM_TYPE:if(v.audio=[],E0(p,q,v),v.audio.length===0)delete v.audio;break}}return v},qu=function(p,q){var v=Ut.aac.isLikelyAacData(p),k;if(v)k=du(p);else k=ju(p);if(!k||!k.audio&&!k.video)return null;return wu(k,q),k},vu={inspect:qu,parseAudioPes_:E0};let ku=function(p,q){q.on("data",function(v){let k=v.initSegment;v.initSegment={data:k.buffer,byteOffset:k.byteOffset,byteLength:k.byteLength};let _=v.data;v.data=_.buffer,p.postMessage({action:"data",segment:v,byteOffset:_.byteOffset,byteLength:_.byteLength},[v.data])}),q.on("done",function(v){p.postMessage({action:"done"})}),q.on("gopInfo",function(v){p.postMessage({action:"gopInfo",gopInfo:v})}),q.on("videoSegmentTimingInfo",function(v){let k={start:{decode:Bt.videoTsToSeconds(v.start.dts),presentation:Bt.videoTsToSeconds(v.start.pts)},end:{decode:Bt.videoTsToSeconds(v.end.dts),presentation:Bt.videoTsToSeconds(v.end.pts)},baseMediaDecodeTime:Bt.videoTsToSeconds(v.baseMediaDecodeTime)};if(v.prependedContentDuration)k.prependedContentDuration=Bt.videoTsToSeconds(v.prependedContentDuration);p.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:k})}),q.on("audioSegmentTimingInfo",function(v){let k={start:{decode:Bt.videoTsToSeconds(v.start.dts),presentation:Bt.videoTsToSeconds(v.start.pts)},end:{decode:Bt.videoTsToSeconds(v.end.dts),presentation:Bt.videoTsToSeconds(v.end.pts)},baseMediaDecodeTime:Bt.videoTsToSeconds(v.baseMediaDecodeTime)};if(v.prependedContentDuration)k.prependedContentDuration=Bt.videoTsToSeconds(v.prependedContentDuration);p.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:k})}),q.on("id3Frame",function(v){p.postMessage({action:"id3Frame",id3Frame:v})}),q.on("caption",function(v){p.postMessage({action:"caption",caption:v})}),q.on("trackinfo",function(v){p.postMessage({action:"trackinfo",trackInfo:v})}),q.on("audioTimingInfo",function(v){p.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:Bt.videoTsToSeconds(v.start),end:Bt.videoTsToSeconds(v.end)}})}),q.on("videoTimingInfo",function(v){p.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:Bt.videoTsToSeconds(v.start),end:Bt.videoTsToSeconds(v.end)}})}),q.on("log",function(v){p.postMessage({action:"log",log:v})})};class z0{constructor(p,q){this.options=q||{},this.self=p,this.init()}init(){if(this.transmuxer)this.transmuxer.dispose();this.transmuxer=new K2.Transmuxer(this.options),ku(this.self,this.transmuxer)}pushMp4Captions(p){if(!this.captionParser)this.captionParser=new cu,this.captionParser.init();let q=new Uint8Array(p.data,p.byteOffset,p.byteLength),v=this.captionParser.parse(q,p.trackIds,p.timescales);this.self.postMessage({action:"mp4Captions",captions:v&&v.captions||[],logs:v&&v.logs||[],data:q.buffer},[q.buffer])}initMp4WebVttParser(p){if(!this.webVttParser)this.webVttParser=new Fc;let q=new Uint8Array(p.data,p.byteOffset,p.byteLength);this.webVttParser.init(q)}getMp4WebVttText(p){if(!this.webVttParser)this.webVttParser=new Fc;let q=new Uint8Array(p.data,p.byteOffset,p.byteLength),v=this.webVttParser.parseSegment(q);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:v||[],data:q.buffer},[q.buffer])}probeMp4StartTime({timescales:p,data:q}){let v=xa.startTime(p,q);this.self.postMessage({action:"probeMp4StartTime",startTime:v,data:q},[q.buffer])}probeMp4Tracks({data:p}){let q=xa.tracks(p);this.self.postMessage({action:"probeMp4Tracks",tracks:q,data:p},[p.buffer])}probeEmsgID3({data:p,offset:q}){let v=xa.getEmsgID3(p,q);this.self.postMessage({action:"probeEmsgID3",id3Frames:v,emsgData:p},[p.buffer])}probeTs({data:p,baseStartTime:q}){let v=typeof q==="number"&&!isNaN(q)?q*Bt.ONE_SECOND_IN_TS:void 0,k=vu.inspect(p,v),_=null;if(k){if(_={hasVideo:k.video&&k.video.length===2||!1,hasAudio:k.audio&&k.audio.length===2||!1},_.hasVideo)_.videoStart=k.video[0].ptsTime;if(_.hasAudio)_.audioStart=k.audio[0].ptsTime}this.self.postMessage({action:"probeTs",result:_,data:p},[p.buffer])}clearAllMp4Captions(){if(this.captionParser)this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){if(this.captionParser)this.captionParser.clearParsedCaptions()}push(p){let q=new Uint8Array(p.data,p.byteOffset,p.byteLength);this.transmuxer.push(q)}reset(){this.transmuxer.reset()}setTimestampOffset(p){let q=p.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(Bt.secondsToVideoTs(q)))}setAudioAppendStart(p){this.transmuxer.setAudioAppendStart(Math.ceil(Bt.secondsToVideoTs(p.appendStart)))}setRemux(p){this.transmuxer.setRemux(p.remux)}flush(p){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(p){this.transmuxer.alignGopsWith(p.gopsToAlignWith.slice())}}self.onmessage=function(p){if(p.data.action==="init"&&p.data.options){this.messageHandlers=new z0(self,p.data.options);return}if(!this.messageHandlers)this.messageHandlers=new z0(self);if(p.data&&p.data.action&&p.data.action!=="init"){if(this.messageHandlers[p.data.action])this.messageHandlers[p.data.action](p.data)}}})),oM=Mq(rM),cM=(e,t,a)=>{let{type:n,initSegment:s,captions:i,captionStreams:f,metadata:l,videoFrameDtsTime:c,videoFramePtsTime:h}=e.data.segment;t.buffer.push({captions:i,captionStreams:f,metadata:l});let u=e.data.segment.boxes||{data:e.data.segment.data},g={type:n,data:new Uint8Array(u.data,u.data.byteOffset,u.data.byteLength),initSegment:new Uint8Array(s.data,s.byteOffset,s.byteLength)};if(typeof c<"u")g.videoFrameDtsTime=c;if(typeof h<"u")g.videoFramePtsTime=h;a(g)},hM=({transmuxedData:e,callback:t})=>{e.buffer=[],t(e)},uM=(e,t)=>{t.gopInfo=e.data.gopInfo},Rq=(e)=>{let{transmuxer:t,bytes:a,audioAppendStart:n,gopsToAlignWith:s,remux:i,onData:f,onTrackInfo:l,onAudioTimingInfo:c,onVideoTimingInfo:h,onVideoSegmentTimingInfo:u,onAudioSegmentTimingInfo:g,onId3:b,onCaptions:d,onDone:j,onEndedTimeline:A,onTransmuxerLog:C,isEndOfTimeline:y,segment:O,triggerSegmentEventFn:T}=e,M={buffer:[]},H=y,N=(z)=>{if(t.currentTransmux!==e)return;if(z.data.action==="data")cM(z,M,f);if(z.data.action==="trackinfo")l(z.data.trackInfo);if(z.data.action==="gopInfo")uM(z,M);if(z.data.action==="audioTimingInfo")c(z.data.audioTimingInfo);if(z.data.action==="videoTimingInfo")h(z.data.videoTimingInfo);if(z.data.action==="videoSegmentTimingInfo")u(z.data.videoSegmentTimingInfo);if(z.data.action==="audioSegmentTimingInfo")g(z.data.audioSegmentTimingInfo);if(z.data.action==="id3Frame")b([z.data.id3Frame],z.data.id3Frame.dispatchType);if(z.data.action==="caption")d(z.data.caption);if(z.data.action==="endedtimeline")H=!1,A();if(z.data.action==="log")C(z.data.log);if(z.data.type!=="transmuxed")return;if(H)return;t.onmessage=null,hM({transmuxedData:M,callback:j}),Nq(t)},x=()=>{let z={message:"Received an error message from the transmuxer worker",metadata:{errorType:se.Error.StreamingFailedToTransmuxSegment,segmentInfo:vr({segment:O})}};j(null,z)};if(t.onmessage=N,t.onerror=x,n)t.postMessage({action:"setAudioAppendStart",appendStart:n});if(Array.isArray(s))t.postMessage({action:"alignGopsWith",gopsToAlignWith:s});if(typeof i<"u")t.postMessage({action:"setRemux",remux:i});if(a.byteLength){let z=a instanceof ArrayBuffer?a:a.buffer,K=a instanceof ArrayBuffer?0:a.byteOffset;T({type:"segmenttransmuxingstart",segment:O}),t.postMessage({action:"push",data:z,byteOffset:K,byteLength:a.byteLength},[z])}if(y)t.postMessage({action:"endTimeline"});t.postMessage({action:"flush"})},Nq=(e)=>{if(e.currentTransmux=null,e.transmuxQueue.length)if(e.currentTransmux=e.transmuxQueue.shift(),typeof e.currentTransmux==="function")e.currentTransmux();else Rq(e.currentTransmux)},Nd=(e,t)=>{e.postMessage({action:t}),Nq(e)},Eq=(e,t)=>{if(!t.currentTransmux){t.currentTransmux=e,Nd(t,e);return}t.transmuxQueue.push(Nd.bind(null,t,e))},mM=(e)=>{Eq("reset",e)},gM=(e)=>{Eq("endTimeline",e)},zq=(e)=>{if(!e.transmuxer.currentTransmux){e.transmuxer.currentTransmux=e,Rq(e);return}e.transmuxer.transmuxQueue.push(e)},pM=(e)=>{let t=new oM;t.currentTransmux=null,t.transmuxQueue=[];let a=t.terminate;return t.terminate=()=>{return t.currentTransmux=null,t.transmuxQueue.length=0,a.call(t)},t.postMessage({action:"init",options:e}),t},a4={reset:mM,endTimeline:gM,transmux:zq,createTransmuxer:pM},fo=function(e){let t=e.transmuxer,a=e.endAction||e.action,n=e.callback,s=Fa({},e,{endAction:null,transmuxer:null,callback:null}),i=(f)=>{if(f.data.action!==a)return;if(t.removeEventListener("message",i),f.data.data){if(f.data.data=new Uint8Array(f.data.data,e.byteOffset||0,e.byteLength||f.data.data.byteLength),e.data)e.data=f.data.data}n(f.data)};if(t.addEventListener("message",i),e.data){let f=e.data instanceof ArrayBuffer;s.byteOffset=f?0:e.data.byteOffset,s.byteLength=e.data.byteLength;let l=[f?e.data:e.data.buffer];t.postMessage(s,l)}else t.postMessage(s)},l0={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Uq="wvtt",A4=(e)=>{e.forEach((t)=>{t.abort()})},bM=(e)=>{return{bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}},wM=(e)=>{let t=e.target,n={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return n.bytesReceived=e.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1000),n},kg=(e,t)=>{let{requestType:a}=t,n=Cr({requestType:a,request:t,error:e});if(t.timedout)return{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:l0.TIMEOUT,xhr:t,metadata:n};if(t.aborted)return{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:l0.ABORTED,xhr:t,metadata:n};if(e)return{status:t.status,message:"HLS request errored at URL: "+t.uri,code:l0.FAILURE,xhr:t,metadata:n};if(t.responseType==="arraybuffer"&&t.response.byteLength===0)return{status:t.status,message:"Empty HLS response at URL: "+t.uri,code:l0.FAILURE,xhr:t,metadata:n};return null},Ed=(e,t,a,n)=>(s,i)=>{let f=i.response,l=kg(s,i);if(l)return a(l,e);if(f.byteLength!==16)return a({status:i.status,message:"Invalid HLS key at URL: "+i.uri,code:l0.FAILURE,xhr:i},e);let c=new DataView(f),h=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let g=0;g<t.length;g++)t[g].bytes=h;let u={uri:i.uri};return n({type:"segmentkeyloadcomplete",segment:e,keyInfo:u}),a(null,e)},dM=(e,t)=>{if(t===Uq)e.transmuxer.postMessage({action:"initMp4WebVttParser",data:e.map.bytes})},jM=(e,t,a)=>{if(t===Uq)fo({action:"getMp4WebVttText",data:e.bytes,transmuxer:e.transmuxer,callback:({data:n,mp4VttCues:s})=>{e.bytes=n,a(null,e,{mp4VttCues:s})}})},Iq=(e,t)=>{let a=j9(e.map.bytes);if(a!=="mp4"){let n=e.map.resolvedUri||e.map.uri,s=a||"unknown";return t({internal:!0,message:`Found unsupported ${s} container for initialization segment at URL: ${n}`,code:l0.FAILURE,metadata:{mediaType:s}})}fo({action:"probeMp4Tracks",data:e.map.bytes,transmuxer:e.transmuxer,callback:({tracks:n,data:s})=>{return e.map.bytes=s,n.forEach(function(i){if(e.map.tracks=e.map.tracks||{},e.map.tracks[i.type])return;if(e.map.tracks[i.type]=i,typeof i.id==="number"&&i.timescale)e.map.timescales=e.map.timescales||{},e.map.timescales[i.id]=i.timescale;if(i.type==="text")dM(e,i.codec)}),t(null)}})},qM=({segment:e,finishProcessingFn:t,triggerSegmentEventFn:a})=>(n,s)=>{let i=kg(n,s);if(i)return t(i,e);let f=new Uint8Array(s.response);if(a({type:"segmentloaded",segment:e}),e.map.key)return e.map.encryptedBytes=f,t(null,e);e.map.bytes=f,Iq(e,function(l){if(l)return l.xhr=s,l.status=s.status,t(l,e);t(null,e)})},vM=({segment:e,finishProcessingFn:t,responseType:a,triggerSegmentEventFn:n})=>(s,i)=>{let f=kg(s,i);if(f)return t(f,e);n({type:"segmentloaded",segment:e});let l=a==="arraybuffer"||!i.responseText?i.response:fM(i.responseText.substring(e.lastReachedChar||0));if(e.stats=bM(i),e.key)e.encryptedBytes=new Uint8Array(l);else e.bytes=new Uint8Array(l);return t(null,e)},kM=({segment:e,bytes:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{let j=e.map&&e.map.tracks||{},A=Boolean(j.audio&&j.video),C=n.bind(null,e,"audio","start"),y=n.bind(null,e,"audio","end"),O=n.bind(null,e,"video","start"),T=n.bind(null,e,"video","end"),M=()=>zq({bytes:t,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,remux:A,onData:(H)=>{H.type=H.type==="combined"?"video":H.type,u(e,H)},onTrackInfo:(H)=>{if(a){if(A)H.isMuxed=!0;a(e,H)}},onAudioTimingInfo:(H)=>{if(C&&typeof H.start<"u")C(H.start),C=null;if(y&&typeof H.end<"u")y(H.end)},onVideoTimingInfo:(H)=>{if(O&&typeof H.start<"u")O(H.start),O=null;if(T&&typeof H.end<"u")T(H.end)},onVideoSegmentTimingInfo:(H)=>{let N={pts:{start:H.start.presentation,end:H.end.presentation},dts:{start:H.start.decode,end:H.end.decode}};d({type:"segmenttransmuxingtiminginfoavailable",segment:e,timingInfo:N}),s(H)},onAudioSegmentTimingInfo:(H)=>{let N={pts:{start:H.start.pts,end:H.end.pts},dts:{start:H.start.dts,end:H.end.dts}};d({type:"segmenttransmuxingtiminginfoavailable",segment:e,timingInfo:N}),i(H)},onId3:(H,N)=>{f(e,H,N)},onCaptions:(H)=>{l(e,[H])},isEndOfTimeline:c,onEndedTimeline:()=>{h()},onTransmuxerLog:b,onDone:(H,N)=>{if(!g)return;H.type=H.type==="combined"?"video":H.type,d({type:"segmenttransmuxingcomplete",segment:e}),g(N,e,H)},segment:e,triggerSegmentEventFn:d});fo({action:"probeTs",transmuxer:e.transmuxer,data:t,baseStartTime:e.baseStartTime,callback:(H)=>{e.bytes=t=H.data;let N=H.result;if(N)a(e,{hasAudio:N.hasAudio,hasVideo:N.hasVideo,isMuxed:A}),a=null;M()}})},Gq=({segment:e,bytes:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{let j=new Uint8Array(t);if(td(j)){e.isFmp4=!0;let{tracks:A}=e.map;if(A.text&&(!A.audio||!A.video)){u(e,{data:j,type:"text"}),jM(e,A.text.codec,g);return}let y={isFmp4:!0,hasVideo:!!A.video,hasAudio:!!A.audio};if(A.audio&&A.audio.codec&&A.audio.codec!=="enca")y.audioCodec=A.audio.codec;if(A.video&&A.video.codec&&A.video.codec!=="encv")y.videoCodec=A.video.codec;if(A.video&&A.audio)y.isMuxed=!0;a(e,y);let O=(T,M)=>{if(u(e,{data:j,type:y.hasAudio&&!y.isMuxed?"audio":"video"}),M&&M.length)f(e,M);if(T&&T.length)l(e,T);g(null,e,{})};fo({action:"probeMp4StartTime",timescales:e.map.timescales,data:j,transmuxer:e.transmuxer,callback:({data:T,startTime:M})=>{if(t=T.buffer,e.bytes=j=T,y.hasAudio&&!y.isMuxed)n(e,"audio","start",M);if(y.hasVideo)n(e,"video","start",M);fo({action:"probeEmsgID3",data:j,transmuxer:e.transmuxer,offset:M,callback:({emsgData:H,id3Frames:N})=>{if(t=H.buffer,e.bytes=j=H,!A.video||!H.byteLength||!e.transmuxer){O(void 0,N);return}fo({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:e.transmuxer,data:j,timescales:e.map.timescales,trackIds:[A.video.id],callback:(x)=>{t=x.data.buffer,e.bytes=j=x.data,x.logs.forEach(function(z){b(Vt(z,{stream:"mp4CaptionParser"}))}),O(x.captions,N)}})}})}});return}if(!e.transmuxer){g(null,e,{});return}if(typeof e.container>"u")e.container=j9(j);if(e.container!=="ts"&&e.container!=="aac"){a(e,{hasAudio:!1,hasVideo:!1}),g(null,e,{});return}kM({segment:e,bytes:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})},Xq=function({id:e,key:t,encryptedBytes:a,decryptionWorker:n,segment:s,doneFn:i},f){let l=(h)=>{if(h.data.source===e){n.removeEventListener("message",l);let u=h.data.decrypted;f(new Uint8Array(u.bytes,u.byteOffset,u.byteLength))}};n.onerror=()=>{let u=vr({segment:s}),g={message:"An error occurred in the decryption worker",metadata:{error:Error("An error occurred in the decryption worker"),errorType:se.Error.StreamingFailedToDecryptSegment,segmentInfo:u,keyInfo:{uri:s.key.resolvedUri||s.map.key.resolvedUri}}};i(g,s)},n.addEventListener("message",l);let c;if(t.bytes.slice)c=t.bytes.slice();else c=new Uint32Array(Array.prototype.slice.call(t.bytes));n.postMessage(_q({source:e,encrypted:a,key:c,iv:t.iv}),[a.buffer,c.buffer])},AM=({decryptionWorker:e,segment:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{d({type:"segmentdecryptionstart"}),Xq({id:t.requestId,key:t.key,encryptedBytes:t.encryptedBytes,decryptionWorker:e,segment:t,doneFn:g},(j)=>{t.bytes=j,d({type:"segmentdecryptioncomplete",segment:t}),Gq({segment:t,bytes:t.bytes,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})})},yM=({activeXhrs:e,decryptionWorker:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{let j=0,A=!1;return(C,y)=>{if(A)return;if(C)return A=!0,A4(e),g(C,y);if(j+=1,j===e.length){let O=function(){if(y.encryptedBytes)return AM({decryptionWorker:t,segment:y,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d});Gq({segment:y,bytes:y.bytes,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})};if(y.endOfAllRequests=Date.now(),y.map&&y.map.encryptedBytes&&!y.map.bytes)return d({type:"segmentdecryptionstart",segment:y}),Xq({decryptionWorker:t,id:y.requestId+"-init",encryptedBytes:y.map.encryptedBytes,key:y.map.key,segment:y,doneFn:g},(T)=>{y.map.bytes=T,d({type:"segmentdecryptioncomplete",segment:y}),Iq(y,(M)=>{if(M)return A4(e),g(M,y);O()})});O()}}},SM=({loadendState:e,abortFn:t})=>(a)=>{if(a.target.aborted&&t&&!e.calledAbortFn)t(),e.calledAbortFn=!0},CM=({segment:e,progressFn:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:f,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u})=>(g)=>{if(g.target.aborted)return;if(e.stats=Vt(e.stats,wM(g)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived)e.stats.firstBytesReceivedAt=Date.now();return t(g,e)},_M=({xhr:e,xhrOptions:t,decryptionWorker:a,segment:n,abortFn:s,progressFn:i,trackInfoFn:f,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:h,id3Fn:u,captionsFn:g,isEndOfTimeline:b,endedTimelineFn:d,dataFn:j,doneFn:A,onTransmuxerLog:C,triggerSegmentEventFn:y})=>{let O=[],T=yM({activeXhrs:O,decryptionWorker:a,trackInfoFn:f,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:h,id3Fn:u,captionsFn:g,isEndOfTimeline:b,endedTimelineFn:d,dataFn:j,doneFn:A,onTransmuxerLog:C,triggerSegmentEventFn:y});if(n.key&&!n.key.bytes){let z=[n.key];if(n.map&&!n.map.bytes&&n.map.key&&n.map.key.resolvedUri===n.key.resolvedUri)z.push(n.map.key);let K=Vt(t,{uri:n.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),$=Ed(n,z,T,y),Q={uri:n.key.resolvedUri};y({type:"segmentkeyloadstart",segment:n,keyInfo:Q});let P=e(K,$);O.push(P)}if(n.map&&!n.map.bytes){if(n.map.key&&(!n.key||n.key.resolvedUri!==n.map.key.resolvedUri)){let P=Vt(t,{uri:n.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),te=Ed(n,[n.map.key],T,y),ee={uri:n.map.key.resolvedUri};y({type:"segmentkeyloadstart",segment:n,keyInfo:ee});let L=e(P,te);O.push(L)}let K=Vt(t,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:k4(n.map),requestType:"segment-media-initialization"}),$=qM({segment:n,finishProcessingFn:T,triggerSegmentEventFn:y});y({type:"segmentloadstart",segment:n});let Q=e(K,$);O.push(Q)}let M=Vt(t,{uri:n.part&&n.part.resolvedUri||n.resolvedUri,responseType:"arraybuffer",headers:k4(n),requestType:"segment"}),H=vM({segment:n,finishProcessingFn:T,responseType:M.responseType,triggerSegmentEventFn:y});y({type:"segmentloadstart",segment:n});let N=e(M,H);N.addEventListener("progress",CM({segment:n,progressFn:i,trackInfoFn:f,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:h,id3Fn:u,captionsFn:g,isEndOfTimeline:b,endedTimelineFn:d,dataFn:j})),O.push(N);let x={};return O.forEach((z)=>{z.addEventListener("loadend",SM({loadendState:x,abortFn:s}))}),()=>A4(O)},A9=gi("PlaylistSelector"),zd=function(e){if(!e||!e.playlist)return;let t=e.playlist;return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||""})},lo=function(e,t){if(!e)return"";let a=V.default.getComputedStyle(e);if(!a)return"";return a[t]},ro=function(e,t){let a=e.slice();e.sort(function(n,s){let i=t(n,s);if(i===0)return a.indexOf(n)-a.indexOf(s);return i})},Ag=function(e,t){let a,n;if(e.attributes.BANDWIDTH)a=e.attributes.BANDWIDTH;if(a=a||V.default.Number.MAX_VALUE,t.attributes.BANDWIDTH)n=t.attributes.BANDWIDTH;return n=n||V.default.Number.MAX_VALUE,a-n},FM=function(e,t){let a,n;if(e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width)a=e.attributes.RESOLUTION.width;if(a=a||V.default.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width)n=t.attributes.RESOLUTION.width;if(n=n||V.default.Number.MAX_VALUE,a===n&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH)return e.attributes.BANDWIDTH-t.attributes.BANDWIDTH;return a-n},Kq=function(e){let{main:t,bandwidth:a,playerWidth:n,playerHeight:s,playerObjectFit:i,limitRenditionByPlayerDimensions:f,playlistController:l}=e;if(!t)return;let c={bandwidth:a,width:n,height:s,limitRenditionByPlayerDimensions:f},h=t.playlists;if(ks.isAudioOnly(t))h=l.getAudioTrackPlaylists_(),c.audioOnly=!0;let u=h.map((x)=>{let z,K=x.attributes&&x.attributes.RESOLUTION&&x.attributes.RESOLUTION.width,$=x.attributes&&x.attributes.RESOLUTION&&x.attributes.RESOLUTION.height;return z=x.attributes&&x.attributes.BANDWIDTH,z=z||V.default.Number.MAX_VALUE,{bandwidth:z,width:K,height:$,playlist:x}});ro(u,(x,z)=>x.bandwidth-z.bandwidth),u=u.filter((x)=>!ks.isIncompatible(x.playlist));let g=u.filter((x)=>ks.isEnabled(x.playlist));if(!g.length)g=u.filter((x)=>!ks.isDisabled(x.playlist));let b=g.filter((x)=>x.bandwidth*jn.BANDWIDTH_VARIANCE<a),d=b[b.length-1],j=b.filter((x)=>x.bandwidth===d.bandwidth)[0];if(f===!1){let x=j||g[0]||u[0];if(x&&x.playlist){let z="sortedPlaylistReps";if(j)z="bandwidthBestRep";if(g[0])z="enabledPlaylistReps";return A9(`choosing ${zd(x)} using ${z} with options`,c),x.playlist}return A9("could not choose a playlist with options",c),null}let A=b.filter((x)=>x.width&&x.height);ro(A,(x,z)=>x.width-z.width);let C=A.filter((x)=>x.width===n&&x.height===s);d=C[C.length-1];let y=C.filter((x)=>x.bandwidth===d.bandwidth)[0],O,T,M;if(!y)O=A.filter((x)=>{if(i==="cover")return x.width>n&&x.height>s;return x.width>n||x.height>s}),T=O.filter((x)=>x.width===O[0].width&&x.height===O[0].height),d=T[T.length-1],M=T.filter((x)=>x.bandwidth===d.bandwidth)[0];let H;if(l.leastPixelDiffSelector){let x=A.map((z)=>{return z.pixelDiff=Math.abs(z.width-n)+Math.abs(z.height-s),z});ro(x,(z,K)=>{if(z.pixelDiff===K.pixelDiff)return K.bandwidth-z.bandwidth;return z.pixelDiff-K.pixelDiff}),H=x[0]}let N=H||M||y||j||g[0]||u[0];if(N&&N.playlist){let x="sortedPlaylistReps";if(H)x="leastPixelDiffRep";else if(M)x="resolutionPlusOneRep";else if(y)x="resolutionBestRep";else if(j)x="bandwidthBestRep";else if(g[0])x="enabledPlaylistReps";return A9(`choosing ${zd(N)} using ${x} with options`,c),N.playlist}return A9("could not choose a playlist with options",c),null},Ud=function(){let e=this.useDevicePixelRatio?V.default.devicePixelRatio||1:1;if(!isNaN(this.customPixelRatio))e=this.customPixelRatio;return Kq({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(lo(this.tech_.el(),"width"),10)*e,playerHeight:parseInt(lo(this.tech_.el(),"height"),10)*e,playerObjectFit:this.usePlayerObjectFit?lo(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},OM=function(e){let t=-1,a=-1;if(e<0||e>1)throw Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let n=this.useDevicePixelRatio?V.default.devicePixelRatio||1:1;if(!isNaN(this.customPixelRatio))n=this.customPixelRatio;if(t<0)t=this.systemBandwidth,a=this.systemBandwidth;if(this.systemBandwidth>0&&this.systemBandwidth!==a)t=e*this.systemBandwidth+(1-e)*t,a=this.systemBandwidth;return Kq({main:this.playlists.main,bandwidth:t,playerWidth:parseInt(lo(this.tech_.el(),"width"),10)*n,playerHeight:parseInt(lo(this.tech_.el(),"height"),10)*n,playerObjectFit:this.usePlayerObjectFit?lo(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},BM=function(e){let{main:t,currentTime:a,bandwidth:n,duration:s,segmentDuration:i,timeUntilRebuffer:f,currentTimeline:l,syncController:c}=e,h=t.playlists.filter((j)=>!ks.isIncompatible(j)),u=h.filter(ks.isEnabled);if(!u.length)u=h.filter((j)=>!ks.isDisabled(j));let b=u.filter(ks.hasAttribute.bind(null,"BANDWIDTH")).map((j)=>{let C=c.getSyncPoint(j,s,l,a)?1:2,O=ks.estimateSegmentRequestTime(i,n,j)*C-f;return{playlist:j,rebufferingImpact:O}}),d=b.filter((j)=>j.rebufferingImpact<=0);if(ro(d,(j,A)=>Ag(A.playlist,j.playlist)),d.length)return d[0];return ro(b,(j,A)=>j.rebufferingImpact-A.rebufferingImpact),b[0]||null},TM=function(){let e=this.playlists.main.playlists.filter(ks.isEnabled);return ro(e,(a,n)=>Ag(a,n)),e.filter((a)=>!!_h(this.playlists.main,a).video)[0]||null},HM=(e)=>{let t=0,a;if(e.bytes)a=new Uint8Array(e.bytes),e.segments.forEach((n)=>{a.set(n,t),t+=n.byteLength});return a};function Lq(e){try{return new URL(e).pathname.split("/").slice(-2).join("/")}catch(t){return""}}var MM=function(e,t,a){if(!e[a]){t.trigger({type:"usage",name:"vhs-608"});let n=a;if(/^cc708_/.test(a))n="SERVICE"+a.split("_")[1];let s=t.textTracks().getTrackById(n);if(s)e[a]=s;else{let i=t.options_.vhs&&t.options_.vhs.captionServices||{},f=a,l=a,c=!1,h=i[n];if(h)f=h.label,l=h.language,c=h.default;e[a]=t.addRemoteTextTrack({kind:"captions",id:n,default:c,label:f,language:l},!1).track}}},DM=function({inbandTextTracks:e,captionArray:t,timestampOffset:a}){if(!t)return;let n=V.default.WebKitDataCue||V.default.VTTCue;t.forEach((s)=>{let i=s.stream;if(s.content)s.content.forEach((f)=>{let l=new n(s.startTime+a,s.endTime+a,f.text);l.line=f.line,l.align="left",l.position=f.position,l.positionAlign="line-left",e[i].addCue(l)});else e[i].addCue(new n(s.startTime+a,s.endTime+a,s.text))})},xM=function(e){Object.defineProperties(e.frame,{id:{get(){return se.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get(){return se.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get(){return se.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}})},RM=({inbandTextTracks:e,metadataArray:t,timestampOffset:a,videoDuration:n})=>{if(!t)return;let s=V.default.WebKitDataCue||V.default.VTTCue,i=e.metadataTrack_;if(!i)return;if(t.forEach((u)=>{let g=u.cueTime+a;if(typeof g!=="number"||V.default.isNaN(g)||g<0||!(g<1/0))return;if(!u.frames||!u.frames.length)return;u.frames.forEach((b)=>{let d=new s(g,g,b.value||b.url||b.data||"");d.frame=b,d.value=b,xM(d),i.addCue(d)})}),!i.cues||!i.cues.length)return;let f=i.cues,l=[];for(let u=0;u<f.length;u++)if(f[u])l.push(f[u]);let c=l.reduce((u,g)=>{let b=u[g.startTime]||[];return b.push(g),u[g.startTime]=b,u},{}),h=Object.keys(c).sort((u,g)=>Number(u)-Number(g));h.forEach((u,g)=>{let b=c[u],d=isFinite(n)?n:u,j=Number(h[g+1])||d;b.forEach((A)=>{A.endTime=j})})},NM={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},EM=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),zM=({inbandTextTracks:e,dateRanges:t})=>{let a=e.metadataTrack_;if(!a)return;let n=V.default.WebKitDataCue||V.default.VTTCue;t.forEach((s)=>{for(let i of Object.keys(s)){if(EM.has(i))continue;let f=new n(s.startTime,s.endTime,"");if(f.id=s.id,f.type="com.apple.quicktime.HLS",f.value={key:NM[i],data:s[i]},i==="scte35Out"||i==="scte35In")f.value.data=new Uint8Array(f.value.data.match(/[\da-f]{2}/gi)).buffer;a.addCue(f)}s.processDateRange()})},Id=(e,t,a)=>{if(e.metadataTrack_)return;if(e.metadataTrack_=a.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,!se.browser.IS_ANY_SAFARI)e.metadataTrack_.inBandMetadataTrackDispatchType=t},kh=function(e,t,a){let n,s;if(!a)return;if(!a.cues)return;n=a.cues.length;while(n--)if(s=a.cues[n],s.startTime>=e&&s.endTime<=t)a.removeCue(s)},UM=function(e){let t=e.cues;if(!t)return;let a={};for(let n=t.length-1;n>=0;n--){let s=t[n],i=`${s.startTime}-${s.endTime}-${s.text}`;if(a[i])e.removeCue(s);else a[i]=s}},IM=(e,t,a)=>{if(typeof t>"u"||t===null||!e.length)return[];let n=Math.ceil((t-a+3)*fl.ONE_SECOND_IN_TS),s;for(s=0;s<e.length;s++)if(e[s].pts>n)break;return e.slice(s)},GM=(e,t,a)=>{if(!t.length)return e;if(a)return t.slice();let n=t[0].pts,s=0;for(s;s<e.length;s++)if(e[s].pts>=n)break;return e.slice(0,s).concat(t)},XM=(e,t,a,n)=>{let s=Math.ceil((t-n)*fl.ONE_SECOND_IN_TS),i=Math.ceil((a-n)*fl.ONE_SECOND_IN_TS),f=e.slice(),l=e.length;while(l--)if(e[l].pts<=i)break;if(l===-1)return f;let c=l+1;while(c--)if(e[c].pts<=s)break;return c=Math.max(c,0),f.splice(c,l-c+1),f},KM=function(e,t){if(!e&&!t||!e&&t||e&&!t)return!1;if(e===t)return!0;let a=Object.keys(e).sort(),n=Object.keys(t).sort();if(a.length!==n.length)return!1;for(let s=0;s<a.length;s++){let i=a[s];if(i!==n[s])return!1;if(e[i]!==t[i])return!1}return!0},LM=function(e,t,a){t=t||[];let n=[],s=0;for(let i=0;i<t.length;i++){let f=t[i];if(e===f.timeline){if(n.push(i),s+=f.duration,s>a)return i}}if(n.length===0)return 0;return n[n.length-1]},qh=1,VM=500,Gd=(e)=>typeof e==="number"&&isFinite(e),y9=0.016666666666666666,YM=(e,t,a)=>{if(e!=="main"||!t||!a)return null;if(!a.hasAudio&&!a.hasVideo)return"Neither audio nor video found in segment.";if(t.hasVideo&&!a.hasVideo)return"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.";if(!t.hasVideo&&a.hasVideo)return"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.";return null},JM=(e,t,a)=>{let n=t-jn.BACK_BUFFER_LENGTH;if(e.length)n=Math.max(n,e.start(0));let s=t-a;return Math.min(s,n)},W1=(e)=>{let{startOfSegment:t,duration:a,segment:n,part:s,playlist:{mediaSequence:i,id:f,segments:l=[]},mediaIndex:c,partIndex:h,timeline:u}=e,g=l.length-1,b="mediaIndex/partIndex increment";if(e.getMediaInfoForTime)b=`getMediaInfoForTime (${e.getMediaInfoForTime})`;else if(e.isSyncRequest)b="getSyncSegmentCandidate (isSyncRequest)";if(e.independent)b+=` with independent ${e.independent}`;let d=typeof h==="number",j=e.segment.uri?"segment":"pre-segment",A=d?oq({preloadSegment:n})-1:0;return`${j} [${i+c}/${i+g}]`+(d?` part [${h}/${A}]`:"")+` segment start/end [${n.start} => ${n.end}]`+(d?` part start/end [${s.start} => ${s.end}]`:"")+` startOfSegment [${t}] duration [${a}] timeline [${u}] selected by [${b}] playlist [${f}]`},Xd=(e)=>`${e}TimingInfo`,QM=({segmentTimeline:e,currentTimeline:t,startOfSegment:a,buffered:n,overrideCheck:s})=>{if(!s&&e===t)return null;if(e<t)return a;return n.length?n.end(n.length-1):a},y4=({timelineChangeController:e,currentTimeline:t,segmentTimeline:a,loaderType:n,audioDisabled:s})=>{if(t===a)return!1;if(n==="audio"){let i=e.lastTimelineChange({type:"main"});return!i||i.to!==a}if(n==="main"&&s){let i=e.pendingTimelineChange({type:"audio"});if(i&&i.to===a)return!1;return!0}return!1},ZM=(e)=>{if(!e)return!1;let t=e.pendingTimelineChange({type:"audio"}),a=e.pendingTimelineChange({type:"main"}),n=t&&a,s=n&&t.to!==a.to;if(n&&t.from!==-1&&a.from!==-1&&s)return!0;return!1},$M=(e)=>{let t=e.timelineChangeController_.pendingTimelineChange({type:"audio"}),a=e.timelineChangeController_.pendingTimelineChange({type:"main"});return t&&a&&t.to<a.to},nl=(e)=>{let t=e.pendingSegment_;if(!t)return;if(y4({timelineChangeController:e.timelineChangeController_,currentTimeline:e.currentTimeline_,segmentTimeline:t.timeline,loaderType:e.loaderType_,audioDisabled:e.audioDisabled_})&&ZM(e.timelineChangeController_)){if($M(e)){e.timelineChangeController_.trigger("audioTimelineBehind");return}e.timelineChangeController_.trigger("fixBadTimelineChange")}},WM=(e)=>{let t=0;if(["video","audio"].forEach(function(a){let n=e[`${a}TimingInfo`];if(!n)return;let{start:s,end:i}=n,f;if(typeof s==="bigint"||typeof i==="bigint")f=V.default.BigInt(i)-V.default.BigInt(s);else if(typeof s==="number"&&typeof i==="number")f=i-s;if(typeof f<"u"&&f>t)t=f}),typeof t==="bigint"&&t<Number.MAX_SAFE_INTEGER)t=Number(t);return t},Kd=({segmentDuration:e,maxDuration:t})=>{if(!e)return!1;return Math.round(e)>t+i0},PM=(e,t)=>{if(t!=="hls")return null;let a=WM({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo});if(!a)return null;let n=e.playlist.targetDuration,s=Kd({segmentDuration:a,maxDuration:n*2}),i=Kd({segmentDuration:a,maxDuration:n}),f=`Segment with index ${e.mediaIndex} from playlist ${e.playlist.id} has a duration of ${a} when the reported duration is ${e.duration} and the target duration is ${n}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;if(s||i)return{severity:s?"warn":"info",message:f};return null},vr=({type:e,segment:t})=>{if(!t)return;let a=Boolean(t.key||t.map&&t.map.ke),n=Boolean(t.map&&!t.map.bytes),s=t.startOfSegment===void 0?t.start:t.startOfSegment;return{type:e||t.type,uri:t.resolvedUri||t.uri,start:s,duration:t.duration,isEncrypted:a,isMediaInitialization:n}};class V9 extends se.EventTarget{constructor(e,t={}){super();if(!e)throw TypeError("Initialization settings are required");if(typeof e.currentTime!=="function")throw TypeError("No currentTime getter specified");if(!e.mediaSource)throw TypeError("No MediaSource specified");if(this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{if(!this.isEndOfStream_())this.ended_=!1}),this.fetchAtBuffer_=!1,this.logger_=gi(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(a){if(a!==this.state_)this.logger_(`${this.state_} -> ${a}`),this.state_=a,this.trigger("statechange")}}),this.sourceUpdater_.on("ready",()=>{if(this.hasEnoughInfoToAppend_())this.processCallQueue_();else nl(this)}),this.sourceUpdater_.on("codecschange",(a)=>{this.trigger(Fa({type:"codecschange"},a))}),this.loaderType_==="main")this.timelineChangeController_.on("pendingtimelinechange",()=>{if(this.hasEnoughInfoToAppend_())this.processCallQueue_();else nl(this)});if(this.loaderType_==="audio")this.timelineChangeController_.on("timelinechange",(a)=>{if(this.trigger(Fa({type:"timelinechange"},a)),this.hasEnoughInfoToLoad_())this.processLoadQueue_();else nl(this);if(this.hasEnoughInfoToAppend_())this.processCallQueue_();else nl(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return a4.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){if(this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_)this.transmuxer_.terminate();if(this.resetStats_(),this.checkBufferTimeout_)V.default.clearTimeout(this.checkBufferTimeout_);if(this.syncController_&&this.triggerSyncInfoUpdate_)this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_);this.off()}setAudio(e){if(this.audioDisabled_=!e,e)this.appendInitSegment_.audio=!0;else this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){if(this.pendingSegment_)this.pendingSegment_=null;this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}if(this.abort_(),this.state="READY",!this.paused())this.monitorBuffer_()}abort_(){if(this.pendingSegment_&&this.pendingSegment_.abortRequests)this.pendingSegment_.abortRequests();this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,V.default.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){if(this.state==="APPENDING"&&!this.pendingSegment_)return this.state="READY",!0;if(!this.pendingSegment_||this.pendingSegment_.requestId!==e)return!0;return!1}error(e){if(typeof e<"u")this.logger_("error occurred:",e),this.error_=e;return this.pendingSegment_=null,this.error_}endOfStream(){if(this.ended_=!0,this.transmuxer_)a4.reset(this.transmuxer_);this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){let e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return qn();if(this.loaderType_==="main"){let{hasAudio:t,hasVideo:a,isMuxed:n}=e;if(a&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered();if(a)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;let a=K9(e),n=this.initSegments_[a];if(t&&!n&&e.bytes)this.initSegments_[a]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales};return n||e}segmentKey(e,t=!1){if(!e)return null;let a=Fq(e),n=this.keyCache_[a];if(this.cacheEncryptionKeys_&&t&&!n&&e.bytes)this.keyCache_[a]=n={resolvedUri:e.resolvedUri,bytes:e.bytes};let s={resolvedUri:(n||e).resolvedUri};if(n)s.bytes=n.bytes;return s}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!this.playlist_)return;if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT")return;this.state="READY"}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e)return;if(this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;let a=this.playlist_,n=this.pendingSegment_;if(this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"){if(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main")this.syncController_.setDateTimeMappingForStart(e)}let s=null;if(a){if(a.id)s=a.id;else if(a.uri)s=a.uri}if(this.logger_(`playlist update [${s} => ${e.id||e.uri}]`),this.mediaSequenceSync_)this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
217
+ currentTime: ${this.currentTime_()}
218
+ bufferedEnd: ${e4(this.buffered_())}
219
+ `,this.mediaSequenceSync_.diagnostics);if(this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!a||a.uri!==e.uri){if(this.mediaIndex!==null)if(!e.endList&&typeof e.partTargetDuration==="number")this.resetLoader();else this.resyncLoader();this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}let i=e.mediaSequence-a.mediaSequence;if(this.logger_(`live window shift [${i}]`),this.mediaIndex!==null)if(this.mediaIndex-=i,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{let f=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!f.parts||!f.parts.length||!f.parts[this.partIndex])){let l=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=l}}if(n)if(n.mediaIndex-=i,n.mediaIndex<0)n.mediaIndex=null,n.partIndex=null;else{if(n.mediaIndex>=0)n.segment=e.segments[n.mediaIndex];if(n.partIndex>=0&&n.segment.parts)n.part=n.segment.parts[n.partIndex]}this.syncController_.saveExpiredSegmentInfo(a,e)}pause(){if(this.checkBufferTimeout_)V.default.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null}paused(){return this.checkBufferTimeout_===null}resetEverything(e){if(this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_)this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"})}resetLoader(){if(this.fetchAtBuffer_=!1,this.mediaSequenceSync_)this.mediaSequenceSync_.resetAppendedStatus();this.resyncLoader()}resyncLoader(){if(this.transmuxer_)a4.reset(this.transmuxer_);this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1;let e=this.currentMediaInfo_&&this.currentMediaInfo_.isFmp4;if(this.sourceType_==="hls"&&!e)this.shouldForceTimestampOffsetAfterResync_=!0;if(this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_)this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,t,a=()=>{},n=!1){if(t===1/0)t=this.duration_();if(t<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_("skipping remove because no source updater or starting media info");return}let s=1,i=()=>{if(s--,s===0)a()};if(n||!this.audioDisabled_)s++,this.sourceUpdater_.removeAudio(e,t,i);if(n||this.loaderType_==="main")this.gopBuffer_=XM(this.gopBuffer_,e,t,this.timeMapping_),s++,this.sourceUpdater_.removeVideo(e,t,i);for(let f in this.inbandTextTracks_)kh(e,t,this.inbandTextTracks_[f]);kh(e,t,this.segmentMetadataTrack_),i()}monitorBuffer_(){if(this.checkBufferTimeout_)V.default.clearTimeout(this.checkBufferTimeout_);this.checkBufferTimeout_=V.default.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){if(this.state==="READY")this.fillBuffer_();if(this.checkBufferTimeout_)V.default.clearTimeout(this.checkBufferTimeout_);this.checkBufferTimeout_=V.default.setTimeout(this.monitorBufferTick_.bind(this),VM)}fillBuffer_(){if(this.sourceUpdater_.updating())return;let e=this.chooseNextRequest_();if(!e)return;let t={segmentInfo:vr({type:this.loaderType_,segment:e})};if(this.trigger({type:"segmentselected",metadata:t}),typeof e.timestampOffset==="number")this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline});this.loadSegment_(e)}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,a=this.partIndex){if(!t||!this.mediaSource_)return!1;let n=typeof e==="number"&&t.segments[e],s=e+1===t.segments.length,i=!n||!n.parts||a+1===n.parts.length;return t.endList&&this.mediaSource_.readyState==="open"&&s&&i}chooseNextRequest_(){let e=this.buffered_(),t=e4(e)||0,a=dg(e,this.currentTime_()),n=!this.hasPlayed_()&&a>=1,s=a>=this.goalBufferLength_(),i=this.playlist_.segments;if(!i.length||n||s)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_(),this.loaderType_);let f={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:Boolean(!this.syncPoint_)};if(f.isSyncRequest)f.mediaIndex=LM(this.currentTimeline_,i,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${f.mediaIndex}`);else if(this.mediaIndex!==null){let g=i[this.mediaIndex],b=typeof this.partIndex==="number"?this.partIndex:-1;if(f.startOfSegment=g.end?g.end:t,g.parts&&g.parts[b+1])f.mediaIndex=this.mediaIndex,f.partIndex=b+1;else f.mediaIndex=this.mediaIndex+1}else{let g,b,d,j=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_)this.logger_(`chooseNextRequest_ request after Quality Switch:
220
+ For TargetTime: ${j}.
221
+ CurrentTime: ${this.currentTime_()}
222
+ BufferedEnd: ${t}
223
+ Fetch At Buffer: ${this.fetchAtBuffer_}
224
+ `,this.mediaSequenceSync_.diagnostics);if(this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){let A=this.getSyncInfoFromMediaSequenceSync_(j);if(!A)return this.error({message:"No sync info found while using media sequence sync",metadata:{errorType:se.Error.StreamingFailedToSelectNextSegment,error:Error("No sync info found while using media sequence sync")}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null;this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${A.start} --> ${A.end})`),g=A.segmentIndex,b=A.partIndex,d=A.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");let A=ks.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:j,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});g=A.segmentIndex,b=A.partIndex,d=A.startTime}f.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${j}`:`currentTime ${j}`,f.mediaIndex=g,f.startOfSegment=d,f.partIndex=b,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${f.mediaIndex} `)}let l=i[f.mediaIndex],c=l&&typeof f.partIndex==="number"&&l.parts&&l.parts[f.partIndex];if(!l||typeof f.partIndex==="number"&&!c)return null;if(typeof f.partIndex!=="number"&&l.parts)f.partIndex=0,c=l.parts[0];let h=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!a&&c&&!h&&!c.independent){if(f.partIndex===0){let g=i[f.mediaIndex-1],b=g.parts&&g.parts.length&&g.parts[g.parts.length-1];if(b&&b.independent)f.mediaIndex-=1,f.partIndex=g.parts.length-1,f.independent="previous segment"}else if(l.parts[f.partIndex-1].independent)f.partIndex-=1,f.independent="previous part"}let u=this.mediaSource_&&this.mediaSource_.readyState==="ended";if(f.mediaIndex>=i.length-1&&u&&!this.seeking_())return null;if(this.shouldForceTimestampOffsetAfterResync_)this.shouldForceTimestampOffsetAfterResync_=!1,f.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync");return this.generateSegmentInfo_(f)}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;let t=Math.max(e,this.mediaSequenceSync_.start);if(e!==t)this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);let a=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!a)return null;if(!a.isAppended)return a;let n=this.mediaSequenceSync_.getSyncInfoForTime(a.end);if(!n)return null;if(n.isAppended)this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!");return n}generateSegmentInfo_(e){let{independent:t,playlist:a,mediaIndex:n,startOfSegment:s,isSyncRequest:i,partIndex:f,forceTimestampOffset:l,getMediaInfoForTime:c}=e,h=a.segments[n],u=typeof f==="number"&&h.parts[f],g={requestId:"segment-loader-"+Math.random(),uri:u&&u.resolvedUri||h.resolvedUri,mediaIndex:n,partIndex:u?f:null,isSyncRequest:i,startOfSegment:s,playlist:a,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:h.timeline,duration:u&&u.duration||h.duration,segment:h,part:u,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:c,independent:t},b=typeof l<"u"?l:this.isPendingTimestampOffset_;g.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:h.timeline,currentTimeline:this.currentTimeline_,startOfSegment:s,buffered:this.buffered_(),overrideCheck:b});let d=e4(this.sourceUpdater_.audioBuffered());if(typeof d==="number")g.audioAppendStart=d-this.sourceUpdater_.audioTimestampOffset();if(this.sourceUpdater_.videoBuffered().length)g.gopsToAlignWith=IM(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_);return g}timestampOffsetForSegment_(e){return QM(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH)return;if(Date.now()-(e.firstBytesReceivedAt||Date.now())<1000)return;let t=this.currentTime_(),a=e.bandwidth,n=this.pendingSegment_.duration,s=ks.estimateSegmentRequestTime(n,a,this.playlist_,e.bytesReceived),i=wH(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(s<=i)return;let f=BM({main:this.vhs_.playlists.main,currentTime:t,bandwidth:a,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:i,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!f)return;let c=s-i-f.rebufferingImpact,h=0.5;if(i<=i0)h=1;if(!f.playlist||f.playlist.uri===this.playlist_.uri||c<h)return;this.bandwidth=f.playlist.attributes.BANDWIDTH*jn.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort")}handleAbort_(e){this.logger_(`Aborting ${W1(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){if(this.earlyAbortWhenNeeded_(t.stats),this.checkForAbort_(t.requestId))return;this.trigger("progress")}handleTrackInfo_(e,t){let{hasAudio:a,hasVideo:n}=t,s={segmentInfo:vr({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:a,hasVideo:n}};if(this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:s}),this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.checkForIllegalMediaSwitch(t))return;if(t=t||{},!KM(this.currentMediaInfo_,t))this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo");if(this.checkForAbort_(e.requestId))return;if(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_())this.processCallQueue_();else nl(this)}handleTimingInfo_(e,t,a,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;let s=this.pendingSegment_,i=Xd(t);if(s[i]=s[i]||{},s[i][a]=n,this.logger_(`timinginfo: ${t} - ${a} - ${n}`),this.hasEnoughInfoToAppend_())this.processCallQueue_();else nl(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}let n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),s={};if(t.forEach((i)=>{s[i.stream]=s[i.stream]||{startTime:1/0,captions:[],endTime:0};let f=s[i.stream];f.startTime=Math.min(f.startTime,i.startTime+n),f.endTime=Math.max(f.endTime,i.endTime+n),f.captions.push(i)}),Object.keys(s).forEach((i)=>{let{startTime:f,endTime:l,captions:c}=s[i],h=this.inbandTextTracks_;this.logger_(`adding cues from ${f} -> ${l} for ${i}`),MM(h,this.vhs_.tech_,i),kh(f,l,h[i]),DM({captionArray:c,inbandTextTracks:h,timestampOffset:n})}),this.transmuxer_)this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,a){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,a));return}this.addMetadataToTextTrack(a,t,this.duration_())}processMetadataQueue_(){this.metadataQueue_.id3.forEach((e)=>e()),this.metadataQueue_.caption.forEach((e)=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){let e=this.callQueue_;this.callQueue_=[],e.forEach((t)=>t())}processLoadQueue_(){let e=this.loadQueue_;this.loadQueue_=[],e.forEach((t)=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;let e=this.pendingSegment_;if(!e)return!1;if(!this.getCurrentMediaInfo_())return!0;if(y4({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))return!1;return!0}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready())return!1;if(this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;let e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;let{hasAudio:a,hasVideo:n,isMuxed:s}=t;if(n&&!e.videoTimingInfo)return!1;if(a&&!this.audioDisabled_&&!s&&!e.audioTimingInfo)return!1;if(y4({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))return!1;return!0}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){nl(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}let a=this.pendingSegment_;if(this.setTimeMapping_(a.timeline),this.updateMediaSecondsLoaded_(a.part||a.segment),this.mediaSource_.readyState==="closed")return;if(e.map)e.map=this.initSegmentForMap(e.map,!0),a.segment.map=e.map;if(e.key)this.segmentKey(e.key,!0);if(a.isFmp4=e.isFmp4,a.timingInfo=a.timingInfo||{},a.isFmp4)this.trigger("fmp4"),a.timingInfo.start=a[Xd(t.type)].start;else{let n=this.getCurrentMediaInfo_(),s=this.loaderType_==="main"&&n&&n.hasVideo,i;if(s)i=a.videoTimingInfo.start;a.timingInfo.start=this.trueSegmentStart_({currentStart:a.timingInfo.start,playlist:a.playlist,mediaIndex:a.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:s,firstVideoFrameTimeForData:i,videoTimingInfo:a.videoTimingInfo,audioTimingInfo:a.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(a,t.type),this.updateSourceBufferTimestampOffset_(a),a.isSyncRequest){this.updateTimingInfoEnd_(a),this.syncController_.saveSegmentTimingInfo({segmentInfo:a,shouldSaveTimelineMapping:this.loaderType_==="main"});let n=this.chooseNextRequest_();if(n.mediaIndex!==a.mediaIndex||n.partIndex!==a.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}a.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(a,t)}updateAppendInitSegmentStatus(e,t){if(this.loaderType_==="main"&&typeof e.timestampOffset==="number"&&!e.changedTimestampOffset)this.appendInitSegment_={audio:!0,video:!0};if(this.playlistOfLastInitSegment_[t]!==e.playlist)this.appendInitSegment_[t]=!0}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:a,playlist:n}){if(a){let s=K9(a);if(this.activeInitSegmentId_===s)return null;t=this.initSegmentForMap(a,!0).bytes,this.activeInitSegmentId_=s}if(t&&this.appendInitSegment_[e])return this.playlistOfLastInitSegment_[e]=n,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t;return null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:a},n){let s=this.sourceUpdater_.audioBuffered(),i=this.sourceUpdater_.videoBuffered();if(s.length>1)this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+kr(s).join(", "));if(i.length>1)this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+kr(i).join(", "));let f=s.length?s.start(0):0,l=s.length?s.end(s.length-1):0,c=i.length?i.start(0):0,h=i.length?i.end(i.length-1):0;if(l-f<=qh&&h-c<=qh){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${a.byteLength}, audio buffer: ${kr(s).join(", ")}, video buffer: ${kr(i).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:a}));let g=this.currentTime_()-qh;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${g}`),this.remove(0,g,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${qh}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=V.default.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},qh*1000)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:a},n){if(!n)return;if(n.code===qq){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:a});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",n),this.error({message:`${t} append of ${a.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:se.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:a,data:n,bytes:s}){if(!s){let f=[n],l=n.byteLength;if(a)f.unshift(a),l+=a.byteLength;s=HM({bytes:l,segments:f})}let i={segmentInfo:vr({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:i}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:s},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:s}))}handleSegmentTimingInfo_(e,t,a){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;let n=this.pendingSegment_.segment,s=`${e}TimingInfo`;if(!n[s])n[s]={};n[s].transmuxerPrependedSeconds=a.prependedContentDuration||0,n[s].transmuxedPresentationStart=a.start.presentation,n[s].transmuxedDecodeStart=a.start.decode,n[s].transmuxedPresentationEnd=a.end.presentation,n[s].transmuxedDecodeEnd=a.end.decode,n[s].baseMediaDecodeTime=a.baseMediaDecodeTime}appendData_(e,t){let{type:a,data:n}=t;if(!n||!n.byteLength)return;if(a==="audio"&&this.audioDisabled_)return;let s=this.getInitSegmentAndUpdateState_({type:a,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:a,initSegment:s,data:n})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset==="number"){if(this.transmuxer_)this.transmuxer_.postMessage({action:"clearAllMp4Captions"})}if(!this.hasEnoughInfoToLoad_()){nl(this),this.loadQueue_.push(()=>{let t=Fa({},e,{forceTimestampOffset:!0});Fa(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){if(this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset))this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset});let t=this.createSimplifiedSegmentObj_(e),a=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),n=this.mediaIndex!==null,s=e.timeline!==this.currentTimeline_&&e.timeline>0,i=a||n&&s;if(this.logger_(`Requesting
225
+ ${Lq(e.uri)}
226
+ ${W1(e)}`),t.map&&!t.map.bytes)this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0};e.abortRequests=_M({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:i,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:f,level:l,stream:c})=>{this.logger_(`${W1(e)} logged from transmuxer stream ${c} as a ${l}: ${f}`)},triggerSegmentEventFn:({type:f,segment:l,keyInfo:c,trackInfo:h,timingInfo:u})=>{let b={segmentInfo:vr({segment:l})};if(c)b.keyInfo=c;if(h)b.trackInfo=h;if(u)b.timingInfo=u;this.trigger({type:f,metadata:b})}})}trimBackBuffer_(e){let t=JM(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);if(t>0)this.remove(0,t)}createSimplifiedSegmentObj_(e){let{segment:t,part:a}=e,n=e.segment.key||e.segment.map&&e.segment.map.key,s=e.segment.map&&!e.segment.map.bytes,i={resolvedUri:a?a.resolvedUri:t.resolvedUri,byterange:a?a.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:n,isMediaInitialization:s},f=e.playlist.segments[e.mediaIndex-1];if(f&&f.timeline===t.timeline){if(f.videoTimingInfo)i.baseStartTime=f.videoTimingInfo.transmuxedDecodeEnd;else if(f.audioTimingInfo)i.baseStartTime=f.audioTimingInfo.transmuxedDecodeEnd}if(t.key){let l=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);i.key=this.segmentKey(t.key),i.key.iv=l}if(t.map)i.map=this.initSegmentForMap(t.map);return i}saveTransferStats_(e){if(this.mediaRequests+=1,e)this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<y9){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${y9}`);return}let a={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:a}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,a){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,a));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_)return;if(t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===l0.ABORTED)return;if(this.pause(),e.code===l0.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}let n=this.pendingSegment_;if(this.saveBandwidthRelatedStats_(n.duration,t.stats),n.endOfAllRequests=t.endOfAllRequests,a.gopInfo)this.gopBuffer_=GM(this.gopBuffer_,a.gopInfo,this.safeAppend_);this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(n)}setTimeMapping_(e){let t=this.syncController_.mappingForTimeline(e);if(t!==null)this.timeMapping_=t}updateMediaSecondsLoaded_(e){if(typeof e.start==="number"&&typeof e.end==="number")this.mediaSecondsLoaded+=e.end-e.start;else this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){if(e===null)return!1;if(this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset())return!0;if(!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())return!0;return!1}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:a,firstVideoFrameTimeForData:n,currentVideoTimestampOffset:s,useVideoTimingInfo:i,videoTimingInfo:f,audioTimingInfo:l}){if(typeof e<"u")return e;if(!i)return l.start;let c=t.segments[a-1];if(a===0||!c||typeof c.start>"u"||c.end!==n+s)return n;return f.start}waitForAppendsToComplete_(e){let t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}let{hasAudio:a,hasVideo:n,isMuxed:s}=t,i=this.loaderType_==="main"&&n,f=!this.audioDisabled_&&a&&!s;if(e.waitingOnAppends=0,!e.hasAppendedData_){if(!e.timingInfo&&typeof e.timestampOffset==="number")this.isPendingTimestampOffset_=!0;if(e.timingInfo={start:0},e.waitingOnAppends++,!this.isPendingTimestampOffset_)this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_();this.checkAppendsDone_(e);return}if(i)e.waitingOnAppends++;if(f)e.waitingOnAppends++;if(i)this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e));if(f)this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){if(this.checkForAbort_(e.requestId))return;if(e.waitingOnAppends--,e.waitingOnAppends===0)this.handleAppendsDone_()}checkForIllegalMediaSwitch(e){let t=YM(this.loaderType_,this.getCurrentMediaInfo_(),e);if(t)return this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0;return!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!=="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;if(e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset())this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0;if(e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset())this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0;if(t)this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:a}){if(!this.useDtsForTimestampOffset_)return a.start;if(e&&typeof e.transmuxedDecodeStart==="number")return e.transmuxedDecodeStart;if(t&&typeof t.transmuxedDecodeStart==="number")return t.transmuxedDecodeStart;return a.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};let t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;if(!n)return;e.timingInfo.end=typeof n.end==="number"?n.end:n.start+e.duration}handleAppendsDone_(){if(this.pendingSegment_){let l={segmentInfo:vr({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:l})}if(!this.pendingSegment_){if(this.state="READY",!this.paused())this.monitorBuffer_();return}let e=this.pendingSegment_;if(e.part&&e.part.syncInfo)e.part.syncInfo.markAppended();else if(e.segment.syncInfo)e.segment.syncInfo.markAppended();if(this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_)this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});let t=PM(e,this.sourceType_);if(t)if(t.severity==="warn")se.log.warn(t.message);else this.logger_(t.message);if(this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest){if(this.trigger("syncinfoupdate"),!e.hasAppendedData_){this.logger_(`Throwing away un-appended sync request ${W1(e)}`);return}}if(this.logger_(`Appended ${W1(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline){if(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_)this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})}this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");let{segment:a,part:n}=e,s=a.end&&this.currentTime_()-a.end>e.playlist.targetDuration*3,i=n&&n.end&&this.currentTime_()-n.end>e.playlist.partTargetDuration*3;if(s||i){this.logger_(`bad ${s?"segment":"part"} ${W1(e)}`),this.resetEverything();return}if(this.mediaIndex!==null)this.trigger("bandwidthupdate");if(this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex))this.endOfStream();if(this.trigger("appended"),e.hasAppendedData_)this.mediaAppends++;if(!this.paused())this.monitorBuffer_()}recordThroughput_(e){if(e.duration<y9){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${y9}`);return}let t=this.throughput.rate,a=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/a*8*1000);this.throughput.rate+=(n-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;let t=e.segment,a=t.start,n=t.end;if(!Gd(a)||!Gd(n))return;kh(a,n,this.segmentMetadataTrack_);let s=V.default.WebKitDataCue||V.default.VTTCue,i={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:a,end:n},f=JSON.stringify(i),l=new s(a,n,f);l.value=i,this.segmentMetadataTrack_.addCue(l)}}function ef(){}var Vq=function(e){if(typeof e!=="string")return e;return e.replace(/./,(t)=>t.toUpperCase())},eD=["video","audio"],S4=(e,t)=>{let a=t[`${e}Buffer`];return a&&a.updating||t.queuePending[e]},tD=(e,t)=>{for(let a=0;a<t.length;a++){let n=t[a];if(n.type==="mediaSource")return null;if(n.type===e)return a}return null},oo=(e,t)=>{if(t.queue.length===0)return;let a=0,n=t.queue[a];if(n.type==="mediaSource"){if(!t.updating()&&t.mediaSource.readyState!=="closed"){if(t.queue.shift(),n.action(t),n.doneFn)n.doneFn();oo("audio",t),oo("video",t)}return}if(e==="mediaSource")return;if(!t.ready()||t.mediaSource.readyState==="closed"||S4(e,t))return;if(n.type!==e){if(a=tD(e,t.queue),a===null)return;n=t.queue[a]}if(t.queue.splice(a,1),t.queuePending[e]=n,n.action(e,t),!n.doneFn){t.queuePending[e]=null,oo(e,t);return}},Yq=(e,t)=>{let a=t[`${e}Buffer`],n=Vq(e);if(!a)return;a.removeEventListener("updateend",t[`on${n}UpdateEnd_`]),a.removeEventListener("error",t[`on${n}Error_`]),t.codecs[e]=null,t[`${e}Buffer`]=null},n0=(e,t)=>e&&t&&Array.prototype.indexOf.call(e.sourceBuffers,t)!==-1,Xs={appendBuffer:(e,t,a)=>(n,s)=>{let i=s[`${n}Buffer`];if(!n0(s.mediaSource,i))return;s.logger_(`Appending segment ${t.mediaIndex}'s ${e.length} bytes to ${n}Buffer`);try{i.appendBuffer(e)}catch(f){s.logger_(`Error with code ${f.code} `+(f.code===qq?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${t.mediaIndex} to ${n}Buffer`),s.queuePending[n]=null,a(f)}},remove:(e,t)=>(a,n)=>{let s=n[`${a}Buffer`];if(!n0(n.mediaSource,s))return;n.logger_(`Removing ${e} to ${t} from ${a}Buffer`);try{s.remove(e,t)}catch(i){n.logger_(`Remove ${e} to ${t} from ${a}Buffer failed`)}},timestampOffset:(e)=>(t,a)=>{let n=a[`${t}Buffer`];if(!n0(a.mediaSource,n))return;a.logger_(`Setting ${t}timestampOffset to ${e}`),n.timestampOffset=e},callback:(e)=>(t,a)=>{e()},endOfStream:(e)=>(t)=>{if(t.mediaSource.readyState!=="open")return;t.logger_(`Calling mediaSource endOfStream(${e||""})`);try{t.mediaSource.endOfStream(e)}catch(a){se.log.warn("Failed to call media source endOfStream",a)}},duration:(e)=>(t)=>{t.logger_(`Setting mediaSource duration to ${e}`);try{t.mediaSource.duration=e}catch(a){se.log.warn("Failed to set media source duration",a)}},abort:()=>(e,t)=>{if(t.mediaSource.readyState!=="open")return;let a=t[`${e}Buffer`];if(!n0(t.mediaSource,a))return;t.logger_(`calling abort on ${e}Buffer`);try{a.abort()}catch(n){se.log.warn(`Failed to abort on ${e}Buffer`,n)}},addSourceBuffer:(e,t)=>(a)=>{let n=Vq(e),s=br(t);a.logger_(`Adding ${e}Buffer with codec ${t} to mediaSource`);let i=a.mediaSource.addSourceBuffer(s);i.addEventListener("updateend",a[`on${n}UpdateEnd_`]),i.addEventListener("error",a[`on${n}Error_`]),a.codecs[e]=t,a[`${e}Buffer`]=i},removeSourceBuffer:(e)=>(t)=>{let a=t[`${e}Buffer`];if(Yq(e,t),!n0(t.mediaSource,a))return;t.logger_(`Removing ${e}Buffer with codec ${t.codecs[e]} from mediaSource`);try{t.mediaSource.removeSourceBuffer(a)}catch(n){se.log.warn(`Failed to removeSourceBuffer ${e}Buffer`,n)}},changeType:(e)=>(t,a)=>{let n=a[`${t}Buffer`],s=br(e);if(!n0(a.mediaSource,n))return;let i=e.substring(0,e.indexOf(".")),f=a.codecs[t];if(f.substring(0,f.indexOf("."))===i)return;let c={codecsChangeInfo:{from:f,to:e}};a.trigger({type:"codecschange",metadata:c}),a.logger_(`changing ${t}Buffer codec from ${f} to ${e}`);try{n.changeType(s),a.codecs[t]=e}catch(h){c.errorType=se.Error.StreamingCodecsChangeError,c.error=h,h.metadata=c,a.error_=h,a.trigger("error"),se.log.warn(`Failed to changeType on ${t}Buffer`,h)}}},Ks=({type:e,sourceUpdater:t,action:a,doneFn:n,name:s})=>{t.queue.push({type:e,action:a,doneFn:n,name:s}),oo(e,t)},Ld=(e,t)=>(a)=>{let n=t[`${e}Buffered`](),s=gH(n);if(t.logger_(`received "updateend" event for ${e} Source Buffer: `,s),t.queuePending[e]){let i=t.queuePending[e].doneFn;if(t.queuePending[e]=null,i)i(t[`${e}Error_`])}oo(e,t)};class yg extends se.EventTarget{constructor(e){super();this.mediaSource=e,this.sourceopenListener_=()=>oo("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=gi("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=Ld("video",this),this.onAudioUpdateEnd_=Ld("audio",this),this.onVideoError_=(t)=>{this.videoError_=t},this.onAudioError_=(t)=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){if(this.hasCreatedSourceBuffers())return;this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady()}triggerReady(){if(this.ready()&&!this.triggeredReady_)this.triggeredReady_=!0,this.trigger("ready")}addSourceBuffer(e,t){Ks({type:"mediaSource",sourceUpdater:this,action:Xs.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){Ks({type:e,sourceUpdater:this,action:Xs.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){se.log.error("removeSourceBuffer is not supported!");return}Ks({type:"mediaSource",sourceUpdater:this,action:Xs.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!se.browser.IS_FIREFOX&&V.default.MediaSource&&V.default.MediaSource.prototype&&typeof V.default.MediaSource.prototype.removeSourceBuffer==="function"}static canChangeType(){return V.default.SourceBuffer&&V.default.SourceBuffer.prototype&&typeof V.default.SourceBuffer.prototype.changeType==="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){se.log.error("changeType is not supported!");return}Ks({type:e,sourceUpdater:this,action:Xs.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!=="object"||Object.keys(e).length===0)throw Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach((t)=>{let a=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,a);if(this.canChangeType())this.changeType(t,a)})}appendBuffer(e,t){let{segmentInfo:a,type:n,bytes:s}=e;if(this.processedAppend_=!0,n==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${s.length} until video append`);return}let i=t;if(Ks({type:n,sourceUpdater:this,action:Xs.appendBuffer(s,a||{mediaIndex:-1},i),doneFn:t,name:"appendBuffer"}),n==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;let f=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${f.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,f.forEach((l)=>{this.appendBuffer.apply(this,l)})}}audioBuffered(){if(!n0(this.mediaSource,this.audioBuffer))return qn();return this.audioBuffer.buffered?this.audioBuffer.buffered:qn()}videoBuffered(){if(!n0(this.mediaSource,this.videoBuffer))return qn();return this.videoBuffer.buffered?this.videoBuffer.buffered:qn()}buffered(){let e=n0(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=n0(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;if(t&&!e)return this.audioBuffered();if(e&&!t)return this.videoBuffered();return bH(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ef){Ks({type:"mediaSource",sourceUpdater:this,action:Xs.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ef){if(typeof e!=="string")e=void 0;Ks({type:"mediaSource",sourceUpdater:this,action:Xs.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,a=ef){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){a();return}Ks({type:"audio",sourceUpdater:this,action:Xs.remove(e,t),doneFn:a,name:"remove"})}removeVideo(e,t,a=ef){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){a();return}Ks({type:"video",sourceUpdater:this,action:Xs.remove(e,t),doneFn:a,name:"remove"})}updating(){if(S4("audio",this)||S4("video",this))return!0;return!1}audioTimestampOffset(e){if(typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e)Ks({type:"audio",sourceUpdater:this,action:Xs.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e;return this.audioTimestampOffset_}videoTimestampOffset(e){if(typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e)Ks({type:"video",sourceUpdater:this,action:Xs.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e;return this.videoTimestampOffset_}audioQueueCallback(e){if(!this.audioBuffer)return;Ks({type:"audio",sourceUpdater:this,action:Xs.callback(e),name:"callback"})}videoQueueCallback(e){if(!this.videoBuffer)return;Ks({type:"video",sourceUpdater:this,action:Xs.callback(e),name:"callback"})}dispose(){if(this.trigger("dispose"),eD.forEach((e)=>{if(this.abort(e),this.canRemoveSourceBuffer())this.removeSourceBuffer(e);else this[`${e}QueueCallback`](()=>Yq(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_)this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_);this.off()}}var Vd=(e)=>decodeURIComponent(escape(String.fromCharCode.apply(null,e))),aD=(e)=>{let t=new Uint8Array(e);return Array.from(t).map((a)=>a.toString(16).padStart(2,"0")).join("")},Yd=new Uint8Array(`
227
+
228
+ `.split("").map((e)=>e.charCodeAt(0)));class Jq extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class Qq extends V9{constructor(e,t={}){super(e,t);this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return qn();let e=this.subtitlesTrack_.cues,t=e[0].startTime,a=e[e.length-1].startTime;return qn([[t,a]])}initSegmentForMap(e,t=!1){if(!e)return null;let a=K9(e),n=this.initSegments_[a];if(t&&!n&&e.bytes){let s=Yd.byteLength+e.bytes.byteLength,i=new Uint8Array(s);i.set(e.bytes),i.set(Yd,e.bytes.byteLength),this.initSegments_[a]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:i}}return n||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){if(typeof e>"u")return this.subtitlesTrack_;if(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_())this.init_();return this.subtitlesTrack_}remove(e,t){kh(e,t,this.subtitlesTrack_)}fillBuffer_(){let e=this.chooseNextRequest_();if(!e)return;if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){let t=()=>{if(this.state="READY",!this.paused())this.monitorBuffer_()};this.syncController_.one("timestampoffset",t),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){while(e&&e.segment.empty){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,a){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){if(e.code===l0.TIMEOUT)this.handleTimeout_();if(e.code===l0.ABORTED)this.mediaRequestsAborted+=1;else this.mediaRequestsErrored+=1;this.stopForError(e);return}let n=this.pendingSegment_,s=a.mp4VttCues&&a.mp4VttCues.length;if(s)n.mp4VttCues=a.mp4VttCues;if(this.saveBandwidthRelatedStats_(n.duration,t.stats),t.key)this.segmentKey(t.key,!0);this.state="APPENDING",this.trigger("appending");let i=n.segment;if(i.map)i.map.bytes=t.map.bytes;if(n.bytes=t.bytes,typeof V.default.WebVTT!=="function"&&typeof this.loadVttJs==="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,a),()=>this.stopForError({message:"Error loading vtt.js"}));return}i.requested=!0;try{this.parseVTTCues_(n)}catch(f){this.stopForError({message:f.message,metadata:{errorType:se.Error.StreamingVttParserError,error:f}});return}if(!s)this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_);if(n.cues.length)n.timingInfo={start:n.cues[0].startTime,end:n.cues[n.cues.length-1].endTime};else n.timingInfo={start:n.startOfSegment,end:n.startOfSegment+n.duration};if(n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=i.duration,n.cues.forEach((f)=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new V.default.VTTCue(f.startTime,f.endTime,f.text):f)}),UM(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){let a=e&&e.type==="vtt",n=t&&t.type==="text";if(a&&n)super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){let t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach((a)=>{let n=a.start+t,s=a.end+t,i=new V.default.VTTCue(n,s,a.cueText);if(a.settings)a.settings.split(" ").forEach((f)=>{let l=f.split(":"),c=l[0],h=l[1];i[c]=isNaN(h)?h:Number(h)});e.cues.push(i)})}parseVTTCues_(e){let t,a=!1;if(typeof V.default.WebVTT!=="function")throw new Jq;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}if(typeof V.default.TextDecoder==="function")t=new V.default.TextDecoder("utf8");else t=V.default.WebVTT.StringDecoder(),a=!0;let n=new V.default.WebVTT.Parser(V.default,V.default.vttjs,t);if(n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=(i)=>{e.timestampmap=i},n.onparsingerror=(i)=>{se.log.warn("Error encountered when parsing cues: "+i.message)},e.segment.map){let i=e.segment.map.bytes;if(a)i=Vd(i);n.parse(i)}let s=e.bytes;if(a)s=Vd(s);n.parse(s),n.flush()}updateTimeMapping_(e,t,a){let n=e.segment;if(!t)return;if(!e.cues.length){n.empty=!0;return}let{MPEGTS:s,LOCAL:i}=e.timestampmap,l=s/fl.ONE_SECOND_IN_TS-i+t.mapping;if(e.cues.forEach((c)=>{let h=c.endTime-c.startTime,u=this.handleRollover_(c.startTime+l,t.time);c.startTime=Math.max(u,0),c.endTime=Math.max(u+h,0)}),!a.syncInfo){let c=e.cues[0].startTime,h=e.cues[e.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+e.mediaIndex,time:Math.min(c,h-n.duration)}}}handleRollover_(e,t){if(t===null)return e;let a=e*fl.ONE_SECOND_IN_TS,n=t*fl.ONE_SECOND_IN_TS,s;if(n<a)s=-8589934592;else s=8589934592;while(Math.abs(a-n)>4294967296)a+=s;return a/fl.ONE_SECOND_IN_TS}}var nD=function(e,t){let a=e.cues;for(let n=0;n<a.length;n++){let s=a[n];if(t>=s.adStartTime&&t<=s.adEndTime)return s}return null},sD=function(e,t,a=0){if(!e.segments)return;let n=a,s;for(let i=0;i<e.segments.length;i++){let f=e.segments[i];if(!s)s=nD(t,n+f.duration/2);if(s){if("cueIn"in f){s.endTime=n,s.adEndTime=n,n+=f.duration,s=null;continue}if(n<s.endTime){n+=f.duration;continue}s.endTime+=f.duration}else{if("cueOut"in f)s=new V.default.VTTCue(n,n+f.duration,f.cueOut),s.adStartTime=n,s.adEndTime=n+parseFloat(f.cueOut),t.addCue(s);if("cueOutCont"in f){let[l,c]=f.cueOutCont.split("/").map(parseFloat);s=new V.default.VTTCue(n,n+f.duration,""),s.adStartTime=n-l,s.adEndTime=s.adStartTime+c,t.addCue(s)}}n+=f.duration}};class C4{constructor({start:e,end:t,segmentIndex:a,partIndex:n=null,appended:s=!1}){this.start_=e,this.end_=t,this.segmentIndex_=a,this.partIndex_=n,this.appended_=s}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class Zq{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach((e)=>e.resetAppendedStatus())}}class Sg{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach((e)=>e.resetAppendStatus())}update(e,t){let{mediaSequence:a,segments:n}=e;if(this.isReliable_=this.isReliablePlaylist_(a,n),!this.isReliable_)return;return this.updateStorage_(n,a,this.calculateBaseTime_(a,n,t))}getSyncInfoForTime(e){for(let{segmentSyncInfo:t,partsSyncInfo:a}of this.storage_.values())if(!a.length){if(t.isInRange(e))return t}else for(let n of a)if(n.isInRange(e))return n;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,a){let n=new Map,s=`
229
+ `,i=a,f=t;this.start_=i,e.forEach((l,c)=>{let h=this.storage_.get(f),u=i,g=u+l.duration,b=Boolean(h&&h.segmentSyncInfo&&h.segmentSyncInfo.isAppended),d=new C4({start:u,end:g,appended:b,segmentIndex:c});l.syncInfo=d;let j=i,A=(l.parts||[]).map((C,y)=>{let O=j,T=j+C.duration,M=Boolean(h&&h.partsSyncInfo&&h.partsSyncInfo[y]&&h.partsSyncInfo[y].isAppended),H=new C4({start:O,end:T,appended:M,segmentIndex:c,partIndex:y});return j=T,s+=`Media Sequence: ${f}.${y} | Range: ${O} --> ${T} | Appended: ${M}
230
+ `,C.syncInfo=H,H});n.set(f,new Zq(d,A)),s+=`${Lq(l.resolvedUri)} | Media Sequence: ${f} | Range: ${u} --> ${g} | Appended: ${b}
231
+ `,f++,i=g}),this.end_=i,this.storage_=n,this.diagnostics_=s}calculateBaseTime_(e,t,a){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;let n=Math.min(...this.storage_.keys());if(e<n){let s=n-e,i=this.storage_.get(n).segmentSyncInfo.start;for(let f=0;f<s;f++){let l=t[f];i-=l.duration}return i}return a}isReliablePlaylist_(e,t){return e!==void 0&&e!==null&&Array.isArray(t)&&t.length}}class _4 extends Sg{constructor(e){super();this.parent_=e}calculateBaseTime_(e,t,a){if(!this.storage_.size){let n=this.parent_.getSyncInfoForMediaSequence(e);if(n)return n.segmentSyncInfo.start;return 0}return super.calculateBaseTime_(e,t,a)}}var iD=86400,n4=[{name:"VOD",run:(e,t,a,n,s)=>{if(a!==1/0)return{time:0,segmentIndex:0,partIndex:null};return null}},{name:"MediaSequence",run:(e,t,a,n,s,i)=>{let f=e.getMediaSequenceSync(i);if(!f)return null;if(!f.isReliable)return null;let l=f.getSyncInfoForTime(s);if(!l)return null;return{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}}},{name:"ProgramDateTime",run:(e,t,a,n,s)=>{if(!Object.keys(e.timelineToDatetimeMappings).length)return null;let i=null,f=null,l=b4(t);s=s||0;for(let c=0;c<l.length;c++){let h=t.endList||s===0?c:l.length-(c+1),u=l[h],g=u.segment,b=e.timelineToDatetimeMappings[g.timeline];if(!b||!g.dateTimeObject)continue;let j=g.dateTimeObject.getTime()/1000+b;if(g.parts&&typeof u.partIndex==="number")for(let C=0;C<u.partIndex;C++)j+=g.parts[C].duration;let A=Math.abs(s-j);if(f!==null&&(A===0||f<A))break;f=A,i={time:j,segmentIndex:u.segmentIndex,partIndex:u.partIndex}}return i}},{name:"Segment",run:(e,t,a,n,s)=>{let i=null,f=null;s=s||0;let l=b4(t);for(let c=0;c<l.length;c++){let h=t.endList||s===0?c:l.length-(c+1),u=l[h],g=u.segment,b=u.part&&u.part.start||g&&g.start;if(g.timeline===n&&typeof b<"u"){let d=Math.abs(s-b);if(f!==null&&f<d)break;if(!i||f===null||f>=d)f=d,i={time:b,segmentIndex:u.segmentIndex,partIndex:u.partIndex}}}return i}},{name:"Discontinuity",run:(e,t,a,n,s)=>{let i=null;if(s=s||0,t.discontinuityStarts&&t.discontinuityStarts.length){let f=null;for(let l=0;l<t.discontinuityStarts.length;l++){let c=t.discontinuityStarts[l],h=t.discontinuitySequence+l+1,u=e.discontinuities[h];if(u){let g=Math.abs(s-u.time);if(f!==null&&f<g)break;if(!i||f===null||f>=g)f=g,i={time:u.time,segmentIndex:c,partIndex:null}}}}return i}},{name:"Playlist",run:(e,t,a,n,s)=>{if(t.syncInfo)return{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence,partIndex:null};return null}}];class $q extends se.EventTarget{constructor(e={}){super();this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};let t=new Sg,a=new _4(t),n=new _4(t);this.mediaSequenceStorage_={main:t,audio:a,vtt:n},this.logger_=gi("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,a,n,s){if(t!==1/0)return n4.find(({name:l})=>l==="VOD").run(this,e,t);let i=this.runStrategies_(e,t,a,n,s);if(!i.length)return null;for(let f of i){let{syncPoint:l,strategy:c}=f,{segmentIndex:h,time:u}=l;if(h<0)continue;let g=e.segments[h],b=u,d=b+g.duration;if(this.logger_(`Strategy: ${c}. Current time: ${n}. selected segment: ${h}. Time: [${b} -> ${d}]}`),n>=b&&n<d)return this.logger_("Found sync point with exact match: ",l),l}return this.selectSyncPoint_(i,{key:"time",value:n})}getExpiredTime(e,t){if(!e||!e.segments)return null;let a=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!a.length)return null;let n=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});if(n.segmentIndex>0)n.time*=-1;return Math.abs(n.time+Ch({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,a,n,s){let i=[];for(let f=0;f<n4.length;f++){let l=n4[f],c=l.run(this,e,t,a,n,s);if(c)c.strategy=l.name,i.push({strategy:l.name,syncPoint:c})}return i}selectSyncPoint_(e,t){let a=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),s=e[0].strategy;for(let i=1;i<e.length;i++){let f=Math.abs(e[i].syncPoint[t.key]-t.value);if(f<n)n=f,a=e[i].syncPoint,s=e[i].strategy}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${s}]: [time:${a.time}, segmentIndex:${a.segmentIndex}`+(typeof a.partIndex==="number"?`,partIndex:${a.partIndex}`:"")+"]"),a}saveExpiredSegmentInfo(e,t){let a=t.mediaSequence-e.mediaSequence;if(a>iD){se.log.warn(`Not saving expired segment info. Media sequence gap ${a} is too large.`);return}for(let n=a-1;n>=0;n--){let s=e.segments[n];if(s&&typeof s.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+n,time:s.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){let t=e.segments[0],a=t.dateTimeObject.getTime()/1000;this.timelineToDatetimeMappings[t.timeline]=-a}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){let a=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),n=e.segment;if(a){if(this.saveDiscontinuitySyncInfo_(e),!e.playlist.syncInfo)e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:n.start}}let s=n.dateTimeObject;if(n.discontinuity&&t&&s)this.timelineToDatetimeMappings[n.timeline]=-(s.getTime()/1000)}timestampOffsetForTimeline(e){if(typeof this.timelines[e]>"u")return null;return this.timelines[e].time}mappingForTimeline(e){if(typeof this.timelines[e]>"u")return null;return this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,a){let{segment:n,part:s}=e,i=this.timelines[e.timeline],f,l;if(typeof e.timestampOffset==="number"){if(i={time:e.startOfSegment,mapping:e.startOfSegment-t.start},a)this.timelines[e.timeline]=i,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${i.time}] [mapping: ${i.mapping}]`);f=e.startOfSegment,l=t.end+i.mapping}else if(i)f=t.start+i.mapping,l=t.end+i.mapping;else return!1;if(s)s.start=f,s.end=l;if(!n.start||f<n.start)n.start=f;return n.end=l,!0}saveDiscontinuitySyncInfo_(e){let{playlist:t,segment:a}=e;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let n=0;n<t.discontinuityStarts.length;n++){let s=t.discontinuityStarts[n],i=t.discontinuitySequence+n+1,f=s-e.mediaIndex,l=Math.abs(f);if(!this.discontinuities[i]||this.discontinuities[i].accuracy>l){let c;if(f<0)c=a.start-Ch({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:s});else c=a.end+Ch({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:s});this.discontinuities[i]={time:c,accuracy:l}}}}dispose(){this.trigger("dispose"),this.off()}}class Wq extends se.EventTarget{constructor(){super();this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:a}){if(typeof t==="number"&&typeof a==="number")this.pendingTimelineChanges_[e]={type:e,from:t,to:a},this.trigger("pendingtimelinechange");return this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:a}){if(typeof t==="number"&&typeof a==="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:a},delete this.pendingTimelineChanges_[e];let n={timelineChangeInfo:{from:t,to:a}};this.trigger({type:"timelinechange",metadata:n})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}var fD=Dq(xq(function(){var e=function(){function A(){this.listeners={}}var C=A.prototype;return C.on=function(O,T){if(!this.listeners[O])this.listeners[O]=[];this.listeners[O].push(T)},C.off=function(O,T){if(!this.listeners[O])return!1;var M=this.listeners[O].indexOf(T);return this.listeners[O]=this.listeners[O].slice(0),this.listeners[O].splice(M,1),M>-1},C.trigger=function(O){var T=this.listeners[O];if(!T)return;if(arguments.length===2){var M=T.length;for(var H=0;H<M;++H)T[H].call(this,arguments[1])}else{var N=Array.prototype.slice.call(arguments,1),x=T.length;for(var z=0;z<x;++z)T[z].apply(this,N)}},C.dispose=function(){this.listeners={}},C.pipe=function(O){this.on("data",function(T){O.push(T)})},A}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function t(A){return A.subarray(0,A.byteLength-A[A.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */let a=function(){let A=[[[],[],[],[],[]],[[],[],[],[],[]]],C=A[0],y=A[1],O=C[4],T=y[4],M,H,N,x=[],z=[],K,$,Q,P,te,ee;for(M=0;M<256;M++)z[(x[M]=M<<1^(M>>7)*283)^M]=M;for(H=N=0;!O[H];H^=K||1,N=z[N]||1){P=N^N<<1^N<<2^N<<3^N<<4,P=P>>8^P&255^99,O[H]=P,T[P]=H,Q=x[$=x[K=x[H]]],ee=Q*16843009^$*65537^K*257^H*16843008,te=x[P]*257^P*16843008;for(M=0;M<4;M++)C[M][H]=te=te<<24^te>>>8,y[M][P]=ee=ee<<24^ee>>>8}for(M=0;M<5;M++)C[M]=C[M].slice(0),y[M]=y[M].slice(0);return A},n=null;class s{constructor(A){if(!n)n=a();this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let C,y,O,T=this._tables[0][4],M=this._tables[1],H=A.length,N=1;if(H!==4&&H!==6&&H!==8)throw Error("Invalid aes key size");let x=A.slice(0),z=[];this._key=[x,z];for(C=H;C<4*H+28;C++){if(O=x[C-1],C%H===0||H===8&&C%H===4){if(O=T[O>>>24]<<24^T[O>>16&255]<<16^T[O>>8&255]<<8^T[O&255],C%H===0)O=O<<8^O>>>24^N<<24,N=N<<1^(N>>7)*283}x[C]=x[C-H]^O}for(y=0;C;y++,C--)if(O=x[y&3?C:C-4],C<=4||y<4)z[y]=O;else z[y]=M[0][T[O>>>24]]^M[1][T[O>>16&255]]^M[2][T[O>>8&255]]^M[3][T[O&255]]}decrypt(A,C,y,O,T,M){let H=this._key[1],N=A^H[0],x=O^H[1],z=y^H[2],K=C^H[3],$,Q,P,te=H.length/4-2,ee,L=4,J=this._tables[1],pe=J[0],ne=J[1],fe=J[2],Ae=J[3],he=J[4];for(ee=0;ee<te;ee++)$=pe[N>>>24]^ne[x>>16&255]^fe[z>>8&255]^Ae[K&255]^H[L],Q=pe[x>>>24]^ne[z>>16&255]^fe[K>>8&255]^Ae[N&255]^H[L+1],P=pe[z>>>24]^ne[K>>16&255]^fe[N>>8&255]^Ae[x&255]^H[L+2],K=pe[K>>>24]^ne[N>>16&255]^fe[x>>8&255]^Ae[z&255]^H[L+3],L+=4,N=$,x=Q,z=P;for(ee=0;ee<4;ee++)T[(3&-ee)+M]=he[N>>>24]<<24^he[x>>16&255]<<16^he[z>>8&255]<<8^he[K&255]^H[L++],$=N,N=x,x=z,z=K,K=$}}class i extends e{constructor(){super(e);this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){if(this.jobs.shift()(),this.jobs.length)this.timeout_=setTimeout(this.processJob_.bind(this),this.delay);else this.timeout_=null}push(A){if(this.jobs.push(A),!this.timeout_)this.timeout_=setTimeout(this.processJob_.bind(this),this.delay)}}let f=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},l=function(A,C,y){let O=new Int32Array(A.buffer,A.byteOffset,A.byteLength>>2),T=new s(Array.prototype.slice.call(C)),M=new Uint8Array(A.byteLength),H=new Int32Array(M.buffer),N,x,z,K,$,Q,P,te,ee;N=y[0],x=y[1],z=y[2],K=y[3];for(ee=0;ee<O.length;ee+=4)$=f(O[ee]),Q=f(O[ee+1]),P=f(O[ee+2]),te=f(O[ee+3]),T.decrypt($,Q,P,te,H,ee),H[ee]=f(H[ee]^N),H[ee+1]=f(H[ee+1]^x),H[ee+2]=f(H[ee+2]^z),H[ee+3]=f(H[ee+3]^K),N=$,x=Q,z=P,K=te;return M};class c{constructor(A,C,y,O){let T=c.STEP,M=new Int32Array(A.buffer),H=new Uint8Array(A.byteLength),N=0;this.asyncStream_=new i,this.asyncStream_.push(this.decryptChunk_(M.subarray(N,N+T),C,y,H));for(N=T;N<M.length;N+=T)y=new Uint32Array([f(M[N-4]),f(M[N-3]),f(M[N-2]),f(M[N-1])]),this.asyncStream_.push(this.decryptChunk_(M.subarray(N,N+T),C,y,H));this.asyncStream_.push(function(){O(null,t(H))})}static get STEP(){return 32000}decryptChunk_(A,C,y,O){return function(){let T=l(A,C,y);O.set(T,A.byteOffset)}}}var h=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},u;if(typeof window<"u")u=window;else if(typeof h<"u")u=h;else if(typeof self<"u")u=self;else u={};var g=u,b=function(C){if(ArrayBuffer.isView==="function")return ArrayBuffer.isView(C);return C&&C.buffer instanceof ArrayBuffer},d=g.BigInt||Number;d("0x1"),d("0x100"),d("0x10000"),d("0x1000000"),d("0x100000000"),d("0x10000000000"),d("0x1000000000000"),d("0x100000000000000"),d("0x10000000000000000"),function(){var A=new Uint16Array([65484]),C=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);if(C[0]===255)return"big";if(C[0]===204)return"little";return"unknown"}();let j=function(A){let C={};return Object.keys(A).forEach((y)=>{let O=A[y];if(b(O))C[y]={bytes:O.buffer,byteOffset:O.byteOffset,byteLength:O.byteLength};else C[y]=O}),C};self.onmessage=function(A){let C=A.data,y=new Uint8Array(C.encrypted.bytes,C.encrypted.byteOffset,C.encrypted.byteLength),O=new Uint32Array(C.key.bytes,C.key.byteOffset,C.key.byteLength/4),T=new Uint32Array(C.iv.bytes,C.iv.byteOffset,C.iv.byteLength/4);new c(y,O,T,function(M,H){self.postMessage(j({source:C.source,decrypted:H}),[H.buffer])})}})),lD=Mq(fD),rD=(e)=>{let t=e.default?"main":"alternative";if(e.characteristics&&e.characteristics.indexOf("public.accessibility.describes-video")>=0)t="main-desc";return t},Pq=(e,t)=>{if(e.abort(),e.pause(),t&&t.activePlaylistLoader)t.activePlaylistLoader.pause(),t.activePlaylistLoader=null},F4=(e,t)=>{t.activePlaylistLoader=e,e.load()},oD=(e,t)=>()=>{let{segmentLoaders:{[e]:a,main:n},mediaTypes:{[e]:s}}=t,i=s.activeTrack(),f=s.getActiveGroup(),l=s.activePlaylistLoader,c=s.lastGroup_;if(f&&c&&f.id===c.id)return;if(s.lastGroup_=f,s.lastTrack_=i,Pq(a,s),!f||f.isMainPlaylist)return;if(!f.playlistLoader){if(l)n.resetEverything();return}a.resyncLoader(),F4(f.playlistLoader,s)},cD=(e,t)=>()=>{let{segmentLoaders:{[e]:a},mediaTypes:{[e]:n}}=t;n.lastGroup_=null,a.abort(),a.pause()},hD=(e,t)=>()=>{let{mainPlaylistLoader:a,segmentLoaders:{[e]:n,main:s},mediaTypes:{[e]:i}}=t,f=i.activeTrack(),l=i.getActiveGroup(),c=i.activePlaylistLoader,h=i.lastTrack_;if(h&&f&&h.id===f.id)return;if(i.lastGroup_=l,i.lastTrack_=f,Pq(n,i),!l)return;if(l.isMainPlaylist){if(!f||!h||f.id===h.id)return;let u=t.vhs.playlistController_,g=u.selectPlaylist();if(u.media()===g)return;i.logger_(`track change. Switching main audio from ${h.id} to ${f.id}`),a.pause(),s.resetEverything(),u.fastQualityChange_(g);return}if(e==="AUDIO"){if(!l.playlistLoader){s.setAudio(!0),s.resetEverything();return}n.setAudio(!0),s.setAudio(!1)}if(c===l.playlistLoader){F4(l.playlistLoader,i);return}if(n.track)n.track(f);n.resetEverything(),F4(l.playlistLoader,i)},Y9={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:a},excludePlaylist:n}=t,s=a.activeTrack(),i=a.activeGroup(),f=(i.filter((c)=>c.default)[0]||i[0]).id,l=a.tracks[f];if(s===l){n({error:{message:"Problem encountered loading the default audio track."}});return}se.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(let c in a.tracks)a.tracks[c].enabled=a.tracks[c]===l;a.onTrackChanged()},SUBTITLES:(e,t)=>()=>{let{mediaTypes:{[e]:a}}=t;se.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");let n=a.activeTrack();if(n)n.mode="disabled";a.onTrackChanged()}},Jd={AUDIO:(e,t,a)=>{if(!t)return;let{tech:n,requestOptions:s,segmentLoaders:{[e]:i}}=a;t.on("loadedmetadata",()=>{let f=t.media();if(i.playlist(f,s),!n.paused()||f.endList&&n.preload()!=="none")i.load()}),t.on("loadedplaylist",()=>{if(i.playlist(t.media(),s),!n.paused())i.load()}),t.on("error",Y9[e](e,a))},SUBTITLES:(e,t,a)=>{let{tech:n,requestOptions:s,segmentLoaders:{[e]:i},mediaTypes:{[e]:f}}=a;t.on("loadedmetadata",()=>{let l=t.media();if(i.playlist(l,s),i.track(f.activeTrack()),!n.paused()||l.endList&&n.preload()!=="none")i.load()}),t.on("loadedplaylist",()=>{if(i.playlist(t.media(),s),!n.paused())i.load()}),t.on("error",Y9[e](e,a))}},uD={AUDIO:(e,t)=>{let{vhs:a,sourceType:n,segmentLoaders:{[e]:s},requestOptions:i,main:{mediaGroups:f},mediaTypes:{[e]:{groups:l,tracks:c,logger_:h}},mainPlaylistLoader:u}=t,g=Rh(u.main);if(!f[e]||Object.keys(f[e]).length===0){if(f[e]={main:{default:{default:!0}}},g)f[e].main.default.playlists=u.main.playlists}for(let b in f[e]){if(!l[b])l[b]=[];for(let d in f[e][b]){let j=f[e][b][d],A;if(g)h(`AUDIO group '${b}' label '${d}' is a main playlist`),j.isMainPlaylist=!0,A=null;else if(n==="vhs-json"&&j.playlists)A=new Ar(j.playlists[0],a,i);else if(j.resolvedUri)A=new Ar(j.resolvedUri,a,i);else if(j.playlists&&n==="dash")A=new L9(j.playlists[0],a,i,u);else A=null;if(j=Vt({id:d,playlistLoader:A},j),Jd[e](e,j.playlistLoader,t),l[b].push(j),typeof c[d]>"u"){let C=new se.AudioTrack({id:d,kind:rD(j),enabled:!1,language:j.language,default:j.default,label:d});c[d]=C}}}s.on("error",Y9[e](e,t))},SUBTITLES:(e,t)=>{let{tech:a,vhs:n,sourceType:s,segmentLoaders:{[e]:i},requestOptions:f,main:{mediaGroups:l},mediaTypes:{[e]:{groups:c,tracks:h}},mainPlaylistLoader:u}=t;for(let g in l[e]){if(!c[g])c[g]=[];for(let b in l[e][g]){if(!n.options_.useForcedSubtitles&&l[e][g][b].forced)continue;let d=l[e][g][b],j;if(s==="hls")j=new Ar(d.resolvedUri,n,f);else if(s==="dash"){if(!d.playlists.filter((C)=>C.excludeUntil!==1/0).length)return;j=new L9(d.playlists[0],n,f,u)}else if(s==="vhs-json")j=new Ar(d.playlists?d.playlists[0]:d.resolvedUri,n,f);if(d=Vt({id:b,playlistLoader:j},d),Jd[e](e,d.playlistLoader,t),c[g].push(d),typeof h[b]>"u"){let A=a.addRemoteTextTrack({id:b,kind:"subtitles",default:d.default&&d.autoselect,language:d.language,label:b},!1).track;h[b]=A}}}i.on("error",Y9[e](e,t))},"CLOSED-CAPTIONS":(e,t)=>{let{tech:a,main:{mediaGroups:n},mediaTypes:{[e]:{groups:s,tracks:i}}}=t;for(let f in n[e]){if(!s[f])s[f]=[];for(let l in n[e][f]){let c=n[e][f][l];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;let h=a.options_.vhs&&a.options_.vhs.captionServices||{},u={label:l,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(h[u.instreamId])u=Vt(u,h[u.instreamId]);if(u.default===void 0)delete u.default;if(s[f].push(Vt({id:l},c)),typeof i[l]>"u"){let g=a.addRemoteTextTrack({id:u.instreamId,kind:"captions",default:u.default,language:u.language,label:u.label},!1).track;i[l]=g}}}}},ev=(e,t)=>{for(let a=0;a<e.length;a++){if(vg(t,e[a]))return!0;if(e[a].playlists&&ev(e[a].playlists,t))return!0}return!1},mD=(e,t)=>(a)=>{let{mainPlaylistLoader:n,mediaTypes:{[e]:{groups:s}}}=t,i=n.media();if(!i)return null;let f=null;if(i.attributes[e])f=s[i.attributes[e]];let l=Object.keys(s);if(!f){if(e==="AUDIO"&&l.length>1&&Rh(t.main))for(let c=0;c<l.length;c++){let h=s[l[c]];if(ev(h,i)){f=h;break}}else if(s.main)f=s.main;else if(l.length===1)f=s[l[0]]}if(typeof a>"u")return f;if(a===null||!f)return null;return f.filter((c)=>c.id===a.id)[0]||null},gD={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:{tracks:a}}}=t;for(let n in a)if(a[n].enabled)return a[n];return null},SUBTITLES:(e,t)=>()=>{let{mediaTypes:{[e]:{tracks:a}}}=t;for(let n in a)if(a[n].mode==="showing"||a[n].mode==="hidden")return a[n];return null}},pD=(e,{mediaTypes:t})=>()=>{let a=t[e].activeTrack();if(!a)return null;return t[e].activeGroup(a)},bD=(e)=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((h)=>{uD[h](h,e)});let{mediaTypes:t,mainPlaylistLoader:a,tech:n,vhs:s,segmentLoaders:{["AUDIO"]:i,main:f}}=e;["AUDIO","SUBTITLES"].forEach((h)=>{t[h].activeGroup=mD(h,e),t[h].activeTrack=gD[h](h,e),t[h].onGroupChanged=oD(h,e),t[h].onGroupChanging=cD(h,e),t[h].onTrackChanged=hD(h,e),t[h].getActiveGroup=pD(h,e)});let l=t.AUDIO.activeGroup();if(l){let h=(l.filter((g)=>g.default)[0]||l[0]).id;if(t.AUDIO.tracks[h].enabled=!0,t.AUDIO.onGroupChanged(),t.AUDIO.onTrackChanged(),!t.AUDIO.getActiveGroup().playlistLoader)f.setAudio(!0);else f.setAudio(!1),i.setAudio(!0)}a.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach((h)=>t[h].onGroupChanged())}),a.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach((h)=>t[h].onGroupChanging())});let c=()=>{t.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",c),n.remoteTextTracks().addEventListener("change",t.SUBTITLES.onTrackChanged),s.on("dispose",()=>{n.audioTracks().removeEventListener("change",c),n.remoteTextTracks().removeEventListener("change",t.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(let h in t.AUDIO.tracks)n.audioTracks().addTrack(t.AUDIO.tracks[h])},wD=()=>{let e={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((t)=>{e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ef,activeTrack:ef,getActiveGroup:ef,onGroupChanged:ef,onTrackChanged:ef,lastTrack_:null,logger_:gi(`MediaGroups[${t}]`)}}),e};class O4{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){if(e===1)this.version_=e}set ttl(e){this.ttl_=e||300}set reloadUri(e){if(e)this.reloadUri_=vs(this.reloadUri_,e)}set priority(e){if(e&&e.length)this.priority_=e}set pathwayClones(e){if(e&&e.length)this.pathwayClones_=new Map(e.map((t)=>[t.ID,t]))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class tv extends se.EventTarget{constructor(e,t){super();this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new O4,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=gi("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";let a=t.serverUri||t.serverURL;if(!a){this.logger_(`steering manifest URL is ${a}, cannot request steering manifest.`),this.trigger("error");return}if(a.startsWith("data:")){this.decodeDataUriManifest_(a.substring(a.indexOf(",")+1));return}if(this.steeringManifest.reloadUri=vs(e,a),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart)this.trigger("content-steering")}requestSteeringManifest(e){let t=this.steeringManifest.reloadUri;if(!t)return;let a=e?t:this.getRequestURI(t);if(!a){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}let n={contentSteeringInfo:{uri:a}};this.trigger({type:"contentsteeringloadstart",metadata:n}),this.request_=this.xhr_({uri:a,requestType:"content-steering-manifest"},(s,i)=>{if(s){if(i.status===410){this.logger_(`manifest request 410 ${s}.`),this.logger_(`There will be no more content steering requests to ${a} this session.`),this.excludedSteeringManifestURLs.add(a);return}if(i.status===429){let c=i.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${s}.`),this.logger_(`content steering will retry in ${c} seconds.`),this.startTTLTimeout_(parseInt(c,10));return}this.logger_(`manifest failed to load ${s}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:n});let f;try{f=JSON.parse(this.request_.responseText)}catch(c){let h={errorType:se.Error.StreamingContentSteeringParserError,error:c};this.trigger({type:"error",metadata:h})}this.assignSteeringProperties_(f);let l={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:l}),this.startTTLTimeout_()})}setProxyServerUrl_(e){let t=new V.default.URL(e),a=new V.default.URL(this.proxyServerUrl_);return a.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(a.toString())}decodeDataUriManifest_(e){let t=JSON.parse(V.default.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){let t=new V.default.URL(e),a=this.getPathway(),n=this.getBandwidth_();if(a){let s=`_${this.manifestType_}_pathway`;t.searchParams.set(s,a)}if(n){let s=`_${this.manifestType_}_throughput`;t.searchParams.set(s,n)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}if(this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,!this.availablePathways_.size)this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose();let a=((n)=>{for(let s of n)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);if(this.currentPathway!==a)this.currentPathway=a,this.trigger("content-steering")}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;let t=(n)=>this.excludedSteeringManifestURLs.has(n);if(this.proxyServerUrl_){let n=this.setProxyServerUrl_(e);if(!t(n))return n}let a=this.setSteeringParams_(e);if(!t(a))return a;return null}startTTLTimeout_(e=this.steeringManifest.ttl){let t=e*1000;this.ttlTimeout_=V.default.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){V.default.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){if(this.request_)this.request_.abort();this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new O4}addAvailablePathway(e){if(e)this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(vs(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}var dD=(e,t)=>{let a=null;return(...n)=>{clearTimeout(a),a=setTimeout(()=>{e.apply(null,n)},t)}},jD=10,W0,qD=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],vD=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},kD=function({currentPlaylist:e,buffered:t,currentTime:a,nextPlaylist:n,bufferLowWaterLine:s,bufferHighWaterLine:i,duration:f,bufferBasedABR:l,log:c}){if(!n)return se.log.warn("We received no playlist to switch to. Please check your stream."),!1;let h=`allowing switch ${e&&e.id||"null"} -> ${n.id}`;if(!e)return c(`${h} as current playlist is not set`),!0;if(n.id===e.id)return!1;let u=Boolean(eo(t,a).length);if(!e.endList){if(!u&&typeof e.partTargetDuration==="number")return c(`not ${h} as current playlist is live llhls, but currentTime isn't in buffered.`),!1;return c(`${h} as current playlist is live`),!0}let g=dg(t,a),b=l?jn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:jn.MAX_BUFFER_LOW_WATER_LINE;if(f<b)return c(`${h} as duration < max low water line (${f} < ${b})`),!0;let d=n.attributes.BANDWIDTH,j=e.attributes.BANDWIDTH;if(d<j&&(!l||g<i)){let A=`${h} as next bandwidth < current bandwidth (${d} < ${j})`;if(l)A+=` and forwardBuffer < bufferHighWaterLine (${g} < ${i})`;return c(A),!0}if((!l||d>j)&&g>=s){let A=`${h} as forwardBuffer >= bufferLowWaterLine (${g} >= ${s})`;if(l)A+=` and next bandwidth > current bandwidth (${d} > ${j})`;return c(A),!0}return c(`not ${h} as no switching criteria met`),!1};class av extends se.EventTarget{constructor(e){super();this.fastQualityChange_=dD(this.fastQualityChange_.bind(this),100);let{src:t,withCredentials:a,tech:n,bandwidth:s,externVhs:i,useCueTags:f,playlistExclusionDuration:l,enableLowInitialPlaylist:c,sourceType:h,cacheEncryptionKeys:u,bufferBasedABR:g,leastPixelDiffSelector:b,captionServices:d,experimentalUseMMS:j}=e;if(!t)throw Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:A}=e;if(A===null||typeof A>"u")A=1/0;if(W0=i,this.bufferBasedABR=Boolean(g),this.leastPixelDiffSelector=Boolean(b),this.withCredentials=a,this.tech_=n,this.vhs_=n.vhs,this.player_=e.player_,this.sourceType_=h,this.useCueTags_=f,this.playlistExclusionDuration=l,this.maxPlaylistRetries=A,this.enableLowInitialPlaylist=c,this.usingManagedMediaSource_=!1,this.useCueTags_)this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType="";if(this.requestOptions_={withCredentials:a,maxPlaylistRetries:A,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=wD(),j&&V.default.ManagedMediaSource)this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new V.default.ManagedMediaSource,this.usingManagedMediaSource_=!0,se.log("Using ManagedMediaSource");else if(V.default.MediaSource)this.mediaSource=new V.default.MediaSource;this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=qn(),this.hasPlayed_=!1,this.syncController_=new $q(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new lD,this.sourceUpdater_=new yg(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Wq,this.keyStatusMap_=new Map;let C={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:d,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:s,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:u,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new L9(t,this.vhs_,Vt(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Ar(t,this.vhs_,Vt(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new V9(Vt(C,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new V9(Vt(C,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new Qq(Vt(C,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((T,M)=>{function H(){n.off("vttjserror",N),T()}function N(){n.off("vttjsloaded",H),M()}n.one("vttjsloaded",H),n.one("vttjserror",N),n.addWebVttScript_()})}),e);let y=()=>{return this.mainSegmentLoader_.bandwidth};if(this.contentSteeringController_=new tv(this.vhs_.xhr,y),this.setupSegmentLoaderListeners_(),this.bufferBasedABR)this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_());if(qD.forEach((T)=>{this[T+"_"]=vD.bind(this,T)}),this.logger_=gi("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none")this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_);else this.mainPlaylistLoader_.load();this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;let O=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(O,()=>{let T=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-T,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){let e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();if(e===-1||t===-1)return-1;return e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){let t=this.selectPlaylist();if(t&&this.shouldSwitchToMedia_(t))this.switchMedia_(t,e)}switchMedia_(e,t,a){let n=this.media(),s=n&&(n.id||n.uri),i=e&&(e.id||e.uri);if(s&&s!==i){this.logger_(`switch media ${s} -> ${i} from ${t}`);let f={renditionInfo:{id:i,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:f}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,a)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((e)=>{let t=this.mediaTypes_[e],a=t?t.activeGroup():null,n=this.contentSteeringController_.getPathway();if(a&&n){let i=(a.length?a[0].playlists:a.playlists).filter((f)=>f.attributes.serviceLocation===n);if(i.length)this.mediaTypes_[e].activePlaylistLoader.media(i[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=V.default.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){if(this.tech_.scrubbing&&this.tech_.scrubbing())return;V.default.clearInterval(this.abrTimer_),this.abrTimer_=null}getAudioTrackPlaylists_(){let e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;let a=e.mediaGroups.AUDIO,n=Object.keys(a),s;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)s=this.mediaTypes_.AUDIO.activeTrack();else{let f=a.main||n.length&&a[n[0]];for(let l in f)if(f[l].default){s={label:l};break}}if(!s)return t;let i=[];for(let f in a)if(a[f][s.label]){let l=a[f][s.label];if(l.playlists&&l.playlists.length)i.push.apply(i,l.playlists);else if(l.uri)i.push(l);else if(e.playlists.length)for(let c=0;c<e.playlists.length;c++){let h=e.playlists[c];if(h.attributes&&h.attributes.AUDIO&&h.attributes.AUDIO===f)i.push(h)}}if(!i.length)return t;return i}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{let t=this.mainPlaylistLoader_.media(),a=t.targetDuration*1.5*1000;if(w4(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media()))this.requestOptions_.timeout=0;else this.requestOptions_.timeout=a;if(t.endList&&this.tech_.preload()!=="none")this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.mainSegmentLoader_.load();if(bD({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),t),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media())this.trigger("selectedinitialmedia");else this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{if(this.loadOnPlay_)this.tech_.off("play",this.loadOnPlay_);let t=this.mainPlaylistLoader_.media();if(!t){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let a;if(this.enableLowInitialPlaylist)a=this.selectInitialPlaylist();if(!a)a=this.selectPlaylist();if(!a||!this.shouldSwitchToMedia_(a))return;if(this.initialMedia_=a,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{let t=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{let t=this.mainPlaylistLoader_.media(),a=t.targetDuration*1.5*1000;if(w4(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media()))this.requestOptions_.timeout=0;else this.requestOptions_.timeout=a;if(this.sourceType_==="dash"){if(this.mainPlaylistLoader_.isPaused)this.mainPlaylistLoader_.load()}if(this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_)this.runFastQualitySwitch_();else this.mainSegmentLoader_.load();this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{let t=this.mainPlaylistLoader_.media();if(t.lastExcludeReason_==="playlist-unchanged")return;if(this.stuckAtPlaylistEnd_(t))this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck")}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach((t)=>{this.mainPlaylistLoader_.on(t,(a)=>{this.player_.trigger(Fa({},a))})})}handleUpdatedMediaPlaylist(e){if(this.useCueTags_)this.updateAdCues_(e);if(this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_)this.runFastQualitySwitch_();if(this.updateDuration(!e.endList),!this.tech_.paused()){if(this.mainSegmentLoader_.load(),this.audioSegmentLoader_)this.audioSegmentLoader_.load()}}triggerPresenceUsage_(e,t){let a=e.mediaGroups||{},n=!0,s=Object.keys(a.AUDIO);for(let i in a.AUDIO)for(let f in a.AUDIO[i])if(!a.AUDIO[i][f].uri)n=!1;if(n)this.tech_.trigger({type:"usage",name:"vhs-demuxed"});if(Object.keys(a.SUBTITLES).length)this.tech_.trigger({type:"usage",name:"vhs-webvtt"});if(W0.Playlist.isAes(t))this.tech_.trigger({type:"usage",name:"vhs-aes"});if(s.length&&Object.keys(a.AUDIO[s[0]]).length>1)this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"});if(this.useCueTags_)this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){let t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,a=this.tech_.currentTime(),n=this.bufferLowWaterLine(),s=this.bufferHighWaterLine(),i=this.tech_.buffered();return kD({buffered:i,currentTime:a,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:s,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){if(this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{if(this.bufferBasedABR)this.mainSegmentLoader_.load()}),!this.bufferBasedABR)this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")});this.mainSegmentLoader_.on("error",()=>{let a=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:a.playlist,error:a})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{let a=this.audioSegmentLoader_.pendingSegment_;if(!a||!a.segment||!a.segment.syncInfo)return;let n=a.segment.syncInfo.end+0.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{if(this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader)this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything();if(this.mediaTypes_.SUBTITLES.activePlaylistLoader)this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything();this.load()}),this.mainSegmentLoader_.on("earlyabort",(a)=>{if(this.bufferBasedABR)return;this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:jD})});let e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();let a=this.getCodecsOrExclude_();if(!a)return;this.sourceUpdater_.addOrChangeSourceBuffers(a)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{if(!this.triggeredFmp4Usage)this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0}),this.audioSegmentLoader_.on("fmp4",()=>{if(!this.triggeredFmp4Usage)this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach((a)=>{this.mainSegmentLoader_.on(a,(n)=>{this.player_.trigger(Fa({},n))}),this.audioSegmentLoader_.on(a,(n)=>{this.player_.trigger(Fa({},n))}),this.subtitleSegmentLoader_.on(a,(n)=>{this.player_.trigger(Fa({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){if(this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader)this.audioSegmentLoader_.load();if(this.mediaTypes_.SUBTITLES.activePlaylistLoader)this.subtitleSegmentLoader_.load()}pause(){if(this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader)this.audioSegmentLoader_.pause();if(this.mediaTypes_.SUBTITLES.activePlaylistLoader)this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){if(this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader)this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything();if(this.mediaTypes_.SUBTITLES.activePlaylistLoader)this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything();this.load()}play(){if(this.setupFirstPlay())return;if(this.tech_.ended())this.tech_.setCurrentTime(0);if(this.hasPlayed_)this.load();let e=this.tech_.seekable();if(this.tech_.duration()===1/0){if(this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}}setupFirstPlay(){let e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){let t=this.seekable();if(!t.length)return!1;let a=t.end(0),n=a;if(e.start){let s=e.start.timeOffset;if(s<0){let i=this.mainPlaylistLoader_.main,f=W0.Playlist.liveEdgeDelay(i,e),l=a+f;n=Math.max(Math.min(l+s,a),t.start(0))}else n=Math.min(a,s)}this.trigger("firstplay"),this.tech_.setCurrentTime(n)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){let e=this.tech_.play();if(typeof e<"u"&&typeof e.then==="function")e.then(null,(t)=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;let e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;let t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){let t=this.mainSegmentLoader_.getCurrentMediaInfo_();if(!t||t.hasVideo)e=e&&this.audioSegmentLoader_.ended_;else e=this.audioSegmentLoader_.ended_}if(!e)return;this.stopABRTimer_(),this.sourceUpdater_.endOfStream()}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;let a=this.syncController_.getExpiredTime(e,this.duration());if(a===null)return!1;let n=W0.Playlist.playlistEnd(e,a),s=this.tech_.currentTime(),i=this.tech_.buffered();if(!i.length)return n-s<=f0;let f=i.end(i.length-1);return f-s<=f0&&n-f<=f0}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:a}){if(e=e||this.mainPlaylistLoader_.media(),a=a||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){if(this.error=t,this.mediaSource.readyState!=="open")this.trigger("error");else this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;let n=this.mainPlaylistLoader_.main.playlists,s=n.filter(Sm),i=s.length===1&&s[0]===e;if(n.length===1&&a!==1/0)return se.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(i);if(i){if(this.main().contentSteering){let d=this.pathwayAttribute_(e),j=this.contentSteeringController_.steeringManifest.ttl*1000;this.contentSteeringController_.excludePathway(d),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(d)},j);return}let b=!1;if(n.forEach((d)=>{if(d===e)return;let j=d.excludeUntil;if(typeof j<"u"&&j!==1/0)b=!0,delete d.excludeUntil}),b)se.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist")}let f;if(e.playlistErrors_>this.maxPlaylistRetries)f=1/0;else f=Date.now()+a*1000;if(e.excludeUntil=f,t.reason)e.lastExcludeReason_=t.reason;this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});let l=this.selectPlaylist();if(!l){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}let c=t.internal?this.logger_:se.log.warn,h=t.message?" "+t.message:"";if(c(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${h} Switching to playlist ${l.id}.`),l.attributes.AUDIO!==e.attributes.AUDIO)this.delegateLoaders_("audio",["abort","pause"]);if(l.attributes.SUBTITLES!==e.attributes.SUBTITLES)this.delegateLoaders_("subtitle",["abort","pause"]);this.delegateLoaders_("main",["abort","pause"]);let u=l.targetDuration/2*1000||5000,g=typeof l.lastRequest==="number"&&Date.now()-l.lastRequest<=u;return this.switchMedia_(l,"exclude",i||g)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){let a=[],n=e==="all";if(n||e==="main")a.push(this.mainPlaylistLoader_);let s=[];if(n||e==="audio")s.push("AUDIO");if(n||e==="subtitle")s.push("CLOSED-CAPTIONS"),s.push("SUBTITLES");s.forEach((i)=>{let f=this.mediaTypes_[i]&&this.mediaTypes_[i].activePlaylistLoader;if(f)a.push(f)}),["main","audio","subtitle"].forEach((i)=>{let f=this[`${i}SegmentLoader_`];if(f&&(e===i||e==="all"))a.push(f)}),a.forEach((i)=>t.forEach((f)=>{if(typeof i[f]==="function")i[f]()}))}setCurrentTime(e){let t=eo(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media()))return 0;if(!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;if(this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader)this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything();if(this.mediaTypes_.SUBTITLES.activePlaylistLoader)this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything();this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;let e=this.mainPlaylistLoader_.media();if(!e)return 0;if(!e.endList)return 1/0;if(this.mediaSource)return this.mediaSource.duration;return W0.Playlist.duration(e)}seekable(){return this.seekable_}getSeekableRange_(e,t){let a=e.media();if(!a)return null;let n=this.syncController_.getMediaSequenceSync(t);if(n&&n.isReliable){let{start:f,end:l}=n;if(!isFinite(f)||!isFinite(l))return null;let c=W0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,a),h=Math.max(f,l-c);return qn([[f,h]])}let s=this.syncController_.getExpiredTime(a,this.duration());if(s===null)return null;let i=W0.Playlist.seekable(a,s,W0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,a));return i.length?i:null}computeFinalSeekable_(e,t){if(!t)return e;let a=e.start(0),n=e.end(0),s=t.start(0),i=t.end(0);if(s>n||a>i)return e;return qn([[Math.max(a,s),Math.min(n,i)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;let e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t)return}let a=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_)return;if(a&&a.length&&this.seekable_.length){if(a.start(0)===this.seekable_.start(0)&&a.end(0)===this.seekable_.end(0))return}this.logger_(`seekable updated [${lq(this.seekable_)}]`);let n={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:n}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_)this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null;if(this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){let n=this.seekable();if(!n.length)return;if(isNaN(this.mediaSource.duration)||this.mediaSource.duration<n.end(n.length-1))this.sourceUpdater_.setDuration(n.end(n.length-1));return}let t=this.tech_.buffered(),a=W0.Playlist.duration(this.mainPlaylistLoader_.media());if(t.length>0)a=Math.max(a,t.end(t.length-1));if(this.mediaSource.duration!==a)this.sourceUpdater_.setDuration(a)}dispose(){if(this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_)this.tech_.off("play",this.loadOnPlay_);if(["AUDIO","SUBTITLES"].forEach((e)=>{let t=this.mediaTypes_[e].groups;for(let a in t)t[a].forEach((n)=>{if(n.playlistLoader)n.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_)this.mediaSource.removeEventListener("sourceopen",this.updateDuration_);this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){let e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),a=!e?!0:!!this.audioSegmentLoader_.getCurrentMediaInfo_();if(!t||!a)return!1;return!0}getCodecsOrExclude_(){let e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;let a=_h(this.main(),t),n={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo)n.video=a.video||e.main.videoCodec||Ob;if(e.main.isMuxed)n.video+=`,${a.audio||e.main.audioCodec||o6}`;if(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)n.audio=a.audio||e.main.audioCodec||e.audio.audioCodec||o6,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4;if(!n.audio&&!n.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}let i=(c,h)=>c?E1(h,this.usingManagedMediaSource_):s9(h),f={},l;if(["video","audio"].forEach(function(c){if(n.hasOwnProperty(c)&&!i(e[c].isFmp4,n[c])){let h=e[c].isFmp4?"browser":"muxer";if(f[h]=f[h]||[],f[h].push(n[c]),c==="audio")l=h}}),s&&l&&t.attributes.AUDIO){let c=t.attributes.AUDIO;this.main().playlists.forEach((h)=>{if((h.attributes&&h.attributes.AUDIO)===c&&h!==t)h.excludeUntil=1/0}),this.logger_(`excluding audio group ${c} as ${l} does not support codec(s): "${n.audio}"`)}if(Object.keys(f).length){let c=Object.keys(f).reduce((h,u)=>{if(h)h+=", ";return h+=`${u} does not support codec(s): "${f[u].join(",")}"`,h},"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:c},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){let c=[];if(["video","audio"].forEach((h)=>{let u=(Ti(this.sourceUpdater_.codecs[h]||"")[0]||{}).type,g=(Ti(n[h]||"")[0]||{}).type;if(u&&g&&u.toLowerCase()!==g.toLowerCase())c.push(`"${this.sourceUpdater_.codecs[h]}" -> "${n[h]}"`)}),c.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${c.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return n}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers())return;if(!this.areMediaTypesKnown_())return;let e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);let t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){let e=this.main().playlists,t=[];Object.keys(e).forEach((a)=>{let n=e[a];if(t.indexOf(n.id)!==-1)return;t.push(n.id);let s=_h(this.main,n),i=[];if(s.audio&&!s9(s.audio)&&!E1(s.audio,this.usingManagedMediaSource_))i.push(`audio codec ${s.audio}`);if(s.video&&!s9(s.video)&&!E1(s.video,this.usingManagedMediaSource_))i.push(`video codec ${s.video}`);if(s.text&&s.text==="stpp.ttml.im1t")i.push(`text codec ${s.text}`);if(i.length)n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${i.join(", ")}`)})}excludeIncompatibleVariants_(e){let t=[],a=this.main().playlists,n=Hh(Ti(e)),s=Md(n),i=n.video&&Ti(n.video)[0]||null,f=n.audio&&Ti(n.audio)[0]||null;Object.keys(a).forEach((l)=>{let c=a[l];if(t.indexOf(c.id)!==-1||c.excludeUntil===1/0)return;t.push(c.id);let h=[],u=_h(this.mainPlaylistLoader_.main,c),g=Md(u);if(!u.audio&&!u.video)return;if(g!==s)h.push(`codec count "${g}" !== "${s}"`);if(!this.sourceUpdater_.canChangeType()){let b=u.video&&Ti(u.video)[0]||null,d=u.audio&&Ti(u.audio)[0]||null;if(b&&i&&b.type.toLowerCase()!==i.type.toLowerCase())h.push(`video codec "${b.type}" !== "${i.type}"`);if(d&&f&&d.type.toLowerCase()!==f.type.toLowerCase())h.push(`audio codec "${d.type}" !== "${f.type}"`)}if(h.length)c.excludeUntil=1/0,this.logger_(`excluding ${c.id}: ${h.join(" && ")}`)})}updateAdCues_(e){let t=0,a=this.seekable();if(a.length)t=a.start(0);sD(e,this.cueTagsTrack_,t)}goalBufferLength(){let e=this.tech_.currentTime(),t=jn.GOAL_BUFFER_LENGTH,a=jn.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,jn.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*a,n)}bufferLowWaterLine(){let e=this.tech_.currentTime(),t=jn.BUFFER_LOW_WATER_LINE,a=jn.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,jn.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(t,jn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*a,this.bufferBasedABR?s:n)}bufferHighWaterLine(){return jn.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){Id(this.inbandTextTracks_,"com.apple.streaming",this.tech_),zM({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,a){let n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();Id(this.inbandTextTracks_,e,this.tech_),RM({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:a})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){let e=this.main();if(!e.contentSteering)return;for(let t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){if(this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach((t)=>{this.contentSteeringController_.on(t,(a)=>{this.trigger(Fa({},a))})}),this.sourceType_==="dash")this.mainPlaylistLoader_.on("loadedplaylist",()=>{let t=this.main();if(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{let s=this.contentSteeringController_.getAvailablePathways(),i=[];for(let f of t.playlists){let l=f.attributes.serviceLocation;if(l){if(i.push(l),!s.has(l))return!0}}if(!i.length&&s.size)return!0;return!1})())this.resetContentSteeringController_()})}excludeThenChangePathway_(){let e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();let a=this.main().playlists,n=new Set,s=!1;if(Object.keys(a).forEach((i)=>{let f=a[i],l=this.pathwayAttribute_(f),c=l&&e!==l;if(f.excludeUntil===1/0&&f.lastExcludeReason_==="content-steering"&&!c)delete f.excludeUntil,delete f.lastExcludeReason_,s=!0;let u=!f.excludeUntil&&f.excludeUntil!==1/0;if(!(!n.has(f.id)&&c&&u))return;n.add(f.id),f.excludeUntil=1/0,f.lastExcludeReason_="content-steering",this.logger_(`excluding ${f.id} for ${f.lastExcludeReason_}`)}),this.contentSteeringController_.manifestType_==="DASH")Object.keys(this.mediaTypes_).forEach((i)=>{let f=this.mediaTypes_[i];if(f.activePlaylistLoader){let l=f.activePlaylistLoader.media_;if(l&&l.attributes.serviceLocation!==e)s=!0}});if(s)this.changeSegmentPathway_()}handlePathwayClones_(){let t=this.main().playlists,a=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(!(a&&a.size||n&&n.size))return;for(let[i,f]of a.entries())if(!n.get(i))this.mainPlaylistLoader_.updateOrDeleteClone(f),this.contentSteeringController_.excludePathway(i);for(let[i,f]of n.entries()){let l=a.get(i);if(!l){t.filter((h)=>{return h.attributes["PATHWAY-ID"]===f["BASE-ID"]}).forEach((h)=>{this.mainPlaylistLoader_.addClonePathway(f,h)}),this.contentSteeringController_.addAvailablePathway(i);continue}if(this.equalPathwayClones_(l,f))continue;this.mainPlaylistLoader_.updateOrDeleteClone(f,!0),this.contentSteeringController_.addAvailablePathway(i)}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;let a=e["URI-REPLACEMENT"].PARAMS,n=t["URI-REPLACEMENT"].PARAMS;for(let s in a)if(a[s]!==n[s])return!1;for(let s in n)if(a[s]!==n[s])return!1;return!0}changeSegmentPathway_(){let e=this.selectPlaylist();if(this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH")this.switchMediaForDASHContentSteering_();this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0,t="non-usable";if(this.mainPlaylistLoader_.main.playlists.forEach((a)=>{let n=this.mainPlaylistLoader_.getKeyIdSet(a);if(!n||!n.size)return;n.forEach((s)=>{let f=this.keyStatusMap_.has(s)&&this.keyStatusMap_.get(s)==="usable",l=a.lastExcludeReason_===t&&a.excludeUntil===1/0;if(!f){if(a.excludeUntil!==1/0&&a.lastExcludeReason_!==t)a.excludeUntil=1/0,a.lastExcludeReason_=t,this.logger_(`excluding playlist ${a.id} because the key ID ${s} doesn't exist in the keyStatusMap or is not usable`);e++}else if(f&&l)delete a.excludeUntil,delete a.lastExcludeReason_,this.logger_(`enabling playlist ${a.id} because key ID ${s} is usable`)})}),e>=this.mainPlaylistLoader_.main.playlists.length)this.mainPlaylistLoader_.main.playlists.forEach((a)=>{let n=a&&a.attributes&&a.attributes.RESOLUTION&&a.attributes.RESOLUTION.height<720,s=a.excludeUntil===1/0&&a.lastExcludeReason_===t;if(n&&s)delete a.excludeUntil,se.log.warn(`enabling non-HD playlist ${a.id} because all playlists were excluded due to ${t} key IDs`)})}addKeyStatus_(e,t){let s=(typeof e==="string"?e:aD(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${s} added to the keyStatusMap`),this.keyStatusMap_.set(s,t)}updatePlaylistByKeyStatus(e,t){if(this.addKeyStatus_(e,t),!this.waitingForFastQualityPlaylistReceived_)this.excludeNonUsableThenChangePlaylist_();this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}var AD=(e,t,a)=>(n)=>{let s=e.main.playlists[t],i=qg(s),f=Sm(s);if(typeof n>"u")return f;if(n)delete s.disabled;else s.disabled=!0;let l={renditionInfo:{id:t,bandwidth:s.attributes.BANDWIDTH,resolution:s.attributes.RESOLUTION,codecs:s.attributes.CODECS},cause:"fast-quality"};if(n!==f&&!i)if(n)a(s),e.trigger({type:"renditionenabled",metadata:l});else e.trigger({type:"renditiondisabled",metadata:l});return n};class nv{constructor(e,t,a){let{playlistController_:n}=e,s=n.fastQualityChange_.bind(n);if(t.attributes){let i=t.attributes.RESOLUTION;this.width=i&&i.width,this.height=i&&i.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=_h(n.main(),t),this.playlist=t,this.id=a,this.enabled=AD(e.playlists,t.id,s)}}var yD=function(e){e.representations=()=>{let t=e.playlistController_.main(),a=Rh(t)?e.playlistController_.getAudioTrackPlaylists_():t.playlists;if(!a)return[];return a.filter((n)=>!qg(n)).map((n,s)=>new nv(e,n,n.id))}},Qd=["seeking","seeked","pause","playing","error"];class sv extends se.EventTarget{constructor(e){super();this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=gi("PlaybackWatcher"),this.logger_("initialize");let t=()=>this.monitorCurrentTime_(),a=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),i=this.playlistController_,f=["main","subtitle","audio"],l={};f.forEach((h)=>{l[h]={reset:()=>this.resetSegmentDownloads_(h),updateend:()=>this.checkSegmentDownloads_(h)},i[`${h}SegmentLoader_`].on("appendsdone",l[h].updateend),i[`${h}SegmentLoader_`].on("playlistupdate",l[h].reset),this.tech_.on(["seeked","seeking"],l[h].reset)});let c=(h)=>{["main","audio"].forEach((u)=>{i[`${u}SegmentLoader_`][h]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{if(this.fixesBadSeeks_())this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),c("off")},this.clearSeekingAppendCheck_=()=>c("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),c("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",n),this.tech_.on(Qd,s),this.tech_.on("canplay",a),this.tech_.one("play",t),this.dispose=()=>{if(this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",n),this.tech_.off(Qd,s),this.tech_.off("canplay",a),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),f.forEach((h)=>{i[`${h}SegmentLoader_`].off("appendsdone",l[h].updateend),i[`${h}SegmentLoader_`].off("playlistupdate",l[h].reset),this.tech_.off(["seeked","seeking"],l[h].reset)}),this.checkCurrentTimeTimeout_)V.default.clearTimeout(this.checkCurrentTimeTimeout_);this.resetTimeUpdate_()}}monitorCurrentTime_(){if(this.checkCurrentTime_(),this.checkCurrentTimeTimeout_)V.default.clearTimeout(this.checkCurrentTimeTimeout_);this.checkCurrentTimeTimeout_=V.default.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){let t=this.playlistController_[`${e}SegmentLoader_`];if(this[`${e}StalledDownloads_`]>0)this.logger_(`resetting possible stalled download count for ${e} loader`);this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){let t=this.playlistController_,a=t[`${e}SegmentLoader_`],n=a.buffered_(),s=dH(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,s){let i={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:i}),this.resetSegmentDownloads_(e);return}if(this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:a.playlist_&&a.playlist_.id,buffered:kr(n)}),this[`${e}StalledDownloads_`]<10)return;if(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e==="subtitle")return;t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0})}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;let e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+f0>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(qn([this.lastRecordedTime,e]));let a={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:a}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;let t=this.seekable(),a=this.tech_.currentTime(),n=this.afterSeekableWindow_(t,a,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s;if(n)s=t.end(t.length-1);if(this.beforeSeekableWindow_(t,a)){let d=t.start(0);s=d+(d===t.end(0)?0:f0)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${a} with seekable range ${lq(t)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;let i=this.playlistController_.sourceUpdater_,f=this.tech_.buffered(),l=i.audioBuffer?i.audioBuffered():null,c=i.videoBuffer?i.videoBuffered():null,h=this.media(),u=h.partTargetDuration?h.partTargetDuration:(h.targetDuration-i0)*2,g=[l,c];for(let d=0;d<g.length;d++){if(!g[d])continue;if(dg(g[d],a)<u)return!1}let b=k9(f,a);if(b.length===0)return!1;return s=b.start(0)+f0,this.logger_(`Buffered region starts (${b.start(0)}) just beyond seek point (${a}). Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0}waiting_(){if(this.techWaiting_())return;let e=this.tech_.currentTime(),t=this.tech_.buffered(),a=eo(t,e);if(a.length&&e+3<=a.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${a.start(0)} -> ${a.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){let e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){let f=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${f}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(f),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}let a=this.tech_.vhs.playlistController_.sourceUpdater_,n=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:a.audioBuffered(),videoBuffered:a.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;let i=k9(n,t);if(i.length>0)return this.logger_(`Stopped at ${t} and seeking to ${i.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0;return!1}afterSeekableWindow_(e,t,a,n=!1){if(!e.length)return!1;let s=e.end(e.length-1)+f0,i=!a.endList,f=typeof a.partTargetDuration==="number";if(i&&(f||n))s=e.end(e.length-1)+a.targetDuration*3;if(t>s)return!0;return!1}beforeSeekableWindow_(e,t){if(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)return!0;return!1}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:a}){if(!e)return;let n;if(e.length&&t.length){let s=eo(e,a-3),i=eo(e,a),f=eo(t,a);if(f.length&&!i.length&&s.length)n={start:s.end(0),end:f.end(0)}}else if(!k9(e,a).length)n=this.gapFromVideoUnderflow_(e,a);if(n)return this.logger_(`Encountered a gap in video from ${n.start} to ${n.end}. Seeking to current time ${a}`),!0;return!1}skipTheGap_(e){let t=this.tech_.buffered(),a=this.tech_.currentTime(),n=k9(t,a);if(this.resetTimeUpdate_(),n.length===0||a!==e)return;this.logger_("skipTheGap_:","currentTime:",a,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+i0);let s={gapInfo:{from:a,to:n.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:s}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){let a=pH(e);for(let n=0;n<a.length;n++){let s=a.start(n),i=a.end(n);if(t-s<4&&t-s>2)return{start:s,end:i}}return null}}var SD={errorInterval:30,getSource(e){let a=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return e(a)}},iv=function(e,t){let a=0,n=0,s=Vt(SD,t);e.ready(()=>{e.trigger({type:"usage",name:"vhs-error-reload-initialized"})});let i=function(){if(n)e.currentTime(n)},f=function(u){if(u===null||u===void 0)return;n=e.duration()!==1/0&&e.currentTime()||0,e.one("loadedmetadata",i),e.src(u),e.trigger({type:"usage",name:"vhs-error-reload"}),e.play()},l=function(){if(Date.now()-a<s.errorInterval*1000){e.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!s.getSource||typeof s.getSource!=="function"){se.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return a=Date.now(),s.getSource.call(e,f)},c=function(){e.off("loadedmetadata",i),e.off("error",l),e.off("dispose",c)},h=function(u){c(),iv(e,u)};e.on("error",l),e.on("dispose",c),e.reloadSourceOnError=h},CD=function(e){iv(this,e)},fv="3.17.3",_D="7.1.0",FD="1.3.1",OD="7.2.0",BD="4.0.2",Oa={PlaylistLoader:Ar,Playlist:ks,utils:KH,STANDARD_PLAYLIST_SELECTOR:Ud,INITIAL_PLAYLIST_SELECTOR:TM,lastBandwidthSelector:Ud,movingAverageBandwidthSelector:OM,comparePlaylistBandwidth:Ag,comparePlaylistResolution:FM,xhr:Cq()};Object.keys(jn).forEach((e)=>{Object.defineProperty(Oa,e,{get(){return se.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),jn[e]},set(t){if(se.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),typeof t!=="number"||t<0){se.log.warn(`value of Vhs.${e} must be greater than or equal to 0`);return}jn[e]=t}})});var lv="videojs-vhs",rv=function(e,t){let a=t.media(),n=-1;for(let s=0;s<e.length;s++)if(e[s].id===a.id){n=s;break}e.selectedIndex_=n,e.trigger({selectedIndex:n,type:"change"})},TD=function(e,t){t.representations().forEach((a)=>{e.addQualityLevel(a)}),rv(e,t.playlists)};Oa.canPlaySource=function(){return se.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};var HD=(e,t,a)=>{if(!e)return e;let n={};if(t&&t.attributes&&t.attributes.CODECS)n=Hh(Ti(t.attributes.CODECS));if(a&&a.attributes&&a.attributes.CODECS)n.audio=a.attributes.CODECS;let s=br(n.video),i=br(n.audio),f={};for(let l in e){if(f[l]={},i)f[l].audioContentType=i;if(s)f[l].videoContentType=s;if(t.contentProtection&&t.contentProtection[l]&&t.contentProtection[l].pssh)f[l].pssh=t.contentProtection[l].pssh;if(typeof e[l]==="string")f[l].url=e[l]}return Vt(e,f)},MD=(e,t)=>{return e.reduce((a,n)=>{if(!n.contentProtection)return a;let s=t.reduce((i,f)=>{let l=n.contentProtection[f];if(l&&l.pssh)i[f]={pssh:l.pssh};return i},{});if(Object.keys(s).length)a.push(s);return a},[])},DD=({player:e,sourceKeySystems:t,audioMedia:a,mainPlaylists:n})=>{if(!e.eme.initializeMediaKeys)return Promise.resolve();let s=a?n.concat([a]):n,i=MD(s,Object.keys(t)),f=[],l=[];return i.forEach((c)=>{l.push(new Promise((h,u)=>{e.tech_.one("keysessioncreated",h)})),f.push(new Promise((h,u)=>{e.eme.initializeMediaKeys({keySystems:c},(g)=>{if(g){u(g);return}h()})}))}),Promise.race([Promise.all(f),Promise.race(l)])},xD=({player:e,sourceKeySystems:t,media:a,audioMedia:n})=>{let s=HD(t,a,n);if(!s)return!1;if(e.currentSource().keySystems=s,s&&!e.eme)return se.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1;return!0},ov=()=>{if(!V.default.localStorage)return null;let e=V.default.localStorage.getItem(lv);if(!e)return null;try{return JSON.parse(e)}catch(t){return null}},RD=(e)=>{if(!V.default.localStorage)return!1;let t=ov();t=t?Vt(t,e):e;try{V.default.localStorage.setItem(lv,JSON.stringify(t))}catch(a){return!1}return t},ND=(e)=>{if(e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0)return JSON.parse(e.substring(e.indexOf(",")+1));return e},cv=(e,t)=>{if(!e._requestCallbackSet)e._requestCallbackSet=new Set;e._requestCallbackSet.add(t)},hv=(e,t)=>{if(!e._responseCallbackSet)e._responseCallbackSet=new Set;e._responseCallbackSet.add(t)},uv=(e,t)=>{if(!e._requestCallbackSet)return;if(e._requestCallbackSet.delete(t),!e._requestCallbackSet.size)delete e._requestCallbackSet},mv=(e,t)=>{if(!e._responseCallbackSet)return;if(e._responseCallbackSet.delete(t),!e._responseCallbackSet.size)delete e._responseCallbackSet};Oa.supportsNativeHls=function(){if(!ye.default||!ye.default.createElement)return!1;let e=ye.default.createElement("video");if(!se.getTech("Html5").isSupported())return!1;return["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(a){return/maybe|probably/i.test(e.canPlayType(a))})}();Oa.supportsNativeDash=function(){if(!ye.default||!ye.default.createElement||!se.getTech("Html5").isSupported())return!1;return/maybe|probably/i.test(ye.default.createElement("video").canPlayType("application/dash+xml"))}();Oa.supportsTypeNatively=(e)=>{if(e==="hls")return Oa.supportsNativeHls;if(e==="dash")return Oa.supportsNativeDash;return!1};Oa.isSupported=function(){return se.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Oa.xhr.onRequest=function(e){cv(Oa.xhr,e)};Oa.xhr.onResponse=function(e){hv(Oa.xhr,e)};Oa.xhr.offRequest=function(e){uv(Oa.xhr,e)};Oa.xhr.offResponse=function(e){mv(Oa.xhr,e)};var ED=se.getComponent("Component");class Cg extends ED{constructor(e,t,a){super(t,a.vhs);if(typeof a.initialBandwidth==="number")this.options_.bandwidth=a.initialBandwidth;if(this.logger_=gi("VhsHandler"),t.options_&&t.options_.playerId){let n=se.getPlayer(t.options_.playerId);this.player_=n}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(ye.default,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(n)=>{let s=ye.default.fullscreenElement||ye.default.webkitFullscreenElement||ye.default.mozFullScreenElement||ye.default.msFullscreenElement;if(s&&s.contains(this.tech_.el()))this.playlistController_.fastQualityChange_();else this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){if(this.tech_.error()&&this.playlistController_)this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=Vt(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions===!1?!1:!0,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=typeof this.options_.useNetworkInformationApi<"u"?this.options_.useNetworkInformationApi:!0,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls===!1?!1:!0,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!=="number")this.options_.playlistExclusionDuration=60;if(typeof this.options_.bandwidth!=="number"){if(this.options_.useBandwidthFromLocalStorage){let a=ov();if(a&&a.bandwidth)this.options_.bandwidth=a.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"});if(a&&a.throughput)this.options_.throughput=a.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"})}}if(typeof this.options_.bandwidth!=="number")this.options_.bandwidth=jn.INITIAL_BANDWIDTH;this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===jn.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","usePlayerObjectFit","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach((a)=>{if(typeof this.source_[a]<"u")this.options_[a]=this.source_[a]}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;let t=this.options_.customPixelRatio;if(typeof t==="number"&&t>=0)this.customPixelRatio=t}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=ND(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Oa,this.options_.sourceType=c6(t),this.options_.seekTo=(s)=>{this.tech_.setCurrentTime(s)},this.options_.player_=this.player_,this.playlistController_=new av(this.options_);let a=Vt({liveRangeSafeTimeDelta:f0},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new sv(a),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{let s=se.players[this.tech_.options_.playerId],i=this.playlistController_.error;if(typeof i==="object"&&!i.code)i.code=3;else if(typeof i==="string")i={message:i,code:3};s.error(i)});let n=this.options_.bufferBasedABR?Oa.movingAverageBandwidthSelector(0.55):Oa.STANDARD_PLAYLIST_SELECTOR;if(this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Oa.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(s){this.playlistController_.selectPlaylist=s.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(s){this.playlistController_.mainSegmentLoader_.throughput.rate=s,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let s=this.playlistController_.mainSegmentLoader_.bandwidth,i=V.default.navigator.connection||V.default.navigator.mozConnection||V.default.navigator.webkitConnection,f=1e7;if(this.options_.useNetworkInformationApi&&i){let l=i.downlink*1000*1000;if(l>=f&&s>=f)s=Math.max(s,l);else s=l}return s},set(s){this.playlistController_.mainSegmentLoader_.bandwidth=s,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){let s=1/(this.bandwidth||1),i;if(this.throughput>0)i=1/this.throughput;else i=0;return Math.floor(1/(s+i))},set(){se.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth)this.bandwidth=this.options_.bandwidth;if(this.options_.throughput)this.throughput=this.options_.throughput;if(Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>kr(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>kr(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{if(this.options_.useBandwidthFromLocalStorage)RD({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{yD(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),!this.tech_.el())return;if(this.mediaSourceUrl_=V.default.URL.createObjectURL(this.playlistController_.mediaSource),(se.browser.IS_ANY_SAFARI||se.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement==="function")this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src);else this.tech_.src(this.mediaSourceUrl_)}createKeySessions_(){let e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),DD({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch((t)=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){let e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=xD({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",(a)=>{this.playlistController_.updatePlaylistByKeyStatus(a.keyId,a.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){let e=se.players[this.tech_.options_.playerId];if(!e||!e.qualityLevels||this.qualityLevels_)return;this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{TD(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{rv(this.qualityLevels_,this.playlists)})}static version(){return{"@videojs/http-streaming":fv,"mux.js":_D,"mpd-parser":FD,"m3u8-parser":OD,"aes-decrypter":BD}}version(){return this.constructor.version()}canChangeType(){return yg.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){if(this.playbackWatcher_)this.playbackWatcher_.dispose();if(this.playlistController_)this.playlistController_.dispose();if(this.qualityLevels_)this.qualityLevels_.dispose();if(this.tech_&&this.tech_.vhs)delete this.tech_.vhs;if(this.mediaSourceUrl_&&V.default.URL.revokeObjectURL)V.default.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null;if(this.tech_)this.tech_.off("waitingforkey",this.handleWaitingForKey_);super.dispose()}convertToProgramTime(e,t){return $H({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,a=!0,n=2){return Tq({programTime:e,playlist:this.playlistController_.media(),retryCount:n,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=(e)=>{cv(this.xhr,e)},this.xhr.onResponse=(e)=>{hv(this.xhr,e)},this.xhr.offRequest=(e)=>{uv(this.xhr,e)},this.xhr.offResponse=(e)=>{mv(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){let e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach((a)=>{this.playlistController_.on(a,(n)=>{this.player_.trigger(Fa({},n))})}),t.forEach((a)=>{this.playbackWatcher_.on(a,(n)=>{this.player_.trigger(Fa({},n))})})}}var J9={name:"videojs-http-streaming",VERSION:fv,canHandleSource(e,t={}){let a=Vt(se.options,t);if(!a.vhs.experimentalUseMMS&&!E1("avc1.4d400d,mp4a.40.2",!1))return!1;return J9.canPlayType(e.type,a)},handleSource(e,t,a={}){let n=Vt(se.options,a);return t.vhs=new Cg(e,t,n),t.vhs.xhr=Cq(),t.vhs.setupXhrHooks_(),t.vhs.src(e.src,e.type),t.vhs},canPlayType(e,t){let a=c6(e);if(!a)return"";let n=J9.getOverrideNative(t);return!Oa.supportsTypeNatively(a)||n?"maybe":""},getOverrideNative(e={}){let{vhs:t={}}=e,a=!(se.browser.IS_ANY_SAFARI||se.browser.IS_IOS),{overrideNative:n=a}=t;return n}},zD=()=>{return E1("avc1.4d400d,mp4a.40.2",!0)};if(zD())se.getTech("Html5").registerSourceHandler(J9,0);se.VhsHandler=Cg;se.VhsSourceHandler=J9;se.Vhs=Oa;if(!se.use)se.registerComponent("Vhs",Oa);se.options.vhs=se.options.vhs||{};if(!se.getPlugin||!se.getPlugin("reloadSourceOnError"))se.registerPlugin("reloadSourceOnError",CD);var Ss=Mt(en(),1);var UD=1000;function _m(e,t,a,n){let[s,i]=Ss.useState(0),f=Ss.useRef(!1),l=Ss.useRef(!1),c=Ss.useRef(null),h=Ss.useRef(s);h.current=s,Ss.useEffect(()=>{i(0);let g=e.current;if(!g)return;let b=()=>{l.current=!0},d=()=>{l.current=!1};return g.addEventListener("play",b),g.addEventListener("pause",d),l.current=!g.paused,()=>{g.removeEventListener("play",b),g.removeEventListener("pause",d)}},[e.current]),Ss.useEffect(()=>{let g=e.current;if(!g)return;let b=null,d=null,j=!0,A=Date.now(),C=!1,y=-1,O=()=>{A=Date.now(),C=!1,y=-1},T=()=>{if(!j)return;if(g.paused||g.ended)return;let x=g,z=!!x.requestVideoFrameCallback,K=_g(t),$=Date.now()-A,Q=C&&$>K,P=!C&&$>UD;if(n||!z||Q||P){let ee=Math.floor(g.currentTime*t+0.45),L=Math.max(0,Math.min(ee,a-1));i(L)}if(d=requestAnimationFrame(T),x.requestVideoFrameCallback&&b===null)b=x.requestVideoFrameCallback((ee,L)=>{b=null,A=Date.now(),C=!0,y=L.mediaTime;let J=Math.floor(L.mediaTime*t+0.45),pe=Math.max(0,Math.min(J,a-1));i(pe)})},M=()=>{O(),T()},H=()=>{if(b!==null){let P=g;if(P.cancelVideoFrameCallback)try{P.cancelVideoFrameCallback(b)}catch{}b=null}if(d!==null)cancelAnimationFrame(d),d=null;let x=_g(t),K=C&&y>=0&&Date.now()-A<=x?y:g.currentTime,$=Math.floor(K*t+0.45),Q=Math.max(0,Math.min($,a-1));if(i(Q),!g.ended){let P=Cm(Q,t);g.currentTime=P}},N=()=>{i(a-1)};if(g.addEventListener("play",M),g.addEventListener("pause",H),g.addEventListener("ended",N),!g.paused)O(),T();return()=>{if(j=!1,g.removeEventListener("play",M),g.removeEventListener("pause",H),g.removeEventListener("ended",N),b!==null){let x=g;if(x.cancelVideoFrameCallback)try{x.cancelVideoFrameCallback(b)}catch{}}if(d!==null)cancelAnimationFrame(d)}},[e.current,t,a]);let u=Ss.useCallback(async(g)=>{let b=e.current;if(!b)return;let d=Math.round(g),j=Math.max(0,Math.min(d,a-1));if(f.current){c.current=j,i(j);return}f.current=!0,i(j);let A=async(C)=>{let y=Cm(C,t),O=!b.paused;if(b.currentTime=y,await new Promise((N)=>{let x=null,z=()=>{if(x)clearTimeout(x);b.removeEventListener("seeked",z),N()};b.addEventListener("seeked",z),x=setTimeout(()=>{b.removeEventListener("seeked",z),N()},500)}),!O&&!l.current)b.pause();let T=Math.floor(b.currentTime*t+0.45),M=Math.max(0,Math.min(T,a-1));i(M);let H=b;if(H.requestVideoFrameCallback)H.requestVideoFrameCallback((N,x)=>{let z=Math.floor(x.mediaTime*t+0.45),K=Math.max(0,Math.min(z,a-1));i(K)});if(c.current!==null){let N=c.current;c.current=null,await A(N)}else f.current=!1};await A(j)},[e,t,a]);return Ss.useEffect(()=>{let g=(b)=>{let d=b.target;if(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d.isContentEditable)return;if(b.key==="ArrowRight"){b.preventDefault();let j=b.shiftKey?10:1;u(h.current+j)}else if(b.key==="ArrowLeft"){b.preventDefault();let j=b.shiftKey?10:1;u(h.current-j)}};return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[u]),Ss.useEffect(()=>{let g=e.current;if(!g)return;let b=()=>{if(!f.current){let d=Math.floor(g.currentTime*t+0.45),j=Math.max(0,Math.min(d,a-1));i(j);let A=Cm(j,t),C=1/t;if(Math.abs(g.currentTime-A)>C/4)g.currentTime=A}};return g.addEventListener("seeked",b),()=>{g.removeEventListener("seeked",b)}},[e.current,t,a]),{currentFrame:s,setCurrentFrame:i,seekToFrame:u,isSeeking:f}}var ss=Mt(en(),1);var ID=(e)=>{if(isNaN(e))return"00:00";let t=new Date(e*1000),a=t.getUTCHours(),n=t.getUTCMinutes(),s=t.getUTCSeconds().toString().padStart(2,"0");if(a)return`${a}:${n.toString().padStart(2,"0")}:${s}`;return`${n}:${s}`},GD=({totalFrames:e,currentFrame:t,fps:a,previewUrl:n,onSeek:s,buffered:i=0,metadata:f})=>{let l=ss.useRef(null),c=ss.useRef(null),[h,u]=ss.useState(null),[g,b]=ss.useState(!1),[d,j]=ss.useState(!1),A=ss.useRef(s);ss.useEffect(()=>{A.current=s},[s]),ss.useEffect(()=>{if(c.current&&n)c.current.load()},[n]);let C=ss.useCallback(($)=>{if(!l.current)return 0;let Q=l.current.getBoundingClientRect();return Math.max(0,Math.min($-Q.left,Q.width))/Q.width},[]),y=ss.useCallback(($)=>{if(d)return;if(!l.current)return;let Q=l.current.getBoundingClientRect(),te=Math.max(0,Math.min($.clientX-Q.left,Q.width))/Q.width;if(u(te),b(!0),c.current&&e){let ee=te*e,L=1/a,J=ee*L+L/2,pe=c.current;if(Number.isFinite(J))pe.currentTime=J}},[e,a,d]),O=()=>{if(!d)b(!1),u(null)},T=($)=>{if($.button!==0)return;$.preventDefault(),j(!0);let Q=C($.clientX);u(Q),b(!0),A.current(Q*e)},M=($)=>{j(!0);let Q=C($.touches[0].clientX);u(Q),b(!0),A.current(Q*e)};ss.useEffect(()=>{if(!d)return;let $=(ee)=>{let L=C(ee.clientX);if(u(L),b(!0),c.current&&e){let J=L*e,pe=1/a,ne=J*pe+pe/2,fe=c.current;if(Number.isFinite(ne))fe.currentTime=ne}A.current(L*e)},Q=(ee)=>{j(!1);let L=!1;if(l.current){let pe=l.current.getBoundingClientRect();L=ee.clientX>=pe.left&&ee.clientX<=pe.right&&ee.clientY>=pe.top&&ee.clientY<=pe.bottom}if(!L)b(!1),u(null);let J=C(ee.clientX);A.current(J*e)},P=(ee)=>{if(ee.touches.length===0)return;let L=C(ee.touches[0].clientX);if(u(L),b(!0),c.current&&e){let J=L*e,pe=1/a,ne=J*pe+pe/2,fe=c.current;if(Number.isFinite(ne))fe.currentTime=ne}A.current(L*e)},te=(ee)=>{j(!1);let L=ee.changedTouches.length>0?ee.changedTouches[0].clientX:null,J=ee.changedTouches.length>0?ee.changedTouches[0].clientY:null,pe=!1;if(L!==null&&J!==null&&l.current){let ne=l.current.getBoundingClientRect();pe=L>=ne.left&&L<=ne.right&&J>=ne.top&&J<=ne.bottom}if(!pe)b(!1),u(null);if(L!==null){let ne=C(L);A.current(ne*e)}};return window.addEventListener("mousemove",$),window.addEventListener("mouseup",Q),window.addEventListener("touchmove",P,{passive:!0}),window.addEventListener("touchend",te),()=>{window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",Q),window.removeEventListener("touchmove",P),window.removeEventListener("touchend",te)}},[d,e,a,C]);let H=d&&h!==null?h*100:e>0?t/e*100:0,N=h!==null?h*100:0,x=()=>{if(h===null)return{};return{left:`${N}%`,transform:`translateX(-${N}%)`}},z=180,K={width:`${z}px`,height:"auto"};if(f&&f.originalWidth&&f.originalHeight){let{originalWidth:$,originalHeight:Q}=f;if($>=Q){let P=z*Q/$;K={width:`${z}px`,height:`${P}px`}}else K={width:`${z*$/Q}px`,height:`${z}px`}}return ie("div",{ref:l,className:"group relative h-1.5 w-full cursor-pointer touch-none rounded-full bg-muted transition-colors duration-200",onMouseMove:y,onMouseLeave:O,onMouseDown:T,onTouchStart:M,"data-testid":"seekbar",children:[R("video",{ref:c,src:n,className:"hidden",preload:"auto",muted:!0,playsInline:!0}),g&&e>0&&R("div",{className:"pointer-events-none absolute bottom-full z-50 mb-3 flex w-max flex-col",style:x(),children:ie("div",{className:"relative overflow-hidden rounded-lg border-2 border-border bg-popover shadow-2xl",children:[R("video",{src:n,className:"bg-black object-cover",style:K,muted:!0,ref:($)=>{if($&&c.current)$.currentTime=c.current.currentTime}}),R("div",{className:"absolute bottom-0 w-full bg-popover/80 py-0.5 text-center text-xs font-medium text-popover-foreground",children:ID(h*e/a)})]})}),R("div",{className:"absolute top-0 left-0 h-full rounded-full bg-muted-foreground/30 transition-all duration-200",style:{width:`${i}%`}}),g&&R("div",{className:"absolute top-0 left-0 h-full rounded-full bg-primary/30",style:{width:`${N}%`}}),R("div",{className:"relative absolute top-0 left-0 h-full rounded-full bg-primary",style:{width:`${H}%`},"data-testid":"seekbar-fill",children:R("div",{className:vn("absolute top-1/2 right-0 h-3.5 w-3.5 -translate-y-1/2 translate-x-1/2 rounded-full border border-border bg-primary shadow-md transition-transform duration-100",g||d?"scale-100":"scale-0 group-hover:scale-100")})})]})},Fm=GD;var pv=({state:e,zoom:t,isControlsVisible:a,buffered:n,data:s,resolutions:i,togglePlay:f,toggleLoop:l,toggleMute:c,handleVolumeChange:h,changePlaybackRate:u,changeResolution:g,handleDownload:b,toggleFullScreen:d,onZoomChange:j,onZoomReset:A,frameRate:C,totalFrames:y,currentFrame:O,seekToFrame:T,floatOverlayInFullScreen:M=!0,onMouseEnter:H,onMouseLeave:N,allowDownload:x=!0})=>{let{videoTimeDisplayMode:z,setVideoTimeDisplayMode:K}=Qf();if(!s.media?.metadata)return null;let $=e.isFullScreen&&M,Q=s.proxyType==="audio",P=s.media?.metadata?.startTimecode,te=Math.max(0,y-1),ee=z==="frames"?`${O} / ${te} fr`:z==="standard"?`${ri(O,C,"standard")} / ${Dm(y/C)}`:`${ri(O,C,z,P)} / ${ri(te,C,z,P)}`;return ie("div",{className:vn("transition-all duration-300 ease-in-out z-20 text-foreground",$?"absolute bottom-0 left-0 right-0 px-4 py-4 bg-card/90 backdrop-blur-md border-t border-border":"relative w-full bg-card border-t border-border px-4 py-3 z-10 transition-colors duration-200",a?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"),onMouseEnter:H,onMouseLeave:N,children:[R("div",{className:"mb-4 px-1",children:R(Fm,{totalFrames:y,currentFrame:O,fps:C,buffered:n,previewUrl:s.media.videoPreview?.url,onSeek:T,metadata:{...s.media.metadata,frameRate:C}})}),ie("div",{className:"flex items-center justify-between text-foreground",children:[ie("div",{className:"flex items-center gap-4",children:[R("button",{onClick:f,className:"hover:text-primary transition-colors","data-testid":"play-toggle","data-playing":e.isPlaying,"aria-label":e.isPlaying?"Pause":"Play",children:e.isPlaying?R(Om,{className:"w-6 h-6 fill-current"}):R(ml,{className:"w-6 h-6 fill-current"})}),R("button",{onClick:l,className:vn("transition-colors",e.isLooping?"text-primary":"text-muted-foreground"),title:"Loop",children:R(Bm,{className:"w-5 h-5"})}),ie("div",{className:"flex items-center gap-3 group/vol",children:[R("button",{onClick:c,className:"hover:text-primary",children:e.isMuted||e.volume===0?R(Mm,{className:"w-6 h-6"}):R(Hm,{className:"w-6 h-6"})}),R("div",{className:"w-0 overflow-hidden group-hover/vol:w-24 transition-all duration-300 ease-in-out",children:R("div",{className:"w-24 px-1",children:R(gv,{value:e.isMuted?[0]:[e.volume],onValueChange:(L)=>h(L[0]),max:1,step:0.05})})})]}),ie("div",{className:"flex items-center gap-1 text-sm font-medium tabular-nums select-none min-w-[100px]",children:[R("span",{className:"text-muted-foreground font-mono","data-testid":"time-readout",children:ee}),ie(Qi,{modal:!1,children:[R(Zi,{asChild:!0,children:R("button",{className:"h-6 w-6 inline-flex items-center justify-center rounded-md hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer focus:outline-none",children:R($f,{className:"h-3.5 w-3.5"})})}),ie($i,{align:"start",className:"w-40 z-30",children:[R(ul,{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Format"}),ie(Hn,{onClick:()=>K("standard"),className:"flex items-center justify-between cursor-pointer text-xs",children:[R("span",{children:"Standard Time"}),z==="standard"&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]}),ie(Hn,{onClick:()=>K("frames"),className:"flex items-center justify-between cursor-pointer text-xs",children:[R("span",{children:"Frames"}),z==="frames"&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]}),ie(Hn,{onClick:()=>K("timecode"),className:"flex items-center justify-between cursor-pointer text-xs",children:[R("span",{children:"Timecode"}),z==="timecode"&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]})]})]})]})]}),ie("div",{className:"relative flex items-center gap-3",children:[!Q&&ie("div",{className:"flex items-center gap-1",children:[ie("div",{className:"flex items-center gap-1 rounded-md bg-muted p-0.5",children:[R("button",{onClick:()=>j(t*0.8),className:"p-1 hover:text-primary rounded",title:He.zoom_out(),children:R(Wf,{size:14})}),ie("span",{className:"text-xs w-8 text-center tabular-nums",children:[Math.round(t*100),"%"]}),R("button",{onClick:()=>j(t*1.2),className:"p-1 hover:text-primary rounded",title:He.zoom_in(),children:R(So,{size:14})})]}),R("button",{onClick:A,className:"text-xs font-medium px-2 py-1 rounded bg-muted hover:text-primary transition-colors",children:He.fit()})]}),ie(Qi,{children:[R(Zi,{asChild:!0,children:ie("button",{className:"w-8 text-sm font-bold hover:text-primary",children:[e.playbackRate,"x"]})}),R($i,{children:[0.5,1,1.5,2].map((L)=>ie(Hn,{onClick:()=>u(L),className:vn("rounded py-1 px-2 text-left text-xs",e.playbackRate===L?"bg-primary text-primary-foreground focus:bg-primary focus:text-primary-foreground":"text-foreground"),children:[L,"x"]},L))})]}),!Q&&i.length>0&&ie(Qi,{children:[R(Zi,{asChild:!0,children:ie("button",{className:"flex items-center gap-1 rounded border border-border px-2 py-0.5 text-sm font-semibold hover:bg-muted transition-colors",children:[R(Tm,{className:"h-3.5 w-3.5"}),R("span",{children:e.currentResolution==="Original"?He.original():e.currentResolution})]})}),ie($i,{children:[R(ul,{children:He.quality()}),i.map((L)=>ie(Hn,{onClick:()=>g(L),className:vn("flex w-full items-center justify-between",e.currentResolution===L.resolution?"text-primary font-medium":"text-foreground"),children:[R("span",{children:L.resolution==="Original"?He.original():L.resolution}),ie("span",{className:"pl-5 text-xs text-muted-foreground",children:[L.width,"x",L.height]})]},L.resolution))]})]}),x&&(Q?R("button",{onClick:()=>b(s.media?.original?.key||""),className:"transition-colors hover:text-primary",title:He.download(),disabled:!s.media?.original?.key,children:R(Bi,{className:"h-5 w-5"})}):ie(Qi,{children:[R(Zi,{asChild:!0,children:R("button",{className:"transition-colors hover:text-primary",title:He.download(),children:R(Bi,{className:"h-5 w-5"})})}),ie($i,{children:[R(ul,{children:He.download()}),i.map((L)=>ie(Hn,{onClick:()=>b(L.key??""),className:"flex w-full items-center justify-between px-3 py-2 text-left text-sm text-foreground",children:[R("span",{children:L.resolution}),R("span",{className:"text-xs text-muted-foreground",children:"MP4"})]},L.resolution)),s.media?.original?.key&&ie(Zf,{children:[R(Nh,{}),ie(Hn,{onClick:()=>b(s.media?.original?.key??""),className:"flex w-full items-center justify-between px-3 py-2 text-left text-sm text-foreground",children:[R("span",{children:He.original()}),R("span",{className:"text-xs text-muted-foreground",children:s.name?.split(".").pop()?.toUpperCase()||"RAW"})]})]})]})]})),R("button",{onClick:d,className:"transition-colors hover:text-primary",title:He.fullscreen(),children:e.isFullScreen?R(yo,{className:"h-6 w-6"}):R(Ao,{className:"h-6 w-6"})})]})]})]})};var bv=({state:e,isControlsVisible:t,buffered:a,data:n,resolutions:s,togglePlay:i,toggleLoop:f,toggleMute:l,changePlaybackRate:c,changeResolution:h,toggleFullScreen:u,frameRate:g,totalFrames:b,currentFrame:d,seekToFrame:j,floatOverlayInFullScreen:A=!0,onMouseEnter:C,onMouseLeave:y})=>{let{videoTimeDisplayMode:O,setVideoTimeDisplayMode:T}=Qf();if(!n.media?.metadata)return null;let M=e.isFullScreen&&A,H=n.proxyType==="audio",N=n.media?.metadata?.startTimecode,x=Math.max(0,b-1),z=O==="frames"?`${d} / ${x} fr`:O==="standard"?`${ri(d,g,"standard")} / ${Dm(b/g)}`:`${ri(d,g,O,N)} / ${ri(x,g,O,N)}`;return ie("div",{className:vn("transition-all duration-300 ease-in-out z-20 text-foreground",M?"absolute bottom-0 left-0 right-0 px-3 py-3 bg-card/90 backdrop-blur-md border-t border-border":"relative w-full bg-card border-t border-border px-3 py-2.5 z-10 transition-colors duration-200",t?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"),onMouseEnter:C,onMouseLeave:y,children:[R("div",{className:"mb-2 px-0.5",children:R(Fm,{totalFrames:b,currentFrame:d,fps:g,buffered:a,previewUrl:n.media.videoPreview?.url,onSeek:j,metadata:{...n.media.metadata,frameRate:g}})}),ie("div",{className:"flex items-center justify-between text-foreground gap-1 select-none",children:[ie("div",{className:"flex items-center gap-2 min-w-0",children:[R("button",{onClick:i,className:"p-1 hover:text-primary transition-colors cursor-pointer shrink-0","data-testid":"play-toggle","data-playing":e.isPlaying,"aria-label":e.isPlaying?"Pause":"Play",children:e.isPlaying?R(Om,{className:"w-5 h-5 fill-current"}):R(ml,{className:"w-5 h-5 fill-current"})}),R("button",{onClick:l,className:"p-1 hover:text-primary transition-colors cursor-pointer shrink-0","aria-label":e.isMuted?"Unmute":"Mute",children:e.isMuted||e.volume===0?R(Mm,{className:"w-5 h-5"}):R(Hm,{className:"w-5 h-5"})}),ie("div",{className:"flex items-center gap-0.5 text-xs font-medium tabular-nums min-w-0",children:[R("span",{className:"text-muted-foreground font-mono truncate text-[11px] sm:text-xs","data-testid":"time-readout",children:z}),ie(Qi,{modal:!1,children:[R(Zi,{asChild:!0,children:R("button",{className:"h-5 w-5 inline-flex items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer focus:outline-none shrink-0","aria-label":He.change_time_format(),children:R($f,{className:"h-3 w-3"})})}),ie($i,{align:"start",className:"w-40 z-30",children:[R(ul,{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:He.format()}),ie(Hn,{onClick:()=>T("standard"),className:"flex items-center justify-between cursor-pointer text-xs",children:[R("span",{children:He.standard_time()}),O==="standard"&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]}),ie(Hn,{onClick:()=>T("frames"),className:"flex items-center justify-between cursor-pointer text-xs",children:[R("span",{children:He.frames()}),O==="frames"&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]}),ie(Hn,{onClick:()=>T("timecode"),className:"flex items-center justify-between cursor-pointer text-xs",children:[R("span",{children:He.timecode()}),O==="timecode"&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]})]})]})]})]}),ie("div",{className:"flex items-center gap-1 shrink-0",children:[ie(Qi,{modal:!1,children:[R(Zi,{asChild:!0,children:ie("button",{className:"flex items-center gap-1 rounded border border-border px-1.5 py-1 text-xs font-semibold hover:bg-muted transition-colors cursor-pointer",title:He.settings(),"aria-label":He.settings(),children:[R(Tm,{className:"h-3.5 w-3.5"}),R("span",{className:"text-[11px]",children:!H&&e.currentResolution?e.currentResolution:`${e.playbackRate}x`})]})}),ie($i,{align:"end",className:"w-48 z-30",children:[!H&&s.length>0&&ie(Zf,{children:[R(ul,{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:He.quality()}),s.map((K)=>ie(Hn,{onClick:()=>h(K),className:vn("flex w-full items-center justify-between text-xs cursor-pointer",e.currentResolution===K.resolution?"text-primary font-medium":"text-foreground"),children:[R("span",{children:K.resolution==="Original"?He.original():K.resolution}),ie("span",{className:"text-[10px] text-muted-foreground",children:[K.width,"x",K.height]})]},K.resolution)),R(Nh,{})]}),R(ul,{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:He.playback_speed()}),[0.5,1,1.5,2].map((K)=>ie(Hn,{onClick:()=>c(K),className:vn("flex items-center justify-between text-xs cursor-pointer",e.playbackRate===K?"text-primary font-medium":"text-foreground"),children:[ie("span",{children:[K,"x"]}),e.playbackRate===K&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]},K)),R(Nh,{}),ie(Hn,{onClick:f,className:"flex items-center justify-between text-xs cursor-pointer",children:[ie("span",{className:"flex items-center gap-1.5",children:[R(Bm,{className:"h-3.5 w-3.5"}),R("span",{children:He.loop()})]}),e.isLooping&&R(pi,{className:"h-3.5 w-3.5 text-primary"})]})]})]}),R("button",{onClick:u,className:"p-1 hover:text-primary transition-colors cursor-pointer shrink-0",title:He.fullscreen(),"aria-label":He.fullscreen(),children:e.isFullScreen?R(yo,{className:"h-5 w-5"}):R(Ao,{className:"h-5 w-5"})})]})]})]})};var XD=Math.PI/180;function KD(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}var gl=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},ve={_global:gl,version:"10.3.0",isBrowser:KD(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return ve.angleDeg?e*XD:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return ve.DD.isDragging},isTransforming(){var e,t;return(t=(e=ve.Transformer)===null||e===void 0?void 0:e.isTransforming())!==null&&t!==void 0?t:!1},isDragReady(){return!!ve.DD.node},releaseCanvasOnDestroy:!0,document:gl.document,_injectGlobal(e){if(typeof gl.Konva<"u")console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.");gl.Konva=e}},lt=(e)=>{ve[e.prototype.getClassName()]=e};ve._injectGlobal(ve);var LD=`Konva.js unsupported environment.
232
+
233
+ Looks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.
234
+
235
+ To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.
236
+
237
+ bash: npm install canvas
238
+ js: import "konva/canvas-backend";
239
+
240
+ or
241
+
242
+ bash: npm install skia-canvas
243
+ js: import "konva/skia-backend";
244
+ `,wv=()=>{if(typeof document>"u")throw Error(LD)};class xn{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new xn(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),a=Math.sin(e),n=this.m[0]*t+this.m[2]*a,s=this.m[1]*t+this.m[3]*a,i=this.m[0]*-a+this.m[2]*t,f=this.m[1]*-a+this.m[3]*t;return this.m[0]=n,this.m[1]=s,this.m[2]=i,this.m[3]=f,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let a=this.m[0]+this.m[2]*t,n=this.m[1]+this.m[3]*t,s=this.m[2]+this.m[0]*e,i=this.m[3]+this.m[1]*e;return this.m[0]=a,this.m[1]=n,this.m[2]=s,this.m[3]=i,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],a=this.m[1]*e.m[0]+this.m[3]*e.m[1],n=this.m[0]*e.m[2]+this.m[2]*e.m[3],s=this.m[1]*e.m[2]+this.m[3]*e.m[3],i=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],f=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=a,this.m[2]=n,this.m[3]=s,this.m[4]=i,this.m[5]=f,this}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,a=-this.m[1]*e,n=-this.m[2]*e,s=this.m[0]*e,i=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),f=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=a,this.m[2]=n,this.m[3]=s,this.m[4]=i,this.m[5]=f,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],a=this.m[2],n=this.m[3],s=this.m[4],i=this.m[5],f=e*n-t*a,l={x:s,y:i,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let c=Math.sqrt(e*e+t*t);l.rotation=t>0?Math.acos(e/c):-Math.acos(e/c),l.scaleX=c,l.scaleY=f/c,l.skewX=(e*a+t*n)/f,l.skewY=0}else if(a!=0||n!=0){let c=Math.sqrt(a*a+n*n);l.rotation=Math.PI/2-(n>0?Math.acos(-a/c):-Math.acos(a/c)),l.scaleX=f/c,l.scaleY=c,l.skewX=0,l.skewY=(e*a+t*n)/f}return l.rotation=Z._getRotation(l.rotation),l}}var VD="[object Array]",YD="[object Number]",JD="[object String]",QD="[object Boolean]",ZD=Math.PI/180,$D=180/Math.PI,Eh="#",WD="",PD="0",ex="Konva warning: ",dv="Konva error: ",tx="rgb(",Fg={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},ax=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,xm=[],zh=null,nx=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)},Z={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===VD},_isNumber(e){return Object.prototype.toString.call(e)===YD&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===JD},_isBoolean(e){return Object.prototype.toString.call(e)===QD},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=="string")return!1;let t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){if(e===0)return 1;if(e>0)return 1;else return-1},requestAnimFrame(e){if(xm.push(e),xm.length===1)nx(function(){let t=xm;xm=[],t.forEach(function(a){a()})})},createCanvasElement(){wv();let e=document.createElement("canvas");try{e.style=e.style||{}}catch(t){}return e},createImageElement(){return wv(),document.createElement("img")},_isInDocument(e){while(e=e.parentNode)if(e==document)return!0;return!1},_urlToImage(e,t){let a=Z.createImageElement();a.onload=function(){t(a)},a.src=e},_rgbToHex(e,t,a){return(16777216+(e<<16)+(t<<8)+a).toString(16).slice(1)},_hexToRgb(e){e=e.replace(Eh,WD);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);while(e.length<6)e=PD+e;return Eh+e},isCanvasFarblingActive(){if(zh!==null)return zh;if(typeof document>"u")return zh=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);let a=t.getImageData(0,0,10,10).data,n=!1;for(let s=0;s<100;s++)if(a[s*4]!==40||a[s*4+1]!==40||a[s*4+2]!==40||a[s*4+3]!==255){n=!0;break}return zh=n,this.releaseCanvas(e),zh},getHitColor(){let e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,a){if(this.isCanvasFarblingActive())e=Math.round(e/5)*5,t=Math.round(t/5)*5,a=Math.round(a/5)*5;return Eh+this._rgbToHex(e,t,a)},getSnappedHexColor(e){let t=this._hexToRgb(e);return Eh+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;if(e in Fg)return t=Fg[e],{r:t[0],g:t[1],b:t[2]};else if(e[0]===Eh)return this._hexToRgb(e.substring(1));else if(e.substr(0,4)===tx)return t=ax.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)};else return{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",Z._namedColorToRBA(e)||Z._hex3ColorToRGBA(e)||Z._hex4ColorToRGBA(e)||Z._hex6ColorToRGBA(e)||Z._hex8ColorToRGBA(e)||Z._rgbColorToRGBA(e)||Z._rgbaColorToRGBA(e)||Z._hslColorToRGBA(e)},_namedColorToRBA(e){let t=Fg[e.toLowerCase()];if(!t)return null;return{r:t[0],g:t[1],b:t[2],a:1}},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];let t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];let t=e.split(/ *, */).map((a,n)=>{if(a.slice(-1)==="%")return n===3?parseInt(a)/100:parseInt(a)/100*255;return Number(a)});return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){let[t,...a]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),n=Number(a[0])/360,s=Number(a[1])/100,i=Number(a[2])/100,f,l,c;if(s===0)return c=i*255,{r:Math.round(c),g:Math.round(c),b:Math.round(c),a:1};if(i<0.5)f=i*(1+s);else f=i+s-i*s;let h=2*i-f,u=[0,0,0];for(let g=0;g<3;g++){if(l=n+0.3333333333333333*-(g-1),l<0)l++;if(l>1)l--;if(6*l<1)c=h+(f-h)*6*l;else if(2*l<1)c=f;else if(3*l<2)c=h+(f-h)*(0.6666666666666666-l)*6;else c=h;u[g]=c*255}return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){let t={};for(let a in e)if(this._isPlainObject(e[a]))t[a]=this.cloneObject(e[a]);else if(this._isArray(e[a]))t[a]=this.cloneArray(e[a]);else t[a]=e[a];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*ZD},radToDeg(e){return e*$D},_degToRad(e){return Z.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Z.degToRad(e)},_radToDeg(e){return Z.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Z.radToDeg(e)},_getRotation(e){return ve.angleDeg?Z.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw Error(dv+e)},error(e){console.error(dv+e)},warn(e){if(!ve.showWarnings)return;console.warn(ex+e)},each(e,t){for(let a in e)t(a,e[a])},_inRange(e,t,a){return t<=e&&e<a},_getProjectionToSegment(e,t,a,n,s,i){let f,l,c,h=(e-a)*(e-a)+(t-n)*(t-n);if(h==0)f=e,l=t,c=(s-a)*(s-a)+(i-n)*(i-n);else{let u=((s-e)*(a-e)+(i-t)*(n-t))/h;if(u<0)f=e,l=t,c=(e-s)*(e-s)+(t-i)*(t-i);else if(u>1)f=a,l=n,c=(a-s)*(a-s)+(n-i)*(n-i);else f=e+u*(a-e),l=t+u*(n-t),c=(f-s)*(f-s)+(l-i)*(l-i)}return[f,l,c]},_getProjectionToLine(e,t,a){let n=Z.cloneObject(e),s=Number.MAX_VALUE;return t.forEach(function(i,f){if(!a&&f===t.length-1)return;let l=t[(f+1)%t.length],c=Z._getProjectionToSegment(i.x,i.y,l.x,l.y,e.x,e.y),h=c[0],u=c[1],g=c[2];if(g<s)n.x=h,n.y=u,s=g}),n},_prepareArrayForTween(e,t,a){let n=[],s=[];if(e.length>t.length){let f=t;t=e,e=f}for(let f=0;f<e.length;f+=2)n.push({x:e[f],y:e[f+1]});for(let f=0;f<t.length;f+=2)s.push({x:t[f],y:t[f+1]});let i=[];return s.forEach(function(f){let l=Z._getProjectionToLine(f,n,a);i.push(l.x),i.push(l.y)}),i},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(let a in e){if(!(e.hasOwnProperty(a)&&e[a]&&typeof e[a]=="object"))continue;if(t=Object.getOwnPropertyDescriptor(e,a),e[a].visitedByCircularReferenceRemoval||Z._isElement(e[a]))if(t.configurable)delete e[a];else return null;else if(Z._prepareToStringify(e[a])===null)if(t.configurable)delete e[a];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(let a in t)e[a]=t[a];return e},_getFirstPointerId(e){if(!e.touches)return e.pointerId||999;else return e.changedTouches[0].identifier},releaseCanvas(...e){if(!ve.releaseCanvasOnDestroy)return;e.forEach((t)=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,a,n){let s=t<0?t:0,i=a<0?a:0;t=Math.abs(t),a=Math.abs(a);let f=0,l=0,c=0,h=0;if(typeof n==="number")f=l=c=h=Math.min(n,t/2,a/2);else f=Math.min(n[0]||0,t/2,a/2),l=Math.min(n[1]||0,t/2,a/2),h=Math.min(n[2]||0,t/2,a/2),c=Math.min(n[3]||0,t/2,a/2);e.moveTo(s+f,i),e.lineTo(s+t-l,i),e.arc(s+t-l,i+l,l,Math.PI*3/2,0,!1),e.lineTo(s+t,i+a-h),e.arc(s+t-h,i+a-h,h,0,Math.PI/2,!1),e.lineTo(s+c,i+a),e.arc(s+c,i+a-c,c,Math.PI/2,Math.PI,!1),e.lineTo(s,i+f),e.arc(s+f,i+f,f,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,a,n,s){n=Math.abs(n);for(let i=0;i<a;i++){let f=t[(i-1+a)%a],l=t[i],c=t[(i+1)%a],h={x:l.x-f.x,y:l.y-f.y},u={x:c.x-l.x,y:c.y-l.y},g=Math.hypot(h.x,h.y),b=Math.hypot(u.x,u.y),d;if(typeof s==="number")d=s;else d=i<s.length?s[i]:0;d=n*Math.cos(Math.PI/a)*Math.min(1,d/n*2);let A={x:h.x/g,y:h.y/g},C={x:u.x/b,y:u.y/b},y={x:l.x-A.x*d,y:l.y-A.y*d},O={x:l.x+C.x*d,y:l.y+C.y*d};if(i===0)e.moveTo(y.x,y.y);else e.lineTo(y.x,y.y);e.arcTo(l.x,l.y,O.x,O.y,d)}}};function sx(e){let t=[],a=e.length,n=Z;for(let s=0;s<a;s++){let i=e[s];if(n._isNumber(i))i=Math.round(i*1000)/1000;else if(!n._isString(i))i=i+"";t.push(i)}return t}var jv=",",ix="(",fx=")",lx="([",rx="])",ox=";",cx="()",hx="=",qv=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],ux=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],mx=100,Rm=null;function Og(){if(Rm!==null)return Rm;try{let t=Z.createCanvasElement().getContext("2d");if(!t)return Rm=!1,!1;return!!t&&"filter"in t}catch(e){return Rm=!1,!1}}class Co{constructor(e){if(this.canvas=e,ve.enableTrace)this.traceArr=[],this._enableTrace()}fillShape(e){if(e.fillEnabled())this._fill(e)}_fill(e){}strokeShape(e){if(e.hasStroke())this._stroke(e)}_stroke(e){}fillStrokeShape(e){if(e.attrs.fillAfterStrokeEnabled)this.strokeShape(e),this.fillShape(e);else this.fillShape(e),this.strokeShape(e)}getTrace(e,t){let a=this.traceArr,n=a.length,s="",i,f,l,c;for(i=0;i<n;i++){if(f=a[i],l=f.method,l)if(c=f.args,s+=l,e)s+=cx;else if(Z._isArray(c[0]))s+=lx+c.join(jv)+rx;else{if(t)c=c.map((h)=>typeof h==="number"?Math.floor(h):h);s+=ix+c.join(jv)+fx}else if(s+=f.property,!e)s+=hx+f.val;s+=ox}return s}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,a;if(t.push(e),a=t.length,a>=mx)t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();if(e)this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0);else this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){let t=e.attrs.lineCap;if(t)this.setAttr("lineCap",t)}_applyOpacity(e){let t=e.getAbsoluteOpacity();if(t!==1)this.setAttr("globalAlpha",t)}_applyLineJoin(e){let t=e.attrs.lineJoin;if(t)this.setAttr("lineJoin",t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;if(t!=null)this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,a,n,s,i){this._context.arc(e,t,a,n,s,i)}arcTo(e,t,a,n,s){this._context.arcTo(e,t,a,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,a,n,s,i){this._context.bezierCurveTo(e,t,a,n,s,i)}clearRect(e,t,a,n){this._context.clearRect(e,t,a,n)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let a=arguments;if(a.length===2)return this._context.createImageData(e,t);else if(a.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,a,n){return this._context.createLinearGradient(e,t,a,n)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,a,n,s,i){return this._context.createRadialGradient(e,t,a,n,s,i)}drawImage(e,t,a,n,s,i,f,l,c){let h=arguments,u=this._context;if(h.length===3)u.drawImage(e,t,a);else if(h.length===5)u.drawImage(e,t,a,n,s);else if(h.length===9)u.drawImage(e,t,a,n,s,i,f,l,c)}ellipse(e,t,a,n,s,i,f,l){this._context.ellipse(e,t,a,n,s,i,f,l)}isPointInPath(e,t,a,n){if(a)return this._context.isPointInPath(a,e,t,n);return this._context.isPointInPath(e,t,n)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,a,n){this._context.fillRect(e,t,a,n)}strokeRect(e,t,a,n){this._context.strokeRect(e,t,a,n)}fillText(e,t,a,n){if(n)this._context.fillText(e,t,a,n);else this._context.fillText(e,t,a)}measureText(e){return this._context.measureText(e)}getImageData(e,t,a,n){return this._context.getImageData(e,t,a,n)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,a,n){this._context.rect(e,t,a,n)}roundRect(e,t,a,n,s){this._context.roundRect(e,t,a,n,s)}putImageData(e,t,a){this._context.putImageData(e,t,a)}quadraticCurveTo(e,t,a,n){this._context.quadraticCurveTo(e,t,a,n)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){if(this._context.setLineDash)this._context.setLineDash(e);else if("mozDash"in this._context)this._context.mozDash=e;else if("webkitLineDash"in this._context)this._context.webkitLineDash=e}getLineDash(){return this._context.getLineDash()}setTransform(e,t,a,n,s,i){this._context.setTransform(e,t,a,n,s,i)}stroke(e){if(e)this._context.stroke(e);else this._context.stroke()}strokeText(e,t,a,n){this._context.strokeText(e,t,a,n)}transform(e,t,a,n,s,i){this._context.transform(e,t,a,n,s,i)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=qv.length,a=this.setAttr,n,s,i=function(f){let l=e[f],c;e[f]=function(){return s=sx(Array.prototype.slice.call(arguments,0)),c=l.apply(e,arguments),e._trace({method:f,args:s}),c}};for(n=0;n<t;n++)i(qv[n]);e.setAttr=function(){a.apply(e,arguments);let f=arguments[0],l=arguments[1];if(f==="shadowOffsetX"||f==="shadowOffsetY"||f==="shadowBlur")l=l/this.canvas.getPixelRatio();e._trace({property:f,val:l})}}_applyGlobalCompositeOperation(e){let t=e.attrs.globalCompositeOperation;if(!(!t||t==="source-over"))this.setAttr("globalCompositeOperation",t)}}ux.forEach(function(e){Object.defineProperty(Co.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});class Bg extends Co{constructor(e,{willReadFrequently:t=!1}={}){super(e);this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){let t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){let t=e._getLinearGradient();if(t)this.setAttr("fillStyle",t),e._fillFunc(this)}_fillRadialGradient(e){let t=e._getRadialGradient();if(t)this.setAttr("fillStyle",t),e._fillFunc(this)}_fill(e){let t=e.fill(),a=e.getFillPriority();if(t&&a==="color"){this._fillColor(e);return}let n=e.getFillPatternImage();if(n&&a==="pattern"){this._fillPattern(e);return}let s=e.getFillLinearGradientColorStops();if(s&&a==="linear-gradient"){this._fillLinearGradient(e);return}let i=e.getFillRadialGradientColorStops();if(i&&a==="radial-gradient"){this._fillRadialGradient(e);return}if(t)this._fillColor(e);else if(n)this._fillPattern(e);else if(s)this._fillLinearGradient(e);else if(i)this._fillRadialGradient(e)}_strokeLinearGradient(e){let t=e.getStrokeLinearGradientStartPoint(),a=e.getStrokeLinearGradientEndPoint(),n=e.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(t.x,t.y,a.x,a.y);if(n){for(let i=0;i<n.length;i+=2)s.addColorStop(n[i],n[i+1]);this.setAttr("strokeStyle",s)}}_stroke(e){let t=e.dash(),a=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!a){this.save();let s=this.getCanvas().getPixelRatio();this.setTransform(s,0,0,s,0,0)}if(this._applyLineCap(e),t&&e.dashEnabled())this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset());if(this.setAttr("lineWidth",e.strokeWidth()),!e.getShadowForStrokeEnabled())this.setAttr("shadowColor","rgba(0,0,0,0)");if(e.getStrokeLinearGradientColorStops())this._strokeLinearGradient(e);else this.setAttr("strokeStyle",e.stroke());if(e._strokeFunc(this),!a)this.restore()}}_applyShadow(e){var t,a,n;let s=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",i=(a=e.getShadowBlur())!==null&&a!==void 0?a:5,f=(n=e.getShadowOffset())!==null&&n!==void 0?n:{x:0,y:0},l=e.getAbsoluteScale(),c=this.canvas.getPixelRatio(),h=l.x*c,u=l.y*c;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",i*Math.min(Math.abs(h),Math.abs(u))),this.setAttr("shadowOffsetX",f.x*h),this.setAttr("shadowOffsetY",f.y*u)}}class Tg extends Co{constructor(e){super(e);this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){if(e.hasHitStroke())this._stroke(e)}_stroke(e){if(e.hasHitStroke()){let t=e.getStrokeScaleEnabled();if(!t){this.save();let s=this.getCanvas().getPixelRatio();this.setTransform(s,0,0,s,0,0)}this._applyLineCap(e);let a=e.hitStrokeWidth(),n=a==="auto"?e.strokeWidth():a;if(this.setAttr("lineWidth",n),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),!t)this.restore()}}}var Nm;function gx(){if(Nm)return Nm;let e=Z.createCanvasElement(),t=e.getContext("2d");return Nm=function(){let a=ve._global.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return a/n}(),Z.releaseCanvas(e),Nm}class Uh{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;let a=(e||{}).pixelRatio||ve.pixelRatio||gx();this.pixelRatio=a,this._canvas=Z.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){let t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";let t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";let t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch(a){try{return this._canvas.toDataURL()}catch(n){return Z.error("Unable to get data URL. "+n.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class bi extends Uh{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e);this.context=new Bg(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}}class Tr extends Uh{constructor(e={width:0,height:0}){super(e);this.hitCanvas=!0,this.context=new Tg(this),this.setSize(e.width,e.height)}}var _t={get isDragging(){let e=!1;return _t._dragElements.forEach((t)=>{if(t.dragStatus==="dragging")e=!0}),e},justDragged:!1,get node(){let e;return _t._dragElements.forEach((t)=>{e=t.node}),e},_dragElements:new Map,_drag(e){let t=[];_t._dragElements.forEach((a,n)=>{let{node:s}=a,i=s.getStage();if(i.setPointersPositions(e),a.pointerId===void 0)a.pointerId=Z._getFirstPointerId(e);let f=i._changedPointerPositions.find((l)=>l.id===a.pointerId);if(!f)return;if(a.dragStatus!=="dragging"){let l=s.dragDistance();if(Math.max(Math.abs(f.x-a.startPointerPos.x),Math.abs(f.y-a.startPointerPos.y))<l)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,a),t.push(s)}),t.forEach((a)=>{if(!a.getStage())return;a.fire("dragmove",{type:"dragmove",target:a,evt:e},!0)})},_endDragBefore(e){let t=[];_t._dragElements.forEach((a)=>{let{node:n}=a,s=n.getStage();if(e)s.setPointersPositions(e);if(!s._changedPointerPositions.find((l)=>l.id===a.pointerId))return;if(a.dragStatus==="dragging"||a.dragStatus==="stopped")_t.justDragged=!0,ve._mouseListenClick=!1,ve._touchListenClick=!1,ve._pointerListenClick=!1,a.dragStatus="stopped";let f=a.node.getLayer()||a.node instanceof ve.Stage&&a.node;if(f&&t.indexOf(f)===-1)t.push(f)}),t.forEach((a)=>{a.draw()})},_endDragAfter(e){_t._dragElements.forEach((t,a)=>{if(t.dragStatus==="stopped")t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0);if(t.dragStatus!=="dragging")_t._dragElements.delete(a)})}};if(ve.isBrowser)window.addEventListener("mouseup",_t._endDragBefore,!0),window.addEventListener("touchend",_t._endDragBefore,!0),window.addEventListener("touchcancel",_t._endDragBefore,!0),window.addEventListener("mousemove",_t._drag),window.addEventListener("touchmove",_t._drag),window.addEventListener("mouseup",_t._endDragAfter,!1),window.addEventListener("touchend",_t._endDragAfter,!1),window.addEventListener("touchcancel",_t._endDragAfter,!1);function pl(e){if(Z._isString(e))return'"'+e+'"';if(Object.prototype.toString.call(e)==="[object Number]")return e;if(Z._isBoolean(e))return e;return Object.prototype.toString.call(e)}function Em(e){if(e>255)return 255;else if(e<0)return 0;return Math.round(e)}function we(){if(ve.isUnminified)return function(e,t){if(!Z._isNumber(e))Z.warn(pl(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.');return e}}function bl(e){if(ve.isUnminified)return function(t,a){let n=Z._isNumber(t),s=Z._isArray(t)&&t.length==e;if(!n&&!s)Z.warn(pl(t)+' is a not valid value for "'+a+'" attribute. The value should be a number or Array<number>('+e+")");return t}}function Ih(){if(ve.isUnminified)return function(e,t){if(!(Z._isNumber(e)||e==="auto"))Z.warn(pl(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".');return e}}function h0(){if(ve.isUnminified)return function(e,t){if(!Z._isString(e))Z.warn(pl(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.');return e}}function Hg(){if(ve.isUnminified)return function(e,t){let a=Z._isString(e),n=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;if(!(a||n))Z.warn(pl(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.');return e}}function vv(){if(ve.isUnminified)return function(e,t){let a=Int8Array?Object.getPrototypeOf(Int8Array):null;if(a&&e instanceof a)return e;if(!Z._isArray(e))Z.warn(pl(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.');else e.forEach(function(n){if(!Z._isNumber(n))Z.warn('"'+t+'" attribute has non numeric element '+n+". Make sure that all elements are numbers.")});return e}}function Rn(){if(ve.isUnminified)return function(e,t){if(!(e===!0||e===!1))Z.warn(pl(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.');return e}}function kv(e){if(ve.isUnminified)return function(t,a){if(t===void 0||t===null)return t;if(!Z.isObject(t))Z.warn(pl(t)+' is a not valid value for "'+a+'" attribute. The value should be an object with properties '+e);return t}}var Gh="get",Xh="set",I={addGetterSetter(e,t,a,n,s){I.addGetter(e,t,a),I.addSetter(e,t,n,s),I.addOverloadedGetterSetter(e,t)},addGetter(e,t,a){let n=Gh+Z._capitalize(t);e.prototype[n]=e.prototype[n]||function(){let s=this.attrs[t];return s===void 0?a:s}},addSetter(e,t,a,n){let s=Xh+Z._capitalize(t);if(!e.prototype[s])I.overWriteSetter(e,t,a,n)},overWriteSetter(e,t,a,n){let s=Xh+Z._capitalize(t);e.prototype[s]=function(i){if(a&&i!==void 0&&i!==null)i=a.call(this,i,t);if(this._setAttr(t,i),n)n.call(this);return this}},addComponentsGetterSetter(e,t,a,n,s){let i=a.length,f=Z._capitalize,l=Gh+f(t),c=Xh+f(t);e.prototype[l]=function(){let u={};for(let g=0;g<i;g++){let b=a[g];u[b]=this.getAttr(t+f(b))}return u};let h=kv(a);e.prototype[c]=function(u){let g=this.attrs[t];if(n)u=n.call(this,u,t);if(h)h.call(this,u,t);for(let b in u){if(!u.hasOwnProperty(b))continue;this._setAttr(t+f(b),u[b])}if(!u)a.forEach((b)=>{this._setAttr(t+f(b),void 0)});if(this._fireChangeEvent(t,g,u),s)s.call(this);return this},I.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let a=Z._capitalize(t),n=Xh+a,s=Gh+a;e.prototype[t]=function(){if(arguments.length)return this[n](arguments[0]),this;return this[s]()}},addDeprecatedGetterSetter(e,t,a,n){Z.error("Adding deprecated "+t);let s=Gh+Z._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[s]=function(){Z.error(i);let f=this.attrs[t];return f===void 0?a:f},I.addSetter(e,t,n,function(){Z.error(i)}),I.addOverloadedGetterSetter(e,t)},backCompat(e,t){Z.each(t,function(a,n){let s=e.prototype[n],i=Gh+Z._capitalize(a),f=Xh+Z._capitalize(a);function l(){s.apply(this,arguments),Z.error('"'+a+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}e.prototype[a]=l,e.prototype[i]=l,e.prototype[f]=l})},afterSetFilter(){this._filterUpToDate=!1}};function px(e){let t=/(\w+)\(([^)]+)\)/g,a;while((a=t.exec(e))!==null){let[,n,s]=a;switch(n){case"blur":{let i=parseFloat(s.replace("px",""));return function(f){this.blurRadius(i*0.5);let l=ve.Filters;if(l&&l.Blur)l.Blur.call(this,f)}}case"brightness":{let i=s.includes("%")?parseFloat(s)/100:parseFloat(s);return function(f){this.brightness(i);let l=ve.Filters;if(l&&l.Brightness)l.Brightness.call(this,f)}}case"contrast":{let i=parseFloat(s);return function(f){let l=100*(Math.sqrt(i)-1);this.contrast(l);let c=ve.Filters;if(c&&c.Contrast)c.Contrast.call(this,f)}}case"grayscale":return function(i){let f=ve.Filters;if(f&&f.Grayscale)f.Grayscale.call(this,i)};case"sepia":return function(i){let f=ve.Filters;if(f&&f.Sepia)f.Sepia.call(this,i)};case"invert":return function(i){let f=ve.Filters;if(f&&f.Invert)f.Invert.call(this,i)};default:Z.warn(`CSS filter "${n}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var zm="absoluteOpacity",Av="allEventListeners",nf="absoluteTransform",yv="absoluteScale",Hr="canvas",bx="Change",wx="children",dx="konva",Mg="listening",jx="mouseenter",qx="mouseleave",vx="pointerenter",kx="pointerleave",Ax="touchenter",yx="touchleave";var Sv="set",Cv="Shape",Um=" ",_v="stage",wl="transform",Sx="Stage",Dg="visible",Cx=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Um),_x=1;class qe{constructor(e){this._id=_x++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){if((e===wl||e===nf)&&this._cache.get(e))this._cache.get(e).dirty=!0;else if(e)this._cache.delete(e);else this._cache.clear()}_getCache(e,t){let a=this._cache.get(e);if(a===void 0||(e===wl||e===nf)&&a.dirty===!0)a=t.call(this),this._cache.set(e,a);return a}_calculate(e,t,a){if(!this._attachedDepsListeners.get(e)){let n=t.map((s)=>s+"Change.konva").join(Um);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,a)}_getCanvasCache(){return this._cache.get(Hr)}_clearSelfAndDescendantCache(e){if(this._clearCache(e),e===nf)this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Hr)){let{scene:e,filter:t,hit:a}=this._cache.get(Hr);Z.releaseCanvas(e._canvas,t._canvas,a._canvas),this._cache.delete(Hr)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},a={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)a=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0});let n=Math.ceil(t.width||a.width),s=Math.ceil(t.height||a.height),i=t.pixelRatio,f=t.x===void 0?Math.floor(a.x):t.x,l=t.y===void 0?Math.floor(a.y):t.y,c=t.offset||0,h=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(!n||!s){Z.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}let g=Math.abs(Math.round(a.x)-f)>0.5?1:0,b=Math.abs(Math.round(a.y)-l)>0.5?1:0;n+=c*2+g,s+=c*2+b,f-=c,l-=c;let d=new bi({pixelRatio:i,width:n,height:s}),j=new bi({pixelRatio:i,width:0,height:0,willReadFrequently:!0}),A=new Tr({pixelRatio:u,width:n,height:s}),C=d.getContext(),y=A.getContext(),O=new bi({width:d.width/d.pixelRatio+Math.abs(f),height:d.height/d.pixelRatio+Math.abs(l),pixelRatio:d.pixelRatio}),T=O.getContext();if(A.isCache=!0,d.isCache=!0,this._cache.delete(Hr),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1)d.getContext()._context.imageSmoothingEnabled=!1,j.getContext()._context.imageSmoothingEnabled=!1;if(C.save(),y.save(),T.save(),C.translate(-f,-l),y.translate(-f,-l),T.translate(-f,-l),O.x=f,O.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(zm),this._clearSelfAndDescendantCache(yv),this.drawScene(d,this,O),this.drawHit(A,this),this._isUnderCache=!1,C.restore(),y.restore(),h)C.save(),C.beginPath(),C.rect(0,0,n,s),C.closePath(),C.setAttr("strokeStyle","red"),C.setAttr("lineWidth",5),C.stroke(),C.restore();return Z.releaseCanvas(O._canvas),this._cache.set(Hr,{scene:d,filter:j,hit:A,x:f,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Hr)}getClientRect(e){throw Error('abstract "getClientRect" method call')}_transformedRect(e,t){let a=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],n=1/0,s=1/0,i=-1/0,f=-1/0,l=this.getAbsoluteTransform(t);return a.forEach(function(c){let h=l.point(c);if(n===void 0)n=i=h.x,s=f=h.y;n=Math.min(n,h.x),s=Math.min(s,h.y),i=Math.max(i,h.x),f=Math.max(f,h.y)}),{x:n,y:s,width:i-n,height:f-s}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let a=this._getCachedSceneCanvas(),n=a.pixelRatio;e.drawImage(a._canvas,0,0,a.width/n,a.height/n),e.restore()}_drawCachedHitCanvas(e){let t=this._getCanvasCache(),a=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(a._canvas,0,0,a.width/a.pixelRatio,a.height/a.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),a=t.scene,n=t.filter,s=n.getContext(),i,f,l,c;if(!e||e.length===0)return a;if(this._filterUpToDate)return n;let h=!0;for(let g=0;g<e.length;g++){let b=typeof e[g]==="string"&&!Og();if(typeof e[g]!=="string"||!Og()){h=!1;break}}let u=a.pixelRatio;if(n.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio),h){let g=e.join(" ");return s.save(),s.setAttr("filter",g),s.drawImage(a._canvas,0,0,a.getWidth()/u,a.getHeight()/u),s.restore(),this._filterUpToDate=!0,n}try{i=e.length,s.clear(),s.drawImage(a._canvas,0,0,a.getWidth()/u,a.getHeight()/u),f=s.getImageData(0,0,n.getWidth(),n.getHeight());for(l=0;l<i;l++){if(c=e[l],typeof c==="string")c=px(c);c.call(this,f),s.putImageData(f,0,0)}}catch(g){Z.error("Unable to apply filter. "+g.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,n}on(...e){let t=e[0],a=e[1],n=e[2];if(this._cache)this._cache.delete(Av);if(e.length===3)return this._delegate.apply(this,e);let s=t.split(Um);for(let i=0;i<s.length;i++){let l=s[i].split("."),c=l[0],h=l[1]||"";if(!this.eventListeners[c])this.eventListeners[c]=[];this.eventListeners[c].push({name:h,handler:a})}return this}off(e,t){let a=(e||"").split(Um),n=a.length,s,i,f,l,c,h;if(this._cache&&this._cache.delete(Av),!e)for(i in this.eventListeners)this._off(i);for(s=0;s<n;s++)if(f=a[s],l=f.split("."),c=l[0],h=l[1],c){if(this.eventListeners[c])this._off(c,h,t)}else for(i in this.eventListeners)this._off(i,h,t);return this}dispatchEvent(e){let t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(a){t.call(this,a.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,a){let n=this;return this.on(e,function(s){let i=s.target.findAncestors(t,!0,n);for(let f=0;f<i.length;f++)s=Z.cloneObject(s),s.currentTarget=i[f],a.call(i[f],s)}),this}remove(){if(this.isDragging())this.stopDrag();return _t._dragElements.delete(this._id),_t._dragElements.forEach((e,t)=>{if(this.isAncestorOf(e.node))_t._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(nf),this._clearSelfAndDescendantCache(zm),this._clearSelfAndDescendantCache(yv),this._clearSelfAndDescendantCache(_v),this._clearSelfAndDescendantCache(Dg),this._clearSelfAndDescendantCache(Mg)}_remove(){this._clearCaches();let e=this.getParent();if(e&&e.children)e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){let t="get"+Z._capitalize(e);if(Z._isFunction(this[t]))return this[t]();return this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];while(e)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,a;if(!e)return this;for(t in e){if(t===wx)continue;if(a=Sv+Z._capitalize(t),Z._isFunction(this[a]))this[a](e[t]);else this._setAttr(t,e[t])}}),this}isListening(){return this._getCache(Mg,this._isListening)}_isListening(e){if(!this.listening())return!1;let a=this.getParent();if(a&&a!==e&&this!==e)return a._isListening(e);else return!0}isVisible(){return this._getCache(Dg,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let a=this.getParent();if(a&&a!==e&&this!==e)return a._isVisible(e);else return!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);let a=this.getLayer(),n=!1;_t._dragElements.forEach((i)=>{if(i.dragStatus!=="dragging")return;else if(i.node.nodeType==="Stage")n=!0;else if(i.node.getLayer()===a)n=!0});let s=!t&&!ve.hitOnDragEnabled&&(n||ve.isTransforming());return this.isListening()&&this.isVisible()&&!s}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,a=0,n,s,i,f;function l(h){n=[],s=h.length;for(i=0;i<s;i++){if(f=h[i],a++,f.nodeType!==Cv)n=n.concat(f.getChildren().slice());if(f._id===t._id)i=s}if(n.length>0&&n[0].getDepth()<=e)l(n)}let c=this.getStage();if(t.nodeType!==Sx&&c)l(c.getChildren());return a}getDepth(){let e=0,t=this.parent;while(t)e++,t=t.parent;return e}_batchTransformChanges(e){if(this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache)this._clearCache(wl),this._clearSelfAndDescendantCache(nf);this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let a=this.getAbsoluteTransform().copy();return a.invert(),a.point(t)}getAbsolutePosition(e){let t=!1,a=this.parent;while(a){if(a.isCached()){t=!0;break}a=a.parent}if(t&&!e)e=!0;let n=this.getAbsoluteTransform(e).getMatrix(),s=new xn,i=this.offset();return s.m=n.slice(),s.translate(i.x,i.y),s.getTranslation()}setAbsolutePosition(e){let{x:t,y:a,...n}=this._clearTransform();this.attrs.x=t,this.attrs.y=a,this._clearCache(wl);let s=this._getAbsoluteTransform().copy();return s.invert(),s.translate(e.x,e.y),e={x:this.attrs.x+s.getTranslation().x,y:this.attrs.y+s.getTranslation().y},this._setTransform(n),this.setPosition({x:e.x,y:e.y}),this._clearCache(wl),this._clearSelfAndDescendantCache(nf),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let{x:t,y:a}=e,n=this.x(),s=this.y();if(t!==void 0)n+=t;if(a!==void 0)s+=a;return this.setPosition({x:n,y:s}),this}_eachAncestorReverse(e,t){let a=[],n=this.getParent(),s,i;if(t&&t._id===this._id)return;a.unshift(this);while(n&&(!t||n._id!==t._id))a.unshift(n),n=n.parent;s=a.length;for(i=0;i<s;i++)e(a[i])}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return Z.warn("Node has no parent. moveToTop function is ignored."),!1;let e=this.index,t=this.parent.getChildren().length;if(e<t-1)return this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0;return!1}moveUp(){if(!this.parent)return Z.warn("Node has no parent. moveUp function is ignored."),!1;let e=this.index,t=this.parent.getChildren().length;if(e<t-1)return this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0;return!1}moveDown(){if(!this.parent)return Z.warn("Node has no parent. moveDown function is ignored."),!1;let e=this.index;if(e>0)return this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0;return!1}moveToBottom(){if(!this.parent)return Z.warn("Node has no parent. moveToBottom function is ignored."),!1;let e=this.index;if(e>0)return this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0;return!1}setZIndex(e){if(!this.parent)return Z.warn("Node has no parent. zIndex parameter is ignored."),this;if(e<0||e>=this.parent.children.length)Z.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(zm,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();if(t&&!t._isUnderCache)e*=t.getAbsoluteOpacity();return e}moveTo(e){if(this.getParent()!==e)this._remove(),e.add(this);return this}toObject(){let e=this.getAttrs(),t,a,n,s,i,f={attrs:{},className:this.getClassName()};for(t in e){if(a=e[t],i=Z.isObject(a)&&!Z._isPlainObject(a)&&!Z._isArray(a),i)continue;if(n=typeof this[t]==="function"&&this[t],delete e[t],s=n?n.call(this):null,e[t]=a,s!==a)f.attrs[t]=a}return Z._prepareToStringify(f)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,a){let n=[];if(t&&this._isMatch(e))n.push(this);let s=this.parent;while(s){if(s===a)return n;if(s._isMatch(e))n.push(s);s=s.parent}return n}isAncestorOf(e){return!1}findAncestor(e,t,a){return this.findAncestors(e,t,a)[0]}_isMatch(e){if(!e)return!1;if(typeof e==="function")return e(this);let t=e.replace(/ /g,"").split(","),a=t.length,n,s;for(n=0;n<a;n++){if(s=t[n],!Z.isValidSelector(s))Z.warn('Selector "'+s+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Z.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Z.warn("Konva is awesome, right?");if(s.charAt(0)==="#"){if(this.id()===s.slice(1))return!0}else if(s.charAt(0)==="."){if(this.hasName(s.slice(1)))return!0}else if(this.className===s||this.nodeType===s)return!0}return!1}getLayer(){let e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(_v,this._getStage)}_getStage(){let e=this.getParent();if(e)return e.getStage();else return null}fire(e,t={},a){if(t.target=t.target||this,a)this._fireAndBubble(e,t);else this._fire(e,t);return this}getAbsoluteTransform(e){if(e)return this._getAbsoluteTransform(e);else return this._getCache(nf,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let t;if(e)return t=new xn,this._eachAncestorReverse(function(a){let n=a.transformsEnabled();if(n==="all")t.multiply(a.getTransform());else if(n==="position")t.translate(a.x()-a.offsetX(),a.y()-a.offsetY())},e),t;else{if(t=this._cache.get(nf)||new xn,this.parent)this.parent.getAbsoluteTransform().copyInto(t);else t.reset();let a=this.transformsEnabled();if(a==="all")t.multiply(this.getTransform());else if(a==="position"){let n=this.attrs.x||0,s=this.attrs.y||0,i=this.attrs.offsetX||0,f=this.attrs.offsetY||0;t.translate(n-i,s-f)}return t.dirty=!1,t}}getAbsoluteScale(e){let t=this;while(t){if(t._isUnderCache)e=t;t=t.getParent()}let n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(wl,this._getTransform)}_getTransform(){var e,t;let a=this._cache.get(wl)||new xn;a.reset();let n=this.x(),s=this.y(),i=ve.getAngle(this.rotation()),f=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,l=(t=this.attrs.scaleY)!==null&&t!==void 0?t:1,c=this.attrs.skewX||0,h=this.attrs.skewY||0,u=this.attrs.offsetX||0,g=this.attrs.offsetY||0;if(n!==0||s!==0)a.translate(n,s);if(i!==0)a.rotate(i);if(c!==0||h!==0)a.skew(c,h);if(f!==1||l!==1)a.scale(f,l);if(u!==0||g!==0)a.translate(-1*u,-1*g);return a.dirty=!1,a}clone(e){let t=Z.cloneObject(this.attrs),a,n,s,i,f;for(a in e)t[a]=e[a];let l=new this.constructor(t);for(a in this.eventListeners){n=this.eventListeners[a],s=n.length;for(i=0;i<s;i++)if(f=n[i],f.name.indexOf(dx)<0){if(!l.eventListeners[a])l.eventListeners[a]=[];l.eventListeners[a].push(f)}}return l}_toKonvaCanvas(e){e=e||{};let t=this.getClientRect(),a=this.getStage(),n=e.x!==void 0?e.x:Math.floor(t.x),s=e.y!==void 0?e.y:Math.floor(t.y),i=e.pixelRatio||1,f=new bi({width:e.width||Math.ceil(t.width)||(a?a.width():0),height:e.height||Math.ceil(t.height)||(a?a.height():0),pixelRatio:i}),l=f.getContext(),c=new bi({width:f.width/f.pixelRatio+Math.abs(n),height:f.height/f.pixelRatio+Math.abs(s),pixelRatio:f.pixelRatio});if(e.imageSmoothingEnabled===!1)l._context.imageSmoothingEnabled=!1;if(l.save(),n||s)l.translate(-1*n,-1*s);return this.drawScene(f,void 0,c),l.restore(),f}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};let t=e.mimeType||null,a=e.quality||null,n=this._toKonvaCanvas(e).toDataURL(t,a);if(e.callback)e.callback(n);return n}toImage(e){return new Promise((t,a)=>{try{let n=e===null||e===void 0?void 0:e.callback;if(n)delete e.callback;Z._urlToImage(this.toDataURL(e),function(s){t(s),n===null||n===void 0||n(s)})}catch(n){a(n)}})}toBlob(e){return new Promise((t,a)=>{try{let n=e===null||e===void 0?void 0:e.callback;if(n)delete e.callback;this.toCanvas(e).toBlob((s)=>{t(s),n===null||n===void 0||n(s)},e===null||e===void 0?void 0:e.mimeType,e===null||e===void 0?void 0:e.quality)}catch(n){a(n)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){if(this.attrs.dragDistance!==void 0)return this.attrs.dragDistance;else if(this.parent)return this.parent.getDragDistance();else return ve.dragDistance}_off(e,t,a){let n=this.eventListeners[e],s,i,f;for(s=0;s<n.length;s++)if(i=n[s].name,f=n[s].handler,(i!=="konva"||t==="konva")&&(!t||i===t)&&(!a||a===f)){if(n.splice(s,1),n.length===0){delete this.eventListeners[e];break}s--}}_fireChangeEvent(e,t,a){this._fire(e+bx,{oldVal:t,newVal:a})}addName(e){if(!this.hasName(e)){let t=this.name(),a=t?t+" "+e:e;this.name(a)}return this}hasName(e){if(!e)return!1;let t=this.name();if(!t)return!1;return(t||"").split(/\s/g).indexOf(e)!==-1}removeName(e){let t=(this.name()||"").split(/\s/g),a=t.indexOf(e);if(a!==-1)t.splice(a,1),this.name(t.join(" "));return this}setAttr(e,t){let a=this[Sv+Z._capitalize(e)];if(Z._isFunction(a))a.call(this,t);else this._setAttr(e,t);return this}_requestDraw(){if(ve.autoDrawEnabled){let e=this.getLayer()||this.getStage();e===null||e===void 0||e.batchDraw()}}_setAttr(e,t){let a=this.attrs[e];if(a===t&&!Z.isObject(t))return;if(t===void 0||t===null)delete this.attrs[e];else this.attrs[e]=t;if(this._shouldFireChangeEvents)this._fireChangeEvent(e,a,t);this._requestDraw()}_setComponentAttr(e,t,a){let n;if(a!==void 0){if(n=this.attrs[e],!n)this.attrs[e]=this.getAttr(e);this.attrs[e][t]=a,this._fireChangeEvent(e,n,a)}}_fireAndBubble(e,t,a){if(t&&this.nodeType===Cv)t.target=this;let n=[jx,qx,vx,kx,Ax,yx];if(!(n.indexOf(e)!==-1&&(a&&(this===a||this.isAncestorOf&&this.isAncestorOf(a))||this.nodeType==="Stage"&&!a))){this._fire(e,t);let i=n.indexOf(e)!==-1&&a&&a.isAncestorOf&&a.isAncestorOf(this)&&!a.isAncestorOf(this.parent);if((t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!i)if(a&&a.parent)this._fireAndBubble.call(this.parent,e,t,a);else this._fireAndBubble.call(this.parent,e,t)}}_getProtoListeners(e){var t,a;let{nodeType:n}=this,s=qe.protoListenerMap.get(n)||{},i=s===null||s===void 0?void 0:s[e];if(i===void 0){i=[];let f=Object.getPrototypeOf(this);while(f){let l=(a=(t=f.eventListeners)===null||t===void 0?void 0:t[e])!==null&&a!==void 0?a:[];i.push(...l),f=Object.getPrototypeOf(f)}s[e]=i,qe.protoListenerMap.set(n,s)}return i}_fire(e,t){t=t||{},t.currentTarget=this,t.type=e;let a=this._getProtoListeners(e);if(a){let s=a.slice();for(let i=0;i<s.length;i++)s[i].handler.call(this,t)}let n=this.eventListeners[e];if(n){let s=n.slice(),i=s.length;for(let l=0;l<s.length;l++)s[l].handler.call(this,t);let f=this.eventListeners[e];if(f)for(let l=i;l<f.length;l++)f[l].handler.call(this,t)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){let t=e?e.pointerId:void 0,a=this.getStage(),n=this.getAbsolutePosition();if(!a)return;let s=a._getPointerById(t)||a._changedPointerPositions[0]||n;_t._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:t,startEvent:e})}startDrag(e,t=!0){if(!_t._dragElements.has(this._id))this._createDragElement(e);let a=_t._dragElements.get(this._id);a.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:a.startEvent&&a.startEvent.evt||e&&e.evt},t)}_setDragPosition(e,t){let a=this.getStage()._getPointerById(t.pointerId);if(!a)return;let n={x:a.x-t.offset.x,y:a.y-t.offset.y},s=this.dragBoundFunc();if(s!==void 0){let i=s.call(this,n,e);if(!i)Z.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.");else n=i}if(!this._lastPos||this._lastPos.x!==n.x||this._lastPos.y!==n.y)this.setAbsolutePosition(n),this._requestDraw();this._lastPos=n}stopDrag(e){let t=_t._dragElements.get(this._id);if(t)t.dragStatus="stopped";_t._endDragBefore(e),_t._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){let e=_t._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){if(!(e.evt.button===void 0||ve.dragButtons.indexOf(e.evt.button)>=0))return;if(this.isDragging())return;let n=!1;if(_t._dragElements.forEach((s)=>{if(this.isAncestorOf(s.node))n=!0}),!n)this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let t=_t._dragElements.get(this._id),a=t&&t.dragStatus==="dragging",n=t&&t.dragStatus==="ready";if(a)this.stopDrag();else if(n)_t._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let a={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return Z.haveIntersection(a,this.getClientRect())}static create(e,t){if(Z._isString(e))e=JSON.parse(e);return this._createNode(e,t)}static _createNode(e,t){let a=qe.prototype.getClassName.call(e),n=e.children,s,i,f;if(t)e.attrs.container=t;if(!ve[a])Z.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape";if(s=new ve[a](e.attrs),n){i=n.length;for(f=0;f<i;f++)s.add(qe._createNode(n[f]))}return s}}qe.protoListenerMap=new Map;qe.prototype.nodeType="Node";qe.prototype._attrsAffectingSize=[];qe.prototype.eventListeners={};qe.prototype.on(Cx,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(wl),this._clearSelfAndDescendantCache(nf)});qe.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(Dg)});qe.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(Mg)});qe.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(zm)});var oa=I.addGetterSetter;oa(qe,"zIndex");oa(qe,"absolutePosition");oa(qe,"position");oa(qe,"x",0,we());oa(qe,"y",0,we());oa(qe,"globalCompositeOperation","source-over",h0());oa(qe,"opacity",1,we());oa(qe,"name","",h0());oa(qe,"id","",h0());oa(qe,"rotation",0,we());I.addComponentsGetterSetter(qe,"scale",["x","y"]);oa(qe,"scaleX",1,we());oa(qe,"scaleY",1,we());I.addComponentsGetterSetter(qe,"skew",["x","y"]);oa(qe,"skewX",0,we());oa(qe,"skewY",0,we());I.addComponentsGetterSetter(qe,"offset",["x","y"]);oa(qe,"offsetX",0,we());oa(qe,"offsetY",0,we());oa(qe,"dragDistance",void 0,we());oa(qe,"width",0,we());oa(qe,"height",0,we());oa(qe,"listening",!0,Rn());oa(qe,"preventDefault",!0,Rn());oa(qe,"filters",void 0,function(e){return this._filterUpToDate=!1,e});oa(qe,"visible",!0,Rn());oa(qe,"transformsEnabled","all",h0());oa(qe,"size");oa(qe,"dragBoundFunc");oa(qe,"draggable",!1,Rn());I.backCompat(qe,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class kn extends qe{constructor(){super(...arguments);this.children=[]}getChildren(e){let t=this.children||[];if(e)return t.filter(e);return t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((e)=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((e)=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let a=0;a<e.length;a++)this.add(e[a]);return this}let t=e[0];if(t.getParent())return t.moveTo(this),this;return this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this}destroy(){if(this.hasChildren())this.destroyChildren();return super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){let t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){let a=[];return this._descendants((n)=>{let s=n._isMatch(e);if(s)a.push(n);if(s&&t)return!0;return!1}),a}_descendants(e){let t=!1,a=this.getChildren();for(let n of a){if(t=e(n),t)return!0;if(!n.hasChildren())continue;if(t=n._descendants(e),t)return!0}return!1}toObject(){let e=qe.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach((t)=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();while(t){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=qe.prototype.clone.call(this,e);return this.getChildren().forEach(function(a){t.add(a.clone())}),t}getAllIntersections(e){let t=[];return this.find("Shape").forEach((a)=>{if(a.isVisible()&&a.intersects(e))t.push(a)}),t}_clearSelfAndDescendantCache(e){var t;if(super._clearSelfAndDescendantCache(e),this.isCached())return;(t=this.children)===null||t===void 0||t.forEach(function(a){a._clearSelfAndDescendantCache(e)})}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,a){t.index=a}),this._requestDraw()}drawScene(e,t,a){let n=this.getLayer(),s=e||n&&n.getCanvas(),i=s&&s.getContext(),f=this._getCanvasCache(),l=f&&f.scene,c=s&&s.isCache;if(!this.isVisible()&&!c)return this;if(l){i.save();let h=this.getAbsoluteTransform(t).getMatrix();i.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren("drawScene",s,t,a);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let a=this.getLayer(),n=e||a&&a.hitCanvas,s=n&&n.getContext(),i=this._getCanvasCache();if(i&&i.hit){s.save();let l=this.getAbsoluteTransform(t).getMatrix();s.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",n,t);return this}_drawChildren(e,t,a,n){var s;let i=t&&t.getContext(),f=this.clipWidth(),l=this.clipHeight(),c=this.clipFunc(),h=typeof f==="number"&&typeof l==="number"||c,u=a===this;if(h){i.save();let b=this.getAbsoluteTransform(a),d=b.getMatrix();i.transform(d[0],d[1],d[2],d[3],d[4],d[5]),i.beginPath();let j;if(c)j=c.call(this,i,this);else{let A=this.clipX(),C=this.clipY();i.rect(A||0,C||0,f,l)}i.clip.apply(i,j),d=b.copy().invert().getMatrix(),i.transform(d[0],d[1],d[2],d[3],d[4],d[5])}let g=!u&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";if(g)i.save(),i._applyGlobalCompositeOperation(this);if((s=this.children)===null||s===void 0||s.forEach(function(b){b[e](t,a,n)}),g)i.restore();if(h)i.restore()}getClientRect(e={}){var t;let{skipTransform:a,relativeTo:n}=e,s,i,f,l,c={x:1/0,y:1/0,width:0,height:0},h=this;(t=this.children)===null||t===void 0||t.forEach(function(b){if(!b.visible())return;let d=b.getClientRect({relativeTo:h,skipShadow:e.skipShadow,skipStroke:e.skipStroke});if(d.width===0&&d.height===0)return;if(s===void 0)s=d.x,i=d.y,f=d.x+d.width,l=d.y+d.height;else s=Math.min(s,d.x),i=Math.min(i,d.y),f=Math.max(f,d.x+d.width),l=Math.max(l,d.y+d.height)});let u=this.find("Shape"),g=!1;for(let b=0;b<u.length;b++)if(u[b]._isVisible(this)){g=!0;break}if(g&&s!==void 0)c={x:s,y:i,width:f-s,height:l-i};else c={x:0,y:0,width:0,height:0};if(!a)return this._transformedRect(c,n);return c}}I.addComponentsGetterSetter(kn,"clip",["x","y","width","height"]);I.addGetterSetter(kn,"clipX",void 0,we());I.addGetterSetter(kn,"clipY",void 0,we());I.addGetterSetter(kn,"clipWidth",void 0,we());I.addGetterSetter(kn,"clipHeight",void 0,we());I.addGetterSetter(kn,"clipFunc");var Kh=new Map,Fv=ve._global.PointerEvent!==void 0;function Im(e){return Kh.get(e)}function Gm(e){return{evt:e,pointerId:e.pointerId}}function Xm(e,t){return Kh.get(e)===t}function Km(e,t){if(Mr(e),!t.getStage())return;if(Kh.set(e,t),Fv)t._fire("gotpointercapture",Gm(new PointerEvent("gotpointercapture")))}function Mr(e,t){let a=Kh.get(e);if(!a)return;let n=a.getStage();if(n&&n.content);if(Kh.delete(e),Fv)a._fire("lostpointercapture",Gm(new PointerEvent("lostpointercapture")))}var Fx="Stage",Ox="string",Bv="px",Bx="mouseout",Hv="mouseleave",Mv="mouseover",Dv="mouseenter",xv="mousemove",Rv="mousedown",Nv="mouseup",Lh="pointermove",Vh="pointerdown",Fo="pointerup",Yh="pointercancel",Tx="lostpointercapture",Lm="pointerout",Jh="pointerleave",Vm="pointerover",Ym="pointerenter",Rg="contextmenu",Ev="touchstart",zv="touchend",Uv="touchmove",Iv="touchcancel",Ng="wheel",Hx=5,Mx=[[Dv,"_pointerenter"],[Rv,"_pointerdown"],[xv,"_pointermove"],[Nv,"_pointerup"],[Hv,"_pointerleave"],[Ev,"_pointerdown"],[Uv,"_pointermove"],[zv,"_pointerup"],[Iv,"_pointercancel"],[Mv,"_pointerover"],[Ng,"_wheel"],[Rg,"_contextmenu"],[Vh,"_pointerdown"],[Lh,"_pointermove"],[Fo,"_pointerup"],[Yh,"_pointercancel"],[Jh,"_pointerleave"],[Tx,"_lostpointercapture"]],xg={mouse:{[Lm]:Bx,[Jh]:Hv,[Vm]:Mv,[Ym]:Dv,[Lh]:xv,[Vh]:Rv,[Fo]:Nv,[Yh]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Lm]:"touchout",[Jh]:"touchleave",[Vm]:"touchover",[Ym]:"touchenter",[Lh]:Uv,[Vh]:Ev,[Fo]:zv,[Yh]:Iv,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Lm]:Lm,[Jh]:Jh,[Vm]:Vm,[Ym]:Ym,[Lh]:Lh,[Vh]:Vh,[Fo]:Fo,[Yh]:Yh,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Qh=(e)=>{if(e.indexOf("pointer")>=0)return"pointer";if(e.indexOf("touch")>=0)return"touch";return"mouse"},_o=(e)=>{let t=Qh(e);if(t==="pointer")return ve.pointerEventsEnabled&&xg.pointer;if(t==="touch")return xg.touch;if(t==="mouse")return xg.mouse};function Tv(e={}){if(e.clipFunc||e.clipWidth||e.clipHeight)Z.warn("Stage does not support clipping. Please use clip for Layers or Groups.");return e}var Dx="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);",Oo=[];class Bo extends kn{constructor(e){super(Tv(e));this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Oo.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Tv(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()==="Layer",a=e.getType()==="FastLayer";if(!(t||a))Z.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;let e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===Ox){let t;if(e.charAt(0)==="."){let a=e.slice(1);e=document.getElementsByClassName(a)[0]}else{if(e.charAt(0)!=="#")t=e;else t=e.slice(1);e=document.getElementById(t)}if(!e)throw"Can not find container in document with id "+t}if(this._setAttr("container",e),this.content){if(this.content.parentElement)this.content.parentElement.removeChild(this.content);e.appendChild(this.content)}return this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let a=0;a<t;a++)e[a].clear();return this}clone(e){if(!e)e={};return e.container=typeof document<"u"&&document.createElement("div"),kn.prototype.clone.call(this,e)}destroy(){super.destroy();let e=this.content;if(e&&Z._isInDocument(e))this.container().removeChild(e);let t=Oo.indexOf(this);if(t>-1)Oo.splice(t,1);return Z.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];if(!e)return Z.warn(Dx),null;return{x:e.x,y:e.y}}_getPointerById(e){return this._pointerPositions.find((t)=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new bi({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),a=t.getContext()._context,n=this.children;if(e.x||e.y)a.translate(-1*e.x,-1*e.y);return n.forEach(function(s){if(!s.isVisible())return;let i=s._toKonvaCanvas(e);a.drawImage(i._canvas,e.x,e.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),t}getIntersection(e){if(!e)return null;let t=this.children,a=t.length,n=a-1;for(let s=n;s>=0;s--){let i=t[s].getIntersection(e);if(i)return i}return null}_resizeDOM(){let e=this.width(),t=this.height();if(this.content)this.content.style.width=e+Bv,this.content.style.height=t+Bv;this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach((a)=>{a.setSize({width:e,height:t}),a.draw()})}add(e,...t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(e);let a=this.children.length;if(a>Hx)Z.warn("The stage has "+a+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.");if(e.setSize({width:this.width(),height:this.height()}),e.draw(),ve.isBrowser)this.content.appendChild(e.canvas._canvas);return this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Xm(e,this)}setPointerCapture(e){Km(e,this)}releaseCapture(e){Mr(e,this)}getLayers(){return this.children}_bindContentEvents(){if(!ve.isBrowser)return;Mx.forEach(([e,t])=>{this.content.addEventListener(e,(a)=>{this[t](a)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);let t=_o(e.type);if(t)this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=_o(e.type);if(t)this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];if(t&&!t.getStage())t=null;return t}_pointerleave(e){let t=_o(e.type),a=Qh(e.type);if(!t)return;this.setPointersPositions(e);let n=this._getTargetShape(a),s=!(ve.isDragging()||ve.isTransforming())||ve.hitOnDragEnabled;if(n&&s)n._fireAndBubble(t.pointerout,{evt:e}),n._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[a+"targetShape"]=null;else if(s)this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this});this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){let t=_o(e.type),a=Qh(e.type);if(!t)return;this.setPointersPositions(e);let n=!1;if(this._changedPointerPositions.forEach((s)=>{let i=this.getIntersection(s);if(_t.justDragged=!1,ve["_"+a+"ListenClick"]=!0,!i||!i.isListening()){this[a+"ClickStartShape"]=void 0;return}if(ve.capturePointerEventsEnabled)i.setPointerCapture(s.id);this[a+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:s.id}),n=!0;let f=e.type.indexOf("touch")>=0;if(i.preventDefault()&&e.cancelable&&f)e.preventDefault()}),!n)this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){let t=_o(e.type),a=Qh(e.type);if(!t)return;let n=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(ve.isDragging()&&_t.node.preventDefault()&&e.cancelable&&n)e.preventDefault();if(this.setPointersPositions(e),!(!(ve.isDragging()||ve.isTransforming())||ve.hitOnDragEnabled))return;let i={},f=!1,l=this._getTargetShape(a);if(this._changedPointerPositions.forEach((c)=>{let h=Im(c.id)||this.getIntersection(c),u=c.id,g={evt:e,pointerId:u},b=l!==h;if(b&&l)l._fireAndBubble(t.pointerout,{...g},h),l._fireAndBubble(t.pointerleave,{...g},h);if(h){if(i[h._id])return;i[h._id]=!0}if(h&&h.isListening()){if(f=!0,b)h._fireAndBubble(t.pointerover,{...g},l),h._fireAndBubble(t.pointerenter,{...g},l),this[a+"targetShape"]=h;h._fireAndBubble(t.pointermove,{...g})}else if(l)this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u}),this[a+"targetShape"]=null}),!f)this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=_o(e.type),a=Qh(e.type);if(!t)return;this.setPointersPositions(e);let n=this[a+"ClickStartShape"],s=this[a+"ClickEndShape"],i={},f=!1;if(this._changedPointerPositions.forEach((l)=>{let c=Im(l.id)||this.getIntersection(l);if(c){if(c.releaseCapture(l.id),i[c._id])return;i[c._id]=!0}let h=l.id,u={evt:e,pointerId:h},g=!1;if(ve["_"+a+"InDblClickWindow"])g=!0,clearTimeout(this[a+"DblTimeout"]);else if(!_t.justDragged)ve["_"+a+"InDblClickWindow"]=!0,clearTimeout(this[a+"DblTimeout"]);if(this[a+"DblTimeout"]=setTimeout(function(){ve["_"+a+"InDblClickWindow"]=!1},ve.dblClickWindow),c&&c.isListening()){if(f=!0,this[a+"ClickEndShape"]=c,c._fireAndBubble(t.pointerup,{...u}),ve["_"+a+"ListenClick"]&&n&&n===c){if(c._fireAndBubble(t.pointerclick,{...u}),g&&s&&s===c)c._fireAndBubble(t.pointerdblclick,{...u})}}else{if(this[a+"ClickEndShape"]=null,!f)this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),f=!0;if(ve["_"+a+"ListenClick"])this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:h});if(g)this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:h})}}),!f)this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id});if(ve["_"+a+"ListenClick"]=!1,e.cancelable&&a!=="touch"&&a!=="pointer")e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());if(t&&t.isListening())t._fireAndBubble(Rg,{evt:e});else this._fire(Rg,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());if(t&&t.isListening())t._fireAndBubble(Ng,{evt:e});else this._fire(Ng,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=Im(e.pointerId)||this.getIntersection(this.getPointerPosition());if(t)t._fireAndBubble(Fo,Gm(e));Mr(e.pointerId)}_lostpointercapture(e){Mr(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),a=null,n=null;if(e=e?e:window.event,e.touches!==void 0)this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,(s)=>{this._pointerPositions.push({id:s.identifier,x:(s.clientX-t.left)/t.scaleX,y:(s.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,(s)=>{this._changedPointerPositions.push({id:s.identifier,x:(s.clientX-t.left)/t.scaleX,y:(s.clientY-t.top)/t.scaleY})});else a=(e.clientX-t.left)/t.scaleX,n=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:a,y:n},this._pointerPositions=[{x:a,y:n,id:Z._getFirstPointerId(e)}],this._changedPointerPositions=[{x:a,y:n,id:Z._getFirstPointerId(e)}]}_setPointerPosition(e){Z.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new bi({width:this.width(),height:this.height()}),this.bufferHitCanvas=new Tr({pixelRatio:1,width:this.width(),height:this.height()}),!ve.isBrowser)return;let e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return Z.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}}Bo.prototype.nodeType=Fx;lt(Bo);I.addGetterSetter(Bo,"container");if(ve.isBrowser)document.addEventListener("visibilitychange",()=>{Oo.forEach((e)=>{e.batchDraw()})});var Gv="hasShadow",Xv="shadowRGBA",Kv="patternImage",Lv="linearGradient",Vv="radialGradient",Jm;function Eg(){if(Jm)return Jm;return Jm=Z.createCanvasElement().getContext("2d"),Jm}var Dr={};function xx(e){let t=this.attrs.fillRule;if(t)e.fill(t);else e.fill()}function Rx(e){e.stroke()}function Nx(e){let t=this.attrs.fillRule;if(t)e.fill(t);else e.fill()}function Ex(e){e.stroke()}function zx(){this._clearCache(Gv)}function Ux(){this._clearCache(Xv)}function Ix(){this._clearCache(Kv)}function Gx(){this._clearCache(Lv)}function Xx(){this._clearCache(Vv)}class je extends qe{constructor(e){super(e);let t,a=0;while(!0){if(t=Z.getHitColor(),t&&!(t in Dr))break;if(a++,a>=1e4){Z.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=Z.getRandomColor();break}}this.colorKey=t,Dr[t]=this}getContext(){return Z.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Z.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Gv,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Kv,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let t=Eg().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){let a=new xn;a.translate(this.fillPatternX(),this.fillPatternY()),a.rotate(ve.getAngle(this.fillPatternRotation())),a.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),a.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=a.getMatrix(),s=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(Lv,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Eg(),a=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=t.createLinearGradient(a.x,a.y,n.x,n.y);for(let i=0;i<e.length;i+=2)s.addColorStop(e[i],e[i+1]);return s}}_getRadialGradient(){return this._getCache(Vv,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=Eg(),a=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),s=t.createRadialGradient(a.x,a.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let i=0;i<e.length;i+=2)s.addColorStop(e[i],e[i+1]);return s}}getShadowRGBA(){return this._getCache(Xv,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;let e=Z.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>{return this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())})}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>{return this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops())})}hasHitStroke(){let e=this.hitStrokeWidth();if(e==="auto")return this.hasStroke();return this.strokeEnabled()&&!!e}intersects(e){let t=this.getStage();if(!t)return!1;let a=t.bufferHitCanvas;return a.getContext().clear(),this.drawHit(a,void 0,!0),a.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return qe.prototype.destroy.call(this),delete Dr[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0?t:!0))return!1;let n=e||this.hasFill(),s=this.hasStroke(),i=this.getAbsoluteOpacity()!==1;if(n&&s&&i)return!0;let f=this.hasShadow(),l=this.shadowForStrokeEnabled();if(n&&s&&f&&l)return!0;return!1}setStrokeHitEnabled(e){if(Z.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e)this.hitStrokeWidth("auto");else this.hitStrokeWidth(0)}getStrokeHitEnabled(){if(this.hitStrokeWidth()===0)return!1;else return!0}getSelfRect(){let e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,a=this.getParent();while(a){if(a.isCached()){t=!0;break}a=a.getParent()}let n=e.skipTransform,s=e.relativeTo||t&&this.getStage()||void 0,i=this.getSelfRect(),l=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,c=i.width+l,h=i.height+l,u=!e.skipShadow&&this.hasShadow(),g=u?this.shadowOffsetX():0,b=u?this.shadowOffsetY():0,d=c+Math.abs(g),j=h+Math.abs(b),A=u&&this.shadowBlur()||0,C=d+A*2,y=j+A*2,O={width:C,height:y,x:-(l/2+A)+Math.min(g,0)+i.x,y:-(l/2+A)+Math.min(b,0)+i.y};if(!n)return this._transformedRect(O,s);return O}drawScene(e,t,a){let n=this.getLayer(),s=e||n.getCanvas(),i=s.getContext(),f=this._getCanvasCache(),l=this.getSceneFunc(),c=this.hasShadow(),h,u=!1,g=t===this;if(!this.isVisible()&&!g)return this;if(f){i.save();let b=this.getAbsoluteTransform(t).getMatrix();return i.transform(b[0],b[1],b[2],b[3],b[4],b[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!l)return this;if(i.save(),this._useBufferCanvas()){h=this.getStage();let b=a||h.bufferCanvas,d=b.getContext();if(a)d.save(),d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,b.width,b.height),d.restore();else d.clear();d.save(),d._applyLineJoin(this),d._applyMiterLimit(this);let j=this.getAbsoluteTransform(t).getMatrix();d.transform(j[0],j[1],j[2],j[3],j[4],j[5]),l.call(this,d,this),d.restore();let A=b.pixelRatio;if(c)i._applyShadow(this);if(!g)i._applyOpacity(this),i._applyGlobalCompositeOperation(this);i.drawImage(b._canvas,b.x||0,b.y||0,b.width/A,b.height/A)}else{if(i._applyLineJoin(this),i._applyMiterLimit(this),!g){let b=this.getAbsoluteTransform(t).getMatrix();i.transform(b[0],b[1],b[2],b[3],b[4],b[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}if(c)i._applyShadow(this);l.call(this,i,this)}return i.restore(),this}drawHit(e,t,a=!1){if(!this.shouldDrawHit(t,a))return this;let n=this.getLayer(),s=e||n.hitCanvas,i=s&&s.getContext(),f=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),c=l&&l.hit;if(!this.colorKey)Z.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()");if(c){i.save();let u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!f)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5])}return f.call(this,i,this),i.restore(),this}drawHitFromCache(e=0){let t=this._getCanvasCache(),a=this._getCachedSceneCanvas(),n=t.hit,s=n.getContext(),i=n.getWidth(),f=n.getHeight();s.clear(),s.drawImage(a._canvas,0,0,i,f);try{let l=s.getImageData(0,0,i,f),c=l.data,h=c.length,u=Z._hexToRgb(this.colorKey);for(let g=0;g<h;g+=4)if(c[g+3]>e)c[g]=u.r,c[g+1]=u.g,c[g+2]=u.b,c[g+3]=255;else c[g+3]=0;s.putImageData(l,0,0)}catch(l){Z.error("Unable to draw hit graph from cached scene canvas. "+l.message)}return this}hasPointerCapture(e){return Xm(e,this)}setPointerCapture(e){Km(e,this)}releaseCapture(e){Mr(e,this)}}je.prototype._fillFunc=xx;je.prototype._strokeFunc=Rx;je.prototype._fillFuncHit=Nx;je.prototype._strokeFuncHit=Ex;je.prototype._centroid=!1;je.prototype.nodeType="Shape";lt(je);je.prototype.eventListeners={};je.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",zx);je.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Ux);je.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",Ix);je.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Gx);je.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Xx);I.addGetterSetter(je,"stroke",void 0,Hg());I.addGetterSetter(je,"strokeWidth",2,we());I.addGetterSetter(je,"fillAfterStrokeEnabled",!1);I.addGetterSetter(je,"hitStrokeWidth","auto",Ih());I.addGetterSetter(je,"strokeHitEnabled",!0,Rn());I.addGetterSetter(je,"perfectDrawEnabled",!0,Rn());I.addGetterSetter(je,"shadowForStrokeEnabled",!0,Rn());I.addGetterSetter(je,"lineJoin");I.addGetterSetter(je,"lineCap");I.addGetterSetter(je,"miterLimit");I.addGetterSetter(je,"sceneFunc");I.addGetterSetter(je,"hitFunc");I.addGetterSetter(je,"dash");I.addGetterSetter(je,"dashOffset",0,we());I.addGetterSetter(je,"shadowColor",void 0,h0());I.addGetterSetter(je,"shadowBlur",0,we());I.addGetterSetter(je,"shadowOpacity",1,we());I.addComponentsGetterSetter(je,"shadowOffset",["x","y"]);I.addGetterSetter(je,"shadowOffsetX",0,we());I.addGetterSetter(je,"shadowOffsetY",0,we());I.addGetterSetter(je,"fillPatternImage");I.addGetterSetter(je,"fill",void 0,Hg());I.addGetterSetter(je,"fillPatternX",0,we());I.addGetterSetter(je,"fillPatternY",0,we());I.addGetterSetter(je,"fillLinearGradientColorStops");I.addGetterSetter(je,"strokeLinearGradientColorStops");I.addGetterSetter(je,"fillRadialGradientStartRadius",0);I.addGetterSetter(je,"fillRadialGradientEndRadius",0);I.addGetterSetter(je,"fillRadialGradientColorStops");I.addGetterSetter(je,"fillPatternRepeat","repeat");I.addGetterSetter(je,"fillEnabled",!0);I.addGetterSetter(je,"strokeEnabled",!0);I.addGetterSetter(je,"shadowEnabled",!0);I.addGetterSetter(je,"dashEnabled",!0);I.addGetterSetter(je,"strokeScaleEnabled",!0);I.addGetterSetter(je,"fillPriority","color");I.addComponentsGetterSetter(je,"fillPatternOffset",["x","y"]);I.addGetterSetter(je,"fillPatternOffsetX",0,we());I.addGetterSetter(je,"fillPatternOffsetY",0,we());I.addComponentsGetterSetter(je,"fillPatternScale",["x","y"]);I.addGetterSetter(je,"fillPatternScaleX",1,we());I.addGetterSetter(je,"fillPatternScaleY",1,we());I.addComponentsGetterSetter(je,"fillLinearGradientStartPoint",["x","y"]);I.addComponentsGetterSetter(je,"strokeLinearGradientStartPoint",["x","y"]);I.addGetterSetter(je,"fillLinearGradientStartPointX",0);I.addGetterSetter(je,"strokeLinearGradientStartPointX",0);I.addGetterSetter(je,"fillLinearGradientStartPointY",0);I.addGetterSetter(je,"strokeLinearGradientStartPointY",0);I.addComponentsGetterSetter(je,"fillLinearGradientEndPoint",["x","y"]);I.addComponentsGetterSetter(je,"strokeLinearGradientEndPoint",["x","y"]);I.addGetterSetter(je,"fillLinearGradientEndPointX",0);I.addGetterSetter(je,"strokeLinearGradientEndPointX",0);I.addGetterSetter(je,"fillLinearGradientEndPointY",0);I.addGetterSetter(je,"strokeLinearGradientEndPointY",0);I.addComponentsGetterSetter(je,"fillRadialGradientStartPoint",["x","y"]);I.addGetterSetter(je,"fillRadialGradientStartPointX",0);I.addGetterSetter(je,"fillRadialGradientStartPointY",0);I.addComponentsGetterSetter(je,"fillRadialGradientEndPoint",["x","y"]);I.addGetterSetter(je,"fillRadialGradientEndPointX",0);I.addGetterSetter(je,"fillRadialGradientEndPointY",0);I.addGetterSetter(je,"fillPatternRotation",0);I.addGetterSetter(je,"fillRule",void 0,h0());I.backCompat(je,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Kx="beforeDraw",Lx="draw",Yv=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Vx=Yv.length;class u0 extends kn{constructor(e){super(e);this.canvas=new bi,this.hitCanvas=new Tr({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();if(t&&t.content)if(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1)t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas);else t.content.appendChild(this.getNativeCanvasElement());return this}moveToTop(){qe.prototype.moveToTop.call(this);let e=this.getStage();if(e&&e.content)e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement());return!0}moveUp(){if(!qe.prototype.moveUp.call(this))return!1;let t=this.getStage();if(!t||!t.content)return!1;if(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1)t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas);else t.content.appendChild(this.getNativeCanvasElement());return!0}moveDown(){if(qe.prototype.moveDown.call(this)){let e=this.getStage();if(e){let t=e.children;if(e.content)e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas)}return!0}return!1}moveToBottom(){if(qe.prototype.moveToBottom.call(this)){let e=this.getStage();if(e){let t=e.children;if(e.content)e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas)}return!0}return!1}getLayer(){return this}remove(){let e=this.getNativeCanvasElement();if(qe.prototype.remove.call(this),e&&e.parentNode&&Z._isInDocument(e))e.parentNode.removeChild(e);return this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){let t=e.getType();if(t!=="Group"&&t!=="Shape")Z.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),qe.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){if(this.visible())this.canvas._canvas.style.display="block";else this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Z.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Z.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){if(!this._waitingForDraw)this._waitingForDraw=!0,Z.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1});return this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,a=!1;while(!0){for(let n=0;n<Vx;n++){let s=Yv[n],i=this._getIntersection({x:e.x+s.x*t,y:e.y+s.y*t}),f=i.shape;if(f)return f;if(a=!!i.antialiased,!i.antialiased)break}if(a)t+=1;else return null}}_getIntersection(e){let t=this.hitCanvas.pixelRatio,a=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,n=a[3];if(n===255){let s=Z.getHitColorKey(a[0],a[1],a[2]),i=Dr[s];if(i)return{shape:i};return{antialiased:!0}}else if(n>0)return{antialiased:!0};return{}}drawScene(e,t,a){let n=this.getLayer(),s=e||n&&n.getCanvas();if(this._fire(Kx,{node:this}),this.clearBeforeDraw())s.getContext().clear();return kn.prototype.drawScene.call(this,s,t,a),this._fire(Lx,{node:this}),this}drawHit(e,t){let a=this.getLayer(),n=e||a&&a.hitCanvas;if(a&&a.clearBeforeDraw())a.getHitCanvas().getContext().clear();return kn.prototype.drawHit.call(this,n,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Z.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Z.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;if(!!this.hitCanvas._canvas.parentNode)e.content.removeChild(this.hitCanvas._canvas);else e.content.appendChild(this.hitCanvas._canvas)}destroy(){return Z.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}u0.prototype.nodeType="Layer";lt(u0);I.addGetterSetter(u0,"imageSmoothingEnabled",!0);I.addGetterSetter(u0,"clearBeforeDraw",!0);I.addGetterSetter(u0,"hitGraphEnabled",!0,Rn());class Zh extends u0{constructor(e){super(e);this.listening(!1),Z.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Zh.prototype.nodeType="FastLayer";lt(Zh);class m0 extends kn{_validateAdd(e){let t=e.getType();if(t!=="Group"&&t!=="Shape")Z.throw("You may only add groups and shapes to groups.")}}m0.prototype.nodeType="Group";lt(m0);var zg=function(){if(gl.performance&&gl.performance.now)return function(){return gl.performance.now()};return function(){return new Date().getTime()}}();class is{constructor(e,t){this.id=is.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:zg(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){let t=[];if(e)t=Array.isArray(e)?e:[e];return this.layers=t,this}getLayers(){return this.layers}addLayer(e){let t=this.layers,a=t.length;for(let n=0;n<a;n++)if(t[n]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){let t=is.animations,a=t.length;for(let n=0;n<a;n++)if(t[n].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=zg(),is._addAnimation(this),this}stop(){return is._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1000/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){let t=e.id,a=this.animations,n=a.length;for(let s=0;s<n;s++)if(a[s].id===t){this.animations.splice(s,1);break}}static _runFrames(){let e={},t=this.animations;for(let a=0;a<t.length;a++){let n=t[a],s=n.layers,i=n.func;n._updateFrameObject(zg());let f=s.length,l;if(i)l=i.call(n,n.frame)!==!1;else l=!0;if(!l)continue;for(let c=0;c<f;c++){let h=s[c];if(h._id!==void 0)e[h._id]=h}}for(let a in e){if(!e.hasOwnProperty(a))continue;e[a].batchDraw()}}static _animationLoop(){let e=is;if(e.animations.length)e._runFrames(),Z.requestAnimFrame(e._animationLoop);else e.animRunning=!1}static _handleAnimation(){if(!this.animRunning)this.animRunning=!0,Z.requestAnimFrame(this._animationLoop)}}is.animations=[];is.animIdCounter=0;is.animRunning=!1;var Yx={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Jx=1,Jv=2,Qv=3,Zv=["fill","stroke","shadowColor"],Qx=0;class $v{constructor(e,t,a,n,s,i,f){this.prop=e,this.propFunc=t,this.begin=n,this._pos=n,this.duration=i,this._change=0,this.prevPos=0,this.yoyo=f,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=a,this._change=s-this.begin,this.pause()}fire(e){let t=this[e];if(t)t()}setTime(e){if(e>this.duration)if(this.yoyo)this._time=this.duration,this.reverse();else this.finish();else if(e<0)if(this.yoyo)this._time=0,this.play();else this.reset();else this._time=e,this.update()}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){if(e===void 0)e=this._time;return this.func(e,this.begin,this._change,this.duration)}play(){this.state=Jv,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=Qv,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){let e=this.getTimer()-this._startTime;if(this.state===Jv)this.setTime(e);else if(this.state===Qv)this.setTime(this.duration-e)}pause(){this.state=Jx,this.fire("onPause")}getTimer(){return new Date().getTime()}}class ca{constructor(e){let t=this,a=e.node,n=a._id,s=e.easing||To.Linear,i=!!e.yoyo,f,l;if(typeof e.duration>"u")f=0.3;else if(e.duration===0)f=0.001;else f=e.duration;this.node=a,this._id=Qx++;let c=a.getLayer()||(a instanceof ve.Stage?a.getLayers():null);if(!c)Z.error("Tween constructor have `node` that is not in a layer. Please add node into layer first.");if(this.anim=new is(function(){t.tween.onEnterFrame()},c),this.tween=new $v(l,function(h){t._tweenFunc(h)},s,0,1,f*1000,i),this._addListeners(),!ca.attrs[n])ca.attrs[n]={};if(!ca.attrs[n][this._id])ca.attrs[n][this._id]={};if(!ca.tweens[n])ca.tweens[n]={};for(l in e)if(Yx[l]===void 0)this._addAttr(l,e[l]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){let a=this.node,n=a._id,s,i,f,l,c,h=ca.tweens[n][e];if(h)delete ca.attrs[n][h][e];let u=a.getAttr(e);if(Z._isArray(t)){if(s=[],i=Math.max(t.length,u.length),e==="points"&&t.length!==u.length)if(t.length>u.length)l=u,u=Z._prepareArrayForTween(u,t,a.closed());else f=t,t=Z._prepareArrayForTween(t,u,a.closed());if(e.indexOf("fill")===0)for(let g=0;g<i;g++)if(g%2===0)s.push(t[g]-u[g]);else{let b=Z.colorToRGBA(u[g]);c=Z.colorToRGBA(t[g]),u[g]=b,s.push({r:c.r-b.r,g:c.g-b.g,b:c.b-b.b,a:c.a-b.a})}else for(let g=0;g<i;g++)s.push(t[g]-u[g])}else if(Zv.indexOf(e)!==-1)u=Z.colorToRGBA(u),c=Z.colorToRGBA(t),s={r:c.r-u.r,g:c.g-u.g,b:c.b-u.b,a:c.a-u.a};else s=t-u;ca.attrs[n][this._id][e]={start:u,diff:s,end:t,trueEnd:f,trueStart:l},ca.tweens[n][e]=this._id}_tweenFunc(e){let t=this.node,a=ca.attrs[t._id][this._id],n,s,i,f,l,c,h,u;for(n in a){if(s=a[n],i=s.start,f=s.diff,u=s.end,Z._isArray(i))if(l=[],h=Math.max(i.length,u.length),n.indexOf("fill")===0)for(c=0;c<h;c++)if(c%2===0)l.push((i[c]||0)+f[c]*e);else l.push("rgba("+Math.round(i[c].r+f[c].r*e)+","+Math.round(i[c].g+f[c].g*e)+","+Math.round(i[c].b+f[c].b*e)+","+(i[c].a+f[c].a*e)+")");else for(c=0;c<h;c++)l.push((i[c]||0)+f[c]*e);else if(Zv.indexOf(n)!==-1)l="rgba("+Math.round(i.r+f.r*e)+","+Math.round(i.g+f.g*e)+","+Math.round(i.b+f.b*e)+","+(i.a+f.a*e)+")";else l=i+f*e;t.setAttr(n,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{let e=this.node,t=ca.attrs[e._id][this._id];if(t.points&&t.points.trueEnd)e.setAttr("points",t.points.trueEnd);if(this.onFinish)this.onFinish.call(this)},this.tween.onReset=()=>{let e=this.node,t=ca.attrs[e._id][this._id];if(t.points&&t.points.trueStart)e.points(t.points.trueStart);if(this.onReset)this.onReset()},this.tween.onUpdate=()=>{if(this.onUpdate)this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1000),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let e=this.node._id,t=this._id,a=ca.tweens[e];if(this.pause(),this.anim)this.anim.stop();for(let n in a)delete ca.tweens[e][n];if(delete ca.attrs[e][t],ca.tweens[e]){if(Object.keys(ca.tweens[e]).length===0)delete ca.tweens[e];if(Object.keys(ca.attrs[e]).length===0)delete ca.attrs[e]}}}ca.attrs={};ca.tweens={};qe.prototype.to=function(e){let t=e.onFinish;e.node=this,e.onFinish=function(){if(this.destroy(),t)t()},new ca(e).play()};var To={BackEaseIn(e,t,a,n){return a*(e/=n)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,a,n){return a*((e=e/n-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,a,n){let s=1.70158;if((e/=n/2)<1)return a/2*(e*e*(((s*=1.525)+1)*e-s))+t;return a/2*((e-=2)*e*(((s*=1.525)+1)*e+s)+2)+t},ElasticEaseIn(e,t,a,n,s,i){let f=0;if(e===0)return t;if((e/=n)===1)return t+a;if(!i)i=n*0.3;if(!s||s<Math.abs(a))s=a,f=i/4;else f=i/(2*Math.PI)*Math.asin(a/s);return-(s*Math.pow(2,10*(e-=1))*Math.sin((e*n-f)*(2*Math.PI)/i))+t},ElasticEaseOut(e,t,a,n,s,i){let f=0;if(e===0)return t;if((e/=n)===1)return t+a;if(!i)i=n*0.3;if(!s||s<Math.abs(a))s=a,f=i/4;else f=i/(2*Math.PI)*Math.asin(a/s);return s*Math.pow(2,-10*e)*Math.sin((e*n-f)*(2*Math.PI)/i)+a+t},ElasticEaseInOut(e,t,a,n,s,i){let f=0;if(e===0)return t;if((e/=n/2)===2)return t+a;if(!i)i=n*0.44999999999999996;if(!s||s<Math.abs(a))s=a,f=i/4;else f=i/(2*Math.PI)*Math.asin(a/s);if(e<1)return-0.5*(s*Math.pow(2,10*(e-=1))*Math.sin((e*n-f)*(2*Math.PI)/i))+t;return s*Math.pow(2,-10*(e-=1))*Math.sin((e*n-f)*(2*Math.PI)/i)*0.5+a+t},BounceEaseOut(e,t,a,n){if((e/=n)<0.36363636363636365)return a*(7.5625*e*e)+t;else if(e<0.7272727272727273)return a*(7.5625*(e-=0.5454545454545454)*e+0.75)+t;else if(e<0.9090909090909091)return a*(7.5625*(e-=0.8181818181818182)*e+0.9375)+t;else return a*(7.5625*(e-=0.9545454545454546)*e+0.984375)+t},BounceEaseIn(e,t,a,n){return a-To.BounceEaseOut(n-e,0,a,n)+t},BounceEaseInOut(e,t,a,n){if(e<n/2)return To.BounceEaseIn(e*2,0,a,n)*0.5+t;else return To.BounceEaseOut(e*2-n,0,a,n)*0.5+a*0.5+t},EaseIn(e,t,a,n){return a*(e/=n)*e+t},EaseOut(e,t,a,n){return-a*(e/=n)*(e-2)+t},EaseInOut(e,t,a,n){if((e/=n/2)<1)return a/2*e*e+t;return-a/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,a,n){return a*(e/=n)*e*e*e*e+t},StrongEaseOut(e,t,a,n){return a*((e=e/n-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,a,n){if((e/=n/2)<1)return a/2*e*e*e*e*e+t;return a/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,a,n){return a*e/n+t}};var Ho=Z._assign(ve,{Util:Z,Transform:xn,Node:qe,Container:kn,Stage:Bo,stages:Oo,Layer:u0,FastLayer:Zh,Group:m0,DD:_t,Shape:je,shapes:Dr,Animation:is,Tween:ca,Easings:To,Context:Co,Canvas:Uh});class xi extends je{_sceneFunc(e){let t=ve.getAngle(this.angle()),a=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,a),e.arc(0,0,this.innerRadius(),t,0,!a),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){let e=this.innerRadius(),t=this.outerRadius(),a=this.clockwise(),n=ve.getAngle(a?360-this.angle():this.angle()),s=Math.cos(Math.min(n,Math.PI)),i=1,f=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),l=Math.sin(Math.min(n,Math.PI/2)),c=s*(s>0?e:t),h=1*t,u=f*(f>0?e:t),g=l*(l>0?t:e);return{x:c,y:a?-1*g:u,width:h-c,height:g-u}}}xi.prototype._centroid=!0;xi.prototype.className="Arc";xi.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"];lt(xi);I.addGetterSetter(xi,"innerRadius",0,we());I.addGetterSetter(xi,"outerRadius",0,we());I.addGetterSetter(xi,"angle",0,we());I.addGetterSetter(xi,"clockwise",!1,Rn());function Ug(e,t,a,n,s,i,f){let l=Math.sqrt(Math.pow(a-e,2)+Math.pow(n-t,2)),c=Math.sqrt(Math.pow(s-a,2)+Math.pow(i-n,2)),h=f*l/(l+c),u=f*c/(l+c),g=a-h*(s-e),b=n-h*(i-t),d=a+u*(s-e),j=n+u*(i-t);return[g,b,d,j]}function Wv(e,t){let a=e.length,n=[];for(let s=2;s<a-2;s+=2){let i=Ug(e[s-2],e[s-1],e[s],e[s+1],e[s+2],e[s+3],t);if(isNaN(i[0]))continue;n.push(i[0]),n.push(i[1]),n.push(e[s]),n.push(e[s+1]),n.push(i[2]),n.push(i[3])}return n}function Zx(e){let t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],a=[];for(let n of t){let s=-3*n[0]+9*n[1]-9*n[2]+3*n[3];if(s!==0){let i=6*n[0]-12*n[1]+6*n[2],f=-3*n[0]+3*n[1],l=i*i-4*s*f;if(l>=0){let c=Math.sqrt(l);a.push((-i+c)/(2*s)),a.push((-i-c)/(2*s))}}}return a.filter((n)=>n>0&&n<1).flatMap((n)=>t.map((s)=>{let i=1-n;return i*i*i*s[0]+3*i*i*n*s[1]+3*i*n*n*s[2]+n*n*n*s[3]}))}class wi extends je{constructor(e){super(e);this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){let t=this.points(),a=t.length,n=this.tension(),s=this.closed(),i=this.bezier();if(!a)return;let f=0;if(e.beginPath(),e.moveTo(t[0],t[1]),n!==0&&a>4){let l=this.getTensionPoints(),c=l.length;if(f=s?0:4,!s)e.quadraticCurveTo(l[0],l[1],l[2],l[3]);while(f<c-2)e.bezierCurveTo(l[f++],l[f++],l[f++],l[f++],l[f++],l[f++]);if(!s)e.quadraticCurveTo(l[c-2],l[c-1],t[a-2],t[a-1])}else if(i){f=2;while(f<a)e.bezierCurveTo(t[f++],t[f++],t[f++],t[f++],t[f++],t[f++])}else for(f=2;f<a;f+=2)e.lineTo(t[f],t[f+1]);if(s)e.closePath(),e.fillStrokeShape(this);else e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){if(this.closed())return this._getTensionPointsClosed();else return Wv(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,a=this.tension(),n=Ug(e[t-2],e[t-1],e[0],e[1],e[2],e[3],a),s=Ug(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],a),i=Wv(e,a);return[n[2],n[3]].concat(i).concat([s[0],s[1],e[t-2],e[t-1],s[2],s[3],n[0],n[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};if(this.tension()!==0)e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]];else if(this.bezier())e=[e[0],e[1],...Zx(this.points()),e[e.length-2],e[e.length-1]];else e=this.points();let t=e[0],a=e[0],n=e[1],s=e[1],i,f;for(let l=0;l<e.length/2;l++)i=e[l*2],f=e[l*2+1],t=Math.min(t,i),a=Math.max(a,i),n=Math.min(n,f),s=Math.max(s,f);return{x:t,y:n,width:a-t,height:s-n}}}wi.prototype.className="Line";wi.prototype._attrsAffectingSize=["points","bezier","tension"];lt(wi);I.addGetterSetter(wi,"closed",!1);I.addGetterSetter(wi,"bezier",!1);I.addGetterSetter(wi,"tension",0,we());I.addGetterSetter(wi,"points",[],vv());var $x=[[],[],[-0.5773502691896257,0.5773502691896257],[0,-0.7745966692414834,0.7745966692414834],[-0.33998104358485626,0.33998104358485626,-0.8611363115940526,0.8611363115940526],[0,-0.5384693101056831,0.5384693101056831,-0.906179845938664,0.906179845938664],[0.6612093864662645,-0.6612093864662645,-0.2386191860831969,0.2386191860831969,-0.932469514203152,0.932469514203152],[0,0.4058451513773972,-0.4058451513773972,-0.7415311855993945,0.7415311855993945,-0.9491079123427585,0.9491079123427585],[-0.1834346424956498,0.1834346424956498,-0.525532409916329,0.525532409916329,-0.7966664774136267,0.7966664774136267,-0.9602898564975363,0.9602898564975363],[0,-0.8360311073266358,0.8360311073266358,-0.9681602395076261,0.9681602395076261,-0.3242534234038089,0.3242534234038089,-0.6133714327005904,0.6133714327005904],[-0.14887433898163122,0.14887433898163122,-0.4333953941292472,0.4333953941292472,-0.6794095682990244,0.6794095682990244,-0.8650633666889845,0.8650633666889845,-0.9739065285171717,0.9739065285171717],[0,-0.26954315595234496,0.26954315595234496,-0.5190961292068118,0.5190961292068118,-0.7301520055740494,0.7301520055740494,-0.8870625997680953,0.8870625997680953,-0.978228658146057,0.978228658146057],[-0.1252334085114689,0.1252334085114689,-0.3678314989981802,0.3678314989981802,-0.5873179542866175,0.5873179542866175,-0.7699026741943047,0.7699026741943047,-0.9041172563704749,0.9041172563704749,-0.9815606342467192,0.9815606342467192],[0,-0.2304583159551348,0.2304583159551348,-0.44849275103644687,0.44849275103644687,-0.6423493394403402,0.6423493394403402,-0.8015780907333099,0.8015780907333099,-0.9175983992229779,0.9175983992229779,-0.9841830547185881,0.9841830547185881],[-0.10805494870734367,0.10805494870734367,-0.31911236892788974,0.31911236892788974,-0.5152486363581541,0.5152486363581541,-0.6872929048116855,0.6872929048116855,-0.827201315069765,0.827201315069765,-0.9284348836635735,0.9284348836635735,-0.9862838086968123,0.9862838086968123],[0,-0.20119409399743451,0.20119409399743451,-0.3941513470775634,0.3941513470775634,-0.5709721726085388,0.5709721726085388,-0.7244177313601701,0.7244177313601701,-0.8482065834104272,0.8482065834104272,-0.937273392400706,0.937273392400706,-0.9879925180204854,0.9879925180204854],[-0.09501250983763744,0.09501250983763744,-0.2816035507792589,0.2816035507792589,-0.45801677765722737,0.45801677765722737,-0.6178762444026438,0.6178762444026438,-0.755404408355003,0.755404408355003,-0.8656312023878318,0.8656312023878318,-0.9445750230732326,0.9445750230732326,-0.9894009349916499,0.9894009349916499],[0,-0.17848418149584785,0.17848418149584785,-0.3512317634538763,0.3512317634538763,-0.5126905370864769,0.5126905370864769,-0.6576711592166907,0.6576711592166907,-0.7815140038968014,0.7815140038968014,-0.8802391537269859,0.8802391537269859,-0.9506755217687678,0.9506755217687678,-0.9905754753144174,0.9905754753144174],[-0.0847750130417353,0.0847750130417353,-0.2518862256915055,0.2518862256915055,-0.41175116146284263,0.41175116146284263,-0.5597708310739475,0.5597708310739475,-0.6916870430603532,0.6916870430603532,-0.8037049589725231,0.8037049589725231,-0.8926024664975557,0.8926024664975557,-0.9558239495713977,0.9558239495713977,-0.9915651684209309,0.9915651684209309],[0,-0.16035864564022537,0.16035864564022537,-0.31656409996362983,0.31656409996362983,-0.46457074137596094,0.46457074137596094,-0.600545304661681,0.600545304661681,-0.7209661773352294,0.7209661773352294,-0.8227146565371428,0.8227146565371428,-0.9031559036148179,0.9031559036148179,-0.96020815213483,0.96020815213483,-0.9924068438435844,0.9924068438435844],[-0.07652652113349734,0.07652652113349734,-0.22778585114164507,0.22778585114164507,-0.37370608871541955,0.37370608871541955,-0.5108670019508271,0.5108670019508271,-0.636053680726515,0.636053680726515,-0.7463319064601508,0.7463319064601508,-0.8391169718222188,0.8391169718222188,-0.912234428251326,0.912234428251326,-0.9639719272779138,0.9639719272779138,-0.9931285991850949,0.9931285991850949],[0,-0.1455618541608951,0.1455618541608951,-0.2880213168024011,0.2880213168024011,-0.4243421202074388,0.4243421202074388,-0.5516188358872198,0.5516188358872198,-0.6671388041974123,0.6671388041974123,-0.7684399634756779,0.7684399634756779,-0.8533633645833173,0.8533633645833173,-0.9200993341504008,0.9200993341504008,-0.9672268385663063,0.9672268385663063,-0.9937521706203895,0.9937521706203895],[-0.06973927331972223,0.06973927331972223,-0.20786042668822127,0.20786042668822127,-0.34193582089208424,0.34193582089208424,-0.469355837986757,0.469355837986757,-0.5876404035069116,0.5876404035069116,-0.6944872631866827,0.6944872631866827,-0.7878168059792081,0.7878168059792081,-0.8658125777203002,0.8658125777203002,-0.926956772187174,0.926956772187174,-0.9700604978354287,0.9700604978354287,-0.9942945854823992,0.9942945854823992],[0,-0.1332568242984661,0.1332568242984661,-0.26413568097034495,0.26413568097034495,-0.3903010380302908,0.3903010380302908,-0.5095014778460075,0.5095014778460075,-0.6196098757636461,0.6196098757636461,-0.7186613631319502,0.7186613631319502,-0.8048884016188399,0.8048884016188399,-0.8767523582704416,0.8767523582704416,-0.9329710868260161,0.9329710868260161,-0.9725424712181152,0.9725424712181152,-0.9947693349975522,0.9947693349975522],[-0.06405689286260563,0.06405689286260563,-0.1911188674736163,0.1911188674736163,-0.3150426796961634,0.3150426796961634,-0.4337935076260451,0.4337935076260451,-0.5454214713888396,0.5454214713888396,-0.6480936519369755,0.6480936519369755,-0.7401241915785544,0.7401241915785544,-0.820001985973903,0.820001985973903,-0.8864155270044011,0.8864155270044011,-0.9382745520027328,0.9382745520027328,-0.9747285559713095,0.9747285559713095,-0.9951872199970213,0.9951872199970213]],Wx=[[],[],[1,1],[0.8888888888888888,0.5555555555555556,0.5555555555555556],[0.6521451548625461,0.6521451548625461,0.34785484513745385,0.34785484513745385],[0.5688888888888889,0.47862867049936647,0.47862867049936647,0.23692688505618908,0.23692688505618908],[0.3607615730481386,0.3607615730481386,0.46791393457269104,0.46791393457269104,0.17132449237917036,0.17132449237917036],[0.4179591836734694,0.3818300505051189,0.3818300505051189,0.27970539148927664,0.27970539148927664,0.1294849661688697,0.1294849661688697],[0.362683783378362,0.362683783378362,0.31370664587788727,0.31370664587788727,0.22238103445337448,0.22238103445337448,0.10122853629037626,0.10122853629037626],[0.3302393550012598,0.1806481606948574,0.1806481606948574,0.08127438836157441,0.08127438836157441,0.31234707704000286,0.31234707704000286,0.26061069640293544,0.26061069640293544],[0.29552422471475287,0.29552422471475287,0.26926671930999635,0.26926671930999635,0.21908636251598204,0.21908636251598204,0.1494513491505806,0.1494513491505806,0.06667134430868814,0.06667134430868814],[0.2729250867779006,0.26280454451024665,0.26280454451024665,0.23319376459199048,0.23319376459199048,0.18629021092773426,0.18629021092773426,0.1255803694649046,0.1255803694649046,0.05566856711617366,0.05566856711617366],[0.24914704581340277,0.24914704581340277,0.2334925365383548,0.2334925365383548,0.20316742672306592,0.20316742672306592,0.16007832854334622,0.16007832854334622,0.10693932599531843,0.10693932599531843,0.04717533638651183,0.04717533638651183],[0.2325515532308739,0.22628318026289723,0.22628318026289723,0.2078160475368885,0.2078160475368885,0.17814598076194574,0.17814598076194574,0.13887351021978725,0.13887351021978725,0.09212149983772845,0.09212149983772845,0.04048400476531588,0.04048400476531588],[0.2152638534631578,0.2152638534631578,0.2051984637212956,0.2051984637212956,0.18553839747793782,0.18553839747793782,0.15720316715819355,0.15720316715819355,0.12151857068790319,0.12151857068790319,0.08015808715976021,0.08015808715976021,0.03511946033175186,0.03511946033175186],[0.2025782419255613,0.19843148532711158,0.19843148532711158,0.1861610000155622,0.1861610000155622,0.16626920581699392,0.16626920581699392,0.13957067792615432,0.13957067792615432,0.10715922046717194,0.10715922046717194,0.07036604748810812,0.07036604748810812,0.03075324199611727,0.03075324199611727],[0.1894506104550685,0.1894506104550685,0.18260341504492358,0.18260341504492358,0.16915651939500254,0.16915651939500254,0.14959598881657674,0.14959598881657674,0.12462897125553388,0.12462897125553388,0.09515851168249279,0.09515851168249279,0.062253523938647894,0.062253523938647894,0.027152459411754096,0.027152459411754096],[0.17944647035620653,0.17656270536699264,0.17656270536699264,0.16800410215645004,0.16800410215645004,0.15404576107681028,0.15404576107681028,0.13513636846852548,0.13513636846852548,0.11188384719340397,0.11188384719340397,0.08503614831717918,0.08503614831717918,0.0554595293739872,0.0554595293739872,0.02414830286854793,0.02414830286854793],[0.1691423829631436,0.1691423829631436,0.16427648374583273,0.16427648374583273,0.15468467512626524,0.15468467512626524,0.14064291467065065,0.14064291467065065,0.12255520671147846,0.12255520671147846,0.10094204410628717,0.10094204410628717,0.07642573025488905,0.07642573025488905,0.0497145488949698,0.0497145488949698,0.02161601352648331,0.02161601352648331],[0.1610544498487837,0.15896884339395434,0.15896884339395434,0.15276604206585967,0.15276604206585967,0.1426067021736066,0.1426067021736066,0.12875396253933621,0.12875396253933621,0.11156664554733399,0.11156664554733399,0.09149002162245,0.09149002162245,0.06904454273764123,0.06904454273764123,0.0448142267656996,0.0448142267656996,0.019461788229726478,0.019461788229726478],[0.15275338713072584,0.15275338713072584,0.14917298647260374,0.14917298647260374,0.14209610931838204,0.14209610931838204,0.13168863844917664,0.13168863844917664,0.11819453196151841,0.11819453196151841,0.10193011981724044,0.10193011981724044,0.08327674157670475,0.08327674157670475,0.06267204833410907,0.06267204833410907,0.04060142980038694,0.04060142980038694,0.017614007139152118,0.017614007139152118],[0.14608113364969041,0.14452440398997005,0.14452440398997005,0.13988739479107315,0.13988739479107315,0.13226893863333747,0.13226893863333747,0.12183141605372853,0.12183141605372853,0.10879729916714838,0.10879729916714838,0.09344442345603386,0.09344442345603386,0.0761001136283793,0.0761001136283793,0.057134425426857205,0.057134425426857205,0.036953789770852494,0.036953789770852494,0.016017228257774335,0.016017228257774335],[0.13925187285563198,0.13925187285563198,0.13654149834601517,0.13654149834601517,0.13117350478706238,0.13117350478706238,0.12325237681051242,0.12325237681051242,0.11293229608053922,0.11293229608053922,0.10041414444288096,0.10041414444288096,0.08594160621706773,0.08594160621706773,0.06979646842452049,0.06979646842452049,0.052293335152683286,0.052293335152683286,0.03377490158481415,0.03377490158481415,0.0146279952982722,0.0146279952982722],[0.13365457218610619,0.1324620394046966,0.1324620394046966,0.12890572218808216,0.12890572218808216,0.12304908430672953,0.12304908430672953,0.11499664022241136,0.11499664022241136,0.10489209146454141,0.10489209146454141,0.09291576606003515,0.09291576606003515,0.07928141177671895,0.07928141177671895,0.06423242140852585,0.06423242140852585,0.04803767173108467,0.04803767173108467,0.030988005856979445,0.030988005856979445,0.013411859487141771,0.013411859487141771],[0.12793819534675216,0.12793819534675216,0.1258374563468283,0.1258374563468283,0.12167047292780339,0.12167047292780339,0.1155056680537256,0.1155056680537256,0.10744427011596563,0.10744427011596563,0.09761865210411388,0.09761865210411388,0.08619016153195327,0.08619016153195327,0.0733464814110803,0.0733464814110803,0.05929858491543678,0.05929858491543678,0.04427743881741981,0.04427743881741981,0.028531388628933663,0.028531388628933663,0.0123412297999872,0.0123412297999872]],Px=[[1],[1,1],[1,2,1],[1,3,3,1]],Gg=(e,t,a)=>{let n,s,i=20,f=a/2;n=0;for(let l=0;l<20;l++)s=f*$x[20][l]+f,n+=Wx[20][l]*eR(e,t,s);return f*n},Xg=(e,t,a)=>{if(a===void 0)a=1;let n=e[0]-2*e[1]+e[2],s=t[0]-2*t[1]+t[2],i=2*e[1]-2*e[0],f=2*t[1]-2*t[0],l=4*(n*n+s*s),c=4*(n*i+s*f),h=i*i+f*f;if(l===0)return a*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));let u=c/(2*l),g=h/l,b=a+u,d=g-u*u,j=b*b+d>0?Math.sqrt(b*b+d):0,A=u*u+d>0?Math.sqrt(u*u+d):0,C=u+Math.sqrt(u*u+d)!==0?d*Math.log(Math.abs((b+j)/(u+A))):0;return Math.sqrt(l)/2*(b*j-u*A+C)};function eR(e,t,a){let n=Ig(1,a,e),s=Ig(1,a,t),i=n*n+s*s;return Math.sqrt(i)}var Ig=(e,t,a)=>{let n=a.length-1,s,i;if(n===0)return 0;if(e===0){i=0;for(let f=0;f<=n;f++)i+=Px[n][f]*Math.pow(1-t,n-f)*Math.pow(t,f)*a[f];return i}else{s=Array(n);for(let f=0;f<n;f++)s[f]=n*(a[f+1]-a[f]);return Ig(e-1,t,s)}},Kg=(e,t,a)=>{let n=1,s=e/t,i=(e-a(s))/t,f=0;while(n>0.001){let l=a(s+i),c=Math.abs(e-l)/t;if(c<n)n=c,s+=i;else{let h=a(s-i),u=Math.abs(e-h)/t;if(u<n)n=u,s-=i;else i/=2}if(f++,f>500)break}return s};class Wt extends je{constructor(e){super(e);this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Wt.parsePathData(this.data()),this.pathLength=Wt.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let a=!1;for(let n=0;n<t.length;n++){let s=t[n].command,i=t[n].points;switch(s){case"L":e.lineTo(i[0],i[1]);break;case"M":e.moveTo(i[0],i[1]);break;case"C":e.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]);break;case"Q":e.quadraticCurveTo(i[0],i[1],i[2],i[3]);break;case"A":let f=i[0],l=i[1],c=i[2],h=i[3],u=i[4],g=i[5],b=i[6],d=i[7],j=c>h?c:h,A=c>h?1:c/h,C=c>h?h/c:1;e.translate(f,l),e.rotate(b),e.scale(A,C),e.arc(0,0,j,u,u+g,1-d),e.scale(1/A,1/C),e.rotate(-b),e.translate(-f,-l);break;case"z":a=!0,e.closePath();break}}if(!a&&!this.hasFill())e.strokeShape(this);else e.fillStrokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach(function(l){if(l.command==="A"){let c=l.points[4],h=l.points[5],u=l.points[4]+h,g=Math.PI/180;if(Math.abs(c-u)<g)g=Math.abs(c-u);if(h<0)for(let b=c-g;b>u;b-=g){let d=Wt.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],b,0);e.push(d.x,d.y)}else for(let b=c+g;b<u;b+=g){let d=Wt.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],b,0);e.push(d.x,d.y)}}else if(l.command==="C")for(let c=0;c<=1;c+=0.01){let h=Wt.getPointOnCubicBezier(c,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);e.push(h.x,h.y)}else e=e.concat(l.points)});let t=e[0],a=e[0],n=e[1],s=e[1],i,f;for(let l=0;l<e.length/2;l++){if(i=e[l*2],f=e[l*2+1],!isNaN(i))t=Math.min(t,i),a=Math.max(a,i);if(!isNaN(f))n=Math.min(n,f),s=Math.max(s,f)}return{x:t,y:n,width:a-t,height:s-n}}getLength(){return this.pathLength}getPointAtLength(e){return Wt.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(e,t,a,n){return Math.sqrt((a-e)*(a-e)+(n-t)*(n-t))}static getPathLength(e){let t=0;for(let a=0;a<e.length;++a)t+=e[a].pathLength;return t}static getPointAtLengthOfDataArray(e,t){let a,n=0,s=t.length;if(!s)return null;while(n<s&&e>t[n].pathLength)e-=t[n].pathLength,++n;if(n===s)return a=t[n-1].points.slice(-2),{x:a[0],y:a[1]};if(e<0.01)if(t[n].command==="M")return a=t[n].points.slice(0,2),{x:a[0],y:a[1]};else return{x:t[n].start.x,y:t[n].start.y};let i=t[n],f=i.points;switch(i.command){case"L":return Wt.getPointOnLine(e,i.start.x,i.start.y,f[0],f[1]);case"C":return Wt.getPointOnCubicBezier(Kg(e,Wt.getPathLength(t),(j)=>{return Gg([i.start.x,f[0],f[2],f[4]],[i.start.y,f[1],f[3],f[5]],j)}),i.start.x,i.start.y,f[0],f[1],f[2],f[3],f[4],f[5]);case"Q":return Wt.getPointOnQuadraticBezier(Kg(e,Wt.getPathLength(t),(j)=>{return Xg([i.start.x,f[0],f[2]],[i.start.y,f[1],f[3]],j)}),i.start.x,i.start.y,f[0],f[1],f[2],f[3]);case"A":let l=f[0],c=f[1],h=f[2],u=f[3],g=f[5],b=f[6],d=f[4];return d+=g*e/i.pathLength,Wt.getPointOnEllipticalArc(l,c,h,u,d,b)}return null}static getPointOnLine(e,t,a,n,s,i,f){i=i!==null&&i!==void 0?i:t,f=f!==null&&f!==void 0?f:a;let l=this.getLineLength(t,a,n,s);if(l<0.0000000001)return{x:t,y:a};if(n===t)return{x:i,y:f+(s>a?e:-e)};let c=(s-a)/(n-t),h=Math.sqrt(e*e/(1+c*c))*(n<t?-1:1),u=c*h;if(Math.abs(f-a-c*(i-t))<0.0000000001)return{x:i+h,y:f+u};let g=((i-t)*(n-t)+(f-a)*(s-a))/(l*l),b=t+g*(n-t),d=a+g*(s-a),j=this.getLineLength(i,f,b,d),A=Math.sqrt(e*e-j*j),C=Math.sqrt(A*A/(1+c*c))*(n<t?-1:1),y=c*C;return{x:b+C,y:d+y}}static getPointOnCubicBezier(e,t,a,n,s,i,f,l,c){function h(A){return A*A*A}function u(A){return 3*A*A*(1-A)}function g(A){return 3*A*(1-A)*(1-A)}function b(A){return(1-A)*(1-A)*(1-A)}let d=l*h(e)+i*u(e)+n*g(e)+t*b(e),j=c*h(e)+f*u(e)+s*g(e)+a*b(e);return{x:d,y:j}}static getPointOnQuadraticBezier(e,t,a,n,s,i,f){function l(b){return b*b}function c(b){return 2*b*(1-b)}function h(b){return(1-b)*(1-b)}let u=i*l(e)+n*c(e)+t*h(e),g=f*l(e)+s*c(e)+a*h(e);return{x:u,y:g}}static getPointOnEllipticalArc(e,t,a,n,s,i){let f=Math.cos(i),l=Math.sin(i),c={x:a*Math.cos(s),y:n*Math.sin(s)};return{x:e+(c.x*f-c.y*l),y:t+(c.x*l+c.y*f)}}static parsePathData(e){if(!e)return[];let t=e,a=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(let u=0;u<a.length;u++)t=t.replace(new RegExp(a[u],"g"),"|"+a[u]);let n=t.split("|"),s=[],i=[],f=0,l=0,c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,h;for(let u=1;u<n.length;u++){let g=n[u],b=g.charAt(0);g=g.slice(1),i.length=0;while(h=c.exec(g))i.push(h[0]);let d=[],j=b==="A"||b==="a"?0:-1;for(let A=0,C=i.length;A<C;A++){let y=i[A];if(y==="00"){if(d.push(0,0),j>=0){if(j+=2,j>=7)j-=7}continue}if(j>=0){if(j===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(y)){if(d.push(parseInt(y[0],10)),d.push(parseInt(y[1],10)),d.push(parseFloat(y.slice(2))),j+=3,j>=7)j-=7;continue}if(y==="11"||y==="10"||y==="01"){if(d.push(parseInt(y[0],10)),d.push(parseInt(y[1],10)),j+=2,j>=7)j-=7;continue}if(y==="0"||y==="1"){if(d.push(parseInt(y,10)),j+=1,j>=7)j-=7;continue}}else if(j===4){if(/^[01]\d+(?:\.\d+)?$/.test(y)){if(d.push(parseInt(y[0],10)),d.push(parseFloat(y.slice(1))),j+=2,j>=7)j-=7;continue}if(y==="0"||y==="1"){if(d.push(parseInt(y,10)),j+=1,j>=7)j-=7;continue}}let O=parseFloat(y);if(!isNaN(O))d.push(O);else d.push(0);if(j+=1,j>=7)j-=7}else{let O=parseFloat(y);if(!isNaN(O))d.push(O);else d.push(0)}}while(d.length>0){if(isNaN(d[0]))break;let A="",C=[],y=f,O=l,T,M,H,N,x,z,K,$,Q,P;switch(b){case"l":f+=d.shift(),l+=d.shift(),A="L",C.push(f,l);break;case"L":f=d.shift(),l=d.shift(),C.push(f,l);break;case"m":let te=d.shift(),ee=d.shift();if(f+=te,l+=ee,A="M",s.length>2&&s[s.length-1].command==="z"){for(let L=s.length-2;L>=0;L--)if(s[L].command==="M"){f=s[L].points[0]+te,l=s[L].points[1]+ee;break}}C.push(f,l),b="l";break;case"M":f=d.shift(),l=d.shift(),A="M",C.push(f,l),b="L";break;case"h":f+=d.shift(),A="L",C.push(f,l);break;case"H":f=d.shift(),A="L",C.push(f,l);break;case"v":l+=d.shift(),A="L",C.push(f,l);break;case"V":l=d.shift(),A="L",C.push(f,l);break;case"C":C.push(d.shift(),d.shift(),d.shift(),d.shift()),f=d.shift(),l=d.shift(),C.push(f,l);break;case"c":C.push(f+d.shift(),l+d.shift(),f+d.shift(),l+d.shift()),f+=d.shift(),l+=d.shift(),A="C",C.push(f,l);break;case"S":if(M=f,H=l,T=s[s.length-1],T.command==="C")M=f+(f-T.points[2]),H=l+(l-T.points[3]);C.push(M,H,d.shift(),d.shift()),f=d.shift(),l=d.shift(),A="C",C.push(f,l);break;case"s":if(M=f,H=l,T=s[s.length-1],T.command==="C")M=f+(f-T.points[2]),H=l+(l-T.points[3]);C.push(M,H,f+d.shift(),l+d.shift()),f+=d.shift(),l+=d.shift(),A="C",C.push(f,l);break;case"Q":C.push(d.shift(),d.shift()),f=d.shift(),l=d.shift(),C.push(f,l);break;case"q":C.push(f+d.shift(),l+d.shift()),f+=d.shift(),l+=d.shift(),A="Q",C.push(f,l);break;case"T":if(M=f,H=l,T=s[s.length-1],T.command==="Q")M=f+(f-T.points[0]),H=l+(l-T.points[1]);f=d.shift(),l=d.shift(),A="Q",C.push(M,H,f,l);break;case"t":if(M=f,H=l,T=s[s.length-1],T.command==="Q")M=f+(f-T.points[0]),H=l+(l-T.points[1]);f+=d.shift(),l+=d.shift(),A="Q",C.push(M,H,f,l);break;case"A":N=d.shift(),x=d.shift(),z=d.shift(),K=d.shift(),$=d.shift(),Q=f,P=l,f=d.shift(),l=d.shift(),A="A",C=this.convertEndpointToCenterParameterization(Q,P,f,l,K,$,N,x,z);break;case"a":N=d.shift(),x=d.shift(),z=d.shift(),K=d.shift(),$=d.shift(),Q=f,P=l,f+=d.shift(),l+=d.shift(),A="A",C=this.convertEndpointToCenterParameterization(Q,P,f,l,K,$,N,x,z);break}s.push({command:A||b,points:C,start:{x:y,y:O},pathLength:this.calcLength(y,O,A||b,C)})}if(b==="z"||b==="Z")s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,t,a,n){let s,i,f,l,c=Wt;switch(a){case"L":return c.getLineLength(e,t,n[0],n[1]);case"C":return Gg([e,n[0],n[2],n[4]],[t,n[1],n[3],n[5]],1);case"Q":return Xg([e,n[0],n[2]],[t,n[1],n[3]],1);case"A":s=0;let h=n[4],u=n[5],g=n[4]+u,b=Math.PI/180;if(Math.abs(h-g)<b)b=Math.abs(h-g);if(i=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],h,0),u<0)for(l=h-b;l>g;l-=b)f=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),s+=c.getLineLength(i.x,i.y,f.x,f.y),i=f;else for(l=h+b;l<g;l+=b)f=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),s+=c.getLineLength(i.x,i.y,f.x,f.y),i=f;return f=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],g,0),s+=c.getLineLength(i.x,i.y,f.x,f.y),s}return 0}static convertEndpointToCenterParameterization(e,t,a,n,s,i,f,l,c){let h=c*(Math.PI/180),u=Math.cos(h)*(e-a)/2+Math.sin(h)*(t-n)/2,g=-1*Math.sin(h)*(e-a)/2+Math.cos(h)*(t-n)/2,b=u*u/(f*f)+g*g/(l*l);if(b>1)f*=Math.sqrt(b),l*=Math.sqrt(b);let d=Math.sqrt((f*f*(l*l)-f*f*(g*g)-l*l*(u*u))/(f*f*(g*g)+l*l*(u*u)));if(s===i)d*=-1;if(isNaN(d))d=0;let j=d*f*g/l,A=d*-l*u/f,C=(e+a)/2+Math.cos(h)*j-Math.sin(h)*A,y=(t+n)/2+Math.sin(h)*j+Math.cos(h)*A,O=function(K){return Math.sqrt(K[0]*K[0]+K[1]*K[1])},T=function(K,$){return(K[0]*$[0]+K[1]*$[1])/(O(K)*O($))},M=function(K,$){return(K[0]*$[1]<K[1]*$[0]?-1:1)*Math.acos(T(K,$))},H=M([1,0],[(u-j)/f,(g-A)/l]),N=[(u-j)/f,(g-A)/l],x=[(-1*u-j)/f,(-1*g-A)/l],z=M(N,x);if(T(N,x)<=-1)z=Math.PI;if(T(N,x)>=1)z=0;if(i===0&&z>0)z=z-2*Math.PI;if(i===1&&z<0)z=z+2*Math.PI;return[C,y,f,l,H,z,h,i]}}Wt.prototype.className="Path";Wt.prototype._attrsAffectingSize=["data"];lt(Wt);I.addGetterSetter(Wt,"data");class sf extends wi{_sceneFunc(e){super._sceneFunc(e);let t=Math.PI*2,a=this.points(),n=a,s=this.tension()!==0&&a.length>4;if(s)n=this.getTensionPoints();let i=this.pointerLength(),f=a.length,l,c;if(s){let g=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],a[f-2],a[f-1]],b=Wt.calcLength(n[n.length-4],n[n.length-3],"C",g),d=Wt.getPointOnQuadraticBezier(Math.min(1,1-i/b),g[0],g[1],g[2],g[3],g[4],g[5]);l=a[f-2]-d.x,c=a[f-1]-d.y}else l=a[f-2]-a[f-4],c=a[f-1]-a[f-3];let h=(Math.atan2(c,l)+t)%t,u=this.pointerWidth();if(this.pointerAtEnding())e.save(),e.beginPath(),e.translate(a[f-2],a[f-1]),e.rotate(h),e.moveTo(0,0),e.lineTo(-i,u/2),e.lineTo(-i,-u/2),e.closePath(),e.restore(),this.__fillStroke(e);if(this.pointerAtBeginning()){if(e.save(),e.beginPath(),e.translate(a[0],a[1]),s)l=(n[0]+n[2])/2-a[0],c=(n[1]+n[3])/2-a[1];else l=a[2]-a[0],c=a[3]-a[1];e.rotate((Math.atan2(-c,-l)+t)%t),e.moveTo(0,0),e.lineTo(-i,u/2),e.lineTo(-i,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)}}__fillStroke(e){let t=this.dashEnabled();if(t)this.attrs.dashEnabled=!1,e.setLineDash([]);if(e.fillStrokeShape(this),t)this.attrs.dashEnabled=!0}getSelfRect(){let e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}}sf.prototype.className="Arrow";lt(sf);I.addGetterSetter(sf,"pointerLength",10,we());I.addGetterSetter(sf,"pointerWidth",10,we());I.addGetterSetter(sf,"pointerAtBeginning",!1);I.addGetterSetter(sf,"pointerAtEnding",!0);class dl extends je{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){if(this.radius()!==e/2)this.radius(e/2)}setHeight(e){if(this.radius()!==e/2)this.radius(e/2)}}dl.prototype._centroid=!0;dl.prototype.className="Circle";dl.prototype._attrsAffectingSize=["radius"];lt(dl);I.addGetterSetter(dl,"radius",0,we());class g0 extends je{_sceneFunc(e){let t=this.radiusX(),a=this.radiusY();if(e.beginPath(),e.save(),t!==a)e.scale(1,a/t);e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}g0.prototype.className="Ellipse";g0.prototype._centroid=!0;g0.prototype._attrsAffectingSize=["radiusX","radiusY"];lt(g0);I.addComponentsGetterSetter(g0,"radius",["x","y"]);I.addGetterSetter(g0,"radiusX",0,we());I.addGetterSetter(g0,"radiusY",0,we());class Cs extends je{constructor(e){super(e);this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",(t)=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){let e=this.image();if(e&&e.complete)return;if(e&&e.readyState===4)return;if(e&&e.addEventListener)e.addEventListener("load",this._loadListener)}_removeImageLoad(e){if(e&&e.removeEventListener)e.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){let e=!!this.cornerRadius(),t=this.hasShadow();if(e&&t)return!0;return super._useBufferCanvas(!0)}_sceneFunc(e){let t=this.getWidth(),a=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image,i;if(s){let f=this.attrs.cropWidth,l=this.attrs.cropHeight;if(f&&l)i=[s,this.cropX(),this.cropY(),f,l,0,0,t,a];else i=[s,0,0,t,a]}if(this.hasFill()||this.hasStroke()||n)e.beginPath(),n?Z.drawRoundedRectPath(e,t,a,n):e.rect(0,0,t,a),e.closePath(),e.fillStrokeShape(this);if(s){if(n)e.clip();e.drawImage.apply(e,i)}}_hitFunc(e){let t=this.width(),a=this.height(),n=this.cornerRadius();if(e.beginPath(),!n)e.rect(0,0,t,a);else Z.drawRoundedRectPath(e,t,a,n);e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t,a;return(a=(e=this.attrs.width)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.width)!==null&&a!==void 0?a:0}getHeight(){var e,t,a;return(a=(e=this.attrs.height)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.height)!==null&&a!==void 0?a:0}static fromURL(e,t,a=null){let n=Z.createImageElement();n.onload=function(){let s=new Cs({image:n});t(s)},n.onerror=a,n.crossOrigin="Anonymous",n.src=e}}Cs.prototype.className="Image";Cs.prototype._attrsAffectingSize=["image"];lt(Cs);I.addGetterSetter(Cs,"cornerRadius",0,bl(4));I.addGetterSetter(Cs,"image");I.addComponentsGetterSetter(Cs,"crop",["x","y","width","height"]);I.addGetterSetter(Cs,"cropX",0,we());I.addGetterSetter(Cs,"cropY",0,we());I.addGetterSetter(Cs,"cropWidth",0,we());I.addGetterSetter(Cs,"cropHeight",0,we());var Pv=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],tR="Change.konva",aR="none",Lg="up",Vg="right",Yg="down",Jg="left",nR=Pv.length;class $h extends m0{constructor(e){super(e);this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,a,n=function(){t._sync()};for(a=0;a<nR;a++)e.on(Pv[a]+tR,n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),a,n,s,i,f,l,c;if(e&&t){switch(a=e.width(),n=e.height(),s=t.pointerDirection(),i=t.pointerWidth(),c=t.pointerHeight(),f=0,l=0,s){case Lg:f=a/2,l=-1*c;break;case Vg:f=a+i,l=n/2;break;case Yg:f=a/2,l=n+c;break;case Jg:f=-1*i,l=n/2;break}t.setAttrs({x:-1*f,y:-1*l,width:a,height:n}),e.setAttrs({x:-1*f,y:-1*l})}}}$h.prototype.className="Label";lt($h);class ff extends je{_sceneFunc(e){let t=this.width(),a=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),i=this.pointerHeight(),f=this.cornerRadius(),l=0,c=0,h=0,u=0;if(typeof f==="number")l=c=h=u=Math.min(f,t/2,a/2);else l=Math.min(f[0]||0,t/2,a/2),c=Math.min(f[1]||0,t/2,a/2),u=Math.min(f[2]||0,t/2,a/2),h=Math.min(f[3]||0,t/2,a/2);if(e.beginPath(),e.moveTo(l,0),n===Lg)e.lineTo((t-s)/2,0),e.lineTo(t/2,-1*i),e.lineTo((t+s)/2,0);if(e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),n===Vg)e.lineTo(t,(a-i)/2),e.lineTo(t+s,a/2),e.lineTo(t,(a+i)/2);if(e.lineTo(t,a-u),e.arc(t-u,a-u,u,0,Math.PI/2,!1),n===Yg)e.lineTo((t+s)/2,a),e.lineTo(t/2,a+i),e.lineTo((t-s)/2,a);if(e.lineTo(h,a),e.arc(h,a-h,h,Math.PI/2,Math.PI,!1),n===Jg)e.lineTo(0,(a+i)/2),e.lineTo(-1*s,a/2),e.lineTo(0,(a-i)/2);e.lineTo(0,l),e.arc(l,l,l,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,a=this.pointerWidth(),n=this.pointerHeight(),s=this.pointerDirection(),i=this.width(),f=this.height();if(s===Lg)t-=n,f+=n;else if(s===Yg)f+=n;else if(s===Jg)e-=a*1.5,i+=a;else if(s===Vg)i+=a*1.5;return{x:e,y:t,width:i,height:f}}}ff.prototype.className="Tag";lt(ff);I.addGetterSetter(ff,"pointerDirection",aR);I.addGetterSetter(ff,"pointerWidth",0,we());I.addGetterSetter(ff,"pointerHeight",0,we());I.addGetterSetter(ff,"cornerRadius",0,bl(4));class jl extends je{_sceneFunc(e){let t=this.cornerRadius(),a=this.width(),n=this.height();if(e.beginPath(),!t)e.rect(0,0,a,n);else Z.drawRoundedRectPath(e,a,n,t);e.closePath(),e.fillStrokeShape(this)}}jl.prototype.className="Rect";lt(jl);I.addGetterSetter(jl,"cornerRadius",0,bl(4));class p0 extends je{_sceneFunc(e){let t=this._getPoints(),a=this.radius(),n=this.sides(),s=this.cornerRadius();if(e.beginPath(),!s){e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y)}else Z.drawRoundedPolygonPath(e,t,n,a,s);e.closePath(),e.fillStrokeShape(this)}_getPoints(){let e=this.attrs.sides,t=this.attrs.radius||0,a=[];for(let n=0;n<e;n++)a.push({x:t*Math.sin(n*2*Math.PI/e),y:-1*t*Math.cos(n*2*Math.PI/e)});return a}getSelfRect(){let e=this._getPoints(),t=e[0].x,a=e[0].x,n=e[0].y,s=e[0].y;return e.forEach((i)=>{t=Math.min(t,i.x),a=Math.max(a,i.x),n=Math.min(n,i.y),s=Math.max(s,i.y)}),{x:t,y:n,width:a-t,height:s-n}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}p0.prototype.className="RegularPolygon";p0.prototype._centroid=!0;p0.prototype._attrsAffectingSize=["radius"];lt(p0);I.addGetterSetter(p0,"radius",0,we());I.addGetterSetter(p0,"sides",0,we());I.addGetterSetter(p0,"cornerRadius",0,bl(4));var ek=Math.PI*2;class lf extends je{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,ek,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),ek,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}lf.prototype.className="Ring";lf.prototype._centroid=!0;lf.prototype._attrsAffectingSize=["innerRadius","outerRadius"];lt(lf);I.addGetterSetter(lf,"innerRadius",0,we());I.addGetterSetter(lf,"outerRadius",0,we());class di extends je{constructor(e){super(e);this._updated=!0,this.anim=new is(()=>{let t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){if(!this.anim.isRunning())return;clearInterval(this.interval),this._setInterval()})}_sceneFunc(e){let t=this.animation(),a=this.frameIndex(),n=a*4,s=this.animations()[t],i=this.frameOffsets(),f=s[n+0],l=s[n+1],c=s[n+2],h=s[n+3],u=this.image();if(this.hasFill()||this.hasStroke())e.beginPath(),e.rect(0,0,c,h),e.closePath(),e.fillStrokeShape(this);if(u)if(i){let g=i[t],b=a*2;e.drawImage(u,f,l,c,h,g[b+0],g[b+1],c,h)}else e.drawImage(u,f,l,c,h,0,0,c,h)}_hitFunc(e){let t=this.animation(),a=this.frameIndex(),n=a*4,s=this.animations()[t],i=this.frameOffsets(),f=s[n+2],l=s[n+3];if(e.beginPath(),i){let c=i[t],h=a*2;e.rect(c[h+0],c[h+1],f,l)}else e.rect(0,0,f,l);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1000/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animation(),a=this.animations(),n=a[t],s=n.length/4;if(e<s-1)this.frameIndex(e+1);else this.frameIndex(0)}}di.prototype.className="Sprite";lt(di);I.addGetterSetter(di,"animation");I.addGetterSetter(di,"animations");I.addGetterSetter(di,"frameOffsets");I.addGetterSetter(di,"image");I.addGetterSetter(di,"frameIndex",0,we());I.addGetterSetter(di,"frameRate",17,we());I.backCompat(di,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class b0 extends je{_sceneFunc(e){let t=this.innerRadius(),a=this.outerRadius(),n=this.numPoints();e.beginPath(),e.moveTo(0,0-a);for(let s=1;s<n*2;s++){let i=s%2===0?a:t,f=i*Math.sin(s*Math.PI/n),l=-1*i*Math.cos(s*Math.PI/n);e.lineTo(f,l)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}b0.prototype.className="Star";b0.prototype._centroid=!0;b0.prototype._attrsAffectingSize=["innerRadius","outerRadius"];lt(b0);I.addGetterSetter(b0,"numPoints",5,we());I.addGetterSetter(b0,"innerRadius",0,we());I.addGetterSetter(b0,"outerRadius",0,we());function rf(e){return[...e].reduce((t,a,n,s)=>{if(/\p{Emoji}/u.test(a)){let i=s[n+1];if(i&&/\p{Emoji_Modifier}|\u200D/u.test(i))t.push(a+i),s[n+1]="";else t.push(a)}else if(/\p{Regional_Indicator}{2}/u.test(a+(s[n+1]||"")))t.push(a+s[n+1]);else if(n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(a))t[t.length-1]+=a;else if(a)t.push(a);return t},[])}var Mo="auto",sR="center",ik="inherit",Wh="justify",iR="Change.konva",fk="2d",tk="-",lk="left",fR="text",lR="Text",rR="top",oR="bottom",ak="middle",rk="normal",cR="px ",Qm=" ",hR="right",nk="rtl",uR="word",mR="char",sk="none",Qg="…",ok=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],gR=ok.length,Ph=null;function pR(){if(Ph!==null)return Ph;Ph=!1;try{let e=document.createElement("canvas");e.width=10,e.height=10;let t=e.getContext(fk);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);let a=t.getImageData(0,0,10,10).data;for(let n=3;n<a.length;n+=4)if(a[n]>0){Ph=!0;break}}}catch(e){}return Ph}function bR(e){return e.split(",").map((t)=>{t=t.trim();let a=t.indexOf(" ")>=0,n=t.indexOf('"')>=0||t.indexOf("'")>=0;if(a&&!n)t=`"${t}"`;return t}).join(", ")}var Zm;function Zg(){if(Zm)return Zm;return Zm=Z.createCanvasElement().getContext(fk),Zm}function wR(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function dR(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function jR(e){if(e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage)e.fill=e.fill||"black";return e}class Pt extends je{constructor(e){super(jR(e));this._partialTextX=0,this._partialTextY=0;for(let t=0;t<gR;t++)this.on(ok[t]+iR,this._setTextData);this._setTextData()}_sceneFunc(e){var t,a;let n=this.textArr,s=n.length;if(!this.text())return;let i=this.padding(),f=this.fontSize(),l=this.lineHeight()*f,c=this.verticalAlign(),h=this.direction(),u=0,g=this.align(),b=this.getWidth(),d=this.letterSpacing(),j=this.charRenderFunc(),A=this.fill(),C=this.textDecoration(),y=this.underlineOffset(),O=C.indexOf("underline")!==-1,T=C.indexOf("line-through")!==-1,M;h=h===ik?e.direction:h;let H=l/2,N=ak;if(!ve.legacyTextRendering){let x=this.measureSize("M");N="alphabetic";let z=(t=x.fontBoundingBoxAscent)!==null&&t!==void 0?t:x.actualBoundingBoxAscent,K=(a=x.fontBoundingBoxDescent)!==null&&a!==void 0?a:x.actualBoundingBoxDescent;H=(z-K)/2+l/2}if(h===nk)e.setAttr("direction",h);if(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",N),e.setAttr("textAlign",lk),c===ak)u=(this.getHeight()-s*l-i*2)/2;else if(c===oR)u=this.getHeight()-s*l-i*2;e.translate(i,u+i);for(M=0;M<s;M++){let x=0,z=0,K=n[M],$=K.text,Q=K.width,P=K.lastInParagraph;if(e.save(),g===hR)x+=b-Q-i*2;else if(g===sR)x+=(b-Q-i*2)/2;if(O){e.save(),e.beginPath();let ee=y!==null&&y!==void 0?y:!ve.legacyTextRendering?Math.round(f/4):Math.round(f/2),L=x,J=H+z+ee;e.moveTo(L,J);let pe=g===Wh&&!P?b-i*2:Q;e.lineTo(L+Math.round(pe),J),e.lineWidth=f/15;let ne=this._getLinearGradient();e.strokeStyle=ne||A,e.stroke(),e.restore()}let te=x;if(h!==nk&&(d!==0||g===Wh||j)){let ee=$.split(" ").length-1,L=rf($);for(let J=0;J<L.length;J++){let pe=L[J];if(pe===" "&&!P&&g===Wh)x+=(b-i*2-Q)/ee;if(this._partialTextX=x,this._partialTextY=H+z,this._partialText=pe,j){e.save();let fe=n.slice(0,M).reduce((he,re)=>he+rf(re.text).length,0),Ae=J+fe;j({char:pe,index:Ae,x,y:H+z,lineIndex:M,column:J,isLastInLine:P,width:this.measureSize(pe).width,context:e})}if(e.fillStrokeShape(this),j)e.restore();x+=this.measureSize(pe).width+d}}else{if(d!==0)e.setAttr("letterSpacing",`${d}px`);this._partialTextX=x,this._partialTextY=H+z,this._partialText=$,e.fillStrokeShape(this)}if(T){e.save(),e.beginPath();let ee=!ve.legacyTextRendering?-Math.round(f/4):0,L=te;e.moveTo(L,H+z+ee);let J=g===Wh&&!P?b-i*2:Q;e.lineTo(L+Math.round(J),H+z+ee),e.lineWidth=f/15;let pe=this._getLinearGradient();e.strokeStyle=pe||A,e.stroke(),e.restore()}if(e.restore(),s>1)H+=l}}_hitFunc(e){let t=this.getWidth(),a=this.getHeight();e.beginPath(),e.rect(0,0,t,a),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=Z._isString(e)?e:e===null||e===void 0?"":e+"";return this._setAttr(fR,t),this}getWidth(){return this.attrs.width===Mo||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Mo||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Z.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,a,n,s,i,f,l,c,h,u,g;let b=Zg(),d=this.fontSize(),j;b.save(),b.font=this._getContextFont(),j=b.measureText(e),b.restore();let A=d/100;return{actualBoundingBoxAscent:(t=j.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*A,actualBoundingBoxDescent:(a=j.actualBoundingBoxDescent)!==null&&a!==void 0?a:0,actualBoundingBoxLeft:(n=j.actualBoundingBoxLeft)!==null&&n!==void 0?n:-7.421875*A,actualBoundingBoxRight:(s=j.actualBoundingBoxRight)!==null&&s!==void 0?s:75.732421875*A,alphabeticBaseline:(i=j.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(f=j.emHeightAscent)!==null&&f!==void 0?f:100*A,emHeightDescent:(l=j.emHeightDescent)!==null&&l!==void 0?l:-20*A,fontBoundingBoxAscent:(c=j.fontBoundingBoxAscent)!==null&&c!==void 0?c:91*A,fontBoundingBoxDescent:(h=j.fontBoundingBoxDescent)!==null&&h!==void 0?h:21*A,hangingBaseline:(u=j.hangingBaseline)!==null&&u!==void 0?u:72.80000305175781*A,ideographicBaseline:(g=j.ideographicBaseline)!==null&&g!==void 0?g:-21*A,width:j.width,height:d}}_getContextFont(){return this.fontStyle()+Qm+this.fontVariant()+Qm+(this.fontSize()+cR)+bR(this.fontFamily())}_addTextLine(e){if(this.align()===Wh)e=e.trim();let a=this._getTextWidth(e);return this.textArr.push({text:e,width:a,lastInParagraph:!1})}_getTextWidth(e){let t=this.letterSpacing(),a=e.length;return Zg().measureText(e).width+t*a}_setTextData(){let e=this.text().split(`
245
+ `),t=+this.fontSize(),a=0,n=this.lineHeight()*t,s=this.attrs.width,i=this.attrs.height,f=s!==Mo&&s!==void 0,l=i!==Mo&&i!==void 0,c=this.padding(),h=s-c*2,u=i-c*2,g=0,b=this.wrap(),d=b!==sk,j=b!==mR&&d,A=this.ellipsis();this.textArr=[],Zg().font=this._getContextFont();let C=A?this._getTextWidth(Qg):0;for(let y=0,O=e.length;y<O;++y){let T=e[y],M=this._getTextWidth(T);if(f&&M>h)while(T.length>0){let H=0,N=rf(T).length,x="",z=0;while(H<N){let K=H+N>>>1,$=rf(T),Q=$.slice(0,K+1).join(""),P=this._getTextWidth(Q);if((A&&l&&g+n>u?P+C:P)<=h)H=K+1,x=Q,z=P;else N=K}if(x){if(j){let Q=rf(T),P=rf(x),te=Q[P.length],ee=te===Qm||te===tk,L;if(ee&&z<=h)L=P.length;else{let J=P.lastIndexOf(Qm),pe=P.lastIndexOf(tk);L=Math.max(J,pe)+1}if(L>0)H=L,x=Q.slice(0,H).join(""),z=this._getTextWidth(x)}if(x=x.trimRight(),this._addTextLine(x),a=Math.max(a,z),g+=n,this._shouldHandleEllipsis(g)){this._tryToAddEllipsisToLastLine();break}if(T=rf(T).slice(H).join("").trimLeft(),T.length>0){if(M=this._getTextWidth(T),M<=h){this._addTextLine(T),g+=n,a=Math.max(a,M);break}}}else break}else if(this._addTextLine(T),g+=n,a=Math.max(a,M),this._shouldHandleEllipsis(g)&&y<O-1)this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1])this.textArr[this.textArr.length-1].lastInParagraph=!0;if(l&&g+n>u)break}this.textHeight=t,this.textWidth=a}_shouldHandleEllipsis(e){let t=+this.fontSize(),a=this.lineHeight()*t,n=this.attrs.height,s=n!==Mo&&n!==void 0,i=this.padding(),f=n-i*2;return this.wrap()===sk||s&&e+a>f}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Mo&&e!==void 0,a=this.padding(),n=e-a*2,s=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!s)return;if(t){if(!(this._getTextWidth(i.text+Qg)<n))i.text=i.text.slice(0,i.text.length-3)}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+Qg)}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){let e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();if(e&&t)return!0;if(t&&this.getAbsoluteOpacity()!==1&&pR())return!0;return super._useBufferCanvas()}}Pt.prototype._fillFunc=wR;Pt.prototype._strokeFunc=dR;Pt.prototype.className=lR;Pt.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];lt(Pt);I.overWriteSetter(Pt,"width",Ih());I.overWriteSetter(Pt,"height",Ih());I.addGetterSetter(Pt,"direction",ik);I.addGetterSetter(Pt,"fontFamily","Arial");I.addGetterSetter(Pt,"fontSize",12,we());I.addGetterSetter(Pt,"fontStyle",rk);I.addGetterSetter(Pt,"fontVariant",rk);I.addGetterSetter(Pt,"padding",0,we());I.addGetterSetter(Pt,"align",lk);I.addGetterSetter(Pt,"verticalAlign",rR);I.addGetterSetter(Pt,"lineHeight",1,we());I.addGetterSetter(Pt,"wrap",uR);I.addGetterSetter(Pt,"ellipsis",!1,Rn());I.addGetterSetter(Pt,"letterSpacing",0,we());I.addGetterSetter(Pt,"text","",h0());I.addGetterSetter(Pt,"textDecoration","");I.addGetterSetter(Pt,"underlineOffset",void 0,we());I.addGetterSetter(Pt,"charRenderFunc",void 0);var qR="",ck="normal";function hk(e){e.fillText(this.partialText,0,0)}function uk(e){e.strokeText(this.partialText,0,0)}class Ea extends je{constructor(e){super(e);this.dummyCanvas=Z.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva directionChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Wt.getPathLength(this.dataArray)}_getPointAtLength(e){if(!this.attrs.data)return null;let t=this.pathLength;if(e>t)return null;return Wt.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Wt.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();let t=this.textDecoration(),a=this.fill(),n=this.fontSize(),s=this.glyphInfo,i=t.indexOf("underline")!==-1,f=t.indexOf("line-through")!==-1;if(i)e.beginPath();for(let l=0;l<s.length;l++){e.save();let c=s[l].p0;if(e.translate(c.x,c.y),e.rotate(s[l].rotation),this.partialText=s[l].text,e.fillStrokeShape(this),i){if(l===0)e.moveTo(0,n/2+1);e.lineTo(s[l].width,n/2+1)}e.restore()}if(i)e.strokeStyle=a,e.lineWidth=n/20,e.stroke();if(f){e.beginPath();for(let l=0;l<s.length;l++){e.save();let c=s[l].p0;if(e.translate(c.x,c.y),e.rotate(s[l].rotation),l===0)e.moveTo(0,0);e.lineTo(s[l].width,0),e.restore()}e.strokeStyle=a,e.lineWidth=n/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();let t=this.glyphInfo;if(t.length>=1){let a=t[0].p0;e.moveTo(a.x,a.y)}for(let a=0;a<t.length;a++){let n=t[a].p1;e.lineTo(n.x,n.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Z.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Pt.prototype.setText.call(this,e)}_getContextFont(){return Pt.prototype._getContextFont.call(this)}_getTextSize(e){let a=this.dummyCanvas.getContext("2d");a.save(),a.font=this._getContextFont();let n=a.measureText(e);return a.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=rf(this.text());if(this.direction()==="rtl")e.reverse();let t=[],a=0;for(let b=0;b<e.length;b++)t.push({char:e[b],width:this._getTextSize(e[b]).width}),a+=t[b].width;let{width:n,height:s}=this._getTextSize(this.attrs.text);if(this.textWidth=a,this.textHeight=s,this.glyphInfo=[],!this.attrs.data)return null;let i=this.letterSpacing(),f=this.align(),l=this.kerningFunc(),c=Math.max(0,a-n),h=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0),u=0;if(f==="center")u=Math.max(0,this.pathLength/2-h/2);if(f==="right")u=Math.max(0,this.pathLength-h);let g=u;for(let b=0;b<t.length;b++){let d=this._getPointAtLength(g);if(!d)return;let j=t[b].char,A=t[b].width+i;if(j===" "&&f==="justify"){let N=this.text().split(" ").length-1;A+=(this.pathLength-h)/N}let C=g+A,y=this._getPointAtLength(C>this.pathLength&&C-this.pathLength<=c?this.pathLength:C);if(!y)return;let O=Wt.getLineLength(d.x,d.y,y.x,y.y),T=0;if(l)try{T=l(t[b-1].char,j)*this.fontSize()}catch(N){T=0}d.x+=T,y.x+=T,this.textWidth+=T;let M=Wt.getPointOnLine(T+O/2,d.x,d.y,y.x,y.y),H=Math.atan2(y.y-d.y,y.x-d.x);this.glyphInfo.push({transposeX:M.x,transposeY:M.y,text:e[b],rotation:H,p0:d,p1:y,width:O}),g+=A}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(c){e.push(c.p0.x),e.push(c.p0.y),e.push(c.p1.x),e.push(c.p1.y)});let t=e[0]||0,a=e[0]||0,n=e[1]||0,s=e[1]||0,i,f;for(let c=0;c<e.length/2;c++)i=e[c*2],f=e[c*2+1],t=Math.min(t,i),a=Math.max(a,i),n=Math.min(n,f),s=Math.max(s,f);let l=this.fontSize();return{x:t-l/2,y:n-l/2,width:a-t+l,height:s-n+l}}destroy(){return Z.releaseCanvas(this.dummyCanvas),super.destroy()}}Ea.prototype._fillFunc=hk;Ea.prototype._strokeFunc=uk;Ea.prototype._fillFuncHit=hk;Ea.prototype._strokeFuncHit=uk;Ea.prototype.className="TextPath";Ea.prototype._attrsAffectingSize=["text","fontSize","data"];lt(Ea);I.addGetterSetter(Ea,"data");I.addGetterSetter(Ea,"fontFamily","Arial");I.addGetterSetter(Ea,"fontSize",12,we());I.addGetterSetter(Ea,"fontStyle",ck);I.addGetterSetter(Ea,"align","left");I.addGetterSetter(Ea,"letterSpacing",0,we());I.addGetterSetter(Ea,"textBaseline","middle");I.addGetterSetter(Ea,"fontVariant",ck);I.addGetterSetter(Ea,"text",qR);I.addGetterSetter(Ea,"textDecoration","");I.addGetterSetter(Ea,"kerningFunc",void 0);I.addGetterSetter(Ea,"direction","inherit");var pk="tr-konva",vR=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((e)=>e+`.${pk}`).join(" "),mk="nodesRect",kR=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],AR={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},yR="ontouchstart"in ve._global;function SR(e,t,a){if(e==="rotater")return a;t+=Z.degToRad(AR[e]||0);let n=(Z.radToDeg(t)%360+360)%360;if(Z._inRange(n,337.5,360)||Z._inRange(n,0,22.5))return"ns-resize";else if(Z._inRange(n,22.5,67.5))return"nesw-resize";else if(Z._inRange(n,67.5,112.5))return"ew-resize";else if(Z._inRange(n,112.5,157.5))return"nwse-resize";else if(Z._inRange(n,157.5,202.5))return"ns-resize";else if(Z._inRange(n,202.5,247.5))return"nesw-resize";else if(Z._inRange(n,247.5,292.5))return"ew-resize";else if(Z._inRange(n,292.5,337.5))return"nwse-resize";else return Z.error("Transformer has unknown angle for cursor detection: "+n),"pointer"}var $m=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],gk=1e8;function CR(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function bk(e,t,a){let n=a.x+(e.x-a.x)*Math.cos(t)-(e.y-a.y)*Math.sin(t),s=a.y+(e.x-a.x)*Math.sin(t)+(e.y-a.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:n,y:s}}function _R(e,t){let a=CR(e);return bk(e,t,a)}function FR(e,t,a){let n=t;for(let s=0;s<e.length;s++){let i=ve.getAngle(e[s]),f=Math.abs(i-t)%(Math.PI*2);if(Math.min(f,Math.PI*2-f)<a)n=i}return n}var $g=0;class kt extends m0{constructor(e){super(e);if(this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(vR,this.update),this.getNode())this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Z.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return pk+this._id}setNodes(e=[]){if(this._nodes&&this._nodes.length)this.detach();let t=e.filter((n)=>{if(n.isAncestorOf(this))return Z.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1;return!0});if(this._nodes=e=t,e.length===1&&this.useSingleNodeRotation())this.rotation(e[0].getAbsoluteRotation());else this.rotation(0);if(this._nodes.forEach((n)=>{let s=()=>{if(this.nodes().length===1&&this.useSingleNodeRotation())this.rotation(this.nodes()[0].getAbsoluteRotation());if(this._resetTransformCache(),!this._transforming&&!this.isDragging())this.update()};if(n._attrsAffectingSize.length){let i=n._attrsAffectingSize.map((f)=>f+"Change."+this._getEventNamespace()).join(" ");n.on(i,s)}n.on(kR.map((i)=>i+`.${this._getEventNamespace()}`).join(" "),s),n.on(`absoluteTransformChange.${this._getEventNamespace()}`,s),this._proxyDrag(n)}),this._resetTransformCache(),!!this.findOne(".top-left"))this.update();return this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,(a)=>{if(t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back"))this.startDrag(a,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,(a)=>{if(!t)return;let n=e.getAbsolutePosition(),s=n.x-t.x,i=n.y-t.y;this.nodes().forEach((f)=>{if(f===e)return;if(f.isDragging())return;let l=f.getAbsolutePosition();f.setAbsolutePosition({x:l.x+s,y:l.y+i}),f.startDrag(a)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){if(this._nodes)this._nodes.forEach((e)=>{e.off("."+this._getEventNamespace())});this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(mk),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(mk,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),a){let n=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=e.getAbsoluteScale(a),i=e.getAbsolutePosition(a),f=n.x*s.x-e.offsetX()*s.x,l=n.y*s.y-e.offsetY()*s.y,c=(ve.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),h={x:i.x+f*Math.cos(c)+l*Math.sin(-c),y:i.y+l*Math.cos(c)+f*Math.sin(c),width:n.width*s.x,height:n.height*s.y,rotation:c};return bk(h,-ve.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-gk,y:-gk,width:0,height:0,rotation:0};let t=[];this.nodes().map((c)=>{let h=c.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),u=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}],g=c.getAbsoluteTransform();u.forEach(function(b){let d=g.point(b);t.push(d)})});let a=new xn;a.rotate(-ve.getAngle(this.rotation()));let n=1/0,s=1/0,i=-1/0,f=-1/0;t.forEach(function(c){let h=a.point(c);if(n===void 0)n=i=h.x,s=f=h.y;n=Math.min(n,h.x),s=Math.min(s,h.y),i=Math.max(i,h.x),f=Math.max(f,h.y)}),a.invert();let l=a.point({x:n,y:s});return{x:l.x,y:l.y,width:i-n,height:f-s,rotation:ve.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),$m.forEach((e)=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){let t=new jl({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:yR?10:"auto"}),a=this;t.on("mousedown touchstart",function(n){a._handleMouseDown(n)}),t.on("dragstart",(n)=>{t.stopDrag(),n.cancelBubble=!0}),t.on("dragend",(n)=>{n.cancelBubble=!0}),t.on("mouseenter",()=>{let n=ve.getAngle(this.rotation()),s=this.rotateAnchorCursor(),i=SR(e,n,s);t.getStage().content&&(t.getStage().content.style.cursor=i),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){let e=new je({name:"back",width:0,height:0,sceneFunc(t,a){let n=a.getParent(),s=n.padding(),i=a.width(),f=a.height();if(t.beginPath(),t.rect(-s,-s,i+s*2,f+s*2),n.rotateEnabled()&&n.rotateLineVisible()){let l=n.rotateAnchorAngle(),c=n.rotateAnchorOffset(),h=Z.degToRad(l),u=Math.sin(h),g=-Math.cos(h),b=i/2,d=f/2,j=1/0;if(g<0)j=Math.min(j,-d/g);else if(g>0)j=Math.min(j,(f-d)/g);if(u<0)j=Math.min(j,-b/u);else if(u>0)j=Math.min(j,(i-b)/u);let A=b+u*j,C=d+g*j,y=Z._sign(f),O=A+u*c*y,T=C+g*c*y;t.moveTo(A,C),t.lineTo(O,T)}t.fillStrokeShape(a)},hitFunc:(t,a)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();t.beginPath(),t.rect(-n,-n,a.width()+n*2,a.height()+n*2),t.fillStrokeShape(a)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t)=>{t.cancelBubble=!0}),e.on("dragmove",(t)=>{t.cancelBubble=!0}),e.on("dragend",(t)=>{t.cancelBubble=!0}),this.on("dragmove",(t)=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];let t=this._getNodeRect(),a=t.width,n=t.height,s=Math.sqrt(Math.pow(a,2)+Math.pow(n,2));if(this.sin=Math.abs(n/s),this.cos=Math.abs(a/s),typeof window<"u")window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0);this._transforming=!0;let i=e.target.getAbsolutePosition(),f=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:f.x-i.x,y:f.y-i.y},$g++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach((l)=>{l._fire("transformstart",{evt:e.evt,target:l})})}_handleMouseMove(e){let t,a,n,s=this.findOne("."+this._movingAnchorName),i=s.getStage();i.setPointersPositions(e);let f=i.getPointerPosition(),l={x:f.x-this._anchorDragOffset.x,y:f.y-this._anchorDragOffset.y},c=s.getAbsolutePosition();if(this.anchorDragBoundFunc())l=this.anchorDragBoundFunc()(c,l,e);s.setAbsolutePosition(l);let h=s.getAbsolutePosition();if(c.x===h.x&&c.y===h.y)return;if(this._movingAnchorName==="rotater"){let y=this._getNodeRect();t=s.x()-y.width/2,a=-s.y()+y.height/2;let O=ve.getAngle(this.rotateAnchorAngle()),T=Math.atan2(-a,t)+Math.PI/2-O;if(y.height<0)T-=Math.PI;let H=ve.getAngle(this.rotation())+T,N=ve.getAngle(this.rotationSnapTolerance()),z=FR(this.rotationSnaps(),H,N)-y.rotation,K=_R(y,z);this._fitNodesInto(K,e);return}let u=this.shiftBehavior(),g;if(u==="inverted")g=this.keepRatio()&&!e.shiftKey;else if(u==="none")g=this.keepRatio();else g=this.keepRatio()||e.shiftKey;let b=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(g){let y=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(y.x-s.x(),2)+Math.pow(y.y-s.y(),2));let O=this.findOne(".top-left").x()>y.x?-1:1,T=this.findOne(".top-left").y()>y.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-a)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(s.y());else if(this._movingAnchorName==="top-right"){if(g){let y=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(s.x()-y.x,2)+Math.pow(y.y-s.y(),2));let O=this.findOne(".top-right").x()<y.x?-1:1,T=this.findOne(".top-right").y()>y.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-a)}var d=s.position();this.findOne(".top-left").y(d.y),this.findOne(".bottom-right").x(d.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(s.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(s.x());else if(this._movingAnchorName==="bottom-left"){if(g){let y=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(y.x-s.x(),2)+Math.pow(s.y()-y.y,2));let O=y.x<s.x()?-1:1,T=s.y()<y.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,s.x(y.x-t),s.y(y.y+a)}d=s.position(),this.findOne(".top-left").x(d.x),this.findOne(".bottom-right").y(d.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(s.y());else if(this._movingAnchorName==="bottom-right"){if(g){let y=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(s.x()-y.x,2)+Math.pow(s.y()-y.y,2));let O=this.findOne(".bottom-right").x()<y.x?-1:1,T=this.findOne(".bottom-right").y()<y.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+a)}}else console.error(Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(b=this.centeredScaling()||e.altKey,b){let y=this.findOne(".top-left"),O=this.findOne(".bottom-right"),T=y.x(),M=y.y(),H=this.getWidth()-O.x(),N=this.getHeight()-O.y();O.move({x:-T,y:-M}),y.move({x:H,y:N})}let j=this.findOne(".top-left").getAbsolutePosition();t=j.x,a=j.y;let A=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),C=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:a,width:A,height:C,rotation:ve.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){if(this._transforming=!1,typeof window<"u")window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0);let a=this.getNode();if($g--,this._fire("transformend",{evt:e,target:a}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),a)this._nodes.forEach((n)=>{var s;n._fire("transformend",{evt:e,target:n}),(s=n.getLayer())===null||s===void 0||s.batchDraw()});this._movingAnchorName=null}}_fitNodesInto(e,t){let a=this._getNodeRect(),n=1;if(Z._inRange(e.width,-this.padding()*2-1,1)){this.update();return}if(Z._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let s=new xn;if(s.rotate(ve.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){let g=s.point({x:-this.padding()*2,y:0});e.x+=g.x,e.y+=g.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=g.x,this._anchorDragOffset.y-=g.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){let g=s.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=g.x,this._anchorDragOffset.y-=g.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){let g=s.point({x:0,y:-this.padding()*2});e.x+=g.x,e.y+=g.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=g.x,this._anchorDragOffset.y-=g.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){let g=s.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=g.x,this._anchorDragOffset.y-=g.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){let g=this.boundBoxFunc()(a,e);if(g)e=g;else Z.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}let i=1e7,f=new xn;f.translate(a.x,a.y),f.rotate(a.rotation),f.scale(a.width/i,a.height/i);let l=new xn,c=e.width/i,h=e.height/i;if(this.flipEnabled()===!1)l.translate(e.x,e.y),l.rotate(e.rotation),l.translate(e.width<0?e.width:0,e.height<0?e.height:0),l.scale(Math.abs(c),Math.abs(h));else l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(c,h);let u=l.multiply(f.invert());this._nodes.forEach((g)=>{var b;if(!g.getStage())return;let d=g.getParent().getAbsoluteTransform(),j=g.getTransform().copy();j.translate(g.offsetX(),g.offsetY());let A=new xn;A.multiply(d.copy().invert()).multiply(u).multiply(d).multiply(j);let C=A.decompose();g.setAttrs(C),(b=g.getLayer())===null||b===void 0||b.batchDraw()}),this.rotation(Z._getRotation(e.rotation)),this._nodes.forEach((g)=>{this._fire("transform",{evt:t,target:g}),g._fire("transform",{evt:t,target:g})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;let t=this._getNodeRect();this.rotation(Z._getRotation(t.rotation));let{width:a,height:n}=t,s=this.enabledAnchors(),i=this.resizeEnabled(),f=this.padding(),l=this.anchorSize(),c=this.find("._anchor");c.forEach((H)=>{H.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+f,offsetY:l/2+f,visible:i&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:a/2,y:0,offsetY:l/2+f,visible:i&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:a,y:0,offsetX:l/2-f,offsetY:l/2+f,visible:i&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:l/2+f,visible:i&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:a,y:n/2,offsetX:l/2-f,visible:i&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:l/2+f,offsetY:l/2-f,visible:i&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:a/2,y:n,offsetY:l/2-f,visible:i&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:a,y:n,offsetX:l/2-f,offsetY:l/2-f,visible:i&&s.indexOf("bottom-right")>=0});let h=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),g=Z.degToRad(h),b=Math.sin(g),d=-Math.cos(g),j=a/2,A=n/2,C=1/0;if(d<0)C=Math.min(C,-A/d);else if(d>0)C=Math.min(C,(n-A)/d);if(b<0)C=Math.min(C,-j/b);else if(b>0)C=Math.min(C,(a-j)/b);let y=j+b*C,O=A+d*C,T=Z._sign(n);this._batchChangeChild(".rotater",{x:y+b*u*T,y:O+d*u*T-f*d,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:a,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some((H)=>H.draggable()),x:0,y:0});let M=this.anchorStyleFunc();if(M)c.forEach((H)=>{M(H)});(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();let e=this.findOne("."+this._movingAnchorName);if(e)e.stopDrag()}}destroy(){if(this.getStage()&&this._cursorChange)this.getStage().content&&(this.getStage().content.style.cursor="");return m0.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){if(this._elementsCreated)return Z.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this;return super.add(...e)}toObject(){return qe.prototype.toObject.call(this)}clone(e){return qe.prototype.clone.call(this,e)}getClientRect(){if(this.nodes().length>0)return super.getClientRect();else return{x:0,y:0,width:0,height:0}}}kt.isTransforming=()=>{return $g>0};function OR(e){if(!(e instanceof Array))Z.warn("enabledAnchors value should be an array");if(e instanceof Array)e.forEach(function(t){if($m.indexOf(t)===-1)Z.warn("Unknown anchor name: "+t+". Available names are: "+$m.join(", "))});return e||[]}kt.prototype.className="Transformer";lt(kt);I.addGetterSetter(kt,"enabledAnchors",$m,OR);I.addGetterSetter(kt,"flipEnabled",!0,Rn());I.addGetterSetter(kt,"resizeEnabled",!0);I.addGetterSetter(kt,"anchorSize",10,we());I.addGetterSetter(kt,"rotateEnabled",!0);I.addGetterSetter(kt,"rotateLineVisible",!0);I.addGetterSetter(kt,"rotationSnaps",[]);I.addGetterSetter(kt,"rotateAnchorOffset",50,we());I.addGetterSetter(kt,"rotateAnchorAngle",0,we());I.addGetterSetter(kt,"rotateAnchorCursor","crosshair");I.addGetterSetter(kt,"rotationSnapTolerance",5,we());I.addGetterSetter(kt,"borderEnabled",!0);I.addGetterSetter(kt,"anchorStroke","rgb(0, 161, 255)");I.addGetterSetter(kt,"anchorStrokeWidth",1,we());I.addGetterSetter(kt,"anchorFill","white");I.addGetterSetter(kt,"anchorCornerRadius",0,we());I.addGetterSetter(kt,"borderStroke","rgb(0, 161, 255)");I.addGetterSetter(kt,"borderStrokeWidth",1,we());I.addGetterSetter(kt,"borderDash");I.addGetterSetter(kt,"keepRatio",!0);I.addGetterSetter(kt,"shiftBehavior","default");I.addGetterSetter(kt,"centeredScaling",!1);I.addGetterSetter(kt,"ignoreStroke",!1);I.addGetterSetter(kt,"padding",0,we());I.addGetterSetter(kt,"nodes");I.addGetterSetter(kt,"node");I.addGetterSetter(kt,"boundBoxFunc");I.addGetterSetter(kt,"anchorDragBoundFunc");I.addGetterSetter(kt,"anchorStyleFunc");I.addGetterSetter(kt,"shouldOverdrawWholeArea",!1);I.addGetterSetter(kt,"useSingleNodeRotation",!0);I.backCompat(kt,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Ri extends je{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,ve.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Ri.prototype.className="Wedge";Ri.prototype._centroid=!0;Ri.prototype._attrsAffectingSize=["radius"];lt(Ri);I.addGetterSetter(Ri,"radius",0,we());I.addGetterSetter(Ri,"angle",0,we());I.addGetterSetter(Ri,"clockwise",!1);I.backCompat(Ri,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function wk(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var BR=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],TR=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function HR(e,t){let{data:a,width:n,height:s}=e,i,f,l,c,h,u,g,b,d,j,A,C,y,O,T,M,H,N,x,z,K=t+t+1,$=n-1,Q=s-1,P=t+1,te=P*(P+1)/2,ee=new wk,L=BR[t],J=TR[t],pe=null,ne=ee,fe=null,Ae=null;for(let he=1;he<K;he++)if(ne=ne.next=new wk,he===P)pe=ne;ne.next=ee,l=f=0;for(let he=0;he<s;he++){C=y=O=T=c=h=u=g=0,b=P*(M=a[f]),d=P*(H=a[f+1]),j=P*(N=a[f+2]),A=P*(x=a[f+3]),c+=te*M,h+=te*H,u+=te*N,g+=te*x,ne=ee;for(let re=0;re<P;re++)ne.r=M,ne.g=H,ne.b=N,ne.a=x,ne=ne.next;for(let re=1;re<P;re++)i=f+(($<re?$:re)<<2),c+=(ne.r=M=a[i])*(z=P-re),h+=(ne.g=H=a[i+1])*z,u+=(ne.b=N=a[i+2])*z,g+=(ne.a=x=a[i+3])*z,C+=M,y+=H,O+=N,T+=x,ne=ne.next;fe=ee,Ae=pe;for(let re=0;re<n;re++){if(a[f+3]=x=g*L>>J,x!==0)x=255/x,a[f]=(c*L>>J)*x,a[f+1]=(h*L>>J)*x,a[f+2]=(u*L>>J)*x;else a[f]=a[f+1]=a[f+2]=0;c-=b,h-=d,u-=j,g-=A,b-=fe.r,d-=fe.g,j-=fe.b,A-=fe.a,i=l+((i=re+t+1)<$?i:$)<<2,C+=fe.r=a[i],y+=fe.g=a[i+1],O+=fe.b=a[i+2],T+=fe.a=a[i+3],c+=C,h+=y,u+=O,g+=T,fe=fe.next,b+=M=Ae.r,d+=H=Ae.g,j+=N=Ae.b,A+=x=Ae.a,C-=M,y-=H,O-=N,T-=x,Ae=Ae.next,f+=4}l+=n}for(let he=0;he<n;he++){y=O=T=C=h=u=g=c=0,f=he<<2,b=P*(M=a[f]),d=P*(H=a[f+1]),j=P*(N=a[f+2]),A=P*(x=a[f+3]),c+=te*M,h+=te*H,u+=te*N,g+=te*x,ne=ee;for(let be=0;be<P;be++)ne.r=M,ne.g=H,ne.b=N,ne.a=x,ne=ne.next;let re=n;for(let be=1;be<=t;be++)if(f=re+he<<2,c+=(ne.r=M=a[f])*(z=P-be),h+=(ne.g=H=a[f+1])*z,u+=(ne.b=N=a[f+2])*z,g+=(ne.a=x=a[f+3])*z,C+=M,y+=H,O+=N,T+=x,ne=ne.next,be<Q)re+=n;f=he,fe=ee,Ae=pe;for(let be=0;be<s;be++){if(i=f<<2,a[i+3]=x=g*L>>J,x>0)x=255/x,a[i]=(c*L>>J)*x,a[i+1]=(h*L>>J)*x,a[i+2]=(u*L>>J)*x;else a[i]=a[i+1]=a[i+2]=0;c-=b,h-=d,u-=j,g-=A,b-=fe.r,d-=fe.g,j-=fe.b,A-=fe.a,i=he+((i=be+P)<Q?i:Q)*n<<2,c+=C+=fe.r=a[i],h+=y+=fe.g=a[i+1],u+=O+=fe.b=a[i+2],g+=T+=fe.a=a[i+3],fe=fe.next,b+=M=Ae.r,d+=H=Ae.g,j+=N=Ae.b,A+=x=Ae.a,C-=M,y-=H,O-=N,T-=x,Ae=Ae.next,f+=n}}}var dk=function(t){let a=Math.round(this.blurRadius());if(a>0)HR(t,a)};I.addGetterSetter(qe,"blurRadius",0,we(),I.afterSetFilter);var jk=function(e){let t=this.brightness()*255,a=e.data,n=a.length;for(let s=0;s<n;s+=4)a[s]+=t,a[s+1]+=t,a[s+2]+=t};I.addGetterSetter(qe,"brightness",0,we(),I.afterSetFilter);var qk=function(e){let t=this.brightness(),a=e.data,n=a.length;for(let s=0;s<n;s+=4)a[s]=Math.min(255,a[s]*t),a[s+1]=Math.min(255,a[s+1]*t),a[s+2]=Math.min(255,a[s+2]*t)};var vk=function(e){let t=Math.pow((this.contrast()+100)/100,2),a=e.data,n=a.length,s=150,i=150,f=150;for(let l=0;l<n;l+=4)s=a[l],i=a[l+1],f=a[l+2],s/=255,s-=0.5,s*=t,s+=0.5,s*=255,i/=255,i-=0.5,i*=t,i+=0.5,i*=255,f/=255,f-=0.5,f*=t,f+=0.5,f*=255,s=s<0?0:s>255?255:s,i=i<0?0:i>255?255:i,f=f<0?0:f>255?255:f,a[l]=s,a[l+1]=i,a[l+2]=f};I.addGetterSetter(qe,"contrast",0,we(),I.afterSetFilter);var kk=function(e){var t,a,n,s,i,f,l,c,h;let{data:u,width:g,height:b}=e,d=Math.min(1,Math.max(0,(a=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&a!==void 0?a:0.5)),j=Math.min(1,Math.max(0,(s=(n=this.embossWhiteLevel)===null||n===void 0?void 0:n.call(this))!==null&&s!==void 0?s:0.5)),C=(l={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(f=(i=this.embossDirection)===null||i===void 0?void 0:i.call(this))!==null&&f!==void 0?f:"top-left"])!==null&&l!==void 0?l:315,y=!!((h=(c=this.embossBlend)===null||c===void 0?void 0:c.call(this))!==null&&h!==void 0?h:!1),O=d*10,T=j*255,M=C*Math.PI/180,H=Math.cos(M),N=Math.sin(M),x=0.12549019607843137*O,z=new Uint8ClampedArray(u),K=new Float32Array(g*b);for(let ee=0,L=0;L<u.length;L+=4,ee++)K[ee]=0.2126*z[L]+0.7152*z[L+1]+0.0722*z[L+2];let $=[-1,0,1,-2,0,2,-1,0,1],Q=[-1,-2,-1,0,0,0,1,2,1],P=[-g-1,-g,-g+1,-1,0,1,g-1,g,g+1],te=(ee)=>ee<0?0:ee>255?255:ee;for(let ee=1;ee<b-1;ee++)for(let L=1;L<g-1;L++){let J=ee*g+L,pe=0,ne=0;pe+=K[J+P[0]]*$[0],ne+=K[J+P[0]]*Q[0],pe+=K[J+P[1]]*$[1],ne+=K[J+P[1]]*Q[1],pe+=K[J+P[2]]*$[2],ne+=K[J+P[2]]*Q[2],pe+=K[J+P[3]]*$[3],ne+=K[J+P[3]]*Q[3],pe+=K[J+P[5]]*$[5],ne+=K[J+P[5]]*Q[5],pe+=K[J+P[6]]*$[6],ne+=K[J+P[6]]*Q[6],pe+=K[J+P[7]]*$[7],ne+=K[J+P[7]]*Q[7],pe+=K[J+P[8]]*$[8],ne+=K[J+P[8]]*Q[8];let fe=H*pe+N*ne,Ae=te(T+fe*x),he=J*4;if(y){let re=Ae-T;u[he]=te(z[he]+re),u[he+1]=te(z[he+1]+re),u[he+2]=te(z[he+2]+re),u[he+3]=z[he+3]}else u[he]=u[he+1]=u[he+2]=Ae,u[he+3]=z[he+3]}for(let ee=0;ee<g;ee++){let L=ee*4,J=((b-1)*g+ee)*4;u[L]=z[L],u[L+1]=z[L+1],u[L+2]=z[L+2],u[L+3]=z[L+3],u[J]=z[J],u[J+1]=z[J+1],u[J+2]=z[J+2],u[J+3]=z[J+3]}for(let ee=1;ee<b-1;ee++){let L=ee*g*4,J=(ee*g+(g-1))*4;u[L]=z[L],u[L+1]=z[L+1],u[L+2]=z[L+2],u[L+3]=z[L+3],u[J]=z[J],u[J+1]=z[J+1],u[J+2]=z[J+2],u[J+3]=z[J+3]}return e};I.addGetterSetter(qe,"embossStrength",0.5,we(),I.afterSetFilter);I.addGetterSetter(qe,"embossWhiteLevel",0.5,we(),I.afterSetFilter);I.addGetterSetter(qe,"embossDirection","top-left",void 0,I.afterSetFilter);I.addGetterSetter(qe,"embossBlend",!1,void 0,I.afterSetFilter);function Wg(e,t,a,n,s){let i=a-t,f=s-n;if(i===0)return n+f/2;if(f===0)return n;let l=(e-t)/i;return l=f*l+n,l}var Ak=function(e){let t=e.data,a=t.length,n=t[0],s=n,i,f=t[1],l=f,c,h=t[2],u=h,g,b=this.enhance();if(b===0)return;for(let T=0;T<a;T+=4){if(i=t[T+0],i<n)n=i;else if(i>s)s=i;if(c=t[T+1],c<f)f=c;else if(c>l)l=c;if(g=t[T+2],g<h)h=g;else if(g>u)u=g}if(s===n)s=255,n=0;if(l===f)l=255,f=0;if(u===h)u=255,h=0;let d,j,A,C,y,O;if(b>0)d=s+b*(255-s),j=n-b*(n-0),A=l+b*(255-l),C=f-b*(f-0),y=u+b*(255-u),O=h-b*(h-0);else{let T=(s+n)*0.5;d=s+b*(s-T),j=n+b*(n-T);let M=(l+f)*0.5;A=l+b*(l-M),C=f+b*(f-M);let H=(u+h)*0.5;y=u+b*(u-H),O=h+b*(h-H)}for(let T=0;T<a;T+=4)t[T+0]=Wg(t[T+0],n,s,j,d),t[T+1]=Wg(t[T+1],f,l,C,A),t[T+2]=Wg(t[T+2],h,u,O,y)};I.addGetterSetter(qe,"enhance",0,we(),I.afterSetFilter);var yk=function(e){let t=e.data,a=t.length;for(let n=0;n<a;n+=4){let s=0.34*t[n]+0.5*t[n+1]+0.16*t[n+2];t[n]=s,t[n+1]=s,t[n+2]=s}};I.addGetterSetter(qe,"hue",0,we(),I.afterSetFilter);I.addGetterSetter(qe,"saturation",0,we(),I.afterSetFilter);I.addGetterSetter(qe,"luminance",0,we(),I.afterSetFilter);var Sk=function(e){let t=e.data,a=t.length,s=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,f=this.luminance()*127,l=1*s*Math.cos(i*Math.PI/180),c=1*s*Math.sin(i*Math.PI/180),h=0.299+0.701*l+0.167*c,u=0.587-0.587*l+0.33*c,g=0.114-0.114*l-0.497*c,b=0.299-0.299*l-0.328*c,d=0.587+0.413*l+0.035*c,j=0.114-0.114*l+0.293*c,A=0.299-0.3*l+1.25*c,C=0.587-0.586*l-1.05*c,y=0.114+0.886*l-0.2*c,O,T,M,H;for(let N=0;N<a;N+=4)O=t[N+0],T=t[N+1],M=t[N+2],H=t[N+3],t[N+0]=h*O+u*T+g*M+f,t[N+1]=b*O+d*T+j*M+f,t[N+2]=A*O+C*T+y*M+f,t[N+3]=H};var Ck=function(e){let t=e.data,a=t.length,n=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,f=n*s*Math.cos(i*Math.PI/180),l=n*s*Math.sin(i*Math.PI/180),c=0.299*n+0.701*f+0.167*l,h=0.587*n-0.587*f+0.33*l,u=0.114*n-0.114*f-0.497*l,g=0.299*n-0.299*f-0.328*l,b=0.587*n+0.413*f+0.035*l,d=0.114*n-0.114*f+0.293*l,j=0.299*n-0.3*f+1.25*l,A=0.587*n-0.586*f-1.05*l,C=0.114*n+0.886*f-0.2*l;for(let y=0;y<a;y+=4){let O=t[y+0],T=t[y+1],M=t[y+2],H=t[y+3];t[y+0]=c*O+h*T+u*M,t[y+1]=g*O+b*T+d*M,t[y+2]=j*O+A*T+C*M,t[y+3]=H}};I.addGetterSetter(qe,"hue",0,we(),I.afterSetFilter);I.addGetterSetter(qe,"saturation",0,we(),I.afterSetFilter);I.addGetterSetter(qe,"value",0,we(),I.afterSetFilter);var _k=function(e){let t=e.data,a=t.length;for(let n=0;n<a;n+=4)t[n]=255-t[n],t[n+1]=255-t[n+1],t[n+2]=255-t[n+2]};var MR=function(e,t,a){let n=e.data,s=t.data,i=e.width,f=e.height,l=a.polarCenterX||i/2,c=a.polarCenterY||f/2,h=Math.sqrt(l*l+c*c),u=i-l,g=f-c,b=Math.sqrt(u*u+g*g);h=b>h?b:h;let d=f,j=i,A=360/j*Math.PI/180;for(let C=0;C<j;C+=1){let y=Math.sin(C*A),O=Math.cos(C*A);for(let T=0;T<d;T+=1){u=Math.floor(l+h*T/d*O),g=Math.floor(c+h*T/d*y);let M=(g*i+u)*4,H=n[M+0],N=n[M+1],x=n[M+2],z=n[M+3];M=(C+T*i)*4,s[M+0]=H,s[M+1]=N,s[M+2]=x,s[M+3]=z}}},DR=function(e,t,a){let n=e.data,s=t.data,i=e.width,f=e.height,l=a.polarCenterX||i/2,c=a.polarCenterY||f/2,h=Math.sqrt(l*l+c*c),u=i-l,g=f-c,b=Math.sqrt(u*u+g*g);h=b>h?b:h;let d=f,j=i,A=a.polarRotation||0,C,y;for(u=0;u<i;u+=1)for(g=0;g<f;g+=1){let O=u-l,T=g-c,M=Math.sqrt(O*O+T*T)*d/h,H=(Math.atan2(T,O)*180/Math.PI+360+A)%360;H=H*j/360,C=Math.floor(H),y=Math.floor(M);let N=(y*i+C)*4,x=n[N+0],z=n[N+1],K=n[N+2],$=n[N+3];N=(g*i+u)*4,s[N+0]=x,s[N+1]=z,s[N+2]=K,s[N+3]=$}},Fk=function(e){let{width:t,height:a}=e,n,s,i,f,l,c,h,u,g,b,d=Math.round(this.kaleidoscopePower()),j=Math.round(this.kaleidoscopeAngle()),A=Math.floor(t*(j%360)/360);if(d<1)return;let C=Z.createCanvasElement();C.width=t,C.height=a;let y=C.getContext("2d").getImageData(0,0,t,a);Z.releaseCanvas(C),MR(e,y,{polarCenterX:t/2,polarCenterY:a/2});let O=t/Math.pow(2,d);while(O<=8)O=O*2,d-=1;O=Math.ceil(O);let T=O,M=0,H=T,N=1;if(A+O>t)M=T,H=0,N=-1;for(s=0;s<a;s+=1)for(n=M;n!==H;n+=N)i=Math.round(n+A)%t,g=(t*s+i)*4,l=y.data[g+0],c=y.data[g+1],h=y.data[g+2],u=y.data[g+3],b=(t*s+n)*4,y.data[b+0]=l,y.data[b+1]=c,y.data[b+2]=h,y.data[b+3]=u;for(s=0;s<a;s+=1){T=Math.floor(O);for(f=0;f<d;f+=1){for(n=0;n<T+1;n+=1)g=(t*s+n)*4,l=y.data[g+0],c=y.data[g+1],h=y.data[g+2],u=y.data[g+3],b=(t*s+T*2-n-1)*4,y.data[b+0]=l,y.data[b+1]=c,y.data[b+2]=h,y.data[b+3]=u;T*=2}}DR(y,e,{polarRotation:0})};I.addGetterSetter(qe,"kaleidoscopePower",2,we(),I.afterSetFilter);I.addGetterSetter(qe,"kaleidoscopeAngle",0,we(),I.afterSetFilter);function Wm(e,t,a){let n=(a*e.width+t)*4,s=[];return s.push(e.data[n++],e.data[n++],e.data[n++],e.data[n++]),s}function e2(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function xR(e){let t=[0,0,0];for(let a=0;a<e.length;a++)t[0]+=e[a][0],t[1]+=e[a][1],t[2]+=e[a][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function RR(e,t){let a=Wm(e,0,0),n=Wm(e,e.width-1,0),s=Wm(e,0,e.height-1),i=Wm(e,e.width-1,e.height-1),f=t||10;if(e2(a,n)<f&&e2(n,i)<f&&e2(i,s)<f&&e2(s,a)<f){let l=xR([n,a,i,s]),c=[];for(let h=0;h<e.width*e.height;h++){let u=e2(l,[e.data[h*4],e.data[h*4+1],e.data[h*4+2]]);c[h]=u<f?0:255}return c}}function NR(e,t){for(let a=0;a<e.width*e.height;a++)e.data[4*a+3]=t[a]}function ER(e,t,a){let n=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(n.length)),i=Math.floor(s/2),f=[];for(let l=0;l<a;l++)for(let c=0;c<t;c++){let h=l*t+c,u=0;for(let g=0;g<s;g++)for(let b=0;b<s;b++){let d=l+g-i,j=c+b-i;if(d>=0&&d<a&&j>=0&&j<t){let A=d*t+j,C=n[g*s+b];u+=e[A]*C}}f[h]=u===2040?255:0}return f}function zR(e,t,a){let n=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(n.length)),i=Math.floor(s/2),f=[];for(let l=0;l<a;l++)for(let c=0;c<t;c++){let h=l*t+c,u=0;for(let g=0;g<s;g++)for(let b=0;b<s;b++){let d=l+g-i,j=c+b-i;if(d>=0&&d<a&&j>=0&&j<t){let A=d*t+j,C=n[g*s+b];u+=e[A]*C}}f[h]=u>=1020?255:0}return f}function UR(e,t,a){let n=[0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111],s=Math.round(Math.sqrt(n.length)),i=Math.floor(s/2),f=[];for(let l=0;l<a;l++)for(let c=0;c<t;c++){let h=l*t+c,u=0;for(let g=0;g<s;g++)for(let b=0;b<s;b++){let d=l+g-i,j=c+b-i;if(d>=0&&d<a&&j>=0&&j<t){let A=d*t+j,C=n[g*s+b];u+=e[A]*C}}f[h]=u}return f}var Ok=function(e){let t=this.threshold(),a=RR(e,t);if(a)a=ER(a,e.width,e.height),a=zR(a,e.width,e.height),a=UR(a,e.width,e.height),NR(e,a);return e};I.addGetterSetter(qe,"threshold",0,we(),I.afterSetFilter);var Bk=function(e){let t=this.noise()*255,a=e.data,n=a.length,s=t/2;for(let i=0;i<n;i+=4)a[i+0]+=s-2*s*Math.random(),a[i+1]+=s-2*s*Math.random(),a[i+2]+=s-2*s*Math.random()};I.addGetterSetter(qe,"noise",0.2,we(),I.afterSetFilter);var Tk=function(e){let t=Math.ceil(this.pixelSize()),a=e.width,n=e.height,s=Math.ceil(a/t),i=Math.ceil(n/t),f=e.data;if(t<=0){Z.error("pixelSize value can not be <= 0");return}for(let l=0;l<s;l+=1)for(let c=0;c<i;c+=1){let h=0,u=0,g=0,b=0,d=l*t,j=d+t,A=c*t,C=A+t,y=0;for(let O=d;O<j;O+=1){if(O>=a)continue;for(let T=A;T<C;T+=1){if(T>=n)continue;let M=(a*T+O)*4;h+=f[M+0],u+=f[M+1],g+=f[M+2],b+=f[M+3],y+=1}}h=h/y,u=u/y,g=g/y,b=b/y;for(let O=d;O<j;O+=1){if(O>=a)continue;for(let T=A;T<C;T+=1){if(T>=n)continue;let M=(a*T+O)*4;f[M+0]=h,f[M+1]=u,f[M+2]=g,f[M+3]=b}}}};I.addGetterSetter(qe,"pixelSize",8,we(),I.afterSetFilter);var Hk=function(e){let t=Math.round(this.levels()*254)+1,a=e.data,n=a.length,s=255/t;for(let i=0;i<n;i+=1)a[i]=Math.floor(a[i]/s)*s};I.addGetterSetter(qe,"levels",0.5,we(),I.afterSetFilter);var Mk=function(e){let t=e.data,a=t.length,n=this.red(),s=this.green(),i=this.blue();for(let f=0;f<a;f+=4){let l=(0.34*t[f]+0.5*t[f+1]+0.16*t[f+2])/255;t[f]=l*n,t[f+1]=l*s,t[f+2]=l*i,t[f+3]=t[f+3]}};I.addGetterSetter(qe,"red",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});I.addGetterSetter(qe,"green",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});I.addGetterSetter(qe,"blue",0,Em,I.afterSetFilter);var Dk=function(e){let t=e.data,a=t.length,n=this.red(),s=this.green(),i=this.blue(),f=this.alpha();for(let l=0;l<a;l+=4){let c=1-f;t[l]=n*f+t[l]*c,t[l+1]=s*f+t[l+1]*c,t[l+2]=i*f+t[l+2]*c}};I.addGetterSetter(qe,"red",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});I.addGetterSetter(qe,"green",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});I.addGetterSetter(qe,"blue",0,Em,I.afterSetFilter);I.addGetterSetter(qe,"alpha",1,function(e){if(this._filterUpToDate=!1,e>1)return 1;else if(e<0)return 0;else return e});var xk=function(e){let t=e.data,a=t.length;for(let n=0;n<a;n+=4){let s=t[n+0],i=t[n+1],f=t[n+2];t[n+0]=Math.min(255,s*0.393+i*0.769+f*0.189),t[n+1]=Math.min(255,s*0.349+i*0.686+f*0.168),t[n+2]=Math.min(255,s*0.272+i*0.534+f*0.131)}};var Rk=function(e){let a=e.data;for(let n=0;n<a.length;n+=4){let s=a[n],i=a[n+1],f=a[n+2];if(0.2126*s+0.7152*i+0.0722*f>=128)a[n]=255-s,a[n+1]=255-i,a[n+2]=255-f}return e};var Nk=function(e){let t=this.threshold()*255,a=e.data,n=a.length;for(let s=0;s<n;s+=1)a[s]=a[s]<t?0:255};I.addGetterSetter(qe,"threshold",0.5,we(),I.afterSetFilter);var Ek=Ho.Util._assign(Ho,{Arc:xi,Arrow:sf,Circle:dl,Ellipse:g0,Image:Cs,Label:$h,Tag:ff,Line:wi,Path:Wt,Rect:jl,RegularPolygon:p0,Ring:lf,Sprite:di,Star:b0,Text:Pt,TextPath:Ea,Transformer:kt,Wedge:Ri,Filters:{Blur:dk,Brightness:qk,Brighten:jk,Contrast:vk,Emboss:kk,Enhance:Ak,Grayscale:yk,HSL:Sk,HSV:Ck,Invert:_k,Kaleidoscope:Fk,Mask:Ok,Noise:Bk,Pixelate:Tk,Posterize:Hk,RGB:Mk,RGBA:Dk,Sepia:xk,Solarize:Rk,Threshold:Nk}});var zk=Ek;var Vs=Mt(en(),1);var fn=Mt(en(),1);var Do=Ho;var sA=Mt(Vk(),1);var a8=1;var t5=32,n8=2;var s8={};JR(s8,{warnsIfNotActing:()=>bN,waitForCommitToBeReady:()=>WN,unhideTextInstance:()=>TN,unhideInstance:()=>BN,trackSchedulerEvent:()=>KN,suspendInstance:()=>$N,supportsPersistence:()=>dN,supportsMutation:()=>wN,supportsMicrotasks:()=>hN,supportsHydration:()=>jN,startSuspendingCommit:()=>ZN,shouldSetTextContent:()=>gN,shouldDeprioritizeSubtree:()=>fN,shouldAttemptEagerTransition:()=>XN,setCurrentUpdatePriority:()=>UN,scheduleTimeout:()=>oN,scheduleMicrotask:()=>uN,run:()=>Zk,resolveUpdatePriority:()=>GN,resolveEventType:()=>LN,resolveEventTimeStamp:()=>VN,resetTextContent:()=>iN,resetFormInstance:()=>tE,resetAfterCommit:()=>sN,requestPostPaintCallback:()=>YN,removeChildFromContainer:()=>yN,removeChild:()=>AN,prepareUpdate:()=>nN,prepareScopeUpdate:()=>EN,preparePortalMount:()=>aN,prepareForCommit:()=>tN,preloadInstance:()=>QN,now:()=>Pm,noTimeout:()=>mN,maySuspendCommit:()=>JN,isPrimaryRenderer:()=>pN,insertInContainerBefore:()=>kN,insertBefore:()=>eA,idlePriority:()=>e5,hideTextInstance:()=>ON,hideInstance:()=>FN,getRootHostContext:()=>lN,getPublicInstance:()=>eN,getInstanceFromScope:()=>zN,getInstanceFromNode:()=>DN,getCurrentUpdatePriority:()=>IN,getCurrentEventPriority:()=>NN,getChildHostContext:()=>rN,finalizeInitialChildren:()=>PR,detachDeletedInstance:()=>MN,createTextInstance:()=>WR,createInstance:()=>$R,commitUpdate:()=>_N,commitTextUpdate:()=>SN,commitMount:()=>CN,clearContainer:()=>HN,cancelTimeout:()=>cN,beforeActiveInstanceBlur:()=>xN,appendInitialChild:()=>ZR,appendChildToContainer:()=>vN,appendChild:()=>qN,afterActiveInstanceBlur:()=>RN,NotPendingTransition:()=>PN,HostTransitionContext:()=>eE});var $k=Mt(en(),1);var Yk={children:!0,ref:!0,key:!0,style:!0,forwardedRef:!0,unstable_applyCache:!0,unstable_applyDrawHitFromCache:!0},Jk=!1,Qk=!1,a2=".react-konva-event",KR=!1;var LR=`ReactKonva: You have a Konva node with draggable = true and position defined but no onDragMove or onDragEnd events are handled.
246
+ Position of a node will be changed during drag&drop, so you should update state of the react app as well.
247
+ Consider to add onDragMove or onDragEnd events.
248
+ For more info see: https://github.com/konvajs/react-konva/issues/256
249
+ `,VR=`ReactKonva: You are using "zIndex" attribute for a Konva node.
250
+ react-konva may get confused with ordering. Just define correct order of elements in your render function of a component.
251
+ For more info see: https://github.com/konvajs/react-konva/issues/194
252
+ `,YR={};function xo(e,t,a=YR){if(!Jk&&"zIndex"in t)console.warn(VR),Jk=!0;if(!Qk&&t.draggable){var n=t.x!==void 0||t.y!==void 0,s=t.onDragEnd||t.onDragMove;if(n&&!s)console.warn(LR),Qk=!0}for(var i in a){if(Yk[i])continue;var f=i.slice(0,2)==="on",l=a[i]!==t[i];if(f&&l){var c=i.substr(2).toLowerCase();if(c.substr(0,7)==="content")c="content"+c.substr(7,1).toUpperCase()+c.substr(8);e.off(c,a[i])}var h=!t.hasOwnProperty(i);if(h)e.setAttr(i,void 0)}var u=KR||t._useStrictMode,g={},b=!1;let d={};for(var i in t){if(Yk[i])continue;var f=i.slice(0,2)==="on",j=a[i]!==t[i];if(f&&j){var c=i.substr(2).toLowerCase();if(c.substr(0,7)==="content")c="content"+c.substr(7,1).toUpperCase()+c.substr(8);if(t[i])d[c]=t[i]}if(!f&&(t[i]!==a[i]||u&&t[i]!==e.getAttr(i)))b=!0,g[i]=t[i]}if(b)e.setAttrs(g),of(e);for(var c in d)e.off(c+a2),e.on(c+a2,d[c])}function of(e){if(!ve.autoDrawEnabled){var t=e.getLayer()||e.getStage();t&&t.batchDraw()}}Lk();var Wk={},QR={};Do.Node.prototype._applyProps=xo;var Pk=t5;function ZR(e,t){if(typeof t==="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${t}`);return}e.add(t),of(e)}function $R(e,t,a){let n=Do[e];if(!n)console.error(`Konva has no node with the type ${e}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${e}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),n=Do.Group;let s={},i={};for(var f in t){if(f==="ref")continue;var l=f.slice(0,2)==="on";if(l)i[f]=t[f];else s[f]=t[f]}let c=new n(s);return xo(c,i),c}function WR(e,t,a){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${e}"`)}function PR(e,t,a){return!1}function eN(e){return e}function tN(){return null}function aN(){return null}function nN(e,t,a,n){return QR}function sN(){}function iN(e){}function fN(e,t){return!1}function lN(){return Wk}function rN(){return Wk}var oN=setTimeout,cN=clearTimeout,hN=!0,uN=typeof queueMicrotask==="function"?queueMicrotask:(e)=>Promise.resolve(null).then(e),mN=-1;function gN(e,t){return!1}var pN=!1,bN=!1,wN=!0,dN=!1,jN=!1;function qN(e,t){if(t.parent===e)t.moveToTop();else e.add(t);of(e)}function vN(e,t){if(t.parent===e)t.moveToTop();else e.add(t);of(e)}function eA(e,t,a){t._remove(),e.add(t),t.setZIndex(a.getZIndex()),of(e)}function kN(e,t,a){eA(e,t,a)}function AN(e,t){t.destroy(),t.off(a2),of(e)}function yN(e,t){t.destroy(),t.off(a2),of(e)}function SN(e,t,a){console.error(`Text components are not yet supported in ReactKonva. You text is: "${a}"`)}function CN(e,t,a){}function _N(e,t,a,n){xo(e,n,a)}function FN(e){e.hide(),of(e)}function ON(e){}function BN(e,t){if(t.visible==null||t.visible)e.show()}function TN(e,t){}function HN(e){}function MN(){}function DN(){return null}function xN(){}function RN(){}function NN(){return t5}function EN(){}function zN(){return null}function UN(e){Pk=e}function IN(){return Pk}function GN(){return n8}function XN(){return!1}function KN(){}function LN(){return null}function VN(){return-1.1}function YN(){}function JN(){return!1}function QN(){return!0}function ZN(){}function $N(){}function WN(){return null}var PN=null,eE=$k.default.createContext(null);function tE(){}var Ta=Mt(en(),1);function tA(e,t,a){if(!e)return;if(a(e)===!0)return e;let n=t?e.return:e.child;for(;n;){let s=tA(n,t,a);if(s)return s;n=t?null:n.sibling}}function aA(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch(t){return e}}var i8=aA(Ta.createContext(null));class a5 extends Ta.Component{render(){return Ta.createElement(i8.Provider,{value:this._reactInternals},this.props.children)}}function aE(){let e=Ta.useContext(i8);if(e===null)throw Error("its-fine: useFiber must be called within a <FiberProvider />!");let t=Ta.useId();return Ta.useMemo(()=>{for(let a of[e,e==null?void 0:e.alternate]){if(!a)continue;let n=tA(a,!1,(s)=>{let i=s.memoizedState;for(;i;){if(i.memoizedState===t)return!0;i=i.next}});if(n)return n}},[e,t])}var nE=Symbol.for("react.context"),sE=(e)=>e!==null&&typeof e=="object"&&("$$typeof"in e)&&e.$$typeof===nE;function iE(){let e=aE(),[t]=Ta.useState(()=>new Map);t.clear();let a=e;for(;a;){let n=a.type;sE(n)&&n!==i8&&!t.has(n)&&t.set(n,Ta.use(aA(n))),a=a.return}return t}function nA(){let e=iE();return Ta.useMemo(()=>Array.from(e.keys()).reduce((t,a)=>(n)=>Ta.createElement(t,null,Ta.createElement(a.Provider,{...n,value:e.get(a)})),(t)=>Ta.createElement(a5,{...t})),[e])}if(fn.default.version.indexOf("19")===-1)throw Error("react-konva version 19 is only compatible with React 19. Make sure to have the last version of react-konva and react or downgrade react-konva to version 18.");function fE(e){let t=fn.default.useRef({});return fn.default.useLayoutEffect(()=>{t.current=e}),fn.default.useLayoutEffect(()=>{return()=>{t.current={}}},[]),t.current}var lE=()=>{let e=fn.default.useRef(0);return fn.default.useMemo(()=>{e.current++},[]),e.current>1},rE=(e)=>{let t=fn.default.useRef(null),a=fn.default.useRef(null),n=fn.default.useRef(null),s=fE(e),i=nA(),f=fn.default.useRef(null),l=(u)=>{let{forwardedRef:g}=e;if(!g)return;if(typeof g==="function")g(u);else g.current=u},c=lE(),h=()=>{l(null),Ro.flushSyncFromReconciler(()=>{Ro.updateContainer(null,n.current,null)}),a.current?.destroy(),a.current=null};return fn.default.useLayoutEffect(()=>{if(f.current)clearTimeout(f.current),f.current=null;if(a.current)l(a.current);else a.current=new Do.Stage({width:e.width,height:e.height,container:t.current}),l(a.current),n.current=Ro.createContainer(a.current,a8,null,!1,null,"",console.error,console.error,console.error,null),Ro.updateContainer(fn.default.createElement(i,{},e.children),n.current,null,()=>{});return()=>{if(c)f.current=setTimeout(h,0);else h()}},[]),fn.default.useLayoutEffect(()=>{l(a.current),xo(a.current,e,s),Ro.updateContainer(fn.default.createElement(i,{},e.children),n.current,null),Ro.flushSyncWork()}),fn.default.createElement("div",{ref:t,id:e.id,accessKey:e.accessKey,className:e.className,role:e.role,style:e.style,tabIndex:e.tabIndex,title:e.title})},iA="Layer";var fA="Group";var f8="Rect";var l8="Line";var lA="Image";var r8="Arrow";var Ro=sA.default(s8),rA=fn.default.forwardRef((e,t)=>{return fn.default.createElement(a5,{},fn.default.createElement(rE,{...e,forwardedRef:t}))});var hA=Mt(cA(),1);var oE=({width:e,height:t,mediaDimensions:a,imageUrl:n,canvasElement:s,videoElement:i,annotations:f,scale:l,offset:c,onPan:h,onClick:u,className:g,isDrawing:b=!1,currentTool:d="arrow",currentColor:j="#ef4444",onAddAnnotation:A})=>{let[C]=hA.default(n||"","anonymous"),y=Vs.useRef(null),O=Vs.useRef(!1),T=Vs.useRef({x:0,y:0}),M=Vs.useRef(null),H=Vs.useRef(null),N=Vs.useRef(null),x=Vs.useRef(null);Vs.useEffect(()=>{if(s&&y.current)y.current.getLayer()?.batchDraw()},[s]),Vs.useEffect(()=>{if(i&&y.current){let te=y.current.getLayer();if(!te)return;let ee=new zk.Animation(()=>{},te);return ee.start(),()=>{ee.stop()}}},[i]);let z=(te,ee=!1,L)=>{let J=te.getAbsoluteTransform().copy();J.invert();let pe=L||te.getStage()?.getPointerPosition();if(pe){let ne=J.point(pe);if(ee)return{x:Math.max(0,Math.min(a.width,ne.x)),y:Math.max(0,Math.min(a.height,ne.y))};return ne}return null},K=Vs.useRef({isDrawing:b,currentTool:d,currentColor:j,onPan:h,offset:c,scale:l,mediaDimensions:a,onAddAnnotation:A});K.current={isDrawing:b,currentTool:d,currentColor:j,onPan:h,offset:c,scale:l,mediaDimensions:a,onAddAnnotation:A};let $=()=>{if(!O.current)return;O.current=!1;let{isDrawing:te,onAddAnnotation:ee,mediaDimensions:L,currentTool:J,currentColor:pe}=K.current;if(te&&ee){let{width:ne,height:fe}=L,Ae=(he,re)=>he/re;if(J==="freehand"&&H.current){H.current.visible(!1);let he=H.current.points(),re=[];for(let be=0;be<he.length;be+=2)re.push([Ae(he[be],ne),Ae(he[be+1],fe)]);if(re.length>1)ee({type:"freehand",color:pe,points:re})}else if(J==="line"&&H.current){H.current.visible(!1);let he=H.current.points(),re={type:"line",color:pe,points:[[Ae(he[0],ne),Ae(he[1],fe)],[Ae(he[2],ne),Ae(he[3],fe)]]};ee(re)}else if(J==="box"&&N.current){N.current.visible(!1);let he=N.current.x(),re=N.current.y(),be=N.current.width(),Ue=N.current.height(),at=[Ae(he,ne),Ae(re,fe)],Ye=[Ae(he+be,ne),Ae(re+Ue,fe)];ee({type:"box",color:pe,points:[at,Ye]})}else if(J==="arrow"&&x.current){x.current.visible(!1);let he=x.current.points(),re={type:"arrow",color:pe,points:[[Ae(he[0],ne),Ae(he[1],fe)],[Ae(he[2],ne),Ae(he[3],fe)]]};ee(re)}}};Vs.useEffect(()=>{let te=(L)=>{if(!O.current)return;let J=y.current?.getStage();if(!J)return;let ne=J.container().getBoundingClientRect(),fe,Ae;if("clientX"in L)fe=L.clientX,Ae=L.clientY;else fe=L.touches[0].clientX,Ae=L.touches[0].clientY;let he={x:fe-ne.left,y:Ae-ne.top};if("touches"in L&&L.touches.length>1){T.current=he;return}let{isDrawing:re,currentTool:be,onPan:Ue,offset:at}=K.current;if(re){if(be==="select")return;let Ye=z(y.current,!0,he);if(!Ye||!M.current)return;let Ie=M.current,mt=y.current?.getLayer();if(be==="freehand"&&H.current){let vt=H.current.points().concat([Ye.x,Ye.y]);H.current.points(vt)}else if(be==="line"&&H.current)H.current.points([Ie.x,Ie.y,Ye.x,Ye.y]);else if(be==="box"&&N.current)N.current.width(Ye.x-Ie.x),N.current.height(Ye.y-Ie.y);else if(be==="arrow"&&x.current)x.current.points([Ie.x,Ie.y,Ye.x,Ye.y]);mt?.batchDraw()}else{if(!Ue)return;let Ye=he.x-T.current.x,Ie=he.y-T.current.y;T.current=he,Ue({x:at.x+Ye,y:at.y+Ie})}},ee=(L)=>{if("touches"in L&&L.touches.length>0)return;$()};return window.addEventListener("mousemove",te),window.addEventListener("mouseup",ee),window.addEventListener("touchmove",te),window.addEventListener("touchend",ee),()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",ee),window.removeEventListener("touchmove",te),window.removeEventListener("touchend",ee)}},[]);let Q=(te)=>{if(b){if(d==="select")return;if(!te.target.getStage())return;let L=z(y.current);if(!L)return;if(L.x<0||L.x>a.width||L.y<0||L.y>a.height)return;O.current=!0,M.current=L;let J=y.current?.getLayer();if(!J)return;if(d==="freehand"&&H.current)H.current.points([L.x,L.y]),H.current.stroke(j),H.current.visible(!0);else if(d==="line"&&H.current)H.current.points([L.x,L.y,L.x,L.y]),H.current.stroke(j),H.current.visible(!0);else if(d==="box"&&N.current)N.current.position(L),N.current.width(0),N.current.height(0),N.current.stroke(j),N.current.visible(!0);else if(d==="arrow"&&x.current)x.current.points([L.x,L.y,L.x,L.y]),x.current.stroke(j),x.current.fill(j),x.current.visible(!0);J.batchDraw()}else{if(!h)return;O.current=!0;let ee=te.target.getStage();if(ee){let L=ee.getPointerPosition();if(L)T.current=L}}},P=(te,ee)=>{let{width:L,height:J}=a;switch(te.type){case"box":{let[pe,ne]=te.points,fe=Math.min(pe[0],ne[0])*L,Ae=Math.min(pe[1],ne[1])*J,he=Math.abs(ne[0]-pe[0])*L,re=Math.abs(ne[1]-pe[1])*J;return R(f8,{x:fe,y:Ae,width:he,height:re,stroke:te.color,strokeWidth:2.6/l,listening:!1},ee)}case"arrow":{let pe=te.points.flat().map((ne,fe)=>fe%2===0?ne*L:ne*J);return R(r8,{points:pe,stroke:te.color,strokeWidth:2.6/l,fill:te.color,pointerLength:10/l,pointerWidth:10/l,listening:!1},ee)}case"line":case"freehand":{let pe=te.points.flat().map((ne,fe)=>fe%2===0?ne*L:ne*J);return R(l8,{points:pe,stroke:te.color,strokeWidth:2.6/l,tension:0.5,lineCap:"round",lineJoin:"round",listening:!1},ee)}default:return null}};return R("div",{className:g,style:{width:e,height:t,overflow:"hidden",pointerEvents:!b&&!h?"none":"auto",cursor:b&&d!=="select"?"crosshair":h?O.current?"grabbing":"grab":"default"},children:R(rA,{width:e,height:t,scaleX:l,scaleY:l,x:c.x,y:c.y,onMouseDown:Q,onClick:!b?u:void 0,onTap:!b?u:void 0,onTouchStart:Q,children:ie(iA,{children:[R(lA,{ref:y,image:i||s||C,width:a.width,height:a.height}),f.map(P),ie(fA,{listening:!1,children:[R(l8,{ref:H,strokeWidth:2.6/l,lineCap:"round",lineJoin:"round",visible:!1}),R(f8,{ref:N,strokeWidth:2.6/l,visible:!1}),R(r8,{ref:x,points:[],strokeWidth:2.6/l,pointerLength:10/l,pointerWidth:10/l,visible:!1})]})]})})})},d0=oE;function ql(e,t,a,n){if(e<=0||t<=0||a<=0||n<=0)return 1;return Math.min(e/a,t/n)}function cf(e,t,a,n,s){return{x:(e-a*s)/2,y:(t-n*s)/2}}function n2(e,t,a=0.02){return e>t*(1+a)}function cE(e,t=0.01,a=50){return Math.min(a,Math.max(t,e))}function hf(e,t,a,n,s,i=0.01,f=50){let l=cE(e*a,i,f),c=l/e;return{zoom:l,pan:{x:n-(n-t.x)*c,y:s-(s-t.y)*c}}}function uA(e,t){let a=t===1?e*16:t===2?e*100:e,n=Math.exp(-a*0.01);return Math.min(2,Math.max(0.5,n))}var n5=Mt(en(),1);function No({containerRef:e,zoom:t,pan:a,baseScale:n,onZoomChange:s,onPanChange:i}){let f=n5.useRef({zoom:t,pan:a,baseScale:n,onZoomChange:s,onPanChange:i});f.current={zoom:t,pan:a,baseScale:n,onZoomChange:s,onPanChange:i},n5.useEffect(()=>{let l=e.current;if(!l)return;let c=new Map,h=null,u=(C)=>{let y=f.current;if(C.ctrlKey){C.preventDefault();let O=l.getBoundingClientRect(),T=C.clientX-O.left,M=C.clientY-O.top;y.onZoomChange(hf(y.zoom,y.pan,uA(C.deltaY,C.deltaMode),T,M));return}if(n2(y.zoom,y.baseScale))C.preventDefault(),y.onPanChange({x:y.pan.x-C.deltaX,y:y.pan.y-C.deltaY})},g=(C,y)=>Math.hypot(y.x-C.x,y.y-C.y),b=(C,y,O)=>({x:(C.x+y.x)/2-O.left,y:(C.y+y.y)/2-O.top}),d=(C)=>{for(let y of Array.from(C.touches))c.set(y.identifier,{x:y.clientX,y:y.clientY});if(c.size===2){C.preventDefault();let y=l.getBoundingClientRect(),[O,T]=Array.from(c.values());h={lastDist:g(O,T),lastMid:b(O,T,y)}}},j=(C)=>{for(let $ of Array.from(C.touches))c.set($.identifier,{x:$.clientX,y:$.clientY});if(!h||c.size<2)return;C.preventDefault();let y=l.getBoundingClientRect(),[O,T]=Array.from(c.values()),M=b(O,T,y),H=g(O,T),N=f.current,x=h.lastDist>0?H/h.lastDist:1,z=hf(N.zoom,N.pan,x,M.x,M.y),K=z.pan;if(n2(z.zoom,N.baseScale))K={x:K.x+(M.x-h.lastMid.x),y:K.y+(M.y-h.lastMid.y)};N.onZoomChange({zoom:z.zoom,pan:K}),h.lastDist=H,h.lastMid=M},A=(C)=>{for(let y of Array.from(C.changedTouches))c.delete(y.identifier);if(c.size<2)h=null};return l.addEventListener("wheel",u,{passive:!1}),l.addEventListener("touchstart",d,{passive:!1}),l.addEventListener("touchmove",j,{passive:!1}),l.addEventListener("touchend",A,{passive:!1}),l.addEventListener("touchcancel",A,{passive:!1}),()=>{l.removeEventListener("wheel",u),l.removeEventListener("touchstart",d),l.removeEventListener("touchmove",j),l.removeEventListener("touchend",A),l.removeEventListener("touchcancel",A)}},[e])}var hE=pt.default.forwardRef(({file:e,onPlay:t,onPause:a,onTimeUpdate:n,annotations:s,startTime:i,shareId:f,children:l,allowDownload:c},h)=>{let u=pt.useRef(null),g=u,b=(e.media?.videoTranscodes??[]).map((Se)=>{let Te=Math.max(Se.width,Se.height),Xe=`${Se.height}p`;if(Te>=3840)Xe="2160p";else if(Te>=1920)Xe="1080p";else if(Te>=1280)Xe="720p";else if(Te>=960)Xe="540p";else if(Te>=640)Xe="360p";else if(Te>=320)Xe="180p";return{...Se,resolution:Xe}}),d=b.length>0&&!!e.media?.metadata,j=pt.useRef(null),A=()=>{if(b.length===0)return null;if(typeof window>"u")return b[0];let Se=window.innerWidth*(window.devicePixelRatio||1),Te=[...b].sort((Le,Aa)=>{let ha=Le.width??0,$s=Aa.width??0;return ha-$s});return Te.find((Le)=>(Le.width??0)>=Se)||Te[Te.length-1]},C=A(),[y,O]=pt.useState({isPlaying:!1,progress:0,currentTime:0,duration:e.media?.metadata?.duration||0,volume:1,isMuted:!1,isLooping:!1,playbackRate:1,isFullScreen:!1,showFrames:!1,currentResolution:C?.resolution??"",currentSrc:C?.url??""}),T=pt.useRef(null),M=pt.useRef(null),H=pt.useRef(null);pt.useImperativeHandle(h,()=>({play:()=>{if(u.current)u.current.play()},pause:()=>{if(u.current)u.current.pause()},seekTo:(Se)=>{if(u.current)u.current.currentTime(Se)},getCurrentTime:()=>{return(u.current?u.current.currentTime():0)??0},getDuration:()=>{return(u.current?u.current.duration():0)??0}}));let N=pt.useRef(!1),[x,z]=pt.useState(void 0),K=pt.useRef(null),[$,Q]=pt.useState(1),[P,te]=pt.useState({x:0,y:0}),[ee,L]=pt.useState(!1),[J,pe]=pt.useState({width:0,height:0});pt.useEffect(()=>{let Se=A();O((Te)=>({...Te,isPlaying:!1,progress:0,currentTime:0,duration:e.media?.metadata?.duration||0,currentResolution:Se?.resolution??"",currentSrc:Se?.url??""})),L(!1),jt(!1),ga(0),xe.current=null},[e.id]);let ne=e.media?.metadata?.originalWidth||1920,fe=e.media?.metadata?.originalHeight||1080,Ae=ql(J.width,J.height,ne,fe),he=(Se)=>{L(!0);let Te=hf($,P,Se/$,J.width/2,J.height/2);Q(Te.zoom),te(Te.pan)},re=()=>{if(L(!1),J.width>0&&J.height>0){let Se=ql(J.width,J.height,ne,fe);Q(Se),te(cf(J.width,J.height,ne,fe,Se))}},{isDrawing:be,currentTool:Ue,currentColor:at,addAnnotation:Ye,annotations:Ie}=bs(),mt=[...s||[],...Ie];pt.useEffect(()=>{if(!T.current)return;let Se=new ResizeObserver((Te)=>{let Xe=Te[0];if(Xe)pe({width:Xe.contentRect.width,height:Xe.contentRect.height})});return Se.observe(T.current),()=>Se.disconnect()},[]),pt.useEffect(()=>{if(J.width<=0||J.height<=0)return;if(ee)return;let Se=ql(J.width,J.height,ne,fe);Q(Se),te(cf(J.width,J.height,ne,fe,Se))},[J.width,J.height,ne,fe,ee]),No({containerRef:T,zoom:$,pan:P,baseScale:Ae,onZoomChange:(Se)=>{L(!0),Q(Se.zoom),te(Se.pan)},onPanChange:te}),pt.useEffect(()=>{return()=>{K.current=null}},[]);let[vt,ga]=pt.useState(0),[Dt,ta]=pt.useState(!0),[rn,jt]=pt.useState(!1),xe=pt.useRef(null),ze=e.media?.metadata,Qe=ze?.frameRate||30,nt=ze?.totalFrames||0,Ot=ze?.duration||0,Ze=e.proxyType==="audio",Yt=i5({dbTotalFrames:nt,containerDuration:Ot,frameRate:Qe}),{currentFrame:wt,seekToFrame:yn}=_m(K,Qe,Yt,Ze),zn=wt/Qe,Ya=Yt/Qe,Ja=Ya>0?zn/Ya*100:0,Sn={...y,currentTime:zn,duration:Ya,progress:Ja};pt.useEffect(()=>{if(n)n(wt/Qe)},[wt,Qe,n]),pt.useEffect(()=>{if(!j.current)return;let Te=A()?.url??"";if(!Te)return;if(g.current&&!g.current.isDisposed())g.current.dispose(),g.current=null,K.current=null;let Xe=document.createElement("video-js");Xe.classList.add("vjs-big-play-centered","!h-full","!w-full"),Xe.style.opacity="0",Xe.style.pointerEvents="none",j.current.appendChild(Xe);let Le=g.current=se(Xe,{controls:!1,autoplay:!1,preload:"auto",playsinline:!0,sources:[{src:Te,type:"video/mp4"}]}),Aa=Xe.querySelector("video");if(Aa)z(Aa),K.current=Aa;else Le.ready(()=>{let ha=Le.tech({iWillNotUseThisInPlugins:!0})?.el();if(ha)z(ha),K.current=ha});return Le.on("play",()=>{O((ha)=>({...ha,isPlaying:!0})),t?.()}),Le.on("pause",()=>{O((ha)=>({...ha,isPlaying:!1})),a?.()}),Le.on("ended",()=>O((ha)=>({...ha,isPlaying:!1}))),Le.on("loadedmetadata",()=>{jt(!0)}),Le.on("loadstart",()=>{jt(!1)}),Le.on("timeupdate",()=>{let ha=Le.duration()||e.media?.metadata?.duration||0,$s=Le.bufferedEnd();if(ha>0)ga($s/ha*100)}),Le.on("volumechange",()=>{let ha=Le.volume(),$s=Le.muted();O((S0)=>({...S0,volume:ha||0,isMuted:$s||!1}))}),Le.on("ratechange",()=>{O((ha)=>({...ha,playbackRate:Le.playbackRate()||1}))}),Le.on("error",()=>{console.error("VideoJS Error:",Le.error())}),Le.volume(y.volume),()=>{if(Le&&!Le.isDisposed())Le.dispose(),g.current=null,K.current=null}},[e.id]),pt.useEffect(()=>{if(!rn)return;if(i!==void 0&&i!==null&&i>0){if(i!==xe.current){xe.current=i;let Se=Math.floor(i*Qe+0.45);yn(Se)}}},[i,Qe,yn,rn]);let pa=pt.useCallback(()=>{if(H.current)clearTimeout(H.current);if(y.isFullScreen&&!N.current)H.current=setTimeout(()=>{ta(!1)},1200)},[y.isFullScreen]),Da=pt.useCallback(()=>{ta(!0),pa()},[pa]),Os=pt.useCallback(()=>{if(N.current=!0,H.current)clearTimeout(H.current);ta(!0)},[]),ls=pt.useCallback(()=>{N.current=!1,pa()},[pa]),Bt=pt.useCallback(()=>{if(y.isFullScreen){if(H.current)clearTimeout(H.current);ta(!1)}},[y.isFullScreen]);pt.useEffect(()=>{return()=>{if(H.current)clearTimeout(H.current)}},[]),pt.useEffect(()=>{if(!y.isFullScreen){if(ta(!0),H.current)clearTimeout(H.current)}else Da()},[y.isPlaying,y.isFullScreen,Da]);let de=pt.useCallback(()=>{if(bs.getState().isDrawing)return;let Se=g.current;if(!Se)return;if(Se.paused()||Se.ended()){let Te=Se.play();if(Te!==void 0)Te.catch((Xe)=>{if(Xe.name==="AbortError")return;console.error("Play failed:",Xe)})}else Se.pause()},[]);pt.useEffect(()=>{let Se=(Te)=>{let Xe=document.activeElement;if(Xe&&(Xe.tagName==="INPUT"||Xe.tagName==="TEXTAREA"||Xe instanceof HTMLElement&&Xe.isContentEditable))return;let Le=Te.key===" ",Aa=Xe&&(Xe.tagName==="BUTTON"||Xe.tagName==="A"||Xe.tagName==="SELECT"||Xe.tagName==="OPTION"||Xe.getAttribute("role")==="button"||Xe.getAttribute("role")==="link"||Xe.getAttribute("role")==="checkbox"||Xe.getAttribute("role")==="radio"||Xe.getAttribute("role")==="menuitem");if(Le&&Aa)return;if(Te.key===" "||Te.key.toLowerCase()==="k")Te.preventDefault(),de()};return window.addEventListener("keydown",Se),()=>{window.removeEventListener("keydown",Se)}},[de]);let $e=()=>{let Se=g.current;if(!Se)return;let Te=!y.isLooping;Se.loop(Te),O((Xe)=>({...Xe,isLooping:Te}))},Je=(Se)=>{O((Xe)=>({...Xe,volume:Se,isMuted:Se===0}));let Te=g.current;if(!Te)return;if(Te.volume(Se),Se>0&&Te.muted())Te.muted(!1);else if(Se===0&&!Te.muted())Te.muted(!0)},xt=()=>{let Se=g.current;if(!Se)return;if(Se.muted()){if(Se.muted(!1),Se.volume()===0)Se.volume(0.5)}else Se.muted(!0)},ka=(Se)=>{let Te=g.current;if(!Te)return;Te.playbackRate(Se)},ia=(Se)=>{let Te=g.current;if(!Te)return;let Xe=!Te.paused(),Le=Te.currentTime();O((Aa)=>({...Aa,currentResolution:Se.resolution,currentSrc:Se.url})),Te.src({type:"video/mp4",src:Se.url}),Te.one("loadedmetadata",()=>{if(Te.currentTime(Le),Xe){let Aa=Te.play();if(Aa!==void 0)Aa.catch((ha)=>{if(ha.name==="AbortError")return;console.error("Play after seek failed:",ha)})}Te.playbackRate(y.playbackRate)})},Me=()=>{let Se=M.current,Te=x||K.current;if(Se&&typeof Se.requestFullscreen==="function"){if(!document.fullscreenElement)Se.requestFullscreen().catch(()=>{}),O((Le)=>({...Le,isFullScreen:!0}));else if(document.exitFullscreen)document.exitFullscreen().catch(()=>{}),O((Le)=>({...Le,isFullScreen:!1}));return}let Xe=Te;if(Xe&&typeof Xe.webkitEnterFullscreen==="function"){if(!Xe.webkitDisplayingFullscreen)try{Xe.webkitEnterFullscreen()}catch(Le){console.error("Failed to enter iOS fullscreen:",Le)}else if(typeof Xe.webkitExitFullscreen==="function")try{Xe.webkitExitFullscreen()}catch(Le){console.error("Failed to exit iOS fullscreen:",Le)}return}O((Le)=>({...Le,isFullScreen:!Le.isFullScreen}))},Re=async(Se)=>{try{let Te=f?await Ht.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:f,fileId:e.id},json:{key:Se}}):await Ht.api.files["download-url"].$post({json:{key:Se,assetId:e.id}});if(!Te.ok)return;let{url:Xe}=await Te.json(),Le=document.createElement("a");Le.href=Xe,Le.download="",document.body.appendChild(Le),Le.click(),document.body.removeChild(Le)}catch{}};pt.useEffect(()=>{let Se=()=>{O((Aa)=>({...Aa,isFullScreen:!!document.fullscreenElement}))};document.addEventListener("fullscreenchange",Se);let Te=x||K.current,Xe=()=>{O((Aa)=>({...Aa,isFullScreen:!0}))},Le=()=>{O((Aa)=>({...Aa,isFullScreen:!1}))};if(Te)Te.addEventListener("webkitbeginfullscreen",Xe),Te.addEventListener("webkitendfullscreen",Le);return()=>{if(document.removeEventListener("fullscreenchange",Se),Te)Te.removeEventListener("webkitbeginfullscreen",Xe),Te.removeEventListener("webkitendfullscreen",Le)}},[x]);let zt=$,Ua=mA();if(!d)return R("div",{className:"flex h-full w-full items-center justify-center",children:R("p",{className:"text-muted-foreground",children:"Media is not available."})});return ie("div",{ref:M,className:vn("group shadow-2xl font-sans select-none flex flex-col mx-auto relative",y.isFullScreen?"h-full w-full rounded-none bg-black":"w-full h-full",!Dt&&y.isFullScreen?"cursor-none":""),onMouseMove:Da,onMouseLeave:Bt,children:[ie("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[!y.isFullScreen&&l,ie("div",{ref:T,className:vn("flex-1 bg-black cursor-pointer relative flex items-center justify-center overflow-hidden min-h-0 touch-none"),onClick:de,"data-vjs-player":!0,"data-testid":"video-area",children:[R("div",{ref:j,className:"absolute inset-0 z-[-1]"}),Ze?R("div",{className:"flex flex-col items-center justify-center text-muted-foreground w-full h-full pointer-events-none select-none",children:R(s5,{className:vn("w-16 h-16 text-foreground/75 transition-transform duration-500",y.isPlaying?"animate-pulse scale-110 text-primary":"")})}):x&&J.width>0&&R(d0,{width:J.width,height:J.height,mediaDimensions:{width:ne,height:fe},videoElement:x,annotations:mt,scale:zt,offset:P,className:"absolute inset-0",isDrawing:be,currentTool:Ue,currentColor:at,onAddAnnotation:Ye}),!y.isPlaying&&!be&&R("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20 pointer-events-none z-10",children:R("div",{className:"w-20 h-20 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center border-2 border-white/30 animate-pulse",children:R(ml,{className:"w-10 h-10 text-white ml-1 fill-white"})})})]})]}),Ua?R(bv,{state:Sn,zoom:$,isControlsVisible:Dt,buffered:vt,data:e,resolutions:b,togglePlay:de,toggleLoop:$e,toggleMute:xt,handleVolumeChange:Je,changePlaybackRate:ka,changeResolution:ia,handleDownload:Re,toggleFullScreen:Me,onZoomChange:he,onZoomReset:re,frameRate:Qe,totalFrames:Yt,currentFrame:wt,seekToFrame:yn,onMouseEnter:Os,onMouseLeave:ls,allowDownload:c}):R(pv,{state:Sn,zoom:$,isControlsVisible:Dt,buffered:vt,data:e,resolutions:b,togglePlay:de,toggleLoop:$e,toggleMute:xt,handleVolumeChange:Je,changePlaybackRate:ka,changeResolution:ia,handleDownload:Re,toggleFullScreen:Me,onZoomChange:he,onZoomReset:re,frameRate:Qe,totalFrames:Yt,currentFrame:wt,seekToFrame:yn,onMouseEnter:Os,onMouseLeave:ls,allowDownload:c})]})}),gA=hE;var dt=Mt(en(),1);function uE(e){return(e.media?.videoTranscodes??[]).map((t)=>{let a=Math.max(t.width,t.height),n=`${t.height}p`;if(a>=3840)n="2160p";else if(a>=1920)n="1080p";else if(a>=1280)n="720p";else if(a>=960)n="540p";else if(a>=640)n="360p";else if(a>=320)n="180p";return{...t,resolution:n}})}var pA=dt.forwardRef(function({file:t,shareId:a,isActive:n,muted:s=!0,volume:i=1,annotations:f,onStateChange:l,onActivate:c,onRequestTogglePlay:h,onTimeUpdate:u,onPlay:g},b){let d=dt.useRef(null),j=dt.useRef(null),A=dt.useRef(null),C=dt.useRef(null),[y,O]=dt.useState(void 0),{isDrawing:T,currentTool:M,currentColor:H,addAnnotation:N,annotations:x}=bs(),[z,K]=dt.useState({width:0,height:0}),[$,Q]=dt.useState(1),[P,te]=dt.useState(!1),[ee,L]=dt.useState(null),[J,pe]=dt.useState(!1),[ne,fe]=dt.useState(!1),[Ae,he]=dt.useState(1),[re,be]=dt.useState(0),[Ue,at]=dt.useState(i),[Ye,Ie]=dt.useState(s),[mt,vt]=dt.useState(!1),ga=t.media?.metadata,Dt=ga?.frameRate||30,ta=ga?.totalFrames||0,rn=ga?.duration||0,jt=i5({dbTotalFrames:ta,containerDuration:rn,frameRate:Dt}),xe=uE(t),ze=xe[0],[Qe,nt]=dt.useState(ze?.resolution??""),Ot=dt.useRef(ze?.url),Ze=t.proxyType==="audio",{currentFrame:Yt,seekToFrame:wt}=_m(C,Dt,jt,Ze),yn=dt.useRef($);yn.current=$;let zn=dt.useRef(Yt);zn.current=Yt,dt.useEffect(()=>{if(!A.current)return;let Me=new ResizeObserver((Re)=>{let zt=Re[0];if(zt)K({width:zt.contentRect.width,height:zt.contentRect.height})});return Me.observe(A.current),()=>Me.disconnect()},[]);let Ya=ga?.originalWidth||1920,Ja=ga?.originalHeight||1080;dt.useEffect(()=>{if(z.width>0&&z.height>0&&!P){let Me=Math.min(z.width/Ya,z.height/Ja);Q(Me)}},[z.width,z.height,Ya,Ja,P]),dt.useEffect(()=>{nt(ze?.resolution??""),Ot.current=ze?.url},[t.id]),dt.useEffect(()=>{if(!j.current)return;let Me=document.createElement("video-js");Me.classList.add("vjs-big-play-centered","!h-full","!w-full"),Me.style.opacity="0",Me.style.pointerEvents="none",j.current.appendChild(Me);let Re=d.current=se(Me,{controls:!1,autoplay:!1,preload:"auto",playsinline:!0,sources:[{src:Ot.current??"",type:"video/mp4"}]}),zt=Me.querySelector("video");if(zt)O(zt),C.current=zt;else Re.ready(()=>{let Ua=Re.tech({iWillNotUseThisInPlugins:!0})?.el();if(Ua)O(Ua),C.current=Ua});return Re.on("play",()=>{pe(!0),g?.()}),Re.on("pause",()=>pe(!1)),Re.on("ended",()=>pe(!1)),Re.on("loadedmetadata",()=>vt(!0)),Re.on("loadstart",()=>vt(!1)),Re.on("timeupdate",()=>{let Ua=Re.duration()||rn||0,Se=Re.bufferedEnd();if(Ua>0)be(Se/Ua*100)}),Re.on("volumechange",()=>{at(Re.volume()||0),Ie(Re.muted()||!1)}),Re.on("ratechange",()=>he(Re.playbackRate()||1)),()=>{if(Re&&!Re.isDisposed())Re.dispose(),d.current=null,C.current=null}},[t.id]),dt.useEffect(()=>{let Me=d.current;if(!Me||!mt)return;Me.muted(s),Me.volume(i)},[s,i,mt]),dt.useEffect(()=>{l({kind:"video",zoom:$,video:{frameRate:Dt,totalFrames:jt,currentFrame:Yt,isPlaying:J,volume:Ue,isMuted:Ye,playbackRate:Ae,isLooping:ne,currentResolution:Qe,resolutions:xe,buffered:re}})},[$,Dt,jt,Yt,J,Ue,Ye,Ae,ne,Qe,re]),dt.useEffect(()=>{if(n)u?.(Yt/Dt)},[Yt,Dt,n,u]);let Sn=dt.useCallback((Me)=>{let zt=yn.current*Me;if(zt<0.01||zt>50)return;Q(zt),te(!0)},[]),pa=dt.useCallback(()=>{te(!1),L(null)},[]),Da=dt.useCallback((Me)=>zp(Me,jt),[jt]),Os=dt.useCallback(async(Me)=>{let Re=Me??t.media?.original?.key;if(!Re||!t.id)return;try{let zt=a?await Ht.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:t.id},json:{key:Re}}):await Ht.api.files["download-url"].$post({json:{key:Re,assetId:t.id}});if(!zt.ok)return;let{url:Ua}=await zt.json(),Se=document.createElement("a");Se.href=Ua,Se.download="",document.body.appendChild(Se),Se.click(),document.body.removeChild(Se)}catch{}},[t.id,t.media?.original?.key,a]),ls=dt.useCallback((Me)=>{let Re=d.current;if(!Re)return;let zt=xe.find((Te)=>Te.resolution===Me);if(!zt)return;let Ua=!Re.paused(),Se=Re.currentTime();nt(Me),Ot.current=zt.url,Re.src({type:"video/mp4",src:zt.url}),Re.one("loadedmetadata",()=>{if(Re.currentTime(Se),Ua){let Te=Re.play();if(Te!==void 0)Te.catch(()=>{})}})},[xe]);dt.useImperativeHandle(b,()=>({getKind:()=>"video",play:()=>{let Me=d.current?.play();if(Me!==void 0)Me.catch(()=>{})},pause:()=>d.current?.pause(),togglePlay:()=>{let Me=d.current;if(!Me)return;if(Me.paused()||Me.ended()){let Re=Me.play();if(Re!==void 0)Re.catch(()=>{})}else Me.pause()},seekToFrame:(Me)=>wt(Da(Me)),seekToSecond:(Me)=>{let Re=Math.floor(Me*Dt+0.45);wt(Da(Re))},stepFrame:(Me)=>wt(Da(zn.current+Me)),setMuted:(Me)=>d.current?.muted(Me),setVolume:(Me)=>{let Re=d.current;if(!Re)return;if(Re.volume(Me),Me>0&&Re.muted())Re.muted(!1);else if(Me===0&&!Re.muted())Re.muted(!0)},setPlaybackRate:(Me)=>d.current?.playbackRate(Me),toggleLoop:()=>{let Me=d.current;if(!Me)return;let Re=!Me.loop();Me.loop(Re),fe(Re)},changeResolution:ls,zoomBy:Sn,fit:pa,panBy:(Me,Re)=>L((zt)=>{let Ua=yn.current,Se=zt??{x:(z.width-Ya*Ua)/2,y:(z.height-Ja*Ua)/2};return{x:Se.x+Me,y:Se.y+Re}}),download:(Me)=>Os(Me)}),[wt,Da,Dt,Sn,pa,ls,Os,z.width,z.height,Ya,Ja]);let Bt=[...f,...n?x:[]],de=$,$e=(z.width-Ya*de)/2,Je=(z.height-Ja*de)/2,xt=ee?.x??$e,ka=ee?.y??Je,ia=dt.useCallback(()=>{if(bs.getState().isDrawing)return;if(!n){c?.();return}h?.()},[n,c,h]);if(!t.media?.metadata||xe.length===0)return R("div",{className:"flex h-full w-full items-center justify-center bg-black",children:R("p",{className:"text-muted-foreground",children:"Media is not available."})});return ie("div",{ref:A,className:vn("relative flex flex-1 cursor-pointer items-center justify-center overflow-hidden bg-black"),onClick:ia,"data-testid":"compare-video-area",children:[R("div",{ref:j,className:"absolute inset-0 z-[-1]"}),Ze?R("div",{className:"flex flex-col items-center justify-center text-muted-foreground w-full h-full pointer-events-none select-none",children:R(s5,{className:vn("w-16 h-16 text-foreground/75 transition-transform duration-500",J?"animate-pulse scale-110 text-primary":"")})}):y&&z.width>0&&R(d0,{width:z.width,height:z.height,mediaDimensions:{width:Ya,height:Ja},videoElement:y,annotations:Bt,scale:de,offset:{x:xt,y:ka},className:"absolute inset-0",onClick:ia,isDrawing:n&&T,currentTool:M,currentColor:H,onAddAnnotation:n?N:void 0}),!J&&!T&&R("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/20",children:R("div",{className:"flex h-16 w-16 items-center justify-center rounded-full border-2 border-white/30 bg-white/10 backdrop-blur-sm",children:R(ml,{className:"ml-1 h-8 w-8 fill-white text-white"})})})]})});var bA={id:"video",name:"Video",match:(e)=>e.proxyType==="video"||e.proxyType==="audio",viewer:gA,comparePane:pA,commentsConfig:{hasTimestamp:!0,hasAnnotations:!0}};var f5=Mt(en(),1);function l5(){let[e,t]=f5.useState({width:window.innerWidth,height:window.innerHeight});return f5.useLayoutEffect(()=>{function a(){t({width:window.innerWidth,height:window.innerHeight})}return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),e}var Yn=Mt(en(),1);function dA({zoom:e,onZoomIn:t,onZoomOut:a,onFit:n,onDownload:s,canDownload:i,onCopy:f,copied:l=!1,canCopy:c=!0,allowDownload:h=!0,fullscreen:u}){return ie("div",{className:"relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-end gap-2 transition-colors duration-200",children:[ie("div",{className:"flex items-center gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5 mr-auto",children:[R("button",{onClick:a,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:He.zoom_out(),children:R(Wf,{size:16})}),ie("span",{className:"w-12 text-center text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none",children:[Math.round(e*100),"%"]}),R("button",{onClick:t,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:He.zoom_in(),children:R(So,{size:16})})]}),R("button",{onClick:n,className:"text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent animate-in fade-in zoom-in-95 duration-200",children:He.fit()}),f&&ie("button",{onClick:f,disabled:!c,className:"flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50 animate-in fade-in zoom-in-95 duration-200",title:He.copy_image_to_clipboard(),children:[l?R(pi,{size:14,className:"text-green-500"}):R(wA,{size:14}),l?He.copied():He.copy()]}),h&&ie("button",{onClick:s,disabled:!i,className:"flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50 animate-in fade-in zoom-in-95 duration-200",title:He.download_original_image(),children:[R(Bi,{size:14}),He.download()]}),u&&R("button",{onClick:u.onToggle,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:He.fullscreen(),children:u.isFullScreen?R(yo,{size:16}):R(Ao,{size:16})})]})}var mE=Yn.default.forwardRef(({file:e,annotations:t,shareId:a,children:n,allowDownload:s},i)=>{Yn.useImperativeHandle(i,()=>({play:()=>{},pause:()=>{},seekTo:()=>{}}));let{width:f}=l5(),{isDrawing:l,currentTool:c,currentColor:h,addAnnotation:u,annotations:g}=bs(),[b,d]=Yn.useState({width:0,height:0}),[j,A]=Yn.useState(1),[C,y]=Yn.useState({x:0,y:0}),[O,T]=Yn.useState(!1),[M,H]=Yn.useState(!1),N=Yn.useRef(null);Yn.useEffect(()=>{T(!1),H(!1)},[e.id]),Yn.useEffect(()=>{let ne=N.current;if(!ne)return;let fe=new ResizeObserver((Ae)=>{let he=Ae[0];if(he)d({width:he.contentRect.width,height:he.contentRect.height})});return fe.observe(ne),()=>fe.disconnect()},[]);let x=e.media?.metadata?.originalWidth??1920,z=e.media?.metadata?.originalHeight??1080,K=b.width,$=b.height,Q=ql(K,$,x,z);Yn.useEffect(()=>{if(K<=0||$<=0)return;if(O)return;A(Q),y(cf(K,$,x,z,Q))},[K,$,Q,x,z,O]);let P=(ne)=>{T(!0);let fe=hf(j,C,ne,K/2,$/2);A(fe.zoom),y(fe.pan)},te=()=>{T(!1),A(Q),y(cf(K,$,x,z,Q))};No({containerRef:N,zoom:j,pan:C,baseScale:Q,onZoomChange:(ne)=>{T(!0),A(ne.zoom),y(ne.pan)},onPanChange:y});let ee=r5(e.media?.imageTranscodes,f)?.url??"",L=async()=>{let ne=e.media?.original?.key;if(!ne||!e.id)return;try{let fe=a?await Ht.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:e.id},json:{key:ne}}):await Ht.api.files["download-url"].$post({json:{key:ne,assetId:e.id}});if(!fe.ok)return;let{url:Ae}=await fe.json(),he=document.createElement("a");he.href=Ae,he.download="",document.body.appendChild(he),he.click(),document.body.removeChild(he)}catch{}},J=async()=>{let ne=ee;if(!ne)return;try{let fe=(async()=>{let he=await(await fetch(ne)).blob(),re=new Image;re.crossOrigin="anonymous";let be=URL.createObjectURL(he);re.src=be;try{await new Promise((Ie,mt)=>{re.onload=Ie,re.onerror=(vt)=>mt(Error("Failed to load image: "+String(vt)))});let Ue=document.createElement("canvas");Ue.width=re.width,Ue.height=re.height;let at=Ue.getContext("2d");if(!at)throw Error("Could not get canvas context");at.drawImage(re,0,0);let Ye=await new Promise((Ie)=>{Ue.toBlob(Ie,"image/png")});if(!Ye)throw Error("Failed to convert image to PNG");return Ye}finally{URL.revokeObjectURL(be)}})();await navigator.clipboard.write([new ClipboardItem({"image/png":fe})]),H(!0),setTimeout(()=>H(!1),2000)}catch(fe){console.error("Failed to copy image to clipboard:",fe)}},pe=[...t||[],...g];return ie("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[ie("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[n,R("div",{ref:N,className:"flex-1 relative overflow-hidden touch-none",children:ee?R(d0,{width:K,height:$,mediaDimensions:{width:x,height:z},imageUrl:ee,annotations:pe,scale:j,offset:C,onPan:n2(j,Q)?y:void 0,className:"absolute inset-0 z-0",isDrawing:l,currentTool:c,currentColor:h,onAddAnnotation:u}):R("div",{className:"flex h-full w-full items-center justify-center",children:R("p",{className:"text-muted-foreground",children:"Preview unavailable"})})})]}),R(dA,{zoom:j,onZoomIn:()=>P(1.2),onZoomOut:()=>P(0.8),onFit:te,onDownload:L,canDownload:!!e.media?.original?.key,onCopy:J,copied:M,canCopy:!!ee,allowDownload:s})]})}),jA=mE;var La=Mt(en(),1);var gE=0.01,pE=50,qA=La.forwardRef(function({file:t,shareId:a,isActive:n,annotations:s,onStateChange:i,onUserPan:f,onActivate:l},c){let{width:h}=l5(),{isDrawing:u,currentTool:g,currentColor:b,addAnnotation:d,annotations:j}=bs(),[A,C]=La.useState({width:0,height:0}),[y,O]=La.useState(1),[T,M]=La.useState({x:0,y:0}),H=La.useRef(null),N=La.useRef(y);N.current=y;let x=La.useRef(T);x.current=T;let z=La.useCallback((Ae)=>{if(H.current)H.current.disconnect(),H.current=null;if(Ae!==null){let he=new ResizeObserver((re)=>{let be=re[0];if(be)C({width:be.contentRect.width,height:be.contentRect.height})});he.observe(Ae),H.current=he}},[]),K=t.media?.metadata?.originalWidth??1920,$=t.media?.metadata?.originalHeight??1080,Q=A.width,P=A.height,te=1;if(Q>0&&P>0)te=Math.min(Q/K,P/$);La.useEffect(()=>{if(Q>0&&P>0)O(te),M({x:(Q-K*te)/2,y:(P-$*te)/2})},[t.id,Q,P,te,K,$]);let ee=La.useCallback((Ae)=>{let he=Q/2,re=P/2,be=N.current,Ue=be*Ae;if(Ue<gE||Ue>pE)return;let at=x.current;M({x:he-(he-at.x)*(Ue/be),y:re-(re-at.y)*(Ue/be)}),O(Ue)},[Q,P]),L=La.useCallback(()=>{O(te),M({x:(Q-K*te)/2,y:(P-$*te)/2})},[te,Q,P,K,$]),J=r5(t.media?.imageTranscodes,h)?.url??"",pe=La.useCallback(async()=>{let Ae=t.media?.original?.key;if(!Ae||!t.id)return;try{let he=a?await Ht.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:t.id},json:{key:Ae}}):await Ht.api.files["download-url"].$post({json:{key:Ae,assetId:t.id}});if(!he.ok)return;let{url:re}=await he.json(),be=document.createElement("a");be.href=re,be.download="",document.body.appendChild(be),be.click(),document.body.removeChild(be)}catch{}},[t.id,t.media?.original?.key,a]);La.useImperativeHandle(c,()=>({getKind:()=>"image",play:()=>{},pause:()=>{},togglePlay:()=>{},seekToFrame:()=>{},seekToSecond:()=>{},stepFrame:()=>{},setMuted:()=>{},setVolume:()=>{},setPlaybackRate:()=>{},toggleLoop:()=>{},changeResolution:()=>{},zoomBy:(Ae)=>ee(Ae),fit:L,panBy:(Ae,he)=>M((re)=>({x:re.x+Ae,y:re.y+he})),download:pe}),[ee,L,pe]),La.useEffect(()=>{i({kind:"image",zoom:y})},[y,i]);let ne=[...s,...n?j:[]],fe=La.useCallback((Ae)=>{let he=x.current,re=Ae.x-he.x,be=Ae.y-he.y;if(M(Ae),re!==0||be!==0)f?.(re,be)},[f]);if(!J)return R("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:R("p",{className:"text-muted-foreground",children:"Preview unavailable"})});return R("div",{ref:z,className:"relative flex-1 overflow-hidden bg-black",onMouseDown:l,children:R(d0,{width:Q,height:P,mediaDimensions:{width:K,height:$},imageUrl:J,annotations:ne,scale:y,offset:T,onPan:fe,className:"absolute inset-0 z-0",isDrawing:n&&u,currentTool:g,currentColor:b,onAddAnnotation:n?d:void 0})})});var vA={id:"image",name:"Image",match:(e)=>e.proxyType==="image",viewer:jA,comparePane:qA,commentsConfig:{hasTimestamp:!1,hasAnnotations:!0}};var Js=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),mf=[1/0,1/0,-1/0,-1/0],Er=new Float32Array(mf),g8=[0.001,0,0,0.001,0,0];var Ys={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},kl={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};var rt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},bt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},bE={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};var ln={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},w5={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},za={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27};var zo={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var T5={ERRORS:0,WARNINGS:1,INFOS:5},k0={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},s2={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},wE={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},H5=T5.WARNINGS;function dE(e){if(Number.isInteger(e))H5=e}function jE(){return H5}function M5(e){if(H5>=T5.INFOS)console.info(`Info: ${e}`)}function ot(e){if(H5>=T5.WARNINGS)console.warn(`Warning: ${e}`)}function Et(e){throw Error(e)}function Ma(e,t){if(!e)Et(t)}function qE(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function VA(e,t=null,a=null){if(!e)return null;if(a&&typeof e==="string"){if(a.addDefaultProtocol&&e.startsWith("www.")){if(e.match(/\./g)?.length>=2)e=`http://${e}`}if(a.tryConvertEncoding)try{e=kE(e)}catch{}}let n=t?URL.parse(e,t):URL.parse(e);return qE(n)?n:null}function YA(e,t,a=!1){let n=URL.parse(e);if(n)return n.hash=t,n.href;if(a&&VA(e,"http://example.com"))return e.split("#",1)[0]+`${t?`#${t}`:""}`;return""}function p8(e){return e.substring(e.lastIndexOf("/")+1)}function ft(e,t,a,n=!1){return Object.defineProperty(e,t,{value:a,enumerable:!n,configurable:!0,writable:!1}),a}var Xr=function(){function t(a,n){this.message=a,this.name=n}return t.prototype=Error(),t.constructor=t,t}();class v5 extends Xr{constructor(e,t){super(e,"PasswordException");this.code=t}}class d5 extends Xr{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class k5 extends Xr{constructor(e){super(e,"InvalidPDFException")}}class h2 extends Xr{constructor(e,t,a){super(e,"ResponseException");this.status=t,this.missing=a}}class JA extends Xr{constructor(e){super(e,"FormatError")}}class pf extends Xr{constructor(e){super(e,"AbortException")}}function vE(e){if(typeof e!=="object"||e?.length===void 0)Et("Invalid argument for bytesToString");let t=e.length,a=8192;if(t<a)return String.fromCharCode.apply(null,e);let n=[];for(let s=0;s<t;s+=a){let i=Math.min(s+a,t),f=e.subarray(s,i);n.push(String.fromCharCode.apply(null,f))}return n.join("")}function D5(e){if(typeof e!=="string")Et("Invalid argument for stringToBytes");let t=e.length,a=new Uint8Array(t);for(let n=0;n<t;++n)a[n]=e.charCodeAt(n)&255;return a}class ea{static get isLittleEndian(){let e=new Uint8Array(4);e[0]=1;let t=new Uint32Array(e.buffer,0,1);return ft(this,"isLittleEndian",t[0]===1)}static get isOffscreenCanvasSupported(){return ft(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return ft(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return ft(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return ft(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:e,userAgent:t}=navigator;return ft(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}static get isCanvasFilterSupported(){let e;if(this.isOffscreenCanvasSupported)e=new OffscreenCanvas(1,1).getContext("2d");else if(typeof document<"u")e=document.createElement("canvas").getContext("2d");return ft(this,"isCanvasFilterSupported",e?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return ft(this,"isAlphaColorInputSupported",!1);let e=document.createElement("input");return e.type="color",e.setAttribute("alpha",""),e.value="#ff000080",ft(this,"isAlphaColorInputSupported",e.value!=="#ff0000")}static get isBackdropFilterSupported(){return ft(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class Fe{static get hexNums(){return ft(this,"hexNums",Array.from(Array(256).keys(),(e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(e,t,a){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[a]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,a=0){let n=e[a],s=e[a+1];e[a]=n*t[0]+s*t[2]+t[4],e[a+1]=n*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,a=0){let n=t[0],s=t[1],i=t[2],f=t[3],l=t[4],c=t[5];for(let h=0;h<6;h+=2){let u=e[a+h],g=e[a+h+1];e[a+h]=u*n+g*i+l,e[a+h+1]=u*s+g*f+c}}static applyInverseTransform(e,t){let a=e[0],n=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(a*t[3]-n*t[2]+t[2]*t[5]-t[4]*t[3])/s,e[1]=(-a*t[1]+n*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,a){let n=t[0],s=t[1],i=t[2],f=t[3],l=t[4],c=t[5],h=e[0],u=e[1],g=e[2],b=e[3],d=n*h+l,j=d,A=n*g+l,C=A,y=f*u+c,O=y,T=f*b+c,M=T;if(s!==0||i!==0){let H=s*h,N=s*g,x=i*u,z=i*b;d+=x,C+=x,A+=z,j+=z,y+=H,M+=H,T+=N,O+=N}a[0]=Math.min(a[0],d,A,j,C),a[1]=Math.min(a[1],y,T,O,M),a[2]=Math.max(a[2],d,A,j,C),a[3]=Math.max(a[3],y,T,O,M)}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){let a=e[0],n=e[1],s=e[2],i=e[3],f=a**2+n**2,l=a*s+n*i,c=s**2+i**2,h=(f+c)/2,u=Math.sqrt(h**2-(f*c-l**2));t[0]=Math.sqrt(h+u||1),t[1]=Math.sqrt(h-u||1)}static normalizeRect(e){let t=e.slice(0);if(e[0]>e[2])t[0]=e[2],t[2]=e[0];if(e[1]>e[3])t[1]=e[3],t[3]=e[1];return t}static intersect(e,t){let a=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),n=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(a>n)return null;let s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),i=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));if(s>i)return null;return[a,s,n,i]}static pointBoundingBox(e,t,a){a[0]=Math.min(a[0],e),a[1]=Math.min(a[1],t),a[2]=Math.max(a[2],e),a[3]=Math.max(a[3],t)}static rectBoundingBox(e,t,a,n,s){s[0]=Math.min(s[0],e,a),s[1]=Math.min(s[1],t,n),s[2]=Math.max(s[2],e,a),s[3]=Math.max(s[3],t,n)}static#e(e,t,a,n,s,i,f,l,c,h){if(c<=0||c>=1)return;let u=1-c,g=c*c,b=g*c,d=u*(u*(u*e+3*c*t)+3*g*a)+b*n,j=u*(u*(u*s+3*c*i)+3*g*f)+b*l;h[0]=Math.min(h[0],d),h[1]=Math.min(h[1],j),h[2]=Math.max(h[2],d),h[3]=Math.max(h[3],j)}static#t(e,t,a,n,s,i,f,l,c,h,u,g){if(Math.abs(c)<0.000000000001){if(Math.abs(h)>=0.000000000001)this.#e(e,t,a,n,s,i,f,l,-u/h,g);return}let b=h**2-4*u*c;if(b<0)return;let d=Math.sqrt(b),j=2*c;this.#e(e,t,a,n,s,i,f,l,(-h+d)/j,g),this.#e(e,t,a,n,s,i,f,l,(-h-d)/j,g)}static bezierBoundingBox(e,t,a,n,s,i,f,l,c){c[0]=Math.min(c[0],e,f),c[1]=Math.min(c[1],t,l),c[2]=Math.max(c[2],e,f),c[3]=Math.max(c[3],t,l),this.#t(e,a,s,f,t,n,i,l,3*(-e+3*(a-s)+f),6*(e-2*a+s),3*(a-e),c),this.#t(e,a,s,f,t,n,i,l,3*(-t+3*(n-i)+l),6*(t-2*n+i),3*(n-t),c)}}function kE(e){return decodeURIComponent(escape(e))}var o8=null,kA=null;function AE(e){if(!o8)o8=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,kA=new Map([["ſt","ſt"]]);return e.replaceAll(o8,(t,a,n)=>a?a.normalize("NFKC"):kA.get(n))}function QA(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),vE(e)}function yE(e,t,a){if(!Array.isArray(a)||a.length<2)return!1;let[n,s,...i]=a;if(!e(n)&&!Number.isInteger(n))return!1;if(!t(s))return!1;let f=i.length,l=!0;switch(s.name){case"XYZ":if(f<2||f>3)return!1;break;case"Fit":case"FitB":return f===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(f>1)return!1;break;case"FitR":if(f!==4)return!1;l=!1;break;default:return!1}for(let c of i){if(typeof c==="number"||l&&c===null)continue;return!1}return!0}var w2=()=>[],S8=()=>new Map,b8=()=>Object.create(null);function da(e,t,a){return Math.min(Math.max(e,t),a)}class d2{constructor({viewBox:e,userUnit:t,scale:a,rotation:n,offsetX:s=0,offsetY:i=0,dontFlip:f=!1}){this.viewBox=e,this.userUnit=t,this.scale=a,this.rotation=n,this.offsetX=s,this.offsetY=i,a*=t;let l=(e[2]+e[0])/2,c=(e[3]+e[1])/2,h,u,g,b;if(n%=360,n<0)n+=360;switch(n){case 180:h=-1,u=0,g=0,b=1;break;case 90:h=0,u=1,g=1,b=0;break;case 270:h=0,u=-1,g=-1,b=0;break;case 0:h=1,u=0,g=0,b=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(f)g=-g,b=-b;let d,j,A,C;if(h===0)d=Math.abs(c-e[1])*a+s,j=Math.abs(l-e[0])*a+i,A=(e[3]-e[1])*a,C=(e[2]-e[0])*a;else d=Math.abs(l-e[0])*a+s,j=Math.abs(c-e[1])*a+i,A=(e[2]-e[0])*a,C=(e[3]-e[1])*a;this.transform=[h*a,u*a,g*a,b*a,d-h*a*l-g*a*c,j-u*a*l-b*a*c],this.width=A,this.height=C}get rawDims(){let e=this.viewBox;return ft(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:a=this.offsetX,offsetY:n=this.offsetY,dontFlip:s=!1}={}){return new d2({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:a,offsetY:n,dontFlip:s})}convertToViewportPoint(e,t){let a=[e,t];return Fe.applyTransform(a,this.transform),a}convertToPdfPoint(e,t){let a=[e,t];return Fe.applyInverseTransform(a,this.transform),a}}class u2{static textContent(e){let t=[],a={items:t,styles:Object.create(null)};function n(s){if(!s)return;let i=null,f=s.name;if(f==="#text")i=s.value;else if(!u2.shouldBuildText(f))return;else if(s?.attributes?.textContent)i=s.attributes.textContent;else if(s.value)i=s.value;if(i!==null)t.push({str:i});if(!s.children)return;for(let l of s.children)n(l)}return n(e),a}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class C8{static setupStorage(e,t,a,n,s){let i=n.getValue(t,{value:null});switch(a.name){case"textarea":if(i.value!==null)e.textContent=i.value;if(s==="print")break;e.addEventListener("input",(f)=>{n.setValue(t,{value:f.target.value})});break;case"input":if(a.attributes.type==="radio"||a.attributes.type==="checkbox"){if(i.value===a.attributes.xfaOn)e.setAttribute("checked",!0);else if(i.value===a.attributes.xfaOff)e.removeAttribute("checked");if(s==="print")break;e.addEventListener("change",(f)=>{n.setValue(t,{value:f.target.checked?f.target.getAttribute("xfaOn"):f.target.getAttribute("xfaOff")})})}else{if(i.value!==null)e.setAttribute("value",i.value);if(s==="print")break;e.addEventListener("input",(f)=>{n.setValue(t,{value:f.target.value})})}break;case"select":if(i.value!==null){e.setAttribute("value",i.value);for(let f of a.children)if(f.attributes.value===i.value)f.attributes.selected=!0;else if(Object.hasOwn(f.attributes,"selected"))delete f.attributes.selected}e.addEventListener("input",(f)=>{let l=f.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;n.setValue(t,{value:c})});break}}static setAttributes({html:e,element:t,storage:a=null,intent:n,linkService:s}){let{attributes:i}=t,f=e instanceof HTMLAnchorElement;if(i.type==="radio")i.name=`${i.name}-${n}`;for(let[l,c]of Object.entries(i)){if(c===null||c===void 0)continue;switch(l){case"class":if(c.length)e.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",c);break;case"style":Object.assign(e.style,c);break;case"textContent":e.textContent=c;break;default:if(!f||l!=="href"&&l!=="newWindow")e.setAttribute(l,c)}}if(f)s.addLinkAttributes(e,i.href,i.newWindow);if(a&&i.dataId)this.setupStorage(e,i.dataId,t,a)}static render(e){let{annotationStorage:t,linkService:a,xfaHtml:n}=e,s=e.intent||"display",i=document.createElement(n.name);if(n.attributes)this.setAttributes({html:i,element:n,intent:s,linkService:a});let f=s!=="richText",l=e.div;if(l.append(i),e.viewport){let u=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=u}if(f)l.setAttribute("class","xfaLayer xfaFont");let c=[];if(n.children.length===0){if(n.value){let u=document.createTextNode(n.value);if(i.append(u),f&&u2.shouldBuildText(n.name))c.push(u)}return{textDivs:c}}let h=[[n,-1,i]];while(h.length>0){let[u,g,b]=h.at(-1);if(g+1===u.children.length){h.pop();continue}let d=u.children[++h.at(-1)[1]];if(d===null)continue;let{name:j}=d;if(j==="#text"){let C=document.createTextNode(d.value);c.push(C),b.append(C);continue}let A=d?.attributes?.xmlns?document.createElementNS(d.attributes.xmlns,j):document.createElement(j);if(b.append(A),d.attributes)this.setAttributes({html:A,element:d,storage:t,intent:s,linkService:a});if(d.children?.length>0)h.push([d,-1,A]);else if(d.value){let C=document.createTextNode(d.value);if(f&&u2.shouldBuildText(j))c.push(C);A.append(C)}}for(let u of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:a=0}){let{width:n,height:s}=e.attributes.style;return new d2({viewBox:[0,0,parseInt(n,10),parseInt(s,10)],userUnit:1,scale:t,rotation:a})}}class Ur{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function _8(e,t="text"){if(r2(e,document.baseURI)){let a=await fetch(e);if(!a.ok)throw Error(a.statusText);switch(t){case"blob":return a.blob();case"bytes":return a.bytes();case"json":return a.json()}return a.text()}return new Promise((a,n)=>{let s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType=t==="bytes"?"arraybuffer":t,s.onreadystatechange=()=>{if(s.readyState!==XMLHttpRequest.DONE)return;if(s.status===200||s.status===0){switch(t){case"bytes":a(new Uint8Array(s.response));return;case"blob":case"json":a(s.response);return}a(s.responseText);return}n(Error(s.statusText))},s.send(null)})}class x5 extends Xr{constructor(e,t=0){super(e,"RenderingCancelledException");this.extraDelay=t}}function R5(e){let t=e.length,a=0;while(a<t&&e[a].trim()==="")a++;return e.substring(a,a+5).toLowerCase()==="data:"}function F8(e){return typeof e==="string"&&/\.pdf$/i.test(e)}function SE(e){return[e]=e.split(/[#?]/,1),p8(e)}function CE(e,t="document.pdf"){if(typeof e!=="string")return t;if(R5(e))return ot('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let n=((l)=>{try{return new URL(l)}catch{}try{return new URL(decodeURIComponent(l))}catch{}try{return new URL(l,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(l),"https://foo.bar")}catch{}return null})(e);if(!n)return t;let s=(l)=>{try{let c=decodeURIComponent(l);if(c.includes("/")){if(c=p8(c),c.length===4&&i.test(c))return l}return c}catch{return l}},i=/\.pdf$/i,f=p8(n.pathname);if(i.test(f))return s(f);if(n.searchParams.size>0){let l=(h)=>[...h].findLast((u)=>i.test(u)),c=l(n.searchParams.values())??l(n.searchParams.keys());if(c)return s(c)}if(n.hash){let c=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(c)return s(c[0])}return t}class w8{#e=new Map;times=[];time(e){if(this.#e.has(e))ot(`Timer is already running for ${e}`);this.#e.set(e,Date.now())}timeEnd(e){if(!this.#e.has(e))ot(`Timer has not been started for ${e}`);this.times.push({name:e,start:this.#e.get(e),end:Date.now()}),this.#e.delete(e)}toString(){let e=Math.max(...this.times.map((t)=>t.name.length));return this.times.map((t)=>`${t.name.padEnd(e)} ${t.end-t.start}ms
253
+ `).join("")}}function r2(e,t){let a=t?URL.parse(e,t):URL.parse(e);return/https?:/.test(a?.protocol??"")}function Ai(e){e.preventDefault()}function Ha(e){e.preventDefault(),e.stopPropagation()}class A5{static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!=="string")return null;this.#e||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");let t=this.#e.exec(e);if(!t)return null;let a=parseInt(t[1],10),n=parseInt(t[2],10);n=n>=1&&n<=12?n-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let i=parseInt(t[4],10);i=i>=0&&i<=23?i:0;let f=parseInt(t[5],10);f=f>=0&&f<=59?f:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;let c=t[7]||"Z",h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let u=parseInt(t[9],10)||0;if(u=u>=0&&u<=59?u:0,c==="-")i+=h,f+=u;else if(c==="+")i-=h,f-=u;return new Date(Date.UTC(a,n,s,i,f,l))}}function j2(e){if(e.startsWith("#")){let a=e.slice(1);return[parseInt(a.slice(0,2),16),parseInt(a.slice(2,4),16),parseInt(a.slice(4,6),16),a.length>=8?parseInt(a.slice(6,8),16)/255:1]}if(e.startsWith("rgb(")){let[a,n,s]=e.slice(4,-1).split(",").map((i)=>parseInt(i,10));return[a,n,s,1]}if(e.startsWith("rgba(")){let a=e.slice(5,-1).split(",");return[parseInt(a[0],10),parseInt(a[1],10),parseInt(a[2],10),parseFloat(a[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);if(t)return[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1];return null}function q2(e){let t=j2(e);if(!t)return ot(`Not a valid color format: "${e}"`),[0,0,0];return t.slice(0,3)}function _E(e){let t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(let a of e.keys()){t.style.color=a;let n=window.getComputedStyle(t).color;e.set(a,q2(n))}t.remove()}function ma(e){let{a:t,b:a,c:n,d:s,e:i,f}=e.getTransform();return[t,a,n,s,i,f]}function j0(e){let{a:t,b:a,c:n,d:s,e:i,f}=e.getTransform().invertSelf();return[t,a,n,s,i,f]}function Ir(e,t,a=!1,n=!0){if(t instanceof d2){let{pageWidth:s,pageHeight:i}=t.rawDims,{style:f}=e,l=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-x))`,c=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;if(!a||t.rotation%180===0)f.width=l,f.height=c;else f.width=c,f.height=l}if(n)e.setAttribute("data-main-rotation",t.rotation)}class y0{constructor(){let{pixelRatio:e}=y0;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,t,a,n,s=-1){let i=1/0,f=1/0,l=1/0;if(a=y0.capPixels(a,s),a>0)i=Math.sqrt(a/(e*t));if(n!==-1)f=n/e,l=n/t;let c=Math.min(i,f,l);if(this.sx>c||this.sy>c)return this.sx=c,this.sy=c,!0;return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let a=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,a):a}return e}}var d8=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class ZA{static get isDarkMode(){return ft(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class $A{static get commentForegroundColor(){let e=document.createElement("span");e.classList.add("comment","sidebar");let{style:t}=e;t.width=t.height="0",t.display="none",t.color="var(--comment-fg-color)",document.body.append(e);let{color:a}=window.getComputedStyle(e);return e.remove(),ft(this,"commentForegroundColor",q2(a))}}function FE(e,t){t=da(t??1,0,1);let a=255*(1-t);return e.map((n)=>Math.round(n*t+a))}function AA(e,t){let a=e[0]/255,n=e[1]/255,s=e[2]/255,i=Math.max(a,n,s),f=Math.min(a,n,s),l=(i+f)/2;if(i===f)t[0]=t[1]=0;else{let c=i-f;switch(t[1]=l<0.5?c/(i+f):c/(2-i-f),i){case a:t[0]=((n-s)/c+(n<s?6:0))*60;break;case n:t[0]=((s-a)/c+2)*60;break;case s:t[0]=((a-n)/c+4)*60;break}}t[2]=l}function j8(e,t){let a=e[0],n=e[1],s=e[2],i=(1-Math.abs(2*s-1))*n,f=i*(1-Math.abs(a/60%2-1)),l=s-i/2;switch(Math.floor(a/60)){case 0:t[0]=i+l,t[1]=f+l,t[2]=l;break;case 1:t[0]=f+l,t[1]=i+l,t[2]=l;break;case 2:t[0]=l,t[1]=i+l,t[2]=f+l;break;case 3:t[0]=l,t[1]=f+l,t[2]=i+l;break;case 4:t[0]=f+l,t[1]=l,t[2]=i+l;break;case 5:case 6:t[0]=i+l,t[1]=l,t[2]=f+l;break}}function yA(e){return e<=0.03928?e/12.92:((e+0.055)/1.055)**2.4}function SA(e,t,a){j8(e,a),a.map(yA);let n=0.2126*a[0]+0.7152*a[1]+0.0722*a[2];j8(t,a),a.map(yA);let s=0.2126*a[0]+0.7152*a[1]+0.0722*a[2];return n>s?(n+0.05)/(s+0.05):(s+0.05)/(n+0.05)}var CA=new Map;function OE(e,t){let a=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,n=CA.get(a);if(n)return n;let s=new Float32Array(9),i=s.subarray(0,3),f=s.subarray(3,6);AA(e,f);let l=s.subarray(6,9);AA(t,l);let c=l[2]<0.5,h=c?12:4.5;if(f[2]=c?Math.sqrt(f[2]):1-Math.sqrt(1-f[2]),SA(f,l,i)<h){let u,g;if(c)u=f[2],g=1;else u=0,g=f[2];let b=0.005;while(g-u>b){let d=f[2]=(u+g)/2;if(c===SA(f,l,i)<h)u=d;else g=d}f[2]=c?g:u}return j8(f,i),n=Fe.makeHexColor(Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255)),CA.set(a,n),n}function WA({html:e,dir:t,className:a},n){let s=document.createDocumentFragment();if(typeof e==="string"){let i=document.createElement("p");i.dir=t||"auto";let f=e.split(/\r\n?|\n/);for(let l=0,c=f.length;l<c;++l){let h=f[l];if(i.append(document.createTextNode(h)),l<c-1)i.append(document.createElement("br"))}s.append(i)}else C8.render({xfaHtml:e,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",a),n.append(s)}function PA(e){let t=new Path2D;if(!e)return t;for(let a=0,n=e.length;a<n;)switch(e[a++]){case s2.moveTo:t.moveTo(e[a++],e[a++]);break;case s2.lineTo:t.lineTo(e[a++],e[a++]);break;case s2.curveTo:t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);break;case s2.quadraticCurveTo:t.quadraticCurveTo(e[a++],e[a++],e[a++],e[a++]);break;case s2.closePath:t.closePath();break;default:ot(`Unrecognized drawing path operator: ${e[a-1]}`);break}return t}class o2{#e=null;#t=null;#a;#n=null;#s=null;#f=null;#i=null;#l=null;static#o=null;constructor(e){this.#a=e,o2.#o||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let e=this.#e=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");let t=this.#a._uiManager._signal;if(t instanceof AbortSignal&&!t.aborted)e.addEventListener("contextmenu",Ai,{signal:t}),e.addEventListener("pointerdown",o2.#r,{signal:t});let a=this.#n=document.createElement("div");a.className="buttons",e.append(a);let n=this.#a.toolbarPosition;if(n){let{style:s}=e,i=this.#a._uiManager.direction==="ltr"?1-n[0]:n[0];s.insetInlineEnd=`${100*i}%`,s.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return this.#e}static#r(e){e.stopPropagation()}#u(e){this.#a._focusEventsAllowed=!1,Ha(e)}#h(e){this.#a._focusEventsAllowed=!0,Ha(e)}#g(e){let t=this.#a._uiManager._signal;if(!(t instanceof AbortSignal)||t.aborted)return!1;return e.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#h.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",Ai,{signal:t}),!0}hide(){this.#e.classList.add("hidden"),this.#t?.hideDropdown()}show(){this.#e.classList.remove("hidden"),this.#s?.shown(),this.#f?.shown()}addDeleteButton(){let{editorType:e,_uiManager:t}=this.#a,a=document.createElement("button");if(a.classList.add("basic","deleteButton"),a.tabIndex=0,a.setAttribute("data-l10n-id",o2.#o[e]),this.#g(a))a.addEventListener("click",(n)=>{t.delete()},{signal:t._signal});this.#n.append(a)}get#b(){let e=document.createElement("div");return e.className="divider",e}async addAltText(e){let t=await e.render();this.#g(t),this.#n.append(t,this.#b),this.#s=e}addComment(e,t=null){if(this.#f)return;let a=e.renderForToolbar();if(!a)return;this.#g(a);let n=this.#i=this.#b;if(!t)this.#n.append(a,n);else this.#n.insertBefore(a,t),this.#n.insertBefore(n,t);this.#f=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;let t=e.renderButton();this.#g(t),this.#n.append(t,this.#b)}async addEditSignatureButton(e){let t=this.#l=await e.renderEditButton(this.#a);this.#g(t),this.#n.append(t,this.#b)}removeButton(e){switch(e){case"comment":this.#f?.removeToolbarCommentButton(),this.#f=null,this.#i?.remove(),this.#i=null;break}}async addButton(e,t){switch(e){case"colorPicker":if(t)this.addColorPicker(t);break;case"altText":if(t)await this.addAltText(t);break;case"editSignature":if(t)await this.addEditSignatureButton(t);break;case"delete":this.addDeleteButton();break;case"comment":if(t)this.addComment(t);break}}async addButtonBefore(e,t,a){if(!t&&e==="comment")return;let n=this.#n.querySelector(a);if(!n)return;if(e==="comment")this.addComment(t,n)}updateEditSignatureButton(e){if(this.#l)this.#l.title=e}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}}class ey{#e=null;#t=null;#a;constructor(e){this.#a=e}#n(){let e=this.#t=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar");let t=this.#a._signal;if(t instanceof AbortSignal&&!t.aborted)e.addEventListener("contextmenu",Ai,{signal:t});let a=this.#e=document.createElement("div");if(a.className="buttons",e.append(a),this.#a.hasCommentManager())this.#f("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#a.commentSelection("floating_button")});return this.#f("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#a.highlightSelection("floating_button")}),e}#s(e,t){let a=0,n=0;for(let s of e){let i=s.y+s.height;if(i<a)continue;let f=s.x+(t?s.width:0);if(i>a){n=f,a=i;continue}if(t){if(f>n)n=f}else if(f<n)n=f}return[t?1-n:n,a]}show(e,t,a){let[n,s]=this.#s(t,a),{style:i}=this.#t||=this.#n();e.append(this.#t),i.insetInlineEnd=`${100*n}%`,i.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#f(e,t,a,n){let s=document.createElement("button");s.classList.add("basic",e),s.tabIndex=0,s.setAttribute("data-l10n-id",t);let i=document.createElement("span");s.append(i),i.className="visuallyHidden",i.setAttribute("data-l10n-id",a);let f=this.#a._signal;if(f instanceof AbortSignal&&!f.aborted)s.addEventListener("contextmenu",Ai,{signal:f}),s.addEventListener("click",n,{signal:f});this.#e.append(s)}}var BE="068f09d6-5b37-4f77-a97a-f8ff4f253b68",c8=Object.freeze({internal:BE});function ty(e,t,a){for(let n of a)t.addEventListener(n,e[n].bind(e))}class Gt{static#e=NaN;static#t=null;static#a=NaN;static#n=null;static initializeAndAddPointerId(e){(Gt.#t||=new Set).add(e)}static setPointer(e,t){Gt.#e||=t,Gt.#n??=e}static setTimeStamp(e){Gt.#a=e}static isSamePointerId(e){return Gt.#e===e}static isSamePointerIdOrRemove(e){if(Gt.#e===e)return!0;return Gt.#t?.delete(e),!1}static isSamePointerType(e){return Gt.#n===e}static isInitializedAndDifferentPointerType(e){return Gt.#n!==null&&!Gt.isSamePointerType(e)}static isSameTimeStamp(e){return Gt.#a===e}static isUsingMultiplePointers(){return Gt.#t?.size>=1}static clearPointerType(){Gt.#n=null}static clearPointerIds(){Gt.#e=NaN,Gt.#t=null}static clearTimeStamp(){Gt.#a=NaN}}class ay{#e=0;get id(){return`pdfjs_internal_editor_${this.#e++}`}}class O8{#e=QA();#t=0;#a=null;static get _isSVGFittingCanvas(){let a=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;n.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';let s=n.decode().then(()=>{return a.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(a.getImageData(0,0,1,1).data.buffer)[0]===0});return ft(this,"_isSVGFittingCanvas",s)}async#n(e,t){this.#a||=new Map;let a=this.#a.get(e);if(a===null)return null;if(a?.bitmap)return a.refCounter+=1,a;try{a||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let n;if(typeof t==="string")a.url=t,n=await _8(t,"blob");else if(t instanceof File)n=a.file=t;else if(t instanceof Blob)n=t;if(n.type==="image/svg+xml"){let s=O8._isSVGFittingCanvas,i=new FileReader,f=new Image,l=new Promise((c,h)=>{f.onload=()=>{a.bitmap=f,a.isSvg=!0,c()},i.onload=async()=>{let u=a.svgUrl=i.result;f.src=await s?`${u}#svgView(preserveAspectRatio(none))`:u},f.onerror=i.onerror=h});i.readAsDataURL(n),await l}else a.bitmap=await createImageBitmap(n);a.refCounter=1}catch(n){ot(n),a=null}if(this.#a.set(e,a),a)this.#a.set(a.id,a);return a}async getFromFile(e){let{lastModified:t,name:a,size:n,type:s}=e;return this.#n(`${t}_${a}_${n}_${s}`,e)}async getFromUrl(e){return this.#n(e,e)}async getFromBlob(e,t){let a=await t;return this.#n(e,a)}async getFromId(e){this.#a||=new Map;let t=this.#a.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:a}=t;return delete t.blobPromise,this.getFromBlob(t.id,a)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#a||=new Map;let a=this.#a.get(e);if(a?.bitmap)return a.refCounter+=1,a;let n=new OffscreenCanvas(t.width,t.height);return n.getContext("2d").drawImage(t,0,0),a={bitmap:n.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#a.set(e,a),this.#a.set(a.id,a),a}getSvgUrl(e){let t=this.#a.get(e);if(!t?.isSvg)return null;return t.svgUrl}deleteId(e){this.#a||=new Map;let t=this.#a.get(e);if(!t)return;if(t.refCounter-=1,t.refCounter!==0)return;let{bitmap:a}=t;if(!t.url&&!t.file){let n=new OffscreenCanvas(a.width,a.height);n.getContext("bitmaprenderer").transferFromImageBitmap(a),t.blobPromise=n.convertToBlob()}a.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}}class ny{#e=[];#t=!1;#a;#n=-1;constructor(e=128){this.#a=e}add({cmd:e,undo:t,post:a,mustExec:n,type:s=NaN,overwriteIfSameType:i=!1,keepUndo:f=!1}){if(n)e();if(this.#t)return;let l={cmd:e,undo:t,post:a,type:s};if(this.#n===-1){if(this.#e.length>0)this.#e.length=0;this.#n=0,this.#e.push(l);return}if(i&&this.#e[this.#n].type===s){if(f)l.undo=this.#e[this.#n].undo;this.#e[this.#n]=l;return}let c=this.#n+1;if(c===this.#a)this.#e.splice(0,1);else if(this.#n=c,c<this.#e.length)this.#e.splice(c);this.#e.push(l)}undo(){if(this.#n===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#n];e(),t?.(),this.#t=!1,this.#n-=1}redo(){if(this.#n<this.#e.length-1){this.#n+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#n];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#e.length-1}cleanType(e){if(this.#n===-1)return;for(let t=this.#n;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#n-t),this.#n=t;return}this.#e.length=0,this.#n=-1}destroy(){this.#e=null}}class Qs{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(e){this.callbacks=new Map;let{isMac:t}=ea.platform;for(let[a,n,s={}]of e){let i=a.some((f)=>f.startsWith("mac+"));for(let f of a){let l=f;if(i){let u=f.startsWith("mac+");if(t!==u)continue;if(u)l=f.slice(4)}let[c,h]=Qs.#e(l);if(c===null)continue;this.callbacks.getOrInsertComputed(c,w2).push({callback:n,options:s,modifiers:h})}}}static#e(e){let t=null,a=0;for(let n of e.split("+")){if(n=n.trim(),!n)continue;let s=n.toUpperCase(),i=Qs[s];if(i){a|=i;continue}if(t!==null){ot(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t=s==="SPACE"?" ":n}if(t===null)ot(`KeyboardManager: no key found in shortcut "${e}"`);return[t,a]}static#t(e){let t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);if(!t)return null;return t[1]?.toLowerCase()??t[2]}exec(e,t){let a=this.callbacks.get(t.key);if(!a){if(/^[a-z]$/i.test(t.key))return;let h=Qs.#t(t.code);if(h===null||h===t.key)return;if(a=this.callbacks.get(h),!a)return}let n=(t.altKey?Qs.ALT:0)|(t.ctrlKey?Qs.CTRL:0)|(t.metaKey?Qs.META:0)|(t.shiftKey?Qs.SHIFT:0),s=a.find((h)=>h.modifiers===n);if(!s)return;let{callback:i,options:{bubbles:f=!1,args:l=[],checker:c=null}}=s;if(c&&!c(e,t))return;if(i.bind(e,...l,t)(),!f)Ha(t)}}class B8{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let e=new Map([["CanvasText",null],["Canvas",null]]);return _E(e),ft(this,"_colors",e)}convert(e){let t=q2(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(let[a,n]of this._colors)if(n.every((s,i)=>s===t[i]))return B8._colorsMapping.get(a);return t}getHexCode(e){let t=this._colors.get(e);if(!t)return e;return Fe.makeHexColor(...t)}}class Al{#e=new AbortController;#t=null;#a=null;#n=new Map;#s=new Map;#f=null;#i=null;#l=null;#o=null;#r=new ny;#u=null;#h=null;#g=null;#b=0;#p=new Set;#c=null;#m=null;#d=new Set;_editorUndoBar=null;#j=!1;#w=!1;#A=!1;#y=null;#q=null;#S=null;#k=null;#_=!1;#O=null;#B=new ay;#F=!1;#M=!1;#D=!1;#H=null;#x=null;#N=null;#z=null;#L=null;#C=rt.NONE;#v=new Set;#R=null;#I=null;#X=null;#Q=null;#Y=null;#J={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#E=[0,0];#K=null;#V=null;#P=null;#ee=null;#U=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let e=Al.prototype,t=(i)=>i.#V.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&i.hasSomethingToControl(),a=(i,{target:f})=>{if(f instanceof HTMLInputElement){let{type:l}=f;return l!=="text"&&l!=="number"}return!0},n=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return ft(this,"_keyboardManager",new Qs([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:a}],[["ctrl+z","mac+meta+z"],e.undo,{checker:a}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:a}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:a}],[["Enter"],e.addNewEditorFromKeyboard,{checker:(i,{target:f})=>!(f instanceof HTMLButtonElement)&&i.#V.contains(f)&&!i.isEnterHandled}],[["Space"],e.addNewEditorFromKeyboard,{checker:(i,{target:f})=>!(f instanceof HTMLButtonElement)&&i.#V.contains(document.activeElement)}],[["Escape"],e.unselectAll],[["ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-s,0],checker:t}],[["ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[s,0],checker:t}],[["ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-s],checker:t}],[["ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,s],checker:t}]]))}constructor(e,t,a,n,s,i,f,l,c,h,u,g,b,d,j,A){let C=this._signal=this.#e.signal;this.#V=e,this.#P=t,this.#ee=a,this.#i=n,this.#u=s,this.#I=i,this.#Y=l,this._eventBus=f;let y={signal:C,...c8};f.on("editingaction",this.onEditingAction.bind(this),y),f.on("pagechanging",this.onPageChanging.bind(this),y),f.on("scalechanging",this.onScaleChanging.bind(this),y),f.on("rotationchanging",this.onRotationChanging.bind(this),y),f.on("setpreference",this.onSetPreference.bind(this),y),f.on("switchannotationeditorparams",(O)=>this.updateParams(O.type,O.value),y),window.addEventListener("pointerdown",()=>{this.#M=!0},{capture:!0,signal:C}),window.addEventListener("pointerup",()=>{this.#M=!1},{capture:!0,signal:C}),window.addEventListener("beforeunload",this.#ie.bind(this),{capture:!0,signal:C}),this.#re(),this.#ge(),this.#ae(),this.#l=l.annotationStorage,this.#y=l.filterFactory,this.#X=c,this.#k=h||null,this.#j=u,this.#w=g,this.#A=b,this.#L=d||null,this.viewParameters={realScale:Ur.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=j||null,this._supportsPinchToZoom=A!==!1,s?.setSidebarUiManager(this)}destroy(){this.#U?.resolve(),this.#U=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#s.values())e.destroy();if(this.#s.clear(),this.#n.clear(),this.#d.clear(),this.#z?.clear(),this.#t=null,this.#v.clear(),this.#r.destroy(),this.#i?.destroy(),this.#u?.destroy(),this.#I?.destroy(),this.#O?.hide(),this.#O=null,this.#N?.destroy(),this.#N=null,this.#a=null,this.#q)clearTimeout(this.#q),this.#q=null;if(this.#K)clearTimeout(this.#K),this.#K=null;this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#L}get useNewAltTextFlow(){return this.#w}get useNewAltTextWhenAddingImage(){return this.#A}get hcmFilter(){return ft(this,"hcmFilter",this.#X?this.#y.addHCMFilter(this.#X.foreground,this.#X.background):"none")}get direction(){return ft(this,"direction",getComputedStyle(this.#V).direction)}get _highlightColors(){return ft(this,"_highlightColors",this.#k?new Map(this.#k.split(",").map((e)=>{return e=e.split("=").map((t)=>t.trim()),e[1]=e[1].toUpperCase(),e})):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return ft(this,"highlightColors",null);let t=new Map,a=!!this.#X;for(let[n,s]of e){let i=n.endsWith("_HCM");if(a&&i){t.set(n.replace("_HCM",""),s);continue}if(!a&&!i)t.set(n,s)}return ft(this,"highlightColors",t)}get highlightColorNames(){return ft(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(e)=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){if(e)this.unselectAll(),this.disableUserSelect(!0);else this.disableUserSelect(!1);this.#g=e}setMainHighlightColorPicker(e){this.#N=e}editAltText(e,t=!1){this.#i?.editAltText(this,e,t)}hasCommentManager(){return!!this.#u}editComment(e,t,a,n){this.#u?.showDialog(this,e,t,a,n)}selectComment(e,t){this.#s.get(e)?.getEditorByUID(t)?.toggleComment(!0,!0)}updateComment(e){this.#u?.updateComment(e.getData())}updatePopupColor(e){this.#u?.updatePopupColor(e)}removeComment(e){this.#u?.removeComments([e.uid])}deleteComment(e,t){let a=()=>{e.comment=t},n=()=>{this._editorUndoBar?.show(a,"comment"),this.toggleComment(null),e.comment=null};this.addCommands({cmd:n,undo:a,mustExec:!0})}toggleComment(e,t,a=void 0){this.#u?.toggleCommentPopup(e,t,a)}makeCommentColor(e,t){return e&&this.#u?.makeCommentColor(e,t)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(e){if(this.#s.has(e-1))return;let{resolve:t,promise:a}=Promise.withResolvers(),n=(s)=>{if(s.pageNumber===e)this._eventBus.off("editorsrendered",n),t()};this._eventBus.on("editorsrendered",n,c8),await a}getSignature(e){this.#I?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#I}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal,...c8}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case"enableNewAltTextWhenAddingImage":this.#A=t;break}}onPageChanging({pageNumber:e}){this.#b=e-1}deletePage(e){for(let t of this.getEditors(e))t.remove();if(this.#s.delete(e),this.#b===e)this.#b=0}focusMainContainer(){this.#V.focus()}findParent(e,t){for(let a of this.#s.values()){let{x:n,y:s,width:i,height:f}=a.div.getBoundingClientRect();if(e>=n&&e<=n+i&&t>=s&&t<=s+f)return a}return null}disableUserSelect(e=!1){this.#P.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#d.add(e)}removeShouldRescale(e){this.#d.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Ur.PDF_TO_CSS_UNITS;for(let t of this.#d)t.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#W({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#te(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let a of this.#s.values())if(a.hasTextLayer(e))return a;return null}highlightSelection(e="",t=!1){let a=document.getSelection();if(!a||a.isCollapsed)return;let{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:f}=a,l=a.toString(),h=this.#W(a).closest(".textLayer"),u=this.getSelectionBoxes(h);if(!u)return;a.empty();let g=this.#te(h),b=this.#C===rt.NONE,d=()=>{let j=g?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:u,anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:f,text:l});if(b)this.showAllEditors("highlight",!0,!0);if(t)j?.editComment()};if(b){this.switchToMode(rt.HIGHLIGHT,d);return}d()}commentSelection(e=""){this.highlightSelection(e,!0)}#ie(e){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#fe(){let e=document.getSelection();if(!e||e.isCollapsed)return;let a=this.#W(e).closest(".textLayer"),n=this.getSelectionBoxes(a);if(!n)return;this.#O||=new ey(this),this.#O.show(a,n,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage(e){if(!this.#l)return null;let t=`pdfjs_internal_editor_${e}`,a=this.#l.getRawValue(t);if(a)this.#l.remove(t);return a}addToAnnotationStorage(e){if(!e.isEmpty()&&this.#l&&!this.#l.has(e.id))this.#l.setValue(e.id,e)}a11yAlert(e,t=null){let a=this.#ee;if(!a)return;if(a.setAttribute("data-l10n-id",e),t)a.setAttribute("data-l10n-args",JSON.stringify(t));else a.removeAttribute("data-l10n-args")}#le(){let e=document.getSelection();if(!e||e.isCollapsed){if(this.#R)this.#O?.hide(),this.#R=null,this.#T({hasSelectedText:!1});return}let{anchorNode:t}=e;if(t===this.#R)return;let n=this.#W(e).closest(".textLayer");if(!n){if(this.#R)this.#O?.hide(),this.#R=null,this.#T({hasSelectedText:!1});return}if(this.#O?.hide(),this.#R=t,this.#T({hasSelectedText:!0}),this.#C!==rt.HIGHLIGHT&&this.#C!==rt.NONE)return;if(this.#C===rt.HIGHLIGHT)this.showAllEditors("highlight",!0,!0);if(this.#_=this.isShiftKeyDown,!this.isShiftKeyDown){let s=this.#C===rt.HIGHLIGHT?this.#te(n):null;if(s?.toggleDrawing(),this.#M){let i=new AbortController,f=this.combinedSignal(i),l=(c)=>{if(c.type==="pointerup"&&c.button!==0)return;if(i.abort(),s?.toggleDrawing(!0),c.type==="pointerup")this.#Z("main_toolbar")};window.addEventListener("pointerup",l,{signal:f}),window.addEventListener("blur",l,{signal:f})}else s?.toggleDrawing(!0),this.#Z("main_toolbar")}}#Z(e=""){if(this.#C===rt.HIGHLIGHT)this.highlightSelection(e);else if(this.#j)this.#fe()}#re(){document.addEventListener("selectionchange",this.#le.bind(this),{signal:this._signal})}#oe(){if(this.#S)return;this.#S=new AbortController;let e=this.combinedSignal(this.#S);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#ce(){this.#S?.abort(),this.#S=null}blur(){if(this.isShiftKeyDown=!1,this.#_)this.#_=!1,this.#Z("main_toolbar");if(!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#v)if(t.div.contains(e)){this.#x=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#x)return;let[e,t]=this.#x;this.#x=null,t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ae(){if(this.#H)return;this.#H=new AbortController;let e=this.combinedSignal(this.#H);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#he(){this.#H?.abort(),this.#H=null}#ue(){if(this.#h)return;this.#h=new AbortController;let e=this.combinedSignal(this.#h);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#me(){this.#h?.abort(),this.#h=null}#ge(){let e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ae(),this.setEditingState(!0)}removeEditListeners(){this.#he(),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let a of this.#m)if(a.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let a of this.#m)if(a.isHandlingMimeForPasting(t.type)){a.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let a of this.#v){let n=a.serialize(!0);if(n)t.push(n)}if(t.length===0)return;e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let s of t.items)for(let i of this.#m)if(i.isHandlingMimeForPasting(s.type)){i.paste(s,this.currentLayer);return}let a=t.getData("application/pdfjs");if(!a)return;try{a=JSON.parse(a)}catch(s){ot(`paste: "${s.message}".`);return}if(!Array.isArray(a))return;this.unselectAll();let n=this.currentLayer;try{let s=[];for(let l of a){let c=await n.deserialize(l);if(!c)return;s.push(c)}let i=()=>{for(let l of s)this.#ne(l);this.#se(s)},f=()=>{for(let l of s)l.remove()};this.addCommands({cmd:i,undo:f,mustExec:!0})}catch(s){ot(`paste: "${s.message}".`)}}keydown(e){if(!this.isShiftKeyDown&&e.key==="Shift")this.isShiftKeyDown=!0;if(this.#C!==rt.NONE&&!this.isEditorHandlingKeyboard)Al._keyboardManager.exec(this,e)}keyup(e){if(this.isShiftKeyDown&&e.key==="Shift"){if(this.isShiftKeyDown=!1,this.#_)this.#_=!1,this.#Z("main_toolbar")}}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(e,t){for(let n of this.getEditors(e))n.pageIndex=t;let a=this.#f.get(e);if(a)if(a.pageIndex=t,this.#s.set(t,a),this.#F)a.enable();else a.disable()}startUpdatePages(){this.#f=new Map(this.#s),this.#s.clear()}endUpdatePages(){this.#f=null}clonePage(e,t){for(let a of this.getEditors(e)){let n=a.serialize(a.mode!==rt.HIGHLIGHT);if(!n)continue;n.pageIndex=t,n.id=this.getId(),n.isClone=!0,delete n.popupRef,this.#l.setValue(n.id,n)}}findClonesForPage(e){let t=[],{pageIndex:a}=e;for(let[n,s]of this.#l)if(s.pageIndex===a&&s.isClone)this.#l.remove(n),t.push(e.deserialize(s).then((i)=>{if(i)i.isClone=!0,e.addOrRebuild(i)}));return Promise.all(t)}#T(e){if(Object.entries(e).some(([a,n])=>this.#J[a]!==n)){if(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#J,e)}),this.#C===rt.HIGHLIGHT&&e.hasSelectedEditor===!1)this.#G([[bt.HIGHLIGHT_FREE,!0]])}}#G(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){if(e)this.#oe(),this.#ue(),this.#T({isEditing:this.#C!==rt.NONE,isEmpty:this.#$(),hasSomethingToUndo:this.#r.hasSomethingToUndo(),hasSomethingToRedo:this.#r.hasSomethingToRedo(),hasSelectedEditor:!1});else this.#ce(),this.#me(),this.#T({isEditing:!1}),this.disableUserSelect(!1)}registerEditorTypes(e){if(this.#m)return;this.#m=e;for(let t of this.#m)this.#G(t.defaultPropertiesToUpdate)}getId(){return this.#B.id}get currentLayer(){return this.#s.get(this.#b)}getLayer(e){return this.#s.get(e)}get currentPageIndex(){return this.#b}addLayer(e){if(this.#s.set(e.pageIndex,e),this.#F)e.enable();else e.disable()}removeLayer(e){this.#s.delete(e.pageIndex)}async updateMode(e,t=null,a=!1,n=!1,s=!1,i=!1){if(this.#C===e)return;if(this.#U){if(await this.#U.promise,!this.#U)return}if(this.#U=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===rt.POPUP)this.#u?.hideSidebar();if(this.#u?.destroyPopup(),this.#C=e,e===rt.NONE){this.setEditingState(!1),this.#be();for(let f of this.#n.values())f.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#U.resolve();return}for(let f of this.#n.values())f.addStandaloneCommentButton();if(e===rt.SIGNATURE)await this.#I?.loadSignatures();if(a)Gt.clearPointerType();this.setEditingState(!0),await this.#pe(),this.unselectAll();for(let f of this.#s.values())f.updateMode(e);if(e===rt.POPUP){this.#a||=await this.#Y.getAnnotationsByType(new Set(this.#m.map((c)=>c._editorType)));let f=new Set,l=[];for(let c of this.#n.values()){let{annotationElementId:h,hasComment:u,deleted:g}=c;if(h)f.add(h);if(u&&!g)l.push(c.getData())}for(let c of this.#a){let{id:h,popupRef:u,contentsObj:g}=c;if(u&&g?.str&&!f.has(h)&&!this.#p.has(h))l.push(c)}this.#u?.showSidebar(l)}if(!t){if(n)this.addNewEditorFromKeyboard();this.#U.resolve();return}for(let f of this.#n.values())if(f.uid===t)if(this.setSelected(f),i)f.editComment();else if(s)f.enterInEditMode();else f.focus();else f.unselect();this.#U.resolve()}addNewEditorFromKeyboard(){if(this.currentLayer.canCreateNewEmptyEditor())this.currentLayer.addNewEditor()}updateToolbar(e){if(e.mode===this.#C)return;this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,t){if(!this.#m)return;switch(e){case bt.CREATE:this.currentLayer.addNewEditor(t);return;case bt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#Q||=new Map).set(e,t),this.showAllEditors("highlight",t);break}if(this.hasSelection)for(let a of this.#v)a.updateParams(e,t);else for(let a of this.#m)a.updateDefaultParams(e,t)}showAllEditors(e,t,a=!1){for(let s of this.#n.values())if(s.editorType===e)s.show(t);if((this.#Q?.get(bt.HIGHLIGHT_SHOW_ALL)??!0)!==t)this.#G([[bt.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#D===e)return;this.#D=e;for(let t of this.#s.values()){if(e)t.disableClick();else t.enableClick();t.div.classList.toggle("waiting",e)}}async#pe(){if(!this.#F){this.#F=!0;let e=[];for(let t of this.#s.values())e.push(t.enable());await Promise.all(e);for(let t of this.#n.values())t.enable()}}#be(){if(this.unselectAll(),this.#F){this.#F=!1;for(let e of this.#s.values())e.disable();for(let e of this.#n.values())e.disable()}}*getEditors(e){for(let t of this.#n.values())if(t.pageIndex===e)yield t}getEditor(e){return this.#n.get(e)}addEditor(e){this.#n.set(e.id,e)}removeEditor(e){if(e.div.contains(document.activeElement)){if(this.#q)clearTimeout(this.#q);this.#q=setTimeout(()=>{this.focusMainContainer(),this.#q=null},0)}if(this.#n.delete(e.id),e.annotationElementId)this.#z?.delete(e.annotationElementId);if(this.unselect(e),!e.annotationElementId||!this.#p.has(e.annotationElementId))this.#l?.remove(e.id)}addDeletedAnnotationElement(e){this.#p.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#p.has(e)}removeDeletedAnnotationElement(e){this.#p.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#ne(e){let t=this.#s.get(e.pageIndex);if(t)t.addOrRebuild(e);else this.addEditor(e),this.addToAnnotationStorage(e)}setActiveEditor(e){if(this.#t===e)return;if(this.#t=e,e)this.#G(e.propertiesToUpdate)}get#we(){let e=null;for(e of this.#v);return e}updateUI(e){if(this.#we===e)this.#G(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#G(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#v.has(e)){this.#v.delete(e),e.unselect(),this.#T({hasSelectedEditor:this.hasSelection});return}this.#v.add(e),e.select(),this.#G(e.propertiesToUpdate),this.#T({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#g?.commitOrRemove();for(let t of this.#v)if(t!==e)t.unselect();this.#u?.destroyPopup(),this.#v.clear(),this.#v.add(e),e.select(),this.#G(e.propertiesToUpdate),this.#T({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#v.values().next().value}unselect(e){e.unselect(),this.#v.delete(e),this.#T({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#r.undo(),this.#T({hasSomethingToUndo:this.#r.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#$()}),this._editorUndoBar?.hide()}redo(){this.#r.redo(),this.#T({hasSomethingToUndo:!0,hasSomethingToRedo:this.#r.hasSomethingToRedo(),isEmpty:this.#$()})}addCommands(e){this.#r.add(e),this.#T({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#$()})}cleanUndoStack(e){this.#r.cleanType(e)}#$(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let e of this.#n.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#v],a=()=>{this._editorUndoBar?.show(n,t.length===1?t[0].editorType:t.length);for(let s of t)s.remove()},n=()=>{for(let s of t)this.#ne(s)};this.addCommands({cmd:a,undo:n,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#se(e){for(let t of this.#v)t.unselect();this.#v.clear();for(let t of e){if(t.isEmpty())continue;this.#v.add(t),t.select()}this.#T({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#v)e.commit();this.#se(this.#n.values())}unselectAll(){if(this.#t){if(this.#t.commitOrRemove(),this.#C!==rt.NONE)return}if(this.#g?.commitOrRemove())return;if(this.#u?.destroyPopup(),!this.hasSelection)return;for(let e of this.#v)e.unselect();this.#v.clear(),this.#T({hasSelectedEditor:!1})}translateSelectedEditors(e,t,a=!1){if(!a)this.commitOrRemove();if(!this.hasSelection)return;this.#E[0]+=e,this.#E[1]+=t;let[n,s]=this.#E,i=[...this.#v],f=1000;if(this.#K)clearTimeout(this.#K);this.#K=setTimeout(()=>{this.#K=null,this.#E[0]=this.#E[1]=0,this.addCommands({cmd:()=>{for(let l of i)if(this.#n.has(l.id))l.translateInPage(n,s),l.translationDone()},undo:()=>{for(let l of i)if(this.#n.has(l.id))l.translateInPage(-n,-s),l.translationDone()},mustExec:!1})},f);for(let l of i)l.translateInPage(e,t),l.translationDone()}setUpDragSession(){if(!this.hasSelection)return;this.disableUserSelect(!0),this.#c=new Map;for(let e of this.#v)this.#c.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#c)return!1;this.disableUserSelect(!1);let e=this.#c;this.#c=null;let t=!1;for(let[{x:n,y:s,pageIndex:i},f]of e)f.newX=n,f.newY=s,f.newPageIndex=i,t||=n!==f.savedX||s!==f.savedY||i!==f.savedPageIndex;if(!t)return!1;let a=(n,s,i,f)=>{if(this.#n.has(n.id)){let l=this.#s.get(f);if(l)n._setParentAndPosition(l,s,i);else n.pageIndex=f,n.x=s,n.y=i}};return this.addCommands({cmd:()=>{for(let[n,{newX:s,newY:i,newPageIndex:f}]of e)a(n,s,i,f)},undo:()=>{for(let[n,{savedX:s,savedY:i,savedPageIndex:f}]of e)a(n,s,i,f)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(!this.#c)return;for(let a of this.#c.keys())a.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);if(t)t.changeParent(e),t.addOrRebuild(e);else this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild()}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#C}isEditingMode(){return this.#C!==rt.NONE}get imageManager(){return ft(this,"imageManager",new O8)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let c=0,h=t.rangeCount;c<h;c++)if(!e.contains(t.getRangeAt(c).commonAncestorContainer))return null;let{x:a,y:n,width:s,height:i}=e.getBoundingClientRect(),f;switch(e.getAttribute("data-main-rotation")){case"90":f=(c,h,u,g)=>({x:(h-n)/i,y:1-(c+u-a)/s,width:g/i,height:u/s});break;case"180":f=(c,h,u,g)=>({x:1-(c+u-a)/s,y:1-(h+g-n)/i,width:u/s,height:g/i});break;case"270":f=(c,h,u,g)=>({x:1-(h+g-n)/i,y:(c-a)/s,width:g/i,height:u/s});break;default:f=(c,h,u,g)=>({x:(c-a)/s,y:(h-n)/i,width:u/s,height:g/i});break}let l=[];for(let c=0,h=t.rangeCount;c<h;c++){let u=t.getRangeAt(c);if(u.collapsed)continue;for(let{x:g,y:b,width:d,height:j}of u.getClientRects()){if(d===0||j===0)continue;l.push(f(g,b,d,j))}}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#o||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#o?.delete(e)}renderAnnotationElement(e){let t=this.#o?.get(e.data.id);if(!t)return;let a=this.#l.getRawValue(t);if(!a)return;if(this.#C===rt.NONE&&!a.hasBeenModified)return;a.renderAnnotationElement(e)}setMissingCanvas(e,t,a){let n=this.#z?.get(e);if(!n)return;n.setCanvas(t,a),this.#z.delete(e)}addMissingCanvas(e,t){(this.#z||=new Map).set(e,t)}}class A0{#e=null;#t=!1;#a=null;#n=null;#s=null;#f=null;#i=!1;#l=null;#o=null;#r=null;#u=null;#h=!1;static#g=null;static _l10n=null;constructor(e){this.#o=e,this.#h=e._uiManager.useNewAltTextFlow,A0.#g||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){A0._l10n??=e}async render(){let e=this.#a=document.createElement("button");e.className="altText",e.tabIndex="0";let t=this.#n=document.createElement("span");if(e.append(t),this.#h)e.classList.add("new"),e.setAttribute("data-l10n-id",A0.#g.missing),t.setAttribute("data-l10n-id",A0.#g["missing-label"]);else e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label");let a=this.#o._uiManager._signal;e.addEventListener("contextmenu",Ai,{signal:a}),e.addEventListener("pointerdown",(s)=>s.stopPropagation(),{signal:a});let n=(s)=>{if(s.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#h)this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#b}})};return e.addEventListener("click",n,{capture:!0,signal:a}),e.addEventListener("keydown",(s)=>{if(s.target===e&&s.key==="Enter")this.#i=!0,n(s)},{signal:a}),await this.#p(),e}get#b(){return this.#e&&"added"||this.#e===null&&this.guessedText&&"review"||"missing"}finish(){if(!this.#a)return;this.#a.focus({focusVisible:this.#i}),this.#i=!1}isEmpty(){if(this.#h)return this.#e===null;return!this.#e&&!this.#t}hasData(){if(this.#h)return this.#e!==null||!!this.#r;return this.isEmpty()}get guessedText(){return this.#r}async setGuessedText(e){if(this.#e!==null)return;this.#r=e,this.#u=await A0._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#p()}toggleAltTextBadge(e=!1){if(!this.#h||this.#e){this.#l?.remove(),this.#l=null;return}if(!this.#l){let t=this.#l=document.createElement("div");t.className="noAltTextBadge",this.#o.div.append(t)}this.#l.classList.toggle("hidden",!e)}serialize(e){let t=this.#e;if(!e&&this.#r===t)t=this.#u;return{altText:t,decorative:this.#t,guessedText:this.#r,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:a,textWithDisclaimer:n,cancel:s=!1}){if(a)this.#r=a,this.#u=n;if(this.#e===e&&this.#t===t)return;if(!s)this.#e=e,this.#t=t;this.#p()}toggle(e=!1){if(!this.#a)return;if(!e&&this.#f)clearTimeout(this.#f),this.#f=null;this.#a.disabled=!e}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#b}})}destroy(){this.#a?.remove(),this.#a=null,this.#n=null,this.#s=null,this.#l?.remove(),this.#l=null}async#p(){let e=this.#a;if(!e)return;if(this.#h){if(e.classList.toggle("done",!!this.#e),e.setAttribute("data-l10n-id",A0.#g[this.#b]),this.#n?.setAttribute("data-l10n-id",A0.#g[`${this.#b}-label`]),!this.#e){this.#s?.remove();return}}else{if(!this.#e&&!this.#t){e.classList.remove("done"),this.#s?.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=this.#s;if(!t){this.#s=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${this.#o.id}`;let n=100,s=this.#o._uiManager._signal;s.addEventListener("abort",()=>{clearTimeout(this.#f),this.#f=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#f=setTimeout(()=>{this.#f=null,this.#s.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:s}),e.addEventListener("mouseleave",()=>{if(this.#f)clearTimeout(this.#f),this.#f=null;this.#s?.classList.remove("show")},{signal:s})}if(this.#t)t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else t.removeAttribute("data-l10n-id"),t.textContent=this.#e;if(!t.parentNode)e.append(t);this.#o.getElementForAltText()?.setAttribute("aria-describedby",t.id)}}class l2{#e=null;#t=null;#a=!1;#n=null;#s=null;#f=null;#i=null;#l=null;#o=!1;#r=null;constructor(e){this.#n=e}renderForToolbar(){let e=this.#t=document.createElement("button");return e.className="comment",this.#u(e,!1)}renderForStandalone(){let e=this.#e=document.createElement("button");e.className="annotationCommentButton";let t=this.#n.commentButtonPosition;if(t){let{style:a}=e;a.insetInlineEnd=`calc(${100*(this.#n._uiManager.direction==="ltr"?1-t[0]:t[0])}% - var(--comment-button-dim))`,a.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let n=this.#n.commentButtonColor;if(n)a.backgroundColor=n}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;let e=this.#n.commentButtonColor;if(e)this.#e.style.backgroundColor=e;this.#n._uiManager.updatePopupColor(this.#n)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#n.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#r)return this.#r;if(!this.#e)return null;let{x:e,y:t,height:a}=this.#e.getBoundingClientRect(),{x:n,y:s,width:i,height:f}=this.#n.parent.boundingClientRect;return[(e-n)/i,(t+a-s)/f]}set commentPopupPositionInLayer(e){this.#r=e}hasDefaultPopupPosition(){return this.#r===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:t}){if(!this.#e)return;this.#e.classList.toggle("selected",e),this.#e.ariaExpanded=t}#u(e,t){if(!this.#n._uiManager.hasCommentManager())return null;if(e.tabIndex="0",e.ariaHasPopup="dialog",t)e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button");else e.ariaControlsElements=[this.#n._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button");let a=this.#n._uiManager._signal;if(!(a instanceof AbortSignal)||a.aborted)return e;if(e.addEventListener("contextmenu",Ai,{signal:a}),t)e.addEventListener("focusin",(s)=>{this.#n._focusEventsAllowed=!1,Ha(s)},{capture:!0,signal:a}),e.addEventListener("focusout",(s)=>{this.#n._focusEventsAllowed=!0,Ha(s)},{capture:!0,signal:a});e.addEventListener("pointerdown",(s)=>s.stopPropagation(),{signal:a});let n=(s)=>{if(s.preventDefault(),e===this.#t)this.edit();else this.#n.toggleComment(!0)};return e.addEventListener("click",n,{capture:!0,signal:a}),e.addEventListener("keydown",(s)=>{if(s.target===e&&s.key==="Enter")this.#a=!0,n(s)},{signal:a}),e.addEventListener("pointerenter",()=>{this.#n.toggleComment(!1,!0)},{signal:a}),e.addEventListener("pointerleave",()=>{this.#n.toggleComment(!1,!1)},{signal:a}),e}edit(e){let t=this.commentPopupPositionInLayer,a,n;if(t)[a,n]=t;else{[a,n]=this.#n.commentButtonPosition;let{width:h,height:u,x:g,y:b}=this.#n;a=g+a*h,n=b+n*u}let s=this.#n.parent.boundingClientRect,{x:i,y:f,width:l,height:c}=s;this.#n._uiManager.editComment(this.#n,i+a*l,f+n*c,{...e,parentDimensions:s})}finish(){if(!this.#t)return;this.#t.focus({focusVisible:this.#a}),this.#a=!1}isDeleted(){return this.#o||this.#i===""}isEmpty(){return this.#i===null}hasBeenEdited(){return this.isDeleted()||this.#i!==this.#s}serialize(){return this.data}get data(){return{text:this.#i,richText:this.#f,date:this.#l,deleted:this.isDeleted()}}set data(e){if(e!==this.#i)this.#f=null;if(e===null){this.#i="",this.#o=!0;return}this.#i=e,this.#l=new Date,this.#o=!1}restoreData({text:e,richText:t,date:a}){this.#i=e,this.#f=t,this.#l=a,this.#o=!1}setInitialText(e,t=null){this.#s=e,this.data=e,this.#l=null,this.#f=t}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#i="",this.#f=null,this.#l=null,this.#n=null,this.#a=!1,this.#o=!1}}class N5{#e;#t=!1;#a=null;#n;#s;#f;#i;#l=null;#o;#r=null;#u;#h=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:a=null,onPinchStart:n=null,onPinching:s=null,onPinchEnd:i=null,signal:f}){this.#e=e,this.#a=a,this.#n=t,this.#s=n,this.#f=s,this.#i=i,this.#u=new AbortController,this.#o=AbortSignal.any([f,this.#u.signal]),e.addEventListener("touchstart",this.#g.bind(this),{passive:!1,signal:this.#o})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/y0.pixelRatio}#g(e){if(this.#n?.())return;if(e.touches.length===1){if(this.#l)return;let n=this.#l=new AbortController,s=AbortSignal.any([this.#o,n.signal]),i=this.#e,f={capture:!0,signal:s,passive:!1},l=(c)=>{if(c.pointerType==="touch")this.#l?.abort(),this.#l=null};i.addEventListener("pointerdown",(c)=>{if(c.pointerType==="touch")Ha(c),l(c)},f),i.addEventListener("pointerup",l,f),i.addEventListener("pointercancel",l,f);return}if(!this.#h){this.#h=new AbortController;let n=AbortSignal.any([this.#o,this.#h.signal]),s=this.#e,i={signal:n,capture:!1,passive:!1};s.addEventListener("touchmove",this.#b.bind(this),i);let f=this.#p.bind(this);s.addEventListener("touchend",f,i),s.addEventListener("touchcancel",f,i),i.capture=!0,s.addEventListener("pointerdown",Ha,i),s.addEventListener("pointermove",Ha,i),s.addEventListener("pointercancel",Ha,i),s.addEventListener("pointerup",Ha,i),this.#s?.()}if(Ha(e),e.touches.length!==2||this.#a?.()){this.#r=null;return}let[t,a]=e.touches;if(t.identifier>a.identifier)[t,a]=[a,t];this.#r={touch0X:t.screenX,touch0Y:t.screenY,touch1X:a.screenX,touch1Y:a.screenY}}#b(e){if(!this.#r||e.touches.length!==2)return;Ha(e);let[t,a]=e.touches;if(t.identifier>a.identifier)[t,a]=[a,t];let{screenX:n,screenY:s}=t,{screenX:i,screenY:f}=a,l=this.#r,{touch0X:c,touch0Y:h,touch1X:u,touch1Y:g}=l,b=u-c,d=g-h,j=i-n,A=f-s,C=Math.hypot(j,A)||1,y=Math.hypot(b,d)||1;if(!this.#t&&Math.abs(y-C)<=N5.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=s,l.touch1X=i,l.touch1Y=f,!this.#t){this.#t=!0;return}let O=[(n+i)/2,(s+f)/2];this.#f?.(O,y,C)}#p(e){if(e.touches.length>=2)return;if(this.#h)this.#h.abort(),this.#h=null,this.#i?.();if(!this.#r)return;Ha(e),this.#r=null,this.#t=!1}destroy(){this.#u?.abort(),this.#u=null,this.#l?.abort(),this.#l=null}}class Ve{#e=null;#t=null;#a=null;#n=null;#s=null;#f=!1;#i=null;#l="";#o=null;#r=null;#u=null;#h=null;#g=null;#b="";#p=!1;#c=null;#m=!1;#d=!1;#j=!1;#w=null;#A=0;#y=0;#q=null;#S=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#k=!1;#_=Ve._zIndex++;static _borderLineWidth=-1;static _colorManager=new B8;static _zIndex=1;static _telemetryTimeout=1000;static get _resizerKeyboardManager(){let e=Ve.prototype._resizeWithKeyboard,t=Al.TRANSLATE_SMALL,a=Al.TRANSLATE_BIG;return ft(this,"_resizerKeyboardManager",new Qs([[["ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-a,0]}],[["ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[a,0]}],[["ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-a]}],[["ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,a]}],[["Escape"],Ve.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;let{rotation:t,rawDims:{pageWidth:a,pageHeight:n,pageX:s,pageY:i}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[a,n],this.pageTranslation=[s,i];let[f,l]=this.parentDimensions;this.x=e.x/f,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return ft(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new sy({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(Ve._l10n??=e,Ve._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),Ve._l10nResizer??=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),Ve._borderLineWidth!==-1)return;let a=getComputedStyle(document.documentElement);Ve._borderLineWidth=parseFloat(a.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Et("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#k}set _isDraggable(e){this.#k=e,this.div?.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#_}setParent(e){if(e!==null)this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions;else this.#E(),this.#h?.remove(),this.#h=null;this.parent=e}focusin(e){if(!this._focusEventsAllowed)return;if(!this.#p)this.parent.setSelected(this);else this.#p=!1}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;if(e.relatedTarget?.closest(`#${this.id}`))return;if(e.preventDefault(),!this.parent?.isMultipleSelection)this.commitOrRemove()}commitOrRemove(){if(this.isEmpty())this.remove();else this.commit()}commit(){if(!this.isInEditMode())return;this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,a,n){let[s,i]=this.parentDimensions;[a,n]=this.screenToPageTranslation(a,n),this.x=(e+a)/s,this.y=(t+n)/i,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[a,n]=this.parentDimensions;this.setAt(e*a,t*n,this.width*a,this.height*n),this._onTranslated()}#O([e,t],a,n){[a,n]=this.screenToPageTranslation(a,n),this.x+=a/e,this.y+=n/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#O(this.parentDimensions,e,t)}translateInPage(e,t){this.#c||=[this.x,this.y,this.width,this.height],this.#O(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){this.#c||=[this.x,this.y,this.width,this.height];let{div:a,parentDimensions:[n,s]}=this;if(this.x+=e/n,this.y+=t/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:u,y:g}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,u,g))this.x-=Math.floor(this.x),this.y-=Math.floor(this.y)}let{x:i,y:f}=this,[l,c]=this.getBaseTranslation();i+=l,f+=c;let{style:h}=a;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*f).toFixed(2)}%`,this._onTranslating(i,f),a.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){let[e,t]=this.parentDimensions,{_borderLineWidth:a}=Ve,n=a/e,s=a/t;switch(this.rotation){case 90:return[-n,s];case 180:return[n,s];case 270:return[n,-s];default:return[-n,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[a,n]}=this,{x:s,y:i,width:f,height:l}=this;if(f*=a,l*=n,s*=a,i*=n,this._mustFixPosition)switch(e){case 0:s=da(s,0,a-f),i=da(i,0,n-l);break;case 90:s=da(s,0,a-l),i=da(i,f,n);break;case 180:s=da(s,f,a),i=da(i,l,n);break;case 270:s=da(s,l,a),i=da(i,0,n-f);break}this.x=s/=a,this.y=i/=n;let[c,h]=this.getBaseTranslation();s+=c,i+=h,t.left=`${(100*s).toFixed(2)}%`,t.top=`${(100*i).toFixed(2)}%`,this.moveInDOM()}static#B(e,t,a){switch(a){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return Ve.#B(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return Ve.#B(e,t,360-this.parentRotation)}#F(e){switch(e){case 90:{let[t,a]=this.pageDimensions;return[0,-t/a,a/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,a]=this.pageDimensions;return[0,t/a,-a/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,a]}=this;return[t*e,a*e]}setDims(){let{div:{style:e},width:t,height:a}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*a).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#M(){if(this.#o)return;this.#o=document.createElement("div"),this.#o.classList.add("resizers");let e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(let a of e){let n=document.createElement("div");this.#o.append(n),n.classList.add("resizer",a),n.setAttribute("data-resizer-name",a),n.addEventListener("pointerdown",this.#D.bind(this,a),{signal:t}),n.addEventListener("contextmenu",Ai,{signal:t}),n.tabIndex=-1}this.div.prepend(this.#o)}#D(e,t){t.preventDefault();let{isMac:a}=ea.platform;if(t.button!==0||t.ctrlKey&&a)return;this.#a?.toggle(!1);let n=this._isDraggable;this._isDraggable=!1,this.#r=[t.screenX,t.screenY];let s=new AbortController,i=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#N.bind(this,e),{passive:!0,capture:!0,signal:i}),window.addEventListener("touchmove",Ha,{passive:!1,signal:i}),window.addEventListener("contextmenu",Ai,{signal:i}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let f=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#a?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=f,this.div.style.cursor=l,this.#x()};window.addEventListener("pointerup",c,{signal:i}),window.addEventListener("blur",c,{signal:i})}#H(e,t,a,n){this.width=a,this.height=n,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#x(){if(!this.#u)return;let{savedX:e,savedY:t,savedWidth:a,savedHeight:n}=this.#u;this.#u=null;let s=this.x,i=this.y,f=this.width,l=this.height;if(s===e&&i===t&&f===a&&l===n)return;this.addCommands({cmd:this.#H.bind(this,s,i,f,l),undo:this.#H.bind(this,e,t,a,n),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#N(e,t){let[a,n]=this.parentDimensions,s=this.x,i=this.y,f=this.width,l=this.height,c=Ve.MIN_SIZE/a,h=Ve.MIN_SIZE/n,u=this.#F(this.rotation),g=(L,J)=>[u[0]*L+u[2]*J,u[1]*L+u[3]*J],b=this.#F(360-this.rotation),d=(L,J)=>[b[0]*L+b[2]*J,b[1]*L+b[3]*J],j,A,C=!1,y=!1;switch(e){case"topLeft":C=!0,j=(L,J)=>[0,0],A=(L,J)=>[L,J];break;case"topMiddle":j=(L,J)=>[L/2,0],A=(L,J)=>[L/2,J];break;case"topRight":C=!0,j=(L,J)=>[L,0],A=(L,J)=>[0,J];break;case"middleRight":y=!0,j=(L,J)=>[L,J/2],A=(L,J)=>[0,J/2];break;case"bottomRight":C=!0,j=(L,J)=>[L,J],A=(L,J)=>[0,0];break;case"bottomMiddle":j=(L,J)=>[L/2,J],A=(L,J)=>[L/2,0];break;case"bottomLeft":C=!0,j=(L,J)=>[0,J],A=(L,J)=>[L,0];break;case"middleLeft":y=!0,j=(L,J)=>[0,J/2],A=(L,J)=>[L,J/2];break}let O=j(f,l),T=A(f,l),M=g(...T),H=Ve._round(s+M[0]),N=Ve._round(i+M[1]),x=1,z=1,K,$;if(!t.fromKeyboard){let{screenX:L,screenY:J}=t,[pe,ne]=this.#r;[K,$]=this.screenToPageTranslation(L-pe,J-ne),this.#r[0]=L,this.#r[1]=J}else({deltaX:K,deltaY:$}=t);if([K,$]=d(K/a,$/n),C){let L=Math.hypot(f,l);x=z=Math.max(Math.min(Math.hypot(T[0]-O[0]-K,T[1]-O[1]-$)/L,1/f,1/l),c/f,h/l)}else if(y)x=da(Math.abs(T[0]-O[0]-K),c,1)/f;else z=da(Math.abs(T[1]-O[1]-$),h,1)/l;let Q=Ve._round(f*x),P=Ve._round(l*z);M=g(...A(Q,P));let te=H-M[0],ee=N-M[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=Q,this.height=P,this.x=te,this.y=ee,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#a?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#d)return this._editToolbar;this._editToolbar=new o2(this),this.div.append(this._editToolbar.render());let{toolbarButtons:e}=this;if(e)for(let[t,a]of e)await this._editToolbar.addButton(t,a);if(!this.hasComment)this._editToolbar.addButton("comment",this.addCommentButton());return this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#a?.destroy()}addContainer(e){let t=this._editToolbar?.div;if(t)t.before(e);else this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!this.#a){if(A0.initialize(Ve._l10n),this.#a=new A0(this),this.#e)this.#a.data=this.#e,this.#e=null}return this.#a}get altTextData(){return this.#a?.data}set altTextData(e){if(!this.#a)return;this.#a.data=e}get guessedAltText(){return this.#a?.guessedText}async setGuessedAltText(e){await this.#a?.setGuessedText(e)}serializeAltText(e){return this.#a?.serialize(e)}hasAltText(){return!!this.#a&&!this.#a.isEmpty()}hasAltTextData(){return this.#a?.hasData()??!1}focusCommentButton(){this.#n?.focusButton()}addCommentButton(){return this.canAddComment?this.#n||=new l2(this):null}addStandaloneCommentButton(){if(!this._uiManager.hasCommentManager())return;if(this.#s){if(this._uiManager.isEditingMode())this.#s.classList.remove("hidden");return}if(!this.hasComment)return;this.#s=this.#n.renderForStandalone(),this.div.append(this.#s)}removeStandaloneCommentButton(){this.#n.removeStandaloneCommentButton(),this.#s=null}hideStandaloneCommentButton(){this.#s?.classList.add("hidden")}get comment(){if(!this.#n)return null;let{data:{richText:e,text:t,date:a,deleted:n}}=this.#n;return{text:t,richText:e,date:a,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){if(this.#n||=new l2(this),typeof e==="object"&&e!==null)this.#n.restoreData(e);else this.#n.data=e;if(this.hasComment)this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this);else this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this)}setCommentData({comment:e,popupRef:t,richText:a}){if(!t)return;if(this.#n||=new l2(this),this.#n.setInitialText(e,a),!this.annotationElementId)return;let n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);if(n)this.updateFromAnnotationLayer(n)}get hasEditedComment(){return this.#n?.hasBeenEdited()}get hasDeletedComment(){return this.#n?.isDeleted()}get hasComment(){return!!this.#n&&!this.#n.isEmpty()&&!this.#n.isDeleted()}async editComment(e){this.#n||=new l2(this),this.#n.edit(e)}toggleComment(e,t=void 0){if(this.hasComment)this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){this.#n.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,n]=e.rect,[s]=this.pageDimensions,[i]=this.pageTranslation,f=i+s+1,l=n-100,c=f+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[f,l,c,n]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){this.#n.data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let e=this.div=document.createElement("div");if(e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=this.#f?-1:0,e.setAttribute("role","application"),this.defaultL10nId)e.setAttribute("data-l10n-id",this.defaultL10nId);if(!this._isVisible)e.classList.add("hidden");this.setInForeground(),this.#I();let[t,a]=this.parentDimensions;if(this.parentRotation%180!==0)e.style.maxWidth=`${(100*a/t).toFixed(2)}%`,e.style.maxHeight=`${(100*t/a).toFixed(2)}%`;let[n,s]=this.getInitialTranslation();if(this.translate(n,s),ty(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom)this.#S||=new N5({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#z.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#C.bind(this),signal:this._uiManager._signal});return this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#z(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#a?.toggle(!1),this.parent.togglePointerEvents(!1)}#L(e,t,a){let s=0.7*(a/t)+1-0.7;if(s===1)return;let i=this.#F(this.rotation),f=(H,N)=>[i[0]*H+i[2]*N,i[1]*H+i[3]*N],[l,c]=this.parentDimensions,h=this.x,u=this.y,g=this.width,b=this.height,d=Ve.MIN_SIZE/l,j=Ve.MIN_SIZE/c;s=Math.max(Math.min(s,1/g,1/b),d/g,j/b);let A=Ve._round(g*s),C=Ve._round(b*s);if(A===g&&C===b)return;this.#c||=[h,u,g,b];let y=f(g/2,b/2),O=Ve._round(h+y[0]),T=Ve._round(u+y[1]),M=f(A/2,C/2);this.x=O-M[0],this.y=T-M[1],this.width=A,this.height=C,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#C(){this.#a?.toggle(!0),this.parent.togglePointerEvents(!0),this.#x()}pointerdown(e){let{isMac:t}=ea.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#p=!0,this._isDraggable){this.#R(e);return}this.#v(e)}#v(e){let{isMac:t}=ea.platform;if(e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t)this.parent.toggleSelected(this);else this.parent.setSelected(this)}#R(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let a=!1,n=new AbortController,s=this._uiManager.combinedSignal(n),i={capture:!0,passive:!1,signal:s},f=(c)=>{if(n.abort(),this.#i=null,this.#p=!1,!this._uiManager.endDragSession())this.#v(c);if(a)this._onStopDragging()};if(t)this.#A=e.clientX,this.#y=e.clientY,this.#i=e.pointerId,this.#l=e.pointerType,window.addEventListener("pointermove",(c)=>{if(!a)a=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging();let{clientX:h,clientY:u,pointerId:g}=c;if(g!==this.#i){Ha(c);return}let[b,d]=this.screenToPageTranslation(h-this.#A,u-this.#y);this.#A=h,this.#y=u,this._uiManager.dragSelectedEditors(b,d)},i),window.addEventListener("touchmove",Ha,i),window.addEventListener("pointerdown",(c)=>{if(c.pointerType===this.#l){if(this.#S||c.isPrimary)f(c)}Ha(c)},i);let l=(c)=>{if(!this.#i||this.#i===c.pointerId){f(c);return}Ha(c)};window.addEventListener("pointerup",l,{signal:s}),window.addEventListener("blur",l,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){if(this.#w)clearTimeout(this.#w);this.#w=setTimeout(()=>{this.#w=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,a){e.changeParent(this),this.x=t,this.y=a,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,a=this.rotation){let n=this.parentScale,[s,i]=this.pageDimensions,[f,l]=this.pageTranslation,c=e/n,h=t/n,u=this.x*s,g=this.y*i,b=this.width*s,d=this.height*i;switch(a){case 0:return[u+c+f,i-g-h-d+l,u+c+b+f,i-g-h+l];case 90:return[u+h+f,i-g+c+l,u+h+d+f,i-g+c+b+l];case 180:return[u-c-b+f,i-g+h+l,u-c+f,i-g+h+d+l];case 270:return[u-h-d+f,i-g-c-b+l,u-h+f,i-g-c+l];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[a,n,s,i]=e,f=s-a,l=i-n;switch(this.rotation){case 0:return[a,t-i,f,l];case 90:return[a,t-n,l,f];case 180:return[s,t-n,f,l];case 270:return[s,t-i,l,f];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Ve._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#n?.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:a,opacity:n,deleted:s,richText:i},uid:f,pageIndex:l,creationDate:c,modificationDate:h}=this;return{id:f,pageIndex:l,rect:this.getPDFRect(),richText:i,contentsObj:{str:e},creationDate:c,modificationDate:a||h,popupRef:!s,color:t,opacity:n}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;return this.parent.setEditingState(!1),this.#d=!0,!0}disableEditMode(){if(!this.isInEditMode())return!1;return this.parent.setEditingState(!0),this.#d=!1,!0}isInEditMode(){return this.#d}shouldGetKeyboardEvents(){return this.#j}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:a,right:n}=this.getClientDimensions(),{innerHeight:s,innerWidth:i}=window;return t<i&&n>0&&e<s&&a>0}#I(){if(this.#g||!this.div)return;this.#g=new AbortController;let e=this._uiManager.combinedSignal(this.#g);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#I()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(e,t,a){let n=new this.prototype.constructor({parent:t,id:a.getId(),uiManager:a,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});n.rotation=e.rotation,n.#e=e.accessibilityData,n._isCopy=e.isCopy||!1;let[s,i]=n.pageDimensions,[f,l,c,h]=n.getRectInCurrentCoords(e.rect,i);return n.x=f/s,n.y=l/i,n.width=c/s,n.height=h/i,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#g?.abort(),this.#g=null,!this.isEmpty())this.commit();if(this.parent)this.parent.remove(this);else this._uiManager.removeEditor(this);if(this.hideCommentPopup(),this.#w)clearTimeout(this.#w),this.#w=null;if(this.#E(),this.removeEditToolbar(),this.#q){for(let e of this.#q.values())clearTimeout(e);this.#q=null}this.parent=null,this.#S?.destroy(),this.#S=null,this.#h?.remove(),this.#h=null}get isResizable(){return!1}makeResizable(){if(this.isResizable)this.#M(),this.#o.classList.remove("hidden")}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[e,t]}=this,[a,n,s,i]=this.getPDFRect();return[Ve._round(a+(s-a)*e),Ve._round(n+(i-n)*(1-t))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#n.commentPopupPositionInLayer}set commentPopupPosition(e){this.#n.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#n.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#n.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#n?.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let t=this.#o.children;if(!this.#t){this.#t=Array.from(t);let i=this.#X.bind(this),f=this.#Q.bind(this),l=this._uiManager._signal;for(let c of this.#t){let h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",i,{signal:l}),c.addEventListener("blur",f,{signal:l}),c.addEventListener("focus",this.#Y.bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",Ve._l10nResizer[h])}}let a=this.#t[0],n=0;for(let i of t){if(i===a)break;n++}let s=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(s!==n){if(s<n)for(let f=0;f<n-s;f++)this.#o.append(this.#o.firstElementChild);else if(s>n)for(let f=0;f<s-n;f++)this.#o.firstElementChild.before(this.#o.lastElementChild);let i=0;for(let f of t){let c=this.#t[i++].getAttribute("data-resizer-name");f.setAttribute("data-l10n-id",Ve._l10nResizer[c])}}this.#J(0),this.#j=!0,this.#o.firstElementChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#X(e){Ve._resizerKeyboardManager.exec(this,e)}#Q(e){if(this.#j&&e.relatedTarget?.parentNode!==this.#o)this.#E()}#Y(e){this.#b=this.#j?e:""}#J(e){if(!this.#t)return;for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){if(!this.#j)return;this.#N(this.#b,{deltaX:e,deltaY:t,fromKeyboard:!0})}#E(){this.#j=!1,this.#J(-1),this.#x()}_stopResizingWithKeyboard(){this.#E(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{if(this.div?.classList.contains("selectedEditor"))this._editToolbar?.show()});return}this._editToolbar?.show(),this.#a?.toggleAltTextBadge(!1)}focus(){if(this.div&&!this.div.contains(document.activeElement))setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(!this.isSelected)return;if(this.isSelected=!1,this.#o?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement))this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide(),this.#a?.toggleAltTextBadge(!0),this.hideCommentPopup()}hideCommentPopup(){if(this.hasComment)this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(!this.canChangeContent)return;this.enableEditMode(),this.div.focus()}dblclick(e){if(e.target.nodeName==="BUTTON")return;this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#m}set isEditing(e){if(this.#m=e,!this.parent)return;if(e)this.parent.setSelected(this),this.parent.setActiveEditor(this);else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#q||=new Map;let{action:a}=e,n=this.#q.get(a);if(n)clearTimeout(n);n=setTimeout(()=>{if(this._reportTelemetry(e),this.#q.delete(a),this.#q.size===0)this.#q=null},Ve._telemetryTimeout),this.#q.set(a,n);return}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){if(this.div)this.div.tabIndex=0;this.#f=!1}disable(){if(this.div)this.div.tabIndex=-1;this.#f=!0}updateFakeAnnotationElement(e){if(!this.#h&&!this.deleted){this.#h=e.addFakeAnnotation(this);return}if(this.deleted){this.#h.remove(),this.#h=null;return}if(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)this.#h.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(".annotationContent");if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){let a=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),a.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;if(t?.nodeName==="DIV"&&t.classList.contains("annotationContent"))t.remove()}}class sy extends Ve{constructor(e){super(e);this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var _A=3285377520,ji=4294901760,q0=65535;class y5{constructor(e){this.h1=e?e&4294967295:_A,this.h2=e?e&4294967295:_A}update(e){let t,a;if(typeof e==="string"){t=new Uint8Array(e.length*2),a=0;for(let j=0,A=e.length;j<A;j++){let C=e.charCodeAt(j);if(C<=255)t[a++]=C;else t[a++]=C>>>8,t[a++]=C&255}}else if(ArrayBuffer.isView(e))t=e.slice(),a=t.byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let n=a>>2,s=a-n*4,i=new Uint32Array(t.buffer,0,n),f=0,l=0,c=this.h1,h=this.h2,u=3432918353,g=461845907,b=u&q0,d=g&q0;for(let j=0;j<n;j++)if(j&1)f=i[j],f=f*u&ji|f*b&q0,f=f<<15|f>>>17,f=f*g&ji|f*d&q0,c^=f,c=c<<13|c>>>19,c=c*5+3864292196;else l=i[j],l=l*u&ji|l*b&q0,l=l<<15|l>>>17,l=l*g&ji|l*d&q0,h^=l,h=h<<13|h>>>19,h=h*5+3864292196;switch(f=0,s){case 3:f^=t[n*4+2]<<16;case 2:f^=t[n*4+1]<<8;case 1:if(f^=t[n*4],f=f*u&ji|f*b&q0,f=f<<15|f>>>17,f=f*g&ji|f*d&q0,n&1)c^=f;else h^=f}this.h1=c,this.h2=h}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&ji|e*36045&q0,t=t*4283543511&ji|((t<<16|e>>>16)*2950163797&ji)>>>16,e^=t>>>1,e=e*444984403&ji|e*60499&q0,t=t*3301882366&ji|((t<<16|e>>>16)*3120437893&ji)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}var m2=Object.freeze({map:null,hash:"",transfer:void 0});class E5{#e=!1;#t=null;#a=null;#n=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,t){let a=this.#n.get(e);if(a===void 0)return t;return Object.assign(t,a)}getRawValue(e){return this.#n.get(e)}remove(e){let t=this.#n.get(e);if(t===void 0)return;if(t instanceof Ve)this.#a.delete(t.annotationElementId);if(this.#n.delete(e),this.#n.size===0)this.resetModified();if(this.#n.values().some((a)=>a instanceof Ve))return;this.onAnnotationEditor?.(null)}setValue(e,t){let a=this.#n.get(e),n=!1;if(a!==void 0){for(let[s,i]of Object.entries(t))if(a[s]!==i)n=!0,a[s]=i}else n=!0,this.#n.set(e,t);if(n)this.#s();if(t instanceof Ve)(this.#a||=new Map).set(t.annotationElementId,t),this.onAnnotationEditor?.(t.constructor._type)}has(e){return this.#n.has(e)}get size(){return this.#n.size}#s(){if(!this.#e)this.#e=!0,this.onSetModified?.()}resetModified(){if(this.#e)this.#e=!1,this.onResetModified?.()}get print(){return new T8(this)}get serializable(){if(this.#n.size===0)return m2;let e=new Map,t=new y5,a=[],n=Object.create(null),s=!1;for(let[i,f]of this.#n){let l=f instanceof Ve?f.serialize(!1,n):f;if(f.page)f.pageIndex=f.page._pageIndex,delete f.page;if(l)e.set(i,l),t.update(`${i}:${JSON.stringify(l)}`),s||=!!l.bitmap}if(s){for(let i of e.values())if(i.bitmap)a.push(i.bitmap)}return e.size>0?{map:e,hash:t.hexdigest(),transfer:a}:m2}get editorStats(){let e=null,t=new Map,a=0,n=0;for(let s of this.#n.values()){if(!(s instanceof Ve)){if(s.popup)if(s.popup.deleted)n+=1;else a+=1;continue}if(s.isCommentDeleted)n+=1;else if(s.hasEditedComment)a+=1;let i=s.telemetryFinalData;if(!i)continue;let{type:f}=i;t.getOrInsertComputed(f,()=>Object.getPrototypeOf(s).constructor),e||=Object.create(null);let l=e[f]||=new Map;for(let[c,h]of Object.entries(i)){if(c==="type")continue;let u=l.getOrInsertComputed(c,S8);u.set(h,(u.get(h)??0)+1)}}if(n>0||a>0)e||=Object.create(null),e.comments={deleted:n,edited:a};if(!e)return null;for(let[s,i]of t)e[s]=i.computeTelemetryFinalData(e[s]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,t){let a=this.#a?.get(e);if(a)return a.updateFromAnnotationLayer(t),!0;return!1}getEditor(e){return this.#a?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;let e=[];if(this.#a)for(let a of this.#a.values()){if(!a.serialize())continue;e.push(a.annotationElementId)}let t="";if(e.length){let a=new y5;a.update(e.join(",")),t=a.hexdigest()}return this.#t={ids:new Set(e),hash:t}}[Symbol.iterator](){return this.#n.entries()}}class T8 extends E5{#e=m2;constructor(e){super();let{serializable:t}=e;if(t===m2)return;let{map:a,hash:n,transfer:s}=t,i=structuredClone(a,s?{transfer:s}:null);this.#e={map:i,hash:n,transfer:[]}}get print(){Et("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#e}get modifiedIds(){return ft(this,"modifiedIds",{ids:new Set,hash:""})}}var Eo="__forcedDependency",{floor:FA,ceil:OA}=Math;function BA(e,t,a,n,s,i){e[t*4+0]=Math.min(e[t*4+0],a),e[t*4+1]=Math.min(e[t*4+1],n),e[t*4+2]=Math.max(e[t*4+2],s),e[t*4+3]=Math.max(e[t*4+3],i)}function TE(e,t,a,n,s){let i;if(e){if(e<0)i=s[0],s[0]=s[2],s[2]=i;if(s[0]*=e,s[2]*=e,t<0)i=s[1],s[1]=s[3],s[3]=i;s[1]*=t,s[3]*=t}else s.fill(0);s[0]+=a,s[1]+=n,s[2]+=a,s[3]+=n}var q8=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class iy{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===q8}minX(e){return this.#t[e*4+0]/256}minY(e){return this.#t[e*4+1]/256}maxX(e){return(this.#t[e*4+2]+1)/256}maxY(e){return(this.#t[e*4+3]+1)/256}}var TA=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class fy{#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#a=new Float64Array(mf);_pendingBBoxIdx=-1;#n;#s;#f;#i;_savesStack=[];_markedContentStack=[];constructor(e,t){this.#n=e.width,this.#s=e.height,this.#l(t)}growOperationsCount(e){if(e>=this.#i.length)this.#l(e,this.#i)}#l(e,t){let a=new ArrayBuffer(e*4);if(this.#f=new Uint8ClampedArray(a),this.#i=new Uint32Array(a),t&&t.length>0)this.#i.set(t),this.#i.fill(q8,t.length);else this.#i.fill(q8)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,t){let a=Object.getPrototypeOf(this.#t);if(a===null)return this;this.#t=a;let n=this._savesStack.pop();if(n!==void 0)t?.(n,e),this.#i[e]=this.#i[n];return this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){if(this._savesStack.length===0)return null;return this._savesStack.at(-1)}recordCloseMarker(e,t){let a=this._savesStack.pop();if(a!==void 0)t?.(a,e),this.#i[e]=this.#i[a];return this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let a=this._markedContentStack.pop();if(a!==void 0)t?.(a,e),this.#i[e]=this.#i[a];return this}pushBaseTransform(e){return this.#e.push(Fe.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){if(this.#e.length>1)this.#e.pop();return this}resetBBox(e){if(this._pendingBBoxIdx!==e)this._pendingBBoxIdx=e,this.#a.set(mf,0);return this}recordClipBox(e,t,a,n,s,i){let f=Fe.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform()),l=mf.slice();Fe.axialAlignedBoundingBox([a,s,n,i],f,l);let c=Fe.intersect(this.#t,l);if(c)this.#t[0]=c[0],this.#t[1]=c[1],this.#t[2]=c[2],this.#t[3]=c[3];else this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0;return this}recordBBox(e,t,a,n,s,i){let f=this.#t;if(f[0]===1/0)return this;let l=Fe.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform());if(f[0]===-1/0)return Fe.axialAlignedBoundingBox([a,s,n,i],l,this.#a),this;let c=mf.slice();return Fe.axialAlignedBoundingBox([a,s,n,i],l,c),this.#a[0]=da(c[0],f[0],this.#a[0]),this.#a[1]=da(c[1],f[1],this.#a[1]),this.#a[2]=da(c[2],this.#a[2],f[2]),this.#a[3]=da(c[3],this.#a[3],f[3]),this}recordFullPageBBox(e){return this.#a[0]=Math.max(0,this.#t[0]),this.#a[1]=Math.max(0,this.#t[1]),this.#a[2]=Math.min(this.#n,this.#t[2]),this.#a[3]=Math.min(this.#s,this.#t[3]),this}recordOperation(e,t=!1,a){if(this._pendingBBoxIdx!==e)return this;let n=FA(this.#a[0]*256/this.#n),s=FA(this.#a[1]*256/this.#s),i=OA(this.#a[2]*256/this.#n),f=OA(this.#a[3]*256/this.#s);if(BA(this.#f,e,n,s,i,f),a){for(let l of a)for(let c of l)if(c!==e)BA(this.#f,c,n,s,i,f)}if(!t)this._pendingBBoxIdx=-1;return this}bboxToClipBoxDropOperation(e){if(this._pendingBBoxIdx===e)this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#a[0]),this.#t[1]=Math.max(this.#t[1],this.#a[1]),this.#t[2]=Math.min(this.#t[2],this.#a[2]),this.#t[3]=Math.min(this.#t[3],this.#a[3]);return this}take(){return new iy(this.#i,this.#f)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,a){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,a,n=1,s=0,i=0,f){return this}getSimpleIndex(e){return}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}}class ly{#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[Eo]:[]};#a=new Map;#n=new Set;#s=new Map;#f;#i;#l;constructor(e,t=!1){if(this.#l=e,t)this.#f=new Map,this.#i=(a,n)=>{TA(this.#f,n).dependencies.add(a)}}get clipBox(){return this.#l.clipBox}growOperationsCount(e){this.#l.growOperationsCount(e)}save(e){return this.#e={__proto__:this.#e},this.#t={__proto__:this.#t,transform:{__proto__:this.#t.transform},moveText:{__proto__:this.#t.moveText},sameLineText:{__proto__:this.#t.sameLineText},[Eo]:{__proto__:this.#t[Eo]}},this.#l.save(e),this}restore(e){this.#l.restore(e,this.#i);let t=Object.getPrototypeOf(this.#e);if(t===null)return this;return this.#e=t,this.#t=Object.getPrototypeOf(this.#t),this}recordOpenMarker(e){return this.#l.recordOpenMarker(e,this.#i),this}getOpenMarker(){return this.#l.getOpenMarker()}recordCloseMarker(e){return this.#l.recordCloseMarker(e,this.#i),this}beginMarkedContent(e){return this.#l.beginMarkedContent(e),this}endMarkedContent(e){return this.#l.endMarkedContent(e,this.#i),this}pushBaseTransform(e){return this.#l.pushBaseTransform(e),this}popBaseTransform(){return this.#l.popBaseTransform(),this}recordSimpleData(e,t){return this.#e[e]=t,this}recordIncrementalData(e,t){return this.#t[e].push(t),this}resetIncrementalData(e,t){return this.#t[e].length=0,this}recordNamedData(e,t){return this.#a.set(e,t),this}recordSimpleDataFromNamed(e,t,a){this.#e[e]=this.#a.get(t)??a}recordFutureForcedDependency(e,t){return this.recordIncrementalData(Eo,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)if(t in this.#e)this.recordFutureForcedDependency(t,this.#e[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of this.#n)this.recordFutureForcedDependency(Eo,e);return this}resetBBox(e){return this.#l.resetBBox(e),this}recordClipBox(e,t,a,n,s,i){return this.#l.recordClipBox(e,t,a,n,s,i),this}recordBBox(e,t,a,n,s,i){return this.#l.recordBBox(e,t,a,n,s,i),this}recordCharacterBBox(e,t,a,n=1,s=0,i=0,f){let l=a.bbox,c,h;if(l){if(c=l[2]!==l[0]&&l[3]!==l[1]&&this.#s.get(a),c!==!1){if(h=[0,0,0,0],Fe.axialAlignedBoundingBox(l,a.fontMatrix,h),n!==1||s!==0||i!==0)TE(n,-n,s,i,h);if(c)return this.recordBBox(e,t,h[0],h[2],h[1],h[3])}}if(!f)return this.recordFullPageBBox(e);let u=f();if(l&&h&&c===void 0){if(c=h[0]<=s-u.actualBoundingBoxLeft&&h[2]>=s+u.actualBoundingBoxRight&&h[1]<=i-u.actualBoundingBoxAscent&&h[3]>=i+u.actualBoundingBoxDescent,this.#s.set(a,c),c)return this.recordBBox(e,t,h[0],h[2],h[1],h[3])}return this.recordBBox(e,t,s-u.actualBoundingBoxLeft,s+u.actualBoundingBoxRight,i-u.actualBoundingBoxAscent,i+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#l.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,t){let a=this.#n,n=this.#e,s=this.#t;for(let i of t)if(i in this.#e)a.add(n[i]);else if(i in s)s[i].forEach(a.add,a);return this}recordNamedDependency(e,t){if(this.#a.has(t))this.#n.add(this.#a.get(t));return this}recordOperation(e,t=!1){if(this.recordDependencies(e,[Eo]),this.#f){let n=TA(this.#f,e),{dependencies:s}=n;this.#n.forEach(s.add,s),this.#l._savesStack.forEach(s.add,s),this.#l._markedContentStack.forEach(s.add,s),s.delete(e),n.isRenderingOperation=!0}let a=!t&&e===this.#l._pendingBBoxIdx;if(this.#l.recordOperation(e,t,[this.#n,this.#l._savesStack,this.#l._markedContentStack]),a)this.#n.clear();return this}recordShowTextOperation(e,t=!1){let a=Array.from(this.#n);this.recordOperation(e,t),this.recordIncrementalData("sameLineText",e);for(let n of a)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(e,t=!1){let a=!t&&e===this.#l._pendingBBoxIdx;if(this.#l.bboxToClipBoxDropOperation(e),a)this.#n.clear();return this}take(){return this.#s.clear(),this.#l.take()}takeDebugMetadata(){return this.#f}}class g2{#e;#t;#a;#n=0;#s=0;constructor(e,t,a){if(e instanceof g2&&e.#a===!!a)return e;this.#e=e,this.#t=t,this.#a=!!a}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw Error("Unreachable")}save(e){return this.#s++,this.#e.save(this.#t),this}restore(e){if(this.#s>0)this.#e.restore(this.#t),this.#s--;return this}recordOpenMarker(e){return this.#n++,this}getOpenMarker(){return this.#n>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#n--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return this.#e.pushBaseTransform(e),this}popBaseTransform(){return this.#e.popBaseTransform(),this}recordSimpleData(e,t){return this.#e.recordSimpleData(e,this.#t),this}recordIncrementalData(e,t){return this.#e.recordIncrementalData(e,this.#t),this}resetIncrementalData(e,t){return this.#e.resetIncrementalData(e,this.#t),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,a){return this.#e.recordSimpleDataFromNamed(e,t,this.#t),this}recordFutureForcedDependency(e,t){return this.#e.recordFutureForcedDependency(e,this.#t),this}inheritSimpleDataAsFutureForcedDependencies(e){return this.#e.inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#e.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){if(!this.#a)this.#e.resetBBox(this.#t);return this}recordClipBox(e,t,a,n,s,i){if(!this.#a)this.#e.recordClipBox(this.#t,t,a,n,s,i);return this}recordBBox(e,t,a,n,s,i){if(!this.#a)this.#e.recordBBox(this.#t,t,a,n,s,i);return this}recordCharacterBBox(e,t,a,n,s,i,f){if(!this.#a)this.#e.recordCharacterBBox(this.#t,t,a,n,s,i,f);return this}recordFullPageBBox(e){if(!this.#a)this.#e.recordFullPageBBox(this.#t);return this}getSimpleIndex(e){return this.#e.getSimpleIndex(e)}recordDependencies(e,t){return this.#e.recordDependencies(this.#t,t),this}recordNamedDependency(e,t){return this.#e.recordNamedDependency(this.#t,t),this}recordOperation(e){return this.#e.recordOperation(this.#t,!0),this}recordShowTextOperation(e){return this.#e.recordShowTextOperation(this.#t,!0),this}bboxToClipBoxDropOperation(e){if(!this.#a)this.#e.bboxToClipBoxDropOperation(this.#t,!0);return this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}var qi={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class S5{#e;#t;#a=4;#n=0;#s=new S5.#f(this.#a*6);static#f=ea.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(e,t,a,n){if(this.#n===this.#a){this.#a*=2;let f=new S5.#f(this.#a*6);f.set(this.#s),this.#s=f}let s=ma(e),i;if(n[0]!==1/0){let f=mf.slice();Fe.axialAlignedBoundingBox([0,-a,t,0],s,f);let l=Fe.intersect(n,f);if(!l)return;let[c,h,u,g]=l;if(c!==f[0]||h!==f[1]||u!==f[2]||g!==f[3]){let b=Math.atan2(s[1],s[0]),d=Math.abs(Math.sin(b)),j=Math.abs(Math.cos(b));if(d<0.000001||j<0.000001||Math.abs(d-j)<0.000001)i=[c,h,c,g,u,h];else{let A=u-c,C=g-h,y=d*d,O=j*j,T=j*d,M=O-y,H=(C*O-A*T)/M,N=(C*T-A*y)/M;i=[c+N,h,c,h+H,u,g-H]}}}if(!i)i=[0,-a,0,0,t,-a],Fe.applyTransform(i,s,0),Fe.applyTransform(i,s,2),Fe.applyTransform(i,s,4);i[0]/=this.#e,i[1]/=this.#t,i[2]/=this.#e,i[3]/=this.#t,i[4]/=this.#e,i[5]/=this.#t,this.#s.set(i,this.#n*6),this.#n++}take(){return this.#s.subarray(0,this.#n*6)}}class ry{#e=new Set;#t=null;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){let t=this.#a();t.insertRule(e,t.cssRules.length)}#a(){if(this.#t)return this.#t;let e=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&e){let{adoptedStyleSheets:t}=this._document;if(t){let a=new e;return t.push(a),this.#t=a}}if(!this.styleElement)this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);return this.#t=this.styleElement.sheet}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),this.#e.clear(),this.#t){let{adoptedStyleSheets:e}=this._document;if(e?.includes(this.#t))this._document.adoptedStyleSheets=e.filter((t)=>t!==this.#t);this.#t=null}if(this.styleElement)this.styleElement.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:a}){if(!e||this.#e.has(e.loadedName))return;if(Ma(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:s,style:i}=e,f=new FontFace(n,s,i);this.addNativeFontFace(f);try{await f.load(),this.#e.add(n),a?.(e)}catch{ot(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(f)}return}Et("Not implemented: loadSystemFont without the Font Loading API.")}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let a=e.createNativeFontFace();if(a){this.addNativeFontFace(a);try{await a.loaded}catch(n){throw ot(`Failed to load font '${a.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise((a)=>{let n=this._queueLoadingCallback(a);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return ft(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return ft(this,"isSyncFontLoadingSupported",Js||ea.platform.isFirefox)}_queueLoadingCallback(e){function t(){Ma(!n.done,"completeRequest() cannot be called twice."),n.done=!0;while(a.length>0&&a[0].done){let s=a.shift();setTimeout(s.callback,0)}}let{loadingRequests:a}=this,n={done:!1,complete:t,callback:e};return a.push(n),n}get _loadTestFont(){let e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return ft(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function a(M,H){return M.charCodeAt(H)<<24|M.charCodeAt(H+1)<<16|M.charCodeAt(H+2)<<8|M.charCodeAt(H+3)&255}function n(M){return String.fromCharCode(M>>24&255,M>>16&255,M>>8&255,M&255)}function s(M,H,N,x){let z=M.substring(0,H),K=M.substring(H+N);return z+x+K}let i,f,l=this._document.createElement("canvas");l.width=1,l.height=1;let c=l.getContext("2d"),h=0;function u(M,H){if(++h>30){ot("Load test font never loaded."),H();return}if(c.font="30px "+M,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){H();return}setTimeout(u.bind(null,M,H))}let g=`lt${Date.now()}${this.loadTestFontId++}`,b=this._loadTestFont;b=s(b,976,g.length,g);let j=16,A=1482184792,C=a(b,j);for(i=0,f=g.length-3;i<f;i+=4)C=C-A+a(g,i)|0;if(i<g.length)C=C-A+a(g+"XXX",i)|0;b=s(b,j,4,n(C));let y=`url(data:font/opentype;base64,${btoa(b)});`,O=`@font-face {font-family:"${g}";src:${y}}`;this.insertRule(O);let T=this._document.createElement("div");T.style.visibility="hidden",T.style.width=T.style.height="10px",T.style.position="absolute",T.style.top=T.style.left="0px";for(let M of[e.loadedName,g]){let H=this._document.createElement("span");H.textContent="Hi",H.style.fontFamily=M,T.append(H)}this._document.body.append(T),u(g,()=>{T.remove(),t.complete()})}}class oy{compiledGlyphs=Object.create(null);#e;constructor(e,t=null,a,n){if(this.#e=e,this._inspectFont=t,a)this.charProcOperatorList=a;if(n)Object.assign(this,n)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};if(this.cssFontInfo.italicAngle)t.style=`oblique ${this.cssFontInfo.italicAngle}deg`;e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;if(this.cssFontInfo.italicAngle)a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let a=this.loadedName+"_path_"+t,n;try{n=e.get(a)}catch(i){ot(`getPathGenerator - ignoring character: "${i}".`)}let s=PA(n?.path);if(!this.fontExtraProperties)e.delete(a);return this.compiledGlyphs[t]=s}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){ft(this,"disableFontFace",!!e)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get ascent(){return this.#e.ascent}get defaultWidth(){return this.#e.defaultWidth}get descent(){return this.#e.descent}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.#e.mimetype}get name(){return this.#e.name}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}get defaultVMetrics(){return this.#e.defaultVMetrics}}class cy{static strings=["fontFamily","fontWeight","italicAngle"]}class hy{static strings=["css","loadedName","baseFontName","src"]}class vi{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class vl{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class uy{#e;#t=new TextDecoder;#a;constructor(e){this.#e=e,this.#a=new DataView(e)}#n(e){Ma(e<cy.strings.length,"Invalid string index");let t=0;for(let n=0;n<e;n++)t+=this.#a.getUint32(t)+4;let a=this.#a.getUint32(t);return this.#t.decode(new Uint8Array(this.#e,t+4,a))}get fontFamily(){return this.#n(0)}get fontWeight(){return this.#n(1)}get italicAngle(){return this.#n(2)}}class my{#e;#t=new TextDecoder;#a;constructor(e){this.#e=e,this.#a=new DataView(e)}get guessFallback(){return this.#a.getUint8(0)!==0}#n(e){Ma(e<hy.strings.length,"Invalid string index");let t=5;for(let n=0;n<e;n++)t+=this.#a.getUint32(t)+4;let a=this.#a.getUint32(t);return this.#t.decode(new Uint8Array(this.#e,t+4,a))}get css(){return this.#n(0)}get loadedName(){return this.#n(1)}get baseFontName(){return this.#n(2)}get src(){return this.#n(3)}get style(){let e=1;e+=4+this.#a.getUint32(e);let t=this.#a.getUint32(e),a=this.#t.decode(new Uint8Array(this.#e,e+4,t));e+=4+t;let n=this.#a.getUint32(e),s=this.#t.decode(new Uint8Array(this.#e,e+4,n));return{style:a,weight:s}}}class gy{#e;#t=new TextDecoder;#a;constructor({buffer:e,extra:t}){if(this.#e=e,this.#a=new DataView(e),t)Object.assign(this,t)}#n(e){Ma(e<vi.bools.length,"Invalid boolean index");let t=Math.floor(e/4),a=e*2%8,n=this.#a.getUint8(t)>>a&3;return n===0?void 0:n===2}get black(){return this.#n(0)}get bold(){return this.#n(1)}get disableFontFace(){return this.#n(2)}get fontExtraProperties(){return this.#n(3)}get isInvalidPDFjsFont(){return this.#n(4)}get isType3Font(){return this.#n(5)}get italic(){return this.#n(6)}get missingFile(){return this.#n(7)}get remeasure(){return this.#n(8)}get vertical(){return this.#n(9)}#s(e){return Ma(e<vi.numbers.length,"Invalid number index"),this.#a.getFloat64(vi.OFFSET_NUMBERS+e*8)}get ascent(){return this.#s(0)}get defaultWidth(){return this.#s(1)}get descent(){return this.#s(2)}#f(e,t,a,n){let s=this.#a.getUint8(e);if(s===0)return;Ma(s===t,"Invalid array length."),e+=1;let i=Array(s);for(let f=0;f<s;f++)i[f]=this.#a[a](e,!0),e+=n;return i}get bbox(){return this.#f(vi.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#f(vi.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#f(vi.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#i(e){Ma(e<vi.strings.length,"Invalid string index");let t=vi.OFFSET_STRINGS+4;for(let n=0;n<e;n++)t+=this.#a.getUint32(t)+4;let a=this.#a.getUint32(t);return this.#t.decode(new Uint8Array(this.#e,t+4,a))}get fallbackName(){return this.#i(0)}get loadedName(){return this.#i(1)}get mimetype(){return this.#i(2)}get name(){return this.#i(3)}#l(){let e=vi.OFFSET_STRINGS,t=this.#a.getUint32(e);e+=4+t;let a=this.#a.getUint32(e);e+=4+a;let n=this.#a.getUint32(e);e+=4+n;let s=this.#a.getUint32(e);return{offset:e,length:s}}get data(){let{offset:e,length:t}=this.#l();return t===0?void 0:new Uint8Array(this.#e,e+4,t)}clearData(){let{offset:e,length:t}=this.#l();if(t===0)return;this.#a.setUint32(e,0),this.#e=new Uint8Array(this.#e,0,e+4).slice().buffer,this.#a=new DataView(this.#e)}get cssFontInfo(){let e=vi.OFFSET_STRINGS,t=this.#a.getUint32(e);e+=4+t;let a=this.#a.getUint32(e);e+=4+a;let n=this.#a.getUint32(e);if(n===0)return null;let s=new Uint8Array(n);return s.set(new Uint8Array(this.#e,e+4,n)),new uy(s.buffer)}get systemFontInfo(){let e=vi.OFFSET_STRINGS,t=this.#a.getUint32(e);e+=4+t;let a=this.#a.getUint32(e);if(a===0)return null;let n=new Uint8Array(a);return n.set(new Uint8Array(this.#e,e+4,a)),new my(n.buffer)}}class py{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){let e=this.view,t=this.data[vl.KIND],a=!!this.data[vl.HAS_BBOX],n=!!this.data[vl.HAS_BACKGROUND],s=e.getUint32(vl.N_COORD,!0),i=e.getUint32(vl.N_COLOR,!0),f=e.getUint32(vl.N_STOP,!0),l=20,c=new Float32Array(this.buffer,l,s*2);l+=s*8;let h=new Uint8Array(this.buffer,l,i*4);l+=i*4;let u=[];for(let d=0;d<f;++d){let j=e.getFloat32(l,!0);l+=4;let A=e.getUint32(l,!0);l+=4,u.push([j,`#${A.toString(16).padStart(6,"0")}`])}let g=null;if(a){g=[];for(let d=0;d<4;++d)g.push(e.getFloat32(l,!0)),l+=4}let b=null;if(n)b=new Uint8Array(this.buffer,l,3),l+=3;if(t===1)return["RadialAxial","axial",g,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(t===2)return["RadialAxial","radial",g,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(t===3){let d=this.data[vl.SHADING_TYPE],j=null;if(c.length>0){j=mf.slice();for(let A=0,C=c.length;A<C;A+=2)Fe.pointBoundingBox(c[A],c[A+1],j)}return["Mesh",d,c,h,s,j,g,b]}throw Error(`Unsupported pattern kind: ${t}`)}}class by{#e;constructor(e){this.#e=e}get path(){if(ea.isFloat16ArraySupported)return new Float16Array(this.#e);return new Float32Array(this.#e)}}function HE(e){if(e instanceof URL)return e;if(typeof e==="string"){if(Js){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);let a=process.getBuiltinModule("url");return new URL(a.pathToFileURL(e))}let t=URL.parse(e,window.location);if(t)return t}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function ME(e){if(Js&&typeof Buffer<"u"&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==="string")return D5(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==="object"&&!isNaN(e?.length))return new Uint8Array(e);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function o5(e){if(typeof e!=="string")return null;if(e.endsWith("/"))return e;throw Error(`Invalid factory url: "${e}" must include trailing slash.`)}var v8=(e)=>typeof e==="object"&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,DE=(e)=>typeof e==="object"&&typeof e?.name==="string",xE=yE.bind(null,v8,DE);class wy{#e=new Map;#t=Promise.resolve();postMessage(e,t){let a={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[n]of this.#e)n.call(this,a)})}addEventListener(e,t,a=null){let n=null;if(a?.signal instanceof AbortSignal){let{signal:s}=a;if(s.aborted){ot("LoopbackPort - cannot use an `aborted` signal.");return}let i=()=>this.removeEventListener(e,t);n=()=>s.removeEventListener("abort",i),s.addEventListener("abort",i)}this.#e.set(t,n)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}}var c5={DATA:1,ERROR:2},an={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function HA(){}function _s(e){if(e instanceof pf||e instanceof k5||e instanceof v5||e instanceof h2||e instanceof d5)return e;if(!(e instanceof Error||typeof e==="object"&&e!==null))Et('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(e.name){case"AbortException":return new pf(e.message);case"InvalidPDFException":return new k5(e.message);case"PasswordException":return new v5(e.message,e.code);case"ResponseException":return new h2(e.message,e.status,e.missing);case"UnknownErrorException":return new d5(e.message,e.details)}return new d5(e.message,e.toString())}class Io{#e=new AbortController;constructor(e,t,a){this.sourceName=e,this.targetName=t,this.comObj=a,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),a.addEventListener("message",this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#n(e);return}if(e.callback){let a=e.callbackId,n=this.callbackCapabilities[a];if(!n)throw Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],e.callback===c5.DATA)n.resolve(e.data);else if(e.callback===c5.ERROR)n.reject(_s(e.reason));else throw Error("Unexpected callback case");return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let a=this.sourceName,n=e.sourceName,s=this.comObj;Promise.try(t,e.data).then(function(i){s.postMessage({sourceName:a,targetName:n,callback:c5.DATA,callbackId:e.callbackId,data:i})},function(i){s.postMessage({sourceName:a,targetName:n,callback:c5.ERROR,callbackId:e.callbackId,reason:_s(i)})});return}if(e.streamId){this.#a(e);return}t(e.data)}on(e,t){let a=this.actionHandler;if(a[e])throw Error(`There is already an actionName called "${e}"`);a[e]=t}send(e,t,a){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},a)}sendWithPromise(e,t,a){let n=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[n]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:n,data:t},a)}catch(i){s.reject(i)}return s.promise}sendWithStream(e,t,a,n){let s=this.streamId++,i=this.sourceName,f=this.targetName,l=this.comObj;return new ReadableStream({start:(c)=>{let h=Promise.withResolvers();return this.streamControllers[s]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:i,targetName:f,action:e,streamId:s,data:t,desiredSize:c.desiredSize},n),h.promise},pull:(c)=>{let h=Promise.withResolvers();return this.streamControllers[s].pullCall=h,l.postMessage({sourceName:i,targetName:f,stream:an.PULL,streamId:s,desiredSize:c.desiredSize}),h.promise},cancel:(c)=>{Ma(c instanceof Error,"cancel must have a valid reason");let h=Promise.withResolvers();return this.streamControllers[s].cancelCall=h,this.streamControllers[s].isClosed=!0,l.postMessage({sourceName:i,targetName:f,stream:an.CANCEL,streamId:s,reason:_s(c)}),h.promise}},a)}#a(e){let t=e.streamId,a=this.sourceName,n=e.sourceName,s=this.comObj,i=this,f=this.actionHandler[e.action],l={enqueue(c,h=1,u){if(this.isCancelled)return;let g=this.desiredSize;if(this.desiredSize-=h,g>0&&this.desiredSize<=0)this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise;s.postMessage({sourceName:a,targetName:n,stream:an.ENQUEUE,streamId:t,chunk:c},u)},close(){if(this.isCancelled)return;this.isCancelled=!0,s.postMessage({sourceName:a,targetName:n,stream:an.CLOSE,streamId:t}),delete i.streamSinks[t]},error(c){if(Ma(c instanceof Error,"error must have a valid reason"),this.isCancelled)return;this.isCancelled=!0,s.postMessage({sourceName:a,targetName:n,stream:an.ERROR,streamId:t,reason:_s(c)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,Promise.try(f,e.data,l).then(function(){s.postMessage({sourceName:a,targetName:n,stream:an.START_COMPLETE,streamId:t,success:!0})},function(c){s.postMessage({sourceName:a,targetName:n,stream:an.START_COMPLETE,streamId:t,reason:_s(c)})})}#n(e){let t=e.streamId,a=this.sourceName,n=e.sourceName,s=this.comObj,i=this.streamControllers[t],f=this.streamSinks[t];switch(e.stream){case an.START_COMPLETE:if(e.success)i.startCall.resolve();else i.startCall.reject(_s(e.reason));break;case an.PULL_COMPLETE:if(e.success)i.pullCall.resolve();else i.pullCall.reject(_s(e.reason));break;case an.PULL:if(!f){s.postMessage({sourceName:a,targetName:n,stream:an.PULL_COMPLETE,streamId:t,success:!0});break}if(f.desiredSize<=0&&e.desiredSize>0)f.sinkCapability.resolve();f.desiredSize=e.desiredSize,Promise.try(f.onPull||HA).then(function(){s.postMessage({sourceName:a,targetName:n,stream:an.PULL_COMPLETE,streamId:t,success:!0})},function(c){s.postMessage({sourceName:a,targetName:n,stream:an.PULL_COMPLETE,streamId:t,reason:_s(c)})});break;case an.ENQUEUE:if(Ma(i,"enqueue should have stream controller"),i.isClosed)break;i.controller.enqueue(e.chunk);break;case an.CLOSE:if(Ma(i,"close should have stream controller"),i.isClosed)break;i.isClosed=!0,i.controller.close(),this.#s(i,t);break;case an.ERROR:Ma(i,"error should have stream controller"),i.controller.error(_s(e.reason)),this.#s(i,t);break;case an.CANCEL_COMPLETE:if(e.success)i.cancelCall.resolve();else i.cancelCall.reject(_s(e.reason));this.#s(i,t);break;case an.CANCEL:if(!f)break;let l=_s(e.reason);Promise.try(f.onCancel||HA,l).then(function(){s.postMessage({sourceName:a,targetName:n,stream:an.CANCEL_COMPLETE,streamId:t,success:!0})},function(c){s.postMessage({sourceName:a,targetName:n,stream:an.CANCEL_COMPLETE,streamId:t,reason:_s(c)})}),f.sinkCapability.reject(l),f.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error("Unexpected stream case")}}async#s(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}}class H8{#e=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:a=null}){this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=a}async fetch({kind:e,filename:t}){switch(e){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:Et(`Not implemented: ${e}`)}let a=this[e];if(!a)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let n=`${a}${t}`;return this._fetch(n,e).catch((s)=>{throw Error(`Unable to load ${this.#e[e]} data at: ${n}`)})}async _fetch(e,t){Et("Abstract method `_fetch` called.")}}class k8 extends H8{async _fetch(e,t){let a=t==="cMapUrl"&&!e.endsWith(".bcmap")?"text":"bytes",n=await _8(e,a);return n instanceof Uint8Array?n:D5(n)}}class M8{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error("Invalid canvas size");let a=this._createCanvas(e,t);return{canvas:a,context:a.getContext("2d",{willReadFrequently:!this.#e})}}reset({canvas:e},t,a){if(!e)throw Error("Canvas is not specified");if(t<=0||a<=0)throw Error("Invalid canvas size");e.width=t,e.height=a}destroy(e){let{canvas:t}=e;if(!t)throw Error("Canvas is not specified");t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Et("Abstract method `_createCanvas` called.")}}class dy extends M8{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t});this._document=e}_createCanvas(e,t){let a=this._document.createElement("canvas");return a.width=e,a.height=t,a}}class D8{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addKnockoutFilter(e=0){return"none"}addHighlightHCMFilter(e,t,a,n,s){return"none"}addSelectionHCMFilter(e,t){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(e=null){return null}destroy(e=!1){}}class jy extends D8{#e;#t;#a;#n;#s;#f;#i=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super();this.#n=e,this.#s=t}get#l(){return this.#t||=new Map}get#o(){return this.#f||=new Map}get#r(){if(!this.#a){let e=this.#s.createElement("div"),{style:t}=e;t.colorScheme="only light",t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let a=this.#s.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width",0),a.setAttribute("height",0),this.#a=this.#s.createElementNS("http://www.w3.org/2000/svg","defs"),e.append(a),a.append(this.#a),this.#s.body.append(e)}return this.#a}#u(e){if(e.length===1){let l=e[0],c=Array(256);for(let u=0;u<256;u++)c[u]=l[u]/255;let h=c.join(",");return[h,h,h]}let[t,a,n]=e,s=Array(256),i=Array(256),f=Array(256);for(let l=0;l<256;l++)s[l]=t[l]/255,i[l]=a[l]/255,f[l]=n[l]/255;return[s.join(","),i.join(","),f.join(",")]}#h(e){if(this.#e===void 0){this.#e="";let t=this.#s.URL;if(t!==this.#s.baseURI)if(R5(t))ot('#createUrl: ignore "data:"-URL for performance reasons.');else this.#e=YA(t,"")}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return"none";let t=this.#l.get(e);if(t)return t;let[a,n,s]=this.#u(e),i=e.length===1?a:`${a}${n}${s}`;if(t=this.#l.get(i),t)return this.#l.set(e,t),t;let f=`g_${this.#n}_transfer_map_${this.#i++}`,l=this.#h(f);this.#l.set(e,l),this.#l.set(i,l);let c=this.#p(f);return this.#m(a,n,s,c),l}addHCMFilter(e,t){let a=`${e}-${t}`,n="base",s=this.#o.get("base");if(s?.key===a)return s.url;if(s)s.filter?.remove(),s.key=a,s.url="none",s.filter=null;else s={key:a,url:"none",filter:null},this.#o.set("base",s);if(!e||!t)return s.url;let i=this.#j(e);e=Fe.makeHexColor(...i);let f=this.#j(t);if(t=Fe.makeHexColor(...f),this.#r.style.color="",e==="#000000"&&t==="#ffffff"||e===t)return s.url;let l=Array(256);for(let b=0;b<=255;b++){let d=b/255;l[b]=d<=0.03928?d/12.92:((d+0.055)/1.055)**2.4}let c=l.join(","),h=`g_${this.#n}_hcm_filter`,u=s.filter=this.#p(h);this.#m(c,c,c,u),this.#b(u);let g=(b,d)=>{let j=i[b]/255,A=f[b]/255,C=Array(d+1);for(let y=0;y<=d;y++)C[y]=j+y/d*(A-j);return C.join(",")};return this.#m(g(0,5),g(1,5),g(2,5),u),s.url=this.#h(h),s.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter("selection",e,t,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){let t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();if(t==="none"||!ea.platform.isFirefox)return null;return{"backdrop-filter":t,"background-color":"transparent"}}addAlphaFilter(e){let t=this.#l.get(e);if(t)return t;let[a]=this.#u([e]),n=`alpha_${a}`;if(t=this.#l.get(n),t)return this.#l.set(e,t),t;let s=`g_${this.#n}_alpha_map_${this.#i++}`,i=this.#h(s);this.#l.set(e,i),this.#l.set(n,i);let f=this.#p(s);return this.#d(a,f),i}addLuminosityFilter(e){let t=this.#l.get(e||"luminosity");if(t)return t;let a,n;if(e)[a]=this.#u([e]),n=`luminosity_${a}`;else n="luminosity";if(t=this.#l.get(n),t)return this.#l.set(e,t),t;let s=`g_${this.#n}_luminosity_map_${this.#i++}`,i=this.#h(s);this.#l.set(e,i),this.#l.set(n,i);let f=this.#p(s);if(this.#g(f),e)this.#d(a,f);return i}addKnockoutFilter(e=0){let t=e>0?Math.min(1/e,1e6):1e6,a=`knockout_${t}`,n=this.#l.get(a);if(n)return n;let s=`g_${this.#n}_knockout_filter_${this.#i++}`,i=this.#h(s);this.#l.set(a,i);let f=this.#p(s),l=this.#s.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer");f.append(l);let c=this.#s.createElementNS("http://www.w3.org/2000/svg","feFuncA");return c.setAttribute("type","linear"),c.setAttribute("slope",`${t}`),c.setAttribute("intercept","0"),l.append(c),i}addHighlightHCMFilter(e,t,a,n,s){let i=`${t}-${a}-${n}-${s}`,f=this.#o.get(e);if(f?.key===i)return f.url;if(f)f.filter?.remove(),f.key=i,f.url="none",f.filter=null;else f={key:i,url:"none",filter:null},this.#o.set(e,f);if(!t||!a)return f.url;let[l,c]=[t,a].map(this.#j.bind(this)),h=Math.round(0.2126*l[0]+0.7152*l[1]+0.0722*l[2]),u=Math.round(0.2126*c[0]+0.7152*c[1]+0.0722*c[2]),[g,b]=[n,s].map(this.#A.bind(this));if(u<h)[h,u,g,b]=[u,h,b,g];this.#r.style.color="";let d=(C,y,O)=>{let T=Array(256),M=(u-h)/O,H=C/255,N=(y-C)/(255*O),x=0;for(let z=0;z<=O;z++){let K=Math.round(h+z*M),$=H+z*N;for(let Q=x;Q<=K;Q++)T[Q]=$;x=K+1}for(let z=x;z<256;z++)T[z]=T[x-1];return T.join(",")},j=`g_${this.#n}_hcm_${e}_filter`,A=f.filter=this.#p(j);return this.#b(A),this.#m(d(g[0],b[0],5),d(g[1],b[1],5),d(g[2],b[2],5),A),f.url=this.#h(j),f.url}destroy(e=!1){if(e&&this.#f?.size)return;this.#a?.parentNode.parentNode.remove(),this.#a=null,this.#t?.clear(),this.#t=null,this.#f?.clear(),this.#f=null,this.#i=0}#g(e){let t=this.#s.createElementNS("http://www.w3.org/2000/svg","feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(t)}#b(e){let t=this.#s.createElementNS("http://www.w3.org/2000/svg","feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#p(e){let t=this.#s.createElementNS("http://www.w3.org/2000/svg","filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#r.append(t),t}#c(e,t,a){let n=this.#s.createElementNS("http://www.w3.org/2000/svg",t);n.setAttribute("type","discrete"),n.setAttribute("tableValues",a),e.append(n)}#m(e,t,a,n){let s=this.#s.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer");n.append(s),this.#c(s,"feFuncR",e),this.#c(s,"feFuncG",t),this.#c(s,"feFuncB",a)}#d(e,t){let a=this.#s.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer");t.append(a),this.#c(a,"feFuncA",e)}#j(e){return this.#r.style.color=e,q2(getComputedStyle(this.#r).getPropertyValue("color"))}#w(e){return this.#r.style.color=e,j2(getComputedStyle(this.#r).getPropertyValue("color"))}#A(e){let[t,a,n,s]=this.#w(e);if(s===1)return[t,a,n];let[i,f,l]=this.#j("Canvas");return[h8(t,i,s),h8(a,f,s),h8(n,l,s)]}}function h8(e,t,a){return Math.round(a*e+(1-a)*t)}if(Js)ot("Please use the `legacy` build in Node.js environments.");async function RE(e){let a=await process.getBuiltinModule("fs/promises").readFile(e);return new Uint8Array(a)}class qy extends D8{}class vy extends M8{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}class ky extends H8{async _fetch(e,t){return RE(e)}}function Ay({src:e,srcPos:t=0,dest:a,width:n,height:s,nonBlackColor:i=4294967295,inverseDecode:f=!1}){let l=ea.isLittleEndian?4278190080:255,[c,h]=f?[i,l]:[l,i],u=n>>3,g=n&7,b=c^h,d=e.length;a=new Uint32Array(a.buffer);let j=0;for(let A=0;A<s;++A){for(let y=t+u;t<y;++t,j+=8){let O=e[t];a[j]=c^-(O>>7&1)&b,a[j+1]=c^-(O>>6&1)&b,a[j+2]=c^-(O>>5&1)&b,a[j+3]=c^-(O>>4&1)&b,a[j+4]=c^-(O>>3&1)&b,a[j+5]=c^-(O>>2&1)&b,a[j+6]=c^-(O>>1&1)&b,a[j+7]=c^-(O&1)&b}if(g===0)continue;let C=t<d?e[t++]:255;for(let y=0;y<g;++y,++j)a[j]=c^-(C>>7-y&1)&b}return{srcPos:t,destPos:j}}function NE({src:e,srcPos:t=0,dest:a,destPos:n=0,width:s,height:i}){let f=0,l=s*i*3,c=l>>2,h=new Uint32Array(e.buffer,t,c),u=ea.isLittleEndian?4278190080:255;if(ea.isLittleEndian){for(;f<c-2;f+=3,n+=4){let g=h[f],b=h[f+1],d=h[f+2];a[n]=g|u,a[n+1]=g>>>24|b<<8|u,a[n+2]=b>>>16|d<<16|u,a[n+3]=d>>>8|u}for(let g=f*4,b=t+l;g<b;g+=3)a[n++]=e[g]|e[g+1]<<8|e[g+2]<<16|u}else{for(;f<c-2;f+=3,n+=4){let g=h[f],b=h[f+1],d=h[f+2];a[n]=g|u,a[n+1]=g<<24|b>>>8|u,a[n+2]=b<<16|d>>>16|u,a[n+3]=d<<8|u}for(let g=f*4,b=t+l;g<b;g+=3)a[n++]=e[g]<<24|e[g+1]<<16|e[g+2]<<8|u}return{srcPos:t+l,destPos:n}}var EE=`
254
+ struct Uniforms {
255
+ offsetX : f32,
256
+ offsetY : f32,
257
+ scaleX : f32,
258
+ scaleY : f32,
259
+ paddedWidth : f32,
260
+ paddedHeight : f32,
261
+ borderSize : f32,
262
+ _pad : f32,
263
+ };
264
+
265
+ @group(0) @binding(0) var<uniform> u : Uniforms;
266
+
267
+ struct VertexInput {
268
+ @location(0) position : vec2<f32>,
269
+ @location(1) color : vec4<f32>,
270
+ };
271
+
272
+ struct VertexOutput {
273
+ @builtin(position) position : vec4<f32>,
274
+ @location(0) color : vec3<f32>,
275
+ };
276
+
277
+ @vertex
278
+ fn vs_main(in : VertexInput) -> VertexOutput {
279
+ var out : VertexOutput;
280
+ let cx = (in.position.x + u.offsetX) * u.scaleX;
281
+ let cy = (in.position.y + u.offsetY) * u.scaleY;
282
+ out.position = vec4<f32>(
283
+ ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
284
+ 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
285
+ 0.0,
286
+ 1.0
287
+ );
288
+ out.color = in.color.rgb;
289
+ return out;
290
+ }
291
+
292
+ @fragment
293
+ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
294
+ return vec4<f32>(in.color, 1.0);
295
+ }
296
+ `;class yy{#e=null;#t=null;#a=null;#n=null;async#s(){if(!globalThis.navigator?.gpu)return!1;try{let e=await navigator.gpu.requestAdapter();if(!e)return!1;return this.#n=navigator.gpu.getPreferredCanvasFormat(),this.#t=await e.requestDevice(),!0}catch{return!1}}init(){return this.#e||=this.#s()}get isReady(){return this.#t!==null}loadMeshShader(){if(!this.#t||this.#a)return;let e=this.#t.createShaderModule({code:EE});this.#a=this.#t.createRenderPipeline({layout:"auto",vertex:{module:e,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:e,entryPoint:"fs_main",targets:[{format:this.#n}]},primitive:{topology:"triangle-list"}})}draw(e,t,a,n,s,i,f,l){this.loadMeshShader();let c=this.#t,{offsetX:h,offsetY:u,scaleX:g,scaleY:b}=n,d=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(e.byteLength>0)c.queue.writeBuffer(d,0,e);let j=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(t.byteLength>0)c.queue.writeBuffer(j,0,t);let A=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(A,0,new Float32Array([h,u,g,b,i,f,l,0]));let C=c.createBindGroup({layout:this.#a.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:A}}]}),y=new OffscreenCanvas(i,f),O=y.getContext("webgpu");O.configure({device:c,format:this.#n,alphaMode:s?"opaque":"premultiplied"});let T=s?{r:s[0]/255,g:s[1]/255,b:s[2]/255,a:1}:{r:0,g:0,b:0,a:0},M=c.createCommandEncoder(),H=M.beginRenderPass({colorAttachments:[{view:O.getCurrentTexture().createView(),clearValue:T,loadOp:"clear",storeOp:"store"}]});if(a>0)H.setPipeline(this.#a),H.setBindGroup(0,C),H.setVertexBuffer(0,d),H.setVertexBuffer(1,j),H.draw(a);return H.end(),c.queue.submit([M.finish()]),d.destroy(),j.destroy(),A.destroy(),y.transferToImageBitmap()}}var z5=new yy;function zE(){return z5.init()}function UE(){return z5.isReady}function IE(){z5.loadMeshShader()}function GE(e,t,a,n,s,i,f,l){return z5.draw(e,t,a,n,s,i,f,l)}var En={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function j5(e,t){if(!t)return;let a=t[2]-t[0],n=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],a,n),e.clip(s)}class U5{isModifyingCurrentTransform(){return!1}getPattern(){Et("Abstract method `getPattern` called.")}}class Sy extends U5{constructor(e){super();this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;let e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e,t=null){let a,n=this._p0,s=this._p1;if(t)n=n.slice(),s=s.slice(),Fe.applyTransform(n,t),Fe.applyTransform(s,t);if(this._type==="axial")a=e.createLinearGradient(n[0],n[1],s[0],s[1]);else if(this._type==="radial"){let i=this._r0,f=this._r1;if(t){let l=new Float32Array(2);Fe.singularValueDecompose2dScale(t,l),i*=l[0],f*=l[0]}a=e.createRadialGradient(n[0],n[1],i,s[0],s[1],f)}for(let i of this._colorStops)a.addColorStop(i[0],i[1]);return a}_createReversedGradient(e,t=null){let a=this._p1,n=this._p0;if(t)a=a.slice(),n=n.slice(),Fe.applyTransform(a,t),Fe.applyTransform(n,t);let s=this._r1,i=this._r0;if(t){let c=new Float32Array(2);Fe.singularValueDecompose2dScale(t,c),s*=c[0],i*=c[0]}let f=e.createRadialGradient(a[0],a[1],s,n[0],n[1],i),l=this._colorStops.map(([c,h])=>[1-c,h]).reverse();for(let[c,h]of l)f.addColorStop(c,h);return f}getPattern(e,t,a,n){let s;if(n===En.STROKE||n===En.FILL){if(this.isOriginBased()){let g=Fe.transform(a,t.baseTransform);if(this.matrix)g=Fe.transform(g,this.matrix);let b=0.001,d=Math.hypot(g[0],g[1]),j=Math.hypot(g[2],g[3]),A=(g[0]*g[2]+g[1]*g[3])/(d*j);if(Math.abs(A)<b)if(this.isRadial()){if(Math.abs(d-j)<b)return this._createGradient(e,g)}else return this._createGradient(e,g)}let i=t.current.getClippedPathBoundingBox(n,ma(e))||[0,0,0,0],f=Math.ceil(i[2]-i[0])||1,l=Math.ceil(i[3]-i[1])||1,c=t.canvasFactory.create(f,l),h=c.context;if(h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-i[0],-i[1]),a=Fe.transform(a,[1,0,0,1,i[0],i[1]]),h.transform(...t.baseTransform),this.matrix)h.transform(...this.matrix);if(j5(h,this._bbox),this.areConic())h.fillStyle=this._createReversedGradient(h),h.fill();h.fillStyle=this._createGradient(h),h.fill(),s=e.createPattern(c.canvas,"no-repeat"),t.canvasFactory.destroy(c);let u=new DOMMatrix(a);s.setTransform(u)}else{if(this.areConic())e.save(),j5(e,this._bbox),e.fillStyle=this._createReversedGradient(e),e.fillRect(-10000000000,-10000000000,20000000000,20000000000),e.restore();j5(e,this._bbox),s=this._createGradient(e)}return s}}function XE(e,t,a,n,s,i,f,l){let{coords:c,colors:h}=t,u=e.data,g=e.width*4,b;if(c[a*2+1]>c[n*2+1])b=a,a=n,n=b,b=i,i=f,f=b;if(c[n*2+1]>c[s*2+1])b=n,n=s,s=b,b=f,f=l,l=b;if(c[a*2+1]>c[n*2+1])b=a,a=n,n=b,b=i,i=f,f=b;let d=(c[a*2]+t.offsetX)*t.scaleX,j=(c[a*2+1]+t.offsetY)*t.scaleY,A=(c[n*2]+t.offsetX)*t.scaleX,C=(c[n*2+1]+t.offsetY)*t.scaleY,y=(c[s*2]+t.offsetX)*t.scaleX,O=(c[s*2+1]+t.offsetY)*t.scaleY;if(j>=O)return;let T=h[i*4],M=h[i*4+1],H=h[i*4+2],N=h[f*4],x=h[f*4+1],z=h[f*4+2],K=h[l*4],$=h[l*4+1],Q=h[l*4+2],P=Math.round(j),te=Math.round(O),ee,L,J,pe,ne,fe,Ae,he;for(let re=P;re<=te;re++){if(re<C){let Ie=re<j?0:(j-re)/(j-C);ee=d-(d-A)*Ie,L=T-(T-N)*Ie,J=M-(M-x)*Ie,pe=H-(H-z)*Ie}else{let Ie;if(re>O)Ie=1;else if(C===O)Ie=0;else Ie=(C-re)/(C-O);ee=A-(A-y)*Ie,L=N-(N-K)*Ie,J=x-(x-$)*Ie,pe=z-(z-Q)*Ie}let be;if(re<j)be=0;else if(re>O)be=1;else be=(j-re)/(j-O);ne=d-(d-y)*be,fe=T-(T-K)*be,Ae=M-(M-$)*be,he=H-(H-Q)*be;let Ue=Math.round(Math.min(ee,ne)),at=Math.round(Math.max(ee,ne)),Ye=g*re+Ue*4;for(let Ie=Ue;Ie<=at;Ie++){if(be=(ee-Ie)/(ee-ne),be<0)be=0;else if(be>1)be=1;u[Ye++]=L-(L-fe)*be|0,u[Ye++]=J-(J-Ae)*be|0,u[Ye++]=pe-(pe-he)*be|0,u[Ye++]=255}}}class Cy extends U5{constructor(e){super();this._posData=e[2],this._colData=e[3],this._vertexCount=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null,IE()}_createMeshCanvas(e,t,a){let f=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-f,h=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(c*e[0]*1.1)),3000)||1,g=Math.min(Math.ceil(Math.abs(h*e[1]*1.1)),3000)||1,b=c?c/u:1,d=h?h/g:1,j={coords:this._posData,colors:this._colData,offsetX:-f,offsetY:-l,scaleX:1/b,scaleY:1/d},A=u+4,C=g+4,y=a.create(A,C);if(UE()&&this._vertexCount>48)y.context.drawImage(GE(this._posData,this._colData,this._vertexCount,j,t,A,C,2),0,0);else{let O=y.context.createImageData(u,g);if(t){let T=O.data;for(let M=0,H=T.length;M<H;M+=4)T[M]=t[0],T[M+1]=t[1],T[M+2]=t[2],T[M+3]=255}for(let T=0,M=this._vertexCount;T<M;T+=3)XE(O,j,T,T+1,T+2,T,T+1,T+2);y.context.putImageData(O,2,2)}return{canvas:y.canvas,offsetX:f-2*b,offsetY:l-2*d,scaleX:b,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(e,t,a,n){j5(e,this._bbox);let s=new Float32Array(2);if(n===En.SHADING)Fe.singularValueDecompose2dScale(ma(e),s);else if(this.matrix){Fe.singularValueDecompose2dScale(this.matrix,s);let[l,c]=s;Fe.singularValueDecompose2dScale(t.baseTransform,s),s[0]*=l,s[1]*=c}else Fe.singularValueDecompose2dScale(t.baseTransform,s);let i=this._createMeshCanvas(s,n===En.SHADING?null:this._background,t.canvasFactory);if(n!==En.SHADING){if(e.setTransform(...t.baseTransform),this.matrix)e.transform(...this.matrix)}e.translate(i.offsetX,i.offsetY),e.scale(i.scaleX,i.scaleY);let f=e.createPattern(i.canvas,"no-repeat");return t.canvasFactory.destroy(i),f}}class _y extends U5{getPattern(){return"hotpink"}}function KE(e){switch(e[0]){case"RadialAxial":return new Sy(e);case"Mesh":return new Cy(e);case"Dummy":return new _y}throw Error(`Unknown IR type: ${e[0]}`)}var MA={COLORED:1,UNCOLORED:2};class c2{static MAX_PATTERN_SIZE=3000;constructor(e,t,a,n){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.needsIsolation=e[9]??!0,this.ctx=t,this.canvasGraphicsFactory=a,this.baseTransform=n,this.patternBaseMatrix=this.matrix?Fe.transform(n,this.matrix):n}canSkipPatternCanvas([e,t,a,n]){let[s,i,f,l]=this.bbox,c=Math.abs(this.xstep),h=Math.abs(this.ystep);if(e>c+0.000001||t>h+0.000001)return null;let u=Math.floor((a-f)/c)+1,g=Math.ceil((a+e-s)/c)-1,b=Math.floor((n-l)/h)+1,d=Math.ceil((n+t-i)/h)-1;return g<=u&&d<=b?[u,b]:null}updatePatternDims(e,t){let a=Fe.inverseTransform(this.patternBaseMatrix),n=[e[0],e[1]],s=[e[2],e[3]];Fe.applyTransform(n,a),Fe.applyTransform(s,a),t[0]=Math.abs(s[0]-n[0]),t[1]=Math.abs(s[1]-n[1]),t[2]=Math.min(n[0],s[0]),t[3]=Math.min(n[1],s[1])}_renderTileCanvas(e,t,a,n){let[s,i,f,l]=this.bbox,c=e.canvasFactory.create(a.size,n.size),h=c.context,u=this.canvasGraphicsFactory.createCanvasGraphics(h,t);return u.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(u,this.paintType,this.color),h.translate(-a.scale*s,-n.scale*i),u.transform(0,a.scale,0,0,n.scale,0,0),h.save(),u.dependencyTracker?.save(),this.clipBbox(u,s,i,f,l),u.baseTransform=ma(u.ctx),u.executeOperatorList(this.operatorList),u.endDrawing(),u.dependencyTracker?.restore(),h.restore(),c}_getCombinedScales(){let e=new Float32Array(2);Fe.singularValueDecompose2dScale(this.matrix,e);let[t,a]=e;return Fe.singularValueDecompose2dScale(this.baseTransform,e),[t*e[0],a*e[1]]}drawPattern(e,t,a=!1,[n,s],i){let[f,l,c,h]=this.bbox,u=e.dependencyTracker;if(u)e.dependencyTracker=new g2(u,i);if(e.save(),a)e.ctx.clip(t,"evenodd");else e.ctx.clip(t);if(e.ctx.setTransform(...this.patternBaseMatrix),e.ctx.translate(n*this.xstep,s*this.ystep),this.needsIsolation||e.ctx.globalAlpha!==1||e.ctx.globalCompositeOperation!=="source-over"||e.inSMaskMode){let g=c-f,b=h-l,[d,j]=this._getCombinedScales(),A=this.getSizeAndScale(g,this.ctx.canvas.width,d),C=this.getSizeAndScale(b,this.ctx.canvas.height,j),y=this._renderTileCanvas(e,i,A,C);e.ctx.drawImage(y.canvas,f,l,g,b),e.canvasFactory.destroy(y)}else this.setFillAndStrokeStyleToContext(e,this.paintType,this.color),this.clipBbox(e,f,l,c,h),e.baseTransformStack.push(e.baseTransform),e.baseTransform=ma(e.ctx),e.executeOperatorList(this.operatorList),e.baseTransform=e.baseTransformStack.pop();if(e.restore(),u)e.dependencyTracker=u}createPatternCanvas(e,t){let[a,n,s,i]=this.bbox,f=s-a,l=i-n,{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),M5("TilingType: "+this.tilingType);let[u,g]=this._getCombinedScales(),b=f,d=l,j=!1,A=!1;if(Math.ceil(c*u)>=Math.ceil(f*u))b=c;else j=!0;if(Math.ceil(h*g)>=Math.ceil(l*g))d=h;else A=!0;let C=this.getSizeAndScale(b,this.ctx.canvas.width,u),y=this.getSizeAndScale(d,this.ctx.canvas.height,g),O=this._renderTileCanvas(e,t,C,y);if(j||A){let T=O.canvas;if(j)b=c;if(A)d=h;let M=this.getSizeAndScale(b,this.ctx.canvas.width,u),H=this.getSizeAndScale(d,this.ctx.canvas.height,g),N=M.size,x=H.size,z=e.canvasFactory.create(N,x),K=z.context,$=j?Math.floor(f/c):0,Q=A?Math.floor(l/h):0;for(let P=0;P<=$;P++)for(let te=0;te<=Q;te++)K.drawImage(T,N*P,x*te,N,x,0,0,N,x);return e.canvasFactory.destroy(O),{canvas:z.canvas,canvasEntry:z,scaleX:M.scale,scaleY:H.scale,offsetX:a,offsetY:n}}return{canvas:O.canvas,canvasEntry:O,scaleX:C.scale,scaleY:y.scale,offsetX:a,offsetY:n}}getSizeAndScale(e,t,a){let n=Math.max(c2.MAX_PATTERN_SIZE,t),s=Math.ceil(e*a);if(s>=n)s=n;else a=s/e;return{scale:a,size:s}}clipBbox(e,t,a,n,s){let i=n-t,f=s-a,l=new Path2D;l.rect(t,a,i,f),Fe.axialAlignedBoundingBox([t,a,n,s],ma(e.ctx),e.current.minMax),e.ctx.clip(l),e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,a){let{ctx:n,current:s}=e;switch(s.patternFill=s.patternStroke=!1,t){case MA.COLORED:let{fillStyle:i,strokeStyle:f}=this.ctx;n.fillStyle=s.fillColor=i,n.strokeStyle=s.strokeColor=f;break;case MA.UNCOLORED:n.fillStyle=n.strokeStyle=a,s.fillColor=s.strokeColor=a;break;default:throw new JA(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,a,n,s){let i=n!==En.SHADING?Fe.transform(a,this.patternBaseMatrix):a,f=this.createPatternCanvas(t,s),l=new DOMMatrix(i);l=l.translate(f.offsetX,f.offsetY),l=l.scale(1/f.scaleX,1/f.scaleY);let c=e.createPattern(f.canvas,"repeat");return t.canvasFactory.destroy(f.canvasEntry),c.setTransform(l),c}}var LE=16,VE=100,YE=15,DA=10,Fs=16,u8=new DOMMatrix,Zs=new Float32Array(2);function xA(e,t){if(e._removeMirroring)throw Error("Context is already forwarding operations.");let a=new Map;for(let n of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){let s=e[n];if(typeof s!=="function"||typeof t[n]!=="function")continue;a.set(n,s),e[n]=function(...i){return t[n](...i),s.apply(this,i)}}e._removeMirroring=()=>{for(let[n,s]of a)e[n]=s;delete e._removeMirroring}}function h5(e,t,a,n,s,i,f,l,c,h){let[u,g,b,d,j,A]=ma(e);if(g===0&&b===0){let O=f*u+j,T=Math.round(O),M=l*d+A,H=Math.round(M),N=(f+c)*u+j,x=Math.abs(Math.round(N)-T)||1,z=(l+h)*d+A,K=Math.abs(Math.round(z)-H)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(d),T,H),e.drawImage(t,a,n,s,i,0,0,x,K),e.setTransform(u,g,b,d,j,A),[x,K]}if(u===0&&d===0){let O=l*b+j,T=Math.round(O),M=f*g+A,H=Math.round(M),N=(l+h)*b+j,x=Math.abs(Math.round(N)-T)||1,z=(f+c)*g+A,K=Math.abs(Math.round(z)-H)||1;return e.setTransform(0,Math.sign(g),Math.sign(b),0,T,H),e.drawImage(t,a,n,s,i,0,0,K,x),e.setTransform(u,g,b,d,j,A),[K,x]}e.drawImage(t,a,n,s,i,f,l,c,h);let C=Math.hypot(u,g),y=Math.hypot(b,d);return[C*c,y*h]}class A8{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=g8;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=ln.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=Er.slice();constructor(e,t){this.clipBox=new Float32Array([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e.tilingPatternDims=this.tilingPatternDims?.slice(),e}getPathBoundingBox(e=En.FILL,t=null){let a=this.minMax.slice();if(e===En.STROKE){if(!t)Et("Stroke bounding box must include transform.");Fe.singularValueDecompose2dScale(t,Zs);let n=Zs[0]*this.lineWidth/2,s=Zs[1]*this.lineWidth/2;a[0]-=n,a[1]-=s,a[2]+=n,a[3]+=s}return a}updateClipFromPath(){let e=Fe.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(Er,0)}getClippedPathBoundingBox(e=En.FILL,t=null){return Fe.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function RA(e,t){let{width:a,height:n,kind:s}=t,i=n%Fs,f=(n-i)/Fs,l=i===0?f:f+1,c=e.createImageData(a,Fs),h=0,u=t.data,g=c.data,b;if(s===w5.GRAYSCALE_1BPP)for(b=0;b<l;b++)({srcPos:h}=Ay({src:u,srcPos:h,dest:g,width:a,height:b<f?Fs:i})),e.putImageData(c,0,b*Fs);else if(s===w5.RGBA_32BPP){let d=0,j=a*Fs*4;for(b=0;b<f;b++)g.set(u.subarray(h,h+j)),h+=j,e.putImageData(c,0,d),d+=Fs;if(b<l)j=a*i*4,g.set(u.subarray(h,h+j)),e.putImageData(c,0,d)}else if(s===w5.RGB_24BPP)for(b=0;b<l;b++)({srcPos:h}=NE({src:u,srcPos:h,dest:new Uint32Array(g.buffer),width:a,height:b<f?Fs:i})),e.putImageData(c,0,b*Fs);else throw Error(`bad image kind: ${s}`)}function NA(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let{width:a,height:n}=t,s=n%Fs,i=(n-s)/Fs,f=s===0?i:i+1,l=e.createImageData(a,Fs),c=0,h=t.data,u=l.data;for(let g=0;g<f;g++)({srcPos:c}=Ay({src:h,srcPos:c,dest:u,width:a,height:g<i?Fs:s,nonBlackColor:0})),e.putImageData(l,0,g*Fs)}function xr(e,t){let a=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let n of a)if(e[n]!==void 0)t[n]=e[n];if(e.setLineDash!==void 0)t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset}function u5(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",e.setLineDash!==void 0)e.setLineDash([]),e.lineDashOffset=0;let{filter:t}=e;if(t!=="none"&&t!=="")e.filter="none"}function EA(e,t){if(t)return!0;Fe.singularValueDecompose2dScale(e,Zs);let a=Math.fround(y0.pixelRatio*Ur.PDF_TO_CSS_UNITS);return Zs[0]<=a&&Zs[1]<=a}var JE=["butt","round","square"],QE=["miter","round","bevel"],ZE={},zA={};class Xo{#e=0;#t=0;#a=null;#n=null;#s=null;#f=null;#i=1;#l;#o=null;#r=[];constructor(e,t,a,n,s,{optionalContentConfig:i,markedContentStack:f=null},l,c,h,u){this.ctx=e,this.current=new A8(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=t,this.objs=a,this.canvasFactory=n,this.filterFactory=s,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=f||[],this.optionalContentConfig=i,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=u??null}getObject(e,t,a=null){if(typeof t==="string")return this.dependencyTracker?.recordNamedDependency(e,t),t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);return a}beginDrawing({transform:e,viewport:t,transparency:a=!1,background:n=null}){let s=this.ctx.canvas.width,i=this.ctx.canvas.height,f=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,s,i),this.ctx.fillStyle=f,a){let l=this.transparentCanvasEntry=this.canvasFactory.create(s,i);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...ma(this.compositeCtx))}if(this.ctx.save(),u5(this.ctx),e)this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[3];this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=ma(this.ctx)}executeOperatorList(e,t,a,n,s){let{argsArray:i,fnArray:f}=e,l=t||0,c=i.length;if(c===l)return l;let h=c-l>DA&&typeof a==="function",u=h?Date.now()+YE:0,g=0,b=this.commonObjs,d=this.objs,j,A;while(!0){if(n!==void 0){if(l===n.nextBreakPoint)return n.breakIt(l,a),l;if(n.shouldSkip(l)){if(++l===c)return l;continue}}if(!s||s(l))if(j=f[l],A=i[l]??null,j!==k0.dependency)if(A===null)this[j](l);else this[j](l,...A);else for(let C of A){this.dependencyTracker?.recordNamedData(C,l);let y=C.startsWith("g_")?b:d;if(!y.has(C))return y.get(C,a),l}if(l++,l===c)return l;if(h&&++g>DA){if(Date.now()>u)return a(),l;g=0}}}#u(){while(this.stateStack.length||this.inSMaskMode)this.restore();if(this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas)this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null}endDrawing(){this.#u();for(let e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let e of this.#r)this.#w(e);this.#r.length=0,this.#a=null,this.#n=null,this.#s=null,this.#f=null,this.#i=1,this.#o=null,this.#t=0,this.#e=0,this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())if(typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement)t.width=t.height=0;e.clear()}this._cachedBitmapsMap.clear(),this.#h()}#h(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let a=e.width??e.displayWidth,n=e.height??e.displayHeight,s=Math.max(Math.hypot(t[0],t[1]),1),i=Math.max(Math.hypot(t[2],t[3]),1),f=[],l=s,c=i,h=a,u=n;while(l>2&&h>1||c>2&&u>1){let C=h,y=u;if(l>2&&h>1)C=Math.ceil(h/2),l/=h/C;if(c>2&&u>1)y=Math.ceil(u/2),c/=u/y;f.push({newWidth:C,newHeight:y}),h=C,u=y}if(f.length===0)return{img:e,paintWidth:a,paintHeight:n,tmpCanvas:null};if(f.length===1){let{newWidth:C,newHeight:y}=f[0],O=this.canvasFactory.create(C,y);return O.context.drawImage(e,0,0,a,n,0,0,C,y),{img:O.canvas,paintWidth:C,paintHeight:y,tmpCanvas:O}}let g=this.canvasFactory.create(1,1),b=this.canvasFactory.create(1,1),d=a,j=n,A=e;for(let{newWidth:C,newHeight:y}of f)this.canvasFactory.reset(b,C,y),b.context.drawImage(A,0,0,d,j,0,0,C,y),[g,b]=[b,g],A=g.canvas,d=C,j=y;return this.canvasFactory.destroy(b),{img:g.canvas,paintWidth:d,paintHeight:j,tmpCanvas:g}}_createMaskCanvas(e,t){let a=this.ctx,{width:n,height:s}=t,i=this.current.fillColor,f=this.current.patternFill,l=ma(a),c,h,u,g;if((t.bitmap||t.data)&&t.count>1){let $=t.bitmap||t.data.buffer;h=JSON.stringify(f?l:[l.slice(0,4),i]),c=this._cachedBitmapsMap.getOrInsertComputed($,S8);let Q=c.get(h);if(Q&&!f){let P=Math.round(Math.min(l[0],l[2])+l[4]),te=Math.round(Math.min(l[1],l[3])+l[5]);return this.dependencyTracker?.recordDependencies(e,qi.transformAndFill),{canvas:Q,offsetX:P,offsetY:te}}u=Q}if(!u)g=this.canvasFactory.create(n,s),NA(g.context,t);let b=Fe.transform(l,[1/n,0,0,-1/s,0,0]);b=Fe.transform(b,[1,0,0,1,0,-s]);let d=Er.slice();Fe.axialAlignedBoundingBox([0,0,n,s],b,d);let[j,A,C,y]=d,O=Math.round(C-j)||1,T=Math.round(y-A)||1,M=this.canvasFactory.create(O,T),H=M.context,N=j,x=A;H.translate(-N,-x),H.transform(...b);let z=null;if(!u){let $=this._scaleImage(g.canvas,j0(H));if(u=$.img,z=$.tmpCanvas,u!==g.canvas)this.canvasFactory.destroy(g),g=null;if(c&&f)c.set(h,u),z=null,g=null}if(H.imageSmoothingEnabled=EA(ma(H),t.interpolate),h5(H,u,0,0,u.width,u.height,0,0,n,s),z)this.canvasFactory.destroy(z);if(g)this.canvasFactory.destroy(g);H.globalCompositeOperation="source-in";let K=Fe.transform(j0(H),[1,0,0,1,-N,-x]);if(H.fillStyle=f?i.getPattern(a,this,K,En.FILL,e):i,H.fillRect(0,0,n,s),c&&!f)c.set(h,M.canvas);return this.dependencyTracker?.recordDependencies(e,qi.transformAndFill),{canvas:M.canvas,canvasEntry:c&&!f?null:M,offsetX:Math.round(N),offsetY:Math.round(x)}}setLineWidth(e,t){if(this.dependencyTracker?.recordSimpleData("lineWidth",e),t!==this.current.lineWidth)this._cachedScaleForStroking[0]=-1;this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(e,t){this.dependencyTracker?.recordSimpleData("lineCap",e),this.ctx.lineCap=JE[t]}setLineJoin(e,t){this.dependencyTracker?.recordSimpleData("lineJoin",e),this.ctx.lineJoin=QE[t]}setMiterLimit(e,t){this.dependencyTracker?.recordSimpleData("miterLimit",e),this.ctx.miterLimit=t}setDash(e,t,a){this.dependencyTracker?.recordSimpleData("dash",e);let n=this.ctx;if(n.setLineDash!==void 0)n.setLineDash(t),n.lineDashOffset=a}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(let[a,n]of t)switch(a){case"LW":this.setLineWidth(e,n);break;case"LC":this.setLineCap(e,n);break;case"LJ":this.setLineJoin(e,n);break;case"ML":this.setMiterLimit(e,n);break;case"D":this.setDash(e,n[0],n[1]);break;case"RI":this.setRenderingIntent(e,n);break;case"FL":this.setFlatness(e,n);break;case"Font":this.setFont(e,n[0],n[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",e),this.current.strokeAlpha=n;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",e),this.ctx.globalAlpha=this.current.fillAlpha=n;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",e),this.ctx.globalCompositeOperation=n;break;case"SMask":if(this.dependencyTracker?.recordSimpleData("SMask",e),this.current.activeSMask=n?this.tempSMask:null,this.current.activeSMask)this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation;this.tempSMask=null,this.checkSMaskState(e);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry)this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null;this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){if(e===this.smaskPreparedFor)return;this._clearPreparedSMask(),this._prepareSMaskCanvas(e)}checkSMaskState(e){let t=this.inSMaskMode;if(this.current.activeSMask&&!t)this.beginSMaskMode(e);else if(!this.current.activeSMask&&t)this.endSMaskMode();else if(this.current.activeSMask&&t)this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){let{canvas:t,subtype:a,backdrop:n,transferMap:s}=e,i=a==="Luminosity"||a==="Alpha"&&s;if(!i&&!(a==="Luminosity"&&n)){this.smaskPreparedFor=e;return}let f;if(a==="Luminosity"&&n){let[y,O,T]=j2(n),M=Math.round(0.3*y+0.59*O+0.11*T);f=s?.[M]??M}else f=s?.[0]??0;let l=4,{width:c,height:h}=this.ctx.canvas,u=t.width*t.height,g=c*h<l*u,b=i?{url:a==="Alpha"?this.filterFactory.addAlphaFilter(s):this.filterFactory.addLuminosityFilter(s),subtype:a,transferMap:s}:null,d=a==="Luminosity"?n:null,j,A,C;if(g)j=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,c,h,d,b),A=0,C=0;else j=this._bakeSMaskCanvas(t,0,0,t.width,t.height,d,b),A=e.offsetX,C=e.offsetY;this.smaskPreparedEntry=j,this.smaskPreparedFor=e,this.smaskPreparedOffsetX=A,this.smaskPreparedOffsetY=C,this.smaskPreparedOOBAlpha=!g&&f!==0?f:null}_bakeSMaskCanvas(e,t,a,n,s,i,f){if(!i&&!f)Et("_bakeSMaskCanvas with neither backdrop nor filter");let l=this.canvasFactory.create(n,s),c=l.context;if(c.drawImage(e,t,a),i)c.globalCompositeOperation="destination-atop",c.fillStyle=i,c.fillRect(0,0,n,s);if(!f)return l;let h=this.canvasFactory.create(n,s),u=h.context;u.filter=f.url;let g=ea.isCanvasFilterSupported&&u.filter!=="none"&&u.filter!=="";if(u.drawImage(l.canvas,0,0),ea.isCanvasFilterSupported)u.filter="none";if(!g){let b=u.getImageData(0,0,n,s),{data:d}=b,{transferMap:j}=f;if(f.subtype==="Luminosity")for(let A=0,C=d.length;A<C;A+=4){let y=0.3*d[A]+0.59*d[A+1]+0.11*d[A+2]+0.5|0;d[A]=d[A+1]=d[A+2]=0,d[A+3]=j?.[y]??y}else for(let A=3,C=d.length;A<C;A+=4)d[A]=j[d[A]];u.putImageData(b,0,0)}return this.canvasFactory.destroy(l),h}beginSMaskMode(e){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:t,height:a}=this.ctx.canvas,n=this.canvasFactory.create(t,a);this.smaskScratchCanvas=n,this.suspendedCtx=this.ctx;let s=this.ctx=n.context;s.setTransform(this.suspendedCtx.getTransform()),xr(this.suspendedCtx,s),xA(s,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),xr(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#g(e,t=null,a=1){let{width:n,height:s}=e,i=t??this.canvasFactory.create(n,s),f=i.context;a=Math.round(a*255)/255;let l=a<1;if(l&&this.#l===void 0)this.#l=ea.isCanvasFilterSupported?new Map:"none";let c="none";if(l&&this.#l instanceof Map)c=this.#l.getOrInsertComputed(a,()=>this.filterFactory.addKnockoutFilter(a));if(!l||c!=="none"){if(t)f.save(),f.setTransform(1,0,0,1,0,0),f.clearRect(0,0,n,s),f.restore();return f.filter=c,f.drawImage(e,0,0),f.filter="none",i}let h=e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,n,s),u=f.createImageData(n,s),g=h.data,b=u.data,d=a>0?1/a:1e6;for(let j=3,A=g.length;j<A;j+=4)b[j]=Math.min(Math.round(g[j]*d),255);return f.putImageData(u,0,0),i}#b(e,t,a,n){let s=e?.[t]??null;if(s&&(s.canvas.width!==a||s.canvas.height!==n))this.canvasFactory.destroy(s),s=null;if(!s){if(s=this.canvasFactory.create(a,n),e)e[t]=s;return s}let i=s.context;return i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,a,n),i.restore(),s}#p(e,t,a={}){let{backdropCanvas:n=null,destTransform:s=[1,0,0,1,0,0],backdropOffset:i=[0,0],reuseMaskEntry:f=null,poolMeta:l=null,sourceAlpha:c=1,sourceFilter:h="none",knockoutAlpha:u=1}=a,{width:g,height:b}=t,d=this.#g(t,f,u),j=e.globalCompositeOperation;if(e.save(),e.setTransform(...s),e.globalAlpha=1,ea.isCanvasFilterSupported)e.filter="none";if(e.globalCompositeOperation="destination-out",e.drawImage(d.canvas,0,0),n){let[A,C]=i,y=this.#b(l,"knockoutBackdropEntry",g,b),O=y.context;if(O.drawImage(n,A,C,g,b,0,0,g,b),O.globalCompositeOperation="destination-in",O.drawImage(d.canvas,0,0),O.globalCompositeOperation="source-over",e.globalCompositeOperation="destination-over",e.drawImage(y.canvas,0,0),!l)this.canvasFactory.destroy(y)}if(e.globalCompositeOperation=j,e.globalAlpha=c,ea.isCanvasFilterSupported)e.filter=h??"none";if(e.drawImage(t,0,0),e.restore(),!f)this.canvasFactory.destroy(d)}#c(e=1){if(this.#e===0||this.#t>0||!this.contentVisible)return!1;this.#t++,this.#i=e;let t=this.#r.at(-1),{canvas:a}=this.ctx,n=this.#b(t,"knockoutTempEntry",a.width,a.height);this.#a=n;let s=n.context;if(s.save(),s.setTransform(this.ctx.getTransform()),xr(this.ctx,s),this.#f=s.globalCompositeOperation,s.globalCompositeOperation="source-over",xA(s,this.ctx),this.#o=t,this.#n=this.ctx,this.#s=this.suspendedCtx,this.ctx=s,this.inSMaskMode)this.suspendedCtx=s;return!0}#m(e){if(!e)return;let t=this.#a,a=this.#n,n=this.#s,s=t.context;if(this.#a=null,this.#n=null,this.#s=null,this.inSMaskMode&&this.suspendedCtx===s&&this.ctx!==s)this.endSMaskMode();if(this.inSMaskMode)this.suspendedCtx=n;this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#f,this.#f=null,xr(this.ctx,a),this.ctx=a;let i=this.#o;this.#o=null;let f=this.#i;this.#i=1;try{this.#p(n??a,t.canvas,{backdropCanvas:i?.backdropCtx?.canvas??null,backdropOffset:i?.backdropCtx?[i.offsetX,i.offsetY]:[0,0],reuseMaskEntry:i?.knockoutMaskEntry??null,poolMeta:i,knockoutAlpha:f})}finally{if(s.restore(),this.#t--,!i)this.canvasFactory.destroy(t)}}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,a=this.suspendedCtx,n=this.#t>0&&a===this.ctx;if(this.composeSMask(n?null:a,t,this.ctx,e),n)return;this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,a,n){let s=n[0],i=n[1],f=n[2]-s,l=n[3]-i;if(f===0||l===0)return;let c=this.smaskPreparedEntry;if(c){let h=s,u=i,g=f,b=l,d=this.smaskPreparedOOBAlpha,j=d!==null;if(j){h=Math.max(s,t.offsetX),u=Math.max(i,t.offsetY);let A=Math.min(s+f,t.offsetX+t.canvas.width),C=Math.min(i+l,t.offsetY+t.canvas.height);g=A-h,b=C-u}if(g>0&&b>0){let A=h-this.smaskPreparedOffsetX,C=u-this.smaskPreparedOffsetY;a.save(),a.globalAlpha=1,a.setTransform(1,0,0,1,0,0);let y=new Path2D;y.rect(h,u,g,b),a.clip(y),a.globalCompositeOperation="destination-in",a.drawImage(c.canvas,A,C,g,b,h,u,g,b),a.restore()}if(j&&d<255)this._applySMaskOOBAlpha(a,s,i,f,l,h,u,h+g,u+b,d)}else this.genericComposeSMask(t,a,f,l,s,i);if(!e)return;e.save(),e.globalAlpha=1,e.globalCompositeOperation=t.blendMode||"source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(a.canvas,s,i,f,l,s,i,f,l),e.restore()}_applySMaskOOBAlpha(e,t,a,n,s,i,f,l,c,h){let u=i<l&&f<c;if(u&&i===t&&f===a&&l===t+n&&c===a+s)return;let g=new Path2D;if(g.rect(t,a,n,s),u)g.rect(i,f,l-i,c-f);e.save(),e.globalAlpha=h/255,e.setTransform(1,0,0,1,0,0),e.clip(g,"evenodd"),e.globalCompositeOperation="destination-in",e.fillStyle="#000000",e.fillRect(t,a,n,s),e.restore()}genericComposeSMask(e,t,a,n,s,i){let{context:f,offsetX:l,offsetY:c}=e;t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let h=new Path2D;h.rect(s,i,a,n),t.clip(h),t.globalCompositeOperation="destination-in",t.drawImage(f.canvas,s-l,i-c,a,n,s,i,a,n),t.restore()}save(e){if(this.inSMaskMode)xr(this.ctx,this.suspendedCtx);this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone(),this.dependencyTracker?.save(e)}restore(e){if(this.dependencyTracker?.restore(e),this.stateStack.length===0){if(this.inSMaskMode)this.endSMaskMode();return}if(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode)xr(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform());this.checkSMaskState(e),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,t,a,n,s,i,f){this.dependencyTracker?.recordIncrementalData("transform",e),this.ctx.transform(t,a,n,s,i,f),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,a,n){let[s]=a;if(!n){if(s||=a[0]=new Path2D,t!==k0.stroke&&t!==k0.closeStroke)this.current.tilingPatternDims=null;this[t](e,s);return}if(this.dependencyTracker!==null){let f=t===k0.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,n[0]-f,n[2]+f,n[1]-f,n[3]+f).recordDependencies(e,["transform"])}if(!(s instanceof Path2D))s=a[0]=PA(s);Fe.axialAlignedBoundingBox(n,ma(this.ctx),this.current.minMax);let i=this.current.tilingPatternDims;if(i&&t!==k0.stroke&&t!==k0.closeStroke&&this.current.fillColor instanceof c2){let f=Fe.intersect(this.current.clipBox,this.current.minMax);if(!f)this.current.tilingPatternDims=null;else this.current.fillColor.updatePatternDims(f,i)}this[t](e,s),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,a=!0){let n=a&&this.#c(this.current.strokeAlpha),s=this.ctx,i=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof i==="object"&&i?.getPattern){let f=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=i.getPattern(s,this,j0(s),En.STROKE,e),f){let l=new Path2D;l.addPath(t,s.getTransform().invertSelf().multiplySelf(f)),t=l}this.rescaleAndStroke(t,!1),s.restore()}else this.rescaleAndStroke(t,!0);if(this.dependencyTracker?.recordDependencies(e,qi.stroke),a)this.consumePath(e,t,this.current.getClippedPathBoundingBox(En.STROKE,ma(this.ctx)));s.globalAlpha=this.current.fillAlpha,this.#m(n)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,a=!0){let n=a&&this.#c(this.current.fillAlpha),s=this.ctx,i=this.current.fillColor,f=this.current.patternFill,l=!1,c=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(e,qi.fill),f){let h=this.current.tilingPatternDims,u=h&&i.canSkipPatternCanvas(h);if(u){if(i.drawPattern(this,t,this.pendingEOFill,u,e),this.pendingEOFill=!1,a)this.consumePath(e,t,c);this.current.tilingPatternDims=null,this.#m(n);return}let g=i.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(e),s.save(),s.fillStyle=i.getPattern(s,this,j0(s),En.FILL,e),g){let b=new Path2D;b.addPath(t,s.getTransform().invertSelf().multiplySelf(g)),t=b}l=!0}if(this.contentVisible&&c!==null)if(this.pendingEOFill)s.fill(t,"evenodd"),this.pendingEOFill=!1;else s.fill(t);if(l)s.restore(),this.dependencyTracker?.restore(e);if(a)this.consumePath(e,t,c);this.#m(n)}eoFill(e,t){this.pendingEOFill=!0,this.fill(e,t)}fillStroke(e,t){let a=this.#c(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1),this.stroke(e,t,!1),this.consumePath(e,t),this.#m(a)}eoFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){let a=this.#c(this.current.fillAlpha);this.ctx.fill(t),this.dependencyTracker?.recordDependencies(e,qi.rawFillPath).recordOperation(e),this.#m(a)}clip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e),this.pendingClip=ZE}eoClip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e),this.pendingClip=zA}beginText(e){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){let t=this.pendingTextPaths,a=this.ctx;if(this.dependencyTracker){let{dependencyTracker:n}=this;if(t!==void 0)n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",e);n.recordCloseMarker(e)}if(t!==void 0){let n=new Path2D,s=a.getTransform().invertSelf();for(let{transform:i,x:f,y:l,fontSize:c,path:h}of t){if(!h)continue;n.addPath(h,new DOMMatrix(i).preMultiplySelf(s).translate(f,l).scale(c,-c))}a.clip(n)}delete this.pendingTextPaths}setCharSpacing(e,t){this.dependencyTracker?.recordSimpleData("charSpacing",e),this.current.charSpacing=t}setWordSpacing(e,t){this.dependencyTracker?.recordSimpleData("wordSpacing",e),this.current.wordSpacing=t}setHScale(e,t){this.dependencyTracker?.recordSimpleData("hScale",e),this.current.textHScale=t/100}setLeading(e,t){this.dependencyTracker?.recordSimpleData("leading",e),this.current.leading=-t}setFont(e,t,a){this.dependencyTracker?.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",t,e);let n=this.commonObjs.get(t),s=this.current;if(!n)throw Error(`Can't find font for ${t}`);if(s.fontMatrix=n.fontMatrix||g8,s.fontMatrix[0]===0||s.fontMatrix[3]===0)ot("Invalid font matrix for font "+t);if(a<0)a=-a,s.fontDirection=-1;else s.fontDirection=1;if(this.current.font=n,this.current.fontSize=a,n.isType3Font)return;let i=n.loadedName||"sans-serif",f=n.systemFontInfo?.css||`"${i}", ${n.fallbackName}`,l="normal";if(n.black)l="900";else if(n.bold)l="bold";let c=n.italic?"italic":"normal",h=da(a,LE,VE);this.current.fontSizeScale=a/h,this.ctx.font=`${c} ${l} ${h}px ${f}`}setTextRenderingMode(e,t){this.dependencyTracker?.recordSimpleData("textRenderingMode",e),this.current.textRenderingMode=t}setTextRise(e,t){this.dependencyTracker?.recordSimpleData("textRise",e),this.current.textRise=t}moveText(e,t,a){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e),this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=a}setLeadingMoveText(e,t,a){this.setLeading(e,-a),this.moveText(e,t,a)}setTextMatrix(e,t){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",e);let{current:a}=this;a.textMatrix=t,a.textMatrixScale=Math.hypot(t[0],t[1]),a.x=a.lineX=0,a.y=a.lineY=0}nextLine(e){this.moveText(e,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}#d(e,t,a){let n=new Path2D;return n.addPath(e,new DOMMatrix(a).invertSelf().multiplySelf(t)),n}paintChar(e,t,a,n,s,i){let f=this.ctx,l=this.current,c=l.font,h=l.textRenderingMode,u=l.fontSize/l.fontSizeScale,g=h&ln.FILL_STROKE_MASK,b=!!(h&ln.ADD_TO_PATH_FLAG),d=l.patternFill&&!c.missingFile,j=l.patternStroke&&!c.missingFile,A;if((c.disableFontFace||b||d||j)&&!c.missingFile)A=c.getPathGenerator(this.commonObjs,t);if(A&&(c.disableFontFace||d||j)){f.save(),f.translate(a,n),f.scale(u,-u),this.dependencyTracker?.recordCharacterBBox(e,f,c);let C;if(g===ln.FILL||g===ln.FILL_STROKE)if(s){C=f.getTransform(),f.setTransform(...s);let y=this.#d(A,C,s);f.fill(y)}else f.fill(A);if(g===ln.STROKE||g===ln.FILL_STROKE)if(i){C||=f.getTransform(),f.setTransform(...i);let{a:y,b:O,c:T,d:M}=C,H=Fe.inverseTransform(i),N=Fe.transform([y,O,T,M,0,0],H);Fe.singularValueDecompose2dScale(N,Zs),f.lineWidth*=Math.max(Zs[0],Zs[1])/u,f.stroke(this.#d(A,C,i))}else f.lineWidth/=u,f.stroke(A);f.restore()}else{if(g===ln.FILL||g===ln.FILL_STROKE)f.fillText(t,a,n),this.dependencyTracker?.recordCharacterBBox(e,f,c,u,a,n,()=>f.measureText(t));if(g===ln.STROKE||g===ln.FILL_STROKE){if(this.dependencyTracker)this.dependencyTracker?.recordCharacterBBox(e,f,c,u,a,n,()=>f.measureText(t)).recordDependencies(e,qi.stroke);f.strokeText(t,a,n)}}if(b)(this.pendingTextPaths||=[]).push({transform:ma(f),x:a,y:n,fontSize:u,path:A}),this.dependencyTracker?.recordCharacterBBox(e,f,c,u,a,n)}get isFontSubpixelAAEnabled(){let e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1),t.fillText("I",0,10);let a=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let n=!1;for(let s=3;s<a.length;s+=4)if(a[s]>0&&a[s]<255){n=!0;break}return ft(this,"isFontSubpixelAAEnabled",n)}showText(e,t){if(this.dependencyTracker){if(this.dependencyTracker.recordDependencies(e,qi.showText).resetBBox(e),this.current.textRenderingMode&ln.ADD_TO_PATH_FLAG)this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies()}let a=this.current,n=a.font;if(n.isType3Font){let Q=this.#c(a.fillAlpha);this.showType3Text(e,t),this.dependencyTracker?.recordShowTextOperation(e),this.#m(Q);return}let s=a.fontSize;if(s===0){this.dependencyTracker?.recordOperation(e);return}let i=this.#c(a.fillAlpha),f=this.ctx,l=a.fontSizeScale,c=a.charSpacing,h=a.wordSpacing,u=a.fontDirection,g=a.textHScale*u,b=t.length,d=n.vertical,j=d?1:-1,A=n.defaultVMetrics,C=s*a.fontMatrix[0],y=a.textRenderingMode===ln.FILL&&!n.disableFontFace&&!a.patternFill;if(f.save(),a.textMatrix)f.transform(...a.textMatrix);if(f.translate(a.x,a.y+a.textRise),u>0)f.scale(g,-1);else f.scale(g,1);let O,T,M=a.textRenderingMode&ln.FILL_STROKE_MASK,H=M===ln.FILL||M===ln.FILL_STROKE,N=M===ln.STROKE||M===ln.FILL_STROKE,x=a.lineWidth,z=a.textMatrixScale;if(z===0||x===0){if(N)x=this.getSinglePixelWidth()}else x/=z;if(l!==1)f.scale(l,l),x/=l;if(f.lineWidth=x,H&&a.patternFill){f.save();let Q=a.fillColor.getPattern(f,this,j0(f),En.FILL,e);O=ma(f),f.restore(),f.fillStyle=Q}if(N&&a.patternStroke){f.save();let Q=a.strokeColor.getPattern(f,this,j0(f),En.STROKE,e);T=ma(f),f.restore(),f.strokeStyle=Q}if(n.isInvalidPDFjsFont){let Q=[],P=0;for(let ee of t)Q.push(ee.unicode),P+=ee.width;let te=Q.join("");if(f.fillText(te,0,0),this.dependencyTracker!==null){let ee=f.measureText(te);this.dependencyTracker.recordBBox(e,this.ctx,-ee.actualBoundingBoxLeft,ee.actualBoundingBoxRight,-ee.actualBoundingBoxAscent,ee.actualBoundingBoxDescent).recordShowTextOperation(e)}a.x+=P*C*g,f.restore(),this.compose(),this.#m(i);return}let K=0,$;for($=0;$<b;++$){let Q=t[$];if(typeof Q==="number"){K+=j*Q*s/1000;continue}let P=!1,te=(Q.isSpace?h:0)+c,ee=Q.fontChar,L=Q.accent,J,pe,ne=Q.width;if(d){let he=Q.vmetric||A,re=-(Q.vmetric?he[1]:ne*0.5)*C,be=he[2]*C;ne=he?-he[0]:ne,J=re/l,pe=(K+be)/l}else J=K/l,pe=0;let fe;if(n.remeasure&&ne>0){fe=f.measureText(ee);let he=fe.width*1000/s*l;if(ne<he&&this.isFontSubpixelAAEnabled){let re=ne/he;P=!0,f.save(),f.scale(re,1),J/=re}else if(ne!==he)J+=(ne-he)/2000*s/l}if(this.contentVisible&&(Q.isInFont||n.missingFile)){if(y&&!L)f.fillText(ee,J,pe),this.dependencyTracker?.recordCharacterBBox(e,f,fe?{bbox:null}:n,s/l,J,pe,()=>fe??f.measureText(ee));else if(this.paintChar(e,ee,J,pe,O,T),L){let he=J+s*L.offset.x/l,re=pe-s*L.offset.y/l;this.paintChar(e,L.fontChar,he,re,O,T)}}let Ae=d?ne*C-te*u:ne*C+te*u;if(K+=Ae,P)f.restore()}if(d)a.y-=K;else a.x+=K*g;f.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(e),this.#m(i)}showType3Text(e,t){let a=this.ctx,n=this.current,s=n.font,i=n.fontSize,f=n.fontDirection,l=s.vertical?1:-1,c=n.charSpacing,h=n.wordSpacing,u=n.textHScale*f,g=n.fontMatrix||g8,b=t.length,d=n.textRenderingMode===ln.INVISIBLE,j,A,C,y;if(d||i===0)return;if(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),n.textMatrix)a.transform(...n.textMatrix);a.translate(n.x,n.y+n.textRise),a.scale(u,f);let O=this.dependencyTracker;this.dependencyTracker=O?new g2(O,e):null;for(j=0;j<b;++j){if(A=t[j],typeof A==="number"){y=l*A*i/1000,this.ctx.translate(y,0),n.x+=y*u;continue}let T=(A.isSpace?h:0)+c,M=s.charProcOperatorList[A.operatorListId];if(!M)ot(`Type3 character "${A.operatorListId}" is not available.`);else if(this.contentVisible){if(this.save(),M.fnArray[0]===k0.setCharWidth)n.fillAlpha=n.strokeAlpha=1,a.globalAlpha=1;a.scale(i,i),a.transform(...g),this.executeOperatorList(M),this.restore()}let H=[A.width,0];Fe.applyTransform(H,g),C=H[0]*i+T,a.translate(C,0),n.x+=C*u}if(a.restore(),O)this.dependencyTracker=O}setCharWidth(e,t,a){}setCharWidthAndBounds(e,t,a,n,s,i,f){let l=new Path2D;l.rect(n,s,i-n,f-s),this.ctx.clip(l),this.dependencyTracker?.recordBBox(e,this.ctx,n,i,s,f).recordClipBox(e,this.ctx,n,i,s,f),this.endPath(e)}getColorN_Pattern(e,t){let a;if(t[0]==="TilingPattern"){let n=this.baseTransform||ma(this.ctx),s={createCanvasGraphics:(i,f)=>new Xo(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new g2(this.dependencyTracker,f,!0):null)};a=new c2(t,this.ctx,s,n)}else a=this._getPattern(e,t[1],t[2]);return a}setStrokeColorN(e,...t){this.dependencyTracker?.recordSimpleData("strokeColor",e),this.current.strokeColor=this.getColorN_Pattern(e,t),this.current.patternStroke=!0}setFillColorN(e,...t){this.dependencyTracker?.recordSimpleData("fillColor",e);let a=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0,this.current.tilingPatternDims=a instanceof c2?[0,0,0,0]:null}setStrokeRGBColor(e,t){this.dependencyTracker?.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(e){this.dependencyTracker?.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t){this.dependencyTracker?.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(e){this.dependencyTracker?.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(e,t,a=null){let n;if(this.cachedPatterns.has(t))n=this.cachedPatterns.get(t);else n=KE(this.getObject(e,t)),this.cachedPatterns.set(t,n);if(a)n.matrix=a;return n}shadingFill(e,t){if(!this.contentVisible)return;let a=this.#c(this.current.fillAlpha),n=this.ctx;this.save(e);let s=this._getPattern(e,t);n.fillStyle=s.getPattern(n,this,j0(n),En.SHADING,e);let i=j0(n);if(i){let{width:f,height:l}=n.canvas,c=Er.slice();Fe.axialAlignedBoundingBox([0,0,f,l],i,c);let[h,u,g,b]=c;this.ctx.fillRect(h,u,g-h,b-u)}else this.ctx.fillRect(-10000000000,-10000000000,20000000000,20000000000);this.dependencyTracker?.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,qi.transform).recordDependencies(e,qi.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e),this.#m(a)}beginInlineImage(){Et("Should not call beginInlineImage")}beginImageData(){Et("Should not call beginImageData")}paintFormXObjectBegin(e,t,a){if(!this.contentVisible)return;if(this.save(e),this.baseTransformStack.push(this.baseTransform),t)this.transform(e,...t);if(this.baseTransform=ma(this.ctx),a){Fe.axialAlignedBoundingBox(a,this.baseTransform,this.current.minMax);let[n,s,i,f]=a,l=new Path2D;l.rect(n,s,i-n,f-s),this.ctx.clip(l),this.dependencyTracker?.recordClipBox(e,this.ctx,n,i,s,f),this.endPath(e)}}paintFormXObjectEnd(e){if(!this.contentVisible)return;this.restore(e),this.baseTransform=this.baseTransformStack.pop()}beginGroup(e,t){if(!this.contentVisible)return;this.save(e);let{inSMaskMode:a}=this;if(a)this.endSMaskMode(),this.current.activeSMask=null;let n=this.ctx;if((!t.needsIsolation||!t.isolated&&!t.hasSoftMask)&&!t.knockout&&!t.isGray&&this.#e===0&&n.globalAlpha===1&&n.globalCompositeOperation==="source-over"&&!a){if(t.bbox){let y=new Path2D,[O,T,M,H]=t.bbox;if(y.rect(O,T,M-O,H-T),t.matrix){let N=new Path2D;N.addPath(y,new DOMMatrix(t.matrix)),y=N}n.clip(y)}this.groupStack.push(null),this.#r.push(null),this.groupLevel++;return}if(!t.isolated&&!t.knockout&&this.#e===0)M5("TODO: Fully support non-isolated non-knockout groups.");let s=ma(n);if(t.matrix)n.transform(...t.matrix);let i=[0,0,n.canvas.width,n.canvas.height],f;if(t.bbox)f=Er.slice(),Fe.axialAlignedBoundingBox(t.bbox,ma(n),f),f=Fe.intersect(f,i)||[0,0,0,0];else f=i;let l=Math.floor(f[0]),c=Math.floor(f[1]),h=Math.max(Math.ceil(f[2])-l,1),u=Math.max(Math.ceil(f[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,u]);let g=this.canvasFactory.create(h,u);if(t.smask)this.smaskGroupCanvases.push(g);let b=g.context,d=t.knockout&&!t.isolated?n:null,j=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&this.#e>0,A=t.knockout?this.canvasFactory.create(h,u):null,C=this.#e;if(t.knockout)this.#e++;else this.#e=0;if(b.translate(-l,-c),b.transform(...s),!t.isolated&&!t.smask&&a&&t.needsIsolation)b.save(),b.setTransform(1,0,0,1,0,0),b.drawImage(n.canvas,-l,-c),b.restore();if(t.bbox){let y=new Path2D,[O,T,M,H]=t.bbox;if(y.rect(O,T,M-O,H-T),t.matrix){let N=new Path2D;N.addPath(y,new DOMMatrix(t.matrix)),y=N}b.clip(y)}if(t.smask)this.smaskStack.push({canvas:g.canvas,context:b,offsetX:l,offsetY:c,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null});if(!t.smask||this.dependencyTracker)n.setTransform(1,0,0,1,0,0),n.translate(l,c),n.save();xr(n,b),this.ctx=b,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(n),this.setGState(e,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(n),this.#r.push({backdropCtx:d,savedKnockoutLevel:C,offsetX:l,offsetY:c,hasInnerBackdrop:j,knockoutMaskEntry:A,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(e,t){if(!this.contentVisible)return;this.groupLevel--;let a=this.ctx,n=this.groupStack.pop(),s=this.#r.pop();if(s)this.#e=s.savedKnockoutLevel;if(n===null){this.restore(e);return}if(t.isGray)this.#j(a);if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),t.smask){if(this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker){if(this.ctx.restore(),this.inSMaskMode)this.ctx.setTransform(this.suspendedCtx.getTransform())}this.#w(s)}else{this.ctx.restore();let i=ma(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...i);let f=Er.slice();Fe.axialAlignedBoundingBox([0,0,a.canvas.width,a.canvas.height],i,f);let l=this.#r.at(-1);if(this.#e>0)if(s.hasInnerBackdrop){let{width:c,height:h}=a.canvas,u=this.canvasFactory.create(c,h),g=u.context;g.drawImage(n.canvas,s.offsetX,s.offsetY,c,h,0,0,c,h),g.globalCompositeOperation="source-over",g.drawImage(a.canvas,0,0);let b=this.#g(a.canvas);g.globalCompositeOperation="destination-in",g.drawImage(b.canvas,0,0);let d=this.ctx.globalCompositeOperation,j=this.ctx.globalAlpha,A=this.ctx.filter;if(this.ctx.save(),this.ctx.setTransform(...i),this.ctx.globalAlpha=1,ea.isCanvasFilterSupported)this.ctx.filter="none";if(this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(b.canvas,0,0),this.ctx.globalCompositeOperation=d,this.ctx.globalAlpha=j,ea.isCanvasFilterSupported)this.ctx.filter=A??"none";this.ctx.drawImage(u.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(b),this.canvasFactory.destroy(u)}else{let c=l?.backdropCtx??null;this.#p(this.ctx,a.canvas,{backdropCanvas:c?.canvas??null,destTransform:i,backdropOffset:c?[l.offsetX+s.offsetX,l.offsetY+s.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(a.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:a.canvas,context:a}),this.#w(s),this.compose(f)}}#j(e){let{canvas:t}=e,{width:a,height:n}=t;if(ea.isCanvasFilterSupported){e.save(),e.setTransform(1,0,0,1,0,0),e.filter="grayscale(1)",e.globalAlpha=1,e.globalCompositeOperation="copy",e.drawImage(t,0,0),e.restore();return}let s=e.getImageData(0,0,a,n),{data:i}=s;for(let f=0,l=i.length;f<l;f+=4){let c=i[f]*0.2126+i[f+1]*0.7152+i[f+2]*0.0722+0.5|0;i[f]=i[f+1]=i[f+2]=c}e.putImageData(s,0,0)}#w(e){if(!e)return;if(e.knockoutMaskEntry)this.canvasFactory.destroy(e.knockoutMaskEntry),e.knockoutMaskEntry=null;if(e.knockoutTempEntry)this.canvasFactory.destroy(e.knockoutTempEntry),e.knockoutTempEntry=null;if(e.knockoutBackdropEntry)this.canvasFactory.destroy(e.knockoutBackdropEntry),e.knockoutBackdropEntry=null}beginAnnotation(e,t,a,n,s,i,f){if(this.#u(),u5(this.ctx),this.ctx.save(),this.save(e),this.baseTransform)this.ctx.setTransform(...this.baseTransform);if(a){let l=a[2]-a[0],c=a[3]-a[1];if(i&&this.annotationCanvasMap){n=n.slice(),n[4]-=a[0],n[5]-=a[1],a=a.slice(),a[0]=a[1]=0,a[2]=l,a[3]=c,Fe.singularValueDecompose2dScale(ma(this.ctx),Zs);let{viewportScale:h}=this,u=Math.ceil(l*this.outputScaleX*h),g=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(u,g);let{canvas:b,context:d}=this.annotationCanvas;if(f){let j=this.annotationCanvasMap.getOrInsertComputed(t,w2);b.setAttribute("data-canvas-name",f);let A=j.findIndex((C)=>C.getAttribute("data-canvas-name")===f);if(A===-1)j.push(b);else j[A]=b}else this.annotationCanvasMap.set(t,b);this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(Zs[0],0,0,-Zs[1],0,c*Zs[1]),u5(this.ctx)}else{u5(this.ctx),this.endPath(e);let h=new Path2D;h.rect(a[0],a[1],l,c),this.ctx.clip(h)}}this.current=new A8(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(e,...n),this.transform(e,...s),this.baseTransform=ma(this.ctx)}endAnnotation(e){if(this.annotationCanvas)this.ctx.restore(),this.#h(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas;this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){if(!this.contentVisible)return;let a=t.count;t=this.getObject(e,t.data,t),t.count=a;let n=this.#c(this.current.fillAlpha),s=this.ctx,i=this._createMaskCanvas(e,t),f=i.canvas;if(s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(f,i.offsetX,i.offsetY),this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,i.offsetX,i.offsetX+f.width,i.offsetY,i.offsetY+f.height).recordOperation(e),s.restore(),i.canvasEntry)this.canvasFactory.destroy(i.canvasEntry);this.compose(),this.#m(n)}paintImageMaskXObjectRepeat(e,t,a,n=0,s=0,i,f){if(!this.contentVisible)return;t=this.getObject(e,t.data,t);let l=this.#c(this.current.fillAlpha),c=this.ctx;c.save();let h=ma(c);c.transform(a,n,s,i,0,0);let u=this._createMaskCanvas(e,t);c.setTransform(1,0,0,1,u.offsetX-h[4],u.offsetY-h[5]),this.dependencyTracker?.resetBBox(e);for(let g=0,b=f.length;g<b;g+=2){let d=Fe.transform(h,[a,n,s,i,f[g],f[g+1]]);c.drawImage(u.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(e,this.ctx,d[4],d[4]+u.canvas.width,d[5],d[5]+u.canvas.height)}if(c.restore(),u.canvasEntry)this.canvasFactory.destroy(u.canvasEntry);this.compose(),this.dependencyTracker?.recordOperation(e),this.#m(l)}paintImageMaskXObjectGroup(e,t){if(!this.contentVisible)return;let a=this.#c(this.current.fillAlpha),n=this.ctx,s=this.current.fillColor,i=this.current.patternFill;this.dependencyTracker?.resetBBox(e).recordDependencies(e,qi.transformAndFill);for(let f of t){let{data:l,width:c,height:h,transform:u}=f,g=this.canvasFactory.create(c,h),b=g.context;b.save();let d=this.getObject(e,l,f);NA(b,d),b.globalCompositeOperation="source-in",b.fillStyle=i?s.getPattern(b,this,j0(n),En.FILL,e):s,b.fillRect(0,0,c,h),b.restore(),n.save(),n.transform(...u),n.scale(1,-1),h5(n,g.canvas,0,0,c,h,0,-1,1,1),this.canvasFactory.destroy(g),this.dependencyTracker?.recordBBox(e,n,0,c,0,h),n.restore()}this.compose(),this.dependencyTracker?.recordOperation(e),this.#m(a)}paintImageXObject(e,t){if(!this.contentVisible)return;let a=this.getObject(e,t);if(!a){ot("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e,a)}paintImageXObjectRepeat(e,t,a,n,s){if(!this.contentVisible)return;let i=this.getObject(e,t);if(!i){ot("Dependent image isn't ready yet");return}let{width:f,height:l}=i,c=[];for(let h=0,u=s.length;h<u;h+=2)c.push({transform:[a,0,0,n,s[h],s[h+1]],x:0,y:0,w:f,h:l});this.paintInlineImageXObjectGroup(e,i,c)}applyTransferMapsToCanvas(e){if(this.current.transferMaps!=="none")e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none";return e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return{img:e.bitmap,canvasEntry:null};let{bitmap:t,width:a,height:n}=e,s=this.canvasFactory.create(a,n),i=s.context;return i.filter=this.current.transferMaps,i.drawImage(t,0,0),i.filter="none",{img:s.canvas,canvasEntry:s}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;let{width:a,height:n}=t,s=this.#c(this.current.fillAlpha),i=this.ctx;this.save(e);let{filter:f}=i;if(f!=="none"&&f!=="")i.filter="none";i.scale(1/a,-1/n);let l,c=null;if(t.bitmap){let u=this.applyTransferMapsToBitmap(t);l=u.img,c=u.canvasEntry}else{let u=this.canvasFactory.create(a,n);RA(u.context,t),l=this.applyTransferMapsToCanvas(u.context),c=u}let h=this._scaleImage(l,j0(i));if(i.imageSmoothingEnabled=EA(ma(i),t.interpolate),this.dependencyTracker)this.dependencyTracker.resetBBox(e).recordBBox(e,i,0,a,-n,0).recordDependencies(e,qi.imageXObject).recordOperation(e),this.imagesTracker?.record(i,a,n,this.dependencyTracker.clipBox);if(h5(i,h.img,0,0,h.paintWidth,h.paintHeight,0,-n,a,n),h.tmpCanvas)this.canvasFactory.destroy(h.tmpCanvas);if(c)this.canvasFactory.destroy(c);this.compose(),this.restore(e),this.#m(s)}paintInlineImageXObjectGroup(e,t,a){if(!this.contentVisible)return;let n=this.#c(this.current.fillAlpha),s=this.ctx,i,f=null;if(t.bitmap)i=t.bitmap;else{let{width:l,height:c}=t,h=this.canvasFactory.create(l,c);RA(h.context,t),i=this.applyTransferMapsToCanvas(h.context),f=h}this.dependencyTracker?.resetBBox(e);for(let l of a)s.save(),s.transform(...l.transform),s.scale(1,-1),h5(s,i,l.x,l.y,l.w,l.h,0,-1,1,1),this.dependencyTracker?.recordBBox(e,s,0,1,-1,0),s.restore();if(f)this.canvasFactory.destroy(f);this.dependencyTracker?.recordOperation(e),this.compose(),this.#m(n)}paintSolidColorImageMask(e){if(!this.contentVisible)return;let t=this.#c(this.current.fillAlpha);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,qi.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose(),this.#m(t)}markPoint(e,t){}markPointProps(e,t,a){}beginMarkedContent(e,t){this.dependencyTracker?.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,a){if(this.dependencyTracker?.beginMarkedContent(e),t==="OC")this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(a)});else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(e){this.dependencyTracker?.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,a){let n=this.current.isEmptyClip();if(this.pendingClip)this.current.updateClipFromPath();if(!this.pendingClip)this.compose(a);let s=this.ctx;if(this.pendingClip){if(!n)if(this.pendingClip===zA)s.clip(t,"evenodd");else s.clip(t);this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)}else this.dependencyTracker?.recordOperation(e);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=ma(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),a=Math.hypot(e[0],e[2]),n=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(a,n)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:a,c:n,d:s}=this.ctx.getTransform(),i,f;if(a===0&&n===0){let l=Math.abs(t),c=Math.abs(s);if(l===c)if(e===0)i=f=1/l;else{let h=l*e;i=f=h<1?1/h:1}else if(e===0)i=1/l,f=1/c;else{let h=l*e,u=c*e;i=h<1?1/h:1,f=u<1?1/u:1}}else{let l=Math.abs(t*s-a*n),c=Math.hypot(t,a),h=Math.hypot(n,s);if(e===0)i=h/l,f=c/l;else{let u=e*l;i=h>u?h/u:1,f=c>u?c/u:1}}this._cachedScaleForStroking[0]=i,this._cachedScaleForStroking[1]=f}return this._cachedScaleForStroking}rescaleAndStroke(e,t){let{ctx:a,current:{lineWidth:n}}=this,[s,i]=this.getScaleForStroking();if(s===i){a.lineWidth=(n||1)*s,a.stroke(e);return}let f=a.getLineDash();if(t)a.save();a.scale(s,i),u8.a=1/s,u8.d=1/i;let l=new Path2D;if(l.addPath(e,u8),f.length>0){let c=Math.max(s,i);a.setLineDash(f.map((h)=>h/c)),a.lineDashOffset/=c}if(a.lineWidth=n||1,a.stroke(l),t)a.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(let e in k0)if(Xo.prototype[e]!==void 0)Xo.prototype[k0[e]]=Xo.prototype[e];class v2{#e=null;#t=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(e,t,a){this._source=e,this.#e=t,this.#t=a}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return Ma(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#e(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let a=new this.#t(this,e,t);return this._rangeReaders.add(a),a}cancelAllRequests(e){this._fullReader?.cancel(e);for(let t of new Set(this._rangeReaders))t.cancel(e)}}class k2{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(e){this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){Et("Abstract method `read` called")}cancel(e){Et("Abstract method `cancel` called")}}class A2{_stream=null;constructor(e,t,a){this._stream=e}async read(){Et("Abstract method `read` called")}cancel(e){Et("Abstract method `cancel` called")}}function $E(e){let t=!0,a=n("filename\\*","i").exec(e);if(a){a=a[1];let u=l(a);return u=unescape(u),u=c(u),u=h(u),i(u)}if(a=f(e),a){let u=h(a);return i(u)}if(a=n("filename","i").exec(e),a){a=a[1];let u=l(a);return u=h(u),i(u)}function n(u,g){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',g)}function s(u,g){if(u){if(!/^[\x00-\xFF]+$/.test(g))return g;try{let b=new TextDecoder(u,{fatal:!0}),d=D5(g);g=b.decode(d),t=!1}catch{}}return g}function i(u){if(t&&/[\x80-\xff]/.test(u)){if(u=s("utf-8",u),t)u=s("iso-8859-1",u)}return u}function f(u){let g=[],b,d=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((b=d.exec(u))!==null){let[,A,C,y]=b;if(A=parseInt(A,10),A in g){if(A===0)break;continue}g[A]=[C,y]}let j=[];for(let A=0;A<g.length;++A){if(!(A in g))break;let[C,y]=g[A];if(y=l(y),C){if(y=unescape(y),A===0)y=c(y)}j.push(y)}return j.join("")}function l(u){if(u.startsWith('"')){let g=u.slice(1).split("\\\"");for(let b=0;b<g.length;++b){let d=g[b].indexOf('"');if(d!==-1)g[b]=g[b].slice(0,d),g.length=b+1;g[b]=g[b].replaceAll(/\\(.)/g,"$1")}u=g.join('"')}return u}function c(u){let g=u.indexOf("'");if(g===-1)return u;let b=u.slice(0,g),j=u.slice(g+1).replace(/^[^']*'/,"");return s(b,j)}function h(u){if(!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u))return u;return u.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(g,b,d,j){if(d==="q"||d==="Q")return j=j.replaceAll("_"," "),j=j.replaceAll(/=([0-9a-f]{2})/gi,function(A,C){return String.fromCharCode(parseInt(C,16))}),s(b,j);try{j=atob(j)}catch{}return s(b,j)})}return""}function Fy(e,t){let a=new Headers;if(!e||!t||typeof t!=="object")return a;for(let n in t){let s=t[n];if(s!==void 0)a.append(n,s)}return a}function I5(e){return URL.parse(e)?.origin??null}function Oy({responseHeaders:e,isHttp:t,rangeChunkSize:a,disableRange:n}){let s={contentLength:0,isRangeSupported:!1},i=parseInt(e.get("Content-Length"),10);if(!Number.isInteger(i))return s;if(s.contentLength=i,i<=2*a)return s;if(n||!t)return s;if(e.get("Accept-Ranges")!=="bytes")return s;if((e.get("Content-Encoding")||"identity")==="identity")s.isRangeSupported=!0;return s}function By(e){let t=e.get("Content-Disposition");if(t){let a=$E(t);if(a.includes("%"))try{a=decodeURIComponent(a)}catch{}if(F8(a))return a}return null}function G5(e,t){return new h2(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,e===404||e===0&&t.protocol==="file:")}function Ty(e,t){if(e!==t)throw Error(`Expected range response-origin "${e}" to match "${t}".`)}function Hy(e,t,a,n){return fetch(e,{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:a?"include":"same-origin",redirect:"follow"})}function My(e,t){if(e!==200&&e!==206)throw G5(e,t)}function X5(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw Error(`getArrayBuffer - unexpected data: ${e}`)}class Dy extends v2{_responseOrigin=null;constructor(e){super(e,xy,Ry);let{httpHeaders:t,url:a}=e;Ma(/https?:/.test(a.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Fy(!0,t)}}class xy extends k2{_abortController=new AbortController;_reader=null;constructor(e){super(e);let{disableRange:t,disableStream:a,rangeChunkSize:n,url:s,withCredentials:i}=e._source;this._isStreamingSupported=!a;let f=new Headers(e.headers);Hy(s,f,i,this._abortController).then((l)=>{e._responseOrigin=I5(l.url),My(l.status,s),this._reader=l.body.getReader();let c=l.headers,{contentLength:h,isRangeSupported:u}=Oy({responseHeaders:c,isHttp:!0,rangeChunkSize:n,disableRange:t});if(this._contentLength=h,this._isRangeSupported=u,this._filename=By(c),!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new pf("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};return this._loaded+=e.byteLength,this._callOnProgress(),{value:X5(e),done:!1}}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class Ry extends A2{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(e,t,a){super(e,t,a);let{url:n,withCredentials:s}=e._source,i=new Headers(e.headers);i.append("Range",`bytes=${t}-${a-1}`),Hy(n,i,s,this._abortController).then((f)=>{let l=I5(f.url);Ty(l,e._responseOrigin),My(f.status,n),this._reader=f.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};return{value:X5(e),done:!1}}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}function UA(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function K5(){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}class Ny extends v2{_progressiveDone=!1;_queuedChunks=[];constructor(e){super(e,Ey,zy);let{pdfDataRangeTransport:t}=e,{initialData:a,progressiveDone:n}=t;if(a?.length>0){let i=UA(a);this._queuedChunks.push(i)}this._progressiveDone=n;let s=(i)=>{switch(i.type){case"range":case"progressiveRead":this.#e(i.begin,i.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};t.transportReady(s)}#e(e,t){let a=UA(t);if(e===void 0)if(this._fullReader)this._fullReader._enqueue(a);else this._queuedChunks.push(a);else{let n=this._rangeReaders.keys().find((s)=>s._begin===e);Ma(n,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),n._enqueue(a)}}getFullReader(){let e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,t){let a=super.getRangeReader(e,t);if(a)a.onDone=()=>this._rangeReaders.delete(a),this._source.pdfDataRangeTransport.requestDataRange(e,t);return a}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}class Ey extends k2{#e=K5.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(e){super(e);let{pdfDataRangeTransport:t,disableRange:a,disableStream:n}=e._source,{length:s,contentDispositionFilename:i}=t;this._queuedChunks=e._queuedChunks||[];for(let l of this._queuedChunks)this._loaded+=l.byteLength;if(this._done=e._progressiveDone,this._contentLength=s,this._isStreamingSupported=!n,this._isRangeSupported=!a,F8(i))this._filename=i;this._headersCapability.resolve();let f=this._loaded;Promise.resolve().then(()=>{if(f>0&&this._loaded===f)this._callOnProgress()})}_enqueue(e){if(this._done)return;if(this._requests.length>0)this._requests.shift().resolve({value:e,done:!1});else this._queuedChunks.push(e);this._loaded+=e.byteLength,this._callOnProgress()}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this.#e()}progressiveDone(){if(this._done||=!0,this._queuedChunks.length===0)this.#e()}}class zy extends A2{#e=K5.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(e,t,a){super(e,t,a);this._begin=t}_enqueue(e){if(this._done)return;if(this._requests.length===0)this._queuedChunk=e;else this._requests.shift().resolve({value:e,done:!1}),this.#e();this._done=!0,this.onDone?.()}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this.#e(),this.onDone?.()}}var m8=200,IA=206;function WE(e){return typeof e!=="string"?e:D5(e).buffer}class Uy extends v2{#e=new WeakMap;_responseOrigin=null;constructor(e){super(e,Iy,Gy);let{httpHeaders:t,url:a}=e;this.url=a,this.isHttp=/https?:/.test(a.protocol),this.headers=Fy(this.isHttp,t)}_request(e){let t=new XMLHttpRequest,a={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};this.#e.set(t,a),t.open("GET",this.url),t.withCredentials=this._source.withCredentials;for(let[n,s]of this.headers)t.setRequestHeader(n,s);if(this.isHttp&&"begin"in e&&"end"in e)t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),a.validateStatus=(n)=>n===IA||n===m8;else a.validateStatus=(n)=>n===m8;return t.responseType="arraybuffer",Ma(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>e.onError(t.status),t.onreadystatechange=this.#a.bind(this,t),t.onprogress=this.#t.bind(this,t),t.send(null),t}#t(e,t){this.#e.get(e)?.onProgress?.(t)}#a(e,t){let a=this.#e.get(e);if(!a)return;if(e.readyState>=2&&a.onHeadersReceived)a.onHeadersReceived(),delete a.onHeadersReceived;if(e.readyState!==4)return;if(!this.#e.has(e))return;if(this.#e.delete(e),e.status===0&&this.isHttp){a.onError(e.status);return}let n=e.status||m8;if(!a.validateStatus(n)){a.onError(e.status);return}let s=WE(e.response);if(n===IA){let i=e.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(i))a.onDone(s);else ot('Missing or invalid "Content-Range" header.'),a.onError(0)}else if(s)a.onDone(s);else a.onError(e.status)}_abortRequest(e){if(this.#e.has(e))this.#e.delete(e),e.abort()}getRangeReader(e,t){let a=super.getRangeReader(e,t);if(a)a.onClosed=()=>this._rangeReaders.delete(a);return a}}class Iy extends k2{#e=K5.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(e){super(e);this._fullRequestXhr=e._request({onHeadersReceived:this.#t.bind(this),onDone:this.#a.bind(this),onError:this.#n.bind(this),onProgress:this.#s.bind(this)})}#t(){let e=this._stream,{disableRange:t,rangeChunkSize:a}=e._source,n=this._fullRequestXhr;e._responseOrigin=I5(n.responseURL);let s=n.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((c)=>{let[h,...u]=c.split(": ");return[h,u.join(": ")]}):[]),{contentLength:f,isRangeSupported:l}=Oy({responseHeaders:i,isHttp:e.isHttp,rangeChunkSize:a,disableRange:t});if(this._contentLength=f,this._isRangeSupported=l,this._filename=By(i),this._isRangeSupported)e._abortRequest(n);this._headersCapability.resolve()}#a(e){if(this._requests.length>0)this._requests.shift().resolve({value:e,done:!1});else this._cachedChunks.push(e);if(this._done=!0,this._cachedChunks.length===0)this.#e()}#n(e){this._storedError=G5(e,this._stream.url),this._headersCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#s(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),this.#e(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class Gy extends A2{#e=K5.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(e,t,a){super(e,t,a);this._requestXhr=e._request({begin:t,end:a,onHeadersReceived:this.#t.bind(this),onDone:this.#a.bind(this),onError:this.#n.bind(this),onProgress:null})}#t(){let e=I5(this._requestXhr?.responseURL);try{Ty(e,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#n(0)}}#a(e){if(this._requests.length>0)this._requests.shift().resolve({value:e,done:!1});else this._queuedChunk=e;this._done=!0,this.#e(),this.onClosed?.()}#n(e){this._storedError??=G5(e,this._stream.url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this.#e(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function Xy(e,t=null){let a=process.getBuiltinModule("fs"),{Readable:n}=process.getBuiltinModule("stream"),s=a.createReadStream(e,t);return n.toWeb(s)}class Ky extends v2{constructor(e){super(e,Ly,Vy);let{url:t}=e;Ma(t.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class Ly extends k2{_reader=null;constructor(e){super(e);let{disableRange:t,disableStream:a,rangeChunkSize:n,url:s}=e._source;this._isStreamingSupported=!a,process.getBuiltinModule("fs/promises").lstat(s).then((f)=>{let l=Xy(s);this._reader=l.getReader();let{size:c}=f;if(this._contentLength=c,this._isRangeSupported=!t&&c>2*n,!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new pf("Streaming is disabled."));this._headersCapability.resolve()}).catch((f)=>{if(f.code==="ENOENT")f=G5(0,s);this._headersCapability.reject(f)})}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};return this._loaded+=e.byteLength,this._callOnProgress(),{value:X5(e),done:!1}}cancel(e){this._reader?.cancel(e)}}class Vy extends A2{_readCapability=Promise.withResolvers();_reader=null;constructor(e,t,a){super(e,t,a);let{url:n}=e._source;try{let s=Xy(n,{start:t,end:a-1});this._reader=s.getReader(),this._readCapability.resolve()}catch(s){this._readCapability.reject(s)}}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};return{value:X5(e),done:!1}}cancel(e){this._reader?.cancel(e)}}function PE(e){return r2(e)?Dy:Js?Ky:Uy}class gf{static#e=null;static#t="";static get workerPort(){return this.#e}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw Error("Invalid `workerPort` type.");this.#e=e}static get workerSrc(){return this.#t}static set workerSrc(e){if(typeof e!=="string")throw Error("Invalid `workerSrc` type.");this.#t=e}}class Yy{#e;#t;constructor({parsedData:e,rawData:t}){this.#e=e,this.#t=t}getRaw(){return this.#t}get(e){return this.#e.get(e)??null}[Symbol.iterator](){return this.#e.entries()}}var Rr=Symbol("INTERNAL");class Jy{#e=!1;#t=!1;#a=!1;#n=!0;constructor(e,{name:t,intent:a,usage:n,rbGroups:s}){this.#e=!!(e&Ys.DISPLAY),this.#t=!!(e&Ys.PRINT),this.name=t,this.intent=a,this.usage=n,this.rbGroups=s}get visible(){if(this.#a)return this.#n;if(!this.#n)return!1;let{print:e,view:t}=this.usage;if(this.#e)return t?.viewState!=="OFF";else if(this.#t)return e?.printState!=="OFF";return!0}_setVisible(e,t,a=!1){if(e!==Rr)Et("Internal method `_setVisible` called.");this.#a=a,this.#n=t}get serializable(){return{userSet:this.#a,visible:this.#n}}}class x8{#e=null;#t=new Map;#a=null;#n=null;#s;creator=null;name=null;constructor(e,t=Ys.DISPLAY,a=null){if(this.#s=e,this.renderingIntent=t,e===null)return;this.name=e.name,this.creator=e.creator,this.#n=e.order;for(let n of e.groups)this.#t.set(n.id,new Jy(t,n));if(a){if(a.size!==this.#t.size)Et("Incorrect serialized groupState.");for(let[n,s]of a)this.#t.get(n)._setVisible(Rr,s.visible,s.userSet)}else{if(e.baseState==="OFF")for(let n of this.#t.values())n._setVisible(Rr,!1);for(let n of e.on)this.#t.get(n)._setVisible(Rr,!0);for(let n of e.off)this.#t.get(n)._setVisible(Rr,!1)}this.#a=this.getHash()}#f(e){let t=e.length;if(t<2)return!0;let a=e[0];for(let n=1;n<t;n++){let s=e[n],i;if(Array.isArray(s))i=this.#f(s);else if(this.#t.has(s))i=this.#t.get(s).visible;else return ot(`Optional content group not found: ${s}`),!0;switch(a){case"And":if(!i)return!1;break;case"Or":if(i)return!0;break;case"Not":return!i;default:return!0}}return a==="And"}isVisible(e){if(this.#t.size===0)return!0;if(!e)return M5("Optional content group not defined."),!0;if(e.type==="OCG"){if(!this.#t.has(e.id))return ot(`Optional content group not found: ${e.id}`),!0;return this.#t.get(e.id).visible}else if(e.type==="OCMD"){if(e.expression)return this.#f(e.expression);if(!e.policy||e.policy==="AnyOn"){for(let t of e.ids){if(!this.#t.has(t))return ot(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(let t of e.ids){if(!this.#t.has(t))return ot(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(let t of e.ids){if(!this.#t.has(t))return ot(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(let t of e.ids){if(!this.#t.has(t))return ot(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return ot(`Unknown optional content policy ${e.policy}.`),!0}return ot(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,a=!0){let n=this.#t.get(e);if(!n){ot(`Optional content group not found: ${e}`);return}if(a&&t&&n.rbGroups.length){for(let s of n.rbGroups)for(let i of s)if(i!==e)this.#t.get(i)?._setVisible(Rr,!1,!0)}n._setVisible(Rr,!!t,!0),this.#e=null}setOCGState({state:e,preserveRB:t}){let a;for(let n of e){switch(n){case"ON":case"OFF":case"Toggle":a=n;continue}let s=this.#t.get(n);if(!s)continue;switch(a){case"ON":this.setVisibility(n,!0,t);break;case"OFF":this.setVisibility(n,!1,t);break;case"Toggle":this.setVisibility(n,!s.visible,t);break}}this.#e=null}get hasInitialVisibility(){return this.#a===null||this.getHash()===this.#a}getOrder(){if(!this.#t.size)return null;if(this.#n)return this.#n.slice();return[...this.#t.keys()]}getGroup(e){return this.#t.get(e)||null}getHash(){if(this.#e!==null)return this.#e;let e=new y5;for(let[t,a]of this.#t)e.update(`${t}:${a.visible}`);return this.#e=e.hexdigest()}[Symbol.iterator](){return this.#t.entries()}get serializable(){let e=new Map;for(let[t,a]of this.#t)e.set(t,a.serializable);return{data:this.#s,renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:e,renderingIntent:t,groupState:a}){return new x8(e,t,a)}}class Qy{#e=null;#t=null;#a=0;#n=null;#s=null;get pagesNumber(){return this.#a}set pagesNumber(e){if(this.#a===e)return;this.#a=e,this.#e=null,this.#t=null}#f(){if(this.#e)return;let e=this.#a,t=this.#e=new Uint32Array(e);for(let a=0;a<e;a++)t[a]=a+1;this.#t=new Int32Array(t)}#i(){let e=new Map,t=this.#e;for(let a=0,n=this.#a;a<n;a++){let s=t[a],i=e.get(s);if(i)i.push(a+1);else e.set(s,[a+1])}return e}movePages(e,t,a){this.#f();let n=this.#e,s=this.#i(),i=t.length,f=new Uint32Array(i),l=0;for(let g=0;g<i;g++){let b=t[g]-1;if(f[g]=n[b],b<a)l++}let c=this.#a,h=c-i,u=da(a-l,0,h);for(let g=0,b=0;g<c;g++)if(!e.has(g+1))n[b++]=n[g];if(n.copyWithin(u+i,u,h),n.set(f,u),this.#l(s),n.every((g,b)=>g===b+1))this.#e=null}deletePages(e){this.#f();let t=this.#e,a=this.#i();this.#s={pageNumberToId:t.slice(),pagesNumber:this.#a,prevPageNumbers:this.#t.slice()};let n=this.#a-e.length;this.#a=n;let s=this.#e=new Uint32Array(n);this.#t=new Int32Array(n);let i=0,f=0;for(let l of e){let c=l-1;if(c!==i)s.set(t.subarray(i,c),f),f+=c-i;i=c+1}if(i<t.length)s.set(t.subarray(i),f);this.#l(a,new Set(e))}cancelDelete(){if(this.#s)this.#e=this.#s.pageNumberToId,this.#a=this.#s.pagesNumber,this.#t=this.#s.prevPageNumbers,this.#s=null}cleanSavedData(){this.#s=null}copyPages(e){this.#f(),this.#n={pageNumbers:e,pageIds:e.map((t)=>this.#e[t-1])}}cancelCopy(){this.#n=null}pastePages(e){this.#f();let t=this.#e,a=this.#i(),{pageNumbers:n,pageIds:s}=this.#n,i=this.#a+n.length;this.#a=i;let f=this.#e=new Uint32Array(i);this.#t=new Int32Array(i),f.set(t.subarray(0,e),0),f.set(s,e),f.set(t.subarray(e),e+n.length),this.#l(a,null,e,n),this.#n=null}#l(e,t=null,a=-1,n=null){let s=this.#t,i=this.#e,f=a+(n?.length??0),l=new Map;for(let c=0,h=this.#a;c<h;c++){if(c>=a&&c<f){s[c]=-n[c-a];continue}let u=i[c],g=e.get(u),b=l.get(u)||0;if(t&&g)while(b<g.length&&t.has(g[b]))b++;s[c]=g?.[b],l.set(u,b+1)}}hasBeenAltered(){return this.#e!==null}getPageMappingForSaving(e=null){e??=this.#i();let t=0;for(let n of e.values())t=Math.max(t,n.length);let a=Array(t);for(let n=0;n<t;n++)a[n]={document:null,pageIndices:[],includePages:[]};for(let[n,s]of e)for(let i=0,f=s.length;i<f;i++)a[i].includePages.push([n-1,s[i]-1]);for(let{includePages:n,pageIndices:s}of a){n.sort((i,f)=>i[0]-f[0]);for(let i=0,f=n.length;i<f;i++)s.push(n[i][1]),n[i]=n[i][0]}return a}extractPages(e){e=Array.from(e).sort((a,n)=>a-n);let t=new Map;for(let a=0,n=e.length;a<n;a++){let s=this.getPageId(e[a]);t.getOrInsertComputed(s,w2).push(a+1)}return this.getPageMappingForSaving(t)}getPrevPageNumber(e){return this.#t?.[e-1]??0}getPageNumber(e){if(!this.#e)return e;let t=this.#e;for(let a=0,n=this.#a;a<n;a++)if(t[a]===e)return a+1;return 0}getPageId(e){return this.#e?.[e-1]??e}getMapping(){return this.#e?.subarray(0,this.pagesNumber)}}var Uo=Symbol("INITIAL_DATA"),GA=()=>({...Promise.withResolvers(),data:Uo});class R8{#e=new Map;get(e,t=null){if(t){let n=this.#e.getOrInsertComputed(e,GA);return n.promise.then(()=>t(n.data)),null}let a=this.#e.get(e);if(!a||a.data===Uo)throw Error(`Requesting object that isn't resolved yet ${e}.`);return a.data}has(e){let t=this.#e.get(e);return!!t&&t.data!==Uo}delete(e){let t=this.#e.get(e);if(!t||t.data===Uo)return!1;return this.#e.delete(e),!0}resolve(e,t=null){let a=this.#e.getOrInsertComputed(e,GA);if(a.data!==Uo)throw Error(`Object already resolved ${e}.`);a.data=t,a.resolve()}clear(){for(let{data:e}of this.#e.values())e?.bitmap?.close();this.#e.clear()}*[Symbol.iterator](){for(let[e,{data:t}]of this.#e)if(t!==Uo)yield[e,t]}}var ez=1e5,XA=30;class fs{#e=Promise.withResolvers();#t=null;#a=!1;#n=!!globalThis.FontInspector?.enabled;#s=null;#f=null;#i=null;#l=0;#o=0;#r=null;#u=null;#h=0;#g=0;#b=Object.create(null);#p=[];#c=null;#m=[];#d=new WeakMap;#j=null;static#w=new Map;static#A=new Map;static#y=new WeakMap;static#q=null;static#S=new Set;constructor({textContentSource:e,images:t,container:a,viewport:n}){if(e instanceof ReadableStream)this.#c=e;else if(typeof e==="object")this.#c=new ReadableStream({start(c){c.enqueue(e),c.close()}});else throw Error('No "textContentSource" parameter specified.');this.#t=this.#u=a,this.#s=t,this.#g=n.scale*y0.pixelRatio,this.#h=n.rotation,this.#i={div:null,properties:null,ctx:null};let{pageWidth:s,pageHeight:i,pageX:f,pageY:l}=n.rawDims;this.#j=[1,0,0,-1,-f,l+i],this.#o=s,this.#l=i,fs.#M(),a.style.setProperty("--min-font-size",fs.#q),Ir(a,n),this.#e.promise.finally(()=>{fs.#S.delete(this),this.#i=null,this.#b=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=ea.platform;return ft(this,"fontFamilyMap",new Map([["sans-serif",`${e&&t?"Calibri, ":""}sans-serif`],["monospace",`${e&&t?"Lucida Console, ":""}monospace`]]))}render(){if(this.#s)this.#t.append(this.#s.render());let e=()=>{this.#r.read().then(({value:t,done:a})=>{if(a){this.#e.resolve();return}this.#f??=t.lang,Object.assign(this.#b,t.styles),this.#k(t.items),e()},this.#e.reject)};return this.#r=this.#c.getReader(),fs.#S.add(this),e(),this.#e.promise}update({viewport:e,onBefore:t=null}){let a=e.scale*y0.pixelRatio,n=e.rotation;if(n!==this.#h)t?.(),this.#h=n,Ir(this.#u,{rotation:n});if(a!==this.#g){t?.(),this.#g=a;let s={div:null,properties:null,ctx:fs.#B(this.#f)};for(let i of this.#m)s.properties=this.#d.get(i),s.div=i,this.#O(s)}}cancel(){let e=new pf("TextLayer task cancelled.");this.#r?.cancel(e).catch(()=>{}),this.#r=null,this.#e.reject(e)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#p}#k(e){if(this.#a)return;this.#i.ctx??=fs.#B(this.#f);let t=this.#m,a=this.#p;for(let n of e){if(t.length>ez){ot("Ignoring additional textDivs for performance reasons."),this.#a=!0;return}if(n.str===void 0){if(n.type==="beginMarkedContentProps"||n.type==="beginMarkedContent"){let s=this.#t;if(this.#t=document.createElement("span"),this.#t.classList.add("markedContent"),n.id)this.#t.setAttribute("id",`${n.id}`);if(n.tag==="Artifact")this.#t.ariaHidden=!0;s.append(this.#t)}else if(n.type==="endMarkedContent")this.#t=this.#t.parentNode;continue}a.push(n.str),this.#_(n)}}#_(e){let t=document.createElement("span"),a={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};this.#m.push(t);let n=Fe.transform(this.#j,e.transform),s=Math.atan2(n[1],n[0]),i=this.#b[e.fontName];if(i.vertical)s+=Math.PI/2;let f=this.#n&&i.fontSubstitution||i.fontFamily;f=fs.fontFamilyMap.get(f)||f;let l=Math.hypot(n[2],n[3]),c=l*fs.#D(f,i,this.#f),h,u;if(s===0)h=n[4],u=n[5]-c;else h=n[4]+c*Math.sin(s),u=n[5]-c*Math.cos(s);let g=t.style;if(g.left=`${(100*h/this.#o).toFixed(2)}%`,g.top=`${(100*u/this.#l).toFixed(2)}%`,g.setProperty("--font-height",`${l.toFixed(2)}px`),g.fontFamily=f,a.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#n)t.dataset.fontName=i.fontSubstitutionLoadedName||e.fontName;if(s!==0)a.angle=s*(180/Math.PI);let b=!1;if(e.str.length>1)b=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){let d=Math.abs(e.transform[0]),j=Math.abs(e.transform[3]);if(d!==j&&Math.max(d,j)/Math.min(d,j)>1.5)b=!0}if(b)a.canvasWidth=i.vertical?e.height:e.width;if(this.#d.set(t,a),this.#i.div=t,this.#i.properties=a,this.#O(this.#i),a.hasText)this.#t.append(t);if(a.hasEOL){let d=document.createElement("br");d.setAttribute("role","presentation"),this.#t.append(d)}}#O(e){let{div:t,properties:a,ctx:n}=e,{style:s}=t;if(a.canvasWidth!==0&&a.hasText){let{fontFamily:i}=s,{canvasWidth:f,fontSize:l}=a;fs.#F(n,l*this.#g,i);let{width:c}=n.measureText(t.textContent);if(c>0)s.setProperty("--scale-x",f*this.#g/c)}if(a.angle!==0)s.setProperty("--rotate",`${a.angle}deg`)}static cleanup(){if(this.#S.size>0)return;this.#w.clear();for(let{canvas:e}of this.#A.values())e.remove();this.#A.clear()}static#B(e=null){let t=this.#A.get(e||="");if(!t){let a=document.createElement("canvas");a.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",a.lang=e,document.body.append(a),t=a.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#A.set(e,t),this.#y.set(t,{size:0,family:""})}return t}static#F(e,t,a){let n=this.#y.get(e);if(t===n.size&&a===n.family)return;e.font=`${t}px ${a}`,n.size=t,n.family=a}static#M(){if(this.#q!==null)return;let e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#q=e.getBoundingClientRect().height,e.remove()}static#D(e,t,a){let n=this.#w.get(e);if(n)return n;let s=this.#B(a);s.canvas.width=s.canvas.height=XA,this.#F(s,XA,e);let i=s.measureText(""),f=i.fontBoundingBoxAscent,l=Math.abs(i.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let c=0.8;if(f)c=f/(f+l);else{if(ea.platform.isFirefox)ot("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");if(t.ascent)c=t.ascent;else if(t.descent)c=1+t.descent}return this.#w.set(e,c),c}}var tz=100;function N8(e={}){let t=new E8,{docId:a}=t,n=e.url?HE(e.url):null,s=e.data?ME(e.data):null,i=e.httpHeaders||null,f=e.withCredentials===!0,l=e.password??null,c=e.range instanceof z8?e.range:null,h=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536,u=e.worker instanceof Nn?e.worker:null,g=e.verbosity,b=typeof e.docBaseUrl==="string"&&!R5(e.docBaseUrl)?e.docBaseUrl:null,d=o5(e.cMapUrl),j=e.cMapPacked!==!1,A=o5(e.iccUrl),C=o5(e.standardFontDataUrl),y=o5(e.wasmUrl),O=e.stopAtErrors!==!0,T=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,M=typeof e.isOffscreenCanvasSupported==="boolean"?e.isOffscreenCanvasSupported:!Js,H=typeof e.isImageDecoderSupported==="boolean"?e.isImageDecoderSupported:!Js,N=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,x=typeof e.disableFontFace==="boolean"?e.disableFontFace:Js,z=e.fontExtraProperties===!0,K=e.enableXfa===!0,$=e.ownerDocument||globalThis.document,Q=e.disableRange===!0,P=e.disableStream===!0,te=e.disableAutoFetch===!0,ee=e.pdfBug===!0,L=e.CanvasFactory||(Js?vy:dy),J=e.FilterFactory||(Js?qy:jy),pe=e.BinaryDataFactory||(Js?ky:k8),ne=e.enableHWA===!0,Ae=e.enableWebGPU===!0?zE():Promise.resolve(!1),he=e.useWasm!==!1,re=e.pagesMapper||new Qy,be=typeof e.useSystemFonts==="boolean"?e.useSystemFonts:!Js&&!x,Ue=typeof e.useWorkerFetch==="boolean"?e.useWorkerFetch:!!(pe===k8&&d&&j&&C&&y&&r2(d,document.baseURI)&&r2(C,document.baseURI)&&r2(y,document.baseURI)),at=null;dE(g);let Ye={canvasFactory:new L({ownerDocument:$,enableHWA:ne}),filterFactory:new J({docId:a,ownerDocument:$}),binaryDataFactory:Ue?null:new pe({cMapUrl:d,standardFontDataUrl:C,wasmUrl:y})};if(!u)u=Nn.create({verbosity:g,port:gf.workerPort}),t._worker=u;let Ie={docId:a,apiVersion:"6.1.200",data:s,password:l,disableAutoFetch:te,rangeChunkSize:h,docBaseUrl:b,enableXfa:K,evaluatorOptions:{maxImageSize:T,disableFontFace:x,ignoreErrors:O,isOffscreenCanvasSupported:M,isImageDecoderSupported:H,canvasMaxAreaInBytes:N,fontExtraProperties:z,useSystemFonts:be,useWasm:he,useWorkerFetch:Ue,cMapUrl:d,cMapPacked:j,iccUrl:A,standardFontDataUrl:C,wasmUrl:y,hasGPU:!1}},mt={ownerDocument:$,pdfBug:ee,styleElement:at,enableHWA:ne,loadingParams:{disableAutoFetch:te,enableXfa:K}};return Promise.all([u.promise,Ae]).then(function([,vt]){if(u.destroyed)throw Error("Worker was destroyed");Ie.evaluatorOptions.hasGPU=vt;let ga=u.messageHandler.sendWithPromise("GetDocRequest",Ie,s?[s.buffer]:null),Dt;if(s);else if(c)Dt=new Ny({pdfDataRangeTransport:c,disableRange:Q,disableStream:P});else if(n)Dt=new(PE(n))({url:n,httpHeaders:i,withCredentials:f,rangeChunkSize:h,disableRange:Q,disableStream:P});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return ga.then((ta)=>{if(u.destroyed)throw Error("Worker was destroyed");let rn=new Io(a,ta,u.port),jt=new $y(rn,t,Dt,mt,Ye,re);if(t._transport=jt,t.destroyed)throw Error("Loading aborted");rn.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}class E8{static#e=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${E8.#e++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{if(this._worker?.port)this._worker._pendingDestroy=!0;await this._setupCapability.promise,await this._transport?.destroy()}catch(e){if(this._worker?.port)delete this._worker._pendingDestroy;throw e}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class z8{#e=Promise.withResolvers();#t=null;constructor(e,t,a=!1,n=null){this.length=e,this.initialData=t,this.progressiveDone=a,this.contentDispositionFilename=n}onDataRange(e,t){this.#t({type:"range",begin:e,chunk:t})}onDataProgressiveRead(e){this.#e.promise.then(()=>{this.#t({type:"progressiveRead",chunk:e})})}onDataProgressiveDone(){this.#e.promise.then(()=>{this.#t({type:"progressiveDone"})})}transportReady(e){this.#t=e,this.#e.resolve()}requestDataRange(e,t){Et("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Zy{constructor(e,t){this._pdfInfo=e,this._transport=t}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return ft(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(e){return this._transport.getAttachmentContent(e)}getAnnotationsByType(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(e){return this._transport.extractPages(e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(e){return this._transport.getRawData(e)}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class U8{#e=!1;#t=null;constructor(e,t,a,n,s=!1){this._pageIndex=e,this._pageInfo=t,this._transport=a,this._stats=s?new w8:null,this._pdfBug=s,this.commonObjs=a.commonObjs,this.objs=new R8,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#t=n,this.imageCoordinates=null}clone(e){let t=new U8(e,this._pageInfo,this._transport,this.#t,this._pdfBug);return t.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(t),t}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:a=0,offsetY:n=0,dontFlip:s=!1}={}){return new d2({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:a,offsetY:n,dontFlip:s})}getAnnotations({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ft(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,canvas:t=e.canvas,viewport:a,intent:n="display",annotationMode:s=kl.ENABLE,transform:i=null,background:f=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors:h=null,printAnnotationStorage:u=null,isEditing:g=!1,recordImages:b=!1,recordOperations:d=!1,operationsFilter:j=null}){this._stats?.time("Overall");let A=this._transport.getRenderingIntent(n,s,u,g),{renderingIntent:C,cacheKey:y}=A;this.#e=!1,l||=this._transport.getOptionalContentConfig(C);let O=this._intentStates.getOrInsertComputed(y,b8);if(O.streamReaderCancelTimeout)clearTimeout(O.streamReaderCancelTimeout),O.streamReaderCancelTimeout=null;let T=!!(C&Ys.PRINT);if(!O.displayReadyCapability)O.displayReadyCapability=Promise.withResolvers(),O.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(A);let M=!!(this._pdfBug&&globalThis.StepperManager?.enabled),H=!!t&&!this.recordedBBoxes&&(d||M),N=!!t&&!this.imageCoordinates&&b,x=(P)=>{if(O.renderTasks.delete($),H){let te=$.gfx?.dependencyTracker.take();if(te){if($.stepper?.setOperatorBBoxes(te,$.gfx.dependencyTracker.takeDebugMetadata()),d)this.recordedBBoxes=te}}if(N&&!P)this.imageCoordinates=$.gfx?.imagesTracker.take();if(T)this.#e=!0;if(this.#a(),P)$.capability.reject(P),this._abortOperatorList({intentState:O,reason:P instanceof Error?P:Error(P)});else $.capability.resolve();if(this._stats){if(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled)globalThis.Stats.add(this.pageNumber,this._stats)}},z=null,K=null;if(H||N)K=new fy(t,O.operatorList.length);if(H)z=new ly(K,M);let $=new Go({callback:x,params:{canvas:t,canvasContext:e,dependencyTracker:z??K,imagesTracker:N?new S5(t):null,viewport:a,transform:i,background:f},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:O.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!T,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:j});(O.renderTasks||=new Set).add($);let Q=$.task;return Promise.all([O.displayReadyCapability.promise,l]).then(([P,te])=>{if(this.destroyed){x();return}if(this._stats?.time("Rendering"),!(te.renderingIntent&C))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");$.initializeGraphics({transparency:P,optionalContentConfig:te}),$.operatorListChanged()}).catch(x),Q}getOperatorList({intent:e="display",annotationMode:t=kl.ENABLE,printAnnotationStorage:a=null,isEditing:n=!1}={}){function s(){if(f.operatorList.lastChunk)f.opListReadCapability.resolve(f.operatorList),f.renderTasks.delete(l)}let i=this._transport.getRenderingIntent(e,t,a,n,!0),f=this._intentStates.getOrInsertComputed(i.cacheKey,b8),l;if(!f.opListReadCapability)l=Object.create(null),l.operatorListChanged=s,f.opListReadCapability=Promise.withResolvers(),(f.renderTasks||=new Set).add(l),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(i);return f.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#t.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(n){return n.items.length}})}async getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((n)=>u2.textContent(n));let t=this.streamTextContent(e),a={items:[],styles:Object.create(null),lang:null};for await(let n of t)a.lang??=n.lang,Object.assign(a.styles,n.styles),a.items.push(...n.items);return a}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values()){if(this._abortOperatorList({intentState:t,reason:Error("Page was destroyed."),force:!0}),t.opListReadCapability)continue;for(let a of t.renderTasks)e.push(a.completed),a.cancel()}return this.objs.clear(),this.#e=!1,Promise.all(e)}cleanup(e=!1){this.#e=!0;let t=this.#a();if(e&&t)this._stats&&=new w8;return t}#a(){if(!this.#e||this.destroyed)return!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}_startRenderPage(e,t){let a=this._intentStates.get(t);if(!a)return;this._stats?.timeEnd("Page Request"),a.displayReadyCapability?.resolve(e)}_renderPageChunk(e,t){for(let a=0,n=e.length;a<n;a++)t.operatorList.fnArray.push(e.fnArray[a]),t.operatorList.argsArray.push(e.argsArray[a]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let a of t.renderTasks)a.operatorListChanged();if(e.lastChunk)this.#a()}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:a,modifiedIds:n}){let{map:s,transfer:i}=a,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#t.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:s,modifiedIds:n},void 0,i).getReader(),c=this._intentStates.get(t);c.streamReader=l;let h=()=>{l.read().then(({value:u,done:g})=>{if(g){c.streamReader=null;return}if(this._transport.destroyed)return;this._renderPageChunk(u,c),h()},(u)=>{if(c.streamReader=null,this._transport.destroyed)return;if(c.operatorList){c.operatorList.lastChunk=!0;for(let g of c.renderTasks)g.operatorListChanged();this.#a()}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.opListReadCapability.reject(u);else throw u})};h()}_abortOperatorList({intentState:e,reason:t,force:a=!1}){if(!e.streamReader)return;if(e.streamReaderCancelTimeout)clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null;if(!a){if(e.renderTasks.size>0)return;if(t instanceof x5){let n=tz;if(t.extraDelay>0&&t.extraDelay<1000)n+=t.extraDelay;e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new pf(t.message)).catch(()=>{}),e.streamReader=null,this._transport.destroyed)return;for(let[n,s]of this._intentStates)if(s===e){this._intentStates.delete(n);break}this.cleanup()}get stats(){return this._stats}}class Nn{#e=Promise.withResolvers();#t=null;#a=null;#n=null;static#s=0;static#f=!1;static#i=new WeakMap;static{if(Js)this.#f=!0,gf.workerSrc||="./pdf.worker.mjs";this._isSameOrigin=(e,t)=>{let a=URL.parse(e);if(!a?.origin||a.origin==="null")return!1;let n=new URL(t,a);return a.origin===n.origin},this._createCDNWrapper=(e)=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:a=jE()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=a,t){if(Nn.#i.has(t))throw Error("Cannot use more than one PDFWorker per port.");Nn.#i.set(t,this),this.#o(t)}else this.#r()}get promise(){return this.#e.promise}#l(){this.#e.resolve(),this.#t.send("configure",{verbosity:this.verbosity})}get port(){return this.#a}get messageHandler(){return this.#t}#o(e){this.#a=e,this.#t=new Io("main","worker",e),this.#t.on("ready",()=>{}),this.#l()}#r(){if(Nn.#f||Nn.#h){this.#u();return}let{workerSrc:e}=Nn;try{if(!Nn._isSameOrigin(window.location,e))e=Nn._createCDNWrapper(new URL(e,window.location).href);let t=new Worker(e,{type:"module"}),a=new Io("main","worker",t),n=()=>{if(s.abort(),a.destroy(),t.terminate(),this.destroyed)this.#e.reject(Error("Worker was destroyed"));else this.#u()},s=new AbortController;t.addEventListener("error",()=>{if(!this.#n)n()},{signal:s.signal}),a.on("test",(f)=>{if(s.abort(),this.destroyed||!f){n();return}this.#t=a,this.#a=t,this.#n=t,this.#l()}),a.on("ready",(f)=>{if(s.abort(),this.destroyed){n();return}try{i()}catch{this.#u()}});let i=()=>{let f=new Uint8Array;a.send("test",f,[f.buffer])};i();return}catch{M5("The worker has been disabled.")}this.#u()}#u(){if(!Nn.#f)ot("Setting up fake worker."),Nn.#f=!0;Nn._setupFakeWorkerGlobal.then((e)=>{if(this.destroyed){this.#e.reject(Error("Worker was destroyed"));return}let t=new wy;this.#a=t;let a=`fake${Nn.#s++}`,n=new Io(a+"_worker",a,t);e.setup(n,t),this.#t=new Io(a,a+"_worker",t),this.#l()}).catch((e)=>{this.#e.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this.#n?.terminate(),this.#n=null,Nn.#i.delete(this.#a),this.#a=null,this.#t?.destroy(),this.#t=null}static create(e){let t=this.#i.get(e?.port);if(t){if(t._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Nn(e)}static get workerSrc(){if(gf.workerSrc)return gf.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#h(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return ft(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#h)return this.#h;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class $y{downloadInfoCapability=Promise.withResolvers();#e=null;#t=new Map;#a=null;#n=new Map;#s=new Map;#f=new Map;#i=null;constructor(e,t,a,n,s,i){this.messageHandler=e,this.loadingTask=t,this.#a=a,this.commonObjs=new R8,this.fontLoader=new ry({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.enableHWA=n.enableHWA,this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.binaryDataFactory=s.binaryDataFactory,this.pagesMapper=i,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(e){let{_pageIndex:t}=e;this.#n.set(t,e),this.#s.set(t,Promise.resolve(e))}#l(e,t=null){return this.#t.getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}#o({loaded:e,total:t}){this.loadingTask.onProgress?.({loaded:e,total:t,percent:t?da(Math.round(e/t*100),0,100):NaN})}get annotationStorage(){return ft(this,"annotationStorage",new E5)}getRenderingIntent(e,t=kl.ENABLE,a=null,n=!1,s=!1){let i=Ys.DISPLAY,f=m2;switch(e){case"any":i=Ys.ANY;break;case"display":break;case"print":i=Ys.PRINT;break;default:ot(`getRenderingIntent - invalid intent: ${e}`)}let l=i&Ys.PRINT&&a instanceof T8?a:this.annotationStorage;switch(t){case kl.DISABLE:i+=Ys.ANNOTATIONS_DISABLE;break;case kl.ENABLE:break;case kl.ENABLE_FORMS:i+=Ys.ANNOTATIONS_FORMS;break;case kl.ENABLE_STORAGE:i+=Ys.ANNOTATIONS_STORAGE,f=l.serializable;break;default:ot(`getRenderingIntent - invalid annotationMode: ${t}`)}if(n)i+=Ys.IS_EDITING;if(s)i+=Ys.OPLIST;let{ids:c,hash:h}=l.modifiedIds,u=[i,f.hash,h];return{renderingIntent:i,cacheKey:u.join("_"),annotationStorageSerializable:f,modifiedIds:c}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(Error("Worker was destroyed during onPassword callback"));let e=[];for(let a of this.#n.values())e.push(a._destroy());if(this.#n.clear(),this.#s.clear(),this.#f.clear(),Object.hasOwn(this,"annotationStorage"))this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),fs.cleanup(),this.#a?.cancelAllRequests(new pf("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(a,n)=>{Ma(this.#a,"GetReader - no `BasePDFStream` instance available."),this.#e=this.#a.getFullReader(),this.#e.onProgress=(s)=>this.#o(s),n.onPull=()=>{this.#e.read().then(function({value:s,done:i}){if(i){n.close();return}Ma(s instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(s),1,[s])}).catch((s)=>{n.error(s)})},n.onCancel=(s)=>{this.#e.cancel(s),n.ready.catch((i)=>{if(this.destroyed)return;throw i})}}),e.on("ReaderHeadersReady",async(a)=>{await this.#e.headersReady;let{isStreamingSupported:n,isRangeSupported:s,contentLength:i}=this.#e;if(n&&s)this.#e.onProgress=null;return{isStreamingSupported:n,isRangeSupported:s,contentLength:i}}),e.on("GetRangeReader",(a,n)=>{Ma(this.#a,"GetRangeReader - no `BasePDFStream` instance available.");let s=this.#a.getRangeReader(a.begin,a.end);if(!s){n.close();return}n.onPull=()=>{s.read().then(function({value:i,done:f}){if(f){n.close();return}Ma(i instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(i),1,[i])}).catch((i)=>{n.error(i)})},n.onCancel=(i)=>{s.cancel(i),n.ready.catch((f)=>{if(this.destroyed)return;throw f})}}),e.on("GetDoc",({pdfInfo:a})=>{this.pagesMapper.pagesNumber=a.numPages,this._numPages=a.numPages,this._htmlForXfa=a.htmlForXfa,delete a.htmlForXfa,t._capability.resolve(new Zy(a,this))}),e.on("DocException",(a)=>{t._capability.reject(_s(a))}),e.on("PasswordRequest",(a)=>{this.#i=Promise.withResolvers();try{if(!t.onPassword)throw _s(a);let n=(s)=>{if(s instanceof Error)this.#i.reject(s);else this.#i.resolve({password:s})};t.onPassword(n,a.code)}catch(n){this.#i.reject(n)}return this.#i.promise}),e.on("DataLoaded",(a)=>{this.#o({loaded:a.length,total:a.length}),this.downloadInfoCapability.resolve(a)}),e.on("StartRenderPage",(a)=>{if(this.destroyed)return;this.#n.get(a.pageIndex)._startRenderPage(a.transparency,a.cacheKey)}),e.on("commonobj",([a,n,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(a))return null;switch(n){case"Font":if("error"in s){let u=s.error;ot(`Error during font loading: ${u}`),this.commonObjs.resolve(a,u);break}let i=new gy(s),f=this._params.pdfBug&&globalThis.FontInspector?.enabled?(u,g)=>globalThis.FontInspector.fontAdded(u,g):null,l=new oy(i,f,s.charProcOperatorList,s.extra);this.fontLoader.bind(l).catch(()=>e.sendWithPromise("FontFallback",{id:a})).finally(()=>{if(!l.fontExtraProperties)l.clearData();this.commonObjs.resolve(a,l)});break;case"CopyLocalImage":let{imageRef:c}=s;Ma(c,"The imageRef must be defined.");for(let u of this.#n.values())for(let[,g]of u.objs){if(g?.ref!==c)continue;if(!g.dataLen)return null;let b=structuredClone(g);return this.commonObjs.resolve(a,b),g.dataLen}break;case"FontPath":this.commonObjs.resolve(a,new by(s));break;case"Image":this.commonObjs.resolve(a,s);break;case"Pattern":let h=new py(s);this.commonObjs.resolve(a,h.getIR());break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on("obj",([a,n,s,i])=>{if(this.destroyed)return;let f=this.#n.get(n);if(f.objs.has(a))return;if(f._intentStates.size===0){i?.bitmap?.close();return}switch(s){case"Image":case"Pattern":f.objs.resolve(a,i);break;default:throw Error(`Got unknown object type ${s}`)}}),e.on("DocProgress",(a)=>{if(this.destroyed)return;this.#o(a)}),e.on("FetchBinaryData",async(a)=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(a)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){if(this.annotationStorage.size<=0)ot("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this.#e?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}extractPages(e){let t={pageInfos:e},a,n=globalThis.ImageBitmap;if(typeof n==="function"){let s=Array.isArray(e)?e:[e];for(let i of s)if(i?.image instanceof n)(a||=[]).push(i.image)}if(this.annotationStorage.size>0){let s=this.annotationStorage.serializable,{map:i}=s;if(s.transfer?.length)if(a)a.push(...s.transfer);else a=s.transfer;let f=this.pagesMapper.getMapping();if(f){let l=new Map;for(let[c,h]of i){if(h?.pageIndex!==void 0&&h.pageIndex>=0&&h.pageIndex<f.length){let u=f[h.pageIndex]-1;if(u!==h.pageIndex){l.set(c,{...h,pageIndex:u});continue}}l.set(c,h)}i=l}t.annotationStorage=i}return this.messageHandler.sendWithPromise("ExtractPages",t,a).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let t=e-1,a=this.pagesMapper.getPageId(e)-1,n=this.#s.get(t);if(n)return n;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:a}).then((i)=>{if(this.destroyed)throw Error("Transport destroyed");if(i.refStr)this.#f.set(i.refStr,a);let f=new U8(t,i,this,this.pagesMapper,this._params.pdfBug);return this.#n.set(t,f),f});return this.#s.set(t,s),s}async getPageIndex(e){if(!v8(e))throw Error("Invalid pageIndex request.");let t=await this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}),a=this.pagesMapper.getPageNumber(t+1);if(a===0)throw Error("GetPageIndex: page has been removed.");return a-1}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return this.#l("GetFieldObjects")}hasJSActions(){return this.#l("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){if(typeof e!=="string")return Promise.reject(Error("Invalid destination request."));return this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(e){return this.messageHandler.sendWithPromise("GetAttachmentContent",e)}getAnnotationsByType(e,t){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:t})}getDocJSActions(){return this.#l("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#l("GetOptionalContentConfig").then((t)=>new x8(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#t.getOrInsertComputed("GetMetadata",()=>this.messageHandler.sendWithPromise("GetMetadata",null).then((t)=>({info:t[0],metadata:t[1]?new Yy(t[1]):null,contentDispositionFilename:this.#e?.filename??null,contentLength:this.#e?.contentLength??null,hasStructTree:t[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(e){return this.messageHandler.sendWithPromise("GetRawData",e)}async startCleanup(e=!1){if(this.destroyed)return;await this.messageHandler.sendWithPromise("Cleanup",null);for(let t of this.#n.values())if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);if(this.commonObjs.clear(),!e)this.fontLoader.clear();this.#t.clear(),this.filterFactory.destroy(!0),fs.cleanup()}cachedPageNumber(e){if(!v8(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`,a=this.#f.get(t);if(a>=0){let n=this.pagesMapper.getPageNumber(a+1);if(n!==0)return n}return null}}class Wy{_internalRenderTask=null;onContinue=null;onError=null;constructor(e){this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(e=0){this._internalRenderTask.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this._internalRenderTask.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this._internalRenderTask;return e.form||e.canvas&&t?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class Go{#e=null;static#t=new WeakSet;constructor({callback:e,params:t,objs:a,commonObjs:n,annotationCanvasMap:s,operatorList:i,pageIndex:f,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:u=!1,pageColors:g=null,enableHWA:b=!1,operationsFilter:d=null}){this.callback=e,this.params=t,this.objs=a,this.commonObjs=n,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=i,this._pageIndex=f,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=g,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Wy(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvas,this._canvasContext=t.canvas?null:t.canvasContext,this._enableHWA=b,this._dependencyTracker=t.dependencyTracker,this._imagesTracker=t.imagesTracker,this._operationsFilter=d}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(Go.#t.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Go.#t.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled)this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint();let{viewport:a,transform:n,background:s,dependencyTracker:i,imagesTracker:f}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Xo(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,i,f),this.gfx.beginDrawing({transform:n,viewport:a,transparency:e,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){if(this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#e)window.cancelAnimationFrame(this.#e),this.#e=null;Go.#t.delete(this._canvas),e||=new x5(`Rendering cancelled, page ${this._pageIndex+1}`,t),this.callback(e),this.task.onError?.(e)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running)return;this._continue()}_continue(){if(this.running=!0,this.cancelled)return;if(this.task.onContinue)this.task.onContinue(this._scheduleNextBound);else this._scheduleNext()}_scheduleNext(){if(this._useRequestAnimationFrame)this.#e=window.requestAnimationFrame(()=>{this.#e=null,this._nextBound().catch(this._cancelBound)});else Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length){if(this.running=!1,this.operatorList.lastChunk)this.gfx.endDrawing(),Go.#t.delete(this._canvas),this.callback()}}}var az="6.1.200",nz="6353acefe";class ki{#e=null;#t=null;#a;#n=null;#s=!1;#f=!1;#i=null;#l;#o=null;#r=null;static#u=null;static get _keyboardManager(){return ft(this,"_keyboardManager",new Qs([[["Escape"],ki.prototype._hideDropdownFromKeyboard],[["Space"],ki.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ki.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ki.prototype._moveToPrevious],[["Home"],ki.prototype._moveToBeginning],[["End"],ki.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){if(e)this.#f=!1,this.#i=e;else this.#f=!0;this.#r=e?._uiManager||t,this.#l=this.#r._eventBus,this.#a=e?.color?.toUpperCase()||this.#r?.highlightColors.values().next().value||"#FFFF98",ki.#u||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let e=this.#e=document.createElement("button");if(e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",this.#i)e.ariaControls=`${this.#i.id}_colorpicker_dropdown`;let t=this.#r._signal;e.addEventListener("click",this.#p.bind(this),{signal:t}),e.addEventListener("keydown",this.#b.bind(this),{signal:t});let a=this.#t=document.createElement("span");return a.className="swatch",a.ariaHidden="true",a.style.backgroundColor=this.#a,e.append(a),e}renderMainDropdown(){let e=this.#n=this.#h();return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}#h(){let e=document.createElement("div"),t=this.#r._signal;if(e.addEventListener("contextmenu",Ai,{signal:t}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#i)e.id=`${this.#i.id}_colorpicker_dropdown`;for(let[a,n]of this.#r.highlightColors){let s=document.createElement("button");s.tabIndex="0",s.role="option",s.setAttribute("data-color",n),s.title=a,s.setAttribute("data-l10n-id",ki.#u[a]);let i=document.createElement("span");s.append(i),i.className="swatch",i.style.backgroundColor=n,s.ariaSelected=n===this.#a,s.addEventListener("click",this.#g.bind(this,n),{signal:t}),e.append(s)}return e.addEventListener("keydown",this.#b.bind(this),{signal:t}),e}#g(e,t){t.stopPropagation(),this.#l.dispatch("switchannotationeditorparams",{source:this,type:bt.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)}_colorSelectFromKeyboard(e){if(e.target===this.#e){this.#p(e);return}let t=e.target.getAttribute("data-color");if(!t)return;this.#g(t,e)}_moveToNext(e){if(!this.#m){this.#p(e);return}if(e.target===this.#e){this.#n.firstElementChild?.focus();return}e.target.nextSibling?.focus()}_moveToPrevious(e){if(e.target===this.#n?.firstElementChild||e.target===this.#e){if(this.#m)this._hideDropdownFromKeyboard();return}if(!this.#m)this.#p(e);e.target.previousSibling?.focus()}_moveToBeginning(e){if(!this.#m){this.#p(e);return}this.#n.firstElementChild?.focus()}_moveToEnd(e){if(!this.#m){this.#p(e);return}this.#n.lastElementChild?.focus()}#b(e){ki._keyboardManager.exec(this,e)}#p(e){if(this.#m){this.hideDropdown();return}if(this.#s=e.detail===0,!this.#o)this.#o=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#r.combinedSignal(this.#o)});if(this.#e.ariaExpanded="true",this.#n){this.#n.classList.remove("hidden");return}let t=this.#n=this.#h();this.#e.append(t)}#c(e){if(this.#n?.contains(e.target))return;this.hideDropdown()}hideDropdown(){this.#n?.classList.add("hidden"),this.#e.ariaExpanded="false",this.#o?.abort(),this.#o=null}get#m(){return this.#n&&!this.#n.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(this.#f)return;if(!this.#m){this.#i?.unselect();return}this.hideDropdown(),this.#e.focus({preventScroll:!0,focusVisible:this.#s})}updateColor(e){if(this.#t)this.#t.style.backgroundColor=e;if(!this.#n)return;let t=this.#r.highlightColors.values();for(let a of this.#n.children)a.ariaSelected=t.next().value===e.toUpperCase()}destroy(){this.#e?.remove(),this.#e=null,this.#t=null,this.#n?.remove(),this.#n=null}}class p2{#e=null;#t=!1;#a=null;#n=null;static#s=null;constructor(e){this.#a=e,this.#n=e._uiManager,p2.#s||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#e)return this.#e;let{editorType:e,colorType:t,colorAndOpacityType:a,opacityType:n,color:s,opacity:i}=this.#a,f=this.#t=ea.isAlphaColorInputSupported&&n!==void 0,l=this.#e=document.createElement("input");if(l.type="color",f){l.setAttribute("alpha","");let c=Fe.hexNums[Math.round((i??1)*255)];l.value=(s||"#000000")+c}else l.value=s||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",p2.#s[e]),l.addEventListener("input",()=>{if(f){let c=j2(l.value);if(!c)return;let[h,u,g,b]=c,d=Fe.makeHexColor(h,u,g);if(a!==void 0)this.#n.updateParams(a,{color:d,opacity:b});else this.#n.updateParams(t,d),this.#n.updateParams(n,b)}else this.#n.updateParams(t,l.value)},{signal:this.#n._signal}),l}update(e){if(!this.#e)return;if(this.#t){let t=Fe.hexNums[Math.round(this.#a.opacity*255)];this.#e.value=e+t}else this.#e.value=e}updateOpacity(e){if(!this.#e||!this.#t)return;let t=Fe.hexNums[Math.round(e*255)];this.#e.value=this.#a.color+t}destroy(){this.#e?.remove(),this.#e=null}hideDropdown(){}}function KA(e){return Math.floor(da(e,0,1)*255).toString(16).padStart(2,"0")}function i2(e){return da(e,0,1)*255}class y8{static CMYK_G([e,t,a,n]){return["G",1-Math.min(1,0.3*e+0.59*a+0.11*t+n)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=i2(e),[e,e,e]}static G_HTML([e]){let t=KA(e);return`#${t}${t}${t}`}static RGB_G([e,t,a]){return["G",0.3*e+0.59*t+0.11*a]}static RGB_rgb(e){return e.map(i2)}static RGB_HTML(e){return`#${e.map(KA).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,a,n]){return["RGB",1-Math.min(1,e+n),1-Math.min(1,a+n),1-Math.min(1,t+n)]}static CMYK_rgb([e,t,a,n]){return[i2(1-Math.min(1,e+n)),i2(1-Math.min(1,a+n)),i2(1-Math.min(1,t+n))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,a]){let n=1-e,s=1-t,i=1-a,f=Math.min(n,s,i);return["CMYK",n,s,i,f]}}class Py{create(e,t,a=!1){if(e<=0||t<=0)throw Error("Invalid SVG dimensions");let n=this._createSVG("svg:svg");if(n.setAttribute("version","1.1"),!a)n.setAttribute("width",`${e}px`),n.setAttribute("height",`${t}px`);return n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${e} ${t}`),n}createElement(e){if(typeof e!=="string")throw Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Et("Abstract method `_createSVG` called.")}}class b2 extends Py{_createSVG(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}}var sz=9,Gr=new WeakSet,iz=new Date().getTimezoneOffset()*60*1000;class q5{static create(e){switch(e.data.annotationType){case za.LINK:return new L5(e);case za.TEXT:return new tS(e);case za.WIDGET:switch(e.data.fieldType){case"Tx":return new aS(e);case"Btn":if(e.data.radioButton)return new iS(e);else if(e.data.checkBox)return new sS(e);return new fS(e);case"Ch":return new lS(e);case"Sig":return new nS(e)}return new yl(e);case za.POPUP:return new C5(e);case za.FREETEXT:return new I8(e);case za.LINE:return new oS(e);case za.SQUARE:return new cS(e);case za.CIRCLE:return new hS(e);case za.POLYLINE:return new G8(e);case za.CARET:return new mS(e);case za.INK:return new V5(e);case za.POLYGON:return new uS(e);case za.HIGHLIGHT:return new X8(e);case za.UNDERLINE:return new gS(e);case za.SQUIGGLY:return new pS(e);case za.STRIKEOUT:return new bS(e);case za.STAMP:return new K8(e);case za.FILEATTACHMENT:return new wS(e);case za.RICHMEDIA:case za.SCREEN:return new L8(e);default:return new va(e)}}}class va{#e=null;#t=!1;#a=null;constructor(e,{isRenderable:t=!1,ignoreBorder:a=!1,createQuadrilaterals:n=!1}={}){if(this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,this.hasOwnCommentButton=!1,t)this.contentElement=this.container=this._createContainer(a);if(n)this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!!(e?.str||t?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return va._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:e}=this,t=this.annotationStorage?.getEditor(e.id);if(t)return t.getData();return e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let e=this.annotationStorage?.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;let{quadPoints:t,inkLists:a,rect:n}=this.data,s=-1/0,i=-1/0;if(t?.length>=8){for(let f=0;f<t.length;f+=8)if(t[f+1]>i)i=t[f+1],s=t[f+2];else if(t[f+1]===i)s=Math.max(s,t[f+2]);return[s,i]}if(a?.length>=1){for(let f of a)for(let l=0,c=f.length;l<c;l+=2)if(f[l+1]>i)i=f[l+1],s=f[l];else if(f[l+1]===i)s=Math.max(s,f[l]);if(s!==1/0)return[s,i]}if(n)return[n[2],n[3]];return null}_normalizePoint(e){let{page:{view:t},viewport:{rawDims:{pageWidth:a,pageHeight:n,pageX:s,pageY:i}}}=this.parent;return e[1]=t[3]-e[1]+t[1],e[0]=100*(e[0]-s)/a,e[1]=100*(e[1]-i)/n,e}get commentText(){let{data:e}=this;return this.annotationStorage.getRawValue(`pdfjs_internal_editor_${e.id}`)?.popup?.contents||e.contentsObj?.str||""}set commentText(e){let{data:t}=this,a={deleted:!e,contents:e||""};if(!this.annotationStorage.updateEditor(t.id,{popup:a}))this.annotationStorage.setValue(`pdfjs_internal_editor_${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:a,popupRef:t.popupRef,modificationDate:new Date});if(!e)this.removePopup()}removePopup(){(this.#a?.popup||this.popup)?.remove(),this.#a=this.popup=null}updateEdited(e){if(!this.container)return;if(e.rect)this.#e||={rect:this.data.rect.slice(0)};let{rect:t,popup:a}=e;if(t)this.#n(t);let n=this.#a?.popup||this.popup;if(!n&&a?.text)this._createPopup(a),n=this.#a.popup;if(!n)return;if(n.updateEdited(e),a?.deleted)n.remove(),this.#a=null,this.popup=null}resetEdited(){if(!this.#e)return;this.#n(this.#e.rect),this.#a?.popup.resetEdited(),this.#e=null}#n(e){let{container:{style:t},data:{rect:a,rotation:n},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:f,pageY:l}}}}=this;if(a?.splice(0,4,...e),t.left=`${100*(e[0]-f)/s}%`,t.top=`${100*(i-e[3]+l)/i}%`,n===0)t.width=`${100*(e[2]-e[0])/s}%`,t.height=`${100*(e[3]-e[1])/i}%`;else this.setRotation(n)}_createContainer(e){let{data:t,parent:{page:a,viewport:n}}=this,s=document.createElement("section");if(s.setAttribute("data-annotation-id",t.id),!(this instanceof yl)&&!(this instanceof L5)&&!(this instanceof L8))s.tabIndex=0;let{style:i}=s;if(i.zIndex=this.parent.zIndex,this.parent.zIndex+=2,t.alternativeText)s.title=t.alternativeText;if(t.noRotate)s.classList.add("norotate");if(!t.rect||this instanceof C5){let{rotation:j}=t;if(!t.hasOwnCanvas&&j!==0)this.setRotation(j,s);return s}let{width:f,height:l}=this;if(!e&&t.borderStyle.width>0){i.borderWidth=`${t.borderStyle.width}px`;let j=t.borderStyle.horizontalCornerRadius,A=t.borderStyle.verticalCornerRadius;if(j>0||A>0){let y=`calc(${j}px * var(--total-scale-factor)) / calc(${A}px * var(--total-scale-factor))`;i.borderRadius=y}switch(t.borderStyle.style){case zo.SOLID:i.borderStyle="solid";break;case zo.DASHED:i.borderStyle="dashed";break;case zo.BEVELED:ot("Unimplemented border style: beveled");break;case zo.INSET:ot("Unimplemented border style: inset");break;case zo.UNDERLINE:i.borderBottomStyle="solid";break;default:break}let C=t.borderColor||null;if(C)this.#t=!0,i.borderColor=Fe.makeHexColor(...C);else i.borderWidth=0}let c=Fe.normalizeRect([t.rect[0],a.view[3]-t.rect[1]+a.view[1],t.rect[2],a.view[3]-t.rect[3]+a.view[1]]),{pageWidth:h,pageHeight:u,pageX:g,pageY:b}=n.rawDims;i.left=`${100*(c[0]-g)/h}%`,i.top=`${100*(c[1]-b)/u}%`;let{rotation:d}=t;if(t.hasOwnCanvas||d===0)i.width=`${100*f/h}%`,i.height=`${100*l/u}%`;else this.setRotation(d,s);return s}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:a,pageHeight:n}=this.parent.viewport.rawDims,{width:s,height:i}=this;if(e%180!==0)[s,i]=[i,s];t.style.width=`${100*s/a}%`,t.style.height=`${100*i/n}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(t,a,n)=>{let s=n.detail[t],i=s[0],f=s.slice(1);n.target.style[a]=y8[`${i}_HTML`](f),this.annotationStorage.setValue(this.data.id,{[a]:y8[`${i}_rgb`](f)})};return ft(this,"_commonActions",{display:(t)=>{let{display:a}=t.detail,n=a%2===1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:a===1||a===2})},print:(t)=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:(t)=>{let{hidden:a}=t.detail;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:a,noView:a})},focus:(t)=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:(t)=>{t.target.title=t.detail.userName},readonly:(t)=>{t.target.disabled=t.detail.readonly},required:(t)=>{this._setRequired(t.target,t.detail.required)},bgColor:(t)=>{e("bgColor","backgroundColor",t)},fillColor:(t)=>{e("fillColor","backgroundColor",t)},fgColor:(t)=>{e("fgColor","color",t)},textColor:(t)=>{e("textColor","color",t)},borderColor:(t)=>{e("borderColor","borderColor",t)},strokeColor:(t)=>{e("strokeColor","borderColor",t)},rotation:(t)=>{let a=t.detail.rotation;this.setRotation(a),this.annotationStorage.setValue(this.data.id,{rotation:a})}})}_dispatchEventFromSandbox(e,t){let a=this._commonActions;for(let n of Object.keys(t.detail))(e[n]||a[n])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let a=this._commonActions;for(let[n,s]of Object.entries(t)){let i=a[n];if(i){let f={detail:{[n]:s},target:e};i(f),delete t[n]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,a,n,s]=this.data.rect.map((j)=>Math.fround(j));if(e.length===8){let[j,A,C,y]=e.subarray(2,6);if(n===j&&s===A&&t===C&&a===y)return}let{style:i}=this.container,f;if(this.#t){let{borderColor:j,borderWidth:A}=i;i.borderWidth=0,f=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${j}" stroke-width="${A}">`],this.container.classList.add("hasBorder")}let l=n-t,c=s-a,{svgFactory:h}=this,u=h.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";let g=h.createElement("defs");u.append(g);let b=h.createElement("clipPath"),d=`clippath_${this.data.id}`;b.setAttribute("id",d),b.setAttribute("clipPathUnits","objectBoundingBox"),g.append(b);for(let j=2,A=e.length;j<A;j+=8){let C=e[j],y=e[j+1],O=e[j+2],T=e[j+3],M=h.createElement("rect"),H=(O-t)/l,N=(s-y)/c,x=(C-O)/l,z=(y-T)/c;M.setAttribute("x",H),M.setAttribute("y",N),M.setAttribute("width",x),M.setAttribute("height",z),b.append(M),f?.push(`<rect vector-effect="non-scaling-stroke" x="${H}" y="${N}" width="${x}" height="${z}"/>`)}if(this.#t)f.push("</g></svg>')"),i.backgroundImage=f.join("");this.container.append(u),this.container.style.clipPath=`url(#${d})`}_createPopup(e=null){let{data:t}=this,a,n;if(e)a={str:e.text},n=e.date;else a=t.contentsObj,n=t.modificationDate;this.#a=new C5({data:{color:t.color,titleObj:t.titleObj,modificationDate:n,contentsObj:a,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#a||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#a}render(){Et("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let a=[];if(this._fieldObjects){let n=this._fieldObjects[e];if(n)for(let{page:s,id:i,exportValues:f}of n){if(s===-1)continue;if(i===t)continue;let l=typeof f==="string"?f:null,c=document.querySelector(`[data-element-id="${i}"]`);if(c&&!Gr.has(c)){ot(`_getElementsByName - element not allowed: ${i}`);continue}a.push({id:i,exportValue:l,domElement:c})}return a}for(let n of document.getElementsByName(e)){let{exportValue:s}=n,i=n.getAttribute("data-element-id");if(i===t)continue;if(!Gr.has(n))continue;a.push({id:i,exportValue:s,domElement:n})}return a}show(){if(this.container)this.container.hidden=!1;this.popup?.maybeShow()}hide(){if(this.container)this.container.hidden=!0;this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){if(!this.data.oc||!e)return;if(e.isVisible(this.data.oc))this.show();else this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":Fe.makeHexColor(...t)}}class eS extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.editor=e.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:e}=this;if(!e.hasComment)return;this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){if(this.editor.comment=e,!e)this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class L5 extends va{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,a=document.createElement("a");a.setAttribute("data-element-id",e.id);let n=!1;if(e.url)t.addLinkAttributes(a,e.url,e.newWindow),n=!0;else if(e.action)this._bindNamedAction(a,e.action,e.overlaidText),n=!0;else if(e.attachment)this.#t(a,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),n=!0;else if(e.setOCGState)this.#a(a,e.setOCGState,e.overlaidText),n=!0;else if(e.dest)this._bindLink(a,e.dest,e.overlaidText),n=!0;else{if(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions)this._bindJSAction(a,e),n=!0;if(e.resetForm)this._bindResetFormAction(a,e.resetForm),n=!0;else if(this.isTooltipOnly&&!n)this._bindLink(a,""),n=!0}if(this.container.classList.add("linkAnnotation"),n)this.contentElement=a,this.container.append(a);return this.container}#e(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t,a=""){if(e.href=this.linkService.getDestinationHash(t),e.onclick=()=>{if(t)this.linkService.goToDestination(t);return!1},t||t==="")this.#e();if(a)e.title=a}_bindNamedAction(e,t,a=""){if(e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>{return this.linkService.executeNamedAction(t),!1},a)e.title=a;this.#e()}#t(e,t,a,n="",s=null){if(e.href=this.linkService.getAnchorUrl(""),a.description)e.title=a.description;else if(n)e.title=n;let i=async()=>{let f=await this.linkService.getAttachmentContent(t);if(f)this.downloadManager?.openOrDownloadData(f,a.filename,s)};e.onclick=()=>{return i(),!1},this.#e()}#a(e,t,a=""){if(e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>{return this.linkService.executeSetOCGState(t),!1},a)e.title=a;this.#e()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let n of Object.keys(t.actions)){let s=a.get(n);if(!s)continue;e[s]=()=>{return this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:n}}),!1}}if(t.overlaidText)e.title=t.overlaidText;if(!e.onclick)e.onclick=()=>!1;this.#e()}_bindResetFormAction(e,t){let a=e.onclick;if(!a)e.href=this.linkService.getAnchorUrl("");if(this.#e(),!this._fieldObjects){if(ot('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!a)e.onclick=()=>!1;return}e.onclick=()=>{a?.();let{fields:n,refs:s,include:i}=t,f=[];if(n.length!==0||s.length!==0){let h=new Set(s);for(let u of n){let g=this._fieldObjects[u]||[];for(let{id:b}of g)h.add(b)}for(let u of Object.values(this._fieldObjects))for(let g of u)if(h.has(g.id)===i)f.push(g)}else for(let h of Object.values(this._fieldObjects))f.push(...h);let l=this.annotationStorage,c=[];for(let h of f){let{id:u}=h;switch(c.push(u),h.type){case"text":{let b=h.defaultValue||"";l.setValue(u,{value:b});break}case"checkbox":case"radiobutton":{let b=h.defaultValue===h.exportValues;l.setValue(u,{value:b});break}case"combobox":case"listbox":{let b=h.defaultValue||"";l.setValue(u,{value:b});break}default:continue}let g=document.querySelector(`[data-element-id="${u}"]`);if(!g)continue;else if(!Gr.has(g)){ot(`_bindResetFormAction - element not allowed: ${u}`);continue}g.dispatchEvent(new Event("resetform"))}if(this.enableScripting)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}});return!1}}}class tS extends va{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");if(e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(e),this.container}}class yl extends va{render(){return this.container}_getKeyModifier(e){return ea.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,a,n,s){if(a.includes("mouse"))e.addEventListener(a,(i)=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(i),shift:i.shiftKey,modifier:this._getKeyModifier(i)}})});else e.addEventListener(a,(i)=>{if(a==="blur"){if(!t.focused||!i.relatedTarget)return;t.focused=!1}else if(a==="focus"){if(t.focused)return;t.focused=!0}if(!s)return;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(i)}})})}_setEventListeners(e,t,a,n){for(let[s,i]of a)if(i==="Action"||this.data.actions?.[i]){if(i==="Focus"||i==="Blur")t||={focused:!1};if(this._setEventListener(e,t,s,i,n),i==="Focus"&&!this.data.actions?.Blur)this._setEventListener(e,t,"blur","Blur",null);else if(i==="Blur"&&!this.data.actions?.Focus)this._setEventListener(e,t,"focus","Focus",null)}}_setTextStyle(e){let t=["left","center","right"],{fontColor:a}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||sz,s=e.style,i,f=2,l=(c)=>Math.round(10*c)/10;if(this.data.multiLine){let c=Math.abs(this.data.rect[3]-this.data.rect[1]-2),h=Math.round(c/(1.35*n))||1,u=c/h;i=Math.min(n,l(u/1.35))}else{let c=Math.abs(this.data.rect[3]-this.data.rect[1]-2);i=Math.min(n,l(c/1.35))}if(s.fontSize=`calc(${i}px * var(--total-scale-factor))`,s.color=Fe.makeHexColor(...a),this.data.textAlignment!==null&&!this.data.comb)s.textAlign=t[this.data.textAlignment]}_setRequired(e,t){if(t)e.setAttribute("required",!0);else e.removeAttribute("required");e.setAttribute("aria-required",t)}}class aS extends yl{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,a,n){let s=this.annotationStorage;for(let i of this._getElementsByName(e.name,e.id)){if(i.domElement)i.domElement[t]=a;s.setValue(i.id,{[n]:a})}}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let a=null;if(this.renderForms){let n=e.getValue(t,{value:this.data.fieldValue}),s=n.value||"",i=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;if(i&&s.length>i)s=s.slice(0,i);let f=n.formattedValue||this.data.textContent?.join(`
297
+ `)||null;if(f&&this.data.comb)f=f.replaceAll(/\s+/g,"");let l={userValue:s,formattedValue:f,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){if(a=document.createElement("textarea"),a.textContent=f??s,this.data.doNotScroll)a.style.overflowY="hidden"}else if(a=document.createElement("input"),a.type=this.data.password?"password":"text",a.setAttribute("value",f??s),this.data.doNotScroll)a.style.overflowX="hidden";if(this.data.hasOwnCanvas){if(this.container.classList.add("hasOwnCanvas"),e.has(t))this.container.classList.add("sandboxModified")}Gr.add(a),this.contentElement=a,a.setAttribute("data-element-id",t),a.disabled=this.data.readOnly,a.name=this.data.fieldName,a.tabIndex=0;let{datetimeFormat:c,datetimeType:h,timeStep:u}=this.data,g=!!h&&this.enableScripting;if(c)a.title=c;if(this._setRequired(a,this.data.required),i)a.maxLength=i;a.addEventListener("input",(d)=>{e.setValue(t,{value:d.target.value}),this.setPropertyOnSiblings(a,"value",d.target.value,"value"),l.formattedValue=null}),a.addEventListener("resetform",(d)=>{let j=this.data.defaultFieldValue??"";a.value=l.userValue=j,l.formattedValue=null});let b=(d)=>{let{formattedValue:j}=l;if(j!==null&&j!==void 0)d.target.value=j;d.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){a.addEventListener("focus",(j)=>{if(l.focused)return;let{target:A}=j;if(g){if(A.type=h,u)A.step=u}if(l.userValue){let C=l.userValue;if(g)if(h==="time"){let y=new Date(C),O=[y.getHours(),y.getMinutes(),y.getSeconds()];A.value=O.map((T)=>T.toString().padStart(2,"0")).join(":")}else A.value=new Date(C-iz).toISOString().split(h==="date"?"T":".",1)[0];else A.value=C}if(l.lastCommittedValue=A.value,l.commitKey=1,!this.data.actions?.Focus)l.focused=!0}),a.addEventListener("updatefromsandbox",(j)=>{this.container.classList.add("sandboxModified");let A={value(C){if(l.userValue=C.detail.value??"",!g)e.setValue(t,{value:l.userValue.toString()});C.target.value=l.userValue},formattedValue(C){let{formattedValue:y}=C.detail;if(l.formattedValue=y,y!==null&&y!==void 0&&C.target!==document.activeElement)C.target.value=y;let O={formattedValue:y};if(g)O.value=y;e.setValue(t,O)},selRange(C){C.target.setSelectionRange(...C.detail.selRange)},charLimit:(C)=>{let{charLimit:y}=C.detail,{target:O}=C;if(y===0){O.removeAttribute("maxLength");return}O.setAttribute("maxLength",y);let T=l.userValue;if(!T||T.length<=y)return;T=T.slice(0,y),O.value=l.userValue=T,e.setValue(t,{value:T}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:T,willCommit:!0,commitKey:1,selStart:O.selectionStart,selEnd:O.selectionEnd}})}};this._dispatchEventFromSandbox(A,j)}),a.addEventListener("keydown",(j)=>{l.commitKey=1;let A=-1;if(j.key==="Escape")A=0;else if(j.key==="Enter"&&!this.data.multiLine)A=2;else if(j.key==="Tab")l.commitKey=3;if(A===-1)return;let{value:C}=j.target;if(l.lastCommittedValue===C)return;l.lastCommittedValue=C,l.userValue=C,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:C,willCommit:!0,commitKey:A,selStart:j.target.selectionStart,selEnd:j.target.selectionEnd}})});let d=b;if(b=null,a.addEventListener("blur",(j)=>{if(!l.focused||!j.relatedTarget)return;if(!this.data.actions?.Blur)l.focused=!1;let{target:A}=j,{value:C}=A;if(g){if(C&&h==="time"){let y=C.split(":").map((O)=>parseInt(O,10));C=new Date(2000,0,1,y[0],y[1],y[2]||0).valueOf(),A.step=""}else{if(!C.includes("T"))C=`${C}T00:00`;C=new Date(C).valueOf()}A.type="text"}if(l.userValue=C,l.lastCommittedValue!==C)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:C,willCommit:!0,commitKey:l.commitKey,selStart:j.target.selectionStart,selEnd:j.target.selectionEnd}});d(j)}),this.data.actions?.Keystroke)a.addEventListener("beforeinput",(j)=>{l.lastCommittedValue=null;let{data:A,target:C}=j,{value:y,selectionStart:O,selectionEnd:T}=C,M=O,H=T;switch(j.inputType){case"deleteWordBackward":{let N=y.substring(0,O).match(/\w*\W*$/);if(N)M-=N[0].length;break}case"deleteWordForward":{let N=y.substring(O).match(/^\W*\w*/);if(N)H+=N[0].length;break}case"deleteContentBackward":if(O===T)M-=1;break;case"deleteContentForward":if(O===T)H+=1;break}j.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:y,change:A||"",willCommit:!1,selStart:M,selEnd:H}})});this._setEventListeners(a,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(j)=>j.target.value)}if(b)a.addEventListener("blur",b);if(this.data.comb){let j=(this.data.rect[2]-this.data.rect[0])/i;a.classList.add("comb"),a.style.setProperty("--comb-width",`calc(${j}px * var(--total-scale-factor))`);let A=this.data.textAlignment;if(A===1||A===2){let C=()=>{let y=i-a.value.length;a.style.setProperty("--comb-offset",`${A===1?y>>1:y}`)};C();for(let y of["input","blur","resetform","updatefromsandbox"])a.addEventListener(y,C)}}}else if(a=document.createElement("div"),a.textContent=this.data.fieldValue,a.style.verticalAlign="middle",a.style.display="table-cell",this.data.hasOwnCanvas)a.hidden=!0;return this._setTextStyle(a),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class nS extends yl{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class sS extends yl{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,a=t.id,n=e.getValue(a,{value:t.exportValue===t.fieldValue}).value;if(typeof n==="string")n=n!=="Off",e.setValue(a,{value:n});this.container.classList.add("buttonWidgetAnnotation","checkBox");let s=document.createElement("input");if(Gr.add(s),s.setAttribute("data-element-id",a),s.disabled=t.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=t.fieldName,n)s.setAttribute("checked",!0);if(s.setAttribute("exportValue",t.exportValue),s.tabIndex=0,s.addEventListener("change",(i)=>{let{name:f,checked:l}=i.target;for(let c of this._getElementsByName(f,a)){let h=l&&c.exportValue===t.exportValue;if(c.domElement)c.domElement.checked=h;e.setValue(c.id,{value:h})}e.setValue(a,{value:l})}),s.addEventListener("resetform",(i)=>{let f=t.defaultFieldValue||"Off";i.target.checked=f===t.exportValue}),this.enableScripting&&this.hasJSActions)s.addEventListener("updatefromsandbox",(i)=>{let f={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(a,{value:l.target.checked})}};this._dispatchEventFromSandbox(f,i)}),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(i)=>i.target.checked);return this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class iS extends yl{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,a=t.id,n=e.getValue(a,{value:t.buttonValue!==null&&t.fieldValue===t.buttonValue}).value;if(typeof n==="string")n=n!==t.buttonValue,e.setValue(a,{value:n});if(n)for(let i of this._getElementsByName(t.fieldName,a))e.setValue(i.id,{value:!1});let s=document.createElement("input");if(Gr.add(s),s.setAttribute("data-element-id",a),s.disabled=t.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=t.fieldName,n)s.setAttribute("checked",!0);if(s.tabIndex=0,s.addEventListener("change",(i)=>{let{name:f,checked:l}=i.target;for(let c of this._getElementsByName(f,a))e.setValue(c.id,{value:!1});e.setValue(a,{value:l})}),s.addEventListener("resetform",(i)=>{let f=t.defaultFieldValue;i.target.checked=f!==null&&f!==void 0&&f===t.buttonValue}),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;s.addEventListener("updatefromsandbox",(f)=>{let l={value:(c)=>{let h=i===c.detail.value;for(let u of this._getElementsByName(c.target.name)){let g=h&&u.id===a;if(u.domElement)u.domElement.checked=g;e.setValue(u.id,{value:g})}}};this._dispatchEventFromSandbox(l,f)}),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(f)=>f.target.checked)}return this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class fS extends L5{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");let t=e.lastChild;if(this.enableScripting&&this.hasJSActions&&t)this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(a)=>{this._dispatchEventFromSandbox({},a)});return e}}class lS extends yl{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,a=e.getValue(t,{value:this.data.fieldValue}),n=document.createElement("select");Gr.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let s=this.data.combo&&this.data.options.length>0;if(!this.data.combo){if(n.size=this.data.options.length,this.data.multiSelect)n.multiple=!0}n.addEventListener("resetform",(u)=>{let g=this.data.defaultFieldValue;for(let b of n.options)b.selected=b.value===g});let i=(u,g)=>{let b=g.replaceAll(" "," ");if(u.textContent=b,b!==g)u.setAttribute("display-value",g)};for(let u of this.data.options){let g=document.createElement("option");if(i(g,u.displayValue),g.value=u.exportValue,a.value.includes(u.exportValue))g.setAttribute("selected",!0),s=!1;n.append(g)}let f=null;if(s){let u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),n.prepend(u),f=()=>{u.remove(),n.removeEventListener("input",f),f=null},n.addEventListener("input",f)}let l=(u)=>{let g=u?"value":"textContent",{options:b,multiple:d}=n;if(!d)return b.selectedIndex===-1?null:b[b.selectedIndex][g];return Array.prototype.filter.call(b,(j)=>j.selected).map((j)=>j[g])},c=l(!1),h=(u)=>{let g=u.target.options;return Array.prototype.map.call(g,(b)=>({displayValue:b.getAttribute("display-value")||b.textContent,exportValue:b.value}))};if(this.enableScripting&&this.hasJSActions)n.addEventListener("updatefromsandbox",(u)=>{let g={value(b){f?.();let d=b.detail.value,j=new Set(Array.isArray(d)?d:[d]);for(let A of n.options)A.selected=j.has(A.value);e.setValue(t,{value:l(!0)}),c=l(!1)},multipleSelection(b){n.multiple=!0},remove(b){let d=n.options,j=b.detail.remove;if(d[j].selected=!1,n.remove(j),d.length>0){if(Array.prototype.findIndex.call(d,(C)=>C.selected)===-1)d[0].selected=!0}e.setValue(t,{value:l(!0),items:h(b)}),c=l(!1)},clear(b){while(n.length!==0)n.remove(0);e.setValue(t,{value:null,items:[]}),c=l(!1)},insert(b){let{index:d,displayValue:j,exportValue:A}=b.detail.insert,C=n.children[d],y=document.createElement("option");if(i(y,j),y.value=A,C)C.before(y);else n.append(y);e.setValue(t,{value:l(!0),items:h(b)}),c=l(!1)},items(b){let{items:d}=b.detail;while(n.length!==0)n.remove(0);for(let j of d){let{displayValue:A,exportValue:C}=j,y=document.createElement("option");i(y,A),y.value=C,n.append(y)}if(n.options.length>0)n.options[0].selected=!0;e.setValue(t,{value:l(!0),items:h(b)}),c=l(!1)},indices(b){let d=new Set(b.detail.indices);for(let j of b.target.options)j.selected=d.has(j.index);e.setValue(t,{value:l(!0)}),c=l(!1)},editable(b){b.target.disabled=!b.detail.editable}};this._dispatchEventFromSandbox(g,u)}),n.addEventListener("input",(u)=>{let g=l(!0),b=l(!1);e.setValue(t,{value:g}),u.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:c,change:b,changeEx:g,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(u)=>u.target.value);else n.addEventListener("input",function(u){e.setValue(t,{value:l(!0)})});if(this.data.combo)this._setTextStyle(n);return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class C5 extends va{constructor(e){let{data:t,elements:a,parent:n}=e,s=!!n._commentManager;super(e,{isRenderable:!s&&va._hasPopupData(t)});if(this.elements=a,s&&va._hasPopupData(t)){let i=this.popup=this.#e();for(let f of a)f.popup=i}else this.popup=null}#e(){return new rS({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){let{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";let t=this.popup=this.#e(),a=[];for(let n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",a.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",a.map((n)=>`pdfjs_internal_id_${n}`).join(",")),this.container}}class rS{#e=null;#t=this.#z.bind(this);#a=this.#R.bind(this);#n=this.#v.bind(this);#s=this.#C.bind(this);#f=null;#i=null;#l=null;#o=null;#r=null;#u=null;#h=null;#g=!1;#b=null;#p=null;#c=null;#m=null;#d=null;#j=null;#w=null;#A=null;#y=null;#q=null;#S=!1;#k=null;#_=null;constructor({container:e,color:t,elements:a,titleObj:n,modificationDate:s,contentsObj:i,richText:f,parent:l,rect:c,parentRect:h,open:u,commentManager:g=null}){if(this.#i=e,this.#y=n,this.#l=i,this.#A=f,this.#u=l,this.#f=t,this.#w=c,this.#h=h,this.#r=a,this.#e=g,this.#k=a[0],this.#o=A5.toDateObject(s),this.trigger=a.flatMap((b)=>b.getElementsToTriggerPopup()),!g){if(this.#O(),this.#i.hidden=!0,u)this.#C()}}#O(){if(this.#p)return;this.#p=new AbortController;let{signal:e}=this.#p;for(let t of this.trigger)t.addEventListener("click",this.#s,{signal:e}),t.addEventListener("pointerenter",this.#n,{signal:e}),t.addEventListener("pointerleave",this.#a,{signal:e}),t.classList.add("popupTriggerArea");for(let t of this.#r)t.container?.addEventListener("keydown",this.#t,{signal:e})}#B(){let e=this.#r.find((t)=>t.hasCommentButton);if(!e)return;this.#d=e._normalizePoint(e.commentButtonPosition)}renderCommentButton(){if(this.#m){if(!this.#m.parentNode)this.#k.container.after(this.#m);return}if(!this.#d)this.#B();if(!this.#d)return;let{signal:e}=this.#p=new AbortController,t=this.#k.hasOwnCommentButton,a=()=>{this.#e.toggleCommentPopup(this,!0,void 0,!t)},n=()=>{this.#e.toggleCommentPopup(this,!1,!0,!t)},s=()=>{this.#e.toggleCommentPopup(this,!1,!1)};if(!t){let i=this.#m=document.createElement("button");i.className="annotationCommentButton";let f=this.#k.container;i.style.zIndex=parseInt(f.style.zIndex,10)+1,i.tabIndex=0,i.ariaHasPopup="dialog",i.ariaControls="commentPopup",i.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#M(),this.#F(),i.addEventListener("keydown",this.#t,{signal:e}),i.addEventListener("click",a,{signal:e}),i.addEventListener("pointerenter",n,{signal:e}),i.addEventListener("pointerleave",s,{signal:e}),f.after(i)}else{this.#m=this.#k.container;for(let i of this.trigger)i.ariaHasPopup="dialog",i.ariaControls="commentPopup",i.addEventListener("keydown",this.#t,{signal:e}),i.addEventListener("click",a,{signal:e}),i.addEventListener("pointerenter",n,{signal:e}),i.addEventListener("pointerleave",s,{signal:e}),i.classList.add("popupTriggerArea")}}#F(){if(this.#k.extraPopupElement&&!this.#k.editor)return;if(!this.#m)this.renderCommentButton();let[e,t]=this.#d,{style:a}=this.#m;a.left=`calc(${e}%)`,a.top=`calc(${t}% - var(--comment-button-dim))`}#M(){if(this.#k.extraPopupElement)return;if(!this.#m)this.renderCommentButton();this.#m.style.backgroundColor=this.commentButtonColor||""}get commentButtonColor(){let{color:e,opacity:t}=this.#k.commentData;if(!e)return null;return this.#u._commentManager.makeCommentColor(e,t)}focusCommentButton(){setTimeout(()=>{this.#m?.focus()},0)}getData(){let{richText:e,color:t,opacity:a,creationDate:n,modificationDate:s}=this.#k.commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:a,creationDate:n,modificationDate:s}}get elementBeforePopup(){return this.#m}get comment(){return this.#_||=this.#k.commentText,this.#_}set comment(e){if(e===this.comment)return;this.#k.commentText=this.#_=e}focus(){this.#k.container?.focus()}get parentBoundingClientRect(){return this.#k.layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){if(!this.#m)return;this.#m.classList.toggle("selected",e),this.#m.ariaExpanded=t}setSelectedCommentButton(e){this.#m.classList.toggle("selected",e)}get commentPopupPosition(){if(this.#j)return this.#j;let{x:e,y:t,height:a}=this.#m.getBoundingClientRect(),{x:n,y:s,width:i,height:f}=this.#k.layer.getBoundingClientRect();return[(e-n)/i,(t+a-s)/f]}set commentPopupPosition(e){this.#j=e}hasDefaultPopupPosition(){return this.#j===null}get commentButtonPosition(){return this.#d}get commentButtonWidth(){return this.#m.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){let[t,a]=this.#j||this.commentButtonPosition.map((c)=>c/100),n=this.parentBoundingClientRect,{x:s,y:i,width:f,height:l}=n;this.#e.showDialog(null,this,s+t*f,i+a*l,{...e,parentDimensions:n})}render(){if(this.#b)return;let e=this.#b=document.createElement("div");if(e.className="popup",this.#f){let a=e.style.outlineColor=Fe.makeHexColor(...this.#f);e.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`}let t=document.createElement("span");if(t.className="header",this.#y?.str){let a=document.createElement("span");a.className="title",t.append(a),{dir:a.dir,str:a.textContent}=this.#y}if(e.append(t),this.#o){let a=document.createElement("time");a.className="popupDate",a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#o.valueOf()})),a.dateTime=this.#o.toISOString(),t.append(a)}WA({html:this.#D||this.#l.str,dir:this.#l?.dir,className:"popupContent"},e),this.#i.append(e)}get#D(){let e=this.#A,t=this.#l;if(e?.str&&(!t?.str||t.str===e.str))return this.#A.html||null;return null}get#H(){return this.#D?.attributes?.style?.fontSize||0}get#x(){return this.#D?.attributes?.style?.color||null}#N(e){let t=[],a={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},n={style:{color:this.#x,fontSize:this.#H?`calc(${this.#H}px * var(--total-scale-factor))`:""}};for(let s of e.split(`
298
+ `))t.push({name:"span",value:s,attributes:n});return a}#z(e){if(e.altKey||e.shiftKey||e.ctrlKey||e.metaKey)return;if(e.key==="Enter"||e.key==="Escape"&&this.#g)this.#C()}updateEdited({rect:e,popup:t,deleted:a}){if(this.#e){if(a)this.remove(),this.#_=null;else if(t)if(t.deleted)this.remove();else this.#M(),this.#_=t.text;if(e)this.#d=null,this.#B(),this.#F();return}if(a||t?.deleted){this.remove();return}if(this.#O(),this.#q||={contentsObj:this.#l,richText:this.#A},e)this.#c=null;if(t&&t.text)this.#A=this.#N(t.text),this.#o=A5.toDateObject(t.date),this.#l=null;this.#b?.remove(),this.#b=null}resetEdited(){if(!this.#q)return;({contentsObj:this.#l,richText:this.#A}=this.#q),this.#q=null,this.#b?.remove(),this.#b=null,this.#c=null}remove(){if(this.#p?.abort(),this.#p=null,this.#b?.remove(),this.#b=null,this.#S=!1,this.#g=!1,this.#m?.remove(),this.#m=null,this.trigger)for(let e of this.trigger)e.classList.remove("popupTriggerArea")}#L(){if(this.#c!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:a,pageX:n,pageY:s}}}=this.#u,i=!!this.#h,f=i?this.#h:this.#w;for(let d of this.#r)if(!f||Fe.intersect(d.data.rect,f)!==null){f=d.data.rect,i=!0;break}let l=Fe.normalizeRect([f[0],e[3]-f[1]+e[1],f[2],e[3]-f[3]+e[1]]),c=5,h=i?f[2]-f[0]+c:0,u=l[0]+h,g=l[1];this.#c=[100*(u-n)/t,100*(g-s)/a];let{style:b}=this.#i;b.left=`${this.#c[0]}%`,b.top=`${this.#c[1]}%`}#C(){if(this.#e){this.#e.toggleCommentPopup(this,!1);return}if(this.#g=!this.#g,this.#g)this.#v(),this.#i.addEventListener("click",this.#s),this.#i.addEventListener("keydown",this.#t);else this.#R(),this.#i.removeEventListener("click",this.#s),this.#i.removeEventListener("keydown",this.#t)}#v(){if(!this.#b)this.render();if(!this.isVisible)this.#L(),this.#i.hidden=!1,this.#i.style.zIndex=parseInt(this.#i.style.zIndex,10)+1000;else if(this.#g)this.#i.classList.add("focused")}#R(){if(this.#i.classList.remove("focused"),this.#g||!this.isVisible)return;this.#i.hidden=!0,this.#i.style.zIndex=parseInt(this.#i.style.zIndex,10)-1000}forceHide(){if(this.#S=this.isVisible,!this.#S)return;this.#i.hidden=!0}maybeShow(){if(this.#e)return;if(this.#O(),!this.#S)return;if(!this.#b)this.#v();this.#S=!1,this.#i.hidden=!1}get isVisible(){if(this.#e)return!1;return this.#i.hidden===!1}}class I8 extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=rt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let e=this.contentElement=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(let t of this.textContent){let a=document.createElement("span");a.textContent=t,e.append(a)}this.container.append(e)}if(!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class oS extends va{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:e,width:t,height:a}=this,n=this.svgFactory.create(t,a,!0),s=this.#e=this.svgFactory.createElement("svg:line");if(s.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),s.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),s.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),s.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),s.setAttribute("stroke-width",e.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),n.append(s),this.container.append(n),!e.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class cS extends va{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:e,width:t,height:a}=this,n=this.svgFactory.create(t,a,!0),s=e.borderStyle.width,i=this.#e=this.svgFactory.createElement("svg:rect");if(i.setAttribute("x",s/2),i.setAttribute("y",s/2),i.setAttribute("width",t-s),i.setAttribute("height",a-s),i.setAttribute("stroke-width",s||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!e.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class hS extends va{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:e,width:t,height:a}=this,n=this.svgFactory.create(t,a,!0),s=e.borderStyle.width,i=this.#e=this.svgFactory.createElement("svg:ellipse");if(i.setAttribute("cx",t/2),i.setAttribute("cy",a/2),i.setAttribute("rx",t/2-s/2),i.setAttribute("ry",a/2-s/2),i.setAttribute("stroke-width",s||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!e.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class G8 extends va{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:a,popupRef:n},width:s,height:i}=this;if(!t)return this.container;let f=this.svgFactory.create(s,i,!0),l=[];for(let h=0,u=t.length;h<u;h+=2){let g=t[h]-e[0],b=e[3]-t[h+1];l.push(`${g},${b}`)}l=l.join(" ");let c=this.#e=this.svgFactory.createElement(this.svgElementName);if(c.setAttribute("points",l),c.setAttribute("stroke-width",a.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),f.append(c),this.container.append(f),!n&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class uS extends G8{constructor(e){super(e);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class mS extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){if(this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}}class V5 extends va{#e=null;#t=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?rt.HIGHLIGHT:rt.INK}#a(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:a,borderStyle:n,popupRef:s}}=this,{transform:i,width:f,height:l}=this.#a(t,e),c=this.svgFactory.create(f,l,!0),h=this.#e=this.svgFactory.createElement("svg:g");c.append(h),h.setAttribute("stroke-width",n.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",i);for(let u=0,g=a.length;u<g;u++){let b=this.svgFactory.createElement(this.svgElementName);this.#t.push(b),b.setAttribute("points",a[u].join(",")),h.append(b)}if(!s&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:a,rect:n}=e,s=this.#e;if(t>=0)s.setAttribute("stroke-width",t||1);if(a)for(let i=0,f=this.#t.length;i<f;i++)this.#t[i].setAttribute("points",a[i].join(","));if(n){let{transform:i,width:f,height:l}=this.#a(this.data.rotation,n);s.parentElement.setAttribute("viewBox",`0 0 ${f} ${l}`),s.setAttribute("transform",i)}}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class X8 extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=rt.HIGHLIGHT}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),e){let a=document.createElement("mark");a.classList.add("overlaidText"),a.textContent=e,this.container.append(a)}return this.container}}class gS extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("underlineAnnotation"),e){let a=document.createElement("u");a.classList.add("overlaidText"),a.textContent=e,this.container.append(a)}return this.container}}class pS extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("squigglyAnnotation"),e){let a=document.createElement("u");a.classList.add("overlaidText"),a.textContent=e,this.container.append(a)}return this.container}}class bS extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("strikeoutAnnotation"),e){let a=document.createElement("s");a.classList.add("overlaidText"),a.textContent=e,this.container.append(a)}return this.container}}class K8 extends va{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=rt.STAMP}render(){if(this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class wS extends va{#e=null;constructor(e){super(e,{isRenderable:!0});let{fileId:t,file:a}=this.data;this.filename=a.filename,this.content=a.content,this.fileId=t,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...a})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:t}=this,a;if(t.hasAppearance||t.fillAlpha===0)a=document.createElement("div");else if(a=document.createElement("img"),a.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1)a.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`;a.addEventListener("dblclick",this.#t.bind(this)),this.#e=a;let{isMac:n}=ea.platform;if(e.addEventListener("keydown",(s)=>{if(s.key==="Enter"&&(n?s.metaKey:s.ctrlKey))this.#t()}),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();else a.classList.add("popupTriggerArea");return e.append(a),e}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}async#t(){let{fileId:e,filename:t,content:a}=this,n=await this.linkService.getAttachmentContent(e)||a;if(n)this.downloadManager?.openOrDownloadData(n,t)}}class L8 extends va{#e=new AbortController;#t=null;#a=null;constructor(e){super(e,{isRenderable:!!e.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");let{filename:e}=this.data.richMedia,t=document.createElement("button");return t.className="mediaPlayButton",t.type="button",t.title=t.ariaLabel=e,t.addEventListener("click",()=>this.#n(t),{signal:this.#e.signal}),this.container.append(t),this.container}async#n(e){let{fileId:t,filename:a,contentType:n}=this.data.richMedia;e.disabled=!0;let s;try{s=await this.linkService.getAttachmentContent(t)}catch{return}finally{e.disabled=!1}if(!s||!e.isConnected)return;let{signal:i}=this.#e,f=URL.createObjectURL(new Blob([s],{type:n}));this.#t=f;let l=n.startsWith("audio/"),c=document.createElement(l?"audio":"video");if(this.#a=c,c.className="mediaContent",this._setBackgroundColor(c),c.src=f,c.title=a,c.controls=!0,c.autoplay=!0,c.tabIndex=0,l){let h=!1,u=!1,g=()=>{c.controls=h||u};this.container.addEventListener("pointerenter",()=>{h=!0,g()},{signal:i}),this.container.addEventListener("pointerleave",()=>{h=!1,g()},{signal:i}),this.container.addEventListener("focusin",()=>{u=!0,g()},{signal:i}),this.container.addEventListener("focusout",()=>{u=!1,g()},{signal:i})}c.addEventListener("emptied",()=>this.#s(f),{once:!0,signal:i}),e.replaceWith(c),c.play().catch(()=>{})}#s(e=this.#t){if(e&&e===this.#t)URL.revokeObjectURL(e),this.#t=null}destroy(){if(this.#e.abort(),this.#a)this.#a.pause(),this.#a.removeAttribute("src"),this.#a.load(),this.#a=null;this.#s()}}class V8{#e=null;#t=null;#a=null;#n=new Map;#s=null;#f=null;#i=[];#l=!1;zIndex=0;constructor({div:e,accessibilityManager:t,annotationCanvasMap:a,annotationEditorUIManager:n,page:s,viewport:i,structTreeLayer:f,commentManager:l,linkService:c,annotationStorage:h}){this.div=e,this.#e=t,this.#t=a,this.#s=f||null,this.#f=c||null,this.#a=h||new E5,this.page=s,this.viewport=i,this._annotationEditorUIManager=n,this._commentManager=l||null}hasEditableAnnotations(){return this.#n.size>0}async render(e){let{annotations:t,optionalContentConfig:a}=e,n=this.div;Ir(n,this.viewport);let s=new Map,i=[],f={data:null,layer:n,linkService:this.#f,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new b2,annotationStorage:this.#a,enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let l of t){if(l.noHTML)continue;let c=l.annotationType===za.POPUP;if(!c){if(l.rect[2]===l.rect[0]||l.rect[3]===l.rect[1])continue}else{let g=s.get(l.id);if(!g)continue;if(!this._commentManager){i.push(l);continue}f.elements=g}f.data=l;let h=q5.create(f);if(!h.isRenderable)continue;if(!c){if(this.#i.push(h),l.popupRef)s.getOrInsertComputed(l.popupRef,w2).push(h)}let u=h.render();if(l.hidden)u.style.visibility="hidden";if(h.updateOC(a),h._isEditable)this.#n.set(h.data.id,h),this._annotationEditorUIManager?.renderAnnotationElement(h)}await this.#o();for(let l of i){let c=f.elements=s.get(l.id);f.data=l;let h=q5.create(f);if(!h.isRenderable)continue;let u=h.render();if(h.contentElement.id=`pdfjs_internal_id_${l.id}`,l.hidden)u.style.visibility="hidden";c.at(-1).container.after(u)}this.#r()}async#o(){if(this.#i.length===0)return;this.div.replaceChildren();let e=[];if(!this.#l){this.#l=!0;for(let{contentElement:a,data:{id:n}}of this.#i){let s=a.id=`pdfjs_internal_id_${n}`;e.push(this.#s?.getAriaAttributes(s).then((i)=>{if(i)for(let[f,l]of i)a.setAttribute(f,l)}))}}this.#i.sort(({data:{rect:[a,n,s,i]}},{data:{rect:[f,l,c,h]}})=>{if(a===s&&n===i)return 1;if(f===c&&l===h)return-1;let u=i,g=n,b=(n+i)/2,d=h,j=l,A=(l+h)/2;if(b>=d&&A<=g)return-1;if(A>=u&&b<=j)return 1;let C=(a+s)/2,y=(f+c)/2;return C-y});let t=document.createDocumentFragment();for(let a of this.#i)if(t.append(a.container),this._commentManager)(a.extraPopupElement?.popup||a.popup)?.renderCommentButton();else if(a.extraPopupElement)t.append(a.extraPopupElement.render());if(this.div.append(t),await Promise.all(e),this.#e)for(let a of this.#i)this.#e.addPointerInTextLayer(a.contentElement,!1)}async addLinkAnnotations(e){let t={data:null,layer:this.div,linkService:this.#f,svgFactory:new b2,parent:this};for(let a of e){a.borderStyle||=V8._defaultBorderStyle,t.data=a;let n=q5.create(t);if(!n.isRenderable)continue;n.render(),n.contentElement.id=`pdfjs_internal_id_${a.id}`,this.#i.push(n)}await this.#o()}update({viewport:e,optionalContentConfig:t}){let a=this.div;this.viewport=e,Ir(a,{rotation:e.rotation});for(let n of this.#i)n.updateOC(t);this.#r(),a.hidden=!1}destroy(){for(let e of this.#i)e.destroy?.(),this.#e?.removePointerInTextLayer(e.contentElement);this.#i.length=0,this.#n.clear(),this.div.replaceChildren()}#r(){if(!this.#t)return;let e=this.div;for(let[t,a]of this.#t){let n=e.querySelector(`[data-annotation-id="${t}"]`);if(!n)continue;if(Array.isArray(a))for(let c of a)c.className="annotationContent",c.ariaHidden=!0;else a.className="annotationContent",a.ariaHidden=!0;let s=[];for(let c of n.children)if(c.nodeName==="CANVAS")s.push(c);for(let c of s)c.remove();let i=Array.isArray(a)?a[0]:a,{firstChild:f}=n;if(!f)n.append(i);else if(!f.classList.contains("annotationContent"))f.before(i);else f.after(i);if(Array.isArray(a)){let c=i;for(let h=1,u=a.length;h<u;h++)c.after(a[h]),c=a[h]}this.#t.delete(t);let l=this.#n.get(t);if(!l)continue;if(l._hasNoCanvas)this._annotationEditorUIManager?.setMissingCanvas(t,n.id,a),l._hasNoCanvas=!1;else l.canvas=a}}refreshCanvases(){this.#r()}getEditableAnnotations(){return this.#n.values()}getEditableAnnotation(e){return this.#n.get(e)}addFakeAnnotation(e){let{div:t}=this,{id:a,rotation:n}=e,s=new eS({data:{id:a,rect:e.getPDFRect(),rotation:n},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:this.#f,annotationStorage:this.#a});return s.render(),s.contentElement.id=`pdfjs_internal_id_${a}`,s.createOrUpdatePopup(),this.#i.push(s),s}removeAnnotation(e){let t=this.#i.findIndex((n)=>n.data.id===e);if(t<0)return;let[a]=this.#i.splice(t,1);this.#e?.removePointerInTextLayer(a.contentElement)}updateFakeAnnotations(e){if(e.length===0)return;for(let t of e)t.updateFakeAnnotationElement(this);this.#o()}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}static get _defaultBorderStyle(){return ft(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:zo.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}var m5=/\r\n?|\n/g;class An extends Ve{#e="";#t=`${this.id}-editor`;#a=null;#n;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let e=An.prototype,t=(s)=>s.isEmpty(),a=Al.TRANSLATE_SMALL,n=Al.TRANSLATE_BIG;return ft(this,"_keyboardManager",new Qs([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-a,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:t}],[["ArrowRight"],e._translateEmpty,{args:[a,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ArrowUp"],e._translateEmpty,{args:[0,-a],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ArrowDown"],e._translateEmpty,{args:[0,a],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}]]))}static _type="freetext";static _editorType=rt.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"});if(this.color=e.color||An._defaultColor||Ve._defaultLineColor,this.#n=e.fontSize||An._defaultFontSize,!this.annotationElementId)this._uiManager.a11yAlert(Ve._l10nAlert.freetext);this.canAddComment=!1}static initialize(e,t){Ve.initialize(e,t);let a=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(a.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case bt.FREETEXT_SIZE:An._defaultFontSize=t;break;case bt.FREETEXT_COLOR:An._defaultColor=t;break}}updateParams(e,t){switch(e){case bt.FREETEXT_SIZE:this.#s(t);break;case bt.FREETEXT_COLOR:this.#f(t);break}}static get defaultPropertiesToUpdate(){return[[bt.FREETEXT_SIZE,An._defaultFontSize],[bt.FREETEXT_COLOR,An._defaultColor||Ve._defaultLineColor]]}get propertiesToUpdate(){return[[bt.FREETEXT_SIZE,this.#n],[bt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new p2(this),[["colorPicker",this._colorPicker]]}get colorType(){return bt.FREETEXT_COLOR}#s(e){let t=(n)=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--total-scale-factor))`,this.translate(0,-(n-this.#n)*this.parentScale),this.#n=n,this.#l()},a=this.#n;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:bt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#f(e){let t=(n)=>{this.color=n,this.onUpdatedColor()},a=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:bt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let e=this.parentScale;return[-An._internalPadding*e,-(An._internalPadding+this.#n)*e]}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(!this.isAttachedToDOM)this.parent.add(this)}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#a=new AbortController;let e=this._uiManager.combinedSignal(this.#a);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){if(!super.disableEditMode())return!1;return this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#t),this._isDraggable=!0,this.#a?.abort(),this.#a=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0}focusin(e){if(!this._focusEventsAllowed)return;if(super.focusin(e),e.target!==this.editorDiv)this.editorDiv.focus()}onceAdded(e){if(this.width)return;if(this.enableEditMode(),e)this.editorDiv.focus();if(this._initialOptions?.isCentered)this.center();this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){if(this.isEditing=!1,this.parent)this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing");super.remove()}#i(){let e=[];this.editorDiv.normalize();let t=null;for(let a of this.editorDiv.childNodes){if(t?.nodeType===Node.TEXT_NODE&&a.nodeName==="BR")continue;e.push(An.#o(a)),t=a}return e.join(`
299
+ `)}#l(){let[e,t]=this.parentDimensions,a;if(this.isAttachedToDOM)a=this.div.getBoundingClientRect();else{let{currentLayer:n,div:s}=this,i=s.style.display,f=s.classList.contains("hidden");s.classList.remove("hidden"),s.style.display="hidden",n.div.append(this.div),a=s.getBoundingClientRect(),s.remove(),s.style.display=i,s.classList.toggle("hidden",f)}if(this.rotation%180===this.parentRotation%180)this.width=a.width/e,this.height=a.height/t;else this.width=a.height/e,this.height=a.width/t;this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#e,t=this.#e=this.#i().trimEnd();if(e===t)return;let a=(n)=>{if(this.#e=n,!n){this.remove();return}this.#r(),this._uiManager.rebuild(this),this.#l()};this.addCommands({cmd:()=>{a(t)},undo:()=>{a(e)},mustExec:!1}),this.#l()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){if(e.target===this.div&&e.key==="Enter")this.enterInEditMode(),e.preventDefault()}editorDivKeydown(e){An._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy||this.annotationElementId)e=this.x,t=this.y;super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#t),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:a}=this.editorDiv;if(a.fontSize=`calc(${this.#n}px * var(--total-scale-factor))`,a.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[n,s]=this.parentDimensions;if(this.annotationElementId){let{position:i}=this._initialData,[f,l]=this.getInitialTranslation();[f,l]=this.pageTranslationToScreen(f,l);let[c,h]=this.pageDimensions,[u,g]=this.pageTranslation,b,d;switch(this.rotation){case 0:b=e+(i[0]-u)/c,d=t+this.height-(i[1]-g)/h;break;case 90:b=e+(i[0]-u)/c,d=t-(i[1]-g)/h,[f,l]=[l,-f];break;case 180:b=e-this.width+(i[0]-u)/c,d=t-(i[1]-g)/h,[f,l]=[-f,-l];break;case 270:b=e+(i[0]-u-this.height*h)/c,d=t+(i[1]-g-this.width*c)/h,[f,l]=[-l,f];break}this.setAt(b*n,d*s,f,l)}else this._moveAfterPaste(e,t);this.#r(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#o(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(m5,"")}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:a}=t;if(a.length===1&&a[0]==="text/plain")return;e.preventDefault();let n=An.#h(t.getData("text")||"").replaceAll(m5,`
300
+ `);if(!n)return;let s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();let i=s.getRangeAt(0);if(!n.includes(`
301
+ `)){i.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),s.collapseToStart();return}let{startContainer:f,startOffset:l}=i,c=[],h=[];if(f.nodeType===Node.TEXT_NODE){let b=f.parentElement;if(h.push(f.nodeValue.slice(l).replaceAll(m5,"")),b!==this.editorDiv){let d=c;for(let j of this.editorDiv.childNodes){if(j===b){d=h;continue}d.push(An.#o(j))}}c.push(f.nodeValue.slice(0,l).replaceAll(m5,""))}else if(f===this.editorDiv){let b=c,d=0;for(let j of this.editorDiv.childNodes){if(d++===l)b=h;b.push(An.#o(j))}}this.#e=`${c.join(`
302
+ `)}${n}${h.join(`
303
+ `)}`,this.#r();let u=new Range,g=Math.sumPrecise(c.map((b)=>b.length));for(let{firstChild:b}of this.editorDiv.childNodes)if(b.nodeType===Node.TEXT_NODE){let d=b.nodeValue.length;if(g<=d){u.setStart(b,g),u.setEnd(b,g);break}g-=d}s.removeAllRanges(),s.addRange(u)}#r(){if(this.editorDiv.replaceChildren(),!this.#e)return;for(let e of this.#e.split(`
304
+ `)){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#u(){return this.#e.replaceAll(" "," ")}static#h(e){return e.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let e=An._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,a){let n=null;if(e instanceof I8){let{data:{defaultAppearanceData:{fontSize:i,fontColor:f},rect:l,rotation:c,id:h,popupRef:u,richText:g,contentsObj:b,creationDate:d,modificationDate:j},textContent:A,textPosition:C,parent:{page:{pageNumber:y}}}=e;if(!A?.length)return null;n=e={annotationType:rt.FREETEXT,color:Array.from(f),fontSize:i,value:A.join(`
305
+ `),position:C,pageIndex:y-1,rect:l.slice(0),rotation:c,annotationElementId:h,id:h,deleted:!1,popupRef:u,comment:b?.str||null,richText:g,creationDate:d,modificationDate:j}}let s=await super.deserialize(e,t,a);if(s.#n=e.fontSize,s.color=Fe.makeHexColor(...e.color),s.#e=An.#h(e.value),s._initialData=n,e.comment)s.setCommentData(e);return s}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=Ve._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),a=Object.assign(super.serialize(e),{color:t,fontSize:this.#n,value:this.#u()});if(this.addComment(a),e)return a.isCopy=!0,a;if(this.annotationElementId&&!this.#g(a))return null;return a.id=this.annotationElementId,a}#g(e){let{value:t,fontSize:a,color:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==a||e.color.some((i,f)=>i!==n[f])||e.pageIndex!==s}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(!t)return null;let{style:a}=t;a.fontSize=`calc(${this.#n}px * var(--total-scale-factor))`,a.color=this.color,t.replaceChildren();for(let n of this.#e.split(`
306
+ `)){let s=document.createElement("div");s.append(n?document.createTextNode(n):document.createElement("br")),t.append(s)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#e}}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class Ee{static PRECISION=0.0001;toSVGPath(){Et("Abstract method `toSVGPath` must be implemented.")}get box(){Et("Abstract getter `box` must be implemented.")}serialize(e,t){Et("Abstract method `serialize` must be implemented.")}static _rescale(e,t,a,n,s,i){i||=new Float32Array(e.length);for(let f=0,l=e.length;f<l;f+=2)i[f]=t+e[f]*n,i[f+1]=a+e[f+1]*s;return i}static _rescaleAndSwap(e,t,a,n,s,i){i||=new Float32Array(e.length);for(let f=0,l=e.length;f<l;f+=2)i[f]=t+e[f+1]*n,i[f+1]=a+e[f]*s;return i}static _translate(e,t,a,n){n||=new Float32Array(e.length);for(let s=0,i=e.length;s<i;s+=2)n[s]=t+e[s],n[s+1]=a+e[s+1];return n}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,t,a,n,s){switch(s){case 90:return[1-t/a,e/n];case 180:return[1-e/a,1-t/n];case 270:return[t/a,1-e/n];default:return[e/a,t/n]}}static createBezierPoints(e,t,a,n,s,i){return[(e+5*a)/6,(t+5*n)/6,(5*a+s)/6,(5*n+i)/6,(a+s)/2,(n+i)/2]}}class zr{#e;#t=[];#a;#n;#s=[];#f=new Float32Array(18);#i;#l;#o;#r;#u;#h;#g=[];static#b=8;static#p=2;static#c=zr.#b+zr.#p;constructor({x:e,y:t},a,n,s,i,f=0){this.#e=a,this.#h=s*n,this.#n=i,this.#f.set([NaN,NaN,NaN,NaN,e,t],6),this.#a=f,this.#r=zr.#b*n,this.#o=zr.#c*n,this.#u=n,this.#g.push(e,t)}isEmpty(){return isNaN(this.#f[8])}#m(){let e=this.#f.subarray(4,6),t=this.#f.subarray(16,18),[a,n,s,i]=this.#e;return[(this.#i+(e[0]-t[0])/2-a)/s,(this.#l+(e[1]-t[1])/2-n)/i,(this.#i+(t[0]-e[0])/2-a)/s,(this.#l+(t[1]-e[1])/2-n)/i]}add({x:e,y:t}){this.#i=e,this.#l=t;let[a,n,s,i]=this.#e,[f,l,c,h]=this.#f.subarray(8,12),u=e-c,g=t-h,b=Math.hypot(u,g);if(b<this.#o)return!1;let d=b-this.#r,j=d/b,A=j*u,C=j*g,y=f,O=l;f=c,l=h,c+=A,h+=C,this.#g?.push(e,t);let T=-C/d,M=A/d,H=T*this.#h,N=M*this.#h;if(this.#f.set(this.#f.subarray(2,8),0),this.#f.set([c+H,h+N],4),this.#f.set(this.#f.subarray(14,18),12),this.#f.set([c-H,h-N],16),isNaN(this.#f[6])){if(this.#s.length===0)this.#f.set([f+H,l+N],2),this.#s.push(NaN,NaN,NaN,NaN,(f+H-a)/s,(l+N-n)/i),this.#f.set([f-H,l-N],14),this.#t.push(NaN,NaN,NaN,NaN,(f-H-a)/s,(l-N-n)/i);return this.#f.set([y,O,f,l,c,h],6),!this.isEmpty()}if(this.#f.set([y,O,f,l,c,h],6),Math.abs(Math.atan2(O-l,y-f)-Math.atan2(C,A))<Math.PI/2)return[f,l,c,h]=this.#f.subarray(2,6),this.#s.push(NaN,NaN,NaN,NaN,((f+c)/2-a)/s,((l+h)/2-n)/i),[f,l,y,O]=this.#f.subarray(14,18),this.#t.push(NaN,NaN,NaN,NaN,((y+f)/2-a)/s,((O+l)/2-n)/i),!0;return[y,O,f,l,c,h]=this.#f.subarray(0,6),this.#s.push(((y+5*f)/6-a)/s,((O+5*l)/6-n)/i,((5*f+c)/6-a)/s,((5*l+h)/6-n)/i,((f+c)/2-a)/s,((l+h)/2-n)/i),[c,h,f,l,y,O]=this.#f.subarray(12,18),this.#t.push(((y+5*f)/6-a)/s,((O+5*l)/6-n)/i,((5*f+c)/6-a)/s,((5*l+h)/6-n)/i,((f+c)/2-a)/s,((l+h)/2-n)/i),!0}toSVGPath(){if(this.isEmpty())return"";let e=this.#s,t=this.#t;if(isNaN(this.#f[6])&&!this.isEmpty())return this.#d();let a=[];a.push(`M${e[4]} ${e[5]}`);for(let n=6;n<e.length;n+=6)if(isNaN(e[n]))a.push(`L${e[n+4]} ${e[n+5]}`);else a.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);this.#w(a);for(let n=t.length-6;n>=6;n-=6)if(isNaN(t[n]))a.push(`L${t[n+4]} ${t[n+5]}`);else a.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);return this.#j(a),a.join(" ")}#d(){let[e,t,a,n]=this.#e,[s,i,f,l]=this.#m();return`M${(this.#f[2]-e)/a} ${(this.#f[3]-t)/n} L${(this.#f[4]-e)/a} ${(this.#f[5]-t)/n} L${s} ${i} L${f} ${l} L${(this.#f[16]-e)/a} ${(this.#f[17]-t)/n} L${(this.#f[14]-e)/a} ${(this.#f[15]-t)/n} Z`}#j(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#w(e){let[t,a,n,s]=this.#e,i=this.#f.subarray(4,6),f=this.#f.subarray(16,18),[l,c,h,u]=this.#m();e.push(`L${(i[0]-t)/n} ${(i[1]-a)/s} L${l} ${c} L${h} ${u} L${(f[0]-t)/n} ${(f[1]-a)/s}`)}newFreeDrawOutline(e,t,a,n,s,i){return new Y8(e,t,a,n,s,i)}getOutlines(){let e=this.#s,t=this.#t,a=this.#f,[n,s,i,f]=this.#e,l=new Float32Array((this.#g?.length??0)+2);for(let u=0,g=l.length-2;u<g;u+=2)l[u]=(this.#g[u]-n)/i,l[u+1]=(this.#g[u+1]-s)/f;if(l[l.length-2]=(this.#i-n)/i,l[l.length-1]=(this.#l-s)/f,isNaN(a[6])&&!this.isEmpty())return this.#A(l);let c=new Float32Array(this.#s.length+24+this.#t.length),h=e.length;for(let u=0;u<h;u+=2){if(isNaN(e[u])){c[u]=c[u+1]=NaN;continue}c[u]=e[u],c[u+1]=e[u+1]}h=this.#q(c,h);for(let u=t.length-6;u>=6;u-=6)for(let g=0;g<6;g+=2){if(isNaN(t[u+g])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=t[u+g],c[h+1]=t[u+g+1],h+=2}return this.#y(c,h),this.newFreeDrawOutline(c,l,this.#e,this.#u,this.#a,this.#n)}#A(e){let t=this.#f,[a,n,s,i]=this.#e,[f,l,c,h]=this.#m(),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-a)/s,(t[3]-n)/i,NaN,NaN,NaN,NaN,(t[4]-a)/s,(t[5]-n)/i,NaN,NaN,NaN,NaN,f,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(t[16]-a)/s,(t[17]-n)/i,NaN,NaN,NaN,NaN,(t[14]-a)/s,(t[15]-n)/i],0),this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#a,this.#n)}#y(e,t){let a=this.#t;return e.set([NaN,NaN,NaN,NaN,a[4],a[5]],t),t+=6}#q(e,t){let a=this.#f.subarray(4,6),n=this.#f.subarray(16,18),[s,i,f,l]=this.#e,[c,h,u,g]=this.#m();return e.set([NaN,NaN,NaN,NaN,(a[0]-s)/f,(a[1]-i)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,u,g,NaN,NaN,NaN,NaN,(n[0]-s)/f,(n[1]-i)/l],t),t+=24}}class Y8 extends Ee{#e;#t=new Float32Array(4);#a;#n;#s;#f;#i;constructor(e,t,a,n,s,i){super();this.#i=e,this.#s=t,this.#e=a,this.#f=n,this.#a=s,this.#n=i,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#l(i);let[f,l,c,h]=this.#t;for(let u=0,g=e.length;u<g;u+=2)e[u]=(e[u]-f)/c,e[u+1]=(e[u+1]-l)/h;for(let u=0,g=t.length;u<g;u+=2)t[u]=(t[u]-f)/c,t[u+1]=(t[u+1]-l)/h}toSVGPath(){let e=[`M${this.#i[4]} ${this.#i[5]}`];for(let t=6,a=this.#i.length;t<a;t+=6){if(isNaN(this.#i[t])){e.push(`L${this.#i[t+4]} ${this.#i[t+5]}`);continue}e.push(`C${this.#i[t]} ${this.#i[t+1]} ${this.#i[t+2]} ${this.#i[t+3]} ${this.#i[t+4]} ${this.#i[t+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,t,a,n],s){let i=a-e,f=n-t,l,c;switch(s){case 0:l=Ee._rescale(this.#i,e,n,i,-f),c=Ee._rescale(this.#s,e,n,i,-f);break;case 90:l=Ee._rescaleAndSwap(this.#i,e,t,i,f),c=Ee._rescaleAndSwap(this.#s,e,t,i,f);break;case 180:l=Ee._rescale(this.#i,a,t,-i,f),c=Ee._rescale(this.#s,a,t,-i,f);break;case 270:l=Ee._rescaleAndSwap(this.#i,a,n,-i,-f),c=Ee._rescaleAndSwap(this.#s,a,n,-i,-f);break}return{outline:Array.from(l),points:[Array.from(c)]}}#l(e){let t=this.#i,a=t[4],n=t[5],s=[a,n,a,n],i=a,f=n,l=a,c=n,h=e?Math.max:Math.min,u=new Float32Array(4);for(let b=6,d=t.length;b<d;b+=6){let j=t[b+4],A=t[b+5];if(isNaN(t[b])){if(Fe.pointBoundingBox(j,A,s),f>A)i=j,f=A;else if(f===A)i=h(i,j);if(c<A)l=j,c=A;else if(c===A)l=h(l,j)}else{if(u.set(mf,0),Fe.bezierBoundingBox(a,n,...t.slice(b,b+6),u),Fe.rectBoundingBox(...u,s),f>u[1])i=u[0],f=u[1];else if(f===u[1])i=h(i,u[0]);if(c<u[3])l=u[2],c=u[3];else if(c===u[3])l=h(l,u[2])}a=j,n=A}let g=this.#t;g[0]=s[0]-this.#a,g[1]=s[1]-this.#a,g[2]=s[2]-s[0]+2*this.#a,g[3]=s[3]-s[1]+2*this.#a,this.firstPoint=[i,f],this.lastPoint=[l,c]}get box(){return this.#t}newOutliner(e,t,a,n,s,i=0){return new zr(e,t,a,n,s,i)}getNewOutline(e,t){let[a,n,s,i]=this.#t,[f,l,c,h]=this.#e,u=s*c,g=i*h,b=a*c+f,d=n*h+l,j=this.newOutliner({x:this.#s[0]*u+b,y:this.#s[1]*g+d},this.#e,this.#f,e,this.#n,t??this.#a);for(let A=2;A<this.#s.length;A+=2)j.add({x:this.#s[A]*u+b,y:this.#s[A+1]*g+d});return j.getOutlines()}}class _5{#e;#t;#a;#n=[];#s=[];constructor(e,t=0,a=0,n=!0){let s=mf.slice(),i=4,f=0.0001;for(let{x:A,y:C,width:y,height:O}of e){let T=Math.floor((A-t)/0.0001)*0.0001,M=Math.ceil((A+y+t)/0.0001)*0.0001,H=Math.floor((C-t)/0.0001)*0.0001,N=Math.ceil((C+O+t)/0.0001)*0.0001,x=[T,H,N,!0],z=[M,H,N,!1];this.#n.push(x,z),Fe.rectBoundingBox(T,H,M,N,s)}let l=s[2]-s[0]+2*a,c=s[3]-s[1]+2*a,h=s[0]-a,u=s[1]-a,g=n?-1/0:1/0,b=1/0,d=this.#n.at(n?-1:-2),j=[d[0],d[2]];for(let A of this.#n){let[C,y,O,T]=A;if(!T&&n){if(y<b)b=y,g=C;else if(y===b)g=Math.max(g,C)}else if(T&&!n){if(y<b)b=y,g=C;else if(y===b)g=Math.min(g,C)}A[0]=(C-h)/l,A[1]=(y-u)/c,A[2]=(O-u)/c}this.#e=new Float32Array([h,u,l,c]),this.#t=[g,b],this.#a=j}getOutlines(){this.#n.sort((t,a)=>t[0]-a[0]||t[1]-a[1]||t[2]-a[2]);let e=[];for(let t of this.#n)if(t[3])e.push(...this.#r(t)),this.#l(t);else this.#o(t),e.push(...this.#r(t));return this.#f(e)}#f(e){let t=[],a=new Set;for(let i of e){let[f,l,c]=i;t.push([f,l,i],[f,c,i])}t.sort((i,f)=>i[1]-f[1]||i[0]-f[0]);for(let i=0,f=t.length;i<f;i+=2){let l=t[i][2],c=t[i+1][2];l.push(c),c.push(l),a.add(l),a.add(c)}let n=[],s;while(a.size>0){let i=a.values().next().value,[f,l,c,h,u]=i;a.delete(i);let g=f,b=l;s=[f,c],n.push(s);while(!0){let d;if(a.has(h))d=h;else if(a.has(u))d=u;else break;if(a.delete(d),[f,l,c,h,u]=d,g!==f)s.push(g,b,f,b===l?l:c),g=f;b=b===l?c:l}s.push(g,b)}return new dS(n,this.#e,this.#t,this.#a)}#i(e){let t=this.#s,a=0,n=t.length-1;while(a<=n){let s=a+n>>1,i=t[s][0];if(i===e)return s;if(i<e)a=s+1;else n=s-1}return n+1}#l([,e,t]){let a=this.#i(e);this.#s.splice(a,0,[e,t])}#o([,e,t]){let a=this.#i(e);for(let n=a;n<this.#s.length;n++){let[s,i]=this.#s[n];if(s!==e)break;if(s===e&&i===t){this.#s.splice(n,1);return}}for(let n=a-1;n>=0;n--){let[s,i]=this.#s[n];if(s!==e)break;if(s===e&&i===t){this.#s.splice(n,1);return}}}#r(e){let[t,a,n]=e,s=[[t,a,n]],i=this.#i(n);for(let f=0;f<i;f++){let[l,c]=this.#s[f];for(let h=0,u=s.length;h<u;h++){let[,g,b]=s[h];if(c<=g||b<=l)continue;if(g>=l){if(b>c)s[h][1]=c;else{if(u===1)return[];s.splice(h,1),h--,u--}continue}if(s[h][2]=l,b>c)s.push([t,c,b])}}return s}}class dS extends Ee{#e;#t;constructor(e,t,a,n){super();this.#t=e,this.#e=t,this.firstPoint=a,this.lastPoint=n}toSVGPath(){let e=[];for(let t of this.#t){let[a,n]=t;e.push(`M${a} ${n}`);for(let s=2;s<t.length;s+=2){let i=t[s],f=t[s+1];if(i===a)e.push(`V${f}`),n=f;else if(f===n)e.push(`H${i}`),a=i}e.push("Z")}return e.join(" ")}serialize([e,t,a,n],s){let i=[],f=a-e,l=n-t;for(let c of this.#t){let h=Array(c.length);for(let u=0;u<c.length;u+=2)h[u]=e+c[u]*f,h[u+1]=n-c[u+1]*l;i.push(h)}return i}get box(){return this.#e}}class F5 extends zr{newFreeDrawOutline(e,t,a,n,s,i){return new jS(e,t,a,n,s,i)}}class jS extends Y8{newOutliner(e,t,a,n,s,i=0){return new F5(e,t,a,n,s,i)}}class Va extends Ve{#e=null;#t=0;#a;#n=null;#s=null;#f=null;#i=null;#l=0;#o=null;#r=null;#u=null;#h=!1;#g=null;#b=null;#p=null;#c="";#m;#d="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=rt.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let e=Va.prototype;return ft(this,"_keyboardManager",new Qs([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"});if(this.color=e.color||Va._defaultColor,this.#m=e.thickness||Va._defaultThickness,this.opacity=e.opacity||Va._defaultOpacity,this.#a=e.boxes||null,this.#d=e.methodOfCreation||"",this.#c=e.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1)this.#h=!0,this.#w(e),this.#k();else if(this.#a)this.#e=e.anchorNode,this.#t=e.anchorOffset,this.#i=e.focusNode,this.#l=e.focusOffset,this.#j(),this.#k(),this.rotate(this.rotation);if(!this.annotationElementId)this._uiManager.a11yAlert(Ve._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#m,methodOfCreation:this.#d}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#j(){let e=new _5(this.#a,0.001);this.#r=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#r.box;let t=new _5(this.#a,0.0025,0.001,this._uiManager.direction==="ltr");this.#f=t.getOutlines();let{firstPoint:a}=this.#r;this.#g=[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height];let{lastPoint:n}=this.#f;this.#b=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#w({highlightOutlines:e,highlightId:t,clipPathId:a}){this.#r=e;let n=1.5;if(this.#f=e.getNewOutline(this.#m/2+n,0.0025),t>=0)this.#u=t,this.#n=a,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#f.box,path:{d:this.#f.toSVGPath()}},!0);else if(this.parent){let u=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Va.#_(this.#r.box,(u-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:Va.#_(this.#f.box,u),path:{d:this.#f.toSVGPath()}})}let[s,i,f,l]=e.box;switch(this.rotation){case 0:this.x=s,this.y=i,this.width=f,this.height=l;break;case 90:{let[u,g]=this.parentDimensions;this.x=i,this.y=1-s,this.width=f*g/u,this.height=l*u/g;break}case 180:this.x=1-s,this.y=1-i,this.width=f,this.height=l;break;case 270:{let[u,g]=this.parentDimensions;this.x=1-i,this.y=s,this.width=f*g/u,this.height=l*u/g;break}}let{firstPoint:c}=e;this.#g=[(c[0]-s)/f,(c[1]-i)/l];let{lastPoint:h}=this.#f;this.#b=[(h[0]-s)/f,(h[1]-i)/l]}static initialize(e,t){Ve.initialize(e,t),Va._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case bt.HIGHLIGHT_COLOR:Va._defaultColor=t;break;case bt.HIGHLIGHT_THICKNESS:Va._defaultThickness=t;break}}translateInPage(e,t){}get toolbarPosition(){return this.#b}get commentButtonPosition(){return this.#g}updateParams(e,t){switch(e){case bt.HIGHLIGHT_COLOR:this.#A(t);break;case bt.HIGHLIGHT_THICKNESS:this.#y(t);break}}static get defaultPropertiesToUpdate(){return[[bt.HIGHLIGHT_COLOR,Va._defaultColor],[bt.HIGHLIGHT_THICKNESS,Va._defaultThickness]]}get propertiesToUpdate(){return[[bt.HIGHLIGHT_COLOR,this.color||Va._defaultColor],[bt.HIGHLIGHT_THICKNESS,this.#m||Va._defaultThickness],[bt.HIGHLIGHT_FREE,this.#h]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#s?.updateColor(this.color),super.onUpdatedColor()}#A(e){let t=(s,i)=>{this.color=s,this.opacity=i,this.onUpdatedColor()},a=this.color,n=this.opacity;this.addCommands({cmd:t.bind(this,e,Va._defaultOpacity),undo:t.bind(this,a,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:bt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)}#y(e){let t=this.#m,a=(n)=>{this.#m=n,this.#q(n)};this.addCommands({cmd:a.bind(this,e),undo:a.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:bt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[["colorPicker",this.#s=new ki({editor:this})]];return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#F())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#F())}onceAdded(e){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(e)this.div.focus()}remove(){this.#S(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#k(),!this.isAttachedToDOM)this.parent.add(this)}setParent(e){let t=!1;if(this.parent&&!e)this.#S();else if(e)this.#k(e),t=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(e),this.show(this._isVisible),t)this.select()}#q(e){if(!this.#h)return;this.#w({highlightOutlines:this.#r.getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims()}#S(){if(this.#u===null||!this.parent)return;this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#p),this.#p=null}#k(e=this.parent){if(this.#u!==null)return;if({id:this.#u,clipPathId:this.#n}=e.drawLayer.draw({bbox:this.#r.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#h},path:{d:this.#r.toSVGPath()}},!1,!0),this.#p=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#h},bbox:this.#f.box,path:{d:this.#f.toSVGPath()}},this.#h),this.#o)this.#o.style.clipPath=this.#n}static#_([e,t,a,n],s){switch(s){case 90:return[1-t-n,e,n,a];case 180:return[1-e-a,1-t-n,a,n];case 270:return[t,1-e-a,n,a]}return[e,t,a,n]}rotate(e){let{drawLayer:t}=this.parent,a;if(this.#h)e=(e-this.rotation+360)%360,a=Va.#_(this.#r.box,e);else a=Va.#_([this.x,this.y,this.width,this.height],e);t.updateProperties(this.#u,{bbox:a,root:{"data-main-rotation":e}}),t.updateProperties(this.#p,{bbox:Va.#_(this.#f.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;let e=super.render();if(this.#c)e.setAttribute("aria-label",this.#c),e.setAttribute("role","mark");if(this.#h)e.classList.add("free");else this.div.addEventListener("keydown",this.#O.bind(this),{signal:this._uiManager._signal});let t=this.#o=document.createElement("div");return e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#n,this.setDims(),ty(this,this.#o,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){if(!this.isSelected)this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){if(!this.isSelected)this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#O(e){Va._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#B(!0);break;case 1:case 3:this.#B(!1);break}}#B(e){if(!this.#e)return;let t=window.getSelection();if(e)t.setPosition(this.#e,this.#t);else t.setPosition(this.#i,this.#l)}select(){if(super.select(),!this.#p)return;this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){if(super.unselect(),!this.#p)return;if(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),!this.#h)this.#B(!1)}get _mustFixPosition(){return!this.#h}show(e=this._isVisible){if(super.show(e),this.parent)this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!e}})}#F(){return this.#h?this.rotation:0}#M(){if(this.#h)return null;let[e,t]=this.pageDimensions,[a,n]=this.pageTranslation,s=this.#a,i=new Float32Array(s.length*8),f=0;for(let{x:l,y:c,width:h,height:u}of s){let g=l*e+a,b=(1-c)*t+n;i[f]=i[f+4]=g,i[f+1]=i[f+3]=b,i[f+2]=i[f+6]=g+h*e,i[f+5]=i[f+7]=b-u*t,f+=8}return i}#D(e){return this.#r.serialize(e,this.#F())}static startHighlighting(e,t,{target:a,x:n,y:s}){let{x:i,y:f,width:l,height:c}=a.getBoundingClientRect(),h=new AbortController,u=e.combinedSignal(h),g=(b)=>{h.abort(),this.#x(e,b)};window.addEventListener("blur",g,{signal:u}),window.addEventListener("pointerup",g,{signal:u}),window.addEventListener("pointerdown",Ha,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",Ai,{signal:u}),a.addEventListener("pointermove",this.#H.bind(this,e),{signal:u}),this._freeHighlight=new F5({x:n,y:s},[i,f,l,c],e.scale,this._defaultThickness/2,t,0.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#H(e,t){if(this._freeHighlight.add(t))e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#x(e,t){if(!this._freeHighlight.isEmpty())e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"});else e.drawLayer.remove(this._freeHighlightId);this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(e,t,a){let n=null;if(e instanceof X8){let{data:{quadPoints:j,rect:A,rotation:C,id:y,color:O,opacity:T,popupRef:M,richText:H,contentsObj:N,creationDate:x,modificationDate:z},parent:{page:{pageNumber:K}}}=e;n=e={annotationType:rt.HIGHLIGHT,color:Array.from(O),opacity:T,quadPoints:j,boxes:null,pageIndex:K-1,rect:A.slice(0),rotation:C,annotationElementId:y,id:y,deleted:!1,popupRef:M,richText:H,comment:N?.str||null,creationDate:x,modificationDate:z}}else if(e instanceof V5){let{data:{inkLists:j,rect:A,rotation:C,id:y,color:O,borderStyle:{rawWidth:T},popupRef:M,richText:H,contentsObj:N,creationDate:x,modificationDate:z},parent:{page:{pageNumber:K}}}=e;n=e={annotationType:rt.HIGHLIGHT,color:Array.from(O),thickness:T,inkLists:j,boxes:null,pageIndex:K-1,rect:A.slice(0),rotation:C,annotationElementId:y,id:y,deleted:!1,popupRef:M,richText:H,comment:N?.str||null,creationDate:x,modificationDate:z}}let{color:s,quadPoints:i,inkLists:f,outlines:l,opacity:c}=e,h=await super.deserialize(e,t,a);if(h.color=Fe.makeHexColor(...s),h.opacity=c||1,f)h.#m=e.thickness;if(h._initialData=n,e.comment)h.setCommentData(e);let[u,g]=h.pageDimensions,[b,d]=h.pageTranslation;if(i){let j=h.#a=[];for(let A=0;A<i.length;A+=8)j.push({x:(i[A]-b)/u,y:1-(i[A+1]-d)/g,width:(i[A+2]-i[A])/u,height:(i[A+1]-i[A+5])/g});h.#j(),h.#k(),h.rotate(h.rotation)}else if(f||l){h.#h=!0;let j=(f||l.points)[0],A={x:j[0]-b,y:g-(j[1]-d)},C=new F5(A,[0,0,u,g],1,h.#m/2,!0,0.001);for(let T=0,M=j.length;T<M;T+=2)A.x=j[T]-b,A.y=g-(j[T+1]-d),C.add(A);let{id:y,clipPathId:O}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);h.#w({highlightOutlines:C.getOutlines(),highlightId:y,clipPathId:O}),h.#k(),h.rotate(h.parentRotation)}return h}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=Ve._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),a=super.serialize(e);if(Object.assign(a,{color:t,opacity:this.opacity,thickness:this.#m,quadPoints:this.#M(),outlines:this.#D(a.rect)}),this.addComment(a),this.annotationElementId&&!this.#N(a))return null;return a.id=this.annotationElementId,a}#N(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((a,n)=>a!==t[n])}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;return e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class J8{#e=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(!e)return;for(let[t,a]of Object.entries(e))if(!t.startsWith("_"))this.updateProperty(t,a)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;return this.#e=Object.create(null),{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Et("Not implemented")}}class It extends Ve{#e=null;#t;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#a=null;static#n=null;static#s=null;static _INNER_MARGIN=3;constructor(e){super(e);this.#t=e.mustBeCommitted||!1,this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines)this.#f(e),this.#o()}#f({drawOutlines:e,drawId:t,drawingOptions:a}){if(this.#e=e,this._drawingOptions||=a,!this.annotationElementId)this._uiManager.a11yAlert(Ve._l10nAlert[this.editorType]);if(t>=0)this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties);else this._drawId=this.#i(e,this.parent);this.#h(e.box)}#i(e,t){let{id:a}=t.drawLayer.draw(It._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return a}static _mergeSVGProperties(e,t){let a=new Set(Object.keys(e));for(let[n,s]of Object.entries(t))if(a.has(n))Object.assign(e[n],s);else e[n]=s;return e}static getDefaultDrawingOptions(e){Et("Not implemented")}static get typesMap(){Et("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let a=this.typesMap.get(e);if(a)this._defaultDrawingOptions.updateProperty(a,t);if(this._currentParent)It.#a.updateProperty(a,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}updateParams(e,t){let a=this.constructor.typesMap.get(e);if(a)this._updateProperty(e,a,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[a,n]of this.typesMap)e.push([a,t[n]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[a,n]of this.constructor.typesMap)e.push([a,t[n]]);return e}_updateProperty(e,t,a){let n=this._drawingOptions,s=n[t],i=(f)=>{n.updateProperty(t,f);let l=this.#e.updateProperty(t,f);if(l)this.#h(l);if(this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),e===this.colorType)this.onUpdatedColor();else if(e===this.opacityType)this.onUpdatedOpacity()};this.addCommands({cmd:i.bind(this,a),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let a=this.constructor.typesMap.get(this.colorType),n=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,i=s[a],f=s[n],l=(c,h)=>{s.updateProperty(a,c),s.updateProperty(n,h),this.#e.updateProperty(a,c),this.#e.updateProperty(n,h),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,e,t),undo:l.bind(this,i,f),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:bt.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,It._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,It._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#u()),{bbox:this.#g()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,It._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(this._isDraggable=!0,this.#t){if(this.#t=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen)this.div.focus()}}remove(){this.#l(),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#o(),this.#h(this.#e.box),!this.isAttachedToDOM)this.parent.add(this)}setParent(e){let t=!1;if(this.parent&&!e)this._uiManager.removeShouldRescale(this),this.#l();else if(e)this._uiManager.addShouldRescale(this),this.#o(e),t=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(e),t)this.select()}#l(){if(this._drawId===null||!this.parent)return;this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset()}#o(e=this.parent){if(this._drawId!==null&&this.parent===e)return;if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#i(this.#e,e)}#r([e,t,a,n]){let{parentDimensions:[s,i],rotation:f}=this;switch(f){case 90:return[t,1-e,a*(i/s),n*(s/i)];case 180:return[1-e,1-t,a,n];case 270:return[1-t,e,a*(i/s),n*(s/i)];default:return[e,t,a,n]}}#u(){let{x:e,y:t,width:a,height:n,parentDimensions:[s,i],rotation:f}=this;switch(f){case 90:return[1-t,e,a*(s/i),n*(i/s)];case 180:return[1-e,1-t,a,n];case 270:return[t,1-e,a*(s/i),n*(i/s)];default:return[e,t,a,n]}}#h(e){if([this.x,this.y,this.width,this.height]=this.#r(e),this.div)this.fixAndSetPosition(),this.setDims();this._onResized()}#g(){let{x:e,y:t,width:a,height:n,rotation:s,parentRotation:i,parentDimensions:[f,l]}=this;switch((s*4+i)/90){case 1:return[1-t-n,e,n,a];case 2:return[1-e-a,1-t-n,a,n];case 3:return[t,1-e-a,n,a];case 4:return[e,t-a*(f/l),n*(l/f),a*(f/l)];case 5:return[1-t,e,a*(f/l),n*(l/f)];case 6:return[1-e-n*(l/f),1-t,n*(l/f),a*(f/l)];case 7:return[t-a*(f/l),1-e-n*(l/f),a*(f/l),n*(l/f)];case 8:return[e-a,t-n,a,n];case 9:return[1-t,e-a,n,a];case 10:return[1-e,1-t,a,n];case 11:return[t-n,1-e,n,a];case 12:return[e-n*(l/f),t,n*(l/f),a*(f/l)];case 13:return[1-t-a*(f/l),e-n*(l/f),a*(f/l),n*(l/f)];case 14:return[1-e,1-t-a*(f/l),n*(l/f),a*(f/l)];case 15:return[t,1-e,a*(f/l),n*(l/f)];default:return[e,t,a,n]}}rotate(){if(!this.parent)return;this.parent.drawLayer.updateProperties(this._drawId,It._mergeSVGProperties({bbox:this.#g()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){if(!this.parent)return;this.#h(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy)e=this.x,t=this.y;let a=super.render();a.classList.add("draw");let n=document.createElement("div");if(a.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy)this._moveAfterPaste(e,t);return a}static createDrawerInstance(e,t,a,n,s){Et("Not implemented")}static startDrawing(e,t,a,n){let{target:s,offsetX:i,offsetY:f,pointerId:l,pointerType:c}=n;if(Gt.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:h}}=e,{width:u,height:g}=s.getBoundingClientRect(),b=It.#n=new AbortController,d=e.combinedSignal(b);if(Gt.setPointer(c,l),window.addEventListener("pointerup",(j)=>{if(Gt.isSamePointerIdOrRemove(j.pointerId))this._endDraw(j)},{signal:d}),window.addEventListener("pointercancel",(j)=>{if(Gt.isSamePointerIdOrRemove(j.pointerId))this._currentParent.endDrawingSession()},{signal:d}),window.addEventListener("pointerdown",(j)=>{if(!Gt.isSamePointerType(j.pointerType))return;if(Gt.initializeAndAddPointerId(j.pointerId),It.#a.isCancellable())if(It.#a.removeLastElement(),It.#a.isEmpty())this._currentParent.endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Ai,{signal:d}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:d}),s.addEventListener("touchmove",(j)=>{if(Gt.isSameTimeStamp(j.timeStamp))Ha(j)},{signal:d}),e.toggleDrawing(),t._editorUndoBar?.hide(),It.#a){e.drawLayer.updateProperties(this._currentDrawId,It.#a.startNew(i,f,u,g,h));return}t.updateUIForDefaultProperties(this),It.#a=this.createDrawerInstance(i,f,u,g,h),It.#s=this.getDefaultDrawingOptions(),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(It.#s.toSVGProperties(),It.#a.defaultSVGProperties),!0,!1)}static _drawMove(e){if(Gt.isSameTimeStamp(e.timeStamp),!It.#a)return;let{offsetX:t,offsetY:a,pointerId:n}=e;if(!Gt.isSamePointerId(n))return;if(Gt.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,It.#a.add(t,a)),Gt.setTimeStamp(e.timeStamp),Ha(e)}static _cleanup(e){if(e)this._currentDrawId=-1,this._currentParent=null,It.#a=null,It.#s=null,Gt.clearTimeStamp();if(It.#n)It.#n.abort(),It.#n=null,Gt.clearPointerIds()}static _endDraw(e){let t=this._currentParent;if(!t)return;if(t.toggleDrawing(!0),this._cleanup(!1),e?.target===t.div)t.drawLayer.updateProperties(this._currentDrawId,It.#a.end(e.offsetX,e.offsetY));if(this.supportMultipleDrawings){let a=It.#a,n=this._currentDrawId,s=a.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,a.setLastElement(s))},undo:()=>{t.drawLayer.updateProperties(n,a.removeLastElement())},mustExec:!1,type:bt.DRAW_STEP});return}this.endDrawing(!1)}static endDrawing(e){let t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(bt.DRAW_STEP),!It.#a.isEmpty()){let{pageDimensions:[a,n],scale:s}=t,i=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:It.#a.getOutlines(a*s,n*s,s,this._INNER_MARGIN),drawingOptions:It.#s,mustBeCommitted:!e});return this._cleanup(!0),i}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,a,n,s,i){Et("Not implemented")}static async deserialize(e,t,a){let{rawDims:{pageWidth:n,pageHeight:s,pageX:i,pageY:f}}=t.viewport,l=this.deserializeDraw(i,f,n,s,this._INNER_MARGIN,e),c=await super.deserialize(e,t,a);return c.createDrawingOptions(e),c.#f({drawOutlines:l}),c.#o(),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){let[t,a]=this.pageTranslation,[n,s]=this.pageDimensions;return this.#e.serialize([t,a,n,s],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class qS{#e=new Float64Array(6);#t;#a;#n;#s;#f;#i="";#l=0;#o=new Ko;#r;#u;constructor(e,t,a,n,s,i){this.#r=a,this.#u=n,this.#n=s,this.#s=i,[e,t]=this.#h(e,t);let f=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#f=[e,t],this.#a=[{line:f,points:this.#f}],this.#e.set(f,0)}updateProperty(e,t){if(e==="stroke-width")this.#s=t}#h(e,t){return Ee._normalizePoint(e,t,this.#r,this.#u,this.#n)}isEmpty(){return!this.#a?.length}isCancellable(){return this.#f.length<=10}add(e,t){[e,t]=this.#h(e,t);let[a,n,s,i]=this.#e.subarray(2,6),f=e-s,l=t-i;if(Math.hypot(this.#r*f,this.#u*l)<=2)return null;if(this.#f.push(e,t),isNaN(a))return this.#e.set([s,i,e,t],2),this.#t.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}};if(isNaN(this.#e[0]))this.#t.splice(6,6);return this.#e.set([a,n,s,i,e,t],0),this.#t.push(...Ee.createBezierPoints(a,n,s,i,e,t)),{path:{d:this.toSVGPath()}}}end(e,t){let a=this.add(e,t);if(a)return a;if(this.#f.length===2)return{path:{d:this.toSVGPath()}};return null}startNew(e,t,a,n,s){this.#r=a,this.#u=n,this.#n=s,[e,t]=this.#h(e,t);let i=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#f=[e,t];let f=this.#a.at(-1);if(f)f.line=new Float32Array(f.line),f.points=new Float32Array(f.points);return this.#a.push({line:i,points:this.#f}),this.#e.set(i,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#a.at(-1)}setLastElement(e){if(!this.#a)return this.#o.setLastElement(e);return this.#a.push(e),this.#t=e.line,this.#f=e.points,this.#l=0,{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#a)return this.#o.removeLastElement();this.#a.pop(),this.#i="";for(let e=0,t=this.#a.length;e<t;e++){let{line:a,points:n}=this.#a[e];this.#t=a,this.#f=n,this.#l=0,this.toSVGPath()}return{path:{d:this.#i}}}toSVGPath(){let e=Ee.svgRound(this.#t[4]),t=Ee.svgRound(this.#t[5]);if(this.#f.length===2)return this.#i=`${this.#i} M ${e} ${t} Z`,this.#i;if(this.#f.length<=6){let n=this.#i.lastIndexOf("M");this.#i=`${this.#i.slice(0,n)} M ${e} ${t}`,this.#l=6}if(this.#f.length===4){let n=Ee.svgRound(this.#t[10]),s=Ee.svgRound(this.#t[11]);return this.#i=`${this.#i} L ${n} ${s}`,this.#l=12,this.#i}let a=[];if(this.#l===0)a.push(`M ${e} ${t}`),this.#l=6;for(let n=this.#l,s=this.#t.length;n<s;n+=6){let[i,f,l,c,h,u]=this.#t.slice(n,n+6).map(Ee.svgRound);a.push(`C${i} ${f} ${l} ${c} ${h} ${u}`)}return this.#i+=a.join(" "),this.#l=this.#t.length,this.#i}getOutlines(e,t,a,n){let s=this.#a.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#o.build(this.#a,e,t,a,this.#n,this.#s,n),this.#e=null,this.#t=null,this.#a=null,this.#i=null,this.#o}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Ko extends Ee{#e;#t=0;#a;#n;#s;#f;#i;#l;#o;build(e,t,a,n,s,i,f){this.#s=t,this.#f=a,this.#i=n,this.#l=s,this.#o=i,this.#a=f??0,this.#n=e,this.#h()}get thickness(){return this.#o}setLastElement(e){return this.#n.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#n.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#n){if(e.push(`M${Ee.svgRound(t[4])} ${Ee.svgRound(t[5])}`),t.length===6){e.push("Z");continue}if(t.length===12&&isNaN(t[6])){e.push(`L${Ee.svgRound(t[10])} ${Ee.svgRound(t[11])}`);continue}for(let a=6,n=t.length;a<n;a+=6){let[s,i,f,l,c,h]=t.subarray(a,a+6).map(Ee.svgRound);e.push(`C${s} ${i} ${f} ${l} ${c} ${h}`)}}return e.join("")}serialize([e,t,a,n],s){let i=[],f=[],[l,c,h,u]=this.#u(),g,b,d,j,A,C,y,O,T;switch(this.#l){case 0:T=Ee._rescale,g=e,b=t+n,d=a,j=-n,A=e+l*a,C=t+(1-c-u)*n,y=e+(l+h)*a,O=t+(1-c)*n;break;case 90:T=Ee._rescaleAndSwap,g=e,b=t,d=a,j=n,A=e+c*a,C=t+l*n,y=e+(c+u)*a,O=t+(l+h)*n;break;case 180:T=Ee._rescale,g=e+a,b=t,d=-a,j=n,A=e+(1-l-h)*a,C=t+c*n,y=e+(1-l)*a,O=t+(c+u)*n;break;case 270:T=Ee._rescaleAndSwap,g=e+a,b=t+n,d=-a,j=-n,A=e+(1-c-u)*a,C=t+(1-l-h)*n,y=e+(1-c)*a,O=t+(1-l)*n;break}for(let{line:M,points:H}of this.#n)i.push(T(M,g,b,d,j,s?Array(M.length):null)),f.push(T(H,g,b,d,j,s?Array(H.length):null));return{lines:i,points:f,rect:[A,C,y,O]}}static deserialize(e,t,a,n,s,{paths:{lines:i,points:f},rotation:l,thickness:c}){let h=[],u,g,b,d,j;switch(l){case 0:j=Ee._rescale,u=-e/a,g=t/n+1,b=1/a,d=-1/n;break;case 90:j=Ee._rescaleAndSwap,u=-t/n,g=-e/a,b=1/n,d=1/a;break;case 180:j=Ee._rescale,u=e/a+1,g=-t/n,b=-1/a,d=1/n;break;case 270:j=Ee._rescaleAndSwap,u=t/n+1,g=e/a+1,b=-1/n,d=-1/a;break}if(!i){i=[];for(let C of f){let y=C.length;if(y===2){i.push(new Float32Array([NaN,NaN,NaN,NaN,C[0],C[1]]));continue}if(y===4){i.push(new Float32Array([NaN,NaN,NaN,NaN,C[0],C[1],NaN,NaN,NaN,NaN,C[2],C[3]]));continue}let O=new Float32Array(3*(y-2));i.push(O);let[T,M,H,N]=C.subarray(0,4);O.set([NaN,NaN,NaN,NaN,T,M],0);for(let x=4;x<y;x+=2){let z=C[x],K=C[x+1];O.set(Ee.createBezierPoints(T,M,H,N,z,K),(x-2)*3),[T,M,H,N]=[H,N,z,K]}}}for(let C=0,y=i.length;C<y;C++)h.push({line:j(i[C].map((O)=>O??NaN),u,g,b,d),points:j(f[C].map((O)=>O??NaN),u,g,b,d)});let A=new this.prototype.constructor;return A.build(h,a,n,1,l,c,s),A}#r(e=this.#o){let t=this.#a+e/2*this.#i;return this.#l%180===0?[t/this.#s,t/this.#f]:[t/this.#f,t/this.#s]}#u(){let[e,t,a,n]=this.#e,[s,i]=this.#r(0);return[e+s,t+i,a-2*s,n-2*i]}#h(){let e=this.#e=Er.slice();for(let{line:n}of this.#n){if(n.length<=12){for(let f=4,l=n.length;f<l;f+=6)Fe.pointBoundingBox(n[f],n[f+1],e);continue}let s=n[4],i=n[5];for(let f=6,l=n.length;f<l;f+=6){let[c,h,u,g,b,d]=n.subarray(f,f+6);Fe.bezierBoundingBox(s,i,c,h,u,g,b,d,e),s=b,i=d}}let[t,a]=this.#r();e[0]=da(e[0]-t,0,1),e[1]=da(e[1]-a,0,1),e[2]=da(e[2]+t,0,1),e[3]=da(e[3]+a,0,1),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){if(e==="stroke-width")return this.#g(t);return null}#g(e){let[t,a]=this.#r();this.#o=e;let[n,s]=this.#r(),[i,f]=[n-t,s-a],l=this.#e;return l[0]-=i,l[1]-=f,l[2]+=2*i,l[3]+=2*f,l}updateParentDimensions([e,t],a){let[n,s]=this.#r();this.#s=e,this.#f=t,this.#i=a;let[i,f]=this.#r(),l=i-n,c=f-s,h=this.#e;return h[0]-=l,h[1]-=c,h[2]+=2*l,h[3]+=2*c,h}updateRotation(e){return this.#t=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(Ee.svgRound).join(" ")}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Ee.svgRound(e)} ${Ee.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,a=0,n=0,s=0,i=0,f=0,l=0;switch(this.#t){case 90:n=t/e,s=-e/t,f=e;break;case 180:a=-1,i=-1,f=e,l=t;break;case 270:n=-t/e,s=e/t,l=t;break;default:return""}return`matrix(${a} ${n} ${s} ${i} ${Ee.svgRound(f)} ${Ee.svgRound(l)})`}getPathResizingSVGProperties([e,t,a,n]){let[s,i]=this.#r(),[f,l,c,h]=this.#e;if(Math.abs(c-s)<=Ee.PRECISION||Math.abs(h-i)<=Ee.PRECISION){let j=e+a/2-(f+c/2),A=t+n/2-(l+h/2);return{path:{"transform-origin":`${Ee.svgRound(e)} ${Ee.svgRound(t)}`,transform:`${this.rotationTransform} translate(${j} ${A})`}}}let u=(a-2*s)/(c-2*s),g=(n-2*i)/(h-2*i),b=c/a,d=h/n;return{path:{"transform-origin":`${Ee.svgRound(f)} ${Ee.svgRound(l)}`,transform:`${this.rotationTransform} scale(${b} ${d}) translate(${Ee.svgRound(s)} ${Ee.svgRound(i)}) scale(${u} ${g}) translate(${Ee.svgRound(-s)} ${Ee.svgRound(-i)})`}}}getPathResizedSVGProperties([e,t,a,n]){let[s,i]=this.#r(),f=this.#e,[l,c,h,u]=f;if(f[0]=e,f[1]=t,f[2]=a,f[3]=n,Math.abs(h-s)<=Ee.PRECISION||Math.abs(u-i)<=Ee.PRECISION){let A=e+a/2-(l+h/2),C=t+n/2-(c+u/2);for(let{line:y,points:O}of this.#n)Ee._translate(y,A,C,y),Ee._translate(O,A,C,O);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Ee.svgRound(e)} ${Ee.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let g=(a-2*s)/(h-2*s),b=(n-2*i)/(u-2*i),d=-g*(l+s)+e+s,j=-b*(c+i)+t+i;if(g!==1||b!==1||d!==0||j!==0)for(let{line:A,points:C}of this.#n)Ee._rescale(A,d,j,g,b,A),Ee._rescale(C,d,j,g,b,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Ee.svgRound(e)} ${Ee.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],a){let[n,s]=a,i=this.#e,f=e-i[0],l=t-i[1];if(this.#s===n&&this.#f===s)for(let{line:c,points:h}of this.#n)Ee._translate(c,f,l,c),Ee._translate(h,f,l,h);else{let c=this.#s/n,h=this.#f/s;this.#s=n,this.#f=s;for(let{line:u,points:g}of this.#n)Ee._rescale(u,f,l,c,h,u),Ee._rescale(g,f,l,c,h,g);i[2]*=c,i[3]*=h}return i[0]=e,i[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Ee.svgRound(e)} ${Ee.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Ee.svgRound(e[0])} ${Ee.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Y5 extends J8{constructor(e){super();this._viewParameters=e,super.updateProperties({fill:"none",stroke:Ve._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){if(e==="stroke-width")t??=this["stroke-width"],t*=this._viewParameters.realScale;super.updateSVGProperty(e,t)}clone(){let e=new Y5(this._viewParameters);return e.updateAll(this),e}}class Q8 extends It{static _type="ink";static _editorType=rt.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,t){Ve.initialize(e,t),this._defaultDrawingOptions=new Y5(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return ft(this,"typesMap",new Map([[bt.INK_THICKNESS,"stroke-width"],[bt.INK_COLOR,"stroke"],[bt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,a,n,s){return new qS(e,t,a,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,a,n,s,i){return Ko.deserialize(e,t,a,n,s,i)}static async deserialize(e,t,a){let n=null;if(e instanceof V5){let{data:{inkLists:i,rect:f,rotation:l,id:c,color:h,opacity:u,borderStyle:{rawWidth:g},popupRef:b,richText:d,contentsObj:j,creationDate:A,modificationDate:C},parent:{page:{pageNumber:y}}}=e;n=e={annotationType:rt.INK,color:Array.from(h),thickness:g,opacity:u,paths:{points:i},boxes:null,pageIndex:y-1,rect:f.slice(0),rotation:l,annotationElementId:c,id:c,deleted:!1,popupRef:b,richText:d,comment:j?.str||null,creationDate:A,modificationDate:C}}let s=await super.deserialize(e,t,a);if(s._initialData=n,e.comment)s.setCommentData(e);return s}get toolbarButtons(){return this._colorPicker||=new p2(this),[["colorPicker",this._colorPicker]]}get colorType(){return bt.INK_COLOR}get colorAndOpacityType(){return bt.INK_COLOR_AND_OPACITY}get opacityType(){return bt.INK_OPACITY}updateParams(e,t){if(e===bt.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(t.color,t.opacity);return}super.updateParams(e,t)}static updateDefaultParams(e,t){if(e===bt.INK_COLOR_AND_OPACITY){super.updateDefaultParams(bt.INK_COLOR,t.color),super.updateDefaultParams(bt.INK_OPACITY,t.opacity);return}super.updateDefaultParams(e,t)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:a}=this;t.updateSVGProperty("stroke-width"),a.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;if(!e)return;super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}createDrawingOptions({color:e,thickness:t,opacity:a}){this._drawingOptions=Q8.getDefaultDrawingOptions({stroke:Fe.makeHexColor(...e),"stroke-width":t,"stroke-opacity":a})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:a}=this.serializeDraw(e),{_drawingOptions:{stroke:n,"stroke-opacity":s,"stroke-width":i}}=this,f=Object.assign(super.serialize(e),{color:Ve._colorManager.convert(n),opacity:s,thickness:i,paths:{lines:t,points:a}});if(this.addComment(f),e)return f.isCopy=!0,f;if(this.annotationElementId&&!this.#e(f))return null;return f.id=this.annotationElementId,f}#e(e){let{color:t,thickness:a,opacity:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((i,f)=>i!==t[f])||e.thickness!==a||e.opacity!==n||e.pageIndex!==s}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let{points:t,rect:a}=this.serializeDraw(!1);return e.updateEdited({rect:a,thickness:this._drawingOptions["stroke-width"],points:t,popup:this.comment}),null}}class O5 extends Ko{toSVGPath(){let e=super.toSVGPath();if(!e.endsWith("Z"))e+="Z";return e}}var g5=8,f2=3;class Nr{static#e={maxDim:512,sigmaSFactor:0.02,sigmaR:25,kernelSize:16};static#t(e,t,a,n){if(a-=e,n-=t,a===0)return n>0?0:4;if(a===1)return n+6;return 2-n}static#a=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#n(e,t,a,n,s,i,f){let l=this.#t(a,n,s,i);for(let c=0;c<8;c++){let h=(-c+l-f+16)%8,u=this.#a[2*h],g=this.#a[2*h+1];if(e[(a+u)*t+(n+g)]!==0)return h}return-1}static#s(e,t,a,n,s,i,f){let l=this.#t(a,n,s,i);for(let c=0;c<8;c++){let h=(c+l+f+16)%8,u=this.#a[2*h],g=this.#a[2*h+1];if(e[(a+u)*t+(n+g)]!==0)return h}return-1}static#f(e,t,a,n){let s=e.length,i=new Int32Array(s);for(let h=0;h<s;h++)i[h]=e[h]<=n?1:0;for(let h=1;h<a-1;h++)i[h*t]=i[h*t+t-1]=0;for(let h=0;h<t;h++)i[h]=i[t*a-1-h]=0;let f=1,l,c=[];for(let h=1;h<a-1;h++){l=1;for(let u=1;u<t-1;u++){let g=h*t+u,b=i[g];if(b===0)continue;let d=h,j=u;if(b===1&&i[g-1]===0)f+=1,j-=1;else if(b>=1&&i[g+1]===0){if(f+=1,j+=1,b>1)l=b}else{if(b!==1)l=Math.abs(b);continue}let A=[u,h],C=j===u+1,y={isHole:C,points:A,id:f,parent:0};c.push(y);let O;for(let $ of c)if($.id===l){O=$;break}if(!O)y.parent=C?l:0;else if(O.isHole)y.parent=C?O.parent:l;else y.parent=C?l:O.parent;let T=this.#n(i,t,h,u,d,j,0);if(T===-1){if(i[g]=-f,i[g]!==1)l=Math.abs(i[g]);continue}let M=this.#a[2*T],H=this.#a[2*T+1],N=h+M,x=u+H;d=N,j=x;let z=h,K=u;while(!0){let $=this.#s(i,t,z,K,d,j,1);M=this.#a[2*$],H=this.#a[2*$+1];let Q=z+M,P=K+H;A.push(P,Q);let te=z*t+K;if(i[te+1]===0)i[te]=-f;else if(i[te]===1)i[te]=f;if(Q===h&&P===u&&z===N&&K===x){if(i[g]!==1)l=Math.abs(i[g]);break}else d=z,j=K,z=Q,K=P}}}return c}static#i(e,t,a,n){if(a-t<=4){for(let N=t;N<a-2;N+=2)n.push(e[N],e[N+1]);return}let s=e[t],i=e[t+1],f=e[a-4]-s,l=e[a-3]-i,c=Math.hypot(f,l),h=f/c,u=l/c,g=h*i-u*s,b=l/f,d=1/c,j=Math.atan(b),A=Math.cos(j),C=Math.sin(j),y=d*(Math.abs(A)+Math.abs(C)),O=d*(1-y+y**2),T=Math.max(Math.atan(Math.abs(C+A)*O),Math.atan(Math.abs(C-A)*O)),M=0,H=t;for(let N=t+2;N<a-2;N+=2){let x=Math.abs(g-h*e[N+1]+u*e[N]);if(x>M)H=N,M=x}if(M>(c*T)**2)this.#i(e,t,H+2,n),this.#i(e,H,a,n);else n.push(s,i)}static#l(e){let t=[],a=e.length;return this.#i(e,0,a,t),t.push(e[a-2],e[a-1]),t.length<=4?null:t}static#o(e,t,a,n,s,i){let f=new Float32Array(i**2),l=-2*n**2,c=i>>1;for(let j=0;j<i;j++){let A=(j-c)**2;for(let C=0;C<i;C++)f[j*i+C]=Math.exp((A+(C-c)**2)/l)}let h=new Float32Array(256),u=-2*s**2;for(let j=0;j<256;j++)h[j]=Math.exp(j**2/u);let g=e.length,b=new Uint8Array(g),d=new Uint32Array(256);for(let j=0;j<a;j++)for(let A=0;A<t;A++){let C=j*t+A,y=e[C],O=0,T=0;for(let H=0;H<i;H++){let N=j+H-c;if(N<0||N>=a)continue;for(let x=0;x<i;x++){let z=A+x-c;if(z<0||z>=t)continue;let K=e[N*t+z],$=f[H*i+x]*h[Math.abs(K-y)];O+=K*$,T+=$}}let M=b[C]=Math.round(O/T);d[M]++}return[b,d]}static#r(e){let t=new Uint32Array(256);for(let a of e)t[a]++;return t}static#u(e){let t=e.length,a=new Uint8ClampedArray(t>>2),n=-1/0,s=1/0;for(let f=0,l=a.length;f<l;f++){let c=a[f]=e[f<<2];n=Math.max(n,c),s=Math.min(s,c)}let i=255/(n-s);for(let f=0,l=a.length;f<l;f++)a[f]=(a[f]-s)*i;return a}static#h(e){let t,a=-1/0,n=-1/0,s=e.findIndex((l)=>l!==0),i=s,f=s;for(t=s;t<256;t++){let l=e[t];if(l>a){if(t-i>n)n=t-i,f=t-1;a=l,i=t}}for(t=f-1;t>=0;t--)if(e[t]>e[t+1])break;return t}static#g(e){let t=e,{width:a,height:n}=e,{maxDim:s}=this.#e,i=a,f=n;if(a>s||n>s){let g=a,b=n,d=Math.log2(Math.max(a,n)/s),j=Math.floor(d);d=d===j?j-1:j;for(let C=0;C<d;C++){i=Math.ceil(g/2),f=Math.ceil(b/2);let y=new OffscreenCanvas(i,f);if(y.getContext("2d").drawImage(e,0,0,g,b,0,0,i,f),g=i,b=f,e!==t)e.close();e=y.transferToImageBitmap()}let A=Math.min(s/i,s/f);i=Math.round(i*A),f=Math.round(f*A)}let c=new OffscreenCanvas(i,f).getContext("2d",{willReadFrequently:!0});c.fillStyle="white",c.fillRect(0,0,i,f),c.filter="grayscale(1)",c.drawImage(e,0,0,e.width,e.height,0,0,i,f);let h=c.getImageData(0,0,i,f).data;return[this.#u(h),i,f]}static extractContoursFromText(e,{fontFamily:t,fontStyle:a,fontWeight:n},s,i,f,l){let c=new OffscreenCanvas(1,1),h=c.getContext("2d",{alpha:!1}),u=200,g=h.font=`${a} ${n} ${u}px ${t}`,{actualBoundingBoxLeft:b,actualBoundingBoxRight:d,actualBoundingBoxAscent:j,actualBoundingBoxDescent:A,fontBoundingBoxAscent:C,fontBoundingBoxDescent:y,width:O}=h.measureText(e),T=1.5,M=Math.ceil(Math.max(Math.abs(b)+Math.abs(d)||0,O)*T),H=Math.ceil(Math.max(Math.abs(j)+Math.abs(A)||u,Math.abs(C)+Math.abs(y)||u)*T);c=new OffscreenCanvas(M,H),h=c.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=g,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,M,H),h.fillStyle="black",h.fillText(e,M*(T-1)/2,H*(3-T)/2);let N=this.#u(h.getImageData(0,0,M,H).data),x=this.#r(N),z=this.#h(x),K=this.#f(N,M,H,z);return this.processDrawnLines({lines:{curves:K,width:M,height:H},pageWidth:s,pageHeight:i,rotation:f,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(e,t,a,n,s){let[i,f,l]=this.#g(e),[c,h]=this.#o(i,f,l,Math.hypot(f,l)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#h(h),g=this.#f(c,f,l,u);return this.processDrawnLines({lines:{curves:g,width:f,height:l},pageWidth:t,pageHeight:a,rotation:n,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:a,rotation:n,innerMargin:s,mustSmooth:i,areContours:f}){if(n%180!==0)[t,a]=[a,t];let{curves:l,width:c,height:h}=e,u=e.thickness??0,g=[],b=Math.min(t/c,a/h),d=b/t,j=b/a,A=[];for(let{points:y}of l){let O=i?this.#l(y):y;if(!O)continue;A.push(O);let T=O.length,M=new Float32Array(T),H=new Float32Array(3*(T===2?2:T-2));if(g.push({line:H,points:M}),T===2){M[0]=O[0]*d,M[1]=O[1]*j,H.set([NaN,NaN,NaN,NaN,M[0],M[1]],0);continue}let[N,x,z,K]=O;N*=d,x*=j,z*=d,K*=j,M.set([N,x,z,K],0),H.set([NaN,NaN,NaN,NaN,N,x],0);for(let $=4;$<T;$+=2){let Q=M[$]=O[$]*d,P=M[$+1]=O[$+1]*j;H.set(Ee.createBezierPoints(N,x,z,K,Q,P),($-2)*3),[N,x,z,K]=[z,K,Q,P]}}if(g.length===0)return null;let C=f?new O5:new Ko;return C.build(g,t,a,1,n,f?0:u,s),{outline:C,newCurves:A,areContours:f,thickness:u,width:c,height:h}}static async compressSignature({outlines:e,areContours:t,thickness:a,width:n,height:s}){let i=1/0,f=-1/0,l=0;for(let y of e){l+=y.length;for(let O=2,T=y.length;O<T;O++){let M=y[O]-y[O-2];i=Math.min(i,M),f=Math.max(f,M)}}let c;if(i>=-128&&f<=127)c=Int8Array;else if(i>=-32768&&f<=32767)c=Int16Array;else c=Int32Array;let h=e.length,u=g5+f2*h,g=new Uint32Array(u),b=0;g[b++]=u*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*c.BYTES_PER_ELEMENT,g[b++]=0,g[b++]=n,g[b++]=s,g[b++]=t?0:1,g[b++]=Math.max(0,Math.floor(a??0)),g[b++]=h,g[b++]=c.BYTES_PER_ELEMENT;for(let y of e)g[b++]=y.length-2,g[b++]=y[0],g[b++]=y[1];let d=new CompressionStream("deflate-raw"),j=d.writable.getWriter();await j.ready,j.write(g);let A=c.prototype.constructor;for(let y of e){let O=new A(y.length-2);for(let T=2,M=y.length;T<M;T++)O[T-2]=y[T]-y[T-2];j.write(O)}return j.close(),(await new Response(d.readable).bytes()).toBase64()}static async decompressSignature(e){try{let t=Uint8Array.fromBase64(e),{readable:a,writable:n}=new DecompressionStream("deflate-raw"),s=n.getWriter();await s.ready,s.write(t).then(async()=>{await s.ready,await s.close()}).catch(()=>{});let i=null,f=0;for await(let O of a)i||=new Uint8Array(new Uint32Array(O.buffer,0,4)[0]),i.set(O,f),f+=O.length;let l=new Uint32Array(i.buffer,0,i.length>>2),c=l[1];if(c!==0)throw Error(`Invalid version: ${c}`);let h=l[2],u=l[3],g=l[4]===0,b=l[5],d=l[6],j=l[7],A=[],C=(g5+f2*d)*Uint32Array.BYTES_PER_ELEMENT,y;switch(j){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(i.buffer,C);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(i.buffer,C);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(i.buffer,C);break}f=0;for(let O=0;O<d;O++){let T=l[f2*O+g5],M=new Float32Array(T+2);A.push(M);for(let H=0;H<f2-1;H++)M[H]=l[f2*O+g5+H+1];for(let H=0;H<T;H++)M[H+2]=M[H]+y[f++]}return{areContours:g,thickness:b,outlines:A,width:h,height:u}}catch(t){return ot(`decompressSignature: ${t}`),null}}}class Z8 extends J8{constructor(){super();super.updateProperties({fill:Ve._defaultLineColor,"stroke-width":0})}clone(){let e=new Z8;return e.updateAll(this),e}}class $8 extends Y5{constructor(e){super(e);super.updateProperties({stroke:Ve._defaultLineColor,"stroke-width":1})}clone(){let e=new $8(this._viewParameters);return e.updateAll(this),e}}class v0 extends It{#e=!1;#t=null;#a=null;#n=null;static _type="signature";static _editorType=rt.SIGNATURE;static _defaultDrawingOptions=null;constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});this._willKeepAspectRatio=!0,this.#a=e.signatureData||null,this.#t=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,t){Ve.initialize(e,t),this._defaultDrawingOptions=new Z8,this._defaultDrawnSignatureOptions=new $8(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!1}static get typesMap(){return ft(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#t}}static computeTelemetryFinalData(e){let t=e.get("hasDescription");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){if(this._drawId===null)return;super.onScaleChanging()}render(){if(this.div)return this.div;let e,t,{_isCopy:a}=this;if(a)this._isCopy=!1,e=this.x,t=this.y;if(super.render(),this._drawId===null)if(this.#a){let{lines:n,mustSmooth:s,areContours:i,description:f,uuid:l,heightInPage:c}=this.#a,{rawDims:{pageWidth:h,pageHeight:u},rotation:g}=this.parent.viewport,b=Nr.processDrawnLines({lines:n,pageWidth:h,pageHeight:u,rotation:g,innerMargin:v0._INNER_MARGIN,mustSmooth:s,areContours:i});this.addSignature(b,c,f,l)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#t||""}));if(a)this._isCopy=!0,this._moveAfterPaste(e,t);return this.div}setUuid(e){this.#n=e,this.addEditToolbar()}getUuid(){return this.#n}get description(){return this.#t}set description(e){if(this.#t=e,!this.div)return;this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then((t)=>{t?.updateEditSignatureButton(e)})}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:a,width:n,height:s}=this.#a,i=Math.max(n,s),f=Nr.processDrawnLines({lines:{curves:e.map((l)=>({points:l})),thickness:a,width:n,height:s},pageWidth:i,pageHeight:i,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t});return{areContours:t,outline:f.outline}}get toolbarButtons(){if(this._uiManager.signatureManager)return[["editSignature",this._uiManager.signatureManager]];return super.toolbarButtons}addSignature(e,t,a,n){let{x:s,y:i}=this,{outline:f}=this.#a=e;this.#e=f instanceof O5,this.description=a;let l;if(this.#e)l=v0.getDefaultDrawingOptions();else l=v0._defaultDrawnSignatureOptions.clone(),l.updateProperties({"stroke-width":f.thickness});this._addOutlines({drawOutlines:f,drawingOptions:l});let[,c]=this.pageDimensions,h=t/c;if(h=h>=1?0.5:h,this.width*=h/this.height,this.width>=1)h*=0.9/this.width,this.width=0.9;this.height=h,this.setDims(),this.x=s,this.y=i,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!a}}),this.div.hidden=!1}getFromImage(e){let{rawDims:{pageWidth:t,pageHeight:a},rotation:n}=this.parent.viewport;return Nr.process(e,t,a,n,v0._INNER_MARGIN)}getFromText(e,t){let{rawDims:{pageWidth:a,pageHeight:n},rotation:s}=this.parent.viewport;return Nr.extractContoursFromText(e,t,a,n,s,v0._INNER_MARGIN)}getDrawnSignature(e){let{rawDims:{pageWidth:t,pageHeight:a},rotation:n}=this.parent.viewport;return Nr.processDrawnLines({lines:e,pageWidth:t,pageHeight:a,rotation:n,innerMargin:v0._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=v0.getDefaultDrawingOptions();else this._drawingOptions=v0._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":t})}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:a}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(e),{isSignature:!0,areContours:this.#e,color:[0,0,0],thickness:this.#e?0:n});if(this.addComment(s),e)s.paths={lines:t,points:a},s.uuid=this.#n,s.isCopy=!0;else s.lines=t;if(this.#t)s.accessibilityData={type:"Figure",alt:this.#t};return s}static deserializeDraw(e,t,a,n,s,i){if(i.areContours)return O5.deserialize(e,t,a,n,s,i);return Ko.deserialize(e,t,a,n,s,i)}static async deserialize(e,t,a){let n=await super.deserialize(e,t,a);return n.#e=e.areContours,n.description=e.accessibilityData?.alt||"",n.#n=e.uuid,n}}class vS extends Ve{#e=null;#t=null;#a=null;#n=null;#s=null;#f="";#i=null;#l=!1;#o=null;#r=!1;#u=!1;static _type="stamp";static _editorType=rt.STAMP;constructor(e){super({...e,name:"stampEditor"});this.#n=e.bitmapUrl,this.#s=e.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,t){Ve.initialize(e,t)}static isHandlingMimeForPasting(e){return d8.includes(e)}static paste(e,t){t.pasteEditor({mode:rt.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){if(this._uiManager.useNewAltTextFlow)this.div.hidden=!1;super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#h(e,t=!1){if(!e){this.remove();return}if(this.#e=e.bitmap,!t)this.#t=e.id,this.#r=e.isSvg;if(e.file)this.#f=e.file.name;this.#p()}#g(){if(this.#a=null,this._uiManager.enableWaiting(!1),!this.#i)return;if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;let{mlManager:a}=this._uiManager;if(!a)throw Error("No ML.");if(!await a.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:n,width:s,height:i}=e||this.copyCanvas(null,null,!0).imageData,f=await a.guess({name:"altText",request:{data:n,width:s,height:i,channels:n.length/(s*i)}});if(!f)throw Error("No response from the AI service.");if(f.error)throw Error("Error from the AI service.");if(f.cancel)return null;if(!f.output)throw Error("No valid response from the AI service.");let l=f.output;if(await this.setGuessedAltText(l),t&&!this.hasAltTextData())this.altTextData={alt:l,decorative:!1};return l}#b(){if(this.#t){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#t).then((a)=>this.#h(a,!0)).finally(()=>this.#g());return}if(this.#n){let a=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#a=this._uiManager.imageManager.getFromUrl(a).then((n)=>this.#h(n)).finally(()=>this.#g());return}if(this.#s){let a=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#a=this._uiManager.imageManager.getFromFile(a).then((n)=>this.#h(n)).finally(()=>this.#g());return}let e=document.createElement("input");e.type="file",e.accept=d8.join(",");let t=this._uiManager._signal;this.#a=new Promise((a)=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#h(n)}a()},{signal:t}),e.addEventListener("cancel",()=>{this.remove(),a()},{signal:t})}).finally(()=>this.#g()),e.click()}remove(){if(this.#t){if(this.#e=null,this._uiManager.imageManager.deleteId(this.#t),this.#i?.remove(),this.#i=null,this.#o)clearTimeout(this.#o),this.#o=null}super.remove()}rebuild(){if(!this.parent){if(this.#t)this.#b();return}if(super.rebuild(),this.div===null)return;if(this.#t&&this.#i===null)this.#b();if(!this.isAttachedToDOM)this.parent.add(this)}onceAdded(e){if(this._isDraggable=!0,e)this.div.focus()}isEmpty(){return!(this.#a||this.#e||this.#n||this.#s||this.#t||this.#l)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy)e=this.x,t=this.y;if(super.render(),this.div.hidden=!0,this.createAltText(),!this.#l)if(this.#e)this.#p();else this.#b();if(this._isCopy)this._moveAfterPaste(e,t);return this._uiManager.addShouldRescale(this),this.div}setCanvas(e,t){let{id:a,bitmap:n}=this._uiManager.imageManager.getFromCanvas(e,t);if(t.remove(),a&&this._uiManager.imageManager.isValidId(a)){if(this.#t=a,n)this.#e=n;this.#l=!1,this.#p()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;if(this.#o!==null)clearTimeout(this.#o);let e=200;this.#o=setTimeout(()=>{this.#o=null,this.#m()},e)}#p(){let{div:e}=this,{width:t,height:a}=this.#e,[n,s]=this.pageDimensions,i=0.75;if(this.width)t=this.width*n,a=this.height*s;else if(t>0.75*n||a>0.75*s){let l=Math.min(0.75*n/t,0.75*s/a);t*=l,a*=l}this._uiManager.enableWaiting(!1);let f=this.#i=document.createElement("canvas");if(f.setAttribute("role","img"),this.addContainer(f),this.width=t/n,this.height=a/s,this.setDims(),this._initialOptions?.isCentered)this.center();else this.fixAndSetPosition();if(this._initialOptions=null,!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)e.hidden=!1;if(this.#m(),!this.#u)this.parent.addUndoableEditor(this),this.#u=!0;if(this._reportTelemetry({action:"inserted_image"}),this.#f)this.div.setAttribute("aria-description",this.#f);if(!this.annotationElementId)this._uiManager.a11yAlert(Ve._l10nAlert.stamp)}copyCanvas(e,t,a=!1){if(!e)e=224;let{width:n,height:s}=this.#e,i=new y0,f=this.#e,l=n,c=s,h=null;if(t){if(n>t||s>t){let H=Math.min(t/n,t/s);l=Math.floor(n*H),c=Math.floor(s*H)}h=document.createElement("canvas");let g=h.width=Math.ceil(l*i.sx),b=h.height=Math.ceil(c*i.sy);if(!this.#r)f=this.#c(g,b);let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let j="white",A="#cfcfd8";if(this._uiManager.hcmFilter!=="none")A="black";else if(ZA.isDarkMode)j="#8f8f9d",A="#42414d";let C=15,y=C*i.sx,O=C*i.sy,T=new OffscreenCanvas(y*2,O*2),M=T.getContext("2d");M.fillStyle=j,M.fillRect(0,0,y*2,O*2),M.fillStyle=A,M.fillRect(0,0,y,O),M.fillRect(y,O,y,O),d.fillStyle=d.createPattern(T,"repeat"),d.fillRect(0,0,g,b),d.drawImage(f,0,0,f.width,f.height,0,0,g,b)}let u=null;if(a){let g,b;if(i.symmetric&&f.width<e&&f.height<e)g=f.width,b=f.height;else if(f=this.#e,n>e||s>e){let A=Math.min(e/n,e/s);if(g=Math.floor(n*A),b=Math.floor(s*A),!this.#r)f=this.#c(g,b)}let j=new OffscreenCanvas(g,b).getContext("2d",{willReadFrequently:!0});j.drawImage(f,0,0,f.width,f.height,0,0,g,b),u={width:g,height:b,data:j.getImageData(0,0,g,b).data}}return{canvas:h,width:l,height:c,imageData:u}}#c(e,t){let{width:a,height:n}=this.#e,s=a,i=n,f=this.#e;while(s>2*e||i>2*t){let l=s,c=i;if(s>2*e)s=Math.ceil(s/2);if(i>2*t)i=Math.ceil(i/2);let h=new OffscreenCanvas(s,i);h.getContext("2d").drawImage(f,0,0,l,c,0,0,s,i),f=h.transferToImageBitmap()}return f}#m(){let[e,t]=this.parentDimensions,{width:a,height:n}=this,s=new y0,i=Math.ceil(a*e*s.sx),f=Math.ceil(n*t*s.sy),l=this.#i;if(!l||l.width===i&&l.height===f)return;l.width=i,l.height=f;let c=this.#r?this.#e:this.#c(i,f),h=l.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(c,0,0,c.width,c.height,0,0,i,f)}#d(e){if(e){if(this.#r){let n=this._uiManager.imageManager.getSvgUrl(this.#t);if(n)return n}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#e,t.getContext("2d").drawImage(this.#e,0,0),t.toDataURL()}if(this.#r){let[t,a]=this.pageDimensions,n=Math.round(this.width*t*Ur.PDF_TO_CSS_UNITS),s=Math.round(this.height*a*Ur.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,s);return i.getContext("2d").drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,s),i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,a){let n=null,s=!1;if(e instanceof K8){let{data:{rect:j,rotation:A,id:C,structParent:y,popupRef:O,richText:T,contentsObj:M,creationDate:H,modificationDate:N},container:x,parent:{page:{pageNumber:z}},canvas:K}=e,$,Q;if(K)delete e.canvas,{id:$,bitmap:Q}=a.imageManager.getFromCanvas(x.id,K),K.remove();else s=!0,e._hasNoCanvas=!0;let P=(await t._structTree.getAriaAttributes(`pdfjs_internal_id_${C}`))?.get("aria-label")||"";n=e={annotationType:rt.STAMP,bitmapId:$,bitmap:Q,pageIndex:z-1,rect:j.slice(0),rotation:A,annotationElementId:C,id:C,deleted:!1,accessibilityData:{decorative:!1,altText:P},isSvg:!1,structParent:y,popupRef:O,richText:T,comment:M?.str||null,creationDate:H,modificationDate:N}}let i=await super.deserialize(e,t,a),{rect:f,bitmap:l,bitmapUrl:c,bitmapId:h,isSvg:u,accessibilityData:g}=e;if(s)a.addMissingCanvas(e.id,i),i.#l=!0;else if(h&&a.imageManager.isValidId(h)){if(i.#t=h,l)i.#e=l}else i.#n=c;i.#r=u;let[b,d]=i.pageDimensions;if(i.width=(f[2]-f[0])/b,i.height=(f[3]-f[1])/d,g)i.altTextData=g;if(i._initialData=n,e.comment)i.setCommentData(e);return i.#u=!!n,i}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let a=Object.assign(super.serialize(e),{bitmapId:this.#t,isSvg:this.#r});if(this.addComment(a),e)return a.bitmapUrl=this.#d(!0),a.accessibilityData=this.serializeAltText(!0),a.isCopy=!0,a;let{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s)a.accessibilityData={type:"Figure",alt:s};if(this.annotationElementId){let f=this.#j(a);if(f.isSame)return null;if(f.isSameAltText)delete a.accessibilityData;else a.accessibilityData.structParent=this._initialData.structParent??-1;return a.id=this.annotationElementId,delete a.bitmapId,a}if(t===null)return a;t.stamps||=new Map;let i=this.#r?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(!t.stamps.has(this.#t))t.stamps.set(this.#t,{area:i,serialized:a}),a.bitmap=this.#d(!1);else if(this.#r){let f=t.stamps.get(this.#t);if(i>f.area)f.area=i,f.serialized.bitmap.close(),f.serialized.bitmap=this.#d(!1)}return a}#j(e){let{pageIndex:t,accessibilityData:{altText:a}}=this._initialData,n=e.pageIndex===t,s=(e.accessibilityData?.alt||"")===a;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;return e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class uf{#e;#t=!1;#a=null;#n=null;#s=null;#f=new Map;#i=!1;#l=!1;#o=!1;#r=null;#u=null;#h=null;#g=null;#b=null;#p=-1;#c;static _initialized=!1;static#m=new Map([An,Q8,vS,Va,v0].map((e)=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:a,structTreeLayer:n,accessibilityManager:s,annotationLayer:i,drawLayer:f,textLayer:l,viewport:c,l10n:h}){let u=[...uf.#m.values()];if(!uf._initialized){uf._initialized=!0;for(let g of u)g.initialize(h,e)}e.registerEditorTypes(u),this.#c=e,this.pageIndex=t,this.div=a,this.#e=s,this.#a=i,this.viewport=c,this.#h=l,this.drawLayer=f,this._structTree=n,this.#c.addLayer(this)}get isEmpty(){return this.#f.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===rt.NONE}updateToolbar(e){this.#c.updateToolbar(e)}updateMode(e=this.#c.getMode()){switch(this.#q(),e){case rt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case rt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case rt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;if(t.toggle("nonEditing",!1),e===rt.POPUP)t.toggle("commentEditing",!0);else{t.toggle("commentEditing",!1);for(let a of uf.#m.values())t.toggle(`${a._type}Editing`,e===a._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#h?.div}setEditingState(e){this.#c.setEditingState(e)}addCommands(e){this.#c.addCommands(e)}cleanUndoStack(e){this.#c.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#a?.togglePointerEvents(e)}get#d(){return this.#f.size!==0?this.#f.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#o=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#b?.abort(),this.#b=null;let e=new Set;for(let a of this.#d)if(a.enableEditing(),a.show(!0),a.annotationElementId)this.#c.removeChangedExistingAnnotation(a),e.add(a.annotationElementId);let t=this.#a;if(t)for(let a of t.getEditableAnnotations()){if(a.hide(),this.#c.isDeletedAnnotationElement(a.data.id))continue;if(e.has(a.data.id))continue;let n=await this.deserialize(a);if(!n)continue;this.addOrRebuild(n),n.enableEditing()}this.#o=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#l=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#h&&!this.#b){this.#b=new AbortController;let n=this.#c.combinedSignal(this.#b);this.#h.div.addEventListener("pointerdown",(s)=>{let{clientX:f,clientY:l,timeStamp:c}=s,h=this.#p;if(c-h>500){this.#p=c;return}this.#p=-1;let{classList:u}=this.div;u.toggle("getElements",!0);let g=document.elementsFromPoint(f,l);if(u.toggle("getElements",!1),!this.div.contains(g[0]))return;let b,d=new RegExp("^pdfjs_internal_editor_[0-9]+$");for(let A of g)if(d.test(A.id)){b=A.id;break}if(!b)return;let j=this.#f.get(b);if(j?.annotationElementId===null)Ha(s),j.dblclick(s)},{signal:n,capture:!0})}let e=this.#a,t=[];if(e){let n=new Map,s=new Map;for(let i of this.#d){if(i.disableEditing(),!i.annotationElementId){t.push(i);continue}if(i.serialize()!==null){n.set(i.annotationElementId,i);continue}else s.set(i.annotationElementId,i);this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}for(let i of e.getEditableAnnotations()){let{id:f}=i.data;if(this.#c.isDeletedAnnotationElement(f)){i.updateEdited({deleted:!0});continue}let l=s.get(f);if(l){l.resetAnnotationElement(i),l.show(!1),i.show();continue}if(l=n.get(f),l){if(this.#c.addChangedExistingAnnotation(l),l.renderAnnotationElement(i))l.show(!1)}i.show()}}if(this.#q(),this.isEmpty)this.div.hidden=!0;let{classList:a}=this.div;for(let n of uf.#m.values())a.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e?.updateFakeAnnotations(t),this.#l=!1}getEditableAnnotation(e){return this.#a?.getEditableAnnotation(e)||null}setActiveEditor(e){if(this.#c.getActive()===e)return;this.#c.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#g){this.#g=new AbortController;let e=this.#c.combinedSignal(this.#g);this.#h.div.addEventListener("pointerdown",this.#j.bind(this),{signal:e}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){if(this.div.tabIndex=0,this.#h?.div&&this.#g)this.#g.abort(),this.#g=null,this.#h.div.classList.remove("highlighting")}#j(e){this.#c.unselectAll();let{target:t}=e;if(t===this.#h.div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent")||t.classList.contains("textLayerImages")||t.classList.contains("textLayerImagePlaceholder"))&&this.#h.div.contains(t)){let{isMac:a}=ea.platform;if(e.button!==0||e.ctrlKey&&a)return;this.#c.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),Va.startHighlighting(this,this.#c.direction==="ltr",{target:this.#h.div,x:e.x,y:e.y}),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#c._signal}),e.preventDefault()}}enableClick(){if(this.#n)return;this.#n=new AbortController;let e=this.#c.combinedSignal(this.#n);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){this.#n?.abort(),this.#n=null}attach(e){this.#f.set(e.id,e);let{annotationElementId:t}=e;if(t&&this.#c.isDeletedAnnotationElement(t))this.#c.removeDeletedAnnotationElement(e)}detach(e){if(this.#f.delete(e.id),this.#e?.removePointerInTextLayer(e.contentDiv),!this.#l&&e.annotationElementId)this.#c.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#c.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){if(e.parent===this)return;if(e.parent&&e.annotationElementId)this.#c.addDeletedAnnotationElement(e),Ve.deleteAnnotationElement(e),e.annotationElementId=null;if(this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM)e.div.remove(),this.div.append(e.div)}add(e){if(e.parent===this&&e.isAttachedToDOM)return;if(this.changeParent(e),this.#c.addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#o),this.#c.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;if(e.div.contains(t)&&!this.#s)e._focusEventsAllowed=!1,this.#s=setTimeout(()=>{if(this.#s=null,!e.div.contains(document.activeElement))e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),t.focus();else e._focusEventsAllowed=!0},0);e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt())e.parent||=this,e.rebuild(),e.show();else this.add(e)}addUndoableEditor(e){let t=()=>e._uiManager.rebuild(e),a=()=>{e.remove()};this.addCommands({cmd:t,undo:a,mustExec:!1})}getEditorByUID(e){for(let t of this.#f.values())if(t.uid===e)return t;return null}get#w(){return uf.#m.get(this.#c.getMode())}combinedSignal(e){return this.#c.combinedSignal(e)}#A(e){let t=this.#w;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#w?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e),await this.#c.updateMode(e.mode);let{offsetX:a,offsetY:n}=this.#y(),s=this.#c.getId(),i=this.#A({parent:this,id:s,x:a,y:n,uiManager:this.#c,isCentered:!0,...t});if(i)this.add(i)}async deserialize(e){return await uf.#m.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#c)||null}createAndAddNewEditor(e,t,a={}){let n=this.#c.getId(),s=this.#A({parent:this,id:n,x:e.offsetX,y:e.offsetY,uiManager:this.#c,isCentered:t,...a});if(s)this.add(s);return s}get boundingClientRect(){return this.div.getBoundingClientRect()}#y(){let{x:e,y:t,width:a,height:n}=this.boundingClientRect,s=Math.max(0,e),i=Math.max(0,t),f=Math.min(window.innerWidth,e+a),l=Math.min(window.innerHeight,t+n),c=(s+f)/2-e,h=(i+l)/2-t,[u,g]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:u,offsetY:g}}addNewEditor(e={}){this.createAndAddNewEditor(this.#y(),!0,e)}setSelected(e){this.#c.setSelected(e)}toggleSelected(e){this.#c.toggleSelected(e)}unselect(e){this.#c.unselect(e)}pointerup(e){let{isMac:t}=ea.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!this.#i)return;if(this.#i=!1,this.#w?.isDrawer&&this.#w.supportMultipleDrawings)return;if(!this.#t){this.#t=!0;return}let a=this.#c.getMode();if(a===rt.STAMP||a===rt.POPUP||a===rt.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){if(this.#c.getMode()===rt.HIGHLIGHT)this.enableTextSelection();if(this.#i){this.#i=!1;return}let{isMac:t}=ea.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(this.#i=!0,this.#w?.isDrawer){this.startDrawingSession(e);return}let a=this.#c.getActive();this.#t=!a||a.isEmpty()}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),this.#r){this.#w.startDrawing(this,this.#c,!1,e);return}this.#c.setCurrentDrawingSession(this),this.#r=new AbortController;let t=this.#c.combinedSignal(this.#r);this.div.addEventListener("blur",({relatedTarget:a})=>{if(a&&!this.div.contains(a))this.#u=null,this.commitOrRemove()},{signal:t}),this.#w.startDrawing(this,this.#c,!1,e)}pause(e){if(e){let{activeElement:t}=document;if(this.div.contains(t))this.#u=t;return}if(this.#u)setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(e=!1){if(!this.#r)return null;return this.#c.setCurrentDrawingSession(null),this.#r.abort(),this.#r=null,this.#u=null,this.#w.endDrawing(e)}findNewParent(e,t,a){let n=this.#c.findParent(t,a);if(n===null||n===this)return!1;return n.changeParent(e),!0}commitOrRemove(){if(this.#r)return this.endDrawingSession(),!0;return!1}onScaleChanging(){if(!this.#r)return;this.#w.onScaleChangingWhenDrawing(this)}destroy(){if(this.commitOrRemove(),this.#c.getActive()?.parent===this)this.#c.commitOrRemove(),this.#c.setActiveEditor(null);if(this.#s)clearTimeout(this.#s),this.#s=null;for(let e of this.#f.values())this.#e?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#f.clear(),this.#c.removeLayer(this)}#q(){for(let e of this.#f.values())if(e.isEmpty())e.remove()}async render({viewport:e}){this.viewport=e,Ir(this.div,e);for(let t of this.#c.getEditors(this.pageIndex))this.add(t),t.rebuild();await this.#c.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:e}){this.#c.commitOrRemove(),this.#q();let t=this.viewport.rotation,a=e.rotation;if(this.viewport=e,Ir(this.div,{rotation:a}),t!==a)for(let n of this.#f.values())n.rotate(a)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#c.viewParameters.realScale}}function fz(e,t){if(e===t)return 0;return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function p5(e){if(!e)return null;if(e.nodeType===Node.ELEMENT_NODE)return e.closest(".textLayer");return e.parentElement?.closest(".textLayer")||null}function lz(e,t,a,n){if(e===a)return t<=n;let s=e.compareDocumentPosition(a);if(s&Node.DOCUMENT_POSITION_FOLLOWING)return!0;if(s&Node.DOCUMENT_POSITION_PRECEDING)return!1;return null}function LA(e,t,a){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains("textLayer")||t!==e.childNodes.length)return{container:e,offset:t};let n=e.lastChild;if(n?.nodeType===Node.ELEMENT_NODE&&n.classList.contains("endOfContent"))n=n.previousSibling;if(!n||!a.contains(n))return null;if(n.nodeType===Node.TEXT_NODE)return{container:n,offset:n.textContent.length};return{container:n,offset:n.childNodes.length}}class it{#e=null;#t=new Map;#a=null;#n=null;#s=null;#f=null;#i=new Map;static#l=0;static#o=0;static#r=null;static#u=new Set;static#h=!1;static#g=new Set;static#b=new WeakMap;constructor({filterFactory:e=null,pageColors:t=null,pageIndex:a,textLayer:n=null}){if(this.pageIndex=a,this.#n=e,this.#s=t,n){let s=it.#b.get(n);if(s?.selectionDiv)s.selectionDiv.remove(),it.#u.delete(s.selectionDiv);if(it.#b.set(n,{drawLayer:this}),it.#g.add(n),this.#a=n,this.#f=new MutationObserver((i)=>{if(!this.#e||!this.#a?.isConnected||!it.#c())return;for(let{addedNodes:f}of i)for(let l of f)if(l.nodeType===Node.ELEMENT_NODE&&l.classList.contains("endOfContent")){it.#d();return}}),this.#f.observe(n,{childList:!0}),it.#r===null){it.#r=new AbortController;let{signal:i}=it.#r;document.addEventListener("selectionchange",it.#d.bind(it),{signal:i}),document.addEventListener("pointerdown",()=>{it.#h=!0},{signal:i}),document.addEventListener("pointerup",()=>{it.#h=!1},{signal:i}),window.addEventListener("blur",()=>{it.#h=!1},{signal:i})}}}setParent(e){if(!this.#e){if(this.#e=e,this.#a?.isConnected&&it.#c())it.#d();return}if(this.#e!==e){if(this.#t.size>0)for(let t of this.#t.values())t.remove(),e.append(t);this.#e=e}}static#p(e){let t=this.#b.get(e);if(!t?.selectionDiv)return;t.selectionDiv.remove(),this.#u.delete(t.selectionDiv),t.selectionDiv=null,t.path=null}static#c(){let e=document.getSelection();return!!e&&!e.isCollapsed}static#m(){return[...this.#g].filter((e)=>e.isConnected).sort(fz)}static#d(){let e=document.getSelection();if(!e||e.isCollapsed){for(let i of this.#u)i.remove();this.#u.clear();return}let t=new WeakMap,a=this.#m(),n=[];for(let i=0,f=e.rangeCount;i<f;i++){let l=e.getRangeAt(i);if(l.collapsed)continue;let{startContainer:c,startOffset:h,endContainer:u,endOffset:g}=l,b=p5(c),d=p5(u),j=b===null,A=d===null;if(this.#h&&j!==A)return;if(e.rangeCount===1){let{anchorNode:O,anchorOffset:T,focusNode:M,focusOffset:H}=e,N=p5(O),x=p5(M),z=lz(O,T,M,H);if(N&&x&&z!==null)if(z)c=O,h=T,b=N,u=M,g=H,d=x;else c=M,h=H,b=x,u=O,g=T,d=N}let C=a.filter((O)=>l.intersectsNode(O));if(C.length===0)continue;let y=!1;if(!b)b=C[0],c=b,h=0,y=!0;if(!d)d=C.at(-1),u=d,g=d.childNodes.length,y=!0;if(u.nodeType===Node.ELEMENT_NODE){if(u.classList.contains("endOfContent")){let O=u.previousSibling;if(!O)continue;u=O,g=O.nodeType===Node.TEXT_NODE?O.textContent.length:O.childNodes.length}else if(u.classList.contains("textLayer")&&u.childNodes.length===g){let O=LA(u,g,d);if(!O)continue;u=O.container,g=O.offset}}if(c.nodeType===Node.ELEMENT_NODE){let O=LA(c,h,b);if(!O)continue;c=O.container,h=O.offset}if(b===d&&!y&&C.includes(b)){n.push([l,b]);continue}for(let O of C){let T=O.firstChild;if(!T)continue;let M=document.createRange();if(O===b)M.setStart(c,h);else M.setStartBefore(T);if(O===d)M.setEnd(u,g);else{let H=O.lastChild;if(!H)continue;if(H.nodeType===Node.ELEMENT_NODE&&H.classList.contains("endOfContent")){let N=H.previousSibling;if(!N)continue;M.setEndAfter(N)}else M.setEndAfter(H)}if(!M.collapsed)n.push([M,O])}}let s=new Set(n.map((i)=>i[1]));for(let i of this.#g)if(!s.has(i))this.#p(i);for(let[i,f]of n){let l=it.#b.get(f);if(!l)continue;let c=t.get(f);if(!c){let d=f.getBoundingClientRect();c=(j,A,C,y)=>({x:(j-d.x)/d.width,y:(A-d.y)/d.height,width:C/d.width,height:y/d.height}),t.set(f,c)}let h=[];for(let{x:d,y:j,width:A,height:C}of i.getClientRects()){if(A===0||C===0)continue;if({x:d,y:j,width:A,height:C}=c(d,j,A,C),A===1&&C===1)continue;h.push(`M${d} ${j} h${A} v${C} h-${A} Z`)}if(h.length===0)continue;let{drawLayer:u,selectionDiv:g,path:b}=l;if(!g){let d=`clip_selection_${it.#o++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${d})`;let j=u.#n?.createSelectionStyle(u.#s);if(j)for(let[y,O]of Object.entries(j))g.style.setProperty(y,O);let A=it._svgFactory.create(1,1,!0);A.setAttribute("aria-hidden","true"),A.setAttribute("width","100%"),A.setAttribute("height","100%");let C=it._svgFactory.createElement("clipPath");C.setAttribute("id",d),C.setAttribute("clipPathUnits","objectBoundingBox"),b=it._svgFactory.createElement("path"),C.append(b),A.append(C),g.append(A),l.path=b,l.selectionDiv=g}if(!g.parentNode&&u.#e)u.#e.append(g),this.#u.add(g);b.setAttribute("d",h.join(" "))}}static get _svgFactory(){return ft(this,"_svgFactory",new b2)}static#j(e,[t,a,n,s]){let{style:i}=e;i.top=`${100*a}%`,i.left=`${100*t}%`,i.width=`${100*n}%`,i.height=`${100*s}%`}#w(){let e=it._svgFactory.create(1,1,!0);return this.#e.append(e),e.setAttribute("aria-hidden","true"),e}#A(e,t){let a=it._svgFactory.createElement("clipPath");e.append(a);let n=`clip_${t}`;a.setAttribute("id",n),a.setAttribute("clipPathUnits","objectBoundingBox");let s=it._svgFactory.createElement("use");return a.append(s),s.setAttribute("href",`#${t}`),s.classList.add("clip"),n}#y(e,t){for(let[a,n]of Object.entries(t))if(n===null)e.removeAttribute(a);else e.setAttribute(a,n)}draw(e,t=!1,a=!1){let n=it.#l++,s=this.#w(),i=it._svgFactory.createElement("defs");s.append(i);let f=it._svgFactory.createElement("path");i.append(f);let l=`path_${n}`;if(f.setAttribute("id",l),f.setAttribute("vector-effect","non-scaling-stroke"),t)this.#i.set(n,f);let c=a?this.#A(i,l):null,h=it._svgFactory.createElement("use");return s.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(s,e),this.#t.set(n,s),{id:n,clipPathId:`url(#${c})`}}drawOutline(e,t){let a=it.#l++,n=this.#w(),s=it._svgFactory.createElement("defs");n.append(s);let i=it._svgFactory.createElement("path");s.append(i);let f=`path_${a}`;i.setAttribute("id",f),i.setAttribute("vector-effect","non-scaling-stroke");let l;if(t){let u=it._svgFactory.createElement("mask");s.append(u),l=`mask_${a}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");let g=it._svgFactory.createElement("rect");u.append(g),g.setAttribute("width","1"),g.setAttribute("height","1"),g.setAttribute("fill","white");let b=it._svgFactory.createElement("use");u.append(b),b.setAttribute("href",`#${f}`),b.setAttribute("stroke","none"),b.setAttribute("fill","black"),b.setAttribute("fill-rule","nonzero"),b.classList.add("mask")}let c=it._svgFactory.createElement("use");if(n.append(c),c.setAttribute("href",`#${f}`),l)c.setAttribute("mask",`url(#${l})`);let h=c.cloneNode();return n.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(n,e),this.#t.set(a,n),a}finalizeDraw(e,t){this.#i.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;let{root:a,bbox:n,rootClass:s,path:i}=t,f=typeof e==="number"?this.#t.get(e):e;if(!f)return;if(a)this.#y(f,a);if(n)it.#j(f,n);if(s){let{classList:l}=f;for(let[c,h]of Object.entries(s))l.toggle(c,h)}if(i){let c=f.firstElementChild.firstElementChild;this.#y(c,i)}}updateParent(e,t){if(t===this)return;let a=this.#t.get(e);if(!a)return;t.#e.append(a),this.#t.delete(e),t.#t.set(e,a)}remove(e){if(this.#i.delete(e),this.#e===null)return;this.#t.get(e).remove(),this.#t.delete(e)}destroy(){this.#e=null;for(let e of this.#t.values())e.remove();if(this.#t.clear(),this.#i.clear(),this.#f?.disconnect(),this.#f=null,this.#a){if(it.#b.get(this.#a)?.drawLayer===this){if(it.#p(this.#a),it.#b.delete(this.#a),it.#g.delete(this.#a),it.#g.size===0)it.#r?.abort(),it.#r=null,it.#h=!1}this.#a=null}}}function b5(e){return`${(e*100).toFixed(2)}%`}class B5{#e=[];#t=new Map;#a=null;#n=0;#s=0;#f=0;static#i=null;constructor(e,t,a,n){this.#n=e,this.#e=t,this.#s=a.rawDims.pageWidth,this.#f=a.rawDims.pageHeight,this.#a=n}render(){let e=document.createElement("div");e.className="textLayerImages";for(let t=0;t<this.#e.length;t+=6){let a=this.#l(this.#e.subarray(t,t+6));if(a)e.append(a)}return e.addEventListener("contextmenu",(t)=>{if(!(t.target instanceof HTMLCanvasElement))return;let a=t.target,n=this.#t.get(a);if(!n)return;let s=B5.#i?.deref();if(s===a)return;if(s)s.width=0,s.height=0;B5.#i=new WeakRef(a);let{inverseTransform:i,x1:f,y1:l,width:c,height:h}=n,u=this.#a(),g=Math.ceil(f*u.width),b=Math.ceil(l*u.height),d=Math.floor((f+c/this.#s)*u.width),j=Math.floor((l+h/this.#f)*u.height);a.width=d-g,a.height=j-b;let A=a.getContext("2d");A.setTransform(...i),A.translate(-g,-b),A.drawImage(u,0,0)}),e}#l([e,t,a,n,s,i]){let f=Math.hypot((s-e)*this.#s,(i-t)*this.#f),l=Math.hypot((a-e)*this.#s,(n-t)*this.#f);if(f<this.#n||l<this.#n)return null;let c=[(s-e)*this.#s/f,(i-t)*this.#f/f,(a-e)*this.#s/l,(n-t)*this.#f/l,0,0],h=Fe.inverseTransform(c),u=document.createElement("canvas");return u.className="textLayerImagePlaceholder",u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:"absolute",left:b5(e),top:b5(t),width:b5(f/this.#s),height:b5(l/this.#f),transformOrigin:"0% 0%",transform:`matrix(${c.join(",")})`}),this.#t.set(u,{inverseTransform:h,width:f,height:l,x1:e,y1:t}),u}}globalThis._pdfjsTestingUtils={HighlightOutliner:_5};globalThis.pdfjsLib={AbortException:pf,AnnotationEditorLayer:uf,AnnotationEditorParamsType:bt,AnnotationEditorType:rt,AnnotationEditorUIManager:Al,AnnotationLayer:V8,AnnotationMode:kl,AnnotationType:za,applyOpacity:FE,build:nz,ColorPicker:ki,createValidAbsoluteUrl:VA,CSSConstants:$A,DOMSVGFactory:b2,DrawLayer:it,FeatureTest:ea,fetchData:_8,findContrastColor:OE,getDocument:N8,getFilenameFromUrl:SE,getPdfFilenameFromUrl:CE,getRGB:q2,getRGBA:j2,getUuid:QA,GlobalWorkerOptions:gf,ImageKind:w5,InvalidPDFException:k5,isDataScheme:R5,isPdfFile:F8,isValidExplicitDest:xE,makeArr:w2,makeMap:S8,makeObj:b8,MathClamp:da,noContextMenu:Ai,normalizeUnicode:AE,OPS:k0,OutputScale:y0,PasswordException:v5,PasswordResponses:wE,PDFDataRangeTransport:z8,PDFDateString:A5,PDFWorker:Nn,PermissionFlag:bE,PixelsPerInch:Ur,RenderingCancelledException:x5,renderRichText:WA,ResponseException:h2,setLayerDimensions:Ir,shadow:ft,SignatureExtractor:Nr,stopEvent:Ha,SupportedImageMimeTypes:d8,TextLayer:fs,TextLayerImages:B5,TouchManager:N5,updateUrlHash:YA,Util:Fe,VerbosityLevel:T5,version:az,XfaLayer:C8};var Xt=Mt(en(),1);function yS({currentPage:e,totalPages:t,onPageChange:a,zoom:n,onZoomIn:s,onZoomOut:i,onFit:f,onDownload:l,canDownload:c,allowDownload:h=!0}){return ie("div",{className:"relative px-2 py-2 sm:px-4 sm:py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-between gap-1.5 sm:gap-2 transition-colors duration-200 shrink-0",children:[ie("div",{className:"flex items-center gap-1 sm:gap-1.5 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5 shrink-0",children:[R("button",{onClick:()=>a(Math.max(1,e-1)),disabled:e<=1,className:"p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40",title:He.previous_page(),children:R(kS,{size:16})}),ie("span",{className:"px-1 sm:px-2 text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none whitespace-nowrap",children:[R("span",{className:"hidden sm:inline",children:He.page_of_pages({current:e,total:t||1})}),ie("span",{className:"inline sm:hidden",children:[e,"/",t||1]})]}),R("button",{onClick:()=>a(Math.min(t,e+1)),disabled:e>=t,className:"p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40",title:He.next_page(),children:R(AS,{size:16})})]}),ie("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[ie("div",{className:"flex items-center gap-0.5 sm:gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5",children:[R("button",{onClick:i,className:"p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:He.zoom_out(),children:R(Wf,{size:16})}),ie("span",{className:"w-10 sm:w-12 text-center text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none",children:[Math.round(n*100),"%"]}),R("button",{onClick:s,className:"p-1 sm:p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:He.zoom_in(),children:R(So,{size:16})})]}),R("button",{onClick:f,className:"text-xs font-medium px-2 py-1 sm:px-3 sm:py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent",children:He.fit()}),h&&ie("button",{onClick:l,disabled:!c,className:"flex items-center gap-1 text-xs font-medium px-2 py-1 sm:px-3 sm:py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50",title:He.download_original_file(),children:[R(Bi,{size:14}),R("span",{className:"hidden sm:inline",children:He.download()})]})]})]})}var Lo="./pdf.worker.min-szxdj13d.mjs";var cz=32000000,SS=16;if(typeof window<"u"&&gf)try{let e=typeof Lo==="string"?Lo.startsWith("/")?Lo:"/"+Lo.replace(/^\.\//,""):Lo;if(typeof e==="string")gf.workerSrc=e}catch{}var hz=Xt.default.forwardRef(({file:e,annotations:t,shareId:a,children:n,onPlay:s,onPause:i,onTimeUpdate:f,startTime:l,allowDownload:c},h)=>{let{isDrawing:u,currentTool:g,currentColor:b,addAnnotation:d,annotations:j}=bs(),[A,C]=Xt.useState(null),[y,O]=Xt.useState(()=>l&&!isNaN(l)?Math.max(1,Math.round(l)):1),[T,M]=Xt.useState(1),[H,N]=Xt.useState(null),[x,z]=Xt.useState({width:800,height:1000}),[K,$]=Xt.useState(2),Q=Xt.useRef(null),[P,te]=Xt.useState(!0),[ee,L]=Xt.useState(null);Xt.useImperativeHandle(h,()=>({play:()=>{s?.()},pause:()=>{i?.()},seekTo:(xe)=>{if(xe&&!isNaN(xe)){let ze=Math.max(1,Math.min(T,Math.round(xe)));O(ze)}}}),[T,s,i]),Xt.useEffect(()=>{f?.(y)},[y,f]),Xt.useEffect(()=>{let xe=(ze)=>{let Qe=document.activeElement;if(Qe&&(Qe.tagName==="INPUT"||Qe.tagName==="TEXTAREA"||Qe instanceof HTMLElement&&Qe.isContentEditable))return;if(ze.key==="ArrowRight"||ze.key==="ArrowDown"||ze.key==="PageDown")ze.preventDefault(),O((nt)=>{let Ot=Math.min(T,nt+1);if(Ot!==nt)s?.();return Ot});else if(ze.key==="ArrowLeft"||ze.key==="ArrowUp"||ze.key==="PageUp")ze.preventDefault(),O((nt)=>{let Ot=Math.max(1,nt-1);if(Ot!==nt)s?.();return Ot});else if(ze.key==="Home")ze.preventDefault(),O(1),s?.();else if(ze.key==="End")ze.preventDefault(),O(T),s?.()};return window.addEventListener("keydown",xe),()=>{window.removeEventListener("keydown",xe)}},[T,s]);let[J,pe]=Xt.useState({width:0,height:0}),[ne,fe]=Xt.useState(1),[Ae,he]=Xt.useState({x:0,y:0}),[re,be]=Xt.useState(!1);Xt.useEffect(()=>{be(!1)},[e.id]);let Ue=Xt.useRef(null);Xt.useEffect(()=>{let xe=Ue.current;if(!xe)return;let ze=new ResizeObserver((Qe)=>{let nt=Qe[0];if(nt)pe({width:nt.contentRect.width,height:nt.contentRect.height})});return ze.observe(xe),()=>ze.disconnect()},[]);let at=e.media?.pdfTranscode?.url;Xt.useEffect(()=>{if(!at){L("No PDF URL available"),te(!1);return}let xe=!0;te(!0),L(null);let ze=N8({url:at});return ze.promise.then((Qe)=>{if(!xe)return;C(Qe),M(Qe.numPages),O((nt)=>l&&!isNaN(l)?Math.max(1,Math.min(Qe.numPages,Math.round(l))):nt),te(!1)}).catch((Qe)=>{if(!xe)return;console.error("Failed to load PDF:",Qe),L("Failed to load PDF document"),te(!1)}),()=>{xe=!1,ze.destroy().catch(()=>{})}},[at,l]),Xt.useEffect(()=>{if(!A)return;let xe=!0,ze=null;return A.getPage(y).then((Qe)=>{if(!xe)return;let nt=Qe.getViewport({scale:1}),Ot=Qe.getViewport({scale:K}),Ze=document.createElement("canvas");Ze.width=Ot.width,Ze.height=Ot.height;let Yt=Ze.getContext("2d");if(!Yt)return;if(ze=Qe.render({canvasContext:Yt,viewport:Ot,canvas:Ze}),!xe){ze.cancel();return}ze.promise.then(()=>{if(!xe)return;N(Ze),z({width:nt.width,height:nt.height})}).catch((wt)=>{if(!xe||wt&&typeof wt==="object"&&"name"in wt&&wt.name==="RenderingCancelledException")return;console.error("Failed to render page:",wt)})}).catch((Qe)=>{if(!xe)return;console.error("Failed to get page:",Qe)}),()=>{if(xe=!1,ze)ze.cancel()}},[A,y,K]),Xt.useEffect(()=>{let xe=window.setTimeout(()=>{let ze=typeof window<"u"?window.devicePixelRatio||1:1,Qe=x.width*x.height,nt=Qe>0?Math.sqrt(cz/Qe):SS,Ot=Math.min(Math.max(0.5,ne*ze),nt,SS);$(Ot)},150);return()=>window.clearTimeout(xe)},[ne,x]),Xt.useEffect(()=>{let xe=Q.current;if(!A||!xe)return;let ze=!0,Qe=null;return xe.innerHTML="",A.getPage(y).then((nt)=>{if(!ze)return;Qe=new fs({textContentSource:nt.streamTextContent(),container:xe,viewport:nt.getViewport({scale:1})}),Qe.render().catch(()=>{})}).catch((nt)=>{if(!ze)return;console.error("Failed to build text layer:",nt)}),()=>{ze=!1,Qe?.cancel()}},[A,y]),Xt.useEffect(()=>{let xe=Q.current;if(!xe)return;xe.style.transform=`translate(${Ae.x}px, ${Ae.y}px) scale(${ne})`},[Ae,ne]);let{width:Ye,height:Ie}=J,mt=x.width,vt=x.height,ga=ql(Ye,Ie,mt,vt);Xt.useEffect(()=>{if(Ye<=0||Ie<=0||mt<=0||vt<=0)return;if(re)return;fe(ga),he(cf(Ye,Ie,mt,vt,ga))},[Ye,Ie,ga,mt,vt,re]);let Dt=(xe)=>{be(!0);let ze=hf(ne,Ae,xe,Ye/2,Ie/2);fe(ze.zoom),he(ze.pan)},ta=()=>{be(!1),fe(ga),he(cf(Ye,Ie,mt,vt,ga))};No({containerRef:Ue,zoom:ne,pan:Ae,baseScale:ga,onZoomChange:(xe)=>{be(!0),fe(xe.zoom),he(xe.pan)},onPanChange:he});let rn=async()=>{let xe=e.media?.original?.key;if(!xe||!e.id)return;try{let ze=a?await Ht.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:e.id},json:{key:xe}}):await Ht.api.files["download-url"].$post({json:{key:xe,assetId:e.id}});if(!ze.ok)return;let{url:Qe}=await ze.json(),nt=document.createElement("a");nt.href=Qe,nt.download=e.name||"document.pdf",document.body.appendChild(nt),nt.click(),document.body.removeChild(nt)}catch{}},jt=[...t||[],...j];return ie("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[ie("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[n,ie("div",{ref:Ue,className:"flex-1 relative overflow-hidden touch-none",children:[P?R("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 z-20",children:R("div",{className:"w-8 h-8 border-4 border-white/30 border-t-white rounded-full animate-spin"})}):ee?R("div",{className:"absolute inset-0 flex items-center justify-center text-gray-500 text-sm",children:ee}):R(d0,{width:Ye,height:Ie,mediaDimensions:x,canvasElement:H,annotations:jt,scale:ne,offset:Ae,className:"absolute inset-0 z-0",isDrawing:u,currentTool:g,currentColor:b,onAddAnnotation:d}),R("div",{ref:Q,className:"pdf-text-layer",onMouseDown:(xe)=>{if(xe.target instanceof HTMLElement&&xe.target.tagName!=="SPAN")window.getSelection()?.removeAllRanges()},style:{transform:`translate(${Ae.x}px, ${Ae.y}px) scale(${ne})`,transformOrigin:"0 0",pointerEvents:u?"none":"auto"}})]})]}),R(yS,{currentPage:y,totalPages:T,onPageChange:(xe)=>{O(xe),s?.()},zoom:ne,onZoomIn:()=>Dt(1.2),onZoomOut:()=>Dt(0.8),onFit:ta,onDownload:rn,canDownload:!!e.media?.original?.key,allowDownload:c})]})}),CS=hz;var _S={id:"pdf",name:"PDF",match:(e)=>e.proxyType==="pdf",viewer:CS,commentsConfig:{hasTimestamp:!0,hasAnnotations:!0,formatTimestamp:(e)=>`P${Math.round(e)}`}};var J5=Mt(en(),1);var uz=J5.default.forwardRef(({file:e,shareId:t,children:a,allowDownload:n=!0},s)=>{return J5.useImperativeHandle(s,()=>({play:()=>{},pause:()=>{},seekTo:()=>{}})),ie("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[ie("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[a,R("div",{className:"flex-1 flex items-center justify-center",children:R("p",{className:"text-muted-foreground",children:"Preview unavailable"})})]}),R("div",{className:"relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-end gap-2 transition-colors duration-200",children:n&&ie("button",{onClick:async()=>{let f=e.media?.original?.key;if(!f||!e.id)return;try{let l=t?await Ht.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:t,fileId:e.id},json:{key:f}}):await Ht.api.files["download-url"].$post({json:{key:f,assetId:e.id}});if(!l.ok)return;let{url:c}=await l.json(),h=document.createElement("a");h.href=c,h.download="",document.body.appendChild(h),h.click(),document.body.removeChild(h)}catch{}},disabled:!e.media?.original?.key,className:"flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50 animate-in fade-in zoom-in-95 duration-200",title:"Download original file",children:[R(Bi,{size:14}),"Download"]})})]})}),FS=uz;var W8={id:"default",name:"Default",match:()=>!0,viewer:FS,commentsConfig:{hasTimestamp:!1,hasAnnotations:!1}};var mz=[_S,bA,vA];function OS(e){if(!e)return W8;return mz.find((a)=>a.match(e))||W8}function bZ({teamId:e,projectId:t,file:a,onSaveField:n,members:s,onCommentSelect:i,hideAnnotationControl:f=!1,readOnly:l=!1,publicFields:c,isPublic:h=!1,shareId:u,currentTime:g,onTyping:b,selectedCommentId:d}){let{canEdit:j}=TS(t),{fields:A,setFields:C}=xS(),y=Yu(),{ref:O,inView:T}=HS(),[M,H]=Ni.useState(null),[N,x]=Ni.useState(!1),[z,K]=Ni.useState(null),{data:$}=Ju({queryKey:["fields",t],queryFn:async()=>{let re=await Ht.api.projects[":projectId"].fields.$get({param:{projectId:t}});if(!re.ok)throw Error("Failed to fetch fields");return await re.json()},enabled:!!t&&!c}),Q=OS(a);Ni.useEffect(()=>{if(c)C(c,t);else if($)C($,t)},[$,c,t,C]);let{data:P,fetchNextPage:te,hasNextPage:ee}=BS({queryKey:h?["shares",u,"files",a?.id,"comments"]:["files",a?.id,"comments"],queryFn:async({pageParam:re})=>{if(h){let be=localStorage.getItem(`share_pwd_${u}`)||"",Ue=await Ht.api.shares[":shareId"].files[":fileId"].comments.$get({param:{shareId:u,fileId:a.id},query:{after:re}},{headers:{"x-share-password":be}});if(!Ue.ok)throw Error("Failed to fetch comments");return await Ue.json()}else{let be=await Ht.api.files[":fileId"].comments.$get({param:{fileId:a.id},query:{after:re}});if(!be.ok)throw Error("Failed to fetch comments");return await be.json()}},enabled:!!a?.id&&(!h||!!u),initialPageParam:"",refetchInterval:2000,getNextPageParam:(re)=>re.pageInfo?.cursor||void 0}),{mutate:L}=ur({mutationFn:async({text:re,attachmentIds:be,annotations:Ue,replyToId:at,guestUserId:Ye,second:Ie})=>{if(h){let mt=localStorage.getItem(`share_pwd_${u}`)||"",vt=await Ht.api.shares[":shareId"].files[":fileId"].comments.$post({param:{shareId:u,fileId:a.id},json:{message:re,attachmentIds:be,replyToId:at??void 0,annotations:Ue,second:Ie??void 0}},{headers:{"x-share-password":mt,...Ye?{"x-guest-user-id":Ye}:{}}});if(!vt.ok)throw Error("Failed to create comment");return await vt.json()}else{let mt=await Ht.api.files[":fileId"].comments.$post({param:{fileId:a.id},json:{message:re,attachmentIds:be,replyToId:at??void 0,annotations:Ue,second:Ie??void 0}});if(!mt.ok)throw Error("Failed to create comment");return await mt.json()}},onSuccess:()=>{y.invalidateQueries({queryKey:h?["shares",u,"files",a?.id,"comments"]:["files",a?.id,"comments"]})}});Ni.default.useEffect(()=>{if(T&&ee)te()},[T,te,ee]);let J=Ni.useMemo(()=>{return(a?.fieldValues||[]).reduce((re,be)=>{return re[be.fieldId]=be,re},{})},[a?.fieldValues]),pe=Ni.useMemo(()=>{return[...A].sort((re,be)=>{let Ue=re.config?.name?.toLowerCase()||"",at=be.config?.name?.toLowerCase()||"";if(Ue<at)return-1;if(Ue>at)return 1;return 0})},[A]),ne=P?.pages.flatMap((re)=>re.data??[])??[],fe=async(re,be,Ue,at,Ye)=>{if(!a?.id)return;if(h){console.log("[handleSendMessage] checking auth status");let Ie=await Ht.api.me.$get(),{id:mt}=await Ie.json();if(console.log("[handleSendMessage] loggedInUserId:",mt),!mt){let vt=localStorage.getItem("guest_user_id");if(console.log("[handleSendMessage] guestUserId from storage:",vt),!vt){console.log("[handleSendMessage] no guest ID, opening popup"),K({text:re,attachmentIds:be,annotations:Ue,replyToId:at,second:Ye}),x(!0);return}L({text:re,attachmentIds:be,annotations:Ue,replyToId:at,guestUserId:vt,second:Ye})}else L({text:re,attachmentIds:be,annotations:Ue,replyToId:at,second:Ye})}else L({text:re,attachmentIds:be,annotations:Ue,replyToId:at,second:Ye});H(null)},Ae=(re)=>{if(console.log("[handleGuestSuccess] guestUserId:",re),z)L({...z,guestUserId:re}),K(null),H(null)},he=(re)=>{let be=s.find((Ue)=>Ue.id===re);if(be)return be;return{id:"unknown",name:"Unknown",role:"unknown"}};if(!a)return R("div",{className:"flex h-full items-center justify-center p-8 text-center bg-background",children:ie("div",{className:"space-y-2",children:[R("p",{className:"text-sm font-medium text-foreground",children:He.no_item_selected()}),R("p",{className:"text-xs text-muted-foreground",children:He.select_file_to_view_details()})]})});return R("div",{className:"bg-background h-full flex flex-col overflow-hidden",children:ie(MS,{defaultValue:"comments",className:"p-1 flex-1 flex flex-col px-2 min-h-0",children:[ie(DS,{className:"w-full shrink-0",children:[R(ep,{value:"comments",className:"flex-1",children:He.comments()}),R(ep,{value:"fields",className:"flex-1",children:He.fields()})]}),ie(tp,{value:"comments",className:"flex-1 flex flex-col overflow-hidden min-h-0 mt-0",children:[R(P8,{className:"flex-1 min-h-0 [&>div>div]:block!",children:ie("div",{className:"space-y-4",children:[ne.map((re)=>ie("div",{children:[R(x3,{teamId:e,message:re,getUser:he,onReply:H,hasReplies:!!re.replies?.length,formatTimestamp:Q?.commentsConfig?.formatTimestamp,frameRate:Q?.commentsConfig?.hasTimestamp?a?.media?.metadata?.frameRate||30:void 0,startTimecode:Q?.commentsConfig?.hasTimestamp?a?.media?.metadata?.startTimecode:void 0,isSelected:d===re.id,onSelect:()=>{i?.(re)}}),re.replies?.map((be,Ue)=>R("div",{children:R(x3,{teamId:e,isReply:!0,message:be,getUser:he,onReply:H,hasReplies:!1,isLastReply:Ue===(re.replies?.length??0)-1,formatTimestamp:Q?.commentsConfig?.formatTimestamp,frameRate:Q?.commentsConfig?.hasTimestamp?a?.media?.metadata?.frameRate||30:void 0,startTimecode:Q?.commentsConfig?.hasTimestamp?a?.media?.metadata?.startTimecode:void 0,isSelected:d===be.id,onSelect:()=>{i?.(be)}})},be.id))]},re.id)),R("div",{ref:O})]})}),(!l||h)&&R("div",{className:"mt-4 shrink-0",children:R(k7,{isOpen:N,onClose:()=>x(!1),onSuccess:Ae,children:R(N3,{projectId:t,onSendMessage:fe,replyingTo:M,onCancelReply:()=>H(null),hideAnnotationControl:f,disableMentions:h,currentTime:Q?.commentsConfig?.hasTimestamp?g:void 0,formatTimestamp:Q?.commentsConfig?.formatTimestamp,frameRate:Q?.commentsConfig?.hasTimestamp?a?.media?.metadata?.frameRate||30:void 0,startTimecode:Q?.commentsConfig?.hasTimestamp?a?.media?.metadata?.startTimecode:void 0,onTyping:b})})})]}),R(tp,{value:"fields",className:"flex-1 flex flex-col overflow-hidden min-h-0 mt-4",children:R(P8,{className:"flex-1 px-4 min-h-0 [&>div>div]:block!",children:pe&&pe.length>0&&R("div",{className:"space-y-4 pb-4",children:pe.map((re)=>ie("div",{className:"space-y-1",children:[R("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:re.config?.name}),R("div",{className:"min-h-[28px]",children:R(RS,{fieldId:re.id,config:re.config,value:J[re.id]?.value,onSave:j?(be)=>n(re.id,be):void 0,readOnly:l||re.readOnly||!j})})]},re.id))})})})]})})}
307
+ export{pv as x,gz as y,dA as z,OS as A,x3 as B,N3 as C,k7 as D,bZ as E};