@shumai-one/shumai 0.3.2 → 0.3.4

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 (191) hide show
  1. package/bin/{chunk-qmtvy2j4.js → chunk-03pw611p.js} +2 -2
  2. package/bin/{chunk-1nh6xgek.js → chunk-05m8w09t.js} +1 -1
  3. package/bin/chunk-0ark0qrm.js +1 -0
  4. package/bin/{chunk-arpna31w.js → chunk-1apsnd7e.js} +1 -1
  5. package/bin/{chunk-g2dk56e7.js → chunk-1bfrnc6b.js} +1 -1
  6. package/bin/chunk-21h9kgp5.js +1 -0
  7. package/bin/{chunk-na2nympm.js → chunk-2967rnmn.js} +1 -1
  8. package/bin/chunk-2errtbmb.js +2 -0
  9. package/bin/{chunk-hrzm70wg.js → chunk-2jnyk045.js} +1 -1
  10. package/bin/{chunk-etces6ff.js → chunk-2mr99scd.js} +2 -2
  11. package/bin/chunk-2pxev94x.js +2 -0
  12. package/bin/chunk-2y9t0qxp.js +45 -0
  13. package/bin/{chunk-s7qpj715.js → chunk-2ydhnafa.js} +2 -2
  14. package/bin/chunk-38hp9gfh.js +2 -0
  15. package/bin/chunk-3t7v2de9.js +307 -0
  16. package/bin/{chunk-20y3wte3.js → chunk-3vbx3x11.js} +2 -2
  17. package/bin/{chunk-d3s00sn0.js → chunk-3xfhbvar.js} +2 -2
  18. package/bin/chunk-4153rke8.js +12 -0
  19. package/bin/{chunk-7jjc175m.js → chunk-4a185tez.js} +3 -3
  20. package/bin/{chunk-zxpef55w.js → chunk-4rexdetz.js} +3 -3
  21. package/bin/{chunk-1dawjfk8.js → chunk-58y9bagr.js} +2 -2
  22. package/bin/chunk-5dqn7egd.js +11 -0
  23. package/bin/{chunk-9p2d0mk1.js → chunk-5e48saab.js} +1 -1
  24. package/bin/{chunk-vnfmh5ke.js → chunk-5qwzveck.js} +2 -2
  25. package/bin/chunk-61hfhfce.js +2 -0
  26. package/bin/chunk-6ab9eftx.js +3 -0
  27. package/bin/chunk-6b0f3d07.js +2 -0
  28. package/bin/chunk-6gjn8trh.js +3 -0
  29. package/bin/{chunk-gn8snrnk.js → chunk-75x3w5hx.js} +1 -1
  30. package/bin/chunk-7e39zmss.js +1 -0
  31. package/bin/chunk-7h1m1e0b.js +1 -0
  32. package/bin/chunk-7kdz1eng.js +3 -0
  33. package/bin/chunk-7pcba64w.js +1 -0
  34. package/bin/{chunk-s05f0v9t.js → chunk-7xfx7741.js} +1 -1
  35. package/bin/chunk-898hrxwq.js +2 -0
  36. package/bin/{chunk-ph3e1bpp.js → chunk-89chaa11.js} +2 -2
  37. package/bin/chunk-8btfb5g6.js +2 -0
  38. package/bin/{chunk-gvn079hy.js → chunk-8pa1n500.js} +2 -2
  39. package/bin/{chunk-vy24ncn2.js → chunk-8qe7cpbr.js} +1 -1
  40. package/bin/{chunk-ws07a9kv.js → chunk-8tnq43k9.js} +1 -1
  41. package/bin/{chunk-1d22tysv.js → chunk-8wzepzp3.js} +2 -2
  42. package/bin/chunk-9deae0n7.js +3 -0
  43. package/bin/{chunk-3rcc5s99.js → chunk-ankkm2wz.js} +2 -2
  44. package/bin/chunk-ardp3pze.js +2 -0
  45. package/bin/chunk-axe5rq99.js +7 -0
  46. package/bin/chunk-bagxeg82.js +2 -0
  47. package/bin/{chunk-ss45w8ks.js → chunk-bhqrqt97.js} +2 -2
  48. package/bin/chunk-bn1sts8x.js +3 -0
  49. package/bin/{chunk-31mjcykb.js → chunk-bpb0szs5.js} +2 -2
  50. package/bin/{chunk-tsncwscz.js → chunk-c1j58ekb.js} +2 -2
  51. package/bin/chunk-c4nenmry.js +2 -0
  52. package/bin/chunk-c9f6n4sf.js +3 -0
  53. package/bin/chunk-cwh21vfb.js +2 -0
  54. package/bin/chunk-cwpmf8tx.js +2 -0
  55. package/bin/{chunk-ejfmxjw6.js → chunk-d2xrh0vv.js} +2 -2
  56. package/bin/chunk-d4sg0z3y.js +2 -0
  57. package/bin/chunk-d4sjezbk.js +8 -0
  58. package/bin/{chunk-vgb8bzcg.js → chunk-ddfx823h.js} +2 -2
  59. package/bin/chunk-dtjx1097.js +2 -0
  60. package/bin/chunk-e32bzfza.js +1 -0
  61. package/bin/chunk-e6rmqgzv.js +2 -0
  62. package/bin/chunk-ersxsrz8.js +62 -0
  63. package/bin/chunk-gg1wfpm8.js +3 -0
  64. package/bin/{chunk-qc6dmzn0.js → chunk-gg8dmkwd.js} +2 -2
  65. package/bin/chunk-gnx9g8px.js +2 -0
  66. package/bin/{chunk-xawwxdq9.js → chunk-h0k9zw29.js} +2 -2
  67. package/bin/chunk-htrzgs2a.css +1 -0
  68. package/bin/chunk-j2jdrmaa.js +2 -0
  69. package/bin/{chunk-v2kfr8fx.js → chunk-j5dejr3e.js} +2 -2
  70. package/bin/{chunk-wap08p4j.js → chunk-j5q3t199.js} +2 -2
  71. package/bin/chunk-jgxhv36z.js +3 -0
  72. package/bin/{chunk-dwswqq3g.js → chunk-jnx8p6kj.js} +1 -1
  73. package/bin/chunk-k41vt2gq.js +1 -0
  74. package/bin/chunk-k78m3rar.js +2 -0
  75. package/bin/chunk-kfbztymc.js +4 -0
  76. package/bin/chunk-kgr3ytpb.js +5 -0
  77. package/bin/chunk-khc3dydj.js +2 -0
  78. package/bin/chunk-krpr6g8a.js +1 -0
  79. package/bin/chunk-m8tnsds1.js +2 -0
  80. package/bin/chunk-mfmcsdd7.js +1 -0
  81. package/bin/chunk-msjv1ykh.js +2 -0
  82. package/bin/chunk-n73dbqps.js +1 -0
  83. package/bin/{chunk-5vqan9c4.js → chunk-n7cmya8k.js} +2 -2
  84. package/bin/{chunk-hfp4hpca.js → chunk-nabagpah.js} +2 -2
  85. package/bin/chunk-nn5qpr0q.js +1 -0
  86. package/bin/{chunk-ve7v8wtv.js → chunk-pew69nxg.js} +2 -2
  87. package/bin/{chunk-7eycsyk6.js → chunk-q2shr586.js} +1 -1
  88. package/bin/chunk-q7v8sj72.js +1 -0
  89. package/bin/chunk-q9tm2d21.js +8 -0
  90. package/bin/{chunk-mcxsk75h.js → chunk-qw5yjhab.js} +3 -3
  91. package/bin/{chunk-j0p1peav.js → chunk-r9thyg31.js} +2 -2
  92. package/bin/{chunk-h2wsm7h3.js → chunk-s584wxzj.js} +2 -2
  93. package/bin/{chunk-wr5byz6r.js → chunk-s5s1rk4n.js} +1 -1
  94. package/bin/{chunk-zs9b0f3z.js → chunk-scfbmsy7.js} +2 -2
  95. package/bin/{chunk-k20bhxed.js → chunk-sddrv3ep.js} +1 -1
  96. package/bin/{chunk-amsb41z5.js → chunk-sfmhbk59.js} +1 -1
  97. package/bin/chunk-tbdgkpgw.js +2 -0
  98. package/bin/chunk-twhj7h73.js +1 -0
  99. package/bin/{chunk-mahxw48e.js → chunk-v5zdafv4.js} +2 -2
  100. package/bin/{chunk-3t7mjvdv.js → chunk-vzx1r87y.js} +2 -2
  101. package/bin/{chunk-a76c5r3c.js → chunk-w3xzd86e.js} +2 -2
  102. package/bin/{chunk-nzy3pjjm.js → chunk-xkh6b42h.js} +2 -2
  103. package/bin/chunk-yn7mxpmb.js +7 -0
  104. package/bin/{chunk-yahb7wan.js → chunk-z544s59c.js} +2 -2
  105. package/bin/{chunk-f8cn9m28.js → chunk-zned6mj8.js} +1 -1
  106. package/bin/{chunk-08mxv0sm.js → chunk-zpq34g0w.js} +2 -2
  107. package/bin/shumai-app.html +1 -1
  108. package/bin/shumai-app.js +495 -372
  109. package/package.json +7 -7
  110. package/prisma/migrations/20260801065040_add_audit_log/migration.sql +33 -0
  111. package/prisma/migrations/20260805021613_add_asset_autofill_context/migration.sql +2 -0
  112. package/prisma/migrations/20260806082136_add_sharelink_watermark/migration.sql +69 -0
  113. package/prisma/migrations/20260806085643_add_watermark_file_status/migration.sql +7 -0
  114. package/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql +86 -0
  115. package/prisma/migrations/20260808014542_add_sharelink_allow_download/migration.sql +2 -0
  116. package/prisma/schema.prisma +93 -0
  117. package/bin/chunk-08dr94gp.js +0 -2
  118. package/bin/chunk-0t4z17qr.js +0 -2
  119. package/bin/chunk-2ynx0den.js +0 -8
  120. package/bin/chunk-31a3k77j.js +0 -2
  121. package/bin/chunk-3jdef7n4.js +0 -6
  122. package/bin/chunk-4ahve1nf.js +0 -2
  123. package/bin/chunk-4hdnrwh1.js +0 -1
  124. package/bin/chunk-4hdx2tv0.js +0 -2
  125. package/bin/chunk-4htdb0xp.js +0 -1
  126. package/bin/chunk-4p7xpfey.js +0 -2
  127. package/bin/chunk-5f81c951.js +0 -1
  128. package/bin/chunk-5zntjzxw.js +0 -3
  129. package/bin/chunk-6a2eb3b5.js +0 -3
  130. package/bin/chunk-6t3gdd7e.js +0 -2
  131. package/bin/chunk-7d5kep8c.js +0 -2
  132. package/bin/chunk-7kzqkp5z.js +0 -1
  133. package/bin/chunk-7sh6409h.js +0 -1
  134. package/bin/chunk-7y8dng8t.js +0 -2
  135. package/bin/chunk-8e5zvy88.js +0 -307
  136. package/bin/chunk-8m6zg15c.js +0 -4
  137. package/bin/chunk-8qyke29r.js +0 -7
  138. package/bin/chunk-90et6bwm.js +0 -3
  139. package/bin/chunk-9c7fxjej.js +0 -2
  140. package/bin/chunk-a10tf0d8.js +0 -3
  141. package/bin/chunk-b10meywb.js +0 -2
  142. package/bin/chunk-b1e3tec3.js +0 -62
  143. package/bin/chunk-bdjhb77e.js +0 -2
  144. package/bin/chunk-beay9amy.js +0 -1
  145. package/bin/chunk-c3fvs0bv.js +0 -4
  146. package/bin/chunk-c5my1b3k.js +0 -7
  147. package/bin/chunk-dhekxndw.js +0 -3
  148. package/bin/chunk-dwaj1yn4.js +0 -2
  149. package/bin/chunk-er1rb6yj.js +0 -1
  150. package/bin/chunk-etqpzc9e.js +0 -3
  151. package/bin/chunk-fdpjw17x.js +0 -7
  152. package/bin/chunk-gqh4ttjh.js +0 -3
  153. package/bin/chunk-hz31j0hk.js +0 -4
  154. package/bin/chunk-jm6bxtzt.js +0 -41
  155. package/bin/chunk-jstc7pka.js +0 -2
  156. package/bin/chunk-k0a35mg9.js +0 -2
  157. package/bin/chunk-k9w6mk9d.js +0 -3
  158. package/bin/chunk-kgb16ggd.css +0 -1
  159. package/bin/chunk-m4py21f3.js +0 -2
  160. package/bin/chunk-mm1j72a8.js +0 -7
  161. package/bin/chunk-nr89225z.js +0 -2
  162. package/bin/chunk-nrf5r23d.js +0 -1
  163. package/bin/chunk-nt9tfjx6.js +0 -12
  164. package/bin/chunk-p396vw9h.js +0 -8
  165. package/bin/chunk-p9xfyqh1.js +0 -2
  166. package/bin/chunk-pj0fgb2x.js +0 -6
  167. package/bin/chunk-pp072ksj.js +0 -2
  168. package/bin/chunk-q5cdjzbv.js +0 -3
  169. package/bin/chunk-qn96vbke.js +0 -2
  170. package/bin/chunk-qvgc9e08.js +0 -3
  171. package/bin/chunk-rrxjvewm.js +0 -2
  172. package/bin/chunk-s5rfya1p.js +0 -1
  173. package/bin/chunk-scsy69bp.js +0 -1
  174. package/bin/chunk-sf6fwvrs.js +0 -8
  175. package/bin/chunk-t2txvzkp.js +0 -3
  176. package/bin/chunk-td54rdfj.js +0 -8
  177. package/bin/chunk-vb9m47z9.js +0 -1
  178. package/bin/chunk-vf066xwh.js +0 -3
  179. package/bin/chunk-w3a50kz8.js +0 -3
  180. package/bin/chunk-w9w5301f.js +0 -4
  181. package/bin/chunk-wny0qagx.js +0 -3
  182. package/bin/chunk-wqhk76de.js +0 -14
  183. package/bin/chunk-wrz9e73c.js +0 -2
  184. package/bin/chunk-x5dcgk62.js +0 -6
  185. package/bin/chunk-xwmsxg5x.js +0 -1
  186. package/bin/chunk-y2nw8rbx.js +0 -4
  187. package/bin/chunk-y9ttm07y.js +0 -3
  188. package/bin/chunk-z0ej44ak.js +0 -3
  189. package/bin/chunk-zemgtnk0.js +0 -1
  190. package/bin/chunk-zg0vm233.js +0 -2
  191. package/bin/chunk-zhd2mkbr.js +0 -1
@@ -1,307 +0,0 @@
1
- import{s as Xp,t as Kp}from"./chunk-nzy3pjjm.js";import{C as qS,E as e7,G as U2,H as G2,I as X2,P as t7,Q as vS,R as nv,S as zl,T as b9,U as ug,V as K9}from"./chunk-9c7fxjej.js";import{Xa as I8}from"./chunk-hfp4hpca.js";import{ab as Dp,bb as Rp,cb as Np,db as zp,eb as Ep,fb as Ip,gb as Up,hb as Gp}from"./chunk-20y3wte3.js";import{Df as E9,Ef as I9,Ff as Fk,Hf as zg,If as Ok,Jf as Bk,Lf as Tk,Mf as zk,Nf as Eg,Of as Mk,Pf as Hk,Qf as Fp,Rf as Op,Sf as Bp,Tf as Tp,Uf as bS,Vf as wS,Wf as z8,Xf as E8,cg as E2}from"./chunk-7y8dng8t.js";import{qg as So}from"./chunk-etces6ff.js";import{rg as dS,sg as hs}from"./chunk-yahb7wan.js";import{tg as y3}from"./chunk-mahxw48e.js";import{Rg as Pf,Tg as er,Ug as tr,Vg as z0,Yg as d9,bh as Pp,ch as jS,dh as A3}from"./chunk-nr89225z.js";import{Ai as nA,Di as Ci,Ej as tv,Fh as Lp,Fj as av,Gi as z2,Hj as _o,Mh as Bt,Vh as Cp,Wh as a7,Xj as Fh,Zi as j9,ak as jn,cj as q9,ck as Si,di as Vp,dj as El,dk as Mp,ek as Hp,fi as v3,fk as xp,gh as Za,gj as Qp,hh as I2,hi as X9,hj as Wq,ih as I,ij as w1,ik as Le,jh as he,jj as d1,kh as N2,lj as Zp,mi as Yp,mj as Pq,nh as Ec,oj as ev,ph as Wf,pi as b1,qh as pS,qi as Co,ri as rS,si as oS,sj as $p,xj as _p,yi as Jp,zj as Wp}from"./chunk-b1e3tec3.js";import{Xk as Mt,Yk as Tt,Zk as HR}from"./chunk-ws07a9kv.js";var Ki=Tt((XE,s7)=>{var Uc;if(typeof window<"u")Uc=window;else if(typeof global<"u")Uc=global;else if(typeof self<"u")Uc=self;else Uc={};s7.exports=Uc});var S3=Tt((KE,l7)=>{var i7=Array.prototype.slice;l7.exports=w_;function w_(e,t){if(!("length"in e))e=[e];e=i7.call(e);while(e.length){var a=e.shift(),n=t(a);if(n)return n;if(a.childNodes&&a.childNodes.length)e=i7.call(a.childNodes).concat(e)}}});var r7=Tt((LE,f7)=>{f7.exports=Fo;function Fo(e,t){if(!(this instanceof Fo))return new Fo(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}Fo.prototype.nodeType=8;Fo.prototype.nodeName="#comment";Fo.prototype.toString=function(){return"[object Comment]"}});var c7=Tt((VE,o7)=>{o7.exports=Il;function Il(e,t){if(!(this instanceof Il))return new Il(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}Il.prototype.type="DOMTextNode";Il.prototype.nodeType=3;Il.prototype.nodeName="#text";Il.prototype.toString=function(){return this.data};Il.prototype.replaceData=function(t,a,n){var s=this.data,i=s.substring(0,t),l=s.substring(t+a,s.length);this.data=i+n+l,this.length=this.data.length}});var C3=Tt((YE,h7)=>{h7.exports=d_;function d_(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 _3=Tt((JE,u7)=>{u7.exports=j_;function j_(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 F3=Tt((QE,m7)=>{m7.exports=q_;function q_(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 w7=Tt((ZE,b7)=>{b7.exports=g7;var v_=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function g7(e){switch(e.nodeType){case 3:return O3(e.data);case 8:return"<!--"+e.data+"-->";default:return k_(e)}}function k_(e){var t=[],a=e.tagName;if(e.namespaceURI==="http://www.w3.org/1999/xhtml")a=a.toLowerCase();if(t.push("<"+a+C_(e)+S_(e)),v_.indexOf(a)>-1)t.push(" />");else{if(t.push(">"),e.childNodes.length)t.push.apply(t,e.childNodes.map(g7));else if(e.textContent||e.innerText)t.push(O3(e.textContent||e.innerText));else if(e.innerHTML)t.push(e.innerHTML);t.push("</"+a+">")}return t.join("")}function A_(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 y_(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 S_(e){var t=e.dataset,a=[];for(var n in t)a.push({name:"data-"+n,value:t[n]});return a.length?p7(a):""}function p7(e){var t=[];return e.forEach(function(a){var{name:n,value:s}=a;if(n==="style")s=y_(s);t.push(n+'="'+__(s)+'"')}),t.length?" "+t.join(" "):""}function C_(e){var t=[];for(var a in e)if(A_(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],l=(i.prefix?i.prefix+":":"")+s;t.push({name:l,value:i.value})}if(e.className)t.push({name:"class",value:e.className});return t.length?p7(t):""}function O3(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 __(e){return O3(e).replace(/"/g,"&quot;")}});var T3=Tt(($E,j7)=>{var B3=S3(),F_=C3(),O_=_3(),B_=F3(),T_=w7(),d7="http://www.w3.org/1999/xhtml";j7.exports=ca;function ca(e,t,a){if(!(this instanceof ca))return new ca(e);var n=a===void 0?d7:a||null;if(this.tagName=n===d7?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"}ca.prototype.type="DOMElement";ca.prototype.nodeType=1;ca.prototype.appendChild=function(t){if(t.parentNode)t.parentNode.removeChild(t);return this.childNodes.push(t),t.parentNode=this,t};ca.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};ca.prototype.removeChild=function(t){var a=this.childNodes.indexOf(t);return this.childNodes.splice(a,1),t.parentNode=null,t};ca.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};ca.prototype.setAttributeNS=function(t,a,n){var s=null,i=a,l=a.indexOf(":");if(l>-1)s=a.substr(0,l),i=a.substr(l+1);if(this.tagName==="INPUT"&&a==="type")this.type=n;else{var f=this._attributes[t]||(this._attributes[t]={});f[i]={value:n,prefix:s}}};ca.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};ca.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]};ca.prototype.hasAttributeNS=function(t,a){var n=this._attributes[t];return!!n&&a in n};ca.prototype.setAttribute=function(t,a){return this.setAttributeNS(null,t,a)};ca.prototype.getAttribute=function(t){return this.getAttributeNS(null,t)};ca.prototype.removeAttribute=function(t){return this.removeAttributeNS(null,t)};ca.prototype.hasAttribute=function(t){return this.hasAttributeNS(null,t)};ca.prototype.removeEventListener=B_;ca.prototype.addEventListener=O_;ca.prototype.dispatchEvent=F_;ca.prototype.focus=function(){return};ca.prototype.toString=function(){return T_(this)};ca.prototype.getElementsByClassName=function(t){var a=t.split(" "),n=[];return B3(this,function(s){if(s.nodeType===1){var i=s.className||"",l=i.split(" ");if(a.every(function(f){return l.indexOf(f)!==-1}))n.push(s)}}),n};ca.prototype.getElementsByTagName=function(t){t=t.toLowerCase();var a=[];return B3(this.childNodes,function(n){if(n.nodeType===1&&(t==="*"||n.tagName.toLowerCase()===t))a.push(n)}),a};ca.prototype.contains=function(t){return B3(this,function(a){return t===a})||!1}});var v7=Tt((WE,q7)=>{var M3=T3();q7.exports=Li;function Li(e){if(!(this instanceof Li))return new Li;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}Li.prototype.type="DocumentFragment";Li.prototype.nodeType=11;Li.prototype.nodeName="#document-fragment";Li.prototype.appendChild=M3.prototype.appendChild;Li.prototype.replaceChild=M3.prototype.replaceChild;Li.prototype.removeChild=M3.prototype.removeChild;Li.prototype.toString=function(){return this.childNodes.map(function(t){return String(t)}).join("")}});var A7=Tt((PE,k7)=>{k7.exports=H3;function H3(e){}H3.prototype.initEvent=function(t,a,n){this.type=t,this.bubbles=a,this.cancelable=n};H3.prototype.preventDefault=function(){}});var S7=Tt((eI,y7)=>{var M_=S3(),H_=r7(),x_=c7(),Gc=T3(),D_=v7(),R_=A7(),N_=C3(),z_=_3(),E_=F3();y7.exports=K2;function K2(){if(!(this instanceof K2))return new K2;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 Rs=K2.prototype;Rs.createTextNode=function(t){return new x_(t,this)};Rs.createElementNS=function(t,a){var n=t===null?null:String(t);return new Gc(a,this,n)};Rs.createElement=function(t){return new Gc(t,this)};Rs.createDocumentFragment=function(){return new D_(this)};Rs.createEvent=function(t){return new R_(t)};Rs.createComment=function(t){return new H_(t,this)};Rs.getElementById=function(t){t=String(t);var a=M_(this.childNodes,function(n){if(String(n.id)===t)return n});return a||null};Rs.getElementsByClassName=Gc.prototype.getElementsByClassName;Rs.getElementsByTagName=Gc.prototype.getElementsByTagName;Rs.contains=Gc.prototype.contains;Rs.removeEventListener=E_;Rs.addEventListener=z_;Rs.dispatchEvent=N_});var _7=Tt((tI,C7)=>{var I_=S7();C7.exports=new I_});var x3=Tt((aI,O7)=>{var F7=typeof global<"u"?global:typeof window<"u"?window:{},U_=_7(),Xc;if(typeof document<"u")Xc=document;else if(Xc=F7["__GLOBAL_DOCUMENT_CACHE@4"],!Xc)Xc=F7["__GLOBAL_DOCUMENT_CACHE@4"]=U_;O7.exports=Xc});var B7=Tt((nI,E0)=>{function D3(){return E0.exports=D3=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},E0.exports.__esModule=!0,E0.exports.default=E0.exports,D3.apply(null,arguments)}E0.exports=D3,E0.exports.__esModule=!0,E0.exports.default=E0.exports});var M7=Tt((sI,T7)=>{T7.exports=X_;var G_=Object.prototype.toString;function X_(e){if(!e)return!1;var t=G_.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 D7=Tt((iI,x7)=>{function K_(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=L_(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 L_(e,t){if(!e)return;if(typeof e==="string")return H7(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 H7(e,t)}function H7(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 V_=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 l=K_(i),f;!(f=l()).done;){var c=f.value;try{s=c(s)}catch(h){}}return s},e}();x7.exports=V_});var N7=Tt((lI,R7)=>{var Y_=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,l=s.delayFactor,f=s.fuzzFactor,c=s.initialDelay;return new J_({maxAttempts:i||this.maxAttempts_,delayFactor:l||this.delayFactor_,fuzzFactor:f||this.fuzzFactor_,initialDelay:c||this.initialDelay_})},e}(),J_=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}();R7.exports=Y_});var E7=Tt((fI,z7)=>{var Q_=Ki(),Z_=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 l=i;if(a)if(Q_.TextDecoder){var f=$_(s.headers&&s.headers["content-type"]);try{l=new TextDecoder(f).decode(i)}catch(c){}}else l=String.fromCharCode.apply(null,new Uint8Array(i));t({cause:l});return}t(null,i)}};function $_(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")}z7.exports=Z_});var X7=Tt((rI,N3)=>{var I7=Ki(),W_=B7(),P_=M7(),U7=D7(),eF=N7();Ua.httpHandler=E7();Ua.requestInterceptorsStorage=new U7;Ua.responseInterceptorsStorage=new U7;Ua.retryManager=new eF;var tF=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(),l=n.slice(s+1).trim();if(typeof a[i]>"u")a[i]=l;else if(Array.isArray(a[i]))a[i].push(l);else a[i]=[a[i],l]}),a};N3.exports=Ua;N3.exports.default=Ua;Ua.XMLHttpRequest=I7.XMLHttpRequest||iF;Ua.XDomainRequest="withCredentials"in new Ua.XMLHttpRequest?Ua.XMLHttpRequest:I7.XDomainRequest;aF(["get","put","post","patch","head","delete"],function(e){Ua[e==="delete"?"del":e]=function(t,a,n){return a=G7(t,a,n),a.method=e.toUpperCase(),R3(a)}});function aF(e,t){for(var a=0;a<e.length;a++)t(e[a])}function nF(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function G7(e,t,a){var n=e;if(P_(t)){if(a=t,typeof e==="string")n={uri:e}}else n=W_({},t,{uri:e});return n.callback=a,n}function Ua(e,t,a){return t=G7(e,t,a),R3(t)}function R3(e){if(typeof e.callback>"u")throw Error("callback argument missing");if(e.requestType&&Ua.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=Ua.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,D,N){if(!n)n=!0,e.callback(H,D,N)};function i(){if(h.readyState===4&&!Ua.responseInterceptorsStorage.getIsEnabled())setTimeout(c,0)}function l(){var M=void 0;if(h.response)M=h.response;else M=h.responseText||sF(h);if(C)try{M=JSON.parse(M)}catch(H){}return M}function f(M){if(clearTimeout(O),clearTimeout(e.retryTimeout),!(M instanceof Error))M=Error(""+(M||"Unknown XMLHttpRequest Error"));if(M.statusCode=0,!g&&Ua.retryManager.getIsEnabled()&&e.retry&&e.retry.shouldRetry()){e.retryTimeout=setTimeout(function(){e.retry.moveToNextAttempt(),e.xhr=h,R3(e)},e.retry.getCurrentFuzzedDelay());return}if(e.requestType&&Ua.responseInterceptorsStorage.getIsEnabled()){var H={headers:T.headers||{},body:T.body,responseUrl:h.responseURL,responseType:h.responseType},D=Ua.responseInterceptorsStorage.execute(e.requestType,H);T.body=D.body,T.headers=D.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,D=null;if(M!==0){if(H={body:l(),statusCode:M,method:d,headers:{},url:b,rawRequest:h},h.getAllResponseHeaders)H.headers=tF(h.getAllResponseHeaders())}else D=Error("Internal XMLHttpRequest Error");if(e.requestType&&Ua.responseInterceptorsStorage.getIsEnabled()){var N={headers:H.headers||{},body:H.body,responseUrl:h.responseURL,responseType:h.responseType},z=Ua.responseInterceptorsStorage.execute(e.requestType,N);H.body=z.body,H.headers=z.headers}return s(D,H,H.body)}var h=e.xhr||null;if(!h)if(e.cors||e.useXDR)h=new Ua.XDomainRequest;else h=new Ua.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||{},S=!!e.sync,C=!1,O,T={body:void 0,headers:{},statusCode:0,method:d,url:b,rawRequest:h};if("json"in e&&e.json!==!1){if(C=!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=f,h.onprogress=function(){},h.onabort=function(){g=!0,clearTimeout(e.retryTimeout)},h.ontimeout=f,h.open(d,b,!S,e.username,e.password),!S)h.withCredentials=!!e.withCredentials;if(!S&&e.timeout>0)O=setTimeout(function(){if(g)return;g=!0,h.abort("timeout");var M=Error("XMLHttpRequest timeout");M.code="ETIMEDOUT",f(M)},e.timeout);if(h.setRequestHeader){for(u in A)if(A.hasOwnProperty(u))h.setRequestHeader(u,A[u])}else if(e.headers&&!nF(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 sF(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 iF(){}});var Z7=Tt((oI,Q7)=>{var K7=x3(),E3=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 Ns(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}Ns.prototype=E3(Error.prototype);Ns.prototype.constructor=Ns;Ns.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function I3(e){function t(n,s,i,l){return(n|0)*3600+(s|0)*60+(i|0)+(l|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 Lc(){this.values=E3(null)}Lc.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 Kc(e,t,a,n){var s=n?e.split(n):[e];for(var i in s){if(typeof s[i]!=="string")continue;var l=s[i].split(a);if(l.length!==2)continue;var f=l[0].trim(),c=l[1].trim();t(f,c)}}function lF(e,t,a){var n=e;function s(){var f=I3(e);if(f===null)throw new Ns(Ns.Errors.BadTimeStamp,"Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),f}function i(f,c){var h=new Lc;Kc(f,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 l(){e=e.replace(/^\s+/,"")}if(l(),t.startTime=s(),l(),e.substr(0,3)!=="-->")throw new Ns(Ns.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+n);e=e.substr(3),l(),t.endTime=s(),l(),i(e,t)}var z3=K7.createElement&&K7.createElement("textarea"),fF={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},L7={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)"},rF={v:"title",lang:"lang"},V7={rt:"ruby"};function J7(e,t){function a(){if(!t)return null;function j(S){return t=t.substr(S.length),S}var A=t.match(/^([^<]*)(<[^>]*>?)?/);return j(A[1]?A[1]:A[2])}function n(j){return z3.innerHTML=j,j=z3.textContent,z3.textContent="",j}function s(j,A){return!V7[A.localName]||V7[A.localName]===j.localName}function i(j,A){var S=fF[j];if(!S)return null;var C=e.document.createElement(S),O=rF[j];if(O&&A)C[O]=A.trim();return C}var l=e.document.createElement("div"),f=l,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(),f=f.parentNode;continue}var u=I3(c.substr(1,c.length-2)),g;if(u){g=e.document.createProcessingInstruction("timestamp",u),f.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(f,g))continue;if(b[2]){var d=b[2].split(".");d.forEach(function(j){var A=/^bg_/.test(j),S=A?j.slice(3):j;if(L7.hasOwnProperty(S)){var C=A?"background-color":"color",O=L7[S];g.style[C]=O}}),g.className=d.join(" ")}h.push(b[1]),f.appendChild(g),f=g;continue}f.appendChild(e.document.createTextNode(n(c)))}return l}var Y7=[[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 oF(e){for(var t=0;t<Y7.length;t++){var a=Y7[t];if(e>=a[0]&&e<=a[1])return!0}return!1}function cF(e){var t=[],a="",n;if(!e||!e.childNodes)return"ltr";function s(f,c){for(var h=c.childNodes.length-1;h>=0;h--)f.push(c.childNodes[h])}function i(f){if(!f||!f.length)return null;var c=f.pop(),h=c.textContent||c.innerText;if(h){var u=h.match(/^.*(\n|\r)/);if(u)return f.length=0,u[0];return h}if(c.tagName==="ruby")return i(f);if(c.childNodes)return s(f,c),i(f)}s(t,e);while(a=i(t))for(var l=0;l<a.length;l++)if(n=a.charCodeAt(l),oF(n))return"rtl";return"ltr"}function hF(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 V2(){}V2.prototype.applyStyles=function(e,t){t=t||this.div;for(var a in e)if(e.hasOwnProperty(a))t.style[a]=e[a]};V2.prototype.formatStyle=function(e,t){return e===0?0:e+t};function L2(e,t,a){V2.call(this),this.cue=t,this.cueDiv=J7(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:cF(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")})}}L2.prototype=E3(V2.prototype);L2.prototype.constructor=L2;function Jn(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}Jn.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}};Jn.prototype.overlaps=function(e){return this.left<e.right&&this.right>e.left&&this.top<e.bottom&&this.bottom>e.top};Jn.prototype.overlapsAny=function(e){for(var t=0;t<e.length;t++)if(this.overlaps(e[t]))return!0;return!1};Jn.prototype.within=function(e){return this.top>=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right};Jn.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}};Jn.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)};Jn.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}};Jn.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 uF(e,t,a,n){function s(S,C){var O,T=new Jn(S),M=1;for(var H=0;H<C.length;H++){while(S.overlapsOppositeAxis(a,C[H])||S.within(a)&&S.overlapsAny(n))S.move(C[H]);if(S.within(a))return S;var D=S.intersectPercentage(a);if(M>D)O=new Jn(S),M=D;S=new Jn(T)}return O||T}var i=new Jn(t),l=t.cue,f=hF(l),c=[];if(l.snapToLines){var h;switch(l.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(f),b=a[h]+u,d=c[0];if(Math.abs(g)>b)g=g<0?-1:1,g*=Math.ceil(b/u)*u;if(f<0)g+=l.vertical===""?a.height:a.width,c=c.reverse();i.move(d,g)}else{var j=i.lineHeight/a.height*100;switch(l.lineAlign){case"center":f-=j/2;break;case"end":f-=j;break}switch(l.vertical){case"":t.applyStyles({top:t.formatStyle(f,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(f,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(f,"%")});break}c=["+y","-x","+x","-y"],i=new Jn(t)}var A=s(i,c);t.move(A.toCSSCompatValues(a))}function Oo(){}Oo.StringDecoder=function(){return{decode:function(e){if(!e)return"";if(typeof e!=="string")throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};Oo.convertCueToDOMTree=function(e,t){if(!e||!t)return null;return J7(e,t)};var mF=0.05,gF="sans-serif",pF="1.5%";Oo.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=pF,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 l=[],f=Jn.getSimpleBoxPosition(n),c=Math.round(f.height*mF*100)/100,h={font:c+"px "+gF};(function(){var u,g;for(var b=0;b<t.length;b++)g=t[b],u=new L2(e,g,h),n.appendChild(u.div),uF(e,u,f,l),g.displayState=u.div,l.push(Jn.getSimpleBoxPosition(u))})()};Oo.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=[]};Oo.Parser.prototype={reportOrThrowError:function(e){if(e instanceof Ns)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 Lc;if(Kc(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 S=new Lc;if(S.percent("x",A[0]),S.percent("y",A[1]),!S.has("x")||!S.has("y"))break;g.set(d+"X",S.get("x")),g.set(d+"Y",S.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 Lc;Kc(u,function(b,d){switch(b){case"MPEGT":g.integer(b+"S",d);break;case"LOCA":g.set(b+"L",I3(d));break}},/[^\d]:/,/,/),t.ontimestampmap&&t.ontimestampmap({MPEGTS:g.get("MPEGTS"),LOCAL:g.get("LOCAL")})}function i(u){if(u.match(/X-TIMESTAMP-MAP/))Kc(u,function(g,b){switch(g){case"X-TIMESTAMP-MAP":s(b);break}},/=/);else Kc(u,function(g,b){switch(g){case"Region":n(b);break}},/:/)}try{var l;if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;l=a();var f=l.match(/^WEBVTT([ \t].*)?$/);if(!f||!f[0])throw new Ns(Ns.Errors.BadSignature);t.state="HEADER"}var c=!1;while(t.buffer){if(!/\r\n|\n/.test(t.buffer))return this;if(!c)l=a();else c=!1;switch(t.state){case"HEADER":if(/:/.test(l))i(l);else if(!l)t.state="ID";continue;case"NOTE":if(!l)t.state="ID";continue;case"ID":if(/^NOTE($|[ \t])/.test(l)){t.state="NOTE";break}if(!l)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",l.indexOf("-->")===-1){t.cue.id=l;continue}case"CUE":try{lF(l,t.cue,t.regionList)}catch(u){t.reportOrThrowError(u),t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var h=l.indexOf("-->")!==-1;if(!l||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+=l.replace(/\u2028/g,`
7
- `).replace(/u2029/g,`
8
- `);continue;case"BADCUE":if(!l)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 Ns(Ns.Errors.BadSignature)}catch(t){e.reportOrThrowError(t)}return e.onflush&&e.onflush(),this}};Q7.exports=Oo});var P7=Tt((cI,W7)=>{var bF="auto",wF={"":1,lr:1,rl:1},dF={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function jF(e){if(typeof e!=="string")return!1;var t=wF[e.toLowerCase()];return t?e.toLowerCase():!1}function U3(e){if(typeof e!=="string")return!1;var t=dF[e.toLowerCase()];return t?e.toLowerCase():!1}function $7(e,t,a){this.hasBeenReset=!1;var n="",s=!1,i=e,l=t,f=a,c=null,h="",u=!0,g="auto",b="start",d="auto",j="auto",A=100,S="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return n},set:function(C){n=""+C}},pauseOnExit:{enumerable:!0,get:function(){return s},set:function(C){s=!!C}},startTime:{enumerable:!0,get:function(){return i},set:function(C){if(typeof C!=="number")throw TypeError("Start time must be set to a number.");i=C,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return l},set:function(C){if(typeof C!=="number")throw TypeError("End time must be set to a number.");l=C,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return f},set:function(C){f=""+C,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return c},set:function(C){c=C,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return h},set:function(C){var O=jF(C);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(C){u=!!C,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return g},set:function(C){if(typeof C!=="number"&&C!==bF)throw SyntaxError("Line: an invalid number or illegal string was specified.");g=C,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return b},set:function(C){var O=U3(C);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(C){if(C<0||C>100)throw Error("Position must be between 0 and 100.");d=C,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return j},set:function(C){var O=U3(C);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(C){if(C<0||C>100)throw Error("Size must be between 0 and 100.");A=C,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return S},set:function(C){var O=U3(C);if(!O)throw SyntaxError("align: an invalid or illegal alignment string was specified.");S=O,this.hasBeenReset=!0}}}),this.displayState=void 0}$7.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};W7.exports=$7});var tb=Tt((hI,eb)=>{var qF={"":!0,up:!0};function vF(e){if(typeof e!=="string")return!1;var t=qF[e.toLowerCase()];return t?e.toLowerCase():!1}function Vc(e){return typeof e==="number"&&(e>=0&&e<=100)}function kF(){var e=100,t=3,a=0,n=100,s=0,i=100,l="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(f){if(!Vc(f))throw Error("Width must be between 0 and 100.");e=f}},lines:{enumerable:!0,get:function(){return t},set:function(f){if(typeof f!=="number")throw TypeError("Lines must be set to a number.");t=f}},regionAnchorY:{enumerable:!0,get:function(){return n},set:function(f){if(!Vc(f))throw Error("RegionAnchorX must be between 0 and 100.");n=f}},regionAnchorX:{enumerable:!0,get:function(){return a},set:function(f){if(!Vc(f))throw Error("RegionAnchorY must be between 0 and 100.");a=f}},viewportAnchorY:{enumerable:!0,get:function(){return i},set:function(f){if(!Vc(f))throw Error("ViewportAnchorY must be between 0 and 100.");i=f}},viewportAnchorX:{enumerable:!0,get:function(){return s},set:function(f){if(!Vc(f))throw Error("ViewportAnchorX must be between 0 and 100.");s=f}},scroll:{enumerable:!0,get:function(){return l},set:function(f){var c=vF(f);if(c===!1)console.warn("Scroll: an invalid or illegal string was specified.");else l=c}}})}eb.exports=kF});var nb=Tt((uI,ab)=>{var I0=Ki(),ar=ab.exports={WebVTT:Z7(),VTTCue:P7(),VTTRegion:tb()};I0.vttjs=ar;I0.WebVTT=ar.WebVTT;var{VTTCue:AF,VTTRegion:yF}=ar,SF=I0.VTTCue,CF=I0.VTTRegion;ar.shim=function(){I0.VTTCue=AF,I0.VTTRegion=yF};ar.restore=function(){I0.VTTCue=SF,I0.VTTRegion=CF};if(!I0.VTTCue)ar.shim()});var Jc=Tt((UF)=>{function EF(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 e6(e,t){if(t===void 0)t=Object;return t&&typeof t.freeze==="function"?t.freeze(e):e}function IF(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 pb=e6({HTML:"text/html",isHTML:function(e){return e===pb.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),bb=e6({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===bb.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});UF.assign=IF;UF.find=EF;UF.freeze=e6;UF.MIME_TYPE=pb;UF.NAMESPACE=bb});var u6=Tt((fO)=>{var yb=Jc(),Vi=yb.find,Qc=yb.NAMESPACE;function YF(e){return e!==""}function JF(e){return e?e.split(/[\t\n\f\r ]+/).filter(YF):[]}function QF(e,t){if(!e.hasOwnProperty(t))e[t]=!0;return e}function wb(e){if(!e)return[];var t=JF(e);return Object.keys(t.reduce(QF,{}))}function ZF(e){return function(t){return e&&e.indexOf(t)!==-1}}function $c(e,t){for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a))t[a]=e[a]}function gs(e,t){var a=e.prototype;if(!(a instanceof t)){let s=function(){};var n=s;s.prototype=t.prototype,s=new s,$c(a,s),e.prototype=a=s}if(a.constructor!=e){if(typeof e!="function")console.error("unknown Class:"+e);a.constructor=e}}var ps={},ni=ps.ELEMENT_NODE=1,xo=ps.ATTRIBUTE_NODE=2,$2=ps.TEXT_NODE=3,Sb=ps.CDATA_SECTION_NODE=4,Cb=ps.ENTITY_REFERENCE_NODE=5,$F=ps.ENTITY_NODE=6,t6=ps.PROCESSING_INSTRUCTION_NODE=7,a6=ps.COMMENT_NODE=8,_b=ps.DOCUMENT_NODE=9,Fb=ps.DOCUMENT_TYPE_NODE=10,U0=ps.DOCUMENT_FRAGMENT_NODE=11,WF=ps.NOTATION_NODE=12,In={},pn={},_I=In.INDEX_SIZE_ERR=(pn[1]="Index size error",1),FI=In.DOMSTRING_SIZE_ERR=(pn[2]="DOMString size error",2),ms=In.HIERARCHY_REQUEST_ERR=(pn[3]="Hierarchy request error",3),OI=In.WRONG_DOCUMENT_ERR=(pn[4]="Wrong document",4),PF=In.INVALID_CHARACTER_ERR=(pn[5]="Invalid character",5),BI=In.NO_DATA_ALLOWED_ERR=(pn[6]="No data allowed",6),TI=In.NO_MODIFICATION_ALLOWED_ERR=(pn[7]="No modification allowed",7),Ob=In.NOT_FOUND_ERR=(pn[8]="Not found",8),MI=In.NOT_SUPPORTED_ERR=(pn[9]="Not supported",9),db=In.INUSE_ATTRIBUTE_ERR=(pn[10]="Attribute in use",10),Ho=In.INVALID_STATE_ERR=(pn[11]="Invalid state",11),HI=In.SYNTAX_ERR=(pn[12]="Syntax error",12),xI=In.INVALID_MODIFICATION_ERR=(pn[13]="Invalid modification",13),DI=In.NAMESPACE_ERR=(pn[14]="Invalid namespace",14),RI=In.INVALID_ACCESS_ERR=(pn[15]="Invalid access",15);function Pt(e,t){if(t instanceof Error)var a=t;else if(a=this,Error.call(this,pn[e]),this.message=pn[e],Error.captureStackTrace)Error.captureStackTrace(this,Pt);if(a.code=e,t)this.message=this.message+": "+t;return a}Pt.prototype=Error.prototype;$c(In,Pt);function G0(){}G0.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++)h6(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 Do(e,t){this._node=e,this._refresh=t,n6(this)}function n6(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var a=e._refresh(e._node);if(Ub(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]}$c(a,e),e._inc=t}}Do.prototype.item=function(e){return n6(this),this[e]||null};gs(Do,G0);function W2(){}function Bb(e,t){var a=e.length;while(a--)if(e[a]===t)return a}function jb(e,t,a,n){if(n)t[Bb(t,n)]=a;else t[t.length++]=a;if(e){a.ownerElement=e;var s=e.ownerDocument;if(s)n&&Hb(s,e,n),eO(s,e,a)}}function qb(e,t,a){var n=Bb(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)Hb(i,e,a),a.ownerElement=null}}else throw new Pt(Ob,Error(e.tagName+"@"+a))}W2.prototype={length:0,item:G0.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 Pt(db);var a=this.getNamedItem(e.nodeName);return jb(this._ownerElement,this,e,a),a},setNamedItemNS:function(e){var t=e.ownerElement,a;if(t&&t!=this._ownerElement)throw new Pt(db);return a=this.getNamedItemNS(e.namespaceURI,e.localName),jb(this._ownerElement,this,e,a),a},removeNamedItem:function(e){var t=this.getNamedItem(e);return qb(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var a=this.getNamedItemNS(e,t);return qb(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 Tb(){}Tb.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,a){var n=new Wc;if(n.implementation=this,n.childNodes=new G0,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 am;return n.name=e,n.nodeName=e,n.publicId=t||"",n.systemId=a||"",n}};function Yt(){}Yt.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 em(this,e,t)},replaceChild:function(e,t){if(em(this,e,t,Db),t)this.removeChild(t)},removeChild:function(e){return xb(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(e){return Ib(this.ownerDocument||this,this,e)},normalize:function(){gn(this,null,{enter:function(e){var t=e.firstChild;while(t){var a=t.nextSibling;if(a!==null&&a.nodeType===$2&&t.nodeType===$2)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==xo?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==xo?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return t==null}};function Mb(e){return e=="<"&&"&lt;"||e==">"&&"&gt;"||e=="&"&&"&amp;"||e=='"'&&"&quot;"||"&#"+e.charCodeAt()+";"}$c(ps,Yt);$c(ps,Yt.prototype);function P2(e,t){return gn(e,null,{enter:function(a){return t(a)?gn.STOP:!0}})===gn.STOP}function gn(e,t,a){var n=[{node:e,context:t,phase:gn.ENTER}];while(n.length>0){var s=n.pop();if(s.phase===gn.ENTER){var i=a.enter(s.node,s.context);if(i===gn.STOP)return gn.STOP;if(n.push({node:s.node,context:i,phase:gn.EXIT}),i===null||i===void 0)continue;var l=s.node.lastChild;while(l)n.push({node:l,context:i,phase:gn.ENTER}),l=l.previousSibling}else if(a.exit)a.exit(s.node,s.context)}}gn.STOP=Symbol("walkDOM.STOP");gn.ENTER=0;gn.EXIT=1;function Wc(){this.ownerDocument=this}function eO(e,t,a){e&&e._inc++;var n=a.namespaceURI;if(n===Qc.XMLNS)t._nsMap[a.prefix?a.localName:""]=a.value}function Hb(e,t,a,n){e&&e._inc++;var s=a.namespaceURI;if(s===Qc.XMLNS)delete t._nsMap[a.prefix?a.localName:""]}function s6(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 xb(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,s6(e.ownerDocument,e),t}function tO(e){return e&&(e.nodeType===Yt.DOCUMENT_NODE||e.nodeType===Yt.DOCUMENT_FRAGMENT_NODE||e.nodeType===Yt.ELEMENT_NODE)}function aO(e){return e&&(Yi(e)||i6(e)||X0(e)||e.nodeType===Yt.DOCUMENT_FRAGMENT_NODE||e.nodeType===Yt.COMMENT_NODE||e.nodeType===Yt.PROCESSING_INSTRUCTION_NODE)}function X0(e){return e&&e.nodeType===Yt.DOCUMENT_TYPE_NODE}function Yi(e){return e&&e.nodeType===Yt.ELEMENT_NODE}function i6(e){return e&&e.nodeType===Yt.TEXT_NODE}function vb(e,t){var a=e.childNodes||[];if(Vi(a,Yi)||X0(t))return!1;var n=Vi(a,X0);return!(t&&n&&a.indexOf(n)>a.indexOf(t))}function kb(e,t){var a=e.childNodes||[];function n(i){return Yi(i)&&i!==t}if(Vi(a,n))return!1;var s=Vi(a,X0);return!(t&&s&&a.indexOf(s)>a.indexOf(t))}function nO(e,t,a){if(!tO(e))throw new Pt(ms,"Unexpected parent node type "+e.nodeType);if(a&&a.parentNode!==e)throw new Pt(Ob,"child not in parent");if(!aO(t)||X0(t)&&e.nodeType!==Yt.DOCUMENT_NODE)throw new Pt(ms,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function sO(e,t,a){var n=e.childNodes||[],s=t.childNodes||[];if(t.nodeType===Yt.DOCUMENT_FRAGMENT_NODE){var i=s.filter(Yi);if(i.length>1||Vi(s,i6))throw new Pt(ms,"More than one element or text in fragment");if(i.length===1&&!vb(e,a))throw new Pt(ms,"Element in fragment can not be inserted before doctype")}if(Yi(t)){if(!vb(e,a))throw new Pt(ms,"Only one element can be added and only after doctype")}if(X0(t)){if(Vi(n,X0))throw new Pt(ms,"Only one doctype is allowed");var l=Vi(n,Yi);if(a&&n.indexOf(l)<n.indexOf(a))throw new Pt(ms,"Doctype can only be inserted before an element");if(!a&&l)throw new Pt(ms,"Doctype can not be appended since element is present")}}function Db(e,t,a){var n=e.childNodes||[],s=t.childNodes||[];if(t.nodeType===Yt.DOCUMENT_FRAGMENT_NODE){var i=s.filter(Yi);if(i.length>1||Vi(s,i6))throw new Pt(ms,"More than one element or text in fragment");if(i.length===1&&!kb(e,a))throw new Pt(ms,"Element in fragment can not be inserted before doctype")}if(Yi(t)){if(!kb(e,a))throw new Pt(ms,"Only one element can be added and only after doctype")}if(X0(t)){let c=function(h){return X0(h)&&h!==a};var f=c;if(Vi(n,c))throw new Pt(ms,"Only one doctype is allowed");var l=Vi(n,Yi);if(a&&n.indexOf(l)<n.indexOf(a))throw new Pt(ms,"Doctype can only be inserted before an element")}}function em(e,t,a,n){if(nO(e,t,a),e.nodeType===Yt.DOCUMENT_NODE)(n||sO)(e,t,a);var s=t.parentNode;if(s)s.removeChild(t);if(t.nodeType===U0){var i=t.firstChild;if(i==null)return t;var l=t.lastChild}else i=l=t;var f=a?a.previousSibling:e.lastChild;if(i.previousSibling=f,l.nextSibling=a,f)f.nextSibling=i;else e.firstChild=i;if(a==null)e.lastChild=l;else a.previousSibling=l;do{i.parentNode=e;var c=e.ownerDocument||e;Zc(i,c)}while(i!==l&&(i=i.nextSibling));if(s6(e.ownerDocument||e,e),t.nodeType==U0)t.firstChild=t.lastChild=null;return t}function Zc(e,t){if(e.ownerDocument===t)return;if(e.ownerDocument=t,e.nodeType===ni&&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)Zc(s,t),s=s.nextSibling}function iO(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,s6(e.ownerDocument,e,t);var a=e.ownerDocument||e;return Zc(t,a),t}Wc.prototype={nodeName:"#document",nodeType:_b,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==U0){var a=e.firstChild;while(a){var n=a.nextSibling;this.insertBefore(a,t),a=n}return e}if(em(this,e,t),Zc(e,this),this.documentElement===null&&e.nodeType===ni)this.documentElement=e;return e},removeChild:function(e){if(this.documentElement==e)this.documentElement=null;return xb(this,e)},replaceChild:function(e,t){if(em(this,e,t,Db),Zc(e,this),t)this.removeChild(t);if(Yi(e))this.documentElement=e},importNode:function(e,t){return lO(this,e,t)},getElementById:function(e){var t=null;return P2(this.documentElement,function(a){if(a.nodeType==ni){if(a.getAttribute("id")==e)return t=a,!0}}),t},getElementsByClassName:function(e){var t=wb(e);return new Do(this,function(a){var n=[];if(t.length>0)P2(a.documentElement,function(s){if(s!==a&&s.nodeType===ni){var i=s.getAttribute("class");if(i){var l=e===i;if(!l){var f=wb(i);l=t.every(ZF(f))}if(l)n.push(s)}}});return n})},createElement:function(e){var t=new lr;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new G0;var a=t.attributes=new W2;return a._ownerElement=t,t},createDocumentFragment:function(){var e=new nm;return e.ownerDocument=this,e.childNodes=new G0,e},createTextNode:function(e){var t=new l6;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new f6;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){if(e.indexOf("]]>")!==-1)throw new Pt(PF,'data contains "]]>"');var t=new r6;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var a=new c6;return a.ownerDocument=this,a.tagName=a.nodeName=a.target=e,a.nodeValue=a.data=t,a},createAttribute:function(e){var t=new tm;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new o6;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var a=new lr,n=t.split(":"),s=a.attributes=new W2;if(a.childNodes=new G0,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 tm,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}};gs(Wc,Yt);function lr(){this._nsMap={}}lr.prototype={nodeType:ni,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===U0)return this.insertBefore(e,null);else return iO(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 Do(this,function(t){var a=[];return P2(t,function(n){if(n!==t&&n.nodeType==ni&&(e==="*"||n.tagName==e))a.push(n)}),a})},getElementsByTagNameNS:function(e,t){return new Do(this,function(a){var n=[];return P2(a,function(s){if(s!==a&&s.nodeType===ni&&(e==="*"||s.namespaceURI===e)&&(t==="*"||s.localName==t))n.push(s)}),n})}};Wc.prototype.getElementsByTagName=lr.prototype.getElementsByTagName;Wc.prototype.getElementsByTagNameNS=lr.prototype.getElementsByTagNameNS;gs(lr,Yt);function tm(){}tm.prototype.nodeType=xo;gs(tm,Yt);function Pc(){}Pc.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(pn[ms])},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}};gs(Pc,Yt);function l6(){}l6.prototype={nodeName:"#text",nodeType:$2,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}};gs(l6,Pc);function f6(){}f6.prototype={nodeName:"#comment",nodeType:a6};gs(f6,Pc);function r6(){}r6.prototype={nodeName:"#cdata-section",nodeType:Sb};gs(r6,Pc);function am(){}am.prototype.nodeType=Fb;gs(am,Yt);function Rb(){}Rb.prototype.nodeType=WF;gs(Rb,Yt);function Nb(){}Nb.prototype.nodeType=$F;gs(Nb,Yt);function o6(){}o6.prototype.nodeType=Cb;gs(o6,Yt);function nm(){}nm.prototype.nodeName="#document-fragment";nm.prototype.nodeType=U0;gs(nm,Yt);function c6(){}c6.prototype.nodeType=t6;gs(c6,Yt);function zb(){}zb.prototype.serializeToString=function(e,t,a,n){return Eb.call(e,t,a,n)};Yt.prototype.toString=Eb;function Eb(e,t,a){var n=!!a&&!!a.requireWellFormed,s=[],i=this.nodeType==9&&this.documentElement||this,l=i.prefix,f=i.namespaceURI;if(f&&l==null){var l=i.lookupPrefix(f);if(l==null)var c=[{namespace:f,prefix:null}]}return h6(this,s,e,t,c,n),s.join("")}function Ab(e,t,a){var n=e.prefix||"",s=e.namespaceURI;if(!s)return!1;if(n==="xml"&&s===Qc.XML||s===Qc.XMLNS)return!1;var i=a.length;while(i--){var l=a[i];if(l.prefix===n)return l.namespace!==s}return!0}function Z2(e,t,a){e.push(" ",t,'="',a.replace(/[<>&"\t\n\r]/g,Mb),'"')}function h6(e,t,a,n,s,i){if(!s)s=[];gn(e,{ns:s,isHTML:a},{enter:function(l,f){var{ns:c,isHTML:h}=f;if(n)if(l=n(l),l){if(typeof l=="string")return t.push(l),null}else return null;switch(l.nodeType){case ni:var u=l.attributes,g=u.length,b=l.tagName;h=Qc.isHTML(l.namespaceURI)||h;var d=b;if(!h&&!l.prefix&&l.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 S=c.length-1;S>=0;S--){var C=c[S];if(C.prefix===""&&C.namespace===l.namespaceURI){j=C.namespace;break}}if(j!==l.namespaceURI)for(var S=c.length-1;S>=0;S--){var C=c[S];if(C.namespace===l.namespaceURI){if(C.prefix)d=C.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(Ab(M,h,O)){var H=M.prefix||"",D=M.namespaceURI;Z2(t,H?"xmlns:"+H:"xmlns",D),O.push({prefix:H,namespace:D})}var N=n?n(M):M;if(N)if(typeof N==="string")t.push(N);else Z2(t,N.name,N.value)}if(b===d&&Ab(l,h,O)){var z=l.prefix||"",D=l.namespaceURI;Z2(t,z?"xmlns:"+z:"xmlns",D),O.push({prefix:z,namespace:D})}var L=l.firstChild;if(L||h&&!/^(?:meta|link|img|br|hr|input)$/i.test(b)){if(t.push(">"),h&&/^script$/i.test(b)){while(L){if(L.data)t.push(L.data);else h6(L,t,h,n,O.slice(),i);L=L.nextSibling}return t.push("</",b,">"),null}return{ns:O,isHTML:h,tag:d}}else return t.push("/>"),null;case _b:case U0:return{ns:c.slice(),isHTML:h,tag:null};case xo:return Z2(t,l.name,l.value),null;case $2:return t.push(l.data.replace(/[<&>]/g,Mb)),null;case Sb:if(i&&l.data.indexOf("]]>")!==-1)throw new Pt(Ho,'The CDATASection data contains "]]>"');return t.push("<![CDATA[",l.data.replace(/]]>/g,"]]]]><![CDATA[>"),"]]>"),null;case a6:if(i&&l.data.indexOf("-->")!==-1)throw new Pt(Ho,'The comment node data contains "-->"');return t.push("<!--",l.data,"-->"),null;case Fb:if(i){if(l.publicId&&!/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(l.publicId))throw new Pt(Ho,"DocumentType publicId is not a valid PubidLiteral");if(l.systemId&&!/^("[^"]*"|'[^']*')$/.test(l.systemId))throw new Pt(Ho,"DocumentType systemId is not a valid SystemLiteral");if(l.internalSubset&&l.internalSubset.indexOf("]>")!==-1)throw new Pt(Ho,'DocumentType internalSubset contains "]>"')}var{publicId:ee,systemId:te}=l;if(t.push("<!DOCTYPE ",l.name),ee){if(t.push(" PUBLIC ",ee),te&&te!=".")t.push(" ",te);t.push(">")}else if(te&&te!=".")t.push(" SYSTEM ",te,">");else{var J=l.internalSubset;if(J)t.push(" [",J,"]");t.push(">")}return null;case t6:if(i&&l.data.indexOf("?>")!==-1)throw new Pt(Ho,'The ProcessingInstruction data contains "?>"');return t.push("<?",l.target," ",l.data,"?>"),null;case Cb:return t.push("&",l.nodeName,";"),null;default:return t.push("??",l.nodeName),null}},exit:function(l,f){if(f&&f.tag)t.push("</",f.tag,">")}})}function lO(e,t,a){var n;return gn(t,null,{enter:function(s,i){var l=s.cloneNode(!1);if(l.ownerDocument=e,l.parentNode=null,i===null)n=l;else i.appendChild(l);var f=s.nodeType===xo||a;return f?l:null}}),n}function Ib(e,t,a){var n;return gn(t,null,{enter:function(s,i){var l=new s.constructor;for(var f in s)if(Object.prototype.hasOwnProperty.call(s,f)){var c=s[f];if(typeof c!="object"){if(c!=l[f])l[f]=c}}if(s.childNodes)l.childNodes=new G0;l.ownerDocument=e;var h=a;switch(l.nodeType){case ni:var u=s.attributes,g=l.attributes=new W2,b=u.length;g._ownerElement=l;for(var d=0;d<b;d++)l.setAttributeNode(Ib(e,u.item(d),!0));break;case xo:h=!0}if(i!==null)i.appendChild(l);else n=l;return h?l:null}}),n}function Ub(e,t,a){e[t]=a}try{if(Object.defineProperty)Object.defineProperty(Do.prototype,"length",{get:function(){return n6(this),this.$$length}}),Object.defineProperty(Yt.prototype,"textContent",{get:function(){if(this.nodeType===ni||this.nodeType===U0){var e=[];return gn(this,null,{enter:function(t){if(t.nodeType===ni||t.nodeType===U0)return!0;if(t.nodeType===t6||t.nodeType===a6)return null;e.push(t.nodeValue)}}),e.join("")}return this.nodeValue},set:function(e){switch(this.nodeType){case ni:case U0: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}}}),Ub=function(e,t,a){e["$$"+t]=a}}catch(e){}fO.DocumentType=am;fO.DOMException=Pt;fO.DOMImplementation=Tb;fO.Element=lr;fO.Node=Yt;fO.NodeList=G0;fO.walkDOM=gn;fO.XMLSerializer=zb});var Kb=Tt((bO)=>{var Gb=Jc().freeze;bO.XML_ENTITIES=Gb({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});bO.HTML_ENTITIES=Gb({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:"‌"});bO.entityMap=bO.HTML_ENTITIES});var Wb=Tt((CO)=>{var nh=Jc().NAMESPACE,m6=/[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]/,Lb=new RegExp("[\\-\\.0-9"+m6.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),Vb=new RegExp("^"+m6.source+Lb.source+"*(?::"+m6.source+Lb.source+"*)?$"),eh=0,Gl=1,Ro=2,th=3,No=4,zo=5,ah=6,sm=7;function Eo(e,t){if(this.message=e,this.locator=t,Error.captureStackTrace)Error.captureStackTrace(this,Eo)}Eo.prototype=Error();Eo.prototype.name=Eo.name;function Qb(){}Qb.prototype={parse:function(e,t,a){var n=this.domBuilder;n.startDocument(),Zb(t,t={}),jO(e,t,a,n,this.errorHandler),n.endDocument()}};function jO(e,t,a,n,s){function i($){if($>65535){$-=65536;var fe=55296+($>>10),P=56320+($&1023);return String.fromCharCode(fe,P)}else return String.fromCharCode($)}function l($){var fe=$.slice(1,-1);if(Object.hasOwnProperty.call(a,fe))return a[fe];else if(fe.charAt(0)==="#")return i(parseInt(fe.substr(1).replace("x","0x")));else return s.error("entity not found:"+$),$}function f($){if($>A){var fe=e.substring(A,$).replace(/&#?\w+;/g,l);b&&c(A),n.characters(fe,0,$-A),A=$}}function c($,fe){while($>=u&&(fe=g.exec(e)))h=fe.index,u=h+fe[0].length,b.lineNumber++;b.columnNumber=$-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 S=e.indexOf("<",A);if(S<0){if(!e.substr(A).match(/^\s*$/)){var C=n.doc,O=C.createTextNode(e.substr(A));C.appendChild(O),n.currentElement=O}return}if(S>A)f(S);switch(e.charAt(S+1)){case"/":var te=e.indexOf(">",S+3),T=e.substring(S+2,te).replace(/[ \t\n\r]+$/g,""),M=d.pop();if(te<0)T=e.substring(S+2).replace(/[\s<].*/,""),s.error("end tag name: "+T+" is not complete:"+M.tagName),te=S+1+T.length;else if(T.match(/\s</))T=T.replace(/[\s<].*/,""),s.error("end tag name: "+T+" maybe not complete"),te=S+1+T.length;var H=M.localNSMap,D=M.tagName==T,N=D||M.tagName&&M.tagName.toLowerCase()==T.toLowerCase();if(N){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(!D)s.fatalError("end tag name: "+T+" is not match the current start tagName:"+M.tagName)}else d.push(M);te++;break;case"?":b&&c(S),te=yO(e,S,n);break;case"!":b&&c(S),te=AO(e,S,n,s);break;default:b&&c(S);var L=new $b,ee=d[d.length-1].currentNSMap,te=qO(e,S,L,ee,l,s),J=L.length;if(!L.closed&&kO(e,te,L.tagName,j)){if(L.closed=!0,!a.nbsp)s.warning("unclosed xml attribute")}if(b&&J){var ae=Yb(b,{});for(var Q=0;Q<J;Q++){var Y=L[Q];c(Y.offset),Y.locator=Yb(b,{})}if(n.locator=ae,Jb(L,n,ee))d.push(L);n.locator=b}else if(Jb(L,n,ee))d.push(L);if(nh.isHTML(L.uri)&&!L.closed)te=vO(e,te,L.tagName,l,n);else te++}}catch($){if($ instanceof Eo)throw $;s.error("element parse error: "+$),te=-1}if(te>A)A=te;else f(Math.max(S,A)+1)}}function Yb(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function qO(e,t,a,n,s,i){function l(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 f,c,h=++t,u=eh;while(!0){var g=e.charAt(h);switch(g){case"=":if(u===Gl)f=e.slice(t,h),u=th;else if(u===Ro)u=th;else throw Error("attribute equal must after attrName");break;case"'":case'"':if(u===th||u===Gl){if(u===Gl)i.warning('attribute value must after "="'),f=e.slice(t,h);if(t=h+1,h=e.indexOf(g,t),h>0)c=e.slice(t,h),l(f,c,t-1),u=zo;else throw Error("attribute value no end '"+g+"' match")}else if(u==No)c=e.slice(t,h),l(f,c,t),i.warning('attribute "'+f+'" missed start quot('+g+")!!"),t=h+1,u=zo;else throw Error('attribute value must after "="');break;case"/":switch(u){case eh:a.setTagName(e.slice(t,h));case zo:case ah:case sm:u=sm,a.closed=!0;case No:case Gl:break;case Ro:a.closed=!0;break;default:throw Error("attribute invalid close char('/')")}break;case"":if(i.error("unexpected end of input"),u==eh)a.setTagName(e.slice(t,h));return h;case">":switch(u){case eh:a.setTagName(e.slice(t,h));case zo:case ah:case sm:break;case No:case Gl:if(c=e.slice(t,h),c.slice(-1)==="/")a.closed=!0,c=c.slice(0,-1);case Ro:if(u===Ro)c=f;if(u==No)i.warning('attribute "'+c+'" missed quot(")!'),l(f,c,t);else{if(!nh.isHTML(n[""])||!c.match(/^(?:disabled|checked|selected)$/i))i.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!');l(c,c,t)}break;case th:throw Error("attribute value missed!!")}return h;case"€":g=" ";default:if(g<=" ")switch(u){case eh:a.setTagName(e.slice(t,h)),u=ah;break;case Gl:f=e.slice(t,h),u=Ro;break;case No:var c=e.slice(t,h);i.warning('attribute "'+c+'" missed quot(")!!'),l(f,c,t);case zo:u=ah;break}else switch(u){case Ro:var b=a.tagName;if(!nh.isHTML(n[""])||!f.match(/^(?:disabled|checked|selected)$/i))i.warning('attribute "'+f+'" missed value!! "'+f+'" instead2!!');l(f,f,t),t=h,u=Gl;break;case zo:i.warning('attribute space is required"'+f+'"!!');case ah:u=Gl,t=h;break;case th:u=No,t=h;break;case sm:throw Error("elements closed character '/' and '>' must be connected to")}}h++}}function Jb(e,t,a){var n=e.tagName,s=null,g=e.length;while(g--){var i=e[g],l=i.qName,f=i.value,b=l.indexOf(":");if(b>0)var c=i.prefix=l.slice(0,b),h=l.slice(b+1),u=c==="xmlns"&&h;else h=l,c=null,u=l==="xmlns"&&"";if(i.localName=h,u!==!1){if(s==null)s={},Zb(a,a={});a[u]=s[u]=f,i.uri=nh.XMLNS,t.startPrefixMapping(u,f)}}var g=e.length;while(g--){i=e[g];var c=i.prefix;if(c){if(c==="xml")i.uri=nh.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 vO(e,t,a,n,s){if(/^(?:script|textarea)$/i.test(a)){var i=e.indexOf("</"+a+">",t),l=e.substring(t+1,i);if(/[&<]/.test(l)){if(/^script$/i.test(a))return s.characters(l,0,l.length),i;return l=l.replace(/&#?\w+;/g,n),s.characters(l,0,l.length),i}}return t+1}function kO(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 Zb(e,t){for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a))t[a]=e[a]}function AO(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 l=SO(e,t),f=l.length;if(f>1&&/!doctype/i.test(l[0][0])){var c=l[1][0],h=!1,u=!1;if(f>3){if(/^public$/i.test(l[2][0]))h=l[3][0],u=f>4&&l[4][0];else if(/^system$/i.test(l[2][0]))u=l[3][0]}var g=l[f-1];return a.startDTD(c,h,u),a.endDTD(),g.index+g[0].length}}return-1}function yO(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 $b(){this.attributeNames={}}$b.prototype={setTagName:function(e){if(!Vb.test(e))throw Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,a){if(!Vb.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 SO(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}CO.XMLReader=Qb;CO.ParseError=Eo});var iw=Tt((DO)=>{var OO=Jc(),BO=u6(),Pb=Kb(),aw=Wb(),TO=BO.DOMImplementation,ew=OO.NAMESPACE,MO=aw.ParseError,HO=aw.XMLReader;function nw(e){return e.replace(/\r[\n\u0085]/g,`
12
- `).replace(/[\r\u0085\u2028]/g,`
13
- `)}function sw(e){this.options=e||{locator:{}}}sw.prototype.parseFromString=function(e,t){var a=this.options,n=new HO,s=a.domBuilder||new sh,i=a.errorHandler,l=a.locator,f=a.xmlns||{},c=/\/x?html?$/.test(t),h=c?Pb.HTML_ENTITIES:Pb.XML_ENTITIES;if(l)s.setDocumentLocator(l);if(n.errorHandler=xO(i,s,l),n.domBuilder=a.domBuilder||s,c)f[""]=ew.HTML;f.xml=f.xml||ew.XML;var u=a.normalizeLineEndings||nw;if(e&&typeof e==="string")n.parse(u(e),f,h);else n.errorHandler.error("invalid doc source");return s.doc};function xO(e,t,a){if(!e){if(t instanceof sh)return t;e=t}var n={},s=e instanceof Function;a=a||{};function i(l){var f=e[l];if(!f&&s)f=e.length==2?function(c){e(l,c)}:e;n[l]=f&&function(c){f("[xmldom "+l+"]\t"+c+g6(a))}||function(){}}return i("warning"),i("error"),i("fatalError"),n}function sh(){this.cdata=!1}function Io(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}sh.prototype={startDocument:function(){if(this.doc=new TO().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),l=n.length;im(this,i),this.currentElement=i,this.locator&&Io(this.locator,i);for(var f=0;f<l;f++){var e=n.getURI(f),c=n.getValue(f),a=n.getQName(f),h=s.createAttributeNS(e,a);this.locator&&Io(n.getLocator(f),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&&Io(this.locator,a),im(this,a)},ignorableWhitespace:function(e,t,a){},characters:function(e,t,a){if(e=tw.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&&Io(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=tw.apply(this,arguments);var n=this.doc.createComment(e);this.locator&&Io(this.locator,n),im(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&&Io(this.locator,s),im(this,s),this.doc.doctype=s}},warning:function(e){console.warn("[xmldom warning]\t"+e,g6(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,g6(this.locator))},fatalError:function(e){throw new MO(e,this.locator)}};function g6(e){if(e)return`
14
- @`+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function tw(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){sh.prototype[e]=function(){return null}});function im(e,t){if(!e.currentElement)e.doc.appendChild(t);else e.currentElement.appendChild(t)}DO.__DOMHandler=sh;DO.normalizeLineEndings=nw;DO.DOMParser=sw});var yw=Tt((YI,Aw)=>{var kw=Math.pow(2,32),MB=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)*kw+t.getUint32(4)};Aw.exports={getUint64:MB,MAX_UINT32:kw}});var _w=Tt((JI,Cw)=>{var Sw=yw().getUint64,HB=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=Sw(e.subarray(n)),a.firstOffset=Sw(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};Cw.exports=HB});var Uw=Tt((dU,Iw)=>{var y6=90000,S6,C6,cm,_6,Nw,zw,Ew;S6=function(e){return e*y6};C6=function(e,t){return e*t};cm=function(e){return e/y6};_6=function(e,t){return e/t};Nw=function(e,t){return S6(_6(e,t))};zw=function(e,t){return C6(cm(e),t)};Ew=function(e,t,a){return cm(a?e:e-t)};Iw.exports={ONE_SECOND_IN_TS:y6,secondsToVideoTs:S6,secondsToAudioTs:C6,videoTsToSeconds:cm,audioTsToSeconds:_6,audioTsToVideoTs:Nw,videoTsToAudioTs:zw,metadataTsToSeconds:Ew}});var xk=Tt((FY,Vh)=>{Hk();var Ig=Mt(Za());Vh.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 l(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 y=m.return;if(y===null)break;var F=y.alternate;if(F===null){if(w=y.return,w!==null){m=w;continue}break}if(y.child===F.child){for(F=y.child;F;){if(F===m)return i(y),r;if(F===w)return i(y),o;F=F.sibling}throw Error(n(188))}if(m.return!==w.return)m=y,w=F;else{for(var x=!1,V=y.child;V;){if(V===m){x=!0,m=y,w=F;break}if(V===w){x=!0,w=y,m=F;break}V=V.sibling}if(!x){for(V=F.child;V;){if(V===m){x=!0,m=F,w=y;break}if(V===w){x=!0,w=F,m=y;break}V=V.sibling}if(!x)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 f(r){var o=r.tag;if(o===5||o===26||o===27||o===6)return r;for(r=r.child;r!==null;){if(o=f(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=X8&&r[X8]||r["@@iterator"],typeof r==="function"?r:null}function u(r){if(r==null)return null;if(typeof r==="function")return r.$$typeof===yS?null:r.displayName||r.name||null;if(typeof r==="string")return r;switch(r){case so:return"Fragment";case I5:return"Profiler";case U8:return"StrictMode";case G5:return"Suspense";case X5:return"SuspenseList";case L5:return"Activity"}if(typeof r==="object")switch(r.$$typeof){case no:return"Portal";case _l:return r.displayName||"Context";case G8:return(r._context.displayName||"Context")+".Consumer";case U5:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case K5:return o=r.displayName||null,o!==null?o:u(r.type)||"Memo";case Fl: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>fo||(r.current=$5[fo],$5[fo]=null,fo--)}function d(r,o){fo++,$5[fo]=r.current,r.current=o}function j(r){return r>>>=0,r===0?32:31-(WC(r)/PC|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 S(r,o,m){var w=r.pendingLanes;if(w===0)return 0;var y=0,F=r.suspendedLanes,x=r.pingedLanes;r=r.warmLanes;var V=w&134217727;return V!==0?(w=V&~F,w!==0?y=A(w):(x&=V,x!==0?y=A(x):m||(m=V&~r,m!==0&&(y=A(m))))):(V=w&~F,V!==0?y=A(V):x!==0?y=A(x):m||(m=w&~r,m!==0&&(y=A(m)))),y===0?0:o!==0&&o!==y&&(o&F)===0&&(F=y&-y,m=o&-o,F>=m||F===32&&(m&4194048)!==0)?o:y}function C(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=d2;return d2<<=1,(d2&62914560)===0&&(d2=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 D(r,o,m,w,y,F){var x=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:V,expirationTimes:oe,hiddenUpdates:ke}=r;for(m=x&~m;0<m;){var Me=31-Bs(m),_e=1<<Me;V[Me]=0,oe[Me]=-1;var Ne=ke[Me];if(Ne!==null)for(ke[Me]=null,Me=0;Me<Ne.length;Me++){var mt=Ne[Me];mt!==null&&(mt.lane&=-536870913)}m&=~_e}w!==0&&N(r,w,0),F!==0&&y===0&&r.tag!==0&&(r.suspendedLanes|=F&~(x&~o))}function N(r,o,m){r.pendingLanes|=o,r.suspendedLanes&=~o;var w=31-Bs(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-Bs(m),y=1<<w;y&o|r[w]&o&&(r[w]|=o),m&=~y}}function L(r,o){var m=o&-o;return m=(m&42)!==0?1:ee(m),(m&(r.suspendedLanes|o))!==0?0:m}function ee(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 te(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function J(r){if(typeof s_==="function"&&i_(r),Ts&&typeof Ts.setStrictMode==="function")try{Ts.setStrictMode(Cc,r)}catch(o){}}function ae(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}function Q(r){if(e3===void 0)try{throw Error()}catch(m){var o=m.stack.trim().match(/\n( *(at )?)/);e3=o&&o[1]||"",pp=-1<m.stack.indexOf(`
15
- at`)?" (<anonymous>)":-1<m.stack.indexOf("@")?"@unknown:0:0":""}return`
16
- `+e3+r+pp}function Y(r,o){if(!r||t3)return"";t3=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(o){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(mt){var Ne=mt}Reflect.construct(r,[],_e)}else{try{_e.call()}catch(mt){Ne=mt}r.call(_e.prototype)}}else{try{throw Error()}catch(mt){Ne=mt}(_e=r())&&typeof _e.catch==="function"&&_e.catch(function(){})}}catch(mt){if(mt&&Ne&&typeof mt.stack==="string")return[mt.stack,Ne.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=w.DetermineComponentFrameRoot(),x=F[0],V=F[1];if(x&&V){var oe=x.split(`
17
- `),ke=V.split(`
18
- `);for(y=w=0;w<oe.length&&!oe[w].includes("DetermineComponentFrameRoot");)w++;for(;y<ke.length&&!ke[y].includes("DetermineComponentFrameRoot");)y++;if(w===oe.length||y===ke.length)for(w=oe.length-1,y=ke.length-1;1<=w&&0<=y&&oe[w]!==ke[y];)y--;for(;1<=w&&0<=y;w--,y--)if(oe[w]!==ke[y]){if(w!==1||y!==1)do if(w--,y--,0>y||oe[w]!==ke[y]){var Me=`
19
- `+oe[w].replace(" at new "," at ");return r.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",r.displayName)),Me}while(1<=w&&0<=y);break}}}finally{t3=!1,Error.prepareStackTrace=m}return(m=r?r.displayName||r.name:"")?Q(m):""}function $(r,o){switch(r.tag){case 26:case 27:case 5:return Q(r.type);case 16:return Q("Lazy");case 13:return r.child!==o&&o!==null?Q("Suspense Fallback"):Q("Suspense");case 19:return Q("SuspenseList");case 0:case 15:return Y(r.type,!1);case 11:return Y(r.type.render,!1);case 1:return Y(r.type,!0);case 31:return Q("Activity");default:return""}}function fe(r){try{var o="",m=null;do o+=$(r,m),m=r,r=r.return;while(r);return o}catch(w){return`
20
- Error generating stack: `+w.message+`
21
- `+w.stack}}function P(r,o){if(typeof r==="object"&&r!==null){var m=bp.get(r);if(m!==void 0)return m;return o={value:r,source:o,stack:fe(o)},bp.set(r,o),o}return{value:r,source:o,stack:fe(o)}}function qe(r,o){oo[co++]=_c,oo[co++]=q2,q2=r,_c=o}function be(r,o,m){Ws[Ps++]=Gi,Ws[Ps++]=Xi,Ws[Ps++]=Ol,Ol=r;var w=Gi;r=Xi;var y=32-Bs(w)-1;w&=~(1<<y),m+=1;var F=32-Bs(o)+y;if(30<F){var x=y-y%5;F=(w&(1<<x)-1).toString(32),w>>=x,y-=x,Gi=1<<32-Bs(o)+y|m<<y|w,Xi=F+r}else Gi=1<<F|m<<y|w,Xi=r}function me(r){r.return!==null&&(qe(r,1),be(r,1,0))}function de(r){for(;r===q2;)q2=oo[--co],oo[co]=null,_c=oo[--co],oo[co]=null;for(;r===Ol;)Ol=Ws[--Ps],Ws[Ps]=null,Xi=Ws[--Ps],Ws[Ps]=null,Gi=Ws[--Ps],Ws[Ps]=null}function ye(r,o){Ws[Ps++]=Gi,Ws[Ps++]=Xi,Ws[Ps++]=Ol,Gi=o.id,Xi=o.overflow,Ol=r}function xe(r,o){d(Bl,o),d(Fc,r),d(Cn,null),r=_S(o),b(Cn),d(Cn,r)}function Qe(){b(Cn),b(Fc),b(Bl)}function ht(r){r.memoizedState!==null&&d(v2,r);var o=Cn.current,m=FS(o,r.type);o!==m&&(d(Fc,r),d(Cn,m))}function Oe(r){Fc.current===r&&(b(Cn),b(Fc)),v2.current===r&&(b(v2),T0?Xf._currentValue=io:Xf._currentValue2=io)}function Ge(r){var o=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw $e(P(o,r)),a3}function ft(r,o){if(!En)throw Error(n(175));FC(r.stateNode,r.type,r.memoizedProps,o,r)||Ge(r,!0)}function Ie(r){for(_n=r.return;_n;)switch(_n.tag){case 5:case 31:case 13:ei=!1;return;case 27:case 3:ei=!0;return;default:_n=_n.return}}function He(r){if(!En||r!==_n)return!1;if(!Ft)return Ie(r),Ft=!0,!1;var o=r.tag;if(en?o!==3&&o!==27&&(o!==5||ap(r.type)&&!p2(r.type,r.memoizedProps))&&da&&Ge(r):o!==3&&(o!==5||ap(r.type)&&!p2(r.type,r.memoizedProps))&&da&&Ge(r),Ie(r),o===13){if(!En)throw Error(n(316));if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));da=HC(r)}else if(o===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));da=MC(r)}else da=en&&o===27?dC(r.type,da):_n?tp(r.stateNode):null;return!0}function Ze(){En&&(da=_n=null,Ft=!1)}function Je(){var r=Tl;return r!==null&&(cs===null?cs=r:cs.push.apply(cs,r),Tl=null),r}function $e(r){Tl===null?Tl=[r]:Tl.push(r)}function Xt(r,o,m){T0?(d(k2,o._currentValue),o._currentValue=m):(d(k2,o._currentValue2),o._currentValue2=m)}function $t(r){var o=k2.current;T0?r._currentValue=o:r._currentValue2=o,b(k2)}function Ka(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 Ht(r,o,m,w){var y=r.child;y!==null&&(y.return=r);for(;y!==null;){var F=y.dependencies;if(F!==null){var x=y.child;F=F.firstContext;e:for(;F!==null;){var V=F;F=y;for(var oe=0;oe<o.length;oe++)if(V.context===o[oe]){F.lanes|=m,V=F.alternate,V!==null&&(V.lanes|=m),Ka(F.return,m,r),w||(x=null);break e}F=V.next}}else if(y.tag===18){if(x=y.return,x===null)throw Error(n(341));x.lanes|=m,F=x.alternate,F!==null&&(F.lanes|=m),Ka(x,m,r),x=null}else x=y.child;if(x!==null)x.return=y;else for(x=y;x!==null;){if(x===r){x=null;break}if(y=x.sibling,y!==null){y.return=x.return,x=y;break}x=x.return}y=x}}function _a(r,o,m,w){r=null;for(var y=o,F=!1;y!==null;){if(!F){if((y.flags&524288)!==0)F=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var x=y.alternate;if(x===null)throw Error(n(387));if(x=x.memoizedProps,x!==null){var V=y.type;Ms(y.pendingProps.value,x.value)||(r!==null?r.push(V):r=[V])}}else if(y===v2.current){if(x=y.alternate,x===null)throw Error(n(387));x.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(r!==null?r.push(Xf):r=[Xf])}y=y.return}r!==null&&Ht(o,r,m,w),o.flags|=262144}function st(r){for(r=r.firstContext;r!==null;){var o=r.context;if(!Ms(T0?o._currentValue:o._currentValue2,r.memoizedValue))return!0;r=r.next}return!1}function sn(r){Kf=r,H0=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function Ot(r){return kn(Kf,r)}function Xn(r,o){return Kf===null&&sn(r),kn(r,o)}function kn(r,o){var m=T0?o._currentValue:o._currentValue2;if(o={context:o,memoizedValue:m,next:null},H0===null){if(r===null)throw Error(n(308));H0=o,r.dependencies={lanes:0,firstContext:o},r.flags|=524288}else H0=H0.next=o;return m}function Dn(){return{controller:new f_,data:new Map,refCount:0}}function Da(r){r.refCount--,r.refCount===0&&r_(o_,function(){r.controller.abort()})}function Fa(){}function Ra(r){r!==ho&&r.next===null&&(ho===null?A2=ho=r:ho=ho.next=r),y2=!0,n3||(n3=!0,Oa())}function Na(r,o){if(!s3&&y2){s3=!0;do{var m=!1;for(var w=A2;w!==null;){if(!o)if(r!==0){var y=w.pendingLanes;if(y===0)var F=0;else{var{suspendedLanes:x,pingedLanes:V}=w;F=(1<<31-Bs(42|r)+1)-1,F&=y&~(x&~V),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(m=!0,_t(w,F))}else F=St,F=S(w,w===aa?F:0,w.cancelPendingCommit!==null||w.timeoutHandle!==Gf),(F&3)===0||C(w,F)||(m=!0,_t(w,F));w=w.next}}while(m);s3=!1}}function ns(){ve()}function ve(){y2=n3=!1;var r=0;Lf!==0&&NS()&&(r=Lf);for(var o=rs(),m=null,w=A2;w!==null;){var y=w.next,F=Re(w,o);if(F===0)w.next=null,m===null?A2=y:m.next=y,y===null&&(ho=m);else if(m=w,r!==0||(F&3)!==0)y2=!0;w=y}tn!==0&&tn!==5||Na(r,!1),Lf!==0&&(Lf=0)}function Re(r,o){for(var{suspendedLanes:m,pingedLanes:w,expirationTimes:y}=r,F=r.pendingLanes&-62914561;0<F;){var x=31-Bs(F),V=1<<x,oe=y[x];if(oe===-1){if((V&m)===0||(V&w)!==0)y[x]=O(V,o)}else oe<=o&&(r.expiredLanes|=V);F&=~V}if(o=aa,m=St,m=S(r,r===o?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==Gf),w=r.callbackNode,m===0||r===o&&(Lt===2||Lt===9)||r.cancelPendingCommit!==null)return w!==null&&w!==null&&W5(w),r.callbackNode=null,r.callbackPriority=0;if((m&3)===0||C(r,m)){if(o=m&-m,o===r.callbackPriority)return o;switch(w!==null&&W5(w),te(m)){case 2:case 8:m=a_;break;case 32:m=P5;break;case 268435456:m=n_;break;default:m=P5}return w=et.bind(null,r),m=j2(m,w),r.callbackPriority=o,r.callbackNode=m,o}return w!==null&&w!==null&&W5(w),r.callbackPriority=2,r.callbackNode=null,2}function et(r,o){if(tn!==0&&tn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var m=r.callbackNode;if(B0()&&r.callbackNode!==m)return null;var w=St;if(w=S(r,r===aa?w:0,r.cancelPendingCommit!==null||r.timeoutHandle!==Gf),w===0)return null;return vc(r,w,o),Re(r,rs()),r.callbackNode!=null&&r.callbackNode===m?et.bind(null,r):null}function _t(r,o){if(B0())return null;vc(r,o,!0)}function Oa(){KS?LS(function(){(kt&6)!==0?j2(mp,ns):ve()}):j2(mp,ns)}function ia(){if(Lf===0){var r=uo;r===0&&(r=b2,b2<<=1,(b2&261888)===0&&(b2=256)),Lf=r}return Lf}function ln(r,o){if(Oc===null){var m=Oc=[];i3=0,uo=ia(),mo={status:"pending",value:void 0,then:function(w){m.push(w)}}}return i3++,o.then(Pa,Pa),o}function Pa(){if(--i3===0&&Oc!==null){mo!==null&&(mo.status="fulfilled");var r=Oc;Oc=null,uo=0,mo=null;for(var o=0;o<r.length;o++)(0,r[o])()}}function Vs(r,o){var m=[],w={status:"pending",value:null,reason:null,then:function(y){m.push(y)}};return r.then(function(){w.status="fulfilled",w.value=o;for(var y=0;y<m.length;y++)(0,m[y])(o)},function(y){w.status="rejected",w.reason=y;for(y=0;y<m.length;y++)(0,m[y])(void 0)}),w}function ze(){var r=Vf.current;return r!==null?r:aa.pooledCache}function Xe(r,o){o===null?d(Vf,Vf.current):d(Vf,o.pool)}function Ae(){var r=ze();return r===null?null:{parent:T0?ja._currentValue:ja._currentValue2,pool:r}}function Ce(r,o){if(Ms(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 y=m[w];if(!l_.call(o,y)||!Ms(r[y],o[y]))return!1}return!0}function Ue(r){return r=r.status,r==="fulfilled"||r==="rejected"}function dt(r,o,m){switch(m=r[m],m===void 0?r.push(o):m!==o&&(o.then(Fa,Fa),o=m),o.status){case"fulfilled":return o.value;case"rejected":throw r=o.reason,Hr(r),r;default:if(typeof o.status==="string")o.then(Fa,Fa);else{if(r=aa,r!==null&&100<r.shellSuspendCounter)throw Error(n(482));r=o,r.status="pending",r.then(function(w){if(o.status==="pending"){var y=o;y.status="fulfilled",y.value=w}},function(w){if(o.status==="pending"){var y=o;y.status="rejected",y.reason=w}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw r=o.reason,Hr(r),r}throw Yf=o,go}}function ba(r){try{var o=r._init;return o(r._payload)}catch(m){if(m!==null&&typeof m==="object"&&typeof m.then==="function")throw Yf=m,go;throw m}}function ji(){if(Yf===null)throw Error(n(459));var r=Yf;return Yf=null,r}function Hr(r){if(r===go||r===S2)throw Error(n(483))}function xr(r){var o=Bc;return Bc+=1,po===null&&(po=[]),dt(po,r,o)}function cf(r,o){o=o.props.ref,r.ref=o!==void 0?o:null}function Dr(r,o){if(o.$$typeof===kS)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 z1(r){function o(ie,ne){if(r){var re=ie.deletions;re===null?(ie.deletions=[ne],ie.flags|=16):re.push(ne)}}function m(ie,ne){if(!r)return null;for(;ne!==null;)o(ie,ne),ne=ne.sibling;return null}function w(ie){for(var ne=new Map;ie!==null;)ie.key!==null?ne.set(ie.key,ie):ne.set(ie.index,ie),ie=ie.sibling;return ne}function y(ie,ne){return ie=le(ie,ne),ie.index=0,ie.sibling=null,ie}function F(ie,ne,re){if(ie.index=re,!r)return ie.flags|=1048576,ne;if(re=ie.alternate,re!==null)return re=re.index,re<ne?(ie.flags|=67108866,ne):re;return ie.flags|=67108866,ne}function x(ie){return r&&ie.alternate===null&&(ie.flags|=67108866),ie}function V(ie,ne,re,Fe){if(ne===null||ne.tag!==6)return ne=tt(re,ie.mode,Fe),ne.return=ie,ne;return ne=y(ne,re),ne.return=ie,ne}function oe(ie,ne,re,Fe){var Pe=re.type;if(Pe===so)return Me(ie,ne,re.props.children,Fe,re.key);if(ne!==null&&(ne.elementType===Pe||typeof Pe==="object"&&Pe!==null&&Pe.$$typeof===Fl&&ba(Pe)===ne.type))return ne=y(ne,re.props),cf(ne,re),ne.return=ie,ne;return ne=ue(re.type,re.key,re.props,null,ie.mode,Fe),cf(ne,re),ne.return=ie,ne}function ke(ie,ne,re,Fe){if(ne===null||ne.tag!==4||ne.stateNode.containerInfo!==re.containerInfo||ne.stateNode.implementation!==re.implementation)return ne=Sn(re,ie.mode,Fe),ne.return=ie,ne;return ne=y(ne,re.children||[]),ne.return=ie,ne}function Me(ie,ne,re,Fe,Pe){if(ne===null||ne.tag!==7)return ne=Ke(re,ie.mode,Fe,Pe),ne.return=ie,ne;return ne=y(ne,re),ne.return=ie,ne}function _e(ie,ne,re){if(typeof ne==="string"&&ne!==""||typeof ne==="number"||typeof ne==="bigint")return ne=tt(""+ne,ie.mode,re),ne.return=ie,ne;if(typeof ne==="object"&&ne!==null){switch(ne.$$typeof){case m2:return re=ue(ne.type,ne.key,ne.props,null,ie.mode,re),cf(re,ne),re.return=ie,re;case no:return ne=Sn(ne,ie.mode,re),ne.return=ie,ne;case Fl:return ne=ba(ne),_e(ie,ne,re)}if(g2(ne)||h(ne))return ne=Ke(ne,ie.mode,re,null),ne.return=ie,ne;if(typeof ne.then==="function")return _e(ie,xr(ne),re);if(ne.$$typeof===_l)return _e(ie,Xn(ie,ne),re);Dr(ie,ne)}return null}function Ne(ie,ne,re,Fe){var Pe=ne!==null?ne.key:null;if(typeof re==="string"&&re!==""||typeof re==="number"||typeof re==="bigint")return Pe!==null?null:V(ie,ne,""+re,Fe);if(typeof re==="object"&&re!==null){switch(re.$$typeof){case m2:return re.key===Pe?oe(ie,ne,re,Fe):null;case no:return re.key===Pe?ke(ie,ne,re,Fe):null;case Fl:return re=ba(re),Ne(ie,ne,re,Fe)}if(g2(re)||h(re))return Pe!==null?null:Me(ie,ne,re,Fe,null);if(typeof re.then==="function")return Ne(ie,ne,xr(re),Fe);if(re.$$typeof===_l)return Ne(ie,ne,Xn(ie,re),Fe);Dr(ie,re)}return null}function mt(ie,ne,re,Fe,Pe){if(typeof Fe==="string"&&Fe!==""||typeof Fe==="number"||typeof Fe==="bigint")return ie=ie.get(re)||null,V(ne,ie,""+Fe,Pe);if(typeof Fe==="object"&&Fe!==null){switch(Fe.$$typeof){case m2:return ie=ie.get(Fe.key===null?re:Fe.key)||null,oe(ne,ie,Fe,Pe);case no:return ie=ie.get(Fe.key===null?re:Fe.key)||null,ke(ne,ie,Fe,Pe);case Fl:return Fe=ba(Fe),mt(ie,ne,re,Fe,Pe)}if(g2(Fe)||h(Fe))return ie=ie.get(re)||null,Me(ne,ie,Fe,Pe,null);if(typeof Fe.then==="function")return mt(ie,ne,re,xr(Fe),Pe);if(Fe.$$typeof===_l)return mt(ie,ne,re,Xn(ne,Fe),Pe);Dr(ne,Fe)}return null}function Fn(ie,ne,re,Fe){for(var Pe=null,qa=null,nt=ne,xt=ne=0,mn=null;nt!==null&&xt<re.length;xt++){nt.index>xt?(mn=nt,nt=null):mn=nt.sibling;var Dt=Ne(ie,nt,re[xt],Fe);if(Dt===null){nt===null&&(nt=mn);break}r&&nt&&Dt.alternate===null&&o(ie,nt),ne=F(Dt,ne,xt),qa===null?Pe=Dt:qa.sibling=Dt,qa=Dt,nt=mn}if(xt===re.length)return m(ie,nt),Ft&&qe(ie,xt),Pe;if(nt===null){for(;xt<re.length;xt++)nt=_e(ie,re[xt],Fe),nt!==null&&(ne=F(nt,ne,xt),qa===null?Pe=nt:qa.sibling=nt,qa=nt);return Ft&&qe(ie,xt),Pe}for(nt=w(nt);xt<re.length;xt++)mn=mt(nt,ie,xt,re[xt],Fe),mn!==null&&(r&&mn.alternate!==null&&nt.delete(mn.key===null?xt:mn.key),ne=F(mn,ne,xt),qa===null?Pe=mn:qa.sibling=mn,qa=mn);return r&&nt.forEach(function(Nl){return o(ie,Nl)}),Ft&&qe(ie,xt),Pe}function Nc(ie,ne,re,Fe){if(re==null)throw Error(n(151));for(var Pe=null,qa=null,nt=ne,xt=ne=0,mn=null,Dt=re.next();nt!==null&&!Dt.done;xt++,Dt=re.next()){nt.index>xt?(mn=nt,nt=null):mn=nt.sibling;var Nl=Ne(ie,nt,Dt.value,Fe);if(Nl===null){nt===null&&(nt=mn);break}r&&nt&&Nl.alternate===null&&o(ie,nt),ne=F(Nl,ne,xt),qa===null?Pe=Nl:qa.sibling=Nl,qa=Nl,nt=mn}if(Dt.done)return m(ie,nt),Ft&&qe(ie,xt),Pe;if(nt===null){for(;!Dt.done;xt++,Dt=re.next())Dt=_e(ie,Dt.value,Fe),Dt!==null&&(ne=F(Dt,ne,xt),qa===null?Pe=Dt:qa.sibling=Dt,qa=Dt);return Ft&&qe(ie,xt),Pe}for(nt=w(nt);!Dt.done;xt++,Dt=re.next())Dt=mt(nt,ie,xt,Dt.value,Fe),Dt!==null&&(r&&Dt.alternate!==null&&nt.delete(Dt.key===null?xt:Dt.key),ne=F(Dt,ne,xt),qa===null?Pe=Dt:qa.sibling=Dt,qa=Dt);return r&&nt.forEach(function(m_){return o(ie,m_)}),Ft&&qe(ie,xt),Pe}function $f(ie,ne,re,Fe){if(typeof re==="object"&&re!==null&&re.type===so&&re.key===null&&(re=re.props.children),typeof re==="object"&&re!==null){switch(re.$$typeof){case m2:e:{for(var Pe=re.key;ne!==null;){if(ne.key===Pe){if(Pe=re.type,Pe===so){if(ne.tag===7){m(ie,ne.sibling),Fe=y(ne,re.props.children),Fe.return=ie,ie=Fe;break e}}else if(ne.elementType===Pe||typeof Pe==="object"&&Pe!==null&&Pe.$$typeof===Fl&&ba(Pe)===ne.type){m(ie,ne.sibling),Fe=y(ne,re.props),cf(Fe,re),Fe.return=ie,ie=Fe;break e}m(ie,ne);break}else o(ie,ne);ne=ne.sibling}re.type===so?(Fe=Ke(re.props.children,ie.mode,Fe,re.key),Fe.return=ie,ie=Fe):(Fe=ue(re.type,re.key,re.props,null,ie.mode,Fe),cf(Fe,re),Fe.return=ie,ie=Fe)}return x(ie);case no:e:{for(Pe=re.key;ne!==null;){if(ne.key===Pe)if(ne.tag===4&&ne.stateNode.containerInfo===re.containerInfo&&ne.stateNode.implementation===re.implementation){m(ie,ne.sibling),Fe=y(ne,re.children||[]),Fe.return=ie,ie=Fe;break e}else{m(ie,ne);break}else o(ie,ne);ne=ne.sibling}Fe=Sn(re,ie.mode,Fe),Fe.return=ie,ie=Fe}return x(ie);case Fl:return re=ba(re),$f(ie,ne,re,Fe)}if(g2(re))return Fn(ie,ne,re,Fe);if(h(re)){if(Pe=h(re),typeof Pe!=="function")throw Error(n(150));return re=Pe.call(re),Nc(ie,ne,re,Fe)}if(typeof re.then==="function")return $f(ie,ne,xr(re),Fe);if(re.$$typeof===_l)return $f(ie,ne,Xn(ie,re),Fe);Dr(ie,re)}return typeof re==="string"&&re!==""||typeof re==="number"||typeof re==="bigint"?(re=""+re,ne!==null&&ne.tag===6?(m(ie,ne.sibling),Fe=y(ne,re),Fe.return=ie,ie=Fe):(m(ie,ne),Fe=tt(re,ie.mode,Fe),Fe.return=ie,ie=Fe),x(ie)):m(ie,ne)}return function(ie,ne,re,Fe){try{Bc=0;var Pe=$f(ie,ne,re,Fe);return po=null,Pe}catch(nt){if(nt===go||nt===S2)throw nt;var qa=t(29,nt,null,ie.mode);return qa.lanes=Fe,qa.return=ie,qa}finally{}}}function il(){for(var r=bo,o=f3=bo=0;o<r;){var m=ti[o];ti[o++]=null;var w=ti[o];ti[o++]=null;var y=ti[o];ti[o++]=null;var F=ti[o];if(ti[o++]=null,w!==null&&y!==null){var x=w.pending;x===null?y.next=y:(y.next=x.next,x.next=y),w.pending=y}F!==0&&gu(m,y,F)}}function w0(r,o,m,w){ti[bo++]=r,ti[bo++]=o,ti[bo++]=m,ti[bo++]=w,f3|=w,r.lanes|=w,r=r.alternate,r!==null&&(r.lanes|=w)}function fn(r,o,m,w){return w0(r,o,m,w),j0(r)}function d0(r,o){return w0(r,null,null,o),j0(r)}function gu(r,o,m){r.lanes|=m;var w=r.alternate;w!==null&&(w.lanes|=m);for(var y=!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||(y=!0)),r=F,F=F.return;return r.tag===3?(F=r.stateNode,y&&o!==null&&(y=31-Bs(m),r=F.hiddenUpdates,w=r[y],w===null?r[y]=[o]:w.push(o),o.lane=m|536870912),F):null}function j0(r){if(50<Rc)throw Rc=0,j3=null,Error(n(185));for(var o=r.return;o!==null;)r=o,o=r.return;return r.tag===3?r.stateNode:null}function Ss(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ll(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 yt(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Hi(r,o,m){var w=r.updateQueue;if(w===null)return null;if(w=w.shared,(kt&2)!==0){var y=w.pending;return y===null?o.next=o:(o.next=y.next,y.next=o),w.pending=o,o=j0(r),gu(r,null,m),o}return w0(r,w,o,m),j0(r)}function xi(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 fl(r,o){var{updateQueue:m,alternate:w}=r;if(w!==null&&(w=w.updateQueue,m===w)){var y=null,F=null;if(m=m.firstBaseUpdate,m!==null){do{var x={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};F===null?y=F=x:F=F.next=x,m=m.next}while(m!==null);F===null?y=F=o:F=F.next=o}else y=F=o;m={baseState:w.baseState,firstBaseUpdate:y,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 hf(){if(r3){var r=mo;if(r!==null)throw r}}function Cs(r,o,m,w){r3=!1;var y=r.updateQueue;Ml=!1;var{firstBaseUpdate:F,lastBaseUpdate:x}=y,V=y.shared.pending;if(V!==null){y.shared.pending=null;var oe=V,ke=oe.next;oe.next=null,x===null?F=ke:x.next=ke,x=oe;var Me=r.alternate;Me!==null&&(Me=Me.updateQueue,V=Me.lastBaseUpdate,V!==x&&(V===null?Me.firstBaseUpdate=ke:V.next=ke,Me.lastBaseUpdate=oe))}if(F!==null){var _e=y.baseState;x=0,Me=ke=oe=null,V=F;do{var Ne=V.lane&-536870913,mt=Ne!==V.lane;if(mt?(St&Ne)===Ne:(w&Ne)===Ne){Ne!==0&&Ne===uo&&(r3=!0),Me!==null&&(Me=Me.next={lane:0,tag:V.tag,payload:V.payload,callback:null,next:null});e:{var Fn=r,Nc=V;Ne=o;var $f=m;switch(Nc.tag){case 1:if(Fn=Nc.payload,typeof Fn==="function"){_e=Fn.call($f,_e,Ne);break e}_e=Fn;break e;case 3:Fn.flags=Fn.flags&-65537|128;case 0:if(Fn=Nc.payload,Ne=typeof Fn==="function"?Fn.call($f,_e,Ne):Fn,Ne===null||Ne===void 0)break e;_e=Yn({},_e,Ne);break e;case 2:Ml=!0}}Ne=V.callback,Ne!==null&&(r.flags|=64,mt&&(r.flags|=8192),mt=y.callbacks,mt===null?y.callbacks=[Ne]:mt.push(Ne))}else mt={lane:Ne,tag:V.tag,payload:V.payload,callback:V.callback,next:null},Me===null?(ke=Me=mt,oe=_e):Me=Me.next=mt,x|=Ne;if(V=V.next,V===null)if(V=y.shared.pending,V===null)break;else mt=V,V=mt.next,mt.next=null,y.lastBaseUpdate=mt,y.shared.pending=null}while(1);Me===null&&(oe=_e),y.baseState=oe,y.firstBaseUpdate=ke,y.lastBaseUpdate=Me,F===null&&(y.shared.lanes=0),xl|=x,r.lanes=x,r.memoizedState=_e}}function ta(r,o){if(typeof r!=="function")throw Error(n(191,r));r.call(o)}function E1(r,o){var m=r.callbacks;if(m!==null)for(r.callbacks=null,r=0;r<m.length;r++)ta(m[r],o)}function uf(r,o){r=R0,d(_2,r),d(wo,o),R0=r|o.baseLanes}function I1(){d(_2,R0),d(wo,wo.current)}function U1(){R0=_2.current,b(wo),b(_2)}function Di(r){var o=r.alternate;d(Ia,Ia.current&1),d(Hs,r),ai===null&&(o===null||wo.current!==null?ai=r:o.memoizedState!==null&&(ai=r))}function Rr(r){d(Ia,Ia.current),d(Hs,r),ai===null&&(ai=r)}function Nr(r){r.tag===22?(d(Ia,Ia.current),d(Hs,r),ai===null&&(ai=r)):Ys(r)}function Ys(){d(Ia,Ia.current),d(Hs,Hs.current)}function Rn(r){b(Hs),ai===r&&(ai=null),b(Ia)}function zr(r){for(var o=r;o!==null;){if(o.tag===13){var m=o.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||J5(m)||Q5(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 ma(){throw Error(n(321))}function rl(r,o){if(o===null)return!1;for(var m=0;m<o.length&&m<r.length;m++)if(!Ms(r[m],o[m]))return!1;return!0}function ol(r,o,m,w,y,F){return x0=F,pt=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,We.H=r===null||r.memoizedState===null?jp:o3,Qf=!1,F=m(w,y),Qf=!1,jo&&(F=cl(o,m,w,y)),G1(r),F}function G1(r){We.H=Mc;var o=Wt!==null&&Wt.next!==null;if(x0=0,Va=Wt=pt=null,F2=!1,Tc=0,qo=null,o)throw Error(n(300));r===null||Ya||(r=r.dependencies,r!==null&&st(r)&&(Ya=!0))}function cl(r,o,m,w){pt=r;var y=0;do{if(jo&&(qo=null),Tc=0,jo=!1,25<=y)throw Error(n(301));if(y+=1,Va=Wt=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=qp,F=o(m,w)}while(jo);return F}function mf(){var r=We.H,o=r.useState()[0];return o=typeof o.then==="function"?ss(o):o,r=r.useState()[0],(Wt!==null?Wt.memoizedState:null)!==r&&(pt.flags|=1024),o}function q0(){var r=O2!==0;return O2=0,r}function v0(r,o,m){o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~m}function X1(r){if(F2){for(r=r.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}F2=!1}x0=0,Va=Wt=pt=null,jo=!1,Tc=O2=0,qo=null}function rn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Va===null?pt.memoizedState=Va=r:Va=Va.next=r,Va}function wa(){if(Wt===null){var r=pt.alternate;r=r!==null?r.memoizedState:null}else r=Wt.next;var o=Va===null?pt.memoizedState:Va.next;if(o!==null)Va=o,Wt=r;else{if(r===null){if(pt.alternate===null)throw Error(n(467));throw Error(n(310))}Wt=r,r={memoizedState:Wt.memoizedState,baseState:Wt.baseState,baseQueue:Wt.baseQueue,queue:Wt.queue,next:null},Va===null?pt.memoizedState=Va=r:Va=Va.next=r}return Va}function Er(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ss(r){var o=Tc;return Tc+=1,qo===null&&(qo=[]),r=dt(qo,r,o),o=pt,(Va===null?o.memoizedState:Va.next)===null&&(o=o.alternate,We.H=o===null||o.memoizedState===null?jp:o3),r}function k0(r){if(r!==null&&typeof r==="object"){if(typeof r.then==="function")return ss(r);if(r.$$typeof===_l)return Ot(r)}throw Error(n(438,String(r)))}function K1(r){var o=null,m=pt.updateQueue;if(m!==null&&(o=m.memoCache),o==null){var w=pt.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(o={data:w.data.map(function(y){return y.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),m===null&&(m=Er(),pt.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]=AS;return o.index++,m}function _s(r,o){return typeof o==="function"?o(r):o}function hl(r){var o=wa();return Kn(o,Wt,r)}function Kn(r,o,m){var w=r.queue;if(w===null)throw Error(n(311));w.lastRenderedReducer=m;var y=r.baseQueue,F=w.pending;if(F!==null){if(y!==null){var x=y.next;y.next=F.next,F.next=x}o.baseQueue=y=F,w.pending=null}if(F=r.baseState,y===null)r.memoizedState=F;else{o=y.next;var V=x=null,oe=null,ke=o,Me=!1;do{var _e=ke.lane&-536870913;if(_e!==ke.lane?(St&_e)===_e:(x0&_e)===_e){var Ne=ke.revertLane;if(Ne===0)oe!==null&&(oe=oe.next={lane:0,revertLane:0,gesture:null,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null}),_e===uo&&(Me=!0);else if((x0&Ne)===Ne){ke=ke.next,Ne===uo&&(Me=!0);continue}else _e={lane:0,revertLane:ke.revertLane,gesture:null,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null},oe===null?(V=oe=_e,x=F):oe=oe.next=_e,pt.lanes|=Ne,xl|=Ne;_e=ke.action,Qf&&m(F,_e),F=ke.hasEagerState?ke.eagerState:m(F,_e)}else Ne={lane:_e,revertLane:ke.revertLane,gesture:ke.gesture,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null},oe===null?(V=oe=Ne,x=F):oe=oe.next=Ne,pt.lanes|=_e,xl|=_e;ke=ke.next}while(ke!==null&&ke!==o);if(oe===null?x=F:oe.next=V,!Ms(F,r.memoizedState)&&(Ya=!0,Me&&(m=mo,m!==null)))throw m;r.memoizedState=F,r.baseState=x,r.baseQueue=oe,w.lastRenderedState=F}return y===null&&(w.lanes=0),[r.memoizedState,w.dispatch]}function L1(r){var o=wa(),m=o.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=r;var{dispatch:w,pending:y}=m,F=o.memoizedState;if(y!==null){m.pending=null;var x=y=y.next;do F=r(F,x.action),x=x.next;while(x!==y);Ms(F,o.memoizedState)||(Ya=!0),o.memoizedState=F,o.baseQueue===null&&(o.baseState=F),m.lastRenderedState=F}return[F,w]}function gf(r,o,m){var w=pt,y=wa(),F=Ft;if(F){if(m===void 0)throw Error(n(407));m=m()}else m=o();var x=!Ms((Wt||y).memoizedState,m);if(x&&(y.memoizedState=m,Ya=!0),y=y.queue,Ur(A0.bind(null,w,y,r),[r]),y.getSnapshot!==o||x||Va!==null&&Va.memoizedState.tag&1){if(w.flags|=2048,ml(9,{destroy:void 0},pf.bind(null,w,y,m,o),null),aa===null)throw Error(n(349));F||(x0&127)!==0||ul(w,o,m)}return m}function ul(r,o,m){r.flags|=16384,r={getSnapshot:o,value:m},o=pt.updateQueue,o===null?(o=Er(),pt.updateQueue=o,o.stores=[r]):(m=o.stores,m===null?o.stores=[r]:m.push(r))}function pf(r,o,m,w){o.value=m,o.getSnapshot=w,Ir(o)&&V1(r)}function A0(r,o,m){return m(function(){Ir(o)&&V1(r)})}function Ir(r){var o=r.getSnapshot;r=r.value;try{var m=o();return!Ms(r,m)}catch(w){return!0}}function V1(r){var o=d0(r,2);o!==null&&cn(o,r,2)}function bf(r){var o=rn();if(typeof r==="function"){var m=r;if(r=m(),Qf){J(!0);try{m()}finally{J(!1)}}}return o.memoizedState=o.baseState=r,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:r},o}function pu(r,o,m,w){return r.baseState=m,Kn(r,Wt,typeof w==="function"?w:_s)}function x5(r,o,m,w,y){if(y0(r))throw Error(n(485));if(r=o.action,r!==null){var F={payload:y,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(x){F.listeners.push(x)}};We.T!==null?m(!0):F.isTransition=!1,w(F),m=o.pending,m===null?(F.next=o.pending=F,bu(o,F)):(F.next=m.next,o.pending=m.next=F)}}function bu(r,o){var{action:m,payload:w}=o,y=r.state;if(o.isTransition){var F=We.T,x={};We.T=x;try{var V=m(y,w),oe=We.S;oe!==null&&oe(x,V),wf(r,o,V)}catch(ke){J1(r,o,ke)}finally{F!==null&&x.types!==null&&(F.types=x.types),We.T=F}}else try{F=m(y,w),wf(r,o,F)}catch(ke){J1(r,o,ke)}}function wf(r,o,m){m!==null&&typeof m==="object"&&typeof m.then==="function"?m.then(function(w){Y1(r,o,w)},function(w){return J1(r,o,w)}):Y1(r,o,m)}function Y1(r,o,m){o.status="fulfilled",o.value=m,Q1(o),r.state=m,o=r.pending,o!==null&&(m=o.next,m===o?r.pending=null:(m=m.next,o.next=m,bu(r,m)))}function J1(r,o,m){var w=r.pending;if(r.pending=null,w!==null){w=w.next;do o.status="rejected",o.reason=m,Q1(o),o=o.next;while(o!==w)}r.action=null}function Q1(r){r=r.listeners;for(var o=0;o<r.length;o++)(0,r[o])()}function wu(r,o){return o}function Z1(r,o){if(Ft){var m=aa.formState;if(m!==null){e:{var w=pt;if(Ft){if(da){var y=bC(da,ei);if(y){da=tp(y),w=wC(y);break e}}Ge(w)}w=!1}w&&(o=m[0])}}m=rn(),m.memoizedState=m.baseState=o,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wu,lastRenderedState:o},m.queue=w,m=Cf.bind(null,pt,w),w.dispatch=m,w=bf(!1);var F=Fs.bind(null,pt,!1,w.queue);return w=rn(),y={state:o,dispatch:null,action:r,pending:null},w.queue=y,m=x5.bind(null,pt,y,F,m),y.dispatch=m,w.memoizedState=r,[o,m,!1]}function du(r){var o=wa();return df(o,Wt,r)}function df(r,o,m){if(o=Kn(r,o,wu)[0],r=hl(_s)[0],typeof o==="object"&&o!==null&&typeof o.then==="function")try{var w=ss(o)}catch(x){if(x===go)throw S2;throw x}else w=o;o=wa();var y=o.queue,F=y.dispatch;return m!==o.memoizedState&&(pt.flags|=2048,ml(9,{destroy:void 0},jf.bind(null,y,m),null)),[w,F,r]}function jf(r,o){r.action=o}function $1(r){var o=wa(),m=Wt;if(m!==null)return df(o,m,r);wa(),o=o.memoizedState,m=wa();var w=m.queue.dispatch;return m.memoizedState=r,[o,w,!1]}function ml(r,o,m,w){return r={tag:r,create:m,deps:w,inst:o,next:null},o=pt.updateQueue,o===null&&(o=Er(),pt.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 ju(){return wa().memoizedState}function qf(r,o,m,w){var y=rn();pt.flags|=r,y.memoizedState=ml(1|o,{destroy:void 0},m,w===void 0?null:w)}function vf(r,o,m,w){var y=wa();w=w===void 0?null:w;var F=y.memoizedState.inst;Wt!==null&&w!==null&&rl(w,Wt.memoizedState.deps)?y.memoizedState=ml(o,F,m,w):(pt.flags|=r,y.memoizedState=ml(1|o,F,m,w))}function qu(r,o){qf(8390656,8,r,o)}function Ur(r,o){vf(2048,8,r,o)}function D5(r){pt.flags|=4;var o=pt.updateQueue;if(o===null)o=Er(),pt.updateQueue=o,o.events=[r];else{var m=o.events;m===null?o.events=[r]:m.push(r)}}function vu(r){var o=wa().memoizedState;return D5({ref:o,nextImpl:r}),function(){if((kt&2)!==0)throw Error(n(440));return o.impl.apply(void 0,arguments)}}function ku(r,o){return vf(4,2,r,o)}function Au(r,o){return vf(4,4,r,o)}function yu(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 Su(r,o,m){m=m!==null&&m!==void 0?m.concat([r]):null,vf(4,4,yu.bind(null,o,r),m)}function kf(){}function Cu(r,o){var m=wa();o=o===void 0?null:o;var w=m.memoizedState;if(o!==null&&rl(o,w[1]))return w[0];return m.memoizedState=[r,o],r}function W1(r,o){var m=wa();o=o===void 0?null:o;var w=m.memoizedState;if(o!==null&&rl(o,w[1]))return w[0];if(w=r(),Qf){J(!0);try{r()}finally{J(!1)}}return m.memoizedState=[w,o],w}function gl(r,o,m){if(m===void 0||(x0&1073741824)!==0&&(St&261930)===0)return r.memoizedState=o;return r.memoizedState=m,r=qc(),pt.lanes|=r,xl|=r,m}function _u(r,o,m,w){if(Ms(m,o))return m;if(wo.current!==null)return r=gl(r,m,w),Ms(r,o)||(Ya=!0),r;if((x0&42)===0||(x0&1073741824)!==0&&(St&261930)===0)return Ya=!0,r.memoizedState=m;return r=qc(),pt.lanes|=r,xl|=r,o}function Fu(r,o,m,w,y){var F=M0();hn(F!==0&&8>F?F:8);var x=We.T,V={};We.T=V,Fs(r,!1,o,m);try{var oe=y(),ke=We.S;if(ke!==null&&ke(V,oe),oe!==null&&typeof oe==="object"&&typeof oe.then==="function"){var Me=Vs(oe,w);An(r,o,Me,fs(r))}else An(r,o,w,fs(r))}catch(_e){An(r,o,{then:function(){},status:"rejected",reason:_e},fs())}finally{hn(F),x!==null&&V.types!==null&&(x.types=V.types),We.T=x}}function Ou(r){var o=r.memoizedState;if(o!==null)return o;o={memoizedState:io,baseState:io,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:io},next:null};var m={};return o.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_s,lastRenderedState:m},next:null},r.memoizedState=o,r=r.alternate,r!==null&&(r.memoizedState=o),o}function P1(){return Ot(Xf)}function Bu(){return wa().memoizedState}function Af(){return wa().memoizedState}function yf(r){for(var o=r.return;o!==null;){switch(o.tag){case 24:case 3:var m=fs();r=yt(m);var w=Hi(o,r,m);w!==null&&(cn(w,o,m),xi(w,o,m)),o={cache:Dn()},r.payload=o;return}o=o.return}}function Sf(r,o,m){var w=fs();m={lane:w,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},y0(r)?ec(o,m):(m=fn(r,o,m,w),m!==null&&(cn(m,r,w),Tu(m,o,w)))}function Cf(r,o,m){var w=fs();An(r,o,m,w)}function An(r,o,m,w){var y={lane:w,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null};if(y0(r))ec(o,y);else{var F=r.alternate;if(r.lanes===0&&(F===null||F.lanes===0)&&(F=o.lastRenderedReducer,F!==null))try{var x=o.lastRenderedState,V=F(x,m);if(y.hasEagerState=!0,y.eagerState=V,Ms(V,x))return w0(r,o,y,0),aa===null&&il(),!1}catch(oe){}finally{}if(m=fn(r,o,y,w),m!==null)return cn(m,r,w),Tu(m,o,w),!0}return!1}function Fs(r,o,m,w){if(w={lane:2,revertLane:ia(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},y0(r)){if(o)throw Error(n(479))}else o=fn(r,m,w,2),o!==null&&cn(o,r,2)}function y0(r){var o=r.alternate;return r===pt||o!==null&&o===pt}function ec(r,o){jo=F2=!0;var m=r.pending;m===null?o.next=o:(o.next=m.next,m.next=o),r.pending=o}function Tu(r,o,m){if((m&4194048)!==0){var w=o.lanes;w&=r.pendingLanes,m|=w,o.lanes=m,z(r,m)}}function tc(r,o,m,w){o=r.memoizedState,m=m(w,o),m=m===null||m===void 0?o:Yn({},o,m),r.memoizedState=m,r.lanes===0&&(r.updateQueue.baseState=m)}function Mu(r,o,m,w,y,F,x){return r=r.stateNode,typeof r.shouldComponentUpdate==="function"?r.shouldComponentUpdate(w,F,x):o.prototype&&o.prototype.isPureReactComponent?!Ce(m,w)||!Ce(y,F):!0}function Hu(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&&c3.enqueueReplaceState(o,o.state,null)}function qi(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=Yn({},m));for(var y in r)m[y]===void 0&&(m[y]=r[y])}return m}function pl(r,o){try{var m=r.onUncaughtError;m(o.value,{componentStack:o.stack})}catch(w){setTimeout(function(){throw w})}}function bl(r,o,m){try{var w=r.onCaughtError;w(m.value,{componentStack:m.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function Ri(r,o,m){return m=yt(m),m.tag=3,m.payload={element:null},m.callback=function(){pl(r,o)},m}function _f(r){return r=yt(r),r.tag=3,r}function Ni(r,o,m,w){var y=m.type.getDerivedStateFromError;if(typeof y==="function"){var F=w.value;r.payload=function(){return y(F)},r.callback=function(){bl(o,m,w)}}var x=m.stateNode;x!==null&&typeof x.componentDidCatch==="function"&&(r.callback=function(){bl(o,m,w),typeof y!=="function"&&(Dl===null?Dl=new Set([this]):Dl.add(this));var V=w.stack;this.componentDidCatch(w.value,{componentStack:V!==null?V:""})})}function R5(r,o,m,w,y){if(m.flags|=32768,w!==null&&typeof w==="object"&&typeof w.then==="function"){if(o=m.alternate,o!==null&&_a(o,m,y,!0),m=Hs.current,m!==null){switch(m.tag){case 31:case 13:return ai===null?If():m.alternate===null&&Ta===0&&(Ta=3),m.flags&=-257,m.flags|=65536,m.lanes=y,w===C2?m.flags|=16384:(o=m.updateQueue,o===null?m.updateQueue=new Set([w]):o.add(w),k(r,w,y)),!1;case 22:return m.flags|=65536,w===C2?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,y)),!1}throw Error(n(435,m.tag))}return k(r,w,y),If(),!1}if(Ft)return o=Hs.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=y,w!==a3&&(r=Error(n(422),{cause:w}),$e(P(r,m)))):(w!==a3&&(o=Error(n(423),{cause:w}),$e(P(o,m))),r=r.current.alternate,r.flags|=65536,y&=-y,r.lanes|=y,w=P(w,m),y=Ri(r.stateNode,w,y),fl(r,y),Ta!==4&&(Ta=2)),!1;var F=Error(n(520),{cause:w});if(F=P(F,m),xc===null?xc=[F]:xc.push(F),Ta!==4&&(Ta=2),o===null)return!0;w=P(w,m),m=o;do{switch(m.tag){case 3:return m.flags|=65536,r=y&-y,m.lanes|=r,r=Ri(m.stateNode,w,r),fl(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"&&(Dl===null||!Dl.has(F))))return m.flags|=65536,y&=-y,m.lanes|=y,y=_f(y),Ni(y,r,m,w),fl(m,y),!1}m=m.return}while(m!==null);return!1}function La(r,o,m,w){o.child=r===null?dp(o,null,m,w):Jf(o,r.child,m,w)}function ac(r,o,m,w,y){m=m.render;var F=o.ref;if("ref"in w){var x={};for(var V in w)V!=="ref"&&(x[V]=w[V])}else x=w;if(sn(o),w=ol(r,o,m,x,F,y),V=q0(),r!==null&&!Ya)return v0(r,o,y),Js(r,o,y);return Ft&&V&&me(o),o.flags|=1,La(r,o,w,y),o.child}function Gr(r,o,m,w,y){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,xu(r,o,F,w,y);return r=ue(m.type,null,w,o,o.mode,y),r.ref=o.ref,r.return=o,o.child=r}if(F=r.child,!lc(r,y)){var x=F.memoizedProps;if(m=m.compare,m=m!==null?m:Ce,m(x,w)&&r.ref===o.ref)return Js(r,o,y)}return o.flags|=1,r=le(F,w),r.ref=o.ref,r.return=o,o.child=r}function xu(r,o,m,w,y){if(r!==null){var F=r.memoizedProps;if(Ce(F,w)&&r.ref===o.ref)if(Ya=!1,o.pendingProps=w=F,lc(r,y))(r.flags&131072)!==0&&(Ya=!0);else return o.lanes=r.lanes,Js(r,o,y)}return Vr(r,o,m,w,y)}function Du(r,o,m,w){var y=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(y=0;w!==null;)y=y|w.lanes|w.childLanes,w=w.sibling;w=y&~F}else w=0,o.child=null;return Of(r,o,F,m,w)}if((m&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},r!==null&&Xe(o,F!==null?F.cachePool:null),F!==null?uf(o,F):I1(),Nr(o);else return w=o.lanes=536870912,Of(r,o,F!==null?F.baseLanes|m:m,m,w)}else F!==null?(Xe(o,F.cachePool),uf(o,F),Ys(o),o.memoizedState=null):(r!==null&&Xe(o,null),I1(),Ys(o));return La(r,o,y,m),o.child}function Ff(r,o){return r!==null&&r.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function Of(r,o,m,w,y){var F=ze();return F=F===null?null:{parent:T0?ja._currentValue:ja._currentValue2,pool:F},o.memoizedState={baseLanes:m,cachePool:F},r!==null&&Xe(o,null),I1(),Nr(o),r!==null&&_a(r,o,w,!0),o.childLanes=y,null}function Xr(r,o){return o=Hf({mode:o.mode,children:o.children},r.mode),o.ref=r.ref,r.child=o,o.return=r,o}function Kr(r,o,m){return Jf(o,r.child,null,m),r=Xr(o,o.pendingProps),r.flags|=2,Rn(o),o.memoizedState=null,r}function N5(r,o,m){var w=o.pendingProps,y=(o.flags&128)!==0;if(o.flags&=-129,r===null){if(Ft){if(w.mode==="hidden")return r=Xr(o,w),o.lanes=536870912,Ff(null,r);if(Rr(o),(r=da)?(r=CC(r,ei),r!==null&&(o.memoizedState={dehydrated:r,treeContext:Ol!==null?{id:Gi,overflow:Xi}:null,retryLane:536870912,hydrationErrors:null},m=Ea(r),m.return=o,o.child=m,_n=o,da=null)):r=null,r===null)throw Ge(o);return o.lanes=536870912,null}return Xr(o,w)}var F=r.memoizedState;if(F!==null){var x=F.dehydrated;if(Rr(o),y)if(o.flags&256)o.flags&=-257,o=Kr(r,o,m);else if(o.memoizedState!==null)o.child=r.child,o.flags|=128,o=null;else throw Error(n(558));else if(Ya||_a(r,o,m,!1),y=(m&r.childLanes)!==0,Ya||y){if(w=aa,w!==null&&(x=L(w,m),x!==0&&x!==F.retryLane))throw F.retryLane=x,d0(r,x),cn(w,r,x),h3;If(),o=Kr(r,o,m)}else r=F.treeContext,En&&(da=vC(x),_n=o,Ft=!0,Tl=null,ei=!1,r!==null&&ye(o,r)),o=Xr(o,w),o.flags|=4096;return o}return r=le(r.child,{mode:w.mode,children:w.children}),r.ref=o.ref,o.child=r,r.return=o,r}function Lr(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 Vr(r,o,m,w,y){if(sn(o),m=ol(r,o,m,w,void 0,y),w=q0(),r!==null&&!Ya)return v0(r,o,y),Js(r,o,y);return Ft&&w&&me(o),o.flags|=1,La(r,o,m,y),o.child}function Bf(r,o,m,w,y,F){if(sn(o),o.updateQueue=null,m=cl(o,w,m,y),G1(r),w=q0(),r!==null&&!Ya)return v0(r,o,F),Js(r,o,F);return Ft&&w&&me(o),o.flags|=1,La(r,o,m,F),o.child}function Ru(r,o,m,w,y){if(sn(o),o.stateNode===null){var F=ro,x=m.contextType;typeof x==="object"&&x!==null&&(F=Ot(x)),F=new m(w,F),o.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=c3,o.stateNode=F,F._reactInternals=o,F=o.stateNode,F.props=w,F.state=o.memoizedState,F.refs={},Ss(o),x=m.contextType,F.context=typeof x==="object"&&x!==null?Ot(x):ro,F.state=o.memoizedState,x=m.getDerivedStateFromProps,typeof x==="function"&&(tc(o,m,x,w),F.state=o.memoizedState),typeof m.getDerivedStateFromProps==="function"||typeof F.getSnapshotBeforeUpdate==="function"||typeof F.UNSAFE_componentWillMount!=="function"&&typeof F.componentWillMount!=="function"||(x=F.state,typeof F.componentWillMount==="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount==="function"&&F.UNSAFE_componentWillMount(),x!==F.state&&c3.enqueueReplaceState(F,F.state,null),Cs(o,w,F,y),hf(),F.state=o.memoizedState),typeof F.componentDidMount==="function"&&(o.flags|=4194308),w=!0}else if(r===null){F=o.stateNode;var V=o.memoizedProps,oe=qi(m,V);F.props=oe;var ke=F.context,Me=m.contextType;x=ro,typeof Me==="object"&&Me!==null&&(x=Ot(Me));var _e=m.getDerivedStateFromProps;Me=typeof _e==="function"||typeof F.getSnapshotBeforeUpdate==="function",V=o.pendingProps!==V,Me||typeof F.UNSAFE_componentWillReceiveProps!=="function"&&typeof F.componentWillReceiveProps!=="function"||(V||ke!==x)&&Hu(o,F,w,x),Ml=!1;var Ne=o.memoizedState;F.state=Ne,Cs(o,w,F,y),hf(),ke=o.memoizedState,V||Ne!==ke||Ml?(typeof _e==="function"&&(tc(o,m,_e,w),ke=o.memoizedState),(oe=Ml||Mu(o,m,oe,w,Ne,ke,x))?(Me||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=x,w=oe):(typeof F.componentDidMount==="function"&&(o.flags|=4194308),w=!1)}else{F=o.stateNode,ll(r,o),x=o.memoizedProps,Me=qi(m,x),F.props=Me,_e=o.pendingProps,Ne=F.context,ke=m.contextType,oe=ro,typeof ke==="object"&&ke!==null&&(oe=Ot(ke)),V=m.getDerivedStateFromProps,(ke=typeof V==="function"||typeof F.getSnapshotBeforeUpdate==="function")||typeof F.UNSAFE_componentWillReceiveProps!=="function"&&typeof F.componentWillReceiveProps!=="function"||(x!==_e||Ne!==oe)&&Hu(o,F,w,oe),Ml=!1,Ne=o.memoizedState,F.state=Ne,Cs(o,w,F,y),hf();var mt=o.memoizedState;x!==_e||Ne!==mt||Ml||r!==null&&r.dependencies!==null&&st(r.dependencies)?(typeof V==="function"&&(tc(o,m,V,w),mt=o.memoizedState),(Me=Ml||Mu(o,m,Me,w,Ne,mt,oe)||r!==null&&r.dependencies!==null&&st(r.dependencies))?(ke||typeof F.UNSAFE_componentWillUpdate!=="function"&&typeof F.componentWillUpdate!=="function"||(typeof F.componentWillUpdate==="function"&&F.componentWillUpdate(w,mt,oe),typeof F.UNSAFE_componentWillUpdate==="function"&&F.UNSAFE_componentWillUpdate(w,mt,oe)),typeof F.componentDidUpdate==="function"&&(o.flags|=4),typeof F.getSnapshotBeforeUpdate==="function"&&(o.flags|=1024)):(typeof F.componentDidUpdate!=="function"||x===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=4),typeof F.getSnapshotBeforeUpdate!=="function"||x===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=1024),o.memoizedProps=w,o.memoizedState=mt),F.props=w,F.state=mt,F.context=oe,w=Me):(typeof F.componentDidUpdate!=="function"||x===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=4),typeof F.getSnapshotBeforeUpdate!=="function"||x===r.memoizedProps&&Ne===r.memoizedState||(o.flags|=1024),w=!1)}return F=w,Lr(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=Jf(o,r.child,null,y),o.child=Jf(o,null,m,y)):La(r,o,m,y),o.memoizedState=F.state,r=o.child):r=Js(r,o,y),r}function Nu(r,o,m,w){return Ze(),o.flags|=256,La(r,o,m,w),o.child}function nc(r){return{baseLanes:r,cachePool:Ae()}}function Tf(r,o,m){return r=r!==null?r.childLanes&~m:0,o&&(r|=Ds),r}function zu(r,o,m){var w=o.pendingProps,y=!1,F=(o.flags&128)!==0,x;if((x=F)||(x=r!==null&&r.memoizedState===null?!1:(Ia.current&2)!==0),x&&(y=!0,o.flags&=-129),x=(o.flags&32)!==0,o.flags&=-33,r===null){if(Ft){if(y?Di(o):Ys(o),(r=da)?(r=_C(r,ei),r!==null&&(o.memoizedState={dehydrated:r,treeContext:Ol!==null?{id:Gi,overflow:Xi}:null,retryLane:536870912,hydrationErrors:null},m=Ea(r),m.return=o,o.child=m,_n=o,da=null)):r=null,r===null)throw Ge(o);return Q5(r)?o.lanes=32:o.lanes=536870912,null}var V=w.children;if(w=w.fallback,y)return Ys(o),y=o.mode,V=Hf({mode:"hidden",children:V},y),w=Ke(w,y,m,null),V.return=o,w.return=o,V.sibling=w,o.child=V,w=o.child,w.memoizedState=nc(m),w.childLanes=Tf(r,x,m),o.memoizedState=u3,Ff(null,w);return Di(o),Mf(o,V)}var oe=r.memoizedState;if(oe!==null&&(V=oe.dehydrated,V!==null)){if(F)o.flags&256?(Di(o),o.flags&=-257,o=sc(r,o,m)):o.memoizedState!==null?(Ys(o),o.child=r.child,o.flags|=128,o=null):(Ys(o),V=w.fallback,y=o.mode,w=Hf({mode:"visible",children:w.children},y),V=Ke(V,y,m,null),V.flags|=2,w.return=o,V.return=o,w.sibling=V,o.child=w,Jf(o,r.child,null,m),w=o.child,w.memoizedState=nc(m),w.childLanes=Tf(r,x,m),o.memoizedState=u3,o=Ff(null,w));else if(Di(o),Q5(V))x=gC(V).digest,w=Error(n(419)),w.stack="",w.digest=x,$e({value:w,source:null,stack:null}),o=sc(r,o,m);else if(Ya||_a(r,o,m,!1),x=(m&r.childLanes)!==0,Ya||x){if(x=aa,x!==null&&(w=L(x,m),w!==0&&w!==oe.retryLane))throw oe.retryLane=w,d0(r,w),cn(x,r,w),h3;J5(V)||If(),o=sc(r,o,m)}else J5(V)?(o.flags|=192,o.child=r.child,o=null):(r=oe.treeContext,En&&(da=kC(V),_n=o,Ft=!0,Tl=null,ei=!1,r!==null&&ye(o,r)),o=Mf(o,w.children),o.flags|=4096);return o}if(y)return Ys(o),V=w.fallback,y=o.mode,oe=r.child,F=oe.sibling,w=le(oe,{mode:"hidden",children:w.children}),w.subtreeFlags=oe.subtreeFlags&65011712,F!==null?V=le(F,V):(V=Ke(V,y,m,null),V.flags|=2),V.return=o,w.return=o,w.sibling=V,o.child=w,Ff(null,w),w=o.child,V=r.child.memoizedState,V===null?V=nc(m):(y=V.cachePool,y!==null?(oe=T0?ja._currentValue:ja._currentValue2,y=y.parent!==oe?{parent:oe,pool:oe}:y):y=Ae(),V={baseLanes:V.baseLanes|m,cachePool:y}),w.memoizedState=V,w.childLanes=Tf(r,x,m),o.memoizedState=u3,Ff(r.child,w);return Di(o),m=r.child,r=m.sibling,m=le(m,{mode:"visible",children:w.children}),m.return=o,m.sibling=null,r!==null&&(x=o.deletions,x===null?(o.deletions=[r],o.flags|=16):x.push(r)),o.child=m,o.memoizedState=null,m}function Mf(r,o){return o=Hf({mode:"visible",children:o},r.mode),o.return=r,r.child=o}function Hf(r,o){return r=t(22,r,null,o),r.lanes=0,r}function sc(r,o,m){return Jf(o,r.child,null,m),r=Mf(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function Eu(r,o,m){r.lanes|=o;var w=r.alternate;w!==null&&(w.lanes|=o),Ka(r.return,o,m)}function ic(r,o,m,w,y,F){var x=r.memoizedState;x===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:y,treeForkCount:F}:(x.isBackwards=o,x.rendering=null,x.renderingStartTime=0,x.last=w,x.tail=m,x.tailMode=y,x.treeForkCount=F)}function Iu(r,o,m){var w=o.pendingProps,y=w.revealOrder,F=w.tail;w=w.children;var x=Ia.current,V=(x&2)!==0;if(V?(x=x&1|2,o.flags|=128):x&=1,d(Ia,x),La(r,o,w,m),w=Ft?_c:0,!V&&r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Eu(r,m,o);else if(r.tag===19)Eu(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(y){case"forwards":m=o.child;for(y=null;m!==null;)r=m.alternate,r!==null&&zr(r)===null&&(y=m),m=m.sibling;m=y,m===null?(y=o.child,o.child=null):(y=m.sibling,m.sibling=null),ic(o,!1,y,m,F,w);break;case"backwards":case"unstable_legacy-backwards":m=null,y=o.child;for(o.child=null;y!==null;){if(r=y.alternate,r!==null&&zr(r)===null){o.child=y;break}r=y.sibling,y.sibling=m,m=y,y=r}ic(o,!0,m,null,F,w);break;case"together":ic(o,!1,null,null,void 0,w);break;default:o.memoizedState=null}return o.child}function Js(r,o,m){if(r!==null&&(o.dependencies=r.dependencies),xl|=o.lanes,(m&o.childLanes)===0)if(r!==null){if(_a(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=le(r,r.pendingProps),o.child=m;for(m.return=o;r.sibling!==null;)r=r.sibling,m=m.sibling=le(r,r.pendingProps),m.return=o;m.sibling=null}return o.child}function lc(r,o){if((r.lanes&o)!==0)return!0;return r=r.dependencies,r!==null&&st(r)?!0:!1}function Uu(r,o,m){switch(o.tag){case 3:xe(o,o.stateNode.containerInfo),Xt(o,ja,r.memoizedState.cache),Ze();break;case 27:case 5:ht(o);break;case 4:xe(o,o.stateNode.containerInfo);break;case 10:Xt(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Rr(o),null;break;case 13:var w=o.memoizedState;if(w!==null){if(w.dehydrated!==null)return Di(o),o.flags|=128,null;if((m&o.child.childLanes)!==0)return zu(r,o,m);return Di(o),r=Js(r,o,m),r!==null?r.sibling:null}Di(o);break;case 19:var y=(r.flags&128)!==0;if(w=(m&o.childLanes)!==0,w||(_a(r,o,m,!1),w=(m&o.childLanes)!==0),y){if(w)return Iu(r,o,m);o.flags|=128}if(y=o.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),d(Ia,Ia.current),w)break;else return null;case 22:return o.lanes=0,Du(r,o,m,o.pendingProps);case 24:Xt(o,ja,r.memoizedState.cache)}return Js(r,o,m)}function Gu(r,o,m){if(r!==null)if(r.memoizedProps!==o.pendingProps)Ya=!0;else{if(!lc(r,m)&&(o.flags&128)===0)return Ya=!1,Uu(r,o,m);Ya=(r.flags&131072)!==0?!0:!1}else Ya=!1,Ft&&(o.flags&1048576)!==0&&be(o,_c,o.index);switch(o.lanes=0,o.tag){case 16:e:{var w=o.pendingProps;if(r=ba(o.elementType),o.type=r,typeof r==="function")W(r)?(w=qi(r,w),o.tag=1,o=Ru(null,o,r,w,m)):(o.tag=0,o=Vr(null,o,r,w,m));else{if(r!==void 0&&r!==null){var y=r.$$typeof;if(y===U5){o.tag=11,o=ac(null,o,r,w,m);break e}else if(y===K5){o.tag=14,o=Gr(null,o,r,w,m);break e}}throw o=u(r)||r,Error(n(306,o,""))}}return o;case 0:return Vr(r,o,o.type,o.pendingProps,m);case 1:return w=o.type,y=qi(w,o.pendingProps),Ru(r,o,w,y,m);case 3:e:{if(xe(o,o.stateNode.containerInfo),r===null)throw Error(n(387));var F=o.pendingProps;y=o.memoizedState,w=y.element,ll(r,o),Cs(o,F,null,m);var x=o.memoizedState;if(F=x.cache,Xt(o,ja,F),F!==y.cache&&Ht(o,[ja],m,!0),hf(),F=x.element,En&&y.isDehydrated)if(y={element:F,isDehydrated:!1,cache:x.cache},o.updateQueue.baseState=y,o.memoizedState=y,o.flags&256){o=Nu(r,o,F,m);break e}else if(F!==w){w=P(Error(n(424)),o),$e(w),o=Nu(r,o,F,m);break e}else for(En&&(da=qC(o.stateNode.containerInfo),_n=o,Ft=!0,Tl=null,ei=!0),m=dp(o,null,F,m),o.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(Ze(),F===w){o=Js(r,o,m);break e}La(r,o,F,m)}o=o.child}return o;case 26:if(Ai)return Lr(r,o),r===null?(m=sp(o.type,null,o.pendingProps,null))?o.memoizedState=m:Ft||(o.stateNode=YC(o.type,o.pendingProps,Bl.current,o)):o.memoizedState=sp(o.type,r.memoizedProps,o.pendingProps,r.memoizedState),null;case 27:if(en)return ht(o),r===null&&en&&Ft&&(w=o.stateNode=cp(o.type,o.pendingProps,Bl.current,Cn.current,!1),_n=o,ei=!0,da=AC(o.type,w,da)),La(r,o,o.pendingProps.children,m),Lr(r,o),r===null&&(o.flags|=4194304),o.child;case 5:if(r===null&&Ft){if(KC(o.type,o.pendingProps,Cn.current),y=w=da)w=yC(w,o.type,o.pendingProps,ei),w!==null?(o.stateNode=w,_n=o,da=jC(w),ei=!1,y=!0):y=!1;y||Ge(o)}return ht(o),y=o.type,F=o.pendingProps,x=r!==null?r.memoizedProps:null,w=F.children,p2(y,F)?w=null:x!==null&&p2(y,x)&&(o.flags|=32),o.memoizedState!==null&&(y=ol(r,o,mf,null,null,m),T0?Xf._currentValue=y:Xf._currentValue2=y),Lr(r,o),La(r,o,w,m),o.child;case 6:if(r===null&&Ft){if(LC(o.pendingProps,Cn.current),r=m=da)m=SC(m,o.pendingProps,ei),m!==null?(o.stateNode=m,_n=o,da=null,r=!0):r=!1;r||Ge(o)}return null;case 13:return zu(r,o,m);case 4:return xe(o,o.stateNode.containerInfo),w=o.pendingProps,r===null?o.child=Jf(o,null,w,m):La(r,o,w,m),o.child;case 11:return ac(r,o,o.type,o.pendingProps,m);case 7:return La(r,o,o.pendingProps,m),o.child;case 8:return La(r,o,o.pendingProps.children,m),o.child;case 12:return La(r,o,o.pendingProps.children,m),o.child;case 10:return w=o.pendingProps,Xt(o,o.type,w.value),La(r,o,w.children,m),o.child;case 9:return y=o.type._context,w=o.pendingProps.children,sn(o),y=Ot(y),w=w(y),o.flags|=1,La(r,o,w,m),o.child;case 14:return Gr(r,o,o.type,o.pendingProps,m);case 15:return xu(r,o,o.type,o.pendingProps,m);case 19:return Iu(r,o,m);case 31:return N5(r,o,m);case 22:return Du(r,o,m,o.pendingProps);case 24:return sn(o),w=Ot(ja),r===null?(y=ze(),y===null&&(y=aa,F=Dn(),y.pooledCache=F,F.refCount++,F!==null&&(y.pooledCacheLanes|=m),y=F),o.memoizedState={parent:w,cache:y},Ss(o),Xt(o,ja,y)):((r.lanes&m)!==0&&(ll(r,o),Cs(o,null,null,m),hf()),y=r.memoizedState,F=o.memoizedState,y.parent!==w?(y={parent:w,cache:w},o.memoizedState=y,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=y),Xt(o,ja,w)):(w=F.cache,Xt(o,ja,w),w!==y.cache&&Ht(o,[ja],m,!0))),La(r,o,o.pendingProps.children,m),o.child;case 29:throw o.pendingProps}throw Error(n(156,o.tag))}function is(r){r.flags|=4}function za(r){Ui&&(r.flags|=8)}function Yr(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 Nn(r,o,m,w){if(zn)for(m=o.child;m!==null;){if(m.tag===5||m.tag===6)V5(r,m.stateNode);else if(!(m.tag===4||en&&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(Ui)for(var y=o.child;y!==null;){if(y.tag===5){var F=y.stateNode;m&&w&&(F=P8(F,y.type,y.memoizedProps)),V5(r,F)}else if(y.tag===6)F=y.stateNode,m&&w&&(F=ep(F,y.memoizedProps)),V5(r,F);else if(y.tag!==4){if(y.tag===22&&y.memoizedState!==null)F=y.child,F!==null&&(F.return=y),Nn(r,y,!0,!0);else if(y.child!==null){y.child.return=y,y=y.child;continue}}if(y===o)break;for(;y.sibling===null;){if(y.return===null||y.return===o)return;y=y.return}y.sibling.return=y.return,y=y.sibling}}function wl(r,o,m,w){var y=!1;if(Ui)for(var F=o.child;F!==null;){if(F.tag===5){var x=F.stateNode;m&&w&&(x=P8(x,F.type,F.memoizedProps)),$8(r,x)}else if(F.tag===6)x=F.stateNode,m&&w&&(x=ep(x,F.memoizedProps)),$8(r,x);else if(F.tag!==4){if(F.tag===22&&F.memoizedState!==null)y=F.child,y!==null&&(y.return=F),wl(r,F,!0,!0),y=!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 y;F=F.return}F.sibling.return=F.return,F=F.sibling}return y}function Xu(r,o){if(Ui&&Yr(r,o)){r=o.stateNode;var m=r.containerInfo,w=Z8();wl(w,o,!1,!1),r.pendingChildren=w,is(o),mC(m,w)}}function fc(r,o,m,w){if(zn)r.memoizedProps!==w&&is(o);else if(Ui){var{stateNode:y,memoizedProps:F}=r;if((r=Yr(r,o))||F!==w){var x=Cn.current;F=uC(y,m,F,w,!r,null),F===y?o.stateNode=y:(za(o),L8(F,m,w,x)&&is(o),o.stateNode=F,r&&Nn(F,o,!1,!1))}else o.stateNode=y}}function Qs(r,o,m,w,y){if((r.mode&32)!==0&&(m===null?ES(o,w):IS(o,m,w))){if(r.flags|=16777216,(y&335544128)===y||Y5(o,w))if(Y8(r.stateNode,o,w))r.flags|=8192;else if(to())r.flags|=8192;else throw Yf=C2,l3}else r.flags&=-16777217}function rc(r,o){if(QC(o)){if(r.flags|=16777216,!op(o))if(to())r.flags|=8192;else throw Yf=C2,l3}else r.flags&=-16777217}function Jr(r,o){o!==null&&(r.flags|=4),r.flags&16384&&(o=r.tag!==22?T():536870912,r.lanes|=o,Ao|=o)}function xf(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 It(r){var o=r.alternate!==null&&r.alternate.child===r.child,m=0,w=0;if(o)for(var y=r.child;y!==null;)m|=y.lanes|y.childLanes,w|=y.subtreeFlags&65011712,w|=y.flags&65011712,y.return=r,y=y.sibling;else for(y=r.child;y!==null;)m|=y.lanes|y.childLanes,w|=y.subtreeFlags,w|=y.flags,y.return=r,y=y.sibling;return r.subtreeFlags|=w,r.childLanes=m,o}function z5(r,o,m){var w=o.pendingProps;switch(de(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(o),null;case 1:return It(o),null;case 3:if(m=o.stateNode,w=null,r!==null&&(w=r.memoizedState.cache),o.memoizedState.cache!==w&&(o.flags|=2048),$t(ja),Qe(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),r===null||r.child===null)He(o)?is(o):r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Je());return Xu(r,o),It(o),null;case 26:if(Ai){var{type:y,memoizedState:F}=o;return r===null?(is(o),F!==null?(It(o),rc(o,F)):(It(o),Qs(o,y,null,w,m))):F?F!==r.memoizedState?(is(o),It(o),rc(o,F)):(It(o),o.flags&=-16777217):(F=r.memoizedProps,zn?F!==w&&is(o):fc(r,o,y,w),It(o),Qs(o,y,F,w,m)),null}case 27:if(en){if(Oe(o),m=Bl.current,y=o.type,r!==null&&o.stateNode!=null)zn?r.memoizedProps!==w&&is(o):fc(r,o,y,w);else{if(!w){if(o.stateNode===null)throw Error(n(166));return It(o),null}r=Cn.current,He(o)?ft(o,r):(r=cp(y,w,m,r,!0),o.stateNode=r,is(o))}return It(o),null}case 5:if(Oe(o),y=o.type,r!==null&&o.stateNode!=null)fc(r,o,y,w);else{if(!w){if(o.stateNode===null)throw Error(n(166));return It(o),null}if(F=Cn.current,He(o))ft(o,F),zC(o.stateNode,y,w,F)&&(o.flags|=64);else{var x=TS(y,w,Bl.current,F,o);za(o),Nn(x,o,!1,!1),o.stateNode=x,L8(x,y,w,F)&&is(o)}}return It(o),Qs(o,o.type,r===null?null:r.memoizedProps,o.pendingProps,m),null;case 6:if(r&&o.stateNode!=null)m=r.memoizedProps,zn?m!==w&&is(o):Ui&&(m!==w?(r=Bl.current,m=Cn.current,za(o),o.stateNode=V8(w,r,m,o)):o.stateNode=r.stateNode);else{if(typeof w!=="string"&&o.stateNode===null)throw Error(n(166));if(r=Bl.current,m=Cn.current,He(o)){if(!En)throw Error(n(176));if(r=o.stateNode,m=o.memoizedProps,w=null,y=_n,y!==null)switch(y.tag){case 27:case 5:w=y.memoizedProps}OC(r,m,o,w)||Ge(o,!0)}else za(o),o.stateNode=V8(w,r,m,o)}return It(o),null;case 31:if(m=o.memoizedState,r===null||r.memoizedState!==null){if(w=He(o),m!==null){if(r===null){if(!w)throw Error(n(318));if(!En)throw Error(n(556));if(r=o.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(557));BC(r,o)}else Ze(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;It(o),r=!1}else m=Je(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=m),r=!0;if(!r){if(o.flags&256)return Rn(o),o;return Rn(o),null}if((o.flags&128)!==0)throw Error(n(558))}return It(o),null;case 13:if(w=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(y=He(o),w!==null&&w.dehydrated!==null){if(r===null){if(!y)throw Error(n(318));if(!En)throw Error(n(344));if(y=o.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(n(317));TC(y,o)}else Ze(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;It(o),y=!1}else y=Je(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=y),y=!0;if(!y){if(o.flags&256)return Rn(o),o;return Rn(o),null}}if(Rn(o),(o.flags&128)!==0)return o.lanes=m,o;return m=w!==null,r=r!==null&&r.memoizedState!==null,m&&(w=o.child,y=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(y=w.alternate.memoizedState.cachePool.pool),F=null,w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(F=w.memoizedState.cachePool.pool),F!==y&&(w.flags|=2048)),m!==r&&m&&(o.child.flags|=8192),Jr(o,o.updateQueue),It(o),null;case 4:return Qe(),Xu(r,o),r===null&&DS(o.stateNode.containerInfo),It(o),null;case 10:return $t(o.type),It(o),null;case 19:if(b(Ia),w=o.memoizedState,w===null)return It(o),null;if(y=(o.flags&128)!==0,F=w.rendering,F===null)if(y)xf(w,!1);else{if(Ta!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(F=zr(r),F!==null){o.flags|=128,xf(w,!1),r=F.updateQueue,o.updateQueue=r,Jr(o,r),o.subtreeFlags=0,r=m;for(m=o.child;m!==null;)Te(m,r),m=m.sibling;return d(Ia,Ia.current&1|2),Ft&&qe(o,w.treeForkCount),o.child}r=r.sibling}w.tail!==null&&rs()>Dc&&(o.flags|=128,y=!0,xf(w,!1),o.lanes=4194304)}else{if(!y)if(r=zr(F),r!==null){if(o.flags|=128,y=!0,r=r.updateQueue,o.updateQueue=r,Jr(o,r),xf(w,!0),w.tail===null&&w.tailMode==="hidden"&&!F.alternate&&!Ft)return It(o),null}else 2*rs()-w.renderingStartTime>Dc&&m!==536870912&&(o.flags|=128,y=!0,xf(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=rs(),r.sibling=null,m=Ia.current,d(Ia,y?m&1|2:m&1),Ft&&qe(o,w.treeForkCount),r;return It(o),null;case 22:case 23:return Rn(o),U1(),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&&(It(o),o.subtreeFlags&6&&(o.flags|=8192)):It(o),m=o.updateQueue,m!==null&&Jr(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(Vf),null;case 24:return m=null,r!==null&&(m=r.memoizedState.cache),o.memoizedState.cache!==m&&(o.flags|=2048),$t(ja),It(o),null;case 25:return null;case 30:return null}throw Error(n(156,o.tag))}function E5(r,o){switch(de(o),o.tag){case 1:return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return $t(ja),Qe(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 26:case 27:case 5:return Oe(o),null;case 31:if(o.memoizedState!==null){if(Rn(o),o.alternate===null)throw Error(n(340));Ze()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 13:if(Rn(o),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Ze()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return b(Ia),null;case 4:return Qe(),null;case 10:return $t(o.type),null;case 22:case 23:return Rn(o),U1(),r!==null&&b(Vf),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 24:return $t(ja),null;case 25:return null;default:return null}}function Ku(r,o){switch(de(o),o.tag){case 3:$t(ja),Qe();break;case 26:case 27:case 5:Oe(o);break;case 4:Qe();break;case 31:o.memoizedState!==null&&Rn(o);break;case 13:Rn(o);break;case 19:b(Ia);break;case 10:$t(o.type);break;case 22:case 23:Rn(o),U1(),r!==null&&b(Vf);break;case 24:$t(ja)}}function Df(r,o){try{var m=o.updateQueue,w=m!==null?m.lastEffect:null;if(w!==null){var y=w.next;m=y;do{if((m.tag&r)===r){w=void 0;var{create:F,inst:x}=m;w=F(),x.destroy=w}m=m.next}while(m!==y)}}catch(V){v(o,o.return,V)}}function vi(r,o,m){try{var w=o.updateQueue,y=w!==null?w.lastEffect:null;if(y!==null){var F=y.next;w=F;do{if((w.tag&r)===r){var x=w.inst,V=x.destroy;if(V!==void 0){x.destroy=void 0,y=o;var oe=m,ke=V;try{ke()}catch(Me){v(y,oe,Me)}}}w=w.next}while(w!==F)}}catch(Me){v(o,o.return,Me)}}function Lu(r){var o=r.updateQueue;if(o!==null){var m=r.stateNode;try{E1(o,m)}catch(w){v(r,r.return,w)}}}function dl(r,o,m){m.props=qi(r.type,r.memoizedProps),m.state=r.memoizedState;try{m.componentWillUnmount()}catch(w){v(r,o,w)}}function jl(r,o){try{var m=r.ref;if(m!==null){switch(r.tag){case 26:case 27:case 5:var w=Ac(r.stateNode);break;case 30:w=r.stateNode;break;default:w=r.stateNode}typeof m==="function"?r.refCleanup=m(w):m.current=w}}catch(y){v(r,o,y)}}function Ln(r,o){var{ref:m,refCleanup:w}=r;if(m!==null)if(typeof w==="function")try{w()}catch(y){v(r,o,y)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof m==="function")try{m(null)}catch(y){v(r,o,y)}else m.current=null}function ql(r){var{type:o,memoizedProps:m,stateNode:w}=r;try{tC(w,o,m,r)}catch(y){v(r,r.return,y)}}function ra(r,o,m){try{aC(r.stateNode,r.type,m,o,r)}catch(w){v(r,r.return,w)}}function S0(r){return r.tag===5||r.tag===3||(Ai?r.tag===26:!1)||(en?r.tag===27&&lo(r.type):!1)||r.tag===4}function Rf(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||S0(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(en&&r.tag===27&&lo(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 oc(r,o,m){var w=r.tag;if(w===5||w===6)r=r.stateNode,o?sC(m,r,o):PS(m,r);else if(w!==4&&(en&&w===27&&lo(r.type)&&(m=r.stateNode,o=null),r=r.child,r!==null))for(oc(r,o,m),r=r.sibling;r!==null;)oc(r,o,m),r=r.sibling}function Qr(r,o,m){var w=r.tag;if(w===5||w===6)r=r.stateNode,o?nC(m,r,o):WS(m,r);else if(w!==4&&(en&&w===27&&lo(r.type)&&(m=r.stateNode),r=r.child,r!==null))for(Qr(r,o,m),r=r.sibling;r!==null;)Qr(r,o,m),r=r.sibling}function Vu(r,o,m){r=r.containerInfo;try{W8(r,m)}catch(w){v(o,o.return,w)}}function Yu(r){var{stateNode:o,memoizedProps:m}=r;try{$C(r.type,m,o,r)}catch(w){v(r,r.return,w)}}function Ju(r,o){OS(r.containerInfo);for(un=o;un!==null;)if(r=un,o=r.child,(r.subtreeFlags&1028)!==0&&o!==null)o.return=r,un=o;else for(;un!==null;){r=un;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 y=o[w];y.ref.impl=y.nextImpl}break;case 11:case 15:break;case 1:if((o&1024)!==0&&m!==null){o=void 0,w=r,y=m.memoizedProps,m=m.memoizedState;var F=w.stateNode;try{var x=qi(w.type,y);o=F.getSnapshotBeforeUpdate(x,m),F.__reactInternalSnapshotBeforeUpdate=o}catch(V){v(w,w.return,V)}}break;case 3:(o&1024)!==0&&zn&&hC(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,un=o;break}un=r.return}}function cc(r,o,m){var w=m.flags;switch(m.tag){case 0:case 11:case 15:ki(r,m),w&4&&Df(5,m);break;case 1:if(ki(r,m),w&4)if(r=m.stateNode,o===null)try{r.componentDidMount()}catch(x){v(m,m.return,x)}else{var y=qi(m.type,o.memoizedProps);o=o.memoizedState;try{r.componentDidUpdate(y,o,r.__reactInternalSnapshotBeforeUpdate)}catch(x){v(m,m.return,x)}}w&64&&Lu(m),w&512&&jl(m,m.return);break;case 3:if(ki(r,m),w&64&&(w=m.updateQueue,w!==null)){if(r=null,m.child!==null)switch(m.child.tag){case 27:case 5:r=Ac(m.child.stateNode);break;case 1:r=m.child.stateNode}try{E1(w,r)}catch(x){v(m,m.return,x)}}break;case 27:en&&o===null&&w&4&&Yu(m);case 26:case 5:if(ki(r,m),o===null){if(w&4)ql(m);else if(w&64){r=m.type,o=m.memoizedProps,y=m.stateNode;try{xC(y,r,o,m)}catch(x){v(m,m.return,x)}}}w&512&&jl(m,m.return);break;case 12:ki(r,m);break;case 31:ki(r,m),w&4&&$r(r,m);break;case 13:ki(r,m),w&4&&uc(r,m),w&64&&(w=m.memoizedState,w!==null&&(w=w.dehydrated,w!==null&&(m=R.bind(null,m),pC(w,m))));break;case 22:if(w=m.memoizedState!==null||D0,!w){o=o!==null&&o.memoizedState!==null||Ja,y=D0;var F=Ja;D0=w,(Ja=o)&&!F?Zs(r,m,(m.subtreeFlags&8772)!==0):ki(r,m),D0=y,Ja=F}break;case 30:break;default:ki(r,m)}}function hc(r){var o=r.alternate;o!==null&&(r.alternate=null,hc(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&zS(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 ls(r,o,m){for(m=m.child;m!==null;)Zr(r,o,m),m=m.sibling}function Zr(r,o,m){if(Ts&&typeof Ts.onCommitFiberUnmount==="function")try{Ts.onCommitFiberUnmount(Cc,m)}catch(F){}switch(m.tag){case 26:if(Ai){Ja||Ln(m,o),ls(r,o,m),m.memoizedState?lp(m.memoizedState):m.stateNode&&rp(m.stateNode);break}case 27:if(en){Ja||Ln(m,o);var w=Qa,y=os;lo(m.type)&&(Qa=m.stateNode,os=!1),ls(r,o,m),hp(m.stateNode),Qa=w,os=y;break}case 5:Ja||Ln(m,o);case 6:if(zn){if(w=Qa,y=os,Qa=null,ls(r,o,m),Qa=w,os=y,Qa!==null)if(os)try{lC(Qa,m.stateNode)}catch(F){v(m,o,F)}else try{iC(Qa,m.stateNode)}catch(F){v(m,o,F)}}else ls(r,o,m);break;case 18:zn&&Qa!==null&&(os?UC(Qa,m.stateNode):IC(Qa,m.stateNode));break;case 4:zn?(w=Qa,y=os,Qa=m.stateNode.containerInfo,os=!0,ls(r,o,m),Qa=w,os=y):(Ui&&Vu(m.stateNode,m,Z8()),ls(r,o,m));break;case 0:case 11:case 14:case 15:vi(2,m,o),Ja||vi(4,m,o),ls(r,o,m);break;case 1:Ja||(Ln(m,o),w=m.stateNode,typeof w.componentWillUnmount==="function"&&dl(m,o,w)),ls(r,o,m);break;case 21:ls(r,o,m);break;case 22:Ja=(w=Ja)||m.memoizedState!==null,ls(r,o,m),Ja=w;break;default:ls(r,o,m)}}function $r(r,o){if(En&&o.memoizedState===null&&(r=o.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{RC(r)}catch(m){v(o,o.return,m)}}}function uc(r,o){if(En&&o.memoizedState===null&&(r=o.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{NC(r)}catch(m){v(o,o.return,m)}}function mc(r){switch(r.tag){case 31:case 13:case 19:var o=r.stateNode;return o===null&&(o=r.stateNode=new vp),o;case 22:return r=r.stateNode,o=r._retryCache,o===null&&(o=r._retryCache=new vp),o;default:throw Error(n(435,r.tag))}}function Wr(r,o){var m=mc(r);o.forEach(function(w){if(!m.has(w)){m.add(w);var y=E.bind(null,r,w);w.then(y,y)}})}function Ba(r,o){var m=o.deletions;if(m!==null)for(var w=0;w<m.length;w++){var y=m[w],F=r,x=o;if(zn){var V=x;e:for(;V!==null;){switch(V.tag){case 27:if(en){if(lo(V.type)){Qa=V.stateNode,os=!1;break e}break}case 5:Qa=V.stateNode,os=!1;break e;case 3:case 4:Qa=V.stateNode.containerInfo,os=!0;break e}V=V.return}if(Qa===null)throw Error(n(160));Zr(F,x,y),Qa=null,os=!1}else Zr(F,x,y);F=y.alternate,F!==null&&(F.return=null),y.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)Qu(o,r),o=o.sibling}function Qu(r,o){var{alternate:m,flags:w}=r;switch(r.tag){case 0:case 11:case 14:case 15:Ba(o,r),on(r),w&4&&(vi(3,r,r.return),Df(3,r),vi(5,r,r.return));break;case 1:Ba(o,r),on(r),w&512&&(Ja||m===null||Ln(m,m.return)),w&64&&D0&&(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(Ai){var y=yi;if(Ba(o,r),on(r),w&512&&(Ja||m===null||Ln(m,m.return)),w&4){w=m!==null?m.memoizedState:null;var F=r.memoizedState;m===null?F===null?r.stateNode===null?r.stateNode=VC(y,r.type,r.memoizedProps,r):fp(y,r.type,r.stateNode):r.stateNode=ip(y,F,r.memoizedProps):w!==F?(w===null?m.stateNode!==null&&rp(m.stateNode):lp(w),F===null?fp(y,r.type,r.stateNode):ip(y,F,r.memoizedProps)):F===null&&r.stateNode!==null&&ra(r,r.memoizedProps,m.memoizedProps)}break}case 27:if(en){Ba(o,r),on(r),w&512&&(Ja||m===null||Ln(m,m.return)),m!==null&&w&4&&ra(r,r.memoizedProps,m.memoizedProps);break}case 5:if(Ba(o,r),on(r),w&512&&(Ja||m===null||Ln(m,m.return)),zn){if(r.flags&32){y=r.stateNode;try{Q8(y)}catch(_e){v(r,r.return,_e)}}w&4&&r.stateNode!=null&&(y=r.memoizedProps,ra(r,y,m!==null?m.memoizedProps:y)),w&1024&&(m3=!0)}else Ui&&r.alternate!==null&&(r.alternate.stateNode=r.stateNode);break;case 6:if(Ba(o,r),on(r),w&4&&zn){if(r.stateNode===null)throw Error(n(162));w=r.memoizedProps,m=m!==null?m.memoizedProps:w,y=r.stateNode;try{eC(y,m,w)}catch(_e){v(r,r.return,_e)}}break;case 3:if(Ai?(JC(),y=yi,yi=Z5(o.containerInfo),Ba(o,r),yi=y):Ba(o,r),on(r),w&4){if(zn&&En&&m!==null&&m.memoizedState.isDehydrated)try{DC(o.containerInfo)}catch(_e){v(r,r.return,_e)}if(Ui){w=o.containerInfo,m=o.pendingChildren;try{W8(w,m)}catch(_e){v(r,r.return,_e)}}}m3&&(m3=!1,gc(r));break;case 4:Ai?(m=yi,yi=Z5(r.stateNode.containerInfo),Ba(o,r),on(r),yi=m):(Ba(o,r),on(r)),w&4&&Ui&&Vu(r.stateNode,r,r.stateNode.pendingChildren);break;case 12:Ba(o,r),on(r);break;case 31:Ba(o,r),on(r),w&4&&(w=r.updateQueue,w!==null&&(r.updateQueue=null,Wr(r,w)));break;case 13:Ba(o,r),on(r),r.child.flags&8192&&r.memoizedState!==null!==(m!==null&&m.memoizedState!==null)&&(D2=rs()),w&4&&(w=r.updateQueue,w!==null&&(r.updateQueue=null,Wr(r,w)));break;case 22:y=r.memoizedState!==null;var x=m!==null&&m.memoizedState!==null,V=D0,oe=Ja;if(D0=V||y,Ja=oe||x,Ba(o,r),Ja=oe,D0=V,on(r),w&8192&&(o=r.stateNode,o._visibility=y?o._visibility&-2:o._visibility|1,y&&(m===null||x||D0||Ja||C0(r)),zn)){e:if(m=null,zn)for(o=r;;){if(o.tag===5||Ai&&o.tag===26){if(m===null){x=m=o;try{F=x.stateNode,y?fC(F):oC(x.stateNode,x.memoizedProps)}catch(_e){v(x,x.return,_e)}}}else if(o.tag===6){if(m===null){x=o;try{var ke=x.stateNode;y?rC(ke):cC(ke,x.memoizedProps)}catch(_e){v(x,x.return,_e)}}}else if(o.tag===18){if(m===null){x=o;try{var Me=x.stateNode;y?GC(Me):XC(x.stateNode)}catch(_e){v(x,x.return,_e)}}}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,Wr(r,m))));break;case 19:Ba(o,r),on(r),w&4&&(w=r.updateQueue,w!==null&&(r.updateQueue=null,Wr(r,w)));break;case 30:break;case 21:break;default:Ba(o,r),on(r)}}function on(r){var o=r.flags;if(o&2){try{for(var m,w=r.return;w!==null;){if(S0(w)){m=w;break}w=w.return}if(zn){if(m==null)throw Error(n(160));switch(m.tag){case 27:if(en){var y=m.stateNode,F=Rf(r);Qr(r,F,y);break}case 5:var x=m.stateNode;m.flags&32&&(Q8(x),m.flags&=-33);var V=Rf(r);Qr(r,V,x);break;case 3:case 4:var oe=m.stateNode.containerInfo,ke=Rf(r);oc(r,ke,oe);break;default:throw Error(n(161))}}}catch(Me){v(r,r.return,Me)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function gc(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var o=r;gc(o),o.tag===5&&o.flags&1024&&XS(o.stateNode),r=r.sibling}}function ki(r,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)cc(r,o.alternate,o),o=o.sibling}function C0(r){for(r=r.child;r!==null;){var o=r;switch(o.tag){case 0:case 11:case 14:case 15:vi(4,o,o.return),C0(o);break;case 1:Ln(o,o.return);var m=o.stateNode;typeof m.componentWillUnmount==="function"&&dl(o,o.return,m),C0(o);break;case 27:en&&hp(o.stateNode);case 26:case 5:Ln(o,o.return),C0(o);break;case 22:o.memoizedState===null&&C0(o);break;case 30:C0(o);break;default:C0(o)}r=r.sibling}}function Zs(r,o,m){m=m&&(o.subtreeFlags&8772)!==0;for(o=o.child;o!==null;){var w=o.alternate,y=r,F=o,x=F.flags;switch(F.tag){case 0:case 11:case 15:Zs(y,F,m),Df(4,F);break;case 1:if(Zs(y,F,m),w=F,y=w.stateNode,typeof y.componentDidMount==="function")try{y.componentDidMount()}catch(ke){v(w,w.return,ke)}if(w=F,y=w.updateQueue,y!==null){var V=w.stateNode;try{var oe=y.shared.hiddenCallbacks;if(oe!==null)for(y.shared.hiddenCallbacks=null,y=0;y<oe.length;y++)ta(oe[y],V)}catch(ke){v(w,w.return,ke)}}m&&x&64&&Lu(F),jl(F,F.return);break;case 27:en&&Yu(F);case 26:case 5:Zs(y,F,m),m&&w===null&&x&4&&ql(F),jl(F,F.return);break;case 12:Zs(y,F,m);break;case 31:Zs(y,F,m),m&&x&4&&$r(y,F);break;case 13:Zs(y,F,m),m&&x&4&&uc(y,F);break;case 22:F.memoizedState===null&&Zs(y,F,m),jl(F,F.return);break;case 30:break;default:Zs(y,F,m)}o=o.sibling}}function pc(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&&Da(m))}function bc(r,o){r=null,o.alternate!==null&&(r=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==r&&(o.refCount++,r!=null&&Da(r))}function Vn(r,o,m,w){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Zu(r,o,m,w),o=o.sibling}function Zu(r,o,m,w){var y=o.flags;switch(o.tag){case 0:case 11:case 15:Vn(r,o,m,w),y&2048&&Df(9,o);break;case 1:Vn(r,o,m,w);break;case 3:Vn(r,o,m,w),y&2048&&(r=null,o.alternate!==null&&(r=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==r&&(o.refCount++,r!=null&&Da(r)));break;case 12:if(y&2048){Vn(r,o,m,w),r=o.stateNode;try{var F=o.memoizedProps,x=F.id,V=F.onPostCommit;typeof V==="function"&&V(x,o.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(oe){v(o,o.return,oe)}}else Vn(r,o,m,w);break;case 31:Vn(r,o,m,w);break;case 13:Vn(r,o,m,w);break;case 23:break;case 22:F=o.stateNode,x=o.alternate,o.memoizedState!==null?F._visibility&2?Vn(r,o,m,w):Nf(r,o):F._visibility&2?Vn(r,o,m,w):(F._visibility|=2,vl(r,o,m,w,(o.subtreeFlags&10256)!==0||!1)),y&2048&&pc(x,o);break;case 24:Vn(r,o,m,w),y&2048&&bc(o.alternate,o);break;default:Vn(r,o,m,w)}}function vl(r,o,m,w,y){y=y&&((o.subtreeFlags&10256)!==0||!1);for(o=o.child;o!==null;){var F=r,x=o,V=m,oe=w,ke=x.flags;switch(x.tag){case 0:case 11:case 15:vl(F,x,V,oe,y),Df(8,x);break;case 23:break;case 22:var Me=x.stateNode;x.memoizedState!==null?Me._visibility&2?vl(F,x,V,oe,y):Nf(F,x):(Me._visibility|=2,vl(F,x,V,oe,y)),y&&ke&2048&&pc(x.alternate,x);break;case 24:vl(F,x,V,oe,y),y&&ke&2048&&bc(x.alternate,x);break;default:vl(F,x,V,oe,y)}o=o.sibling}}function Nf(r,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var m=r,w=o,y=w.flags;switch(w.tag){case 22:Nf(m,w),y&2048&&pc(w.alternate,w);break;case 24:Nf(m,w),y&2048&&bc(w.alternate,w);break;default:Nf(m,w)}o=o.sibling}}function _0(r,o,m){if(r.subtreeFlags&vo)for(r=r.child;r!==null;)$u(r,o,m),r=r.sibling}function $u(r,o,m){switch(r.tag){case 26:if(_0(r,o,m),r.flags&vo)if(r.memoizedState!==null)ZC(m,yi,r.memoizedState,r.memoizedProps);else{var{stateNode:w,type:y}=r;r=r.memoizedProps,((o&335544128)===o||Y5(y,r))&&J8(m,w,y,r)}break;case 5:_0(r,o,m),r.flags&vo&&(w=r.stateNode,y=r.type,r=r.memoizedProps,((o&335544128)===o||Y5(y,r))&&J8(m,w,y,r));break;case 3:case 4:Ai?(w=yi,yi=Z5(r.stateNode.containerInfo),_0(r,o,m),yi=w):_0(r,o,m);break;case 22:r.memoizedState===null&&(w=r.alternate,w!==null&&w.memoizedState!==null?(w=vo,vo=16777216,_0(r,o,m),vo=w):_0(r,o,m));break;default:_0(r,o,m)}}function Wu(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 zf(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];un=w,e2(w,r)}Wu(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Pu(r),r=r.sibling}function Pu(r){switch(r.tag){case 0:case 11:case 15:zf(r),r.flags&2048&&vi(9,r,r.return);break;case 3:zf(r);break;case 12:zf(r);break;case 22:var o=r.stateNode;r.memoizedState!==null&&o._visibility&2&&(r.return===null||r.return.tag!==13)?(o._visibility&=-3,Pr(r)):zf(r);break;default:zf(r)}}function Pr(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];un=w,e2(w,r)}Wu(r)}for(r=r.child;r!==null;){switch(o=r,o.tag){case 0:case 11:case 15:vi(8,o,o.return),Pr(o);break;case 22:m=o.stateNode,m._visibility&2&&(m._visibility&=-3,Pr(o));break;default:Pr(o)}r=r.sibling}}function e2(r,o){for(;un!==null;){var m=un;switch(m.tag){case 0:case 11:case 15:vi(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:Da(m.memoizedState.cache)}if(w=m.child,w!==null)w.return=m,un=w;else e:for(m=r;un!==null;){w=un;var{sibling:y,return:F}=w;if(hc(w),w===m){un=null;break e}if(y!==null){y.return=F,un=y;break e}un=F}}}function wc(r){var o=xS(r);if(o!=null){if(typeof o.memoizedProps["data-testname"]!=="string")throw Error(n(364));return o}if(r=VS(r),r===null)throw Error(n(362));return r.stateNode.current}function $s(r,o){var m=r.tag;switch(o.$$typeof){case B2:if(r.type===o.value)return!0;break;case T2:e:{o=o.value,r=[r,0];for(m=0;m<r.length;){var w=r[m++],y=w.tag,F=r[m++],x=o[F];if(y!==5&&y!==26&&y!==27||!Sc(w)){for(;x!=null&&$s(w,x);)F++,x=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 M2:if((m===5||m===26||m===27)&&QS(r.stateNode,o.value))return!0;break;case x2:if(m===5||m===6||m===26||m===27){if(r=JS(r),r!==null&&0<=r.indexOf(o.value))return!0}break;case H2: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 dc(r){switch(r.$$typeof){case B2:return"<"+(u(r.value)||"Unknown")+">";case T2:return":has("+(dc(r)||"")+")";case M2:return'[role="'+r.value+'"]';case x2:return'"'+r.value+'"';case H2:return'[data-testname="'+r.value+'"]';default:throw Error(n(365))}}function t2(r,o){var m=[];r=[r,0];for(var w=0;w<r.length;){var y=r[w++],F=y.tag,x=r[w++],V=o[x];if(F!==5&&F!==26&&F!==27||!Sc(y)){for(;V!=null&&$s(y,V);)x++,V=o[x];if(x===o.length)m.push(y);else for(y=y.child;y!==null;)r.push(y,x),y=y.sibling}}return m}function jc(r,o){if(!yc)throw Error(n(363));r=wc(r),r=t2(r,o),o=[],r=Array.from(r);for(var m=0;m<r.length;){var w=r[m++],y=w.tag;if(y===5||y===26||y===27)Sc(w)||o.push(w.stateNode);else for(w=w.child;w!==null;)r.push(w),w=w.sibling}return o}function fs(){return(kt&2)!==0&&St!==0?St&-St:We.T!==null?ia():RS()}function qc(){if(Ds===0)if((St&536870912)===0||Ft){var r=w2;w2<<=1,(w2&3932160)===0&&(w2=262144),Ds=r}else Ds=536870912;return r=Hs.current,r!==null&&(r.flags|=32),Ds}function cn(r,o,m){if(r===aa&&(Lt===2||Lt===9)||r.cancelPendingCommit!==null)kl(r,0),zi(r,St,Ds,!1);if(H(r,m),(kt&2)===0||r!==aa)r===aa&&((kt&2)===0&&(Zf|=m),Ta===4&&zi(r,St,Ds,!1)),Ra(r)}function vc(r,o,m){if((kt&6)!==0)throw Error(n(327));var w=!m&&(o&127)===0&&(o&r.expiredLanes)===0||C(r,o),y=w?F0(r,o):Ei(r,o,!0),F=w;do{if(y===0){ko&&!w&&zi(r,o,0,!1);break}else{if(m=r.current.alternate,F&&!eo(m)){y=Ei(r,o,!1),F=!1;continue}if(y===2){if(F=o,r.errorRecoveryDisabledLanes&F)var x=0;else x=r.pendingLanes&-536870913,x=x!==0?x:x&536870912?536870912:0;if(x!==0){o=x;e:{var V=r;y=xc;var oe=En&&V.current.memoizedState.isDehydrated;if(oe&&(kl(V,x).flags|=256),x=Ei(V,x,!1),x!==2){if(g3&&!oe){V.errorRecoveryDisabledLanes|=F,Zf|=F,y=4;break e}F=cs,cs=y,F!==null&&(cs===null?cs=F:cs.push.apply(cs,F))}y=x}if(F=!1,y!==2)continue}}if(y===1){kl(r,0),zi(r,o,0,!0);break}e:{switch(w=r,F=y,F){case 0:case 1:throw Error(n(345));case 4:if((o&4194048)!==o)break;case 6:zi(w,o,Ds,!Hl);break e;case 2:cs=null;break;case 3:case 5:break;default:throw Error(n(329))}if((o&62914560)===o&&(y=D2+300-rs(),10<y)){if(zi(w,o,Ds,!Hl),S(w,0,!0)!==0)break e;N0=o,w.timeoutHandle=MS(Ef.bind(null,w,m,cs,R2,b3,o,Ds,Zf,Ao,Hl,F,"Throttled",-0,0),y);break e}Ef(w,m,cs,R2,b3,o,Ds,Zf,Ao,Hl,F,null,-0,0)}}break}while(1);Ra(r)}function Ef(r,o,m,w,y,F,x,V,oe,ke,Me,_e,Ne,mt){if(r.timeoutHandle=Gf,_e=o.subtreeFlags,_e&8192||(_e&16785408)===16785408){_e=US(),$u(o,F,_e);var Fn=(F&62914560)===F?D2-rs():(F&4194048)===F?kp-rs():0;if(Fn=GS(_e,Fn),Fn!==null){N0=F,r.cancelPendingCommit=Fn(r2.bind(null,r,o,F,m,w,y,x,V,oe,Me,_e,null,Ne,mt)),zi(r,F,x,!ke);return}}r2(r,o,F,m,w,y,x,V,oe)}function eo(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 y=m[w],F=y.getSnapshot;y=y.value;try{if(!Ms(F(),y))return!1}catch(x){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 zi(r,o,m,w){o&=~p3,o&=~Zf,r.suspendedLanes|=o,r.pingedLanes&=~o,w&&(r.warmLanes|=o),w=r.expirationTimes;for(var y=o;0<y;){var F=31-Bs(y),x=1<<F;w[F]=-1,y&=~x}m!==0&&N(r,m,o)}function a2(){return(kt&6)===0?(Na(0,!1),!1):!0}function kc(){if(At!==null){if(Lt===0)var r=At.return;else r=At,H0=Kf=null,X1(r),po=null,Bc=0,r=At;for(;r!==null;)Ku(r.alternate,r),r=r.return;At=null}}function kl(r,o){var m=r.timeoutHandle;m!==Gf&&(r.timeoutHandle=Gf,HS(m)),m=r.cancelPendingCommit,m!==null&&(r.cancelPendingCommit=null,m()),N0=0,kc(),aa=r,At=m=le(r.current,null),St=o,Lt=0,xs=null,Hl=!1,ko=C(r,o),g3=!1,Ao=Ds=p3=Zf=xl=Ta=0,cs=xc=null,b3=!1,(o&8)!==0&&(o|=o&32);var w=r.entangledLanes;if(w!==0)for(r=r.entanglements,w&=o;0<w;){var y=31-Bs(w),F=1<<y;o|=r[y],w&=~F}return R0=o,il(),m}function n2(r,o){pt=null,We.H=Mc,o===go||o===S2?(o=ji(),Lt=3):o===l3?(o=ji(),Lt=4):Lt=o===h3?8:o!==null&&typeof o==="object"&&typeof o.then==="function"?6:1,xs=o,At===null&&(Ta=1,pl(r,P(o,r.current)))}function to(){var r=Hs.current;return r===null?!0:(St&4194048)===St?ai===null?!0:!1:(St&62914560)===St||(St&536870912)!==0?r===ai:!1}function s2(){var r=We.H;return We.H=Mc,r===null?Mc:r}function i2(){var r=We.A;return We.A=h_,r}function If(){Ta=4,Hl||(St&4194048)!==St&&Hs.current!==null||(ko=!0),(xl&134217727)===0&&(Zf&134217727)===0||aa===null||zi(aa,St,Ds,!1)}function Ei(r,o,m){var w=kt;kt|=2;var y=s2(),F=i2();if(aa!==r||St!==o)R2=null,kl(r,o);o=!1;var x=Ta;e:do try{if(Lt!==0&&At!==null){var V=At,oe=xs;switch(Lt){case 8:kc(),x=6;break e;case 3:case 2:case 9:case 6:Hs.current===null&&(o=!0);var ke=Lt;if(Lt=0,xs=null,O0(r,V,oe,ke),m&&ko){x=0;break e}break;default:ke=Lt,Lt=0,xs=null,O0(r,V,oe,ke)}}Nt(),x=Ta;break}catch(Me){n2(r,Me)}while(1);return o&&r.shellSuspendCounter++,H0=Kf=null,kt=w,We.H=y,We.A=F,At===null&&(aa=null,St=0,il()),x}function Nt(){for(;At!==null;)Os(At)}function F0(r,o){var m=kt;kt|=2;var w=s2(),y=i2();aa!==r||St!==o?(R2=null,Dc=rs()+500,kl(r,o)):ko=C(r,o);e:do try{if(Lt!==0&&At!==null){o=At;var F=xs;t:switch(Lt){case 1:Lt=0,xs=null,O0(r,o,F,1);break;case 2:case 9:if(Ue(F)){Lt=0,xs=null,l2(o);break}o=function(){Lt!==2&&Lt!==9||aa!==r||(Lt=7),Ra(r)},F.then(o,o);break e;case 3:Lt=7;break e;case 4:Lt=5;break e;case 7:Ue(F)?(Lt=0,xs=null,l2(o)):(Lt=0,xs=null,O0(r,o,F,7));break;case 5:var x=null;switch(At.tag){case 26:x=At.memoizedState;case 5:case 27:var V=At,oe=V.type,ke=V.pendingProps;if(x?op(x):Y8(V.stateNode,oe,ke)){Lt=0,xs=null;var Me=V.sibling;if(Me!==null)At=Me;else{var _e=V.return;_e!==null?(At=_e,ao(_e)):At=null}break t}}Lt=0,xs=null,O0(r,o,F,5);break;case 6:Lt=0,xs=null,O0(r,o,F,6);break;case 8:kc(),Ta=6;break e;default:throw Error(n(462))}}yn();break}catch(Ne){n2(r,Ne)}while(1);if(H0=Kf=null,We.H=w,We.A=y,kt=m,At!==null)return 0;return aa=null,St=0,il(),Ta}function yn(){for(;At!==null&&!e_();)Os(At)}function Os(r){var o=Gu(r.alternate,r,R0);r.memoizedProps=r.pendingProps,o===null?ao(r):At=o}function l2(r){var o=r,m=o.alternate;switch(o.tag){case 15:case 0:o=Bf(m,o,o.pendingProps,o.type,void 0,St);break;case 11:o=Bf(m,o,o.pendingProps,o.type.render,o.ref,St);break;case 5:X1(o);default:Ku(m,o),o=At=Te(o,R0),o=Gu(m,o,R0)}r.memoizedProps=r.pendingProps,o===null?ao(r):At=o}function O0(r,o,m,w){H0=Kf=null,X1(o),po=null,Bc=0;var y=o.return;try{if(R5(r,y,o,m,St)){Ta=1,pl(r,P(m,r.current)),At=null;return}}catch(F){if(y!==null)throw At=y,F;Ta=1,pl(r,P(m,r.current)),At=null;return}if(o.flags&32768){if(Ft||w===1)r=!0;else if(ko||(St&536870912)!==0)r=!1;else if(Hl=r=!0,w===2||w===9||w===3||w===6)w=Hs.current,w!==null&&w.tag===13&&(w.flags|=16384);f2(o,r)}else ao(o)}function ao(r){var o=r;do{if((o.flags&32768)!==0){f2(o,Hl);return}r=o.return;var m=z5(o.alternate,o,R0);if(m!==null){At=m;return}if(o=o.sibling,o!==null){At=o;return}At=o=r}while(o!==null);Ta===0&&(Ta=5)}function f2(r,o){do{var m=E5(r.alternate,r);if(m!==null){m.flags&=32767,At=m;return}if(m=r.return,m!==null&&(m.flags|=32768,m.subtreeFlags=0,m.deletions=null),!o&&(r=r.sibling,r!==null)){At=r;return}At=r=m}while(r!==null);Ta=6,At=null}function r2(r,o,m,w,y,F,x,V,oe){r.cancelPendingCommit=null;do B0();while(tn!==0);if((kt&6)!==0)throw Error(n(327));if(o!==null){if(o===r.current)throw Error(n(177));if(F=o.lanes|o.childLanes,F|=f3,D(r,m,F,x,V,oe),r===aa&&(At=aa=null,St=0),yo=o,Rl=r,N0=m,w3=F,d3=y,Ap=w,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,G(P5,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,y=M0(),hn(2),x=kt,kt|=4;try{Ju(r,o,m)}finally{kt=x,hn(y),We.T=w}}tn=1,o2(),c2(),h2()}}function o2(){if(tn===1){tn=0;var r=Rl,o=yo,m=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||m){m=We.T,We.T=null;var w=M0();hn(2);var y=kt;kt|=4;try{Qu(o,r),BS(r.containerInfo)}finally{kt=y,hn(w),We.T=m}}r.current=o,tn=2}}function c2(){if(tn===2){tn=0;var r=Rl,o=yo,m=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||m){m=We.T,We.T=null;var w=M0();hn(2);var y=kt;kt|=4;try{cc(r,o.alternate,o)}finally{kt=y,hn(w),We.T=m}}tn=3}}function h2(){if(tn===4||tn===3){tn=0,t_();var r=Rl,o=yo,m=N0,w=Ap;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?tn=5:(tn=0,yo=Rl=null,u2(r,r.pendingLanes));var y=r.pendingLanes;if(y===0&&(Dl=null),te(m),o=o.stateNode,Ts&&typeof Ts.onCommitFiberRoot==="function")try{Ts.onCommitFiberRoot(Cc,o,void 0,(o.current.flags&128)===128)}catch(oe){}if(w!==null){o=We.T,y=M0(),hn(2),We.T=null;try{for(var F=r.onRecoverableError,x=0;x<w.length;x++){var V=w[x];F(V.value,{componentStack:V.stack})}}finally{We.T=o,hn(y)}}(N0&3)!==0&&B0(),Ra(r),y=r.pendingLanes,(m&261930)!==0&&(y&42)!==0?r===j3?Rc++:(Rc=0,j3=r):Rc=0,En&&EC(),Na(0,!1)}}function u2(r,o){(r.pooledCacheLanes&=o)===0&&(o=r.pooledCache,o!=null&&(r.pooledCache=null,Da(o)))}function B0(){return o2(),c2(),h2(),p()}function p(){if(tn!==5)return!1;var r=Rl,o=w3;w3=0;var m=te(N0),w=32>m?32:m;m=We.T;var y=M0();try{hn(w),We.T=null,w=d3,d3=null;var F=Rl,x=N0;if(tn=0,yo=Rl=null,N0=0,(kt&6)!==0)throw Error(n(331));var V=kt;if(kt|=4,Pu(F.current),Zu(F,F.current,x,w),kt=V,Na(0,!1),Ts&&typeof Ts.onPostCommitFiberRoot==="function")try{Ts.onPostCommitFiberRoot(Cc,F)}catch(oe){}return!0}finally{hn(y),We.T=m,u2(r,o)}}function q(r,o,m){o=P(m,o),o=Ri(r.stateNode,o,2),r=Hi(r,o,2),r!==null&&(H(r,2),Ra(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"&&(Dl===null||!Dl.has(w))){r=P(m,r),m=_f(2),w=Hi(o,m,2),w!==null&&(Ni(m,w,o,r),H(w,2),Ra(w));break}}o=o.return}}function k(r,o,m){var w=r.pingCache;if(w===null){w=r.pingCache=new u_;var y=new Set;w.set(o,y)}else y=w.get(o),y===void 0&&(y=new Set,w.set(o,y));y.has(m)||(g3=!0,y.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,aa===r&&(St&m)===m&&(Ta===4||Ta===3&&(St&62914560)===St&&300>rs()-D2?(kt&2)===0&&kl(r,0):p3|=m,Ao===St&&(Ao=0)),Ra(r)}function B(r,o){o===0&&(o=T()),r=d0(r,o),r!==null&&(H(r,o),Ra(r))}function R(r){var o=r.memoizedState,m=0;o!==null&&(m=o.retryLane),B(r,m)}function E(r,o){var m=0;switch(r.tag){case 31:case 13:var{stateNode:w,memoizedState:y}=r;y!==null&&(m=y.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 j2(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 le(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 Te(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 ue(r,o,m,w,y,F){var x=0;if(w=r,typeof r==="function")W(r)&&(x=1);else if(typeof r==="string")x=Ai&&en?np(r,m,Cn.current)?26:up(r)?27:5:Ai?np(r,m,Cn.current)?26:5:en?up(r)?27:5:5;else e:switch(r){case L5:return r=t(31,m,o,y),r.elementType=L5,r.lanes=F,r;case so:return Ke(m.children,y,F,o);case U8:x=8,y|=24;break;case I5:return r=t(12,m,o,y|2),r.elementType=I5,r.lanes=F,r;case G5:return r=t(13,m,o,y),r.elementType=G5,r.lanes=F,r;case X5:return r=t(19,m,o,y),r.elementType=X5,r.lanes=F,r;default:if(typeof r==="object"&&r!==null)switch(r.$$typeof){case _l:x=10;break e;case G8:x=9;break e;case U5:x=11;break e;case K5:x=14;break e;case Fl:x=16,w=null;break e}x=29,m=Error(n(130,r===null?"null":typeof r,"")),w=null}return o=t(x,m,o,y),o.elementType=r,o.type=w,o.lanes=F,o}function Ke(r,o,m,w){return r=t(7,r,w,o),r.lanes=m,r}function tt(r,o,m){return r=t(6,r,null,o),r.lanes=m,r}function Ea(r){var o=t(18,null,null,0);return o.stateNode=r,o}function Sn(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 Ii(r,o,m,w,y,F,x,V,oe){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Gf,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=y,this.onCaughtError=F,this.onRecoverableError=x,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=oe,this.incompleteTransitions=new Map}function Al(r,o,m,w,y,F,x,V,oe,ke,Me,_e){return r=new Ii(r,o,m,x,oe,ke,Me,_e,V),o=1,F===!0&&(o|=24),F=t(3,null,null,o),r.current=F,F.stateNode=r,o=Dn(),o.refCount++,r.pooledCache=o,o.refCount++,F.memoizedState={element:w,isDehydrated:m,cache:o},Ss(F),r}function yl(r){if(!r)return ro;return r=ro,r}function Sl(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=l(o),r=r!==null?f(r):null,r===null?null:Ac(r.stateNode)}function Cl(r,o,m,w,y,F){y=yl(y),w.context===null?w.context=y:w.pendingContext=y,w=yt(o),w.payload={element:m},F=F===void 0?null:F,F!==null&&(w.callback=F),m=Hi(r,w,o),m!==null&&(cn(m,r,o),xi(m,r,o))}function Uf(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var m=r.retryLane;r.retryLane=m!==0&&m<o?m:o}}function Kt(r,o){Uf(r,o),(r=r.alternate)&&Uf(r,o)}var ut={},Yn=Object.assign,kS=Symbol.for("react.element"),m2=Symbol.for("react.transitional.element"),no=Symbol.for("react.portal"),so=Symbol.for("react.fragment"),U8=Symbol.for("react.strict_mode"),I5=Symbol.for("react.profiler"),G8=Symbol.for("react.consumer"),_l=Symbol.for("react.context"),U5=Symbol.for("react.forward_ref"),G5=Symbol.for("react.suspense"),X5=Symbol.for("react.suspense_list"),K5=Symbol.for("react.memo"),Fl=Symbol.for("react.lazy"),L5=Symbol.for("react.activity"),AS=Symbol.for("react.memo_cache_sentinel"),X8=Symbol.iterator,yS=Symbol.for("react.client.reference"),g2=Array.isArray,We=Ig.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,SS=e.rendererVersion,CS=e.rendererPackageName,K8=e.extraDevToolsConfig,Ac=e.getPublicInstance,_S=e.getRootHostContext,FS=e.getChildHostContext,OS=e.prepareForCommit,BS=e.resetAfterCommit,TS=e.createInstance;e.cloneMutableInstance;var{appendInitialChild:V5,finalizeInitialChildren:L8,shouldSetTextContent:p2,createTextInstance:V8}=e;e.cloneMutableTextInstance;var{scheduleTimeout:MS,cancelTimeout:HS,noTimeout:Gf,isPrimaryRenderer:T0}=e;e.warnsIfNotActing;var{supportsMutation:zn,supportsPersistence:Ui,supportsHydration:En,getInstanceFromNode:xS}=e;e.beforeActiveInstanceBlur;var DS=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var{setCurrentUpdatePriority:hn,getCurrentUpdatePriority:M0,resolveUpdatePriority:RS}=e;e.trackSchedulerEvent,e.resolveEventType,e.resolveEventTimeStamp;var{shouldAttemptEagerTransition:NS,detachDeletedInstance:zS}=e;e.requestPostPaintCallback;var{maySuspendCommit:ES,maySuspendCommitOnUpdate:IS,maySuspendCommitInSyncRender:Y5,preloadInstance:Y8,startSuspendingCommit:US,suspendInstance:J8}=e;e.suspendOnActiveViewTransition;var GS=e.waitForCommitToBeReady;e.getSuspendedCommitReason;var{NotPendingTransition:io,HostTransitionContext:Xf,resetFormInstance:XS}=e;e.bindToConsole;var{supportsMicrotasks:KS,scheduleMicrotask:LS,supportsTestSelectors:yc,findFiberRoot:VS,getBoundingRect:YS,getTextContent:JS,isHiddenSubtree:Sc,matchAccessibilityRole:QS,setFocusIfFocusable:ZS,setupIntersectionObserver:$S,appendChild:WS,appendChildToContainer:PS,commitTextUpdate:eC,commitMount:tC,commitUpdate:aC,insertBefore:nC,insertInContainerBefore:sC,removeChild:iC,removeChildFromContainer:lC,resetTextContent:Q8,hideInstance:fC,hideTextInstance:rC,unhideInstance:oC,unhideTextInstance:cC}=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 hC=e.clearContainer;e.createFragmentInstance,e.updateFragmentInstanceFiber,e.commitNewChildToFragmentInstance,e.deleteChildFromFragmentInstance;var{cloneInstance:uC,createContainerChildSet:Z8,appendChildToContainerChildSet:$8,finalizeContainerChildren:mC,replaceContainerChildren:W8,cloneHiddenInstance:P8,cloneHiddenTextInstance:ep,isSuspenseInstancePending:J5,isSuspenseInstanceFallback:Q5,getSuspenseInstanceFallbackErrorDetails:gC,registerSuspenseInstanceRetry:pC,canHydrateFormStateMarker:bC,isFormStateMarkerMatching:wC,getNextHydratableSibling:tp,getNextHydratableSiblingAfterSingleton:dC,getFirstHydratableChild:jC,getFirstHydratableChildWithinContainer:qC,getFirstHydratableChildWithinActivityInstance:vC,getFirstHydratableChildWithinSuspenseInstance:kC,getFirstHydratableChildWithinSingleton:AC,canHydrateInstance:yC,canHydrateTextInstance:SC,canHydrateActivityInstance:CC,canHydrateSuspenseInstance:_C,hydrateInstance:FC,hydrateTextInstance:OC,hydrateActivityInstance:BC,hydrateSuspenseInstance:TC,getNextHydratableInstanceAfterActivityInstance:MC,getNextHydratableInstanceAfterSuspenseInstance:HC,commitHydratedInstance:xC,commitHydratedContainer:DC,commitHydratedActivityInstance:RC,commitHydratedSuspenseInstance:NC,finalizeHydratedChildren:zC,flushHydrationEvents:EC}=e;e.clearActivityBoundary;var IC=e.clearSuspenseBoundary;e.clearActivityBoundaryFromContainer;var{clearSuspenseBoundaryFromContainer:UC,hideDehydratedBoundary:GC,unhideDehydratedBoundary:XC,shouldDeleteUnhydratedTailInstances:ap}=e;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var{validateHydratableInstance:KC,validateHydratableTextInstance:LC,supportsResources:Ai,isHostHoistableType:np,getHoistableRoot:Z5,getResource:sp,acquireResource:ip,releaseResource:lp,hydrateHoistable:VC,mountHoistable:fp,unmountHoistable:rp,createHoistableInstance:YC,prepareToCommitHoistables:JC,mayResourceSuspendCommit:QC,preloadResource:op,suspendResource:ZC,supportsSingletons:en,resolveSingletonInstance:cp,acquireSingletonInstance:$C,releaseSingletonInstance:hp,isHostSingletonType:up,isSingletonScope:lo}=e,$5=[],fo=-1,ro={},Bs=Math.clz32?Math.clz32:j,WC=Math.log,PC=Math.LN2,b2=256,w2=262144,d2=4194304,j2=Eg,W5=Bk,e_=Mk,t_=Tk,rs=E9,mp=Fk,a_=Ok,P5=zg,n_=I9,s_=void 0,i_=void 0,Cc=null,Ts=null,Ms=typeof Object.is==="function"?Object.is:ae,gp=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)},l_=Object.prototype.hasOwnProperty,e3,pp,t3=!1,bp=new WeakMap,oo=[],co=0,q2=null,_c=0,Ws=[],Ps=0,Ol=null,Gi=1,Xi="",Cn=g(null),Fc=g(null),Bl=g(null),v2=g(null),_n=null,da=null,Ft=!1,Tl=null,ei=!1,a3=Error(n(519)),k2=g(null),Kf=null,H0=null,f_=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()})}},r_=Eg,o_=zg,ja={$$typeof:_l,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},A2=null,ho=null,n3=!1,y2=!1,s3=!1,Lf=0,Oc=null,i3=0,uo=0,mo=null,wp=We.S;We.S=function(r,o){kp=rs(),typeof o==="object"&&o!==null&&typeof o.then==="function"&&ln(r,o),wp!==null&&wp(r,o)};var Vf=g(null),go=Error(n(460)),l3=Error(n(474)),S2=Error(n(542)),C2={then:function(){}},Yf=null,po=null,Bc=0,Jf=z1(!0),dp=z1(!1),ti=[],bo=0,f3=0,Ml=!1,r3=!1,wo=g(null),_2=g(0),Hs=g(null),ai=null,Ia=g(0),x0=0,pt=null,Wt=null,Va=null,F2=!1,jo=!1,Qf=!1,O2=0,Tc=0,qo=null,c_=0,Mc={readContext:Ot,use:k0,useCallback:ma,useContext:ma,useEffect:ma,useImperativeHandle:ma,useLayoutEffect:ma,useInsertionEffect:ma,useMemo:ma,useReducer:ma,useRef:ma,useState:ma,useDebugValue:ma,useDeferredValue:ma,useTransition:ma,useSyncExternalStore:ma,useId:ma,useHostTransitionStatus:ma,useFormState:ma,useActionState:ma,useOptimistic:ma,useMemoCache:ma,useCacheRefresh:ma};Mc.useEffectEvent=ma;var jp={readContext:Ot,use:k0,useCallback:function(r,o){return rn().memoizedState=[r,o===void 0?null:o],r},useContext:Ot,useEffect:qu,useImperativeHandle:function(r,o,m){m=m!==null&&m!==void 0?m.concat([r]):null,qf(4194308,4,yu.bind(null,o,r),m)},useLayoutEffect:function(r,o){return qf(4194308,4,r,o)},useInsertionEffect:function(r,o){qf(4,2,r,o)},useMemo:function(r,o){var m=rn();o=o===void 0?null:o;var w=r();if(Qf){J(!0);try{r()}finally{J(!1)}}return m.memoizedState=[w,o],w},useReducer:function(r,o,m){var w=rn();if(m!==void 0){var y=m(o);if(Qf){J(!0);try{m(o)}finally{J(!1)}}}else y=o;return w.memoizedState=w.baseState=y,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:y},w.queue=r,r=r.dispatch=Sf.bind(null,pt,r),[w.memoizedState,r]},useRef:function(r){var o=rn();return r={current:r},o.memoizedState=r},useState:function(r){r=bf(r);var o=r.queue,m=Cf.bind(null,pt,o);return o.dispatch=m,[r.memoizedState,m]},useDebugValue:kf,useDeferredValue:function(r,o){var m=rn();return gl(m,r,o)},useTransition:function(){var r=bf(!1);return r=Fu.bind(null,pt,r.queue,!0,!1),rn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,o,m){var w=pt,y=rn();if(Ft){if(m===void 0)throw Error(n(407));m=m()}else{if(m=o(),aa===null)throw Error(n(349));(St&127)!==0||ul(w,o,m)}y.memoizedState=m;var F={value:m,getSnapshot:o};return y.queue=F,qu(A0.bind(null,w,F,r),[r]),w.flags|=2048,ml(9,{destroy:void 0},pf.bind(null,w,F,m,o),null),m},useId:function(){var r=rn(),o=aa.identifierPrefix;if(Ft){var m=Xi,w=Gi;m=(w&~(1<<32-Bs(w)-1)).toString(32)+m,o="_"+o+"R_"+m,m=O2++,0<m&&(o+="H"+m.toString(32)),o+="_"}else m=c_++,o="_"+o+"r_"+m.toString(32)+"_";return r.memoizedState=o},useHostTransitionStatus:P1,useFormState:Z1,useActionState:Z1,useOptimistic:function(r){var o=rn();o.memoizedState=o.baseState=r;var m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=m,o=Fs.bind(null,pt,!0,m),m.dispatch=o,[r,o]},useMemoCache:K1,useCacheRefresh:function(){return rn().memoizedState=yf.bind(null,pt)},useEffectEvent:function(r){var o=rn(),m={impl:r};return o.memoizedState=m,function(){if((kt&2)!==0)throw Error(n(440));return m.impl.apply(void 0,arguments)}}},o3={readContext:Ot,use:k0,useCallback:Cu,useContext:Ot,useEffect:Ur,useImperativeHandle:Su,useInsertionEffect:ku,useLayoutEffect:Au,useMemo:W1,useReducer:hl,useRef:ju,useState:function(){return hl(_s)},useDebugValue:kf,useDeferredValue:function(r,o){var m=wa();return _u(m,Wt.memoizedState,r,o)},useTransition:function(){var r=hl(_s)[0],o=wa().memoizedState;return[typeof r==="boolean"?r:ss(r),o]},useSyncExternalStore:gf,useId:Bu,useHostTransitionStatus:P1,useFormState:du,useActionState:du,useOptimistic:function(r,o){var m=wa();return pu(m,Wt,r,o)},useMemoCache:K1,useCacheRefresh:Af};o3.useEffectEvent=vu;var qp={readContext:Ot,use:k0,useCallback:Cu,useContext:Ot,useEffect:Ur,useImperativeHandle:Su,useInsertionEffect:ku,useLayoutEffect:Au,useMemo:W1,useReducer:L1,useRef:ju,useState:function(){return L1(_s)},useDebugValue:kf,useDeferredValue:function(r,o){var m=wa();return Wt===null?gl(m,r,o):_u(m,Wt.memoizedState,r,o)},useTransition:function(){var r=L1(_s)[0],o=wa().memoizedState;return[typeof r==="boolean"?r:ss(r),o]},useSyncExternalStore:gf,useId:Bu,useHostTransitionStatus:P1,useFormState:$1,useActionState:$1,useOptimistic:function(r,o){var m=wa();if(Wt!==null)return pu(m,Wt,r,o);return m.baseState=r,[r,m.queue.dispatch]},useMemoCache:K1,useCacheRefresh:Af};qp.useEffectEvent=vu;var c3={enqueueSetState:function(r,o,m){r=r._reactInternals;var w=fs(),y=yt(w);y.payload=o,m!==void 0&&m!==null&&(y.callback=m),o=Hi(r,y,w),o!==null&&(cn(o,r,w),xi(o,r,w))},enqueueReplaceState:function(r,o,m){r=r._reactInternals;var w=fs(),y=yt(w);y.tag=1,y.payload=o,m!==void 0&&m!==null&&(y.callback=m),o=Hi(r,y,w),o!==null&&(cn(o,r,w),xi(o,r,w))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var m=fs(),w=yt(m);w.tag=2,o!==void 0&&o!==null&&(w.callback=o),o=Hi(r,w,m),o!==null&&(cn(o,r,m),xi(o,r,m))}},h3=Error(n(461)),Ya=!1,u3={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},D0=!1,Ja=!1,m3=!1,vp=typeof WeakSet==="function"?WeakSet:Set,un=null,Qa=null,os=!1,yi=null,vo=8192,h_={getCacheForType:function(r){var o=Ot(ja),m=o.data.get(r);return m===void 0&&(m=r(),o.data.set(r,m)),m},cacheSignal:function(){return Ot(ja).controller.signal}},B2=0,T2=1,M2=2,H2=3,x2=4;if(typeof Symbol==="function"&&Symbol.for){var Hc=Symbol.for;B2=Hc("selector.component"),T2=Hc("selector.has_pseudo_class"),M2=Hc("selector.role"),H2=Hc("selector.test_id"),x2=Hc("selector.text")}var u_=typeof WeakMap==="function"?WeakMap:Map,kt=0,aa=null,At=null,St=0,Lt=0,xs=null,Hl=!1,ko=!1,g3=!1,R0=0,Ta=0,xl=0,Zf=0,p3=0,Ds=0,Ao=0,xc=null,cs=null,b3=!1,D2=0,kp=0,Dc=1/0,R2=null,Dl=null,tn=0,Rl=null,yo=null,N0=0,w3=0,d3=null,Ap=null,Rc=0,j3=null;return ut.attemptContinuousHydration=function(r){if(r.tag===13||r.tag===31){var o=d0(r,67108864);o!==null&&cn(o,r,67108864),Kt(r,67108864)}},ut.attemptHydrationAtCurrentPriority=function(r){if(r.tag===13||r.tag===31){var o=fs();o=ee(o);var m=d0(r,o);m!==null&&cn(m,r,o),Kt(r,o)}},ut.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-Bs(o);r.entanglements[1]|=m,o&=~m}Ra(r),(kt&6)===0&&(Dc=rs()+500,Na(0,!1))}}break;case 31:case 13:o=d0(r,2),o!==null&&cn(o,r,2),a2(),Kt(r,2)}},ut.batchedUpdates=function(r,o){return r(o)},ut.createComponentSelector=function(r){return{$$typeof:B2,value:r}},ut.createContainer=function(r,o,m,w,y,F,x,V,oe,ke){return Al(r,o,!1,null,m,w,F,null,x,V,oe,ke)},ut.createHasPseudoClassSelector=function(r){return{$$typeof:T2,value:r}},ut.createHydrationContainer=function(r,o,m,w,y,F,x,V,oe,ke,Me,_e,Ne,mt){return r=Al(m,w,!0,r,y,F,V,mt,oe,ke,Me,_e),r.context=yl(null),m=r.current,w=fs(),w=ee(w),y=yt(w),y.callback=o!==void 0&&o!==null?o:null,Hi(m,y,w),o=w,r.current.lanes=o,H(r,o),Ra(r),r},ut.createPortal=function(r,o,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:no,key:w==null?null:""+w,children:r,containerInfo:o,implementation:m}},ut.createRoleSelector=function(r){return{$$typeof:M2,value:r}},ut.createTestNameSelector=function(r){return{$$typeof:H2,value:r}},ut.createTextSelector=function(r){return{$$typeof:x2,value:r}},ut.defaultOnCaughtError=function(r){console.error(r)},ut.defaultOnRecoverableError=function(r){gp(r)},ut.defaultOnUncaughtError=function(r){gp(r)},ut.deferredUpdates=function(r){var o=We.T,m=M0();try{return hn(32),We.T=null,r()}finally{hn(m),We.T=o}},ut.discreteUpdates=function(r,o,m,w,y){var F=We.T,x=M0();try{return hn(2),We.T=null,r(o,m,w,y)}finally{hn(x),We.T=F,kt===0&&(Dc=rs()+500)}},ut.findAllNodes=jc,ut.findBoundingRects=function(r,o){if(!yc)throw Error(n(363));o=jc(r,o),r=[];for(var m=0;m<o.length;m++)r.push(YS(o[m]));for(o=r.length-1;0<o;o--){m=r[o];for(var w=m.x,y=w+m.width,F=m.y,x=F+m.height,V=o-1;0<=V;V--)if(o!==V){var oe=r[V],ke=oe.x,Me=ke+oe.width,_e=oe.y,Ne=_e+oe.height;if(w>=ke&&F>=_e&&y<=Me&&x<=Ne){r.splice(o,1);break}else if(!(w!==ke||m.width!==oe.width||Ne<F||_e>x)){_e>F&&(oe.height+=_e-F,oe.y=F),Ne<x&&(oe.height=x-_e),r.splice(o,1);break}else if(!(F!==_e||m.height!==oe.height||Me<w||ke>y)){ke>w&&(oe.width+=ke-w,oe.x=w),Me<y&&(oe.width=y-ke),r.splice(o,1);break}}}return r},ut.findHostInstance=Sl,ut.findHostInstanceWithNoPortals=function(r){return r=l(r),r=r!==null?c(r):null,r===null?null:Ac(r.stateNode)},ut.findHostInstanceWithWarning=function(r){return Sl(r)},ut.flushPassiveEffects=B0,ut.flushSyncFromReconciler=function(r){var o=kt;kt|=1;var m=We.T,w=M0();try{if(hn(2),We.T=null,r)return r()}finally{hn(w),We.T=m,kt=o,(kt&6)===0&&Na(0,!1)}},ut.flushSyncWork=a2,ut.focusWithin=function(r,o){if(!yc)throw Error(n(363));r=wc(r),o=t2(r,o),o=Array.from(o);for(r=0;r<o.length;){var m=o[r++],w=m.tag;if(!Sc(m)){if((w===5||w===26||w===27)&&ZS(m.stateNode))return!0;for(m=m.child;m!==null;)o.push(m),m=m.sibling}}return!1},ut.getFindAllNodesFailureDescription=function(r,o){if(!yc)throw Error(n(363));var m=0,w=[];r=[wc(r),0];for(var y=0;y<r.length;){var F=r[y++],x=F.tag,V=r[y++],oe=o[V];if(x!==5&&x!==26&&x!==27||!Sc(F)){if($s(F,oe)&&(w.push(dc(oe)),V++,V>m&&(m=V)),V<o.length)for(F=F.child;F!==null;)r.push(F,V),F=F.sibling}}if(m<o.length){for(r=[];m<o.length;m++)r.push(dc(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},ut.getPublicRootInstance=function(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 27:case 5:return Ac(r.child.stateNode);default:return r.child.stateNode}},ut.injectIntoDevTools=function(){var r={bundleType:0,version:SS,rendererPackageName:CS,currentDispatcherRef:We,reconcilerVersion:"19.2.0"};if(K8!==null&&(r.rendererConfig=K8),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")r=!1;else{var o=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(o.isDisabled||!o.supportsFiber)r=!0;else{try{Cc=o.inject(r),Ts=o}catch(m){}r=o.checkDCE?!0:!1}}return r},ut.isAlreadyRendering=function(){return(kt&6)!==0},ut.observeVisibleRects=function(r,o,m,w){if(!yc)throw Error(n(363));r=jc(r,o);var y=$S(r,m,w).disconnect;return{disconnect:function(){y()}}},ut.shouldError=function(){return null},ut.shouldSuspend=function(){return!1},ut.startHostTransition=function(r,o,m,w){if(r.tag!==5)throw Error(n(476));var y=Ou(r).queue;Fu(r,y,o,io,m===null?a:function(){var F=Ou(r);return F.next===null&&(F=r.alternate.memoizedState),An(r,F.next.queue,{},fs()),m(w)})},ut.updateContainer=function(r,o,m,w){var y=o.current,F=fs();return Cl(y,F,r,o,m,w),F},ut.updateContainerSync=function(r,o,m,w){return Cl(o.current,2,r,o,m,w),2},ut};Vh.exports.default=Vh.exports;Object.defineProperty(Vh.exports,"__esModule",{value:!0})});var Wk=Tt((JY,$k)=>{var o0=Mt(Za());$k.exports=function(t,a,n){let s=o0.useRef("loading"),i=o0.useRef(),[l,f]=o0.useState(0),c=o0.useRef(),h=o0.useRef(),u=o0.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 o0.useLayoutEffect(function(){if(!t)return;var g=document.createElement("img");function b(){g.decode().catch(()=>{}).finally(()=>{s.current="loaded",i.current=g,f(Math.random())})}function d(){s.current="failed",i.current=void 0,f(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 $z(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 yp(e,t){return Math.max(0,Math.min(e,Math.max(0,t-1)))}var di=Mt(Za(),1);var zc=Mt(Za(),1);var g_=(e)=>he("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:[I("circle",{cx:"12",cy:"12",r:"10"}),I("path",{d:"m9 12 2 2 4-4"})]}),p_=(e)=>he("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",...e,children:[I("circle",{cx:"12",cy:"12",r:"10"}),I("path",{d:"m9 12 2 2 4-4",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Sp={__CHAT__:"Generating...",__AUTOFILL__:"Autofilling metadata...",__EMBEDDING__:"Generating embeddings...",__RUNNING__:"Generating..."},q3=({teamId:e,message:t,isReply:a,hasReplies:n,isLastReply:s,getUser:i,onReply:l,onViewAttachment:f,isSelected:c,onSelect:h,frameRate:u,startTimecode:g,formatTimestamp:b})=>{let d=t,j=!!d.annotations&&Array.isArray(d.annotations)&&d.annotations.length>0,A=d.creator,S=!!d.sessionId&&!!d.message&&d.message in Sp,C=d.message&&Sp[d.message]||"Generating...",[O,T]=zc.default.useState(!1),{videoTimeDisplayMode:M}=So(),H=zc.default.useMemo(()=>{if(d.second===null||d.second===void 0)return"";if(b)return b(d.second);if(!u)return"";let P=Math.round(d.second*u);return zl(P,u,M,g)},[d.second,u,M,g,b]),{data:D}=Ec({queryKey:["teams",e,"me"],queryFn:async()=>{let P=await Bt.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!P.ok)throw Error("Failed to fetch current member info");return await P.json()},enabled:!!e,staleTime:300000}),N=D?.role==="owner",z=N2(),{mutate:L}=Wf({mutationFn:async()=>{let P=await Bt.api.comments[":commentId"].complete.$post({param:{commentId:d.id},json:{isCompleted:!d.isCompleted}});if(!P.ok)throw Error("Failed to update comment completion status");return await P.json()},onSuccess:()=>{z.invalidateQueries({predicate:(P)=>P.queryKey.includes("comments")})}}),[ee,te]=zc.default.useState(!1),{mutate:J,isPending:ae}=Wf({mutationFn:async()=>{let P=await Bt.api.comments[":commentId"].$delete({param:{commentId:d.id}});if(!P.ok)throw Error("Failed to delete comment");return await P.json()},onSuccess:()=>{z.invalidateQueries({predicate:(P)=>P.queryKey.includes("comments")}),te(!1)}}),Q=zc.default.useMemo(()=>{if(!D)return!1;if(D.role==="owner")return!0;if(d.creator?.id===D.id)return!0;return!1},[D,d.creator?.id]),Y=(P)=>{return P.split(/(<@[a-zA-Z0-9_-]+>)/g).map((be,me)=>{if(be.match(/^<@[a-zA-Z0-9_-]+>$/)){let de=be.slice(2,-1),ye=d.mentions?.find((xe)=>xe.id===de)||i(de);return he("span",{className:"text-primary font-medium hover:underline cursor-pointer",children:["@",ye?.name||"Unknown"]},me)}return I("span",{children:be},me)})},$=(P)=>{return P.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},fe=()=>{l(d)};return he("div",{onClick:h,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"} ${c?"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:[he("div",{className:"flex flex-col items-center shrink-0 w-8 relative",children:[a&&I("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)&&I("div",{className:"absolute top-4 bottom-[-1rem] w-0.5 bg-foreground/10 left-1/2 -translate-x-1/2 z-0"}),he(Mp,{className:"z-10 relative",children:[A?.image&&I(Hp,{src:A.image,alt:A.name||"",className:"object-cover"}),I(xp,{className:"bg-rose-400 text-black",children:A?.name?.[0]?.toUpperCase()||"U"})]})]}),he("div",{className:"flex-1 min-w-0",children:[he("div",{className:"flex items-center justify-between w-full mb-1",children:[he("div",{className:"flex items-center gap-2",children:[I("span",{className:"font-semibold text-sm",children:A?.name||"Unknown"}),I("span",{className:"text-xs text-gray-400",children:new Date(d.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),Q&&I("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:he(Pf,{modal:!1,children:[I(er,{asChild:!0,children:I(Si,{size:"icon-xs",variant:"ghost",className:"h-6 w-6 cursor-pointer",onClick:(P)=>P.stopPropagation(),children:I(Cp,{className:"h-4 w-4 text-foreground/70"})})}),I(tr,{align:"end",onClick:(P)=>P.stopPropagation(),children:he(z0,{className:"text-destructive focus:text-destructive cursor-pointer",onClick:(P)=>{P.stopPropagation(),te(!0)},children:[I(_p,{className:"mr-2 h-4 w-4"}),I("span",{children:Le.delete()})]})})]})})]}),he("div",{className:"flow-root mt-1",children:[d.second!==null&&d.second!==void 0&&u&&I("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:H}),j&&I("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:I(E2,{className:"w-3.5 h-3.5"})}),S?he("div",{className:"space-y-2",children:[I(hs,{className:"h-4 w-3/4"}),I(hs,{className:"h-4 w-1/2"}),I("span",{className:"text-xs text-muted-foreground animate-pulse",children:C})]}):d.sessionId?I("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:I(Xp,{children:$(d.message)})}):I("div",{className:"text-sm leading-[1.8] whitespace-pre-wrap break-words text-wrap break-all",children:Y(d.message)})]}),d.attachments&&d.attachments.length>0&&I("div",{className:"flex flex-wrap gap-2 mt-3",children:d.attachments.map((P)=>{let qe=P.proxyType==="image",be=P.url?.split("/").pop()?.split("?")[0]||"file";return he("div",{className:"relative group rounded-lg overflow-hidden border bg-white shadow-sm hover:shadow-md transition-shadow w-48 h-32",onClick:()=>qe&&f(P),children:[qe?I("img",{src:P.url,alt:be,className:"w-full h-full object-cover cursor-pointer"}):he("div",{className:"w-full h-full bg-gray-100 flex flex-col items-center justify-center p-2 text-center",children:[I(z2,{className:"w-8 h-8 text-gray-500 mb-2"}),I("span",{className:"text-xs font-medium text-gray-700 break-all line-clamp-2",children:be})]}),I("a",{href:P.url,target:"_blank",rel:"noreferrer",download:be,className:"absolute right-2 bottom-2 bg-black/60 text-white hover:bg-black/80 p-1.5 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",onClick:(me)=>me.stopPropagation(),children:I(Ci,{className:"w-4 h-4"})})]},P.id)})}),d.sessionId&&he("div",{className:"mt-3 pt-2 border-t border-foreground/5 flex items-center justify-between text-xs text-muted-foreground/60",children:[I("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground/80",children:"Created by Agent"}),N&&I(Si,{variant:"outline",size:"xs",onClick:()=>T(!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"})]}),he("div",{className:"mt-2 flex items-center justify-between w-full",children:[I("button",{onClick:fe,className:"text-xs font-medium text-gray-500 hover:text-blue-600 flex items-center gap-1 cursor-pointer",children:Le.reply()}),I(Fp,{children:he(Op,{children:[I(Bp,{asChild:!0,children:I("button",{onClick:(P)=>{P.stopPropagation(),L()},className:`flex items-center justify-center p-1 rounded-full transition-colors cursor-pointer ${d.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:d.isCompleted?I(p_,{className:"w-5 h-5"}):I(g_,{className:"w-5 h-5"})})}),I(Tp,{children:d.isCompleted?Le.mark_as_incomplete():Le.mark_as_complete()})]})})]})]}),I(Kp,{sessionId:d.sessionId,open:O,onOpenChange:T}),I(Dp,{open:ee,onOpenChange:te,children:he(Rp,{onClick:(P)=>P.stopPropagation(),children:[he(Np,{children:[I(Ep,{children:Le.delete_comment_confirm()}),I(Ip,{children:Le.delete_comment_description()})]}),he(zp,{children:[I(Gp,{disabled:ae,onClick:(P)=>{P.stopPropagation(),te(!1)},children:Le.cancel()}),I(Up,{className:"bg-destructive hover:bg-destructive/90 text-white",disabled:ae,onClick:(P)=>{P.stopPropagation(),J()},children:Le.delete()})]})]})})]})};var us=Lp((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(),l=[...n,a],f=s.slice(0,i+1);f.push(l),e({annotations:l,history:f,historyIndex:f.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 oa=Mt(Za(),1);var b_=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#000000","#ffffff"],k3=oa.default.forwardRef(({projectId:e,onSendMessage:t,replyingTo:a,onCancelReply:n,bots:s=[],initialText:i="",hideAnnotationControl:l=!1,disableMentions:f=!1,currentTime:c,frameRate:h,startTimecode:u,formatTimestamp:g,onTyping:b},d)=>{let[j,A]=oa.useState([]),[S,C]=oa.useState(null),[O,T]=oa.useState(!0),{videoTimeDisplayMode:M}=So(),H=oa.default.useMemo(()=>{if(c===void 0)return"";if(g)return g(c);if(!h)return"";let ve=Math.round(c*h);return zl(ve,h,M,u)},[c,h,M,u,g]),{teamId:D,ensureTeamIdForProject:N}=Pp(),{members:z,loading:L,fetchMembers:ee}=t7();oa.useEffect(()=>{if(e&&!D)N(e)},[e,D,N]);let{isDrawing:te,setIsDrawing:J,currentTool:ae,setTool:Q,currentColor:Y,setColor:$,undo:fe,redo:P,history:qe,historyIndex:be,annotations:me,reset:de}=us(),[ye,xe]=oa.useState(!1),[Qe,ht]=oa.useState(""),[Oe,Ge]=oa.useState(0),[ft,Ie]=oa.useState({bots:!1,users:!1}),[He,Ze]=oa.useState(!1),Je=oa.default.useMemo(()=>{if(!O||c===void 0||!g&&!h||He)return"";if(M==="timecode")return"pl-[120px]";return"pl-[85px]"},[O,c,h,He,M]),$e=oa.useRef(null),Xt=oa.useRef(null),$t=oa.useRef(null),{mutateAsync:Ka}=Wf({mutationFn:async({projectId:ve,data:Re})=>{let et=await Bt.api.projects[":projectId"].attachments.$post({param:{projectId:ve},json:Re});if(!et.ok)throw Error("Failed to create attachment");return await et.json()}});oa.useEffect(()=>{if(i&&$e.current){$e.current.innerText=i,Ze(!!i.trim()),$e.current.focus();let ve=document.createRange(),Re=window.getSelection();ve.selectNodeContents($e.current),ve.collapse(!1),Re?.removeAllRanges(),Re?.addRange(ve)}},[i]),oa.useEffect(()=>{if(a&&$e.current){$e.current.focus();let ve=document.createRange(),Re=window.getSelection();ve.selectNodeContents($e.current),ve.collapse(!1),Re?.removeAllRanges(),Re?.addRange(ve)}},[a]),oa.useEffect(()=>{return()=>{J(!1)}},[J]);let Ht=[...z.filter((ve)=>ve.type==="agent"&&ve.name?.toLowerCase().startsWith(Qe.toLowerCase())).map((ve)=>({type:"user",data:ve})),...s.filter((ve)=>ve.name?.toLowerCase().startsWith(Qe.toLowerCase())).map((ve)=>({type:"bot",data:ve}))],_a=z.filter((ve)=>ve.type!=="agent"&&ve.name?.toLowerCase().startsWith(Qe.toLowerCase())).map((ve)=>({type:"user",data:ve})),st=[...ft.bots?[]:Ht,...ft.users?[]:_a];oa.useEffect(()=>{Ge(0)},[Qe,ye,ft]);let sn=()=>{if(!$e.current)return;if(Ze(!!$e.current.innerText.trim()),b?.(),f){xe(!1),$t.current=null;return}let ve=window.getSelection();if(!ve||ve.rangeCount===0)return;let Re=ve.getRangeAt(0),et=Re.startContainer,_t=Re.startOffset;if(et.nodeType===Node.TEXT_NODE){let ia=(et.textContent||"").slice(0,_t),ln=ia.lastIndexOf("@");if(ln!==-1){let Pa=ln===0,Vs=ia[ln-1];if(Pa||/\s/.test(Vs)){let Xe=ia.slice(ln+1);if(!/\s/.test(Xe)){if(ht(Xe),xe(!0),D)ee(D,!0,!0);let Ae=document.createRange();Ae.setStart(et,ln),Ae.setEnd(et,_t),$t.current=Ae;return}}}}xe(!1),$t.current=null},Ot=(ve)=>{if(!$t.current||!$e.current)return;let Re=$t.current;Re.deleteContents();let et=document.createElement("span");et.contentEditable="false",et.dataset.type="mention",et.dataset.id=ve.data.id,et.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",et.innerText=`@${ve.data.name}`,Re.insertNode(et);let _t=document.createTextNode(" ");et.after(_t);let Oa=document.createRange(),ia=window.getSelection();Oa.setStartAfter(_t),Oa.collapse(!0),ia?.removeAllRanges(),ia?.addRange(Oa),xe(!1),$t.current=null,Ze(!0),$e.current.focus()},Xn=(ve)=>{if(ve.nativeEvent.isComposing)return;if(ye&&st.length>0){if(ve.key==="ArrowUp"){ve.preventDefault(),Ge((Re)=>Re>0?Re-1:st.length-1);return}if(ve.key==="ArrowDown"){ve.preventDefault(),Ge((Re)=>Re<st.length-1?Re+1:0);return}if(ve.key==="Enter"||ve.key==="Tab"){ve.preventDefault(),Ot(st[Oe]);return}if(ve.key==="Escape"){ve.preventDefault(),xe(!1);return}}if(ve.key==="Enter"&&!ve.shiftKey)ve.preventDefault(),Da()},kn=oa.useCallback(async(ve)=>{if(!ve.target.files)return;let Re=Array.from(ve.target.files);for(let et of Re){let _t=`${Date.now()}-${et.name}`,Oa={id:_t,file:et,progress:0};A((ia)=>[...ia,Oa]);try{let ia=await Ka({projectId:e,data:{fileName:et.name,contentType:et.type,size:et.size}});if(ia.uploadUrl&&ia.id)await fetch(ia.uploadUrl,{method:"PUT",body:et,headers:{"Content-Type":et.type}}),A((ln)=>ln.map((Pa)=>Pa.id===_t?{...Pa,progress:100,attachmentId:ia.id}:Pa))}catch(ia){A((ln)=>ln.map((Pa)=>Pa.id===_t?{...Pa,error:ia instanceof Error?ia.message:"Upload failed"}:Pa))}}if(Xt.current)Xt.current.value=""},[e,Ka]),Dn=(ve)=>{A((Re)=>Re.filter((et)=>et.id!==ve))},Da=()=>{if(!$e.current)return;if(j.some((_t)=>!_t.attachmentId&&!_t.error))return;let Re=j.map((_t)=>_t.attachmentId).filter((_t)=>!!_t),et="";if($e.current.childNodes.forEach((_t)=>{if(_t.nodeType===Node.TEXT_NODE)et+=_t.textContent;else if(_t.nodeType===Node.ELEMENT_NODE){let Oa=_t;if(Oa.dataset.type==="mention")et+=`<@${Oa.dataset.id}>`;else if(Oa.tagName==="BR")et+=`
26
- `;else if(Oa.tagName==="DIV"||Oa.tagName==="P")et+=`
27
- `+Oa.innerText;else et+=Oa.innerText}}),et=et.trim(),!et&&Re.length===0&&me.length===0)return;if(t(et,Re,me,a?.id,O?c:void 0),$e.current.innerHTML="",Ze(!1),A([]),C(null),J(!1),de(),xe(!1),n)n()},Fa=j.some((ve)=>!ve.attachmentId&&!ve.error),Ra=j.some((ve)=>!!ve.attachmentId),Na=He||Ra||me.length>0,ns=j.length>0||!!a;return he("div",{ref:d,className:"relative flex flex-col w-full border border-foreground/35 rounded-3xl shadow-sm transition-all duration-200",children:[I("style",{children:`
28
- [contenteditable]:empty:before {
29
- content: attr(data-placeholder);
30
- color: #9ca3af;
31
- cursor: text;
32
- }
33
- `}),ye&&(L||Ht.length>0||_a.length>0)&&I("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:I("div",{className:"h-64 overflow-y-auto",children:L?he("div",{className:"p-2 space-y-4 animate-pulse",children:[he("div",{className:"space-y-2",children:[I("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:I(hs,{className:"h-3 w-16"})}),he("div",{className:"flex items-center gap-2 px-3 py-2",children:[I(hs,{className:"w-6 h-6 rounded-full"}),I(hs,{className:"h-4 w-28"})]}),he("div",{className:"flex items-center gap-2 px-3 py-2",children:[I(hs,{className:"w-6 h-6 rounded-full"}),I(hs,{className:"h-4 w-20"})]})]}),he("div",{className:"space-y-2",children:[I("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:I(hs,{className:"h-3 w-16"})}),he("div",{className:"flex items-center gap-2 px-3 py-2",children:[I(hs,{className:"w-6 h-6 rounded-full"}),I(hs,{className:"h-4 w-32"})]}),he("div",{className:"flex items-center gap-2 px-3 py-2",children:[I(hs,{className:"w-6 h-6 rounded-full"}),I(hs,{className:"h-4 w-24"})]})]})]}):he(I2,{children:[Ht.length>0&&he(I2,{children:[he("button",{onClick:(ve)=>{ve.preventDefault(),ve.stopPropagation(),Ie((Re)=>({...Re,bots:!Re.bots}))},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border sticky top-0 flex items-center justify-between hover:bg-muted transition-colors",children:[I("span",{children:"Agents"}),I(Co,{className:`w-3 h-3 transition-transform ${ft.bots?"-rotate-90":""}`})]}),!ft.bots&&Ht.map((ve,Re)=>{let et=Re;return he("button",{onClick:()=>Ot(ve),onMouseEnter:()=>Ge(et),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left ${et===Oe?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[I("div",{className:"w-6 h-6 rounded-full bg-purple-100 dark:bg-purple-900/40 flex items-center justify-center text-xs font-bold text-purple-600 dark:text-purple-300",children:ve.data.name?.[0]}),I("span",{className:"text-sm",children:ve.data.name})]},ve.data.id)})]}),_a.length>0&&he(I2,{children:[he("button",{onClick:(ve)=>{ve.preventDefault(),ve.stopPropagation(),Ie((Re)=>({...Re,users:!Re.users}))},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border sticky top-0 flex items-center justify-between hover:bg-muted transition-colors",children:[I("span",{children:"Members"}),I(Co,{className:`w-3 h-3 transition-transform ${ft.users?"-rotate-90":""}`})]}),!ft.users&&_a.map((ve,Re)=>{let et=(ft.bots?0:Ht.length)+Re;return he("button",{onClick:()=>Ot(ve),onMouseEnter:()=>Ge(et),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left ${et===Oe?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[I("div",{className:"w-6 h-6 rounded-full bg-blue-100 dark:bg-blue-900/40 flex items-center justify-center text-xs font-bold text-blue-600 dark:text-blue-300",children:ve.data.name?.[0]}),I("span",{className:"text-sm",children:ve.data.name})]},ve.data.id)})]})]})})}),ns&&he("div",{className:"flex flex-col gap-2 p-3 pb-0 animate-in fade-in slide-in-from-bottom-2 duration-200",children:[a&&he("div",{className:"flex items-center justify-between bg-muted p-2 px-3 rounded-lg border border-border",children:[I("div",{className:"text-xs text-muted-foreground truncate mr-2",children:Le.reply_to_message({message:a.message||""})}),I("button",{onClick:n,className:"text-muted-foreground hover:text-foreground p-1 rounded-full hover:bg-muted-foreground/10 shrink-0",children:I(_o,{className:"w-3.5 h-3.5"})})]}),j.length>0&&I("div",{className:"flex gap-3 overflow-x-auto py-2 px-1 scrollbar-hide",children:j.map((ve)=>he("div",{className:"relative group flex-shrink-0",children:[he("div",{className:"w-16 h-16 rounded-lg border border-gray-200 overflow-hidden bg-gray-50 flex items-center justify-center",children:[ve.file.type.startsWith("image/")?I("img",{src:URL.createObjectURL(ve.file),alt:"preview",onClick:()=>C(ve.file),className:`w-full h-full object-cover ${!ve.attachmentId?"opacity-50":""}`}):I(z2,{className:"w-8 h-8 text-gray-400"}),Fa&&!ve.attachmentId&&!ve.error&&I("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:I(e7,{progress:ve.progress,className:"w-10 h-10"})})]}),I("button",{onClick:()=>Dn(ve.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:I(_o,{className:"w-3 h-3"})}),I("span",{className:"text-[10px] text-gray-500 mt-1 block max-w-[4rem] truncate text-center",children:ve.file.name})]},ve.id))})]}),he("div",{onClick:()=>$e.current?.focus(),className:"w-full px-4 pt-1 pb-1 cursor-text flow-root max-h-60 overflow-y-auto",children:[O&&c!==void 0&&h!==void 0&&I("div",{onClick:(ve)=>{ve.stopPropagation(),$e.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:H}),I("div",{ref:$e,contentEditable:!0,suppressContentEditableWarning:!0,onInput:sn,onKeyDown:Xn,"data-placeholder":a?Le.reply_placeholder():Le.message_placeholder(),className:`bg-transparent border-none focus:ring-0 resize-none min-h-[40px] leading-relaxed py-2 focus:outline-none block ${Je}`})]}),he("div",{className:"flex justify-between items-center px-2 pb-2",children:[te?he("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide w-full mr-2",children:[I(Si,{onClick:()=>{J(!1),de()},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:I(Vp,{className:"w-4 h-4"})}),I("div",{className:"h-4 w-px bg-gray-300 mx-1"}),I("button",{onClick:()=>Q("arrow"),className:`p-1.5 rounded hover:bg-gray-100 ${ae==="arrow"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Arrow",children:I(v3,{size:16,className:"rotate-45"})}),I("button",{onClick:()=>Q("line"),className:`p-1.5 rounded hover:bg-gray-100 ${ae==="line"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Line",children:I(El,{size:16,className:"-rotate-45"})}),I("button",{onClick:()=>Q("box"),className:`p-1.5 rounded hover:bg-gray-100 ${ae==="box"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Box",children:I($p,{size:16})}),I("button",{onClick:()=>Q("freehand"),className:`p-1.5 rounded hover:bg-gray-100 ${ae==="freehand"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Freehand",children:I(Yp,{size:16})}),I("div",{className:"h-4 w-px bg-gray-300 mx-1"}),he(U2,{children:[I(G2,{asChild:!0,children:he("button",{className:"flex items-center gap-1 p-1 rounded hover:bg-gray-100",children:[I("div",{className:"w-4 h-4 rounded-full border border-gray-200",style:{backgroundColor:Y}}),I(Co,{size:12,className:"text-gray-500"})]})}),I(X2,{className:"w-auto p-2",align:"center",side:"top",children:I("div",{className:"flex items-center gap-1",children:b_.map((ve)=>I("button",{onClick:()=>$(ve),className:`w-6 h-6 rounded-full border border-gray-200 transition-transform hover:scale-110 ${Y===ve?"ring-2 ring-blue-500 ring-offset-1":""}`,style:{backgroundColor:ve}},ve))})})]}),I("div",{className:"h-4 w-px bg-gray-300 mx-1"}),I("button",{onClick:fe,disabled:be<=0,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:I(Wp,{size:16})}),I("button",{onClick:P,disabled:be>=qe.length-1,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:I(Zp,{size:16})})]}):he("div",{className:"flex items-center gap-1",children:[I("input",{type:"file",ref:Xt,className:"hidden",multiple:!0,onChange:kn}),c!==void 0&&h!==void 0&&I(Si,{onClick:()=>T(!O),variant:O?"secondary":"ghost",size:"icon",className:`p-2 rounded-full cursor-pointer ${O?"text-blue-600 bg-blue-50 dark:bg-blue-900/20":""}`,title:O?Le.disable_timestamp():Le.enable_timestamp(),children:I(Jp,{className:"w-4 h-4"})}),I(Si,{onClick:()=>Xt.current?.click(),className:"p-2 rounded-full cursor-pointer",variant:"ghost",size:"icon",title:Le.attach_files(),children:I(Qp,{className:"w-4 h-4"})}),!l&&I(Si,{onClick:()=>J(!0),variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer",title:Le.toggle_annotation(),children:I(E2,{className:"w-4 h-4"})})]}),I("button",{onClick:Da,disabled:!Na||Fa,className:`p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 ${Na&&!Fa?"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:I(v3,{className:"w-4 h-4"})})]}),S&&he("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:[I("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:I(_o,{className:"w-8 h-8"})}),I("div",{className:"w-full h-full flex items-center justify-center p-2",children:I("img",{src:URL.createObjectURL(S),alt:"Enlarged view",className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:(ve)=>{ve.stopPropagation(),C(null)}})}),I("div",{className:"absolute bottom-6 text-white text-sm font-medium bg-black/50 px-4 py-2 rounded-full backdrop-blur-sm",children:S.name})]})]})});k3.displayName="ChatInput";var Ic=Mt(Za(),1);function n7({isOpen:e,onClose:t,onSuccess:a,children:n}){let[s,i]=Ic.useState(""),[l,f]=Ic.useState(""),[c,h]=Ic.useState(!1),[u,g]=Ic.useState(null);return he(U2,{open:e,onOpenChange:(d)=>!d&&t(),children:[I(G2,{asChild:!0,children:n}),I(X2,{className:"w-80",align:"end",side:"top",children:he("form",{onSubmit:async(d)=>{d.preventDefault(),h(!0),g(null);try{let j=await Bt.api.identify.$post({json:{username:s,email:l}});if(!j.ok){let S=await j.json();throw Error(S.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:[he("div",{className:"space-y-2",children:[I("h4",{className:"font-medium leading-none",children:Le.enter_your_details()}),I("p",{className:"text-sm text-muted-foreground",children:Le.provide_name_email_for_comment()})]}),he("div",{className:"grid gap-2",children:[he("div",{className:"grid gap-1",children:[I(y3,{htmlFor:"name",children:Le.name()}),I(A3,{id:"name",value:s,onChange:(d)=>i(d.target.value),placeholder:Le.name_placeholder(),size:32,required:!0})]}),he("div",{className:"grid gap-1",children:[I(y3,{htmlFor:"email",children:Le.email()}),I(A3,{id:"email",type:"email",value:l,onChange:(d)=>f(d.target.value),placeholder:Le.email_field_placeholder(),required:!0})]}),u&&I("p",{className:"text-xs text-destructive",children:u})]}),he("div",{className:"flex justify-end gap-2",children:[I(Si,{type:"button",variant:"outline",size:"sm",onClick:t,children:Le.cancel()}),he(Si,{type:"submit",size:"sm",disabled:c,children:[c&&I(a7,{className:"mr-2 h-3 w-3 animate-spin"}),Le.confirm()]})]})]})})]})}var jt=Mt(Za(),1);var K=Mt(Ki(),1),Se=Mt(x3(),1),p4=Mt(X7(),1),X6=Mt(nb(),1);function va(){return va=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},va.apply(null,arguments)}var Bo=Mt(Ki(),1),sb="https://example.com",_F=function(t,a){if(/^[a-z]+:/i.test(a))return a;if(/^data:/.test(t))t=Bo.default.location&&Bo.default.location.href||"";var n=/^\/\//.test(t),s=!Bo.default.location&&!/\/\//i.test(t);t=new Bo.default.URL(t,Bo.default.location||sb);var i=new URL(a,t);if(s)return i.href.slice(sb.length);else if(n)return i.href.slice(i.protocol.length);return i.href},To=_F;var Y2=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 l=0;l<i;++l)s[l].call(this,arguments[1])}else{var f=Array.prototype.slice.call(arguments,1),c=s.length;for(var h=0;h<c;++h)s[h].apply(this,f)}},t.dispose=function(){this.listeners={}},t.pipe=function(n){this.on("data",function(s){n.push(s)})},e}();var G3=Mt(Ki(),1),FF=function(t){return G3.default.atob?G3.default.atob(t):Buffer.from(t,"base64").toString("binary")};function Yc(e){var t=FF(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 lb extends Y2{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 OF=String.fromCharCode(9),X3=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},BF=function(){return new RegExp("(?:^|,)("+'(?:[^=]*)=(?:"[^"]*"|[^,]*)'+")")},Qn=function(e){let t={};if(!e)return t;let a=e.split(BF()),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},ib=(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 fb extends Y2{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 l=i(e);if(l===e)return s;return s.concat([l])},[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=va(X3(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=Qn(t[1]);if(i.URI)a.uri=i.URI;if(i.BYTERANGE)a.byterange=X3(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=Qn(t[1]),a.attributes.RESOLUTION)a.attributes.RESOLUTION=ib(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=Qn(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=Qn(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=Qn(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=Qn(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(OF);this.trigger("data",a);return}if(t=/^#EXT-X-PART:(.*)$/.exec(s),t&&t[1]){if(a={type:"tag",tagType:"part"},a.attributes=Qn(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=X3(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=Qn(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=Qn(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=Qn(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(i){if(a.attributes.hasOwnProperty(i)){a.attributes[i]=parseInt(a.attributes[i],10);let l=i==="BYTERANGE-LENGTH"?"length":"offset";a.attributes.byterange=a.attributes.byterange||{},a.attributes.byterange[l]=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=Qn(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=Qn(t[1]),["ID","CLASS"].forEach(function(l){if(a.attributes.hasOwnProperty(l))a.attributes[l]=String(a.attributes[l])}),["START-DATE","END-DATE"].forEach(function(l){if(a.attributes.hasOwnProperty(l))a.attributes[l]=new Date(a.attributes[l])}),["DURATION","PLANNED-DURATION"].forEach(function(l){if(a.attributes.hasOwnProperty(l))a.attributes[l]=parseFloat(a.attributes[l])}),["END-ON-NEXT"].forEach(function(l){if(a.attributes.hasOwnProperty(l))a.attributes[l]=/YES/i.test(a.attributes[l])}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(l){if(a.attributes.hasOwnProperty(l))a.attributes[l]=a.attributes[l].toString(16)});let i=/^X-([A-Z]+-)+[A-Z]+$/;for(let l in a.attributes){if(!i.test(l))continue;let f=/[0-9A-Fa-f]{6}/g.test(a.attributes[l]),c=/^\d+(\.\d+)?$/.test(a.attributes[l]);a.attributes[l]=f?a.attributes[l].toString(16):c?parseFloat(a.attributes[l]):String(a.attributes[l])}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=Qn(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=Qn(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=ib(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=Qn(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 TF=(e)=>e.toLowerCase().replace(/-(\w)/g,(t)=>t[1].toUpperCase()),Ul=function(e){let t={};return Object.keys(e).forEach(function(a){t[TF(a)]=e[a]}),t},K3=function(e){let{serverControl:t,targetDuration:a,partTargetDuration:n}=e;if(!t)return;let s="#EXT-X-SERVER-CONTROL",i="holdBack",l="partHoldBack",f=a&&a*3,c=n&&n*2;if(a&&!t.hasOwnProperty(i))t[i]=f,this.trigger("info",{message:`${s} defaulting HOLD-BACK to targetDuration * 3 (${f}).`});if(f&&t[i]<f)this.trigger("warn",{message:`${s} clamping HOLD-BACK (${t[i]}) to targetDuration * 3 (${f})`}),t[i]=f;if(n&&!t.hasOwnProperty(l))t[l]=n*3,this.trigger("info",{message:`${s} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${t[l]}).`});if(n&&t[l]<c)this.trigger("warn",{message:`${s} clamping PART-HOLD-BACK (${t[l]}) to partTargetDuration * 2 (${c}).`}),t[l]=c};class L3 extends Y2{constructor(e={}){super();this.lineStream=new lb,this.parseStream=new fb,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,l=!1,f=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,S;if(t.manifest.definitions)for(let C in t.manifest.definitions){if(j.uri)j.uri=j.uri.replace(`{$${C}}`,t.manifest.definitions[C]);if(j.attributes){for(let O in j.attributes)if(typeof j.attributes[O]==="string")j.attributes[O]=j.attributes[O].replace(`{$${C}}`,t.manifest.definitions[C])}}({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 C={};if("length"in j){if(n.byterange=C,C.length=j.length,!("offset"in j))j.offset=g}if("offset"in j)n.byterange=C,C.offset=j.offset;g=C.offset+C.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:Yc(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={};va(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 C=this.manifest.mediaGroups[j.attributes.TYPE];if(C[j.attributes["GROUP-ID"]]=C[j.attributes["GROUP-ID"]]||{},A=C[j.attributes["GROUP-ID"]],S={default:/yes/i.test(j.attributes.DEFAULT)},S.default)S.autoselect=!0;else S.autoselect=/yes/i.test(j.attributes.AUTOSELECT);if(j.attributes.LANGUAGE)S.language=j.attributes.LANGUAGE;if(j.attributes.URI)S.uri=j.attributes.URI;if(j.attributes["INSTREAM-ID"])S.instreamId=j.attributes["INSTREAM-ID"];if(j.attributes.CHARACTERISTICS)S.characteristics=j.attributes.CHARACTERISTICS;if(j.attributes.FORCED)S.forced=/yes/i.test(j.attributes.FORCED);A[j.attributes.NAME]=S},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:C}=this;if(this.lastProgramDateTime=new Date(j.dateTimeString).getTime(),C===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,K3.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=Ul(j.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",j.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;let C=this.manifest.segments.length,O=Ul(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 #${C}`,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 C=this.manifest.serverControl=Ul(j.attributes);if(!C.hasOwnProperty("canBlockReload"))C.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"});if(K3.call(this,this.manifest),C.canSkipDateranges&&!C.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 C=this.manifest.segments.length,O=Ul(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 #${C}`,j.attributes,["TYPE","URI"]),!O.type)return;for(let H=0;H<n.preloadHints.length-1;H++){let D=n.preloadHints[H];if(!D.type)continue;if(D.type===O.type)this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${M} for segment #${C} has the same TYPE ${O.type} as preload hint #${H}`})}},"rendition-report"(){let C=Ul(j.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(C);let O=this.manifest.renditionReports.length-1,T=["LAST-MSN","URI"];if(l)T.push("LAST-PART");this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${O}`,j.attributes,T)},"part-inf"(){if(this.manifest.partInf=Ul(j.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",j.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget)this.manifest.partTargetDuration=this.manifest.partInf.partTarget;K3.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(Ul(j.attributes));let C=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${C}`,j.attributes,["ID","START-DATE"]);let O=this.manifest.dateRanges[C];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[C].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]=va(this.manifest.dateRanges[M],O),d[O.id]=va(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=Ul(j.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",j.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};let C=(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}C(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}C(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}C(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]||f).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 nr=Mt(Ki(),1),sr={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^/},MF=["video","audio","text"],rb=["Video","Audio","Text"],V3=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),l=("00"+Number(s).toString(16)).slice(-2);return"avc1."+i+"00"+l})};var _i=function(t){if(t===void 0)t="";var a=t.split(","),n=[];return a.forEach(function(s){s=s.trim();var i;if(MF.forEach(function(l){var f=sr[l].exec(s.toLowerCase());if(!f||f.length<=1)return;i=l;var c=s.substring(0,f[1].length),h=s.replace(c,"");n.push({type:c,details:h,mediaType:l})}),!i)n.push({type:s,details:"",mediaType:"unknown"})}),n},ob=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 _i(i.playlists[0].attributes.CODECS)}return null};var Y3=function(t){if(t===void 0)t="";return sr.audio.test(t.trim().toLowerCase())},HF=function(t){if(t===void 0)t="";return sr.text.test(t.trim().toLowerCase())},ir=function(t){if(!t||typeof t!=="string")return;var a=t.toLowerCase().split(",").map(function(i){return V3(i.trim())}),n="video";if(a.length===1&&Y3(a[0]))n="audio";else if(a.length===1&&HF(a[0]))n="application";var s="mp4";if(a.every(function(i){return sr.mp4.test(i)}))s="mp4";else if(a.every(function(i){return sr.webm.test(i)}))s="webm";else if(a.every(function(i){return sr.ogg.test(i)}))s="ogg";return n+"/"+s+';codecs="'+t+'"'},Mo=function(t,a){if(t===void 0)t="";if(a===void 0)a=!1;return nr.default.MediaSource&&nr.default.MediaSource.isTypeSupported&&nr.default.MediaSource.isTypeSupported(ir(t))||a&&nr.default.ManagedMediaSource&&nr.default.ManagedMediaSource.isTypeSupported&&nr.default.ManagedMediaSource.isTypeSupported(ir(t))||!1},J2=function(t){if(t===void 0)t="";return t.toLowerCase().split(",").every(function(a){a=a.trim();for(var n=0;n<rb.length;n++){var s=rb[n];if(sr["muxer"+s].test(a))return!0}return!1})},J3="mp4a.40.2",cb="avc1.4d400d";var xF=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,DF=/^application\/dash\+xml/i,Q3=function(t){if(xF.test(t))return"hls";if(DF.test(t))return"dash";if(t==="application/vnd.videojs.vhs+json")return"vhs-json";return null};var hb=Mt(Ki(),1);var RF=function(t){return t.toString(2).length},NF=function(t){return Math.ceil(RF(t)/8)};var $3=function(t){if(ArrayBuffer.isView==="function")return ArrayBuffer.isView(t);return t&&t.buffer instanceof ArrayBuffer},zF=function(t){return $3(t)},Ve=function(t){if(t instanceof Uint8Array)return t;if(!Array.isArray(t)&&!zF(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 On=hb.default.BigInt||Number,Z3=[On("0x1"),On("0x100"),On("0x10000"),On("0x1000000"),On("0x100000000"),On("0x10000000000"),On("0x1000000000000"),On("0x100000000000000"),On("0x10000000000000000")],AI=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 W3=function(t,a){var n=a===void 0?{}:a,s=n.signed,i=s===void 0?!1:s,l=n.le,f=l===void 0?!1:l;t=Ve(t);var c=f?"reduce":"reduceRight",h=t[c]?t[c]:Array.prototype[c],u=h.call(t,function(b,d,j){var A=f?j:Math.abs(j+1-t.length);return b+On(d)*Z3[A]},On(0));if(i){var g=Z3[t.length]/On(2)-On(1);if(u=On(u),u>g)u-=g,u-=g,u-=On(2)}return Number(u)},ub=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=On(t);var l=NF(t),f=new Uint8Array(new ArrayBuffer(l));for(var c=0;c<l;c++){var h=i?c:Math.abs(c+1-f.length);if(f[h]=Number(t/Z3[c]&On(255)),t<0)f[h]=Math.abs(~f[h]),f[h]-=c===0?1:2}return f},P3=function(t){if(!t)return"";t=Array.prototype.slice.call(t);var a=String.fromCharCode.apply(null,Ve(t));try{return decodeURIComponent(escape(a))}catch(n){}return a},Q2=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},mb=function(){for(var t=arguments.length,a=Array(t),n=0;n<t;n++)a[n]=arguments[n];if(a=a.filter(function(f){return f&&(f.byteLength||f.length)&&typeof f!=="string"}),a.length<=1)return Ve(a[0]);var s=a.reduce(function(f,c,h){return f+(c.byteLength||c.length)},0),i=new Uint8Array(s),l=0;return a.forEach(function(f){f=Ve(f),i.set(f,l),l+=f.byteLength}),i},Vt=function(t,a,n){var s=n===void 0?{}:n,i=s.offset,l=i===void 0?0:i,f=s.mask,c=f===void 0?[]:f;t=Ve(t),a=Ve(a);var h=a.every?a.every:Array.prototype.every;return a.length&&t.length-l>=a.length&&h.call(a,function(u,g){var b=c[g]?c[g]&t[l+g]:t[l+g];return u===b})};var Zn=Mt(Ki(),1);var gb=function(t,a,n){a.forEach(function(s){for(var i in t.mediaGroups[s])for(var l in t.mediaGroups[s][i]){var f=t.mediaGroups[s][i][l];n(f,s,i,l)}})};var lw=u6();var{DOMImplementation:EO,XMLSerializer:IO}=lw,p6=iw().DOMParser;/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */var fw=(e)=>{return!!e&&typeof e==="object"},bn=(...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(fw(t[n])&&fw(a[n]))t[n]=bn(t[n],a[n]);else t[n]=a[n]}),t},{})},gw=(e)=>Object.keys(e).map((t)=>e[t]),UO=(e,t)=>{let a=[];for(let n=e;n<t;n++)a.push(n);return a},Go=(e)=>e.reduce((t,a)=>t.concat(a),[]),pw=(e)=>{if(!e.length)return[];let t=[];for(let a=0;a<e.length;a++)t.push(e[a]);return t},GO=(e,t)=>e.reduce((a,n,s)=>{if(n[t])a.push(s);return a},[]),XO=(e,t)=>{return gw(e.reduce((a,n)=>{return n.forEach((s)=>{a[t(s)]=s}),a},{}))},Xo={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"},ih=({baseUrl:e="",source:t="",range:a="",indexRange:n=""})=>{let s={uri:t,resolvedUri:To(e||"",t)};if(a||n){let l=(a?a:n).split("-"),f=Zn.default.BigInt?Zn.default.BigInt(l[0]):parseInt(l[0],10),c=Zn.default.BigInt?Zn.default.BigInt(l[1]):parseInt(l[1],10);if(f<Number.MAX_SAFE_INTEGER&&typeof f==="bigint")f=Number(f);if(c<Number.MAX_SAFE_INTEGER&&typeof c==="bigint")c=Number(c);let h;if(typeof c==="bigint"||typeof f==="bigint")h=Zn.default.BigInt(c)-Zn.default.BigInt(f)+Zn.default.BigInt(1);else h=c-f+1;if(typeof h==="bigint"&&h<Number.MAX_SAFE_INTEGER)h=Number(h);s.byterange={length:h,offset:f}}return s},KO=(e)=>{let t;if(typeof e.offset==="bigint"||typeof e.length==="bigint")t=Zn.default.BigInt(e.offset)+Zn.default.BigInt(e.length)-Zn.default.BigInt(1);else t=e.offset+e.length-1;return`${e.offset}-${t}`},rw=(e)=>{if(e&&typeof e!=="number")e=parseInt(e,10);if(isNaN(e))return null;return e},LO={static(e){let{duration:t,timescale:a=1,sourceDuration:n,periodDuration:s}=e,i=rw(e.endNumber),l=t/a;if(typeof i==="number")return{start:0,end:i};if(typeof s==="number")return{start:0,end:s/l};return{start:0,end:n/l}},dynamic(e){let{NOW:t,clientOffset:a,availabilityStartTime:n,timescale:s=1,duration:i,periodStart:l=0,minimumUpdatePeriod:f=0,timeShiftBufferDepth:c=1/0}=e,h=rw(e.endNumber),u=(t+a)/1000,g=n+l,d=u+f-g,j=Math.ceil(d*s/i),A=Math.floor((u-g-c)*s/i),S=Math.floor((u-g)*s/i);return{start:Math.max(0,A),end:typeof h==="number"?h:Math.min(j,S)}}},VO=(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}},w6=(e)=>{let{type:t,duration:a,timescale:n=1,periodDuration:s,sourceDuration:i}=e,{start:l,end:f}=LO[t](e),c=UO(l,f).map(VO(e));if(t==="static"){let h=c.length-1,u=typeof s==="number"?s:i;c[h].duration=u-a/n*h}return c},bw=(e)=>{let{baseUrl:t,initialization:a={},sourceDuration:n,indexRange:s="",periodStart:i,presentationTime:l,number:f=0,duration:c}=e;if(!t)throw Error(Xo.NO_BASE_URL);let h=ih({baseUrl:t,source:a.sourceURL,range:a.range}),u=ih({baseUrl:t,source:t,indexRange:s});if(u.map=h,c){let g=w6(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=l||i,u.number=f,[u]},lm=(e,t,a)=>{let n=e.sidx.map?e.sidx.map:null,s=e.sidx.duration,i=e.timeline||0,l=e.sidx.byterange,f=l.offset+l.length,c=t.timescale,h=t.references.filter((S)=>S.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=Zn.default.BigInt(f)+t.firstOffset;else A=f+t.firstOffset;for(let S=0;S<h.length;S++){let C=t.references[S],O=C.referencedSize,T=C.subsegmentDuration,M;if(typeof A==="bigint")M=A+Zn.default.BigInt(O)-Zn.default.BigInt(1);else M=A+O-1;let H=`${A}-${M}`,N=bw({baseUrl:a,timescale:c,timeline:i,periodStart:b,presentationTime:d,number:j,duration:T,sourceDuration:s,indexRange:H,type:g})[0];if(n)N.map=n;if(u.push(N),typeof A==="bigint")A+=Zn.default.BigInt(O);else A+=O;d+=T/c,j++}return e.segments=u,e},YO=["AUDIO","SUBTITLES"],JO=0.016666666666666666,ww=(e)=>{return XO(e,({timeline:t})=>t).sort((t,a)=>t.timeline>a.timeline?1:-1)},QO=(e,t)=>{for(let a=0;a<e.length;a++)if(e[a].attributes.NAME===t)return e[a];return null},ow=(e)=>{let t=[];return gb(e,YO,(a,n,s,i)=>{t=t.concat(a.playlists||[])}),t},cw=({playlist:e,mediaSequence:t})=>{e.mediaSequence=t,e.segments.forEach((a,n)=>{a.number=e.mediaSequence+n})},ZO=({oldPlaylists:e,newPlaylists:t,timelineStarts:a})=>{t.forEach((n)=>{n.discontinuitySequence=a.findIndex(function({timeline:c}){return c===n.timeline});let s=QO(e,n.attributes.NAME);if(!s)return;if(n.sidx)return;let i=n.segments[0],l=s.segments.findIndex(function(c){return Math.abs(c.presentationTime-i.presentationTime)<JO});if(l===-1){if(cw({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[l].discontinuity&&!i.discontinuity)i.discontinuity=!0,n.discontinuityStarts.unshift(0),n.discontinuitySequence--;cw({playlist:n,mediaSequence:s.segments[l].number})})},$O=({oldManifest:e,newManifest:t})=>{let a=e.playlists.concat(ow(e)),n=t.playlists.concat(ow(t));return t.timelineStarts=ww([e.timelineStarts,t.timelineStarts]),ZO({oldPlaylists:a,newPlaylists:n,timelineStarts:t.timelineStarts}),t},lh=(e)=>e&&e.uri+"-"+KO(e.byterange),b6=(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=gw(n.reduce((i,l)=>{let f=l.attributes.id+(l.attributes.lang||"");if(!i[f])i[f]=l,i[f].attributes.timelineStarts=[];else{if(l.segments){if(l.segments[0])l.segments[0].discontinuity=!0;i[f].segments.push(...l.segments)}if(l.attributes.contentProtection)i[f].attributes.contentProtection=l.attributes.contentProtection}return i[f].attributes.timelineStarts.push({start:l.attributes.periodStart,timeline:l.attributes.periodStart}),i},{}));a=a.concat(s)}),a.map((n)=>{return n.discontinuityStarts=GO(n.segments||[],"discontinuity"),n})},d6=(e,t)=>{let a=lh(e.sidx),n=a&&t[a]&&t[a].sidx;if(n)lm(e,n,e.sidx.resolvedUri);return e},WO=(e,t={})=>{if(!Object.keys(t).length)return e;for(let a in e)e[a]=d6(e[a],t);return e},PO=({attributes:e,segments:t,sidx:a,mediaSequence:n,discontinuitySequence:s,discontinuityStarts:i},l)=>{let f={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)f.contentProtection=e.contentProtection;if(e.serviceLocation)f.attributes.serviceLocation=e.serviceLocation;if(a)f.sidx=a;if(l)f.attributes.AUDIO="audio",f.attributes.SUBTITLES="subs";return f},eB=({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 l={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)l.attributes.serviceLocation=e.serviceLocation;return l},tB=(e,t={},a=!1)=>{let n,s=e.reduce((i,l)=>{let f=l.attributes.role&&l.attributes.role.value||"",c=l.attributes.lang||"",h=l.attributes.label||"main";if(c&&!l.attributes.label){let g=f?` (${f})`:"";h=`${l.attributes.lang}${g}`}if(!i[h])i[h]={language:c,autoselect:!0,default:f==="main",playlists:[],uri:""};let u=d6(PO(l,a),t);if(i[h].playlists.push(u),typeof n>"u"&&f==="main")n=l,n.default=!0;return i},{});if(!n){let i=Object.keys(s)[0];s[i].default=!0}return s},aB=(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(d6(eB(n),t)),a},{})},nB=(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},{}),sB=({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},iB=({attributes:e})=>e.mimeType==="video/mp4"||e.mimeType==="video/webm"||e.contentType==="video",lB=({attributes:e})=>e.mimeType==="audio/mp4"||e.mimeType==="audio/webm"||e.contentType==="audio",fB=({attributes:e})=>e.mimeType==="text/vtt"||e.contentType==="text",rB=(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})})},hw=(e)=>{if(!e)return[];return Object.keys(e).reduce((t,a)=>{let n=e[a];return t.concat(n.playlists)},[])},oB=({dashPlaylists:e,locations:t,contentSteering:a,sidxMapping:n={},previousManifest:s,eventStream:i})=>{if(!e.length)return{};let{sourceDuration:l,type:f,suggestedPresentationDelay:c,minimumUpdatePeriod:h}=e[0].attributes,u=b6(e.filter(iB)).map(sB),g=b6(e.filter(lB)),b=b6(e.filter(fB)),d=e.map((M)=>M.attributes.captionServices).filter(Boolean),j={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},["CLOSED-CAPTIONS"]:{},SUBTITLES:{}},uri:"",duration:l,playlists:WO(u,n)};if(h>=0)j.minimumUpdatePeriod=h*1000;if(t)j.locations=t;if(a)j.contentSteering=a;if(f==="dynamic")j.suggestedPresentationDelay=c;if(i&&i.length>0)j.eventStream=i;let A=j.playlists.length===0,S=g.length?tB(g,n,A):null,C=b.length?aB(b,n):null,O=u.concat(hw(S),hw(C)),T=O.map(({timelineStarts:M})=>M);if(j.timelineStarts=ww(T),rB(O,j.timelineStarts),S)j.mediaGroups.AUDIO.audio=S;if(C)j.mediaGroups.SUBTITLES.subs=C;if(d.length)j.mediaGroups["CLOSED-CAPTIONS"].cc=nB(d);if(s)return $O({oldManifest:s,newManifest:j});return j},cB=(e,t,a)=>{let{NOW:n,clientOffset:s,availabilityStartTime:i,timescale:l=1,periodStart:f=0,minimumUpdatePeriod:c=0}=e,h=(n+s)/1000,u=i+f,b=h+c-u;return Math.ceil((b*l-t)/a)},dw=(e,t)=>{let{type:a,minimumUpdatePeriod:n=0,media:s="",sourceDuration:i,timescale:l=1,startNumber:f=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 S;if(j<0){let T=g+1;if(T===t.length)if(a==="dynamic"&&n>0&&s.indexOf("$Number$")>0)S=cB(e,u,d);else S=(i*l-u)/d;else S=(t[T].t-u)/d}else S=j+1;let C=f+h.length+S,O=f+h.length;while(O<C)h.push({number:O,duration:d/l,time:u,timeline:c}),u+=d,O++}return h},hB=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,uB=(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}`},uw=(e,t)=>e.replace(hB,uB(t)),mB=(e,t)=>{if(!e.duration&&!t)return[{number:e.startNumber||1,duration:e.sourceDuration,time:0,timeline:e.periodStart}];if(e.duration)return w6(e);return dw(e,t)},gB=(e,t)=>{let a={RepresentationID:e.id,Bandwidth:e.bandwidth||0},{initialization:n={sourceURL:"",range:""}}=e,s=ih({baseUrl:e.baseUrl,source:uw(n.sourceURL,a),range:n.range});return mB(e,t).map((l)=>{a.Number=l.number,a.Time=l.time;let f=uw(e.media||"",a),c=e.timescale||1,h=e.presentationTimeOffset||0,u=e.periodStart+(l.time-h)/c;return{uri:f,timeline:l.timeline,duration:l.duration,resolvedUri:To(e.baseUrl||"",f),map:s,number:l.number,presentationTime:u}})},pB=(e,t)=>{let{baseUrl:a,initialization:n={}}=e,s=ih({baseUrl:a,source:n.sourceURL,range:n.range}),i=ih({baseUrl:a,source:t.media,range:t.mediaRange});return i.map=s,i},bB=(e,t)=>{let{duration:a,segmentUrls:n=[],periodStart:s}=e;if(!a&&!t||a&&t)throw Error(Xo.SEGMENT_TIME_UNSPECIFIED);let i=n.map((c)=>pB(e,c)),l;if(a)l=w6(e);if(t)l=dw(e,t);return l.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)},wB=({attributes:e,segmentInfo:t})=>{let a,n;if(t.template)n=gB,a=bn(e,t.template);else if(t.base)n=bw,a=bn(e,t.base);else if(t.list)n=bB,a=bn(e,t.list);let s={attributes:e};if(!n)return s;let i=n(a,t.segmentTimeline);if(a.duration){let{duration:l,timescale:f=1}=a;a.duration=l/f}else if(i.length)a.duration=i.reduce((l,f)=>{return Math.max(l,Math.ceil(f.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},dB=(e)=>e.map(wB),ga=(e,t)=>pw(e.childNodes).filter(({tagName:a})=>a===t),fh=(e)=>e.textContent.trim(),jB=(e)=>{return parseFloat(e.split("/").reduce((t,a)=>t/a))},Uo=(e)=>{let f=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(e);if(!f)return 0;let[c,h,u,g,b,d]=f.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)},qB=(e)=>{if(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(e))e+="Z";return Date.parse(e)},mw={mediaPresentationDuration(e){return Uo(e)},availabilityStartTime(e){return qB(e)/1000},minimumUpdatePeriod(e){return Uo(e)},suggestedPresentationDelay(e){return Uo(e)},type(e){return e},timeShiftBufferDepth(e){return Uo(e)},start(e){return Uo(e)},width(e){return parseInt(e,10)},height(e){return parseInt(e,10)},bandwidth(e){return parseInt(e,10)},frameRate(e){return jB(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 Uo(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}},$a=(e)=>{if(!(e&&e.attributes))return{};return pw(e.attributes).reduce((t,a)=>{let n=mw[a.name]||mw.DEFAULT;return t[a.name]=n(a.value),t},{})},vB={"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"},fm=(e,t)=>{if(!t.length)return e;return Go(e.map(function(a){return t.map(function(n){let s=fh(n),i=To(a.baseUrl,s),l=bn($a(n),{baseUrl:i});if(i!==s&&!l.serviceLocation&&a.serviceLocation)l.serviceLocation=a.serviceLocation;return l})}))},j6=(e)=>{let t=ga(e,"SegmentTemplate")[0],a=ga(e,"SegmentList")[0],n=a&&ga(a,"SegmentURL").map((g)=>bn({tag:"SegmentURL"},$a(g))),s=ga(e,"SegmentBase")[0],i=a||t,l=i&&ga(i,"SegmentTimeline")[0],f=a||s||t,c=f&&ga(f,"Initialization")[0],h=t&&$a(t);if(h&&c)h.initialization=c&&$a(c);else if(h&&h.initialization)h.initialization={sourceURL:h.initialization};let u={template:h,segmentTimeline:l&&ga(l,"S").map((g)=>$a(g)),list:a&&bn($a(a),{segmentUrls:n,initialization:$a(c)}),base:s&&bn($a(s),{initialization:$a(c)})};return Object.keys(u).forEach((g)=>{if(!u[g])delete u[g]}),u},kB=(e,t,a)=>(n)=>{let s=ga(n,"BaseURL"),i=fm(t,s),l=bn(e,$a(n)),f=j6(n);return i.map((c)=>{return{segmentInfo:bn(a,f),attributes:bn(l,c)}})},AB=(e)=>{return e.reduce((t,a)=>{let n=$a(a);if(n.schemeIdUri)n.schemeIdUri=n.schemeIdUri.toLowerCase();let s=vB[n.schemeIdUri];if(s){t[s]={attributes:n};let i=ga(a,"cenc:pssh")[0];if(i){let l=fh(i);t[s].pssh=l&&Yc(l)}}return t},{})},yB=(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((l)=>{let[f,c]=l.split(":");if(f==="lang")n.language=c;else if(f==="er")n.easyReader=Number(c);else if(f==="war")n.aspectRatio=Number(c);else if(f==="3D")n["3D"]=Number(c)})}else n.language=a;if(n.channel)n.channel="SERVICE"+n.channel;return n})},SB=(e)=>{return Go(ga(e.node,"EventStream").map((t)=>{let a=$a(t),n=a.schemeIdUri;return ga(t,"Event").map((s)=>{let i=$a(s),l=i.presentationTime||0,f=a.timescale||1,c=i.duration||0,h=l/f+e.attributes.start;return{schemeIdUri:n,value:a.value,id:i.id,start:h,end:h+c/f,messageData:fh(s)||i.messageData,contentEncoding:a.contentEncoding,presentationTimeOffset:a.presentationTimeOffset||0}})}))},CB=(e,t,a)=>(n)=>{let s=$a(n),i=fm(t,ga(n,"BaseURL")),l=ga(n,"Role")[0],f={role:$a(l)},c=bn(e,s,f),h=ga(n,"Accessibility")[0],u=yB($a(h));if(u)c=bn(c,{captionServices:u});let g=ga(n,"Label")[0];if(g&&g.childNodes.length){let S=g.childNodes[0].nodeValue.trim();c=bn(c,{label:S})}let b=AB(ga(n,"ContentProtection"));if(Object.keys(b).length)c=bn(c,{contentProtection:b});let d=j6(n),j=ga(n,"Representation"),A=bn(a,d);return Go(j.map(kB(c,i,A)))},_B=(e,t)=>(a,n)=>{let s=fm(t,ga(a.node,"BaseURL")),i=bn(e,{periodStart:a.attributes.start});if(typeof a.attributes.duration==="number")i.periodDuration=a.attributes.duration;let l=ga(a.node,"AdaptationSet"),f=j6(a.node);return Go(l.map(CB(i,s,f)))},FB=(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=bn({serverURL:fh(e[0])},$a(e[0]));return a.queryBeforeStart=a.queryBeforeStart==="true",a},OB=({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},BB=(e,t={})=>{let{manifestUri:a="",NOW:n=Date.now(),clientOffset:s=0,eventHandler:i=function(){}}=t,l=ga(e,"Period");if(!l.length)throw Error(Xo.INVALID_NUMBER_OF_PERIOD);let f=ga(e,"Location"),c=$a(e),h=fm([{baseUrl:a}],ga(e,"BaseURL")),u=ga(e,"ContentSteering");if(c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=n,c.clientOffset=s,f.length)c.locations=f.map(fh);let g=[];return l.forEach((b,d)=>{let j=$a(b),A=g[d-1];j.start=OB({attributes:j,priorPeriodAttributes:A?A.attributes:null,mpdType:c.type}),g.push({node:b,attributes:j})}),{locations:c.locations,contentSteeringInfo:FB(u,i),representationInfo:Go(g.map(_B(c,h))),eventStream:Go(g.map(SB))}},jw=(e)=>{if(e==="")throw Error(Xo.DASH_EMPTY_MANIFEST);let t=new p6,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(Xo.DASH_INVALID_XML);return n},TB=(e)=>{let t=ga(e,"UTCTiming")[0];if(!t)return null;let a=$a(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(Xo.UNSUPPORTED_UTC_TIMING_SCHEME)}return a};var qw=(e,t={})=>{let a=BB(jw(e),t),n=dB(a.representationInfo);return oB({dashPlaylists:n,locations:a.locations,contentSteering:a.contentSteeringInfo,sidxMapping:t.sidxMapping,previousManifest:t.previousManifest,eventStream:a.eventStream})},vw=(e)=>TB(jw(e));var Td=Mt(_w(),1);var xB=Ve([73,68,51]),DB=function(t,a){if(a===void 0)a=0;t=Ve(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},fr=function e(t,a){if(a===void 0)a=0;if(t=Ve(t),t.length-a<10||!Vt(t,xB,{offset:a}))return a;return a+=DB(t,a),e(t,a)};var eU=new Uint8Array([79,112,117,115,72,101,97,100]);var Ow=function(t){if(typeof t==="string")return Q2(t);if(typeof t==="number")return t;return t},IB=function(t){if(!Array.isArray(t))return[Ow(t)];return t.map(function(a){return Ow(a)})},q6,Bw=function(t){t=Ve(t);var a=[],n=0;while(t.length>n){var s=t[n],i=0,l=0;l++;var f=t[l];l++;while(f&128)i=(f&127)<<7,f=t[l],l++;i+=f&127;for(var c=0;c<q6.length;c++){var h=q6[c],u=h.id,g=h.parser;if(s===u){a.push(g(t.subarray(l,l+i)));break}}n+=i+l}return a};q6=[{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=P3(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=Bw(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:Bw(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 Tw=function e(t,a,n){if(n===void 0)n=!1;a=IB(a),t=Ve(t);var s=[];if(!a.length)return s;var i=0;while(i<t.length){var l=(t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3])>>>0,f=t.subarray(i+4,i+8);if(l===0)break;var c=i+l;if(c>t.length){if(n)break;c=t.length}var h=t.subarray(i+8,c);if(Vt(f,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 rh={EBML:Ve([26,69,223,163]),DocType:Ve([66,130]),Segment:Ve([24,83,128,103]),SegmentInfo:Ve([21,73,169,102]),Tracks:Ve([22,84,174,107]),Track:Ve([174]),TrackNumber:Ve([215]),DefaultDuration:Ve([35,227,131]),TrackEntry:Ve([174]),TrackType:Ve([131]),FlagDefault:Ve([136]),CodecID:Ve([134]),CodecPrivate:Ve([99,162]),VideoTrack:Ve([224]),AudioTrack:Ve([225]),Cluster:Ve([31,67,182,117]),Timestamp:Ve([231]),TimestampScale:Ve([42,215,177]),BlockGroup:Ve([160]),BlockDuration:Ve([155]),Block:Ve([161]),SimpleBlock:Ve([163])},v6=[128,64,32,16,8,4,2,1],UB=function(t){var a=1;for(var n=0;n<v6.length;n++){if(t&v6[n])break;a++}return a},rm=function(t,a,n,s){if(n===void 0)n=!0;if(s===void 0)s=!1;var i=UB(t[a]),l=t.subarray(a,a+i);if(n)l=Array.prototype.slice.call(t,a,a+i),l[0]^=v6[i-1];return{length:i,value:W3(l,{signed:s}),bytes:l}},Mw=function e(t){if(typeof t==="string")return t.match(/.{1,2}/g).map(function(a){return e(a)});if(typeof t==="number")return ub(t);return t},GB=function(t){if(!Array.isArray(t))return[Mw(t)];return t.map(function(a){return Mw(a)})},XB=function e(t,a,n){if(n>=a.length)return a.length;var s=rm(a,n,!1);if(Vt(t.bytes,s.bytes))return n;var i=rm(a,n+s.length);return e(t,a,n+i.length+i.value+s.length)},k6=function e(t,a){a=GB(a),t=Ve(t);var n=[];if(!a.length)return n;var s=0;while(s<t.length){var i=rm(t,s,!1),l=rm(t,s+i.length),f=s+i.length+l.length;if(l.value===127){if(l.value=XB(i,t,f),l.value!==t.length)l.value-=f}var c=f+l.value>t.length?t.length:f+l.value,h=t.subarray(f,c);if(Vt(a[0],i.bytes))if(a.length===1)n.push(h);else n=n.concat(e(h,a.slice(1)));var u=i.length+l.length+h.length;s+=u}return n};var KB=Ve([0,0,0,1]),LB=Ve([0,0,1]),VB=Ve([0,0,3]),YB=function(t){var a=[],n=1;while(n<t.length-2){if(Vt(t.subarray(n,n+3),VB))a.push(n+2),n++;n++}if(a.length===0)return t;var s=t.length-a.length,i=new Uint8Array(s),l=0;for(n=0;n<s;l++,n++){if(l===a[0])l++,a.shift();i[n]=t[l]}return i},Hw=function(t,a,n,s){if(s===void 0)s=1/0;t=Ve(t),n=[].concat(n);var i=0,l,f=0;while(i<t.length&&(f<s||l)){var c=void 0;if(Vt(t.subarray(i),KB))c=4;else if(Vt(t.subarray(i),LB))c=3;if(!c){i++;continue}if(f++,l)return YB(t.subarray(l,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)l=i+c;i+=c+(a==="h264"?1:2)}return t.subarray(0,0)},xw=function(t,a,n){return Hw(t,"h264",a,n)},Dw=function(t,a,n){return Hw(t,"h265",a,n)};var $n={webm:Ve([119,101,98,109]),matroska:Ve([109,97,116,114,111,115,107,97]),flac:Ve([102,76,97,67]),ogg:Ve([79,103,103,83]),ac3:Ve([11,119]),riff:Ve([82,73,70,70]),avi:Ve([65,86,73]),wav:Ve([87,65,86,69]),"3gp":Ve([102,116,121,112,51,103]),mp4:Ve([102,116,121,112]),fmp4:Ve([115,116,121,112]),mov:Ve([102,116,121,112,113,116]),moov:Ve([109,111,111,118]),moof:Ve([109,111,111,102])},Ko={aac:function(t){var a=fr(t);return Vt(t,[255,16],{offset:a,mask:[255,22]})},mp3:function(t){var a=fr(t);return Vt(t,[255,2],{offset:a,mask:[255,6]})},webm:function(t){var a=k6(t,[rh.EBML,rh.DocType])[0];return Vt(a,$n.webm)},mkv:function(t){var a=k6(t,[rh.EBML,rh.DocType])[0];return Vt(a,$n.matroska)},mp4:function(t){if(Ko["3gp"](t)||Ko.mov(t))return!1;if(Vt(t,$n.mp4,{offset:4})||Vt(t,$n.fmp4,{offset:4}))return!0;if(Vt(t,$n.moof,{offset:4})||Vt(t,$n.moov,{offset:4}))return!0},mov:function(t){return Vt(t,$n.mov,{offset:4})},"3gp":function(t){return Vt(t,$n["3gp"],{offset:4})},ac3:function(t){var a=fr(t);return Vt(t,$n.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=fr(t);return Vt(t,$n.flac,{offset:a})},ogg:function(t){return Vt(t,$n.ogg)},avi:function(t){return Vt(t,$n.riff)&&Vt(t,$n.avi,{offset:8})},wav:function(t){return Vt(t,$n.riff)&&Vt(t,$n.wav,{offset:8})},h264:function(t){return xw(t,7,3).length},h265:function(t){return Dw(t,[32,33],3).length}},A6=Object.keys(Ko).filter(function(e){return e!=="ts"&&e!=="h264"&&e!=="h265"}).concat(["ts","h264","h265"]);A6.forEach(function(e){var t=Ko[e];Ko[e]=function(a){return t(Ve(a))}});var JB=Ko,om=function(t){t=Ve(t);for(var a=0;a<A6.length;a++){var n=A6[a];if(JB[n](t))return n}return""},Rw=function(t){return Tw(t,["moof"]).length>0};var Yl=Mt(Uw(),1),K6="8.23.7",L0={},Ql=function(e,t){if(L0[e]=L0[e]||[],t)L0[e]=L0[e].concat(t);return L0[e]},QB=function(e,t){Ql(e,t)},Md=function(e,t){let a=Ql(e).indexOf(t);if(a<=-1)return!1;return L0[e]=L0[e].slice(),L0[e].splice(a,1),!0},ZB=function(e,t){Ql(e,[].concat(t).map((a)=>{let n=(...s)=>{return Md(e,n),a(...s)};return n}))},dm={prefixed:!0},pm=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],Gw=pm[0],uh;for(let e=0;e<pm.length;e++)if(pm[e][1]in Se.default){uh=pm[e];break}if(uh){for(let e=0;e<uh.length;e++)dm[Gw[e]]=uh[e];dm.prefixed=uh[0]!==Gw[0]}var bs=[],$B=(e,t,a)=>(n,s,i)=>{let l=t.levels[s],f=new RegExp(`^(${l})$`),c=e;if(n!=="log")i.unshift(n.toUpperCase()+":");if(a)c=`%c${e}`,i.unshift(a);if(i.unshift(c+":"),bs){bs.push([].concat(i));let u=bs.length-1000;bs.splice(0,u>0?u:0)}if(!K.default.console)return;let h=K.default.console[n];if(!h&&n==="debug")h=K.default.console.info||K.default.console.log;if(!h||!l||!f.test(n))return;h[Array.isArray(i)?"apply":"call"](K.default.console,i)};function L6(e,t=":",a=""){let n="info",s;function i(...l){s("log",n,l)}return s=$B(e,i,a),i.createLogger=(l,f,c)=>{let h=f!==void 0?f:t,u=c!==void 0?c:a,g=`${e} ${h} ${l}`;return L6(g,h,u)},i.createNewLogger=(l,f,c)=>{return L6(l,f,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=(l)=>{if(typeof l==="string"){if(!i.levels.hasOwnProperty(l))throw Error(`"${l}" in not a valid log level`);n=l}return n},i.history=()=>bs?[].concat(bs):[],i.history.filter=(l)=>{return(bs||[]).filter((f)=>{return new RegExp(`.*${l}.*`).test(f[0])})},i.history.clear=()=>{if(bs)bs.length=0},i.history.disable=()=>{if(bs!==null)bs.length=0,bs=null},i.history.enable=()=>{if(bs===null)bs=[]},i.error=(...l)=>s("error",n,l),i.warn=(...l)=>s("warn",n,l),i.debug=(...l)=>s("debug",n,l),i}var qt=L6("VIDEOJS"),Hd=qt.createLogger,WB=Object.prototype.toString,xd=function(e){return e0(e)?Object.keys(e):[]};function Qo(e,t){xd(e).forEach((a)=>t(e[a],a))}function Dd(e,t,a=0){return xd(e).reduce((n,s)=>t(n,e[s],s),a)}function e0(e){return!!e&&typeof e==="object"}function s1(e){return e0(e)&&WB.call(e)==="[object Object]"&&e.constructor===Object}function ea(...e){let t={};return e.forEach((a)=>{if(!a)return;Qo(a,(n,s)=>{if(!s1(n)){t[s]=n;return}if(!s1(t[s]))t[s]={};t[s]=ea(t[s],n)})}),t}function Rd(e={}){let t=[];for(let a in e)if(e.hasOwnProperty(a)){let n=e[a];t.push(n)}return t}function Em(e,t,a,n=!0){let s=(l)=>Object.defineProperty(e,t,{value:l,enumerable:!0,writable:!0}),i={configurable:!0,enumerable:!0,get(){let l=a();return s(l),l}};if(n)i.set=s;return Object.defineProperty(e,t,i)}var PB=Object.freeze({__proto__:null,each:Qo,reduce:Dd,isObject:e0,isPlain:s1,merge:ea,values:Rd,defineLazyProperty:Em}),b4=!1,Nd=null,Oi=!1,zd,Ed=!1,Zo=!1,$o=!1,t0=!1,w4=null,Im=null,eT=Boolean(K.default.cast&&K.default.cast.framework&&K.default.cast.framework.CastReceiverContext),Id=null,jm=!1,Um=!1,qm=!1,Gm=!1,vm=!1,km=!1,Am=!1,jh=Boolean(o1()&&(("ontouchstart"in K.default)||K.default.navigator.maxTouchPoints||K.default.DocumentTouch&&K.default.document instanceof K.default.DocumentTouch)),Xl=K.default.navigator&&K.default.navigator.userAgentData;if(Xl&&Xl.platform&&Xl.brands)Oi=Xl.platform==="Android",Zo=Boolean(Xl.brands.find((e)=>e.brand==="Microsoft Edge")),$o=Boolean(Xl.brands.find((e)=>e.brand==="Chromium")),t0=!Zo&&$o,w4=Im=(Xl.brands.find((e)=>e.brand==="Chromium")||{}).version||null,Um=Xl.platform==="Windows";if(!$o){let e=K.default.navigator&&K.default.navigator.userAgent||"";b4=/iPod/i.test(e),Nd=function(){let t=e.match(/OS (\d+)_/i);if(t&&t[1])return t[1];return null}(),Oi=/Android/i.test(e),zd=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}(),Ed=/Firefox/i.test(e),Zo=/Edg/i.test(e),$o=/Chrome/i.test(e)||/CriOS/i.test(e),t0=!Zo&&$o,w4=Im=function(){let t=e.match(/(Chrome|CriOS)\/(\d+)/);if(t&&t[2])return parseFloat(t[2]);return null}(),Id=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}(),vm=/Tizen/i.test(e),km=/Web0S/i.test(e),Am=vm||km,jm=/Safari/i.test(e)&&!t0&&!Oi&&!Zo&&!Am,Um=/Windows/i.test(e),qm=/iPad/i.test(e)||jm&&jh&&!/iPhone/i.test(e),Gm=/iPhone/i.test(e)&&!qm}var Un=Gm||qm||b4,Xm=(jm||Un)&&!t0,Ud=Object.freeze({__proto__:null,get IS_IPOD(){return b4},get IOS_VERSION(){return Nd},get IS_ANDROID(){return Oi},get ANDROID_VERSION(){return zd},get IS_FIREFOX(){return Ed},get IS_EDGE(){return Zo},get IS_CHROMIUM(){return $o},get IS_CHROME(){return t0},get CHROMIUM_VERSION(){return w4},get CHROME_VERSION(){return Im},IS_CHROMECAST_RECEIVER:eT,get IE_VERSION(){return Id},get IS_SAFARI(){return jm},get IS_WINDOWS(){return Um},get IS_IPAD(){return qm},get IS_IPHONE(){return Gm},get IS_TIZEN(){return vm},get IS_WEBOS(){return km},get IS_SMART_TV(){return Am},TOUCH_ENABLED:jh,IS_IOS:Un,IS_ANY_SAFARI:Xm});function Xw(e){return typeof e==="string"&&Boolean(e.trim())}function tT(e){if(e.indexOf(" ")>=0)throw Error("class has illegal whitespace characters")}function o1(){return Se.default===K.default.document}function c1(e){return e0(e)&&e.nodeType===1}function Gd(){try{return K.default.parent!==K.default.self}catch(e){return!0}}function Xd(e){return function(t,a){if(!Xw(t))return Se.default[e](null);if(Xw(a))a=Se.default.querySelector(a);let n=c1(a)?a:Se.default;return n[e]&&n[e](t)}}function at(e="div",t={},a={},n){let s=Se.default.createElement(e);if(Object.getOwnPropertyNames(t).forEach(function(i){let l=t[i];if(i==="textContent")Wl(s,l);else if(s[i]!==l||i==="tabIndex")s[i]=l}),Object.getOwnPropertyNames(a).forEach(function(i){s.setAttribute(i,a[i])}),n)d4(s,n);return s}function Wl(e,t){if(typeof e.textContent>"u")e.innerText=t;else e.textContent=t;return e}function V6(e,t){if(t.firstChild)t.insertBefore(e,t.firstChild);else t.appendChild(e)}function gh(e,t){return tT(t),e.classList.contains(t)}function mr(e,...t){return e.classList.add(...t.reduce((a,n)=>a.concat(n.split(/\s+/)),[])),e}function Km(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 Kd(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 Ld(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 Ll(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,l=n[s].value;if(a.includes(i))l=l!==null?!0:!1;t[i]=l}}return t}function Vd(e,t){return e.getAttribute(t)}function i1(e,t,a){e.setAttribute(t,a)}function Lm(e,t){e.removeAttribute(t)}function Yd(){Se.default.body.focus(),Se.default.onselectstart=function(){return!1}}function Jd(){Se.default.onselectstart=function(){return!0}}function l1(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(f1(e,"height"));if(!a.width)a.width=parseFloat(f1(e,"width"));return a}}function qh(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!==Se.default[dm.fullscreenElement])n+=e.offsetLeft,s+=e.offsetTop,e=e.offsetParent;return{left:n,top:s,width:t,height:a}}function Vm(e,t){let a={x:0,y:0};if(Un){let u=e;while(u&&u.nodeName.toLowerCase()!=="html"){let g=f1(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&&K.default.WebKitCSSMatrix){let b=K.default.getComputedStyle(u.assignedSlot.parentElement).transform,d=new K.default.WebKitCSSMatrix(b);a.x+=d.m41,a.y+=d.m42}u=u.parentNode||u.host}}let n={},s=qh(t.target),i=qh(e),l=i.width,f=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,Un)h-=a.x,c-=a.y}return n.y=1-Math.max(0,Math.min(1,c/f)),n.x=Math.max(0,Math.min(1,h/l)),n}function Qd(e){return e0(e)&&e.nodeType===3}function Ym(e){while(e.firstChild)e.removeChild(e.firstChild);return e}function Zd(e){if(typeof e==="function")e=e();return(Array.isArray(e)?e:[e]).map((t)=>{if(typeof t==="function")t=t();if(c1(t)||Qd(t))return t;if(typeof t==="string"&&/\S/.test(t))return Se.default.createTextNode(t)}).filter((t)=>t)}function d4(e,t){return Zd(t).forEach((a)=>e.appendChild(a)),e}function $d(e,t){return d4(Ym(e),t)}function vh(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 Zl=Xd("querySelector"),Wd=Xd("querySelectorAll");function f1(e,t){if(!e||!t)return"";if(typeof K.default.getComputedStyle==="function"){let a;try{a=K.default.getComputedStyle(e)}catch(n){return""}return a?a.getPropertyValue(t)||a[t]:""}return""}function Pd(e){[...Se.default.styleSheets].forEach((t)=>{try{let a=[...t.cssRules].map((s)=>s.cssText).join(""),n=Se.default.createElement("style");n.textContent=a,e.document.head.appendChild(n)}catch(a){let n=Se.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 ej=Object.freeze({__proto__:null,isReal:o1,isEl:c1,isInFrame:Gd,createEl:at,textContent:Wl,prependTo:V6,hasClass:gh,addClass:mr,removeClass:Km,toggleClass:Kd,setAttributes:Ld,getAttributes:Ll,getAttribute:Vd,setAttribute:i1,removeAttribute:Lm,blockTextSelection:Yd,unblockTextSelection:Jd,getBoundingClientRect:l1,findPosition:qh,getPointerPosition:Vm,isTextNode:Qd,emptyEl:Ym,normalizeContent:Zd,appendContent:d4,insertContent:$d,isSingleLeftClick:vh,$:Zl,$$:Wd,computedStyle:f1,copyStyleSheetsToWindow:Pd}),tj=!1,Y6,aT=function(){if(Y6.options.autoSetup===!1)return;let e=Array.prototype.slice.call(Se.default.getElementsByTagName("video")),t=Array.prototype.slice.call(Se.default.getElementsByTagName("audio")),a=Array.prototype.slice.call(Se.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 l=n[s];if(l&&l.getAttribute){if(l.player===void 0){if(l.getAttribute("data-setup")!==null)Y6(l)}}else{J6(1);break}}else if(!tj)J6(1)};function J6(e,t){if(!o1())return;if(t)Y6=t;K.default.setTimeout(aT,e)}function Q6(){tj=!0,K.default.removeEventListener("load",Q6)}if(o1())if(Se.default.readyState==="complete")Q6();else K.default.addEventListener("load",Q6);var aj=function(e){let t=Se.default.createElement("style");return t.className=e,t},nj=function(e,t){if(e.styleSheet)e.styleSheet.cssText=t;else e.textContent=t},Pn=new WeakMap,nT=3,sT=nT;function li(){return sT++}function Kw(e,t){if(!Pn.has(e))return;let a=Pn.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)Pn.delete(e)}function j4(e,t,a,n){a.forEach(function(s){e(t,s,n)})}function Jm(e){if(e.fixed_)return e;function t(){return!0}function a(){return!1}if(!e||!e.isPropagationStopped||!e.isImmediatePropagationStopped){let n=e||K.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||Se.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=Se.default.documentElement,l=Se.default.body;e.pageX=e.clientX+(i&&i.scrollLeft||l&&l.scrollLeft||0)-(i&&i.clientLeft||l&&l.clientLeft||0),e.pageY=e.clientY+(i&&i.scrollTop||l&&l.scrollTop||0)-(i&&i.clientTop||l&&l.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 hm,iT=function(){if(typeof hm!=="boolean"){hm=!1;try{let e=Object.defineProperty({},"passive",{get(){hm=!0}});K.default.addEventListener("test",null,e),K.default.removeEventListener("test",null,e)}catch(e){}}return hm},lT=["touchstart","touchmove"];function Is(e,t,a){if(Array.isArray(t))return j4(Is,e,t,a);if(!Pn.has(e))Pn.set(e,{});let n=Pn.get(e);if(!n.handlers)n.handlers={};if(!n.handlers[t])n.handlers[t]=[];if(!a.guid)a.guid=li();if(n.handlers[t].push(a),!n.dispatcher)n.disabled=!1,n.dispatcher=function(s,i){if(n.disabled)return;s=Jm(s);let l=n.handlers[s.type];if(l){let f=l.slice(0);for(let c=0,h=f.length;c<h;c++)if(s.isImmediatePropagationStopped())break;else try{f[c].call(e,s,i)}catch(u){qt.error(u)}}};if(n.handlers[t].length===1){if(e.addEventListener){let s=!1;if(iT()&&lT.indexOf(t)>-1)s={passive:!0};e.addEventListener(t,n.dispatcher,s)}else if(e.attachEvent)e.attachEvent("on"+t,n.dispatcher)}}function Gn(e,t,a){if(!Pn.has(e))return;let n=Pn.get(e);if(!n.handlers)return;if(Array.isArray(t))return j4(Gn,e,t,a);let s=function(l,f){n.handlers[f]=[],Kw(l,f)};if(t===void 0){for(let l in n.handlers)if(Object.prototype.hasOwnProperty.call(n.handlers||{},l))s(e,l);return}let i=n.handlers[t];if(!i)return;if(!a){s(e,t);return}if(a.guid){for(let l=0;l<i.length;l++)if(i[l].guid===a.guid)i.splice(l--,1)}Kw(e,t)}function h1(e,t,a){let n=Pn.has(e)?Pn.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=Jm(t),n.dispatcher)n.dispatcher.call(e,t,a);if(s&&!t.isPropagationStopped()&&t.bubbles===!0)h1.call(null,s,t,a);else if(!s&&!t.defaultPrevented&&t.target&&t.target[t.type]){if(!Pn.has(t.target))Pn.set(t.target,{});let i=Pn.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 Qm(e,t,a){if(Array.isArray(t))return j4(Qm,e,t,a);let n=function(){Gn(e,t,n),a.apply(this,arguments)};n.guid=a.guid=a.guid||li(),Is(e,t,n)}function q4(e,t,a){let n=function(){Gn(e,t,n),a.apply(this,arguments)};n.guid=a.guid=a.guid||li(),Is(e,t,n)}var fT=Object.freeze({__proto__:null,fixEvent:Jm,on:Is,off:Gn,trigger:h1,one:Qm,any:q4}),fi=30,la=function(e,t,a){if(!t.guid)t.guid=li();let n=t.bind(e);return n.guid=a?a+"_"+t.guid:t.guid,n},a0=function(e,t){let a=K.default.performance.now();return function(...s){let i=K.default.performance.now();if(i-a>=t)e(...s),a=i}},sj=function(e,t,a,n=K.default){let s,i=()=>{n.clearTimeout(s),s=null},l=function(){let f=this,c=arguments,h=function(){if(s=null,h=null,!a)e.apply(f,c)};if(!s&&a)e.apply(f,c);n.clearTimeout(s),s=n.setTimeout(h,t)};return l.cancel=i,l},rT=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:fi,bind_:la,throttle:a0,debounce:sj}),oh;class qs{on(e,t){let a=this.addEventListener;this.addEventListener=()=>{},Is(this,e,t),this.addEventListener=a}off(e,t){Gn(this,e,t)}one(e,t){let a=this.addEventListener;this.addEventListener=()=>{},Qm(this,e,t),this.addEventListener=a}any(e,t){let a=this.addEventListener;this.addEventListener=()=>{},q4(this,e,t),this.addEventListener=a}trigger(e){let t=e.type||e;if(typeof e==="string")e={type:t};if(e=Jm(e),this.allowedEvents_[t]&&this["on"+t])this["on"+t](e);h1(this,e)}queueTrigger(e){if(!oh)oh=new Map;let t=e.type||e,a=oh.get(this);if(!a)a=new Map,oh.set(this,a);let n=a.get(t);a.delete(t),K.default.clearTimeout(n);let s=K.default.setTimeout(()=>{if(a.delete(t),a.size===0)a=null,oh.delete(this);this.trigger(e)},0);a.set(t,s)}}qs.prototype.allowedEvents_={};qs.prototype.addEventListener=qs.prototype.on;qs.prototype.removeEventListener=qs.prototype.off;qs.prototype.dispatchEvent=qs.prototype.trigger;var Zm=(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},Y0=(e)=>e instanceof qs||!!e.eventBusEl_&&["on","one","off","trigger"].every((t)=>typeof e[t]==="function"),oT=(e,t)=>{if(Y0(e))t();else{if(!e.eventedCallbacks)e.eventedCallbacks=[];e.eventedCallbacks.push(t)}},Z6=(e)=>typeof e==="string"&&/\S/.test(e)||Array.isArray(e)&&!!e.length,ym=(e,t,a)=>{if(!e||!e.nodeName&&!Y0(e))throw Error(`Invalid target for ${Zm(t)}#${a}; must be a DOM node or evented object.`)},ij=(e,t,a)=>{if(!Z6(e))throw Error(`Invalid event type for ${Zm(t)}#${a}; must be a non-empty string or array.`)},lj=(e,t,a)=>{if(typeof e!=="function")throw Error(`Invalid listener for ${Zm(t)}#${a}; must be a function.`)},F6=(e,t,a)=>{let n=t.length<3||t[0]===e||t[0]===e.eventBusEl_,s,i,l;if(n){if(s=e.eventBusEl_,t.length>=3)t.shift();[i,l]=t}else s=t[0],i=t[1],l=t[2];return ym(s,e,a),ij(i,e,a),lj(l,e,a),l=la(e,l),{isTargetingSelf:n,target:s,type:i,listener:l}},rr=(e,t,a,n)=>{if(ym(e,e,t),e.nodeName)fT[t](e,a,n);else e[t](a,n)},cT={on(...e){let{isTargetingSelf:t,target:a,type:n,listener:s}=F6(this,e,"on");if(rr(a,"on",n,s),!t){let i=()=>this.off(a,n,s);i.guid=s.guid;let l=()=>this.off("dispose",i);l.guid=s.guid,rr(this,"on","dispose",i),rr(a,"on","dispose",l)}},one(...e){let{isTargetingSelf:t,target:a,type:n,listener:s}=F6(this,e,"one");if(t)rr(a,"one",n,s);else{let i=(...l)=>{this.off(a,n,i),s.apply(null,l)};i.guid=s.guid,rr(a,"one",n,i)}},any(...e){let{isTargetingSelf:t,target:a,type:n,listener:s}=F6(this,e,"any");if(t)rr(a,"any",n,s);else{let i=(...l)=>{this.off(a,n,i),s.apply(null,l)};i.guid=s.guid,rr(a,"any",n,i)}},off(e,t,a){if(!e||Z6(e))Gn(this.eventBusEl_,e,t);else{let n=e,s=t;if(ym(n,this,"off"),ij(s,this,"off"),lj(a,this,"off"),a=la(this,a),this.off("dispose",a),n.nodeName)Gn(n,s,a),Gn(n,"dispose",a);else if(Y0(n))n.off(s,a),n.off("dispose",a)}},trigger(e,t){ym(this.eventBusEl_,this,"trigger");let a=e&&typeof e!=="string"?e.type:e;if(!Z6(a))throw Error(`Invalid event type for ${Zm(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return h1(this.eventBusEl_,e,t)}};function v4(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_=at("span",{className:"vjs-event-bus"});if(Object.assign(e,cT),e.eventedCallbacks)e.eventedCallbacks.forEach((n)=>{n()});return e.on("dispose",()=>{e.off(),[e,e.el_,e.eventBusEl_].forEach(function(n){if(n&&Pn.has(n))Pn.delete(n)}),K.default.setTimeout(()=>{e.eventBusEl_=null},0)}),e}var hT={state:{},setState(e){if(typeof e==="function")e=e();let t;if(Qo(e,(a,n)=>{if(this.state[n]!==a)t=t||{},t[n]={from:this.state[n],to:a};this.state[n]=a}),t&&Y0(this))this.trigger({changes:t,type:"statechanged"});return t}};function fj(e,t){if(Object.assign(e,hT),e.state=Object.assign({},e.state,t),typeof e.handleStateChanged==="function"&&Y0(e))e.on("statechanged",e.handleStateChanged);return e}var ph=function(e){if(typeof e!=="string")return e;return e.replace(/./,(t)=>t.toLowerCase())},Ma=function(e){if(typeof e!=="string")return e;return e.replace(/./,(t)=>t.toUpperCase())},rj=function(e,t){return Ma(e)===Ma(t)},uT=Object.freeze({__proto__:null,toLowerCase:ph,toTitleCase:Ma,titleCaseEquals:rj});class ce{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_=ea({},this.options_),t=this.options_=ea(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_${li()}`}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)v4(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange);if(fj(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_=ea(this.options_,e),this.options_}el(){return this.el_}createEl(e,t,a){return at(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],l=n&&n.split("-")[0],f=s&&s[l],c=a;if(i&&i[e])c=i[e];else if(f&&f[e])c=f[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=at("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),s=Se.default.createElementNS(a,"svg");s.setAttributeNS(null,"viewBox","0 0 512 512");let i=Se.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=Ma(e);let i=t.componentClass||s;t.name=s;let l=ce.getComponent(i);if(!l)throw Error(`Component ${i} does not exist`);if(typeof l!=="function")return null;n=new l(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&&Ma(n.name()),s)this.childNameIndex_[s]=n,this.childNameIndex_[ph(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(c1(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_[Ma(e.name())]=null,this.childNameIndex_[ph(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:l,opts:f}=i;if(t[l]!==void 0)f=t[l];if(f===!1)return;if(f===!0)f={};f.playerOptions=this.options_.playerOptions;let c=this.addChild(l,f);if(c)this[l]=c},n,s=ce.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(l){if(typeof l==="string")return i===l;return i===l.name})})).map((i)=>{let l,f;if(typeof i==="string")l=i,f=e[l]||this.options_[l]||{};else l=i.name,f=i;return{name:l,opts:f}}).filter((i)=>{let l=ce.getComponent(i.opts.componentClass||Ma(i.name));return l&&!s.isTech(l)}).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 Zl(e,t||this.contentEl())}$$(e,t){return Wd(e,t||this.contentEl())}hasClass(e){return gh(this.el_,e)}addClass(...e){mr(this.el_,...e)}removeClass(...e){Km(this.el_,...e)}toggleClass(e,t){Kd(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 Vd(this.el_,e)}setAttribute(e,t){i1(this.el_,e,t)}removeAttribute(e){Lm(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"+Ma(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw Error("currentDimension only accepts width or height value");if(t=f1(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){let a=`offset${Ma(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(l){if(l.touches.length===1)t={pageX:l.touches[0].pageX,pageY:l.touches[0].pageY},e=K.default.performance.now(),s=!0}),this.on("touchmove",function(l){if(l.touches.length>1)s=!1;else if(t){let f=l.touches[0].pageX-t.pageX,c=l.touches[0].pageY-t.pageY;if(Math.sqrt(f*f+c*c)>a)s=!1}});let i=function(){s=!1};this.on("touchleave",i),this.on("touchcancel",i),this.on("touchend",function(l){if(t=null,s===!0){if(K.default.performance.now()-e<n)l.preventDefault(),this.trigger("tap")}})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;let e=la(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=la(this,e),this.clearTimersOnDispose_(),a=K.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),K.default.clearTimeout(e);return e}setInterval(e,t){e=la(this,e),this.clearTimersOnDispose_();let a=K.default.setInterval(e,t);return this.setIntervalIds_.add(a),a}clearInterval(e){if(this.setIntervalIds_.has(e))this.setIntervalIds_.delete(e),K.default.clearInterval(e);return e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=la(this,e),t=K.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=la(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),K.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=K.default.getComputedStyle(s,null),l=i.getPropertyValue("visibility");return i.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(l)}function a(s){if(!t(s.parentElement))return!1;if(!t(s)||s.style.opacity==="0"||K.default.getComputedStyle(s).height==="0px"||K.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>(Se.default.documentElement.clientWidth||K.default.innerWidth))return!1;if(i.y<0)return!1;if(i.y>(Se.default.documentElement.clientHeight||K.default.innerHeight))return!1;let l=Se.default.elementFromPoint(i.x,i.y);while(l){if(l===s)return!0;if(l.parentNode)l=l.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=ce.getComponent("Tech"),n=a&&a.isTech(t),s=ce===t||ce.prototype.isPrototypeOf(t.prototype);if(n||!s){let l;if(n)l="techs must be registered using Tech.registerTech()";else l="must be a Component subclass";throw Error(`Illegal component, "${e}"; ${l}.`)}if(e=Ma(e),!ce.components_)ce.components_={};let i=ce.getComponent("Player");if(e==="Player"&&i&&i.players){let l=i.players,f=Object.keys(l);if(l&&f.length>0){for(let c=0;c<f.length;c++)if(l[f[c]]!==null)throw Error("Can not register Player component after player has been created.")}}return ce.components_[e]=t,ce.components_[ph(e)]=t,t}static getComponent(e){if(!e||!ce.components_)return;return ce.components_[e]}}ce.registerComponent("Component",ce);function mT(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 Lw(e,t,a,n){return mT(e,n,a.length-1),a[n][t]}function O6(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:Lw.bind(null,"start",0,e),end:Lw.bind(null,"end",1,e)};if(K.default.Symbol&&K.default.Symbol.iterator)t[K.default.Symbol.iterator]=()=>(e||[]).values();return t}function Fi(e,t){if(Array.isArray(e))return O6(e);else if(e===void 0||t===void 0)return O6();return O6([[e,t]])}var oj=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),l=Math.floor(t/3600);if(isNaN(e)||e===1/0)s=n=a="-";return s=s>0||l>0?s+":":"",n=((s||i>=10)&&n<10?"0"+n:n)+":",a=a<10?"0"+a:a,s+n+a},k4=oj;function cj(e){k4=e}function hj(){k4=oj}function br(e,t=e){return k4(e,t)}var gT=Object.freeze({__proto__:null,createTimeRanges:Fi,createTimeRange:Fi,setFormatTime:cj,resetFormatTime:hj,formatTime:br});function uj(e,t){let a=0,n,s;if(!t)return 0;if(!e||!e.length)e=Fi(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 Aa(e){if(e instanceof Aa)return e;if(typeof e==="number")this.code=e;else if(typeof e==="string")this.message=e;else if(e0(e)){if(typeof e.code==="number")this.code=e.code;Object.assign(this,e)}if(!this.message)this.message=Aa.defaultMessages[this.code]||""}Aa.prototype.code=0;Aa.prototype.message="";Aa.prototype.status=null;Aa.prototype.metadata=null;Aa.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Aa.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."};Aa.MEDIA_ERR_CUSTOM=0;Aa.prototype.MEDIA_ERR_CUSTOM=0;Aa.MEDIA_ERR_ABORTED=1;Aa.prototype.MEDIA_ERR_ABORTED=1;Aa.MEDIA_ERR_NETWORK=2;Aa.prototype.MEDIA_ERR_NETWORK=2;Aa.MEDIA_ERR_DECODE=3;Aa.prototype.MEDIA_ERR_DECODE=3;Aa.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Aa.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Aa.MEDIA_ERR_ENCRYPTED=5;Aa.prototype.MEDIA_ERR_ENCRYPTED=5;function bh(e){return e!==void 0&&e!==null&&typeof e.then==="function"}function Zi(e){if(bh(e))e.then(null,(t)=>{})}var $6=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}})})},pT=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=$6(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($6))},bT=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()},W6={textTracksToJson:pT,jsonToTextTracks:bT,trackToJson:$6},B6="vjs-modal-dialog";class wr extends ce{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_=at("div",{className:`${B6}-content`},{role:"document"}),this.descEl_=at("p",{className:`${B6}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Wl(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`${B6} 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(),$d(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"),Ym(this.contentEl()),this.trigger("modalempty")}content(e){if(typeof e<"u")this.content_=e;return this.content_}conditionalFocus_(){let e=Se.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(Se.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 K.default.HTMLAnchorElement||t instanceof K.default.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof K.default.HTMLInputElement||t instanceof K.default.HTMLSelectElement||t instanceof K.default.HTMLTextAreaElement||t instanceof K.default.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof K.default.HTMLIFrameElement||t instanceof K.default.HTMLObjectElement||t instanceof K.default.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable")})}}wr.prototype.options_={pauseOnOpen:!0,temporary:!0};ce.registerComponent("ModalDialog",wr);class $l extends qs{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})},Y0(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}}$l.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(let e in $l.prototype.allowedEvents_)$l.prototype["on"+e]=null;var T6=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 A4 extends $l{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){T6(e,e[t]);break}super(e);this.changing_=!1}addTrack(e){if(e.enabled)T6(this,e);if(super.addTrack(e),!e.addEventListener)return;e.enabledChange_=()=>{if(this.changing_)return;this.changing_=!0,T6(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 M6=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 y4 extends $l{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){M6(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)M6(this,e);if(super.addTrack(e),!e.addEventListener)return;e.selectedChange_=()=>{if(this.changing_)return;this.changing_=!0,M6(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 $m extends $l{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 mj{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 Sm{constructor(e){Sm.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 wT={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},dT={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},jT={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},Vw={disabled:"disabled",hidden:"hidden",showing:"showing"};class Wm extends qs{constructor(e={}){super();let t={id:e.id||"vjs_track_"+li(),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 S4=function(e){return new URL(e,Se.default.baseURI)},gj=function(e){return new URL(e,Se.default.baseURI).href},C4=function(e){if(typeof e==="string"){let a=e.split("?")[0].replace(/\/+$/,"").match(/\.([^.\/]+)$/);return a?a[1].toLowerCase():""}return""},Pm=function(e,t=K.default.location){return S4(e).origin!==t.origin},qT=Object.freeze({__proto__:null,parseUrl:S4,getAbsoluteURL:gj,getFileExtension:C4,isCrossOrigin:Pm}),Yw=function(e,t){let a=new K.default.WebVTT.Parser(K.default,K.default.vttjs,K.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(K.default.console&&K.default.console.groupCollapsed)K.default.console.groupCollapsed(`Text Track parsing errors for ${t.src}`);if(n.forEach((s)=>qt.error(s)),K.default.console&&K.default.console.groupEnd)K.default.console.groupEnd()}a.flush()},Jw=function(e,t){let a={uri:e},n=Pm(e);if(n)a.cors=n;let s=t.tech_.crossOrigin()==="use-credentials";if(s)a.withCredentials=s;p4.default(a,la(this,function(i,l,f){if(i)return qt.error(i,l);if(t.loaded_=!0,typeof K.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 Yw(f,t)})}else Yw(f,t)}))};class u1 extends Wm{constructor(e={}){if(!e.tech)throw Error("A tech was not provided.");let t=ea(e,{kind:jT[e.kind]||"subtitles",language:e.language||e.srclang||""}),a=Vw[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 Sm(this.cues_),i=new Sm(this.activeCues_),l=!1;this.timeupdateHandler=la(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,l)this.trigger("cuechange"),l=!1;if(c.type!=="timeupdate")this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler)});let f=()=>{this.stopTracking()};if(this.tech_.one("dispose",f),a!=="disabled")this.startTracking();if(Object.defineProperties(this,{default:{get(){return n},set(){}},mode:{get(){return a},set(c){if(!Vw[c])return;if(a===c)return;if(a=c,!this.preload_&&a!=="disabled"&&this.cues.length===0)Jw(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(l=!1,h.length!==this.activeCues_.length)l=!0;else for(let u=0;u<h.length;u++)if(this.activeCues_.indexOf(h[u])===-1)l=!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")Jw(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 K.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 W6.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}}}}u1.prototype.allowedEvents_={cuechange:"cuechange"};class _4 extends Wm{constructor(e={}){let t=ea(e,{kind:dT[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 F4 extends Wm{constructor(e={}){let t=ea(e,{kind:wT[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 J0 extends qs{constructor(e={}){super();let t,a=new u1(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=J0.NONE,a.addEventListener("loadeddata",()=>{t=J0.LOADED,this.trigger({type:"load",target:this})})}}J0.prototype.allowedEvents_={load:"load"};J0.NONE=0;J0.LOADING=1;J0.LOADED=2;J0.ERROR=3;var ii={audio:{ListClass:A4,TrackClass:_4,capitalName:"Audio"},video:{ListClass:y4,TrackClass:F4,capitalName:"Video"},text:{ListClass:$m,TrackClass:u1,capitalName:"Text"}};Object.keys(ii).forEach(function(e){ii[e].getterName=`${e}Tracks`,ii[e].privateName=`${e}Tracks_`});var r1={remoteText:{ListClass:$m,TrackClass:u1,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:mj,TrackClass:J0,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},Wn=Object.assign({},ii,r1);r1.names=Object.keys(r1);ii.names=Object.keys(ii);Wn.names=[].concat(r1.names).concat(ii.names);function vT(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 l=new Wn.text.TrackClass(s);return i.addTrack(l),l}class gt extends ce{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}),Wn.names.forEach((a)=>{let n=Wn[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 Wn.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(la(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 Fi(0,0)}bufferedPercent(){return uj(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(ii.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 Aa(e),this.trigger("error");return this.error_}played(){if(this.hasStarted_)return Fi(0,0);return Fi()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){if(this.manualTimeUpdates)this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){ii.names.forEach((e)=>{let t=ii[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(K.default.WebVTT)return;if(Se.default.body.contains(this.el())){if(!this.options_["vtt.js"]&&s1(X6.default)&&Object.keys(X6.default).length>0){this.trigger("vttjsloaded");return}let e=Se.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}),K.default.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){let e=this.textTracks(),t=this.remoteTextTracks(),a=(l)=>e.addTrack(l.track),n=(l)=>e.removeTrack(l.track);t.on("addtrack",a),t.on("removetrack",n),this.addWebVttScript_();let s=()=>this.trigger("texttrackchange"),i=()=>{s();for(let l=0;l<e.length;l++){let f=e[l];if(f.removeEventListener("cuechange",s),f.mode==="showing")f.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 l=0;l<e.length;l++)e[l].removeEventListener("cuechange",s)})}addTextTrack(e,t,a){if(!e)throw Error("TextTrack kind is required but was not provided");return vT(this,e,t,a)}createRemoteTextTrack(e){let t=ea(e,{tech:this});return new r1.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=li();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 gt.canPlayType(e.type)}static isTech(e){return e.prototype instanceof gt||e instanceof gt||e===gt}static registerTech(e,t){if(!gt.techs_)gt.techs_={};if(!gt.isTech(t))throw Error(`Tech ${e} must be a Tech`);if(!gt.canPlayType)throw Error("Techs must have a static canPlayType method on them");if(!gt.canPlaySource)throw Error("Techs must have a static canPlaySource method on them");if(e=Ma(e),gt.techs_[e]=t,gt.techs_[ph(e)]=t,e!=="Tech")gt.defaultTechOrder_.push(e);return t}static getTech(e){if(!e)return;if(gt.techs_&&gt.techs_[e])return gt.techs_[e];if(e=Ma(e),K.default&&K.default.videojs&&K.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)`),K.default.videojs[e]}}Wn.names.forEach(function(e){let t=Wn[e];gt.prototype[t.getterName]=function(){return this[t.privateName]=this[t.privateName]||new t.ListClass,this[t.privateName]}});gt.prototype.featuresVolumeControl=!0;gt.prototype.featuresMuteControl=!0;gt.prototype.featuresFullscreenResize=!1;gt.prototype.featuresPlaybackRate=!1;gt.prototype.featuresProgressEvents=!1;gt.prototype.featuresSourceset=!1;gt.prototype.featuresTimeupdateEvents=!1;gt.prototype.featuresNativeTextTracks=!1;gt.prototype.featuresVideoFrameCallback=!1;gt.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 l=0;l<s.length;l++)if(i=s[l].canHandleSource(a,n),i)return s[l];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}}};ce.registerComponent("Tech",gt);gt.registerTech("Tech",gt);gt.defaultTechOrder_=[];var gr={},Cm={},_m={};function kT(e,t){gr[e]=gr[e]||[],gr[e].push(t)}function AT(e,t,a){e.setTimeout(()=>or(t,gr[t.type],a,e),1)}function yT(e,t){e.forEach((a)=>a.setTech&&a.setTech(t))}function ST(e,t,a){return e.reduceRight(O4(a),t[a]())}function CT(e,t,a,n){return t[a](e.reduce(O4(a),n))}function Qw(e,t,a,n=null){let s="call"+Ma(a),i=e.reduce(O4(s),n),l=i===_m,f=l?null:t[a](i);return OT(e,a,f,l),f}var _T={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},FT={setCurrentTime:1,setMuted:1,setVolume:1},Zw={play:1,pause:1};function O4(e){return(t,a)=>{if(t===_m)return _m;if(a[e])return a[e](t);return t}}function OT(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 BT(e){if(Cm.hasOwnProperty(e.id()))delete Cm[e.id()]}function TT(e,t){let a=Cm[e.id()],n=null;if(a===void 0||a===null)return n=t(e),Cm[e.id()]=[[t,n]],n;for(let s=0;s<a.length;s++){let[i,l]=a[s];if(i!==t)continue;n=l}if(n===null)n=t(e),a.push([t,n]);return n}function or(e={},t=[],a,n,s=[],i=!1){let[l,...f]=t;if(typeof l==="string")or(e,gr[l],a,n,s,i);else if(l){let c=TT(n,l);if(!c.setSource)return s.push(c),or(e,f,a,n,s,i);c.setSource(Object.assign({},e),function(h,u){if(h)return or(e,f,a,n,s,i);s.push(c),or(u,e.type===u.type?f:gr[u.type],a,n,s,i)})}else if(f.length)or(e,f,a,n,s,i);else if(i)a(e,s);else or(e,gr["*"],a,n,s,!0)}var MT={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"},Fm=function(e=""){let t=C4(e);return MT[t.toLowerCase()]||""},HT=(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 Fm(t)},pj=function(e){if(Array.isArray(e)){let t=[];e.forEach(function(a){if(a=pj(a),Array.isArray(a))t=t.concat(a);else if(e0(a))t.push(a)}),e=t}else if(typeof e==="string"&&e.trim())e=[$w({src:e})];else if(e0(e)&&typeof e.src==="string"&&e.src&&e.src.trim())e=[$w(e)];else e=[];return e};function $w(e){if(!e.type){let t=Fm(e.src);if(t)e.type=t}return e}var xT=`<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>`,Ww=vm?10009:km?461:8,Lo={codes:{play:415,pause:19,ff:417,rw:412,back:Ww},names:{415:"play",19:"pause",417:"ff",412:"rw",[Ww]:"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}},Pw=5;class bj extends qs{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(Lo.isEventKey(t,"play")||Lo.isEventKey(t,"pause")||Lo.isEventKey(t,"ff")||Lo.isEventKey(t,"rw")){t.preventDefault();let a=Lo.getEventName(t);this.performMediaAction_(a)}else if(Lo.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()+Pw);break;case"rw":this.userSeek_(this.player_.currentTime()-Pw);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((l,f)=>{t.push({name:()=>{return"ModalButton"+(f+1)},el:()=>l,getPositions:()=>{let c=l.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:()=>l.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 l=i.getPositions().center,f=this.calculateDistance_(e,l,a);if(f<n)n=f,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 wj extends ce{constructor(e,t,a){let n=ea({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 l=Ma(i[s]),f=gt.getTech(l);if(!l)f=ce.getComponent(l);if(f&&f.isSupported()){e.loadTech_(l);break}}else e.src(t.playerOptions.sources)}}ce.registerComponent("MediaLoader",wj);class yh extends ce{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=at(e,t,a);if(!this.player_.options_.experimentalSvgIcons)n.appendChild(at("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0}));return this.createControlTextEl(n),n}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){if(this.controlTextEl_=at("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,Wl(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)}}ce.registerComponent("ClickableComponent",yh);class Om extends yh{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 at("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(at("picture",{className:"vjs-poster",tabIndex:-1},{},at("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())Zi(this.player_.play());else this.player_.pause()}}Om.prototype.crossorigin=Om.prototype.crossOrigin;ce.registerComponent("PosterImage",Om);var si="#222",ed="#ccc",DT={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 H6(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 Ji(e,t,a){try{e.style[t]=a}catch(n){return}}function td(e){return e?`${e}px`:""}class dj extends ce{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(la(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",s),e.on("playerresize",s);let i=K.default.screen.orientation||K.default,l=K.default.screen.orientation?"change":"orientationchange";i.addEventListener(l,s),e.on("dispose",()=>i.removeEventListener(l,s));let f=this.options_.playerOptions.tracks||[];for(let c=0;c<f.length;c++)this.player_.addRemoteTextTrack(f[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 l=0;l<t.length;l++){let f=t[l];if(a&&a.enabled&&a.language&&a.language===f.language&&f.kind in e){if(f.kind===a.kind)i=f;else if(!i)i=f}else if(a&&!a.enabled)i=null,n=null,s=null;else if(f.default){if(f.kind==="descriptions"&&!n)n=f;else if(f.kind in e&&!s)s=f}}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 K.default.WebVTT==="function")K.default.WebVTT.processCues(K.default,[],this.el_)}updateDisplay(){let e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){let i=[];for(let l=0;l<e.length;++l){let f=e[l];if(f.mode!=="showing")continue;i.push(f)}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(!(K.default.CSS!==void 0&&K.default.CSS.supports("inset","10px"))){let i=this.el_,l=i.querySelectorAll(".vjs-text-track-cue"),f=this.player_.controlBar.el_.getBoundingClientRect().height,c=this.player_.el_.getBoundingClientRect().height;if(i.style="",Ji(i,"position","relative"),Ji(i,"height",c-f+"px"),Ji(i,"top","unset"),Am)Ji(i,"bottom",c+"px");else Ji(i,"bottom","0px");if(l.length>0)l.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()||!(K.default.CSS!==void 0&&K.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);Ji(this.el_,"insetInline",td(s)),Ji(this.el_,"insetBlock",td(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)Ji(i.firstChild,"color",H6(t.color||"#fff",t.textOpacity));if(t.backgroundColor)i.firstChild.style.backgroundColor=t.backgroundColor;if(t.backgroundOpacity)Ji(i.firstChild,"backgroundColor",H6(t.backgroundColor||"#000",t.backgroundOpacity));if(t.windowColor)if(t.windowOpacity)Ji(i,"backgroundColor",H6(t.windowColor,t.windowOpacity));else i.style.backgroundColor=t.windowColor;if(t.edgeStyle){if(t.edgeStyle==="dropshadow")i.firstChild.style.textShadow=`2px 2px 3px ${si}, 2px 2px 4px ${si}, 2px 2px 5px ${si}`;else if(t.edgeStyle==="raised")i.firstChild.style.textShadow=`1px 1px ${si}, 2px 2px ${si}, 3px 3px ${si}`;else if(t.edgeStyle==="depressed")i.firstChild.style.textShadow=`1px 1px ${ed}, 0 1px ${ed}, -1px -1px ${si}, 0 -1px ${si}`;else if(t.edgeStyle==="uniform")i.firstChild.style.textShadow=`0 0 4px ${si}, 0 0 4px ${si}, 0 0 4px ${si}, 0 0 4px ${si}`}if(t.fontPercent&&t.fontPercent!==1){let l=K.default.parseFloat(i.style.fontSize);i.style.fontSize=l*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=DT[t.fontFamily]}}updateForTrack(e){if(!Array.isArray(e))e=[e];if(typeof K.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])}K.default.WebVTT.processCues(K.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(mr(i,"vjs-text-track-cue","vjs-text-track-cue-"+(n.language?n.language:a)),n.language)i1(i,"lang",n.language)}if(this.player_.textTrackSettings)this.updateDisplayState(n)}}}ce.registerComponent("TextTrackDisplay",dj);class jj extends ce{createEl(){let e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),a=at("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"])}}ce.registerComponent("LoadingSpinner",jj);class Bn extends yh{createEl(e,t={},a={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),a=Object.assign({type:"button"},a);let n=at(e,t,a);if(!this.player_.options_.experimentalSvgIcons)n.appendChild(at("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.`),ce.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)}}ce.registerComponent("Button",Bn);class B4 extends Bn{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(Zi(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(bh(t))t.then(s,()=>{});else this.setTimeout(s,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}B4.prototype.controlText_="Play Video";ce.registerComponent("BigPlayButton",B4);class qj extends Bn{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)}}ce.registerComponent("CloseButton",qj);class T4 extends Bn{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())Zi(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))}}T4.prototype.controlText_="Play";ce.registerComponent("PlayToggle",T4);class dr extends ce{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=at("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(a),this.contentEl_=at("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=br(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_=Se.default.createTextNode(this.formattedTime_),!this.textNode_)return;if(t)this.contentEl_.replaceChild(this.textNode_,t);else this.contentEl_.appendChild(this.textNode_)})}updateContent(e){}}dr.prototype.labelText_="Time";dr.prototype.controlText_="Time";ce.registerComponent("TimeDisplay",dr);class e9 extends dr{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)}}e9.prototype.labelText_="Current Time";e9.prototype.controlText_="Current Time";ce.registerComponent("CurrentTimeDisplay",e9);class t9 extends dr{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)}}t9.prototype.labelText_="Duration";t9.prototype.controlText_="Duration";ce.registerComponent("DurationDisplay",t9);class vj extends ce{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}}ce.registerComponent("TimeDivider",vj);class a9 extends dr{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(at("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)}}a9.prototype.labelText_="Remaining Time";a9.prototype.controlText_="Remaining Time";ce.registerComponent("RemainingTimeDisplay",a9);class kj extends ce{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_=at("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(at("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(Se.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()}}ce.registerComponent("LiveDisplay",kj);class M4 extends Bn{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_=at("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()}}M4.prototype.controlText_="Seek to live, currently playing live";ce.registerComponent("SeekToLive",M4);function Sh(e,t,a){return e=Number(e),Math.min(a,Math.max(t,isNaN(e)?t:e))}var RT=Object.freeze({__proto__:null,clamp:Sh});class n9 extends ce{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"&&!t0)e.preventDefault();Yd(),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;Jd(),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(Sh(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){let t=Vm(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")}}ce.registerComponent("Slider",n9);var x6=(e,t)=>Sh(e/t*100,0,100).toFixed(2)+"%";class Aj extends ce{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=at("span",{className:"vjs-control-text"}),a=at("span",{textContent:this.localize("Loaded")}),n=Se.default.createTextNode(": ");return this.percentageEl_=at("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_,l=x6(s,n);if(this.percent_!==l)this.el_.style.width=l,Wl(this.percentageEl_,l),this.percent_=l;for(let f=0;f<a.length;f++){let c=a.start(f),h=a.end(f),u=i[f];if(!u)u=this.el_.appendChild(at()),i[f]=u;if(u.dataset.start===c&&u.dataset.end===h)continue;u.dataset.start=c,u.dataset.end=h,u.style.left=x6(c,s),u.style.width=x6(h-c,s)}for(let f=i.length;f>a.length;f--)this.el_.removeChild(i[f-1]);i.length=a.length})}}ce.registerComponent("LoadProgressBar",Aj);class yj extends ce{constructor(e,t){super(e,t);this.update=a0(la(this,this.update),fi)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,a){let n=qh(this.el_),s=l1(this.player_.el()),i=e.width*t;if(!s||!n)return;let l=e.left-s.left+i,f=e.width-i+(s.right-e.right);if(!f)f=e.width-i,l=i;let c=n.width/2;if(l<c)c+=c-l;else if(f<c)c=f;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){Wl(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 l=this.player_.liveTracker.liveWindow(),f=l-t*l;s=(f<1?"":"-")+br(f,l)}else s=br(a,i);if(this.update(e,t,s),n)n()})}}ce.registerComponent("TimeTooltip",yj);class s9 extends ce{constructor(e,t){super(e,t);this.setIcon("circle"),this.update=a0(la(this,this.update),fi)}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)}}s9.prototype.options_={children:[]};if(!Un&&!Oi)s9.prototype.options_.children.push("timeTooltip");ce.registerComponent("PlayProgressBar",s9);class H4 extends ce{constructor(e,t){super(e,t);this.update=a0(la(this,this.update),fi)}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`})}}H4.prototype.options_={children:["timeTooltip"]};ce.registerComponent("MouseTimeDisplay",H4);class i9 extends n9{constructor(e,t){t=ea(i9.prototype.options_,t),t.children=[...t.children];let a=e.options_.disableSeekWhileScrubbingOnMobile&&(Un||Oi)||e.options_.disableSeekWhileScrubbingOnSTV;if(!Un&&!Oi||a)t.children.splice(1,0,"mouseTimeDisplay");super(e,t);this.shouldDisableSeekWhileScrubbing_=a,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){if(this.update_=la(this,this.update),this.update=a0(this.update_,fi),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 Se.default&&"visibilityState"in Se.default)this.on(Se.default,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){if(Se.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,fi)}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(Se.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}",[br(a,s),br(s,s)],"{1} of {2}")),this.currentTime_=a,this.duration_=s;if(this.bar)this.bar.update(l1(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(!vh(e))return;if(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),!this.shouldDisableSeekWhileScrubbing_)this.player_.pause();super.handleMouseDown(e)}handleMouseMove(e,t=!1){if(!vh(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(),l=s.liveCurrentTime();if(a=i+n*s.liveWindow(),a>=l)a=l;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)Zi(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 Se.default&&"visibilityState"in Se.default)this.off(Se.default,"visibilitychange",this.toggleVisibility_);super.dispose()}}i9.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar",stepSeconds:5,pageMultiplier:12};ce.registerComponent("SeekBar",i9);class x4 extends ce{constructor(e,t){super(e,t);this.handleMouseMove=a0(la(this,this.handleMouseMove),fi),this.throttledHandleMouseSeek=a0(la(this,this.handleMouseSeek),fi),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=qh(s),l=Vm(s,e).x;if(l=Sh(l,0,1),n)n.update(i,l);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)Zi(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()}}x4.prototype.options_={children:["seekBar"]};ce.registerComponent("ProgressControl",x4);class D4 extends Bn{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(Se.default.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in K.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 Se.default.exitPictureInPicture!=="function")return;super.show()}}D4.prototype.controlText_="Picture-in-Picture";ce.registerComponent("PictureInPictureToggle",D4);class R4 extends Bn{constructor(e,t){super(e,t);if(this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",(a)=>this.handleFullscreenChange(a)),Se.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()}}R4.prototype.controlText_="Fullscreen";ce.registerComponent("FullscreenToggle",R4);var NT=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 Sj extends ce{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}}ce.registerComponent("VolumeLevel",Sj);class Cj extends ce{constructor(e,t){super(e,t);this.update=a0(la(this,this.update),fi)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,a,n){if(!a){let s=l1(this.el_),i=l1(this.player_.el()),l=e.width*t;if(!i||!s)return;let f=e.left-i.left+l,c=e.width-l+(i.right-e.right),h=s.width/2;if(f<h)h+=h-f;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){Wl(this.el_,e)}updateVolume(e,t,a,n,s){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{if(this.update(e,t,a,n.toFixed(0)),s)s()})}}ce.registerComponent("VolumeLevelTooltip",Cj);class N4 extends ce{constructor(e,t){super(e,t);this.update=a0(la(this,this.update),fi)}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`})}}N4.prototype.options_={children:["volumeLevelTooltip"]};ce.registerComponent("MouseVolumeLevelDisplay",N4);class Ch extends n9{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(!vh(e))return;super.handleMouseDown(e)}handleMouseMove(e){let t=this.getChild("mouseVolumeLevelDisplay");if(t){let a=this.el(),n=l1(a),s=this.vertical(),i=Vm(a,e);i=s?i.y:i.x,i=Sh(i,0,1),t.update(n,i,s)}if(!vh(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)})}}Ch.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};if(!Un&&!Oi)Ch.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");Ch.prototype.playerEvent="volumechange";ce.registerComponent("VolumeBar",Ch);class z4 extends ce{constructor(e,t={}){if(t.vertical=t.vertical||!1,typeof t.volumeBar>"u"||s1(t.volumeBar))t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical;super(e,t);NT(this,e),this.throttledHandleMouseMove=a0(la(this,this.handleMouseMove),fi),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)}}z4.prototype.options_={children:["volumeBar"]};ce.registerComponent("VolumeControl",z4);var zT=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 E4 extends Bn{constructor(e,t){super(e,t);zT(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"),Un&&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;Km(this.el_,[0,1,2,3].reduce((a,n)=>a+`${n?" ":""}vjs-vol-${n}`,"")),mr(this.el_,`vjs-vol-${t}`)}updateControlText_(){let t=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";if(this.controlText()!==t)this.controlText(t)}}E4.prototype.controlText_="Mute";ce.registerComponent("MuteToggle",E4);class I4 extends ce{constructor(e,t={}){if(typeof t.inline<"u")t.inline=t.inline;else t.inline=!0;if(typeof t.volumeControl>"u"||s1(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"),Is(Se.default,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Gn(Se.default,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){if(e.key==="Escape")this.handleMouseOut()}}I4.prototype.options_={children:["muteToggle","volumeControl"]};ce.registerComponent("VolumePanel",I4);class U4 extends Bn{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]))}}U4.prototype.controlText_="Skip Forward";ce.registerComponent("SkipForward",U4);class G4 extends Bn{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]))}}G4.prototype.controlText_="Skip Backward";ce.registerComponent("SkipBackward",G4);class X4 extends ce{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 ce))return;this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_)}removeEventListenerForItem(e){if(!(e instanceof ce))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_=at(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_),Is(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||Se.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()}}}ce.registerComponent("Menu",X4);class l9 extends ce{constructor(e,t={}){super(e,t);this.menuButton_=new Bn(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");let a=Bn.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(),Is(Se.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 X4(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){let t=at("li",{className:"vjs-menu-title",textContent:Ma(this.options_.title),tabIndex:-1}),a=new ce(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=Bn.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"),Gn(Se.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"),Un&&Gd())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()}}ce.registerComponent("MenuButton",l9);class f9 extends l9{constructor(e,t){let a=t.tracks;super(e,t);if(this.items.length<=1)this.hide();if(!a)return;let n=la(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)})}}ce.registerComponent("TrackButton",f9);class m1 extends yh{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=at("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}}ce.registerComponent("MenuItem",m1);class g1 extends m1{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=(...l)=>{this.handleTracksChange.apply(this,l)},i=(...l)=>{this.handleSelectedLanguageChange.apply(this,l)};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 l;this.on(["tap","click"],function(){if(typeof K.default.Event!=="object")try{l=new K.default.Event("change")}catch(f){}if(!l)l=Se.default.createEvent("Event"),l.initEvent("change",!0,!0);n.dispatchEvent(l)})}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()}}ce.registerComponent("TextTrackMenuItem",g1);class K4 extends g1{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()}}ce.registerComponent("OffTextTrackMenuItem",K4);class jr extends f9{constructor(e,t={}){t.tracks=e.textTracks();super(e,t)}createItems(e=[],t=g1){let a;if(this.label_)a=`${this.label_} off`;e.push(new K4(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 l=new t(this.player_,{track:i,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});l.addClass(`vjs-${i.kind}-menu-item`),e.push(l)}}return e}}ce.registerComponent("TextTrackButton",jr);class L4 extends m1{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)}}ce.registerComponent("ChaptersTrackMenuItem",L4);class r9 extends jr{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(Ma(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 L4(this.player_,{track:this.track_,cue:s});e.push(i)}return e}}r9.prototype.kind_="chapters";r9.prototype.controlText_="Chapters";ce.registerComponent("ChaptersButton",r9);class o9 extends jr{constructor(e,t,a){super(e,t,a);this.setIcon("audio-description");let n=e.textTracks(),s=la(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()}`}}o9.prototype.kind_="descriptions";o9.prototype.controlText_="Descriptions";ce.registerComponent("DescriptionsButton",o9);class c9 extends jr{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()}`}}c9.prototype.kind_="subtitles";c9.prototype.controlText_="Subtitles";ce.registerComponent("SubtitlesButton",c9);class h9 extends g1{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()}}ce.registerComponent("CaptionSettingsMenuItem",h9);class u9 extends jr{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 h9(this.player_,{kind:this.kind_})),this.hideThreshold_+=1;return super.createItems(e)}}u9.prototype.kind_="captions";u9.prototype.controlText_="Captions";ce.registerComponent("CaptionsButton",u9);class V4 extends g1{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(at("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0}));s.appendChild(at("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))}return n}}ce.registerComponent("SubsCapsMenuItem",V4);class m9 extends jr{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(Ma(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 h9(this.player_,{kind:this.label_})),this.hideThreshold_+=1;return e=super.createItems(e,V4),e}}m9.prototype.kinds_=["captions","subtitles"];m9.prototype.controlText_="Subtitles";ce.registerComponent("SubsCapsButton",m9);class Y4 extends m1{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(at("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),s.appendChild(at("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)}}ce.registerComponent("AudioTrackMenuItem",Y4);class J4 extends f9{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 Y4(this.player_,{track:n,selectable:!0,multiSelectable:!1}))}return e}}J4.prototype.controlText_="Audio Track";ce.registerComponent("AudioTrackButton",J4);class g9 extends m1{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)}}g9.prototype.contentElType="button";ce.registerComponent("PlaybackRateMenuItem",g9);class Q4 extends l9{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_=at("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 g9(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"}}Q4.prototype.controlText_="Playback Rate";ce.registerComponent("PlaybackRateMenuButton",Q4);class Z4 extends ce{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},a={}){if(!t.className)t.className=this.buildCSSClass();return super.createEl(e,t,a)}}ce.registerComponent("Spacer",Z4);class _j extends Z4{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}ce.registerComponent("CustomControlSpacer",_j);class $4 extends ce{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}$4.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};ce.registerComponent("ControlBar",$4);class W4 extends wr{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):""}}W4.prototype.options_=Object.assign({},wr.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});ce.registerComponent("ErrorDisplay",W4);class P4 extends ce{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(),at("select",{id:this.options_.id},{},this.options_.SelectOptions.map((t)=>{let a=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${li()}`)+"-"+t[1].replace(/\W+/g,""),n=at("option",{id:a,value:this.localize(t[0]),textContent:this.localize(t[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${a}`),n}))}}ce.registerComponent("TextTrackSelect",P4);class Jl extends ce{constructor(e,t={}){super(e,t);let a=at("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],l=i.className,f=i.id.replace("%s",this.options_.id_),c=null,h=`vjs_select_${li()}`;if(this.options_.type==="colors"){c=at("span",{className:l});let g=at("label",{id:f,className:"vjs-label",textContent:this.localize(i.label)});g.setAttribute("for",h),c.appendChild(g)}let u=new P4(e,{SelectOptions:i.options,legendId:this.options_.legendId,id:h,labelId:f});if(this.addChild(u),this.options_.type==="colors")c.appendChild(u.el()),this.el().appendChild(c)}}createEl(){return at("fieldset",{className:this.options_.className})}}ce.registerComponent("TextTrackFieldset",Jl);class eg extends ce{constructor(e,t={}){super(e,t);let a=this.options_.textTrackComponentid,n=new Jl(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 Jl(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 Jl(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 at("div",{className:"vjs-track-settings-colors"})}}ce.registerComponent("TextTrackSettingsColors",eg);class tg extends ce{constructor(e,t={}){super(e,t);let a=this.options_.textTrackComponentid,n=new Jl(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 Jl(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 Jl(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 at("div",{className:"vjs-track-settings-font"})}}ce.registerComponent("TextTrackSettingsFont",tg);class ag extends ce{constructor(e,t={}){super(e,t);let a=new Bn(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 Bn(e,{controlText:n,className:"vjs-done-button"});s.el().classList.remove("vjs-control","vjs-button"),s.el().textContent=n,this.addChild(s)}createEl(){return at("div",{className:"vjs-track-settings-controls"})}}ce.registerComponent("TrackSettingsControls",ag);var D6="vjs-text-track-settings",ad=["#000","Black"],nd=["#00F","Blue"],sd=["#0FF","Cyan"],id=["#0F0","Green"],ld=["#F0F","Magenta"],fd=["#F00","Red"],rd=["#FFF","White"],od=["#FF0","Yellow"],R6=["1","Opaque"],N6=["0.5","Semi-Transparent"],cd=["0","Transparent"],Vl={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[ad,rd,fd,id,nd,od,ld,sd],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[R6,N6,cd],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[rd,ad,fd,id,nd,od,ld,sd],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:[R6,N6],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:[cd,N6,R6],className:"vjs-window-opacity vjs-opacity"}};Vl.windowColor.options=Vl.backgroundColor.options;function Fj(e,t){if(t)e=t(e);if(e&&e!=="none")return e}function ET(e,t){let a=e.options[e.options.selectedIndex].value;return Fj(a,t)}function IT(e,t,a){if(!t)return;for(let n=0;n<e.options.length;n++)if(Fj(e.options[n].value,a)===t){e.selectedIndex=n;break}}class Oj extends wr{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=at("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 eg(e,{textTrackComponentid:this.id_,selectConfigs:Vl,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);let a=new tg(e,{textTrackComponentid:this.id_,selectConfigs:Vl,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(a);let n=new ag(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()}),Qo(Vl,(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 Dd(Vl,(e,t,a)=>{let n=ET(this.$(t.selector),t.parser);if(n!==void 0)e[a]=n;return e},{})}setValues(e){Qo(Vl,(t,a)=>{IT(this.$(t.selector),e[a],t.parser)})}setDefaults(){Qo(Vl,(e)=>{let t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(K.default.localStorage.getItem(D6))}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)K.default.localStorage.setItem(D6,JSON.stringify(e));else K.default.localStorage.removeItem(D6)}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()}}ce.registerComponent("TextTrackSettings",Oj);class Bj extends ce{constructor(e,t){let a=t.ResizeObserver||K.default.ResizeObserver;if(t.ResizeObserver===null)a=!1;let n=ea({createEl:!a,reportTouchActivity:!1},t);super(e,n);if(this.ResizeObserver=t.ResizeObserver||K.default.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=sj(()=>{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(){Gn(this,"resize",s),Gn(this,"unload",i),i=null};Is(this.el_.contentWindow,"unload",i),Is(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()}}ce.registerComponent("ResizeManager",Bj);var UT={trackingThreshold:20,liveTolerance:15};class Tj extends ce{constructor(e,t){let a=ea(UT,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(K.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_,fi),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()}}ce.registerComponent("LiveTracker",Tj);class Mj extends ce{constructor(e,t){super(e,t);this.on("statechanged",(a)=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:at("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${li()}`}),description:at("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${li()}`})},at("div",{className:"vjs-title-bar"},{},Rd(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],l=a[n];if(Ym(i),s)Wl(i,s);if(t){if(t.removeAttribute(l),s)t.setAttribute(l,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}}ce.registerComponent("TitleBar",Mj);var GT={initialDisplay:4000,position:[],takeFocus:!1};class Hj extends Bn{constructor(e,t){t=ea(GT,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=at("button",{},{type:"button",class:this.buildCSSClass()},at("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()}}ce.registerComponent("TransientButton",Hj);var P6=(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 l=a[i].src;if(l&&n.indexOf(l)===-1)n.push(l)}if(!n.length)return!1;if(n.length===1)s=n[0];return e.triggerSourceset(s),!0},XT=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(e){let t=Se.default.createElement(this.nodeName.toLowerCase());t.innerHTML=e;let a=Se.default.createDocumentFragment();while(t.childNodes.length)a.appendChild(t.childNodes[0]);return this.innerText="",K.default.Element.prototype.appendChild.call(this,a),this.innerHTML}}),xj=(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},KT=(e)=>xj([e.el(),K.default.HTMLMediaElement.prototype,K.default.Element.prototype,XT],"innerHTML"),hd=function(e){let t=e.el();if(t.resetSourceWatch_)return;let a={},n=KT(e),s=(i)=>(...l)=>{let f=i.apply(t,l);return P6(e),f};["append","appendChild","insertAdjacentHTML"].forEach((i)=>{if(!t[i])return;a[i]=t[i],t[i]=s(a[i])}),Object.defineProperty(t,"innerHTML",ea(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_)},LT=Object.defineProperty({},"src",{get(){if(this.hasAttribute("src"))return gj(K.default.Element.prototype.getAttribute.call(this,"src"));return""},set(e){return K.default.Element.prototype.setAttribute.call(this,"src",e),e}}),VT=(e)=>xj([e.el(),K.default.HTMLMediaElement.prototype,LT],"src"),YT=function(e){if(!e.featuresSourceset)return;let t=e.el();if(t.resetSourceset_)return;let a=VT(e),n=t.setAttribute,s=t.load;if(Object.defineProperty(t,"src",ea(a,{set:(i)=>{let l=a.set.call(t,i);return e.triggerSourceset(t.src),l}})),t.setAttribute=(i,l)=>{let f=n.call(t,i,l);if(/src/i.test(i))e.triggerSourceset(t.src);return f},t.load=()=>{let i=s.call(t);if(!P6(e))e.triggerSourceset(""),hd(e);return i},t.currentSrc)e.triggerSourceset(t.currentSrc);else if(!P6(e))hd(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 gt{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,l=[];while(i--){let f=s[i];if(f.nodeName.toLowerCase()==="track"){if(!this.featuresNativeTextTracks)l.push(f);else if(this.remoteTextTrackEls().addTrackElement_(f),this.remoteTextTracks().addTrack(f.track),this.textTracks().addTrack(f.track),!n&&!this.el_.hasAttribute("crossorigin")&&Pm(f.src))n=!0}}for(let f=0;f<l.length;f++)this.el_.removeChild(l[f])}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_(),(jh||Gm)&&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_(){YT(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=ii[e],a=this.el()[t.getterName],n=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!a||!a.addEventListener)return;let s={change:(l)=>{let f={type:"change",target:n,currentTarget:n,srcElement:n};if(n.trigger(f),e==="text")this[r1.remoteText.getterName]().trigger(f)},addtrack(l){n.addTrack(l.track)},removetrack(l){n.removeTrack(l.track)}},i=function(){let l=[];for(let f=0;f<n.length;f++){let c=!1;for(let h=0;h<a.length;h++)if(a[h]===n[f]){c=!0;break}if(!c)l.push(n[f])}while(l.length)n.removeTrack(l.shift())};this[t.getterName+"Listeners_"]=s,Object.keys(s).forEach((l)=>{let f=s[l];a.addEventListener(l,f),this.on("dispose",(c)=>a.removeEventListener(l,f))}),this.on("loadstart",i),this.on("dispose",(l)=>this.off("loadstart",i))}proxyNativeTracks_(){ii.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=Se.default.createElement("video");let a=this.options_.tag&&Ll(this.options_.tag),n=ea({},a);if(!jh||this.options_.nativeControlsForTouch!==!0)delete n.controls;Ld(e,Object.assign(n,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}if(typeof this.options_.preload<"u")i1(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)i1(e,n,n);else Lm(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&&Xm)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&&Oi&&t0&&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)Zi(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=at("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=Se.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(K.default.performance)e.creationTime=K.default.performance.now();return e}}Em(De,"TEST_VID",function(){if(!o1())return;let e=Se.default.createElement("video"),t=Se.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&&Un)return K.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)i1(De.TEST_VID,"muted","muted");else Lm(De.TEST_VID,"muted","muted");return e!==De.TEST_VID.muted}catch(e){return!1}};De.canControlPlaybackRate=function(){if(Oi&&t0&&Im<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(Se.default.createElement("video"),"src",{get:e,set:e}),Object.defineProperty(Se.default.createElement("audio"),"src",{get:e,set:e}),Object.defineProperty(Se.default.createElement("video"),"innerHTML",{get:e,set:e}),Object.defineProperty(Se.default.createElement("audio"),"innerHTML",{get:e,set:e})}catch(e){return!1}return!0};De.supportsNativeTextTracks=function(){return Xm||Un&&t0};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]){Em(De.prototype,e,()=>De[t](),!0)});De.prototype.featuresVolumeControl=De.canControlVolume();De.prototype.movingMediaElementInDOM=!Un;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"+Ma(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"+Ma(e)]=function(t){this.el_[e]=t}});["pause","load","play"].forEach(function(e){De.prototype[e]=function(){return this.el_[e]()}});gt.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=C4(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);gt.registerTech("Html5",De);var Dj=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],z6={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},e4=["tiny","xsmall","small","medium","large","xlarge","huge"],bm={};e4.forEach((e)=>{let t=e.charAt(0)==="x"?`x-${e.substring(1)}`:e;bm[e]=`vjs-layout-${t}`});var JT={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class Ut extends ce{constructor(e,t,a){if(e.id=e.id||t.id||`vjs_video_${li()}`,t=Object.assign(Ut.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=Hd(this.id_),this.fsApi_=dm,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&&Ll(e),this.language(this.options_.language),t.languages){let i={};Object.getOwnPropertyNames(t.languages).forEach(function(l){i[l.toLowerCase()]=t.languages[l]}),this.languages_=i}else this.languages_=Ut.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(),v4(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen)Is(Se.default,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_);if(this.fluid_)this.on(["playerreset","resize"],this.boundUpdateStyleEl_);let n=ea(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 l=new K.default.DOMParser().parseFromString(xT,"image/svg+xml");if(l.querySelector("parsererror"))qt.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{let c=l.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 bj(this),this.addClass("vjs-spatial-navigation-enabled");if(jh)this.addClass("vjs-touch-enabled");if(!Un)this.addClass("vjs-workinghover");Ut.players[this.id_]=this;let s=K6.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"),Gn(Se.default,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Gn(Se.default,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode)this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null;if(Ut.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;BT(this),Wn.names.forEach((e)=>{let t=Wn[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=Ll(e);if(n){t=this.el_=e,e=this.tag=Se.default.createElement("video");while(t.children.length)e.appendChild(t.firstChild);if(!gh(t,"video-js"))mr(t,"video-js");t.appendChild(e),a=this.playerElIngest_=t,Object.keys(t).forEach((f)=>{try{e[f]=t[f]}catch(c){}})}if(e.setAttribute("tabindex","-1"),s.tabindex="-1",t0&&Um)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(f){if(!(n&&f==="class"))t.setAttribute(f,s[f]);if(n)e.setAttribute(f,s[f])}),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((f)=>Ud[f]).map((f)=>{return"vjs-device-"+f.substring(3).toLowerCase().replace(/\_/g,"-")});if(this.addClass(...i),K.default.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=aj("vjs-styles-dimensions");let f=Zl(".vjs-styles-defaults"),c=Zl("head");c.insertBefore(this.styleEl_,f?f.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 l=e.getElementsByTagName("a");for(let f=0;f<l.length;f++){let c=l.item(f);mr(c,"vjs-hidden"),c.setAttribute("hidden","hidden")}if(e.initNetworkState_=e.networkState,e.parentNode&&!a)e.parentNode.insertBefore(t,e);return V6(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,Y0(this))this.off(["playerreset","resize"],this.boundUpdateStyleEl_);if(e)this.addClass("vjs-fluid"),this.fill(!1),oT(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(K.default.VIDEOJS_NO_DYNAMIC_STYLE===!0){let l=typeof this.width_==="number"?this.width_:this.options_.width,f=typeof this.height_==="number"?this.height_:this.options_.height,c=this.tech_&&this.tech_.el();if(c){if(l>=0)c.width=l;if(f>=0)c.height=f}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),nj(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=Ma(e),n=e.charAt(0).toLowerCase()+e.slice(1);if(a!=="Html5"&&this.tag)gt.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(Wn.names.forEach((f)=>{let c=Wn[f];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 l=gt.getTech(e);if(!l)throw Error(`No Tech named '${a}' exists! '${a}' should be registered using videojs.registerTech()'`);if(this.tech_=new l(i),this.tech_.ready(la(this,this.handleTechReady_),!0),W6.jsonToTextTracks(this.textTracksJson_||[],this.tech_),Dj.forEach((f)=>{this.on(this.tech_,f,(c)=>this[`handleTech${Ma(f)}_`](c))}),Object.keys(z6).forEach((f)=>{this.on(this.tech_,f,(c)=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${z6[f]}_`].bind(this),event:c});return}this[`handleTech${z6[f]}_`](c)})}),this.on(this.tech_,"loadstart",(f)=>this.handleTechLoadStart_(f)),this.on(this.tech_,"sourceset",(f)=>this.handleTechSourceset_(f)),this.on(this.tech_,"waiting",(f)=>this.handleTechWaiting_(f)),this.on(this.tech_,"ended",(f)=>this.handleTechEnded_(f)),this.on(this.tech_,"seeking",(f)=>this.handleTechSeeking_(f)),this.on(this.tech_,"play",(f)=>this.handleTechPlay_(f)),this.on(this.tech_,"pause",(f)=>this.handleTechPause_(f)),this.on(this.tech_,"durationchange",(f)=>this.handleTechDurationChange_(f)),this.on(this.tech_,"fullscreenchange",(f,c)=>this.handleTechFullscreenChange_(f,c)),this.on(this.tech_,"fullscreenerror",(f,c)=>this.handleTechFullscreenError_(f,c)),this.on(this.tech_,"enterpictureinpicture",(f)=>this.handleTechEnterPictureInPicture_(f)),this.on(this.tech_,"leavepictureinpicture",(f)=>this.handleTechLeavePictureInPicture_(f)),this.on(this.tech_,"error",(f)=>this.handleTechError_(f)),this.on(this.tech_,"posterchange",(f)=>this.handleTechPosterChange_(f)),this.on(this.tech_,"textdata",(f)=>this.handleTechTextData_(f)),this.on(this.tech_,"ratechange",(f)=>this.handleTechRateChange_(f)),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))V6(this.tech_.el(),this.el());if(this.tag)this.tag.player=null,this.tag=null}unloadTech_(){if(Wn.names.forEach((e)=>{let t=Wn[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=W6.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":K6}}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(!bh(i))return;return i.catch((l)=>{throw s(),Error(`Rejection at manualAutoplay. Restoring muted value. ${l?l:""}`)})},a;if(e==="any"&&!this.muted()){if(a=this.play(),bh(a))a=a.catch(t)}else if(e==="muted"&&!this.muted())a=t();else a=this.play();if(!bh(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=HT(this,t);this.cache_.source=ea({},e,{src:t,type:a});let n=this.cache_.sources.filter((f)=>f.src&&f.src===t),s=[],i=this.$$("source"),l=[];for(let f=0;f<i.length;f++){let c=Ll(i[f]);if(s.push(c),c.src&&c.src===t)l.push(c.src)}if(l.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())Zi(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()&&!Se.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=Se.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 FT)return CT(this.middleware_,this.tech_,e,t);else if(e in Zw)return Qw(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 _T)return ST(this.middleware_,this.tech_,e);else if(e in Zw)return Qw(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=Zi){this.playCallbacks_.push(e);let t=Boolean(!this.changingSrc_&&(this.src()||this.currentSrc())),a=Boolean(Xm||Un);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")||Fi(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=Fi(0,0);return e}seekable(){let e=this.techGet_("seekable");if(!e||!e.length)e=Fi(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 uj(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",l),t.off("fullscreenchange",i)}function i(){s(),a()}function l(c,h){s(),n(h)}t.one("fullscreenchange",i),t.one("fullscreenerror",l);let f=t.requestFullscreenHelper_(e);if(f)f.then(s,s),f.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(f,c){n(),a(c)}e.one("fullscreenchange",s),e.one("fullscreenerror",i);let l=e.exitFullscreenHelper_();if(l)l.then(n,n),l.then(t,a)})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){let e=Se.default[this.fsApi_.exitFullscreen]();if(e)Zi(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=Se.default.documentElement.style.overflow,Is(Se.default,"keydown",this.boundFullWindowOnEscKey_),Se.default.documentElement.style.overflow="hidden",mr(Se.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,Gn(Se.default,"keydown",this.boundFullWindowOnEscKey_),Se.default.documentElement.style.overflow=this.docOrigOverflow,Km(Se.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&&K.default.documentPictureInPicture){let e=Se.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(at("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),K.default.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then((t)=>{return Pd(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 Se.default&&this.disablePictureInPicture()===!1)return this.techGet_("requestPictureInPicture");return Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(K.default.documentPictureInPicture&&K.default.documentPictureInPicture.window)return K.default.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in Se.default)return Se.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=ce.getComponent("FullscreenToggle");if(Se.default[this.fsApi_.fullscreenEnabled]!==!1)i.prototype.handleClick.call(this,e)}else if(n.call(this,e))e.preventDefault(),e.stopPropagation(),ce.getComponent("MuteToggle").prototype.handleClick.call(this,e);else if(s.call(this,e))e.preventDefault(),e.stopPropagation(),ce.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=gt.getTech(s);if(!i)i=ce.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((l)=>{return[l,gt.getTech(l)]}).filter(([l,f])=>{if(f)return f.isSupported();return qt.error(`The "${l}" tech is undefined. Skipped browser support check for that tech.`),!1}),a=function(l,f,c){let h;return l.some((u)=>{return f.some((g)=>{if(h=c(u,g),h)return!0})}),h},n,s=(l)=>(f,c)=>l(c,f),i=([l,f],c)=>{if(f.canPlaySource(c,this.options_[l.toLowerCase()]))return{source:c,tech:l}};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=pj(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]),AT(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}yT(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(!rj(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();Zi(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(Y0(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(Ql("beforeerror").forEach((t)=>{let a=t(this,e);if(!(e0(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 Aa(e),this.addClass("vjs-error"),qt.error(`(CODE:${this.error_.code} ${Aa.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Ql("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=la(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)},l=function(u){n(),this.clearInterval(e)};this.on("mousedown",i),this.on("mousemove",s),this.on("mouseup",l),this.on("mouseleave",l);let f=this.getChild("controlBar");if(f&&!Un&&!Oi)f.on("mouseenter",function(u){if(this.player().options_.inactivityTimeout!==0)this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout;this.player().options_.inactivityTimeout=0}),f.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(),Y0(this))this.trigger("languagechange")}}languages(){return ea(Ut.prototype.options_.languages,this.languages_)}toJSON(){let e=ea(this.options_),t=e.tracks;e.tracks=[];for(let a=0;a<t.length;a++){let n=t[a];n=ea(n),n.player=void 0,e.tracks[a]=n}return e}createModal(e,t){t=t||{},t.content=e||"";let a=new wr(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<e4.length;a++){let n=e4[a],s=this.breakpoints_[n];if(t<=s){if(e===n)return;if(e)this.removeClass(bm[e]);this.addClass(bm[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({},JT,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 bm[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!=="object")return;let a=this.crossOrigin();this.reset(),this.cache_.media=ea(e);let{artist:n,artwork:s,description:i,poster:l,src:f,textTracks:c,title:h}=this.cache_.media;if(!s&&l)this.cache_.media.artwork=[{src:l,type:Fm(l)}];if(a)this.crossOrigin(a);if(f)this.src(f);if(l)this.poster(l);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:Fm(n.poster)}];return n}return ea(this.cache_.media)}static getTagSettings(e){let t={sources:[],tracks:[]},a=Ll(e),n=a["data-setup"];if(gh(e,"vjs-fill"))a.fill=!0;if(gh(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,l=s.length;i<l;i++){let f=s[i],c=f.nodeName.toLowerCase();if(c==="source")t.sources.push(Ll(f));else if(c==="track")t.tracks.push(Ll(f))}}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")}}Ut.prototype.videoTracks=()=>{};Ut.prototype.audioTracks=()=>{};Ut.prototype.textTracks=()=>{};Ut.prototype.remoteTextTracks=()=>{};Ut.prototype.remoteTextTrackEls=()=>{};Wn.names.forEach(function(e){let t=Wn[e];Ut.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]}});Ut.prototype.crossorigin=Ut.prototype.crossOrigin;Ut.players={};var ch=K.default.navigator;Ut.prototype.options_={techOrder:gt.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2000,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:ch&&(ch.languages&&ch.languages[0]||ch.userLanguage||ch.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};Dj.forEach(function(e){Ut.prototype[`handleTech${Ma(e)}_`]=function(){return this.trigger(e)}});ce.registerComponent("Player",Ut);var Bm="plugin",Wo="activePlugins_",Yo={},Tm=(e)=>Yo.hasOwnProperty(e),wm=(e)=>Tm(e)?Yo[e]:void 0,Rj=(e,t)=>{e[Wo]=e[Wo]||{},e[Wo][t]=!0},Mm=(e,t,a)=>{let n=(a?"before":"")+"pluginsetup";e.trigger(n,t),e.trigger(n+":"+t.name,t)},QT=function(e,t){let a=function(){Mm(this,{name:e,plugin:t,instance:null},!0);let n=t.apply(this,arguments);return Rj(this,e),Mm(this,{name:e,plugin:t,instance:n}),n};return Object.keys(t).forEach(function(n){a[n]=t[n]}),a},ud=(e,t)=>{return t.prototype.name=e,function(...a){Mm(this,{name:e,plugin:t,instance:null},!0);let n=new t(...[this,...a]);return this[e]=()=>n,Mm(this,n.getEventHash()),n}};class js{constructor(e){if(this.constructor===js)throw Error("Plugin must be sub-classed; not directly instantiated.");if(this.player=e,!this.log)this.log=this.player.log.createLogger(this.name);v4(this),delete this.trigger,fj(this,this.constructor.defaultState),Rj(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 h1(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[Wo][e]=!1,this.player=this.state=null,t[e]=ud(e,Yo[e])}static isBasic(e){let t=typeof e==="string"?wm(e):e;return typeof t==="function"&&!js.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(Tm(e))qt.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(Ut.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(Yo[e]=t,e!==Bm)if(js.isBasic(t))Ut.prototype[e]=QT(e,t);else Ut.prototype[e]=ud(e,t);return t}static deregisterPlugin(e){if(e===Bm)throw Error("Cannot de-register base plugin.");if(Tm(e))delete Yo[e],delete Ut.prototype[e]}static getPlugins(e=Object.keys(Yo)){let t;return e.forEach((a)=>{let n=wm(a);if(n)t=t||{},t[a]=n}),t}static getPluginVersion(e){let t=wm(e);return t&&t.VERSION||""}}js.getPlugin=wm;js.BASE_PLUGIN_NAME=Bm;js.registerPlugin(Bm,js);Ut.prototype.usingPlugin=function(e){return!!this[Wo]&&this[Wo][e]===!0};Ut.prototype.hasPlugin=function(e){return!!Tm(e)};function ZT(e,t){let a=!1;return function(...n){if(!a)qt.warn(e);return a=!0,t.apply(this,n)}}function Bi(e,t,a,n){return ZT(`${t} is deprecated and will be removed in ${e}.0; please use ${a} instead.`,n)}var $T={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"},Nj=(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"?Zl("#"+Nj(e)):e;if(!c1(s))throw TypeError("The element or ID supplied is not valid. (videojs)");let l=("getRootNode"in s?s.getRootNode()instanceof K.default.ShadowRoot:!1)?s.getRootNode():s.ownerDocument.body;if(!s.ownerDocument.defaultView||!l.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 Ql("beforesetup").forEach((c)=>{let h=c(s,ea(t));if(!e0(h)||Array.isArray(h)){qt.error("please return an object in beforesetup hooks");return}t=ea(t,h)}),n=new(ce.getComponent("Player"))(s,t,a),Ql("setup").forEach((c)=>c(n)),n}se.hooks_=L0;se.hooks=Ql;se.hook=QB;se.hookOnce=ZB;se.removeHook=Md;if(K.default.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&o1()){let e=Zl(".vjs-styles-defaults");if(!e){e=aj("vjs-styles-defaults");let t=Zl("head");if(t)t.insertBefore(e,t.firstChild);nj(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
- `)}}J6(1,se);se.VERSION=K6;se.options=Ut.prototype.options_;se.getPlayers=()=>Ut.players;se.getPlayer=(e)=>{let t=Ut.players,a;if(typeof e==="string"){let n=Nj(e),s=t[n];if(s)return s;a=Zl("#"+n)}else a=e;if(c1(a)){let{player:n,playerId:s}=a;if(n||t[s])return n||t[s]}};se.getAllPlayers=()=>Object.keys(Ut.players).map((e)=>Ut.players[e]).filter(Boolean);se.players=Ut.players;se.getComponent=ce.getComponent;se.registerComponent=(e,t)=>{if(gt.isTech(t))qt.warn(`The ${e} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`);return ce.registerComponent.call(ce,e,t)};se.getTech=gt.getTech;se.registerTech=gt.registerTech;se.use=kT;Object.defineProperty(se,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(se.middleware,"TERMINATOR",{value:_m,writeable:!1,enumerable:!0});se.browser=Ud;se.obj=PB;se.mergeOptions=Bi(9,"videojs.mergeOptions","videojs.obj.merge",ea);se.defineLazyProperty=Bi(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",Em);se.bind=Bi(9,"videojs.bind","native Function.prototype.bind",la);se.registerPlugin=js.registerPlugin;se.deregisterPlugin=js.deregisterPlugin;se.plugin=(e,t)=>{return qt.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),js.registerPlugin(e,t)};se.getPlugins=js.getPlugins;se.getPlugin=js.getPlugin;se.getPluginVersion=js.getPluginVersion;se.addLanguage=function(e,t){return e=(""+e).toLowerCase(),se.options.languages=ea(se.options.languages,{[e]:t}),se.options.languages[e]};se.log=qt;se.createLogger=Hd;se.time=gT;se.createTimeRange=Bi(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Fi);se.createTimeRanges=Bi(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Fi);se.formatTime=Bi(9,"videojs.formatTime","videojs.time.formatTime",br);se.setFormatTime=Bi(9,"videojs.setFormatTime","videojs.time.setFormatTime",cj);se.resetFormatTime=Bi(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",hj);se.parseUrl=Bi(9,"videojs.parseUrl","videojs.url.parseUrl",S4);se.isCrossOrigin=Bi(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",Pm);se.EventTarget=qs;se.any=q4;se.on=Is;se.one=Qm;se.off=Gn;se.trigger=h1;se.xhr=p4.default;se.TrackList=$l;se.TextTrack=u1;se.TextTrackList=$m;se.AudioTrack=_4;se.AudioTrackList=A4;se.VideoTrack=F4;se.VideoTrackList=y4;["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`),ej[e].apply(null,arguments)}});se.computedStyle=Bi(9,"videojs.computedStyle","videojs.dom.computedStyle",f1);se.dom=ej;se.fn=rT;se.num=RT;se.str=uT;se.url=qT;se.Error=$T;/*! @name videojs-contrib-quality-levels @version 4.1.0 @license Apache-2.0 */class zj{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 kh 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 zj(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}}kh.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(let e in kh.prototype.allowedEvents_)kh.prototype["on"+e]=null;var Ej="4.1.0",WT=function(e,t){let a=e.qualityLevels,n=new kh,s=function(){n.dispose(),e.qualityLevels=a,e.off("dispose",s)};return e.on("dispose",s),e.qualityLevels=()=>n,e.qualityLevels.VERSION=Ej,n},Ij=function(e){return WT(this,se.obj.merge({},e))};se.registerPlugin("qualityLevels",Ij);Ij.VERSION=Ej;/*! @name @videojs/http-streaming @version 3.17.3 @license Apache-2.0 */var ws=To,Hm=(e,t)=>{if(t&&t.responseURL&&e!==t.responseURL)return t.responseURL;return e},ri=(e)=>{if(se.log.debug)return se.log.debug.bind(se,"VHS:",`${e} >`);return function(){}};function Gt(...e){let t=se.obj||se;return(t.merge||t.mergeOptions).apply(t,e)}function dn(...e){let t=se.time||se;return(t.createTimeRanges||t.createTimeRanges).apply(t,e)}function PT(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 $i=0.03333333333333333,Wi=$i*3,Uj=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 dn(a)},Jo=function(e,t){return Uj(e,function(a,n){return a-Wi<=t&&n+Wi>=t})},um=function(e,t){return Uj(e,function(a){return a-$i>=t})},eM=function(e){if(e.length<2)return dn();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 dn(t)},tM=function(e,t){let a=null,n=null,s=0,i=[],l=[];if(!e||!e.length||!t||!t.length)return dn();let f=e.length;while(f--)i.push({time:e.start(f),type:"start"}),i.push({time:e.end(f),type:"end"});f=t.length;while(f--)i.push({time:t.start(f),type:"start"}),i.push({time:t.end(f),type:"end"});i.sort(function(c,h){return c.time-h.time});for(f=0;f<i.length;f++){if(i[f].type==="start"){if(s++,s===2)a=i[f].time}else if(i[f].type==="end"){if(s--,s===1)n=i[f].time}if(a!==null&&n!==null)l.push([a,n]),a=null,n=null}return dn(l)},Gj=(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(", ")},aM=function(e,t,a=1){return((e.length?e.end(e.length-1):0)-t)/a},hr=(e)=>{let t=[];for(let a=0;a<e.length;a++)t.push({start:e.start(a),end:e.end(a)});return t},nM=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},E6=function(e){if(!e||!e.length||!e.end)return;return e.end(e.length-1)},ng=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},sg=(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},t4=(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},[]),Xj=(e)=>{let t=e.segments&&e.segments.length&&e.segments[e.segments.length-1];return t&&t.parts||[]},Kj=({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},Lj=(e,t)=>{if(t.endList)return 0;if(e&&e.suggestedPresentationDelay)return e.suggestedPresentationDelay;let a=Xj(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},sM=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+=sg(e,s),typeof s.start<"u")return{result:a+s.start,precise:!0}}return{result:a,precise:!1}},iM=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+=sg(e,n),typeof n.end<"u")return{result:n.end-a,precise:!0}}return{result:-1,precise:!1}},Vj=function(e,t,a){if(typeof t>"u")t=e.mediaSequence+e.segments.length;if(t<e.mediaSequence)return 0;let n=sM(e,t);if(n.precise)return n.result;let s=iM(e,t);if(s.precise)return s.result;return n.result+a},Yj=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 K.default.Infinity}return Vj(e,t,a)},wh=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},Jj=function(e,t,a,n){if(!e||!e.segments)return null;if(e.endList)return Yj(e);if(t===null)return null;t=t||0;let s=Vj(e,e.mediaSequence+e.segments.length,t);if(a)n=typeof n==="number"?n:Lj(null,e),s-=n;return Math.max(0,s)},lM=function(e,t,a){let s=t||0,i=Jj(e,t,!0,a);if(i===null)return dn();if(i<s)i=s;return dn(s,i)},fM=function({playlist:e,currentTime:t,startingSegmentIndex:a,startingPartIndex:n,startTime:s,exactManifestTimings:i}){let l=t-s,f=t4(e),c=0;for(let h=0;h<f.length;h++){let u=f[h];if(a!==u.segmentIndex)continue;if(typeof n==="number"&&typeof u.partIndex==="number"&&n!==u.partIndex)continue;c=h;break}if(l<0){if(c>0)for(let h=c-1;h>=0;h--){let u=f[h];if(l+=u.duration,i){if(l<0)continue}else if(l+$i<=0)continue;return{partIndex:u.partIndex,segmentIndex:u.segmentIndex,startTime:s-wh({defaultDuration:e.targetDuration,durationList:f,startIndex:c,endIndex:h})}}return{partIndex:f[0]&&f[0].partIndex||null,segmentIndex:f[0]&&f[0].segmentIndex||0,startTime:t}}if(c<0){for(let h=c;h<0;h++)if(l-=e.targetDuration,l<0)return{partIndex:f[0]&&f[0].partIndex||null,segmentIndex:f[0]&&f[0].segmentIndex||0,startTime:t};c=0}for(let h=c;h<f.length;h++){let u=f[h];l-=u.duration;let g=u.duration>$i,b=l===0,d=g&&l+$i>=0;if(b||d){if(h!==f.length-1)continue}if(i){if(l>0)continue}else if(l-$i>=0)continue;return{partIndex:u.partIndex,segmentIndex:u.segmentIndex,startTime:s+wh({defaultDuration:e.targetDuration,durationList:f,startIndex:c,endIndex:h})}}return{segmentIndex:f[f.length-1].segmentIndex,partIndex:f[f.length-1].partIndex,startTime:t}},Qj=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},ig=function(e){return e.excludeUntil&&e.excludeUntil===1/0},p9=function(e){let t=Qj(e);return!e.disabled&&!t},rM=function(e){return e.disabled},oM=function(e){for(let t=0;t<e.segments.length;t++)if(e.segments[t].key)return!0;return!1},Zj=function(e,t){return t.attributes&&t.attributes[e]},cM=function(e,t,a,n=0){if(!Zj("BANDWIDTH",a))return NaN;return(e*a.attributes.BANDWIDTH-n*8)/t},a4=(e,t)=>{if(e.playlists.length===1)return!0;let a=t.attributes.BANDWIDTH||Number.MAX_VALUE;return e.playlists.filter((n)=>{if(!p9(n))return!1;return(n.attributes.BANDWIDTH||0)<a}).length===0},lg=(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},md=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},_h=(e)=>{if(!e||!e.playlists||!e.playlists.length)return md(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)=>Y3(i)))continue;if(md(e,(i)=>lg(a,i)))continue;return!1}return!0},ds={liveEdgeDelay:Lj,duration:Yj,seekable:lM,getMediaInfoForTime:fM,isEnabled:p9,isDisabled:rM,isExcluded:Qj,isIncompatible:ig,playlistEnd:Jj,isAes:oM,hasAttribute:Zj,estimateSegmentRequestTime:cM,isLowestEnabledRendition:a4,isAudioOnly:_h,playlistMatch:lg,segmentDurationWithParts:sg},{log:$j}=se,Po=(e,t)=>{return`${e}-${t}`},Wj=(e,t,a)=>{return`placeholder-uri-${e}-${t}-${a}`},hM=({onwarn:e,oninfo:t,manifestString:a,customTagParsers:n=[],customTagMappers:s=[],llhls:i})=>{let l=new L3;if(e)l.on("warn",e);if(t)l.on("info",t);n.forEach((h)=>l.addParser(h)),s.forEach((h)=>l.addTagMapper(h)),l.push(a),l.end();let f=l.manifest;if(!i){if(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(h){if(f.hasOwnProperty(h))delete f[h]}),f.segments)f.segments.forEach(function(h){["parts","preloadHints"].forEach(function(u){if(h.hasOwnProperty(u))delete h[u]})})}if(!f.targetDuration){let h=10;if(f.segments&&f.segments.length)h=f.segments.reduce((u,g)=>Math.max(u,g.duration),0);if(e)e({message:`manifest has no targetDuration defaulting to ${h}`});f.targetDuration=h}let c=Xj(f);if(c.length&&!f.partTargetDuration){let h=c.reduce((u,g)=>Math.max(u,g.duration),0);if(e)e({message:`manifest has no partTargetDuration defaulting to ${h}`}),$j.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.");f.partTargetDuration=h}return f},p1=(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)}})},Pj=({playlist:e,uri:t,id:a})=>{if(e.id=a,e.playlistErrors_=0,t)e.uri=t;e.attributes=e.attributes||{}},uM=(e)=>{let t=e.playlists.length;while(t--){let a=e.playlists[t];if(Pj({playlist:a,id:Po(t,a.uri)}),a.resolvedUri=ws(e.uri,a.uri),e.playlists[a.id]=a,e.playlists[a.uri]=a,!a.attributes.BANDWIDTH)$j.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},mM=(e)=>{p1(e,(t)=>{if(t.uri)t.resolvedUri=ws(e.uri,t.uri)})},gM=(e,t)=>{let a=Po(0,t),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:K.default.location.href,resolvedUri:K.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},eq=(e,t,a=Wj)=>{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=_h(e);p1(e,(s,i,l,f)=>{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===l)return}s.playlists=[va({},s)]}s.playlists.forEach(function(c,h){let u=a(i,l,f,c),g=Po(h,u);if(c.uri)c.resolvedUri=c.resolvedUri||ws(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})}),uM(e),mM(e)};class n4{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 tq=22,pr=({requestType:e,request:t,error:a,parseFailure:n})=>{let s=t.status<200||t.status>299,i=t.status>=400&&t.status<=499,l={uri:t.uri,requestType:e},f=s&&!i||n;if(a&&i)l.error=va({},a),l.errorType=se.Error.NetworkRequestFailed;else if(t.aborted)l.errorType=se.Error.NetworkRequestAborted;else if(t.timedout)l.errorType=se.Error.NetworkRequestTimeout;else if(f){let c=n?se.Error.NetworkBodyParserFailed:se.Error.NetworkBadStatus;l.errorType=c,l.status=t.status,l.headers=t.headers}return l},pM=ri("CodecUtils"),aq=function(e){let t=e.attributes||{};if(t.CODECS)return _i(t.CODECS)},nq=(e,t)=>{let a=t.attributes||{};return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&a.AUDIO&&e.mediaGroups.AUDIO[a.AUDIO]},bM=(e,t)=>{if(!nq(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},Ah=function(e){let t={};return e.forEach(({mediaType:a,type:n,details:s})=>{t[a]=t[a]||[],t[a].push(V3(`${n}${s}`))}),Object.keys(t).forEach(function(a){if(t[a].length>1){pM(`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},gd=function(e){let t=0;if(e.audio)t++;if(e.video)t++;return t},dh=function(e,t){let a=t.attributes||{},n=Ah(aq(t)||[]);if(nq(e,t)&&!n.audio){if(!bM(e,t)){let s=Ah(ob(e,a.AUDIO)||[]);if(s.audio)n.audio=s.audio}}return n},{EventTarget:wM}=se,dM=(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||[],l=Kj(t)-1;if(l>-1&&l!==i.length-1)a._HLS_part=l;if(l>-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 K.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},jM=(e,t)=>{if(!e)return t;let a=Gt(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]=Gt(e.parts[n],t.parts[n])}if(!e.skipped&&t.skipped)a.skipped=!1;if(e.preload&&!t.preload)a.preload=!1;return a},qM=(e,t,a)=>{let n=e.slice(),s=t.slice();a=a||0;let i=[],l;for(let f=0;f<s.length;f++){let c=n[f+a],h=s[f];if(c)l=c.map||l,i.push(jM(c,h));else{if(l&&!h.map)h.map=l;i.push(h)}}return i},sq=(e,t)=>{if(!e.resolvedUri&&e.uri)e.resolvedUri=ws(t,e.uri);if(e.key&&!e.key.resolvedUri)e.key.resolvedUri=ws(t,e.key.uri);if(e.map&&!e.map.resolvedUri)e.map.resolvedUri=ws(t,e.map.uri);if(e.map&&e.map.key&&!e.map.key.resolvedUri)e.map.key.resolvedUri=ws(t,e.map.key.uri);if(e.parts&&e.parts.length)e.parts.forEach((a)=>{if(a.resolvedUri)return;a.resolvedUri=ws(t,a.uri)});if(e.preloadHints&&e.preloadHints.length)e.preloadHints.forEach((a)=>{if(a.resolvedUri)return;a.resolvedUri=ws(t,a.uri)})},iq=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},lq=(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,s4=(e,t,a=lq)=>{let n=Gt(e,{}),s=n.playlists[t.id];if(!s)return null;if(a(s,t))return null;t.segments=iq(t);let i=Gt(s,t);if(i.preloadSegment&&!t.preloadSegment)delete i.preloadSegment;if(s.segments){if(t.skip){t.segments=t.segments||[];for(let l=0;l<t.skip.skippedSegments;l++)t.segments.unshift({skipped:!0})}i.segments=qM(s.segments,t.segments,t.mediaSequence-s.mediaSequence)}i.segments.forEach((l)=>{sq(l,i.resolvedUri)});for(let l=0;l<n.playlists.length;l++)if(n.playlists[l].id===t.id)n.playlists[l]=i;return n.playlists[t.id]=i,n.playlists[t.uri]=i,p1(e,(l,f,c,h)=>{if(!l.playlists)return;for(let u=0;u<l.playlists.length;u++)if(t.id===l.playlists[u].id)l.playlists[u]=i}),n},i4=(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},pd=(e,t,a)=>{if(!e)return;let n=[];return e.forEach((s)=>{if(!s.attributes)return;let{BANDWIDTH:i,RESOLUTION:l,CODECS:f}=s.attributes;n.push({id:s.id,bandwidth:i,resolution:l,codecs:f})}),{type:t,isLive:a,renditions:n}};class ur extends wM{constructor(e,t,a={}){super();if(!e)throw Error("A non-empty playlist URL or object is required");this.logger_=ri("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 n4,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=ws(this.main.uri,e.uri);if(this.llhls)t=dM(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:pr({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{let a=hM({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 l=aq(a)||[],f=Ah(l);return Boolean(f.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(),Pj({playlist:i,uri:a,id:n});let l=s4(this.main,i);if(this.targetDuration=i.partTargetDuration||i.targetDuration,this.pendingMedia_=null,l)this.main=l,this.media_=this.main.playlists[n];else this.trigger("playlistunchanged");this.updateMediaUpdateTimeout_(i4(this.media(),!!l)),s.parsedPlaylist=pd(this.main.playlists,s.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:s}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),K.default.clearTimeout(this.mediaUpdateTimeout),K.default.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new n4,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(K.default.clearTimeout(this.finalRenditionTimeout),t){let l=(e.partTargetDuration||e.targetDuration)/2*1000||5000;this.finalRenditionTimeout=K.default.setTimeout(this.media.bind(this,e,!1),l);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_(i4(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"},(l,f)=>{if(!this.request)return;if(e.lastRequest=Date.now(),e.resolvedUri=Hm(e.resolvedUri,f),l)return this.playlistRequestError(this.request,e,a);if(this.trigger({type:"playlistrequestcomplete",metadata:i}),this.haveMetadata({playlistString:f.responseText,url:e.uri,id:e.id}),a==="HAVE_MAIN_MANIFEST")this.trigger("loadedmetadata");else this.trigger("mediachange")})}pause(){if(this.mediaUpdateTimeout)K.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)K.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=K.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)K.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;if(!this.media()||this.media().endList)return;this.mediaUpdateTimeout=K.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=K.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:pr({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=Hm(this.src,a),this.trigger({type:"playlistparsestart",metadata:e});let n=this.parseManifest_({manifestString:a.responseText,url:this.src});e.parsedPlaylist=pd(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,eq(this.main,this.srcUri()),e.playlists.forEach((a)=>{a.segments=iq(a),a.segments.forEach((n)=>{sq(n,a.resolvedUri)})}),this.trigger("loadedplaylist"),!this.request)this.media(this.main.playlists[0]);return}let t=this.srcUri()||K.default.location.href;this.main=gM(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:l,id:f}=i;if(t){let c=this.createCloneURI_(i.resolvedUri,e),h=Po(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[f],delete a.playlists[l]}}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 l in a.mediaGroups[s][i])a.mediaGroups[s][i][l].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=Po(e.ID,s),l=this.createCloneAttributes_(e.ID,t.attributes),f=this.createClonePlaylist_(t,i,e,l);a.playlists[n]=f,a.playlists[i]=f,a.playlists[s]=f,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 l in n.mediaGroups[s][i]){let f=n.mediaGroups[s][i][l];n.mediaGroups[s][t][l]=va({},f);let c=n.mediaGroups[s][t][l],h=this.createCloneURI_(f.resolvedUri,e);c.resolvedUri=h,c.uri=h,c.playlists=[],f.playlists.forEach((u,g)=>{let b=n.playlists[u.id],d=Wj(s,t,l),j=Po(t,d);if(b&&!n.playlists[j]){let A=this.createClonePlaylist_(b,j,e),S=A.resolvedUri;n.playlists[j]=A,n.playlists[S]=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 Gt(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 l4=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)},vM=(e,t)=>{if(!e||!e.size)return;let a=t;return e.forEach((n)=>{a=n(a)}),a},kM=(e,t,a,n)=>{if(!e||!e.size)return;e.forEach((s)=>{s(t,a,n)})},fq=function(){let e=function t(a,n){a=Gt({timeout:45000},a);let s=t.beforeRequest||se.Vhs.xhr.beforeRequest,i=t._requestCallbackSet||se.Vhs.xhr._requestCallbackSet||new Set,l=t._responseCallbackSet||se.Vhs.xhr._responseCallbackSet;if(s&&typeof s==="function")se.log.warn("beforeRequest is deprecated, use onRequest instead."),i.add(s);let f=se.Vhs.xhr.original===!0?se.xhr:se.Vhs.xhr,c=vM(i,a);i.delete(s);let h=f(c||a,function(g,b){return kM(l,h,g,b),l4(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},AM=function(e){let t,a=e.offset;if(typeof e.offset==="bigint"||typeof e.length==="bigint")t=K.default.BigInt(e.offset)+K.default.BigInt(e.length)-K.default.BigInt(1);else t=e.offset+e.length-1;return"bytes="+a+"-"+t},f4=function(e){let t={};if(e.byterange)t.Range=AM(e.byterange);return t},yM=function(e,t){return e.start(t)+"-"+e.end(t)},SM=function(e,t){let a=e.toString(16);return"00".substring(0,2-a.length)+a+(t%2?" ":"")},CM=function(e){if(e>=32&&e<126)return String.fromCharCode(e);return"."},rq=function(e){let t={};return Object.keys(e).forEach((a)=>{let n=e[a];if($3(n))t[a]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength};else t[a]=n}),t},xm=function(e){let t=e.byterange||{length:1/0,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")},oq=function(e){return e.resolvedUri},cq=(e)=>{let t=Array.prototype.slice.call(e),a=16,n="",s,i;for(let l=0;l<t.length/16;l++)s=t.slice(l*16,l*16+16).map(SM).join(""),i=t.slice(l*16,l*16+16).map(CM).join(""),n+=s+" "+i+`
202
- `;return n},_M=({bytes:e})=>cq(e),FM=(e)=>{let t="",a;for(a=0;a<e.length;a++)t+=yM(e,a)+" ";return t},OM=Object.freeze({__proto__:null,createTransferableMessage:rq,initSegmentId:xm,segmentKeyId:oq,hexDump:cq,tagDump:_M,textRanges:FM}),hq=0.25,BM=(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)},TM=(e)=>{return e.transmuxedPresentationEnd-e.transmuxedPresentationStart-e.transmuxerPrependedSeconds},MM=(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,l=s.videoTimingInfo?TM(s.videoTimingInfo):s.duration+s.duration*hq,f=new Date(i.getTime()+l*1000);if(a>f)return null;if(a>new Date(i))n=s;return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:ds.duration(t,t.mediaSequence+t.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"}},HM=(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*hq)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:a-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},xM=(e,t)=>{let a,n;try{a=new Date(e),n=new Date(t)}catch(l){}let s=a.getTime();return(n.getTime()-s)/1000},DM=(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},RM=({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=HM(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=BM(t,n.segment);if(i)s.programDateTime=i.toISOString();return a(null,s)},uq=({programTime:e,playlist:t,retryCount:a=2,seekTo:n,pauseAfterSeek:s=!0,tech:i,callback:l})=>{if(!l)throw Error("seekToProgramTime: callback must be provided");if(typeof e>"u"||!t||!n)return l({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!i.hasStarted_)return l({message:"player must be playing a live stream to start buffering"});if(!DM(t))return l({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});let f=MM(e,t);if(!f)return l({message:`${e} was not found in the stream`});let c=f.segment,h=xM(c.dateTimeObject,e);if(f.type==="estimate"){if(a===0)return l({message:`${e} is not buffered yet. Try again`});n(f.estimatedStart+h),i.one("seeked",()=>{uq({programTime:e,playlist:t,retryCount:a-1,seekTo:n,pauseAfterSeek:s,tech:i,callback:l})});return}let u=c.start+h,g=()=>{return l(null,i.currentTime())};if(i.one("seeked",g),s)i.pause();n(u)},I6=(e,t)=>{if(e.readyState===4)return t();return},NM=(e,t,a,n)=>{let s=[],i,l=!1,f=function(g,b,d,j){return b.abort(),l=!0,a(g,b,d,j)},c=function(g,b){if(l)return;if(g)return g.metadata=pr({requestType:n,request:b,error:g}),f(g,b,"",s);let d=b.responseText.substring(s&&s.byteLength||0,b.responseText.length);if(s=mb(s,Q2(d,!0)),i=i||fr(s),s.length<10||i&&s.length<i+2)return I6(b,()=>f(g,b,"",s));let j=om(s);if(j==="ts"&&s.length<188)return I6(b,()=>f(g,b,"",s));if(!j&&s.length<376)return I6(b,()=>f(g,b,"",s));return f(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 l4(g,null,{statusCode:g.status},c)})}},function(g,b){return l4(u,g,b,c)});return u},{EventTarget:zM}=se,bd=function(e,t){if(!lq(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,l=s.byterange;if(i&&!l||!i&&l)return!1;if(i.offset!==l.offset||i.length!==l.length)return!1}return!0},EM=(e,t,a,n)=>{let s=n.attributes.NAME||a;return`placeholder-uri-${e}-${t}-${s}`},IM=({mainXml:e,srcUrl:t,clientOffset:a,sidxMapping:n,previousManifest:s})=>{let i=qw(e,{manifestUri:t,clientOffset:a,sidxMapping:n,previousManifest:s});return eq(i,t,EM),i},UM=(e,t)=>{p1(e,(a,n,s,i)=>{if(!t.mediaGroups[n][s]||!(i in t.mediaGroups[n][s]))delete e.mediaGroups[n][s][i]})},GM=(e,t,a)=>{let n=!0,s=Gt(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod,timelineStarts:t.timelineStarts});for(let i=0;i<t.playlists.length;i++){let l=t.playlists[i];if(l.sidx){let c=lh(l.sidx);if(a&&a[c]&&a[c].sidx)lm(l,a[c].sidx,l.sidx.resolvedUri)}let f=s4(s,l,bd);if(f)s=f,n=!1}if(p1(t,(i,l,f,c)=>{if(i.playlists&&i.playlists.length){let h=i.playlists[0].id,u=s4(s,i.playlists[0],bd);if(u){if(s=u,!(c in s.mediaGroups[l][f]))s.mediaGroups[l][f][c]=i;s.mediaGroups[l][f][c].playlists[0]=s.playlists[h],n=!1}}}),UM(s,t),t.minimumUpdatePeriod!==e.minimumUpdatePeriod)n=!1;if(n)return null;return s},XM=(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},wd=(e,t)=>{let a={};for(let n in e){let i=e[n].sidx;if(i){let l=lh(i);if(!t[l])break;let f=t[l].sidxInfo;if(XM(f,i))a[l]=t[l]}}return a},KM=(e,t)=>{let n=wd(e.playlists,t);return p1(e,(s,i,l,f)=>{if(s.playlists&&s.playlists.length){let c=s.playlists;n=Gt(n,wd(c,t))}}),n};class Dm extends zM{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_=ri("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&&lh(e.sidx);if(!e.sidx||!n||this.mainPlaylistLoader_.sidxMapping_[n]){K.default.clearTimeout(this.mediaRequest_),this.mediaRequest_=K.default.setTimeout(()=>a(!1),0);return}let s=Hm(e.sidx.resolvedUri),i=(f,c)=>{if(this.requestErrored_(f,c,t))return;let h=this.mainPlaylistLoader_.sidxMapping_,{requestType:u}=c,g;try{g=Td.default(Ve(c.response).subarray(8))}catch(b){b.metadata=pr({requestType:u,request:c,parseFailure:!0}),this.requestErrored_(b,c,t);return}return h[n]={sidxInfo:e.sidx,sidx:g},lm(e,g,e.sidx.resolvedUri),a(!0)},l="dash-sidx";this.request=NM(s,this.vhs_.xhr,(f,c,h,u)=>{if(f)return i(f,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(f,{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:f4({byterange:e.sidx.byterange})},i)},l)}dispose(){if(this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},K.default.clearTimeout(this.minimumUpdatePeriodTimeout_),K.default.clearTimeout(this.mediaRequest_),K.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,K.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(),K.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_)K.default.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null;if(this.state==="HAVE_NOTHING")this.started=!1}load(e){this.isPaused_=!1,K.default.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;let t=this.media();if(e){let a=t?t.targetDuration/2*1000:5000;this.mediaUpdateTimeout=K.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_){K.default.clearTimeout(this.mediaRequest_),this.mediaRequest_=K.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=pr({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=Hm(this.mainPlaylistLoader_.srcUrl,n),s){this.handleMain_(),this.syncClientServerClock_(()=>{return e(n,s)});return}return e(n,s)})}syncClientServerClock_(e){let t=vw(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:ws(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=pr({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_(){K.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=IM({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=GM(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,l=[];a.playlists.forEach((c)=>{l.push({id:c.id,bandwidth:c.attributes.BANDWIDTH,resolution:c.attributes.RESOLUTION,codecs:c.attributes.CODECS})});let f={duration:s,isLive:!i,renditions:l};t.parsedManifest=f,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_)K.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_=K.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_=KM(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=K.default.setTimeout(()=>{this.trigger("mediaupdatetimeout"),n()},i4(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 wn={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},LM=(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},mq=function(e){return e.on=e.addEventListener,e.off=e.removeEventListener,e},VM=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())}},gq=function(e){return function(){let t=VM(e),a=mq(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}},pq=function(e){return`var browserWorkerPolyFill = ${mq.toString()};
203
- browserWorkerPolyFill(self);
204
- `+e},bq=function(e){return e.toString().replace(/^function.+?{/,"").slice(0,-1)},YM=pq(bq(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},l=i.MAX_UINT32,f,c,h,u,g,b,d,j,A,S,C,O,T,M,H,D,N,z,L,ee,te,J,ae,Q,Y,$,fe,P,qe,be,me,de,ye,xe,Qe,ht;(function(){var p;if(ae={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 ae)if(ae.hasOwnProperty(p))ae[p]=[p.charCodeAt(0),p.charCodeAt(1),p.charCodeAt(2),p.charCodeAt(3)];Q=new Uint8Array([105,115,111,109]),$=new Uint8Array([97,118,99,49]),Y=new Uint8Array([0,0,0,1]),fe=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]),P=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]),qe={video:fe,audio:P},de=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),me=new Uint8Array([0,0,0,0,0,0,0,0]),ye=new Uint8Array([0,0,0,0,0,0,0,0]),xe=ye,Qe=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),ht=ye,be=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])})(),f=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 f(ae.dinf,f(ae.dref,de))},h=function(p){return f(ae.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 f(ae.ftyp,Q,Y,Q,$)},D=function(p){return f(ae.hdlr,qe[p])},g=function(p){return f(ae.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 f(ae.mdhd,q)},M=function(p){return f(ae.mdia,H(p),D(p.type),d(p))},b=function(p){return f(ae.mfhd,new Uint8Array([0,0,0,0,(p&4278190080)>>24,(p&16711680)>>16,(p&65280)>>8,p&255]))},d=function(p){return f(ae.minf,p.type==="video"?f(ae.vmhd,be):f(ae.smhd,me),c(),z(p))},j=function(p,q){var v=[],k=q.length;while(k--)v[k]=ee(q[k]);return f.apply(null,[ae.moof,b(p)].concat(v))},A=function(p){var q=p.length,v=[];while(q--)v[q]=O(p[q]);return f.apply(null,[ae.moov,C(4294967295)].concat(v).concat(S(p)))},S=function(p){var q=p.length,v=[];while(q--)v[q]=te(p[q]);return f.apply(null,[ae.mvex].concat(v))},C=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 f(ae.mvhd,q)},N=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 f(ae.sdtp,v)},z=function(p){return f(ae.stbl,L(p),f(ae.stts,ht),f(ae.stsc,xe),f(ae.stsz,Qe),f(ae.stco,ye))},function(){var p,q;L=function(v){return f(ae.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=[],R=[],E,G;for(E=0;E<k.length;E++)B.push((k[E].byteLength&65280)>>>8),B.push(k[E].byteLength&255),B=B.concat(Array.prototype.slice.call(k[E]));for(E=0;E<_.length;E++)R.push((_[E].byteLength&65280)>>>8),R.push(_[E].byteLength&255),R=R.concat(Array.prototype.slice.call(_[E]));if(G=[ae.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]),f(ae.avcC,new Uint8Array([1,v.profileIdc,v.profileCompatibility,v.levelIdc,255].concat([k.length],B,[_.length],R))),f(ae.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(f(ae.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 f.apply(null,G)},q=function(v){return f(ae.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 f(ae.tkhd,q)},ee=function(p){var q,v,k,_,B,R,E;if(q=f(ae.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])),R=Math.floor(p.baseMediaDecodeTime/l),E=Math.floor(p.baseMediaDecodeTime%l),v=f(ae.tfdt,new Uint8Array([1,0,0,0,R>>>24&255,R>>>16&255,R>>>8&255,R&255,E>>>24&255,E>>>16&255,E>>>8&255,E&255])),B=92,p.type==="audio")return k=J(p,B),f(ae.traf,q,v,k);return _=N(p),k=J(p,_.length+B),f(ae.traf,q,v,k,_)},O=function(p){return p.duration=p.duration||4294967295,f(ae.trak,T(p),M(p))},te=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 f(ae.trex,q)},function(){var p,q,v;v=function(k,_){var B=0,R=0,E=0,G=0;if(k.length){if(k[0].duration!==void 0)B=1;if(k[0].size!==void 0)R=2;if(k[0].flags!==void 0)E=4;if(k[0].compositionTimeOffset!==void 0)G=8}return[0,0,B|R|E|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,R,E,G,X,W;G=k.samples||[],_+=20+16*G.length,E=v(G,_),R=new Uint8Array(E.length+G.length*16),R.set(E),B=E.length;for(W=0;W<G.length;W++)X=G[W],R[B++]=(X.duration&4278190080)>>>24,R[B++]=(X.duration&16711680)>>>16,R[B++]=(X.duration&65280)>>>8,R[B++]=X.duration&255,R[B++]=(X.size&4278190080)>>>24,R[B++]=(X.size&16711680)>>>16,R[B++]=(X.size&65280)>>>8,R[B++]=X.size&255,R[B++]=X.flags.isLeading<<2|X.flags.dependsOn,R[B++]=X.flags.isDependedOn<<6|X.flags.hasRedundancy<<4|X.flags.paddingValue<<1|X.flags.isNonSyncSample,R[B++]=X.flags.degradationPriority&61440,R[B++]=X.flags.degradationPriority&15,R[B++]=(X.compositionTimeOffset&4278190080)>>>24,R[B++]=(X.compositionTimeOffset&16711680)>>>16,R[B++]=(X.compositionTimeOffset&65280)>>>8,R[B++]=X.compositionTimeOffset&255;return f(ae.trun,R)},p=function(k,_){var B,R,E,G,X,W;G=k.samples||[],_+=20+8*G.length,E=v(G,_),B=new Uint8Array(E.length+G.length*8),B.set(E),R=E.length;for(W=0;W<G.length;W++)X=G[W],B[R++]=(X.duration&4278190080)>>>24,B[R++]=(X.duration&16711680)>>>16,B[R++]=(X.duration&65280)>>>8,B[R++]=X.duration&255,B[R++]=(X.size&4278190080)>>>24,B[R++]=(X.size&16711680)>>>16,B[R++]=(X.size&65280)>>>8,B[R++]=X.size&255;return f(ae.trun,B)},J=function(k,_){if(k.type==="audio")return p(k,_);return q(k,_)}}();var Oe={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}},Ge=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),_},ft=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),_},Ie=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},He=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},Ze=function(p,q){var v=He();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},Je=function(p,q){var v,k,_,B,R,E=q||0,G=[];for(v=0;v<p.length;v++){B=p[v];for(k=0;k<B.length;k++)R=B[k],_=Ze(R,E),E+=_.size,G.push(_)}return G},$e=function(p){var q,v,k,_,B,R,E=0,G=p.byteLength,X=p.nalCount,W=G+4*X,le=new Uint8Array(W),Te=new DataView(le.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++)R=B[k],Te.setUint32(E,R.data.byteLength),E+=4,le.set(R.data,E),E+=R.data.byteLength}}return le},Xt=function(p,q){var v,k=q||0,_=[];return v=Ze(p,k),_.push(v),_},$t=function(p){var q,v,k=0,_=p.byteLength,B=p.length,R=_+4*B,E=new Uint8Array(R),G=new DataView(E.buffer);for(q=0;q<p.length;q++)v=p[q],G.setUint32(k,v.data.byteLength),k+=4,E.set(v.data,k),k+=v.data.byteLength;return E},Ka={groupNalsIntoFrames:Ge,groupFramesIntoGops:ft,extendFirstKeyFrame:Ie,generateSampleTable:Je,concatenateNalData:$e,generateSampleTableForFrame:Xt,concatenateNalDataForFrame:$t},Ht=[33,16,5,32,164,27],_a=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],st=function(p){var q=[];while(p--)q.push(0);return q},sn=function(p){return Object.keys(p).reduce(function(q,v){return q[v]=new Uint8Array(p[v].reduce(function(k,_){return k.concat(_)},[])),q},{})},Ot,Xn=function(){if(!Ot){var p={96000:[Ht,[227,64],st(154),[56]],88200:[Ht,[231],st(170),[56]],64000:[Ht,[248,192],st(240),[56]],48000:[Ht,[255,192],st(268),[55,148,128],st(54),[112]],44100:[Ht,[255,192],st(268),[55,163,128],st(84),[112]],32000:[Ht,[255,192],st(268),[55,234],st(226),[112]],24000:[Ht,[255,192],st(268),[55,255,128],st(268),[111,112],st(126),[224]],16000:[Ht,[255,192],st(268),[55,255,128],st(268),[111,255],st(269),[223,108],st(195),[1,192]],12000:[_a,st(268),[3,127,248],st(268),[6,255,240],st(268),[13,255,224],st(268),[27,253,128],st(259),[56]],11025:[_a,st(268),[3,127,248],st(268),[6,255,240],st(268),[13,255,224],st(268),[27,255,192],st(268),[55,175,128],st(108),[112]],8000:[_a,st(268),[3,121,16],st(47),[7]]};Ot=sn(p)}return Ot},kn=90000,Dn,Da,Fa,Ra,Na,ns,ve;Dn=function(p){return p*kn},Da=function(p,q){return p*q},Fa=function(p){return p/kn},Ra=function(p,q){return p/q},Na=function(p,q){return Dn(Ra(p,q))},ns=function(p,q){return Da(Fa(p),q)},ve=function(p,q,v){return Fa(v?p:p-q)};var Re={ONE_SECOND_IN_TS:kn,secondsToVideoTs:Dn,secondsToAudioTs:Da,videoTsToSeconds:Fa,audioTsToSeconds:Ra,audioTsToVideoTs:Na,videoTsToAudioTs:ns,metadataTsToSeconds:ve},et=Xn,_t=Re,Oa=function(p){var q,v,k=0;for(q=0;q<p.length;q++)v=p[q],k+=v.data.byteLength;return k},ia=function(p,q,v,k){var _,B=0,R=0,E=0,G=0,X,W,le;if(!q.length)return;if(_=_t.audioTsToVideoTs(p.baseMediaDecodeTime,p.samplerate),B=Math.ceil(_t.ONE_SECOND_IN_TS/(p.samplerate/1024)),v&&k)R=_-Math.max(v,k),E=Math.floor(R/B),G=E*B;if(E<1||G>_t.ONE_SECOND_IN_TS/2)return;if(X=et()[p.samplerate],!X)X=q[0].data;for(W=0;W<E;W++)le=q[0],q.splice(0,0,{data:X,dts:le.dts-B,pts:le.pts-B});return p.baseMediaDecodeTime-=Math.floor(_t.videoTsToAudioTs(G,p.samplerate)),G},ln=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})},Pa=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},Vs=function(p){var q,v,k=0,_=new Uint8Array(Oa(p));for(q=0;q<p.length;q++)v=p[q],_.set(v.data,k),k+=v.data.byteLength;return _},ze={prefixWithSilence:ia,trimAdtsFramesByEarliestDts:ln,generateSampleTable:Pa,concatenateFrameData:Vs},Xe=Re.ONE_SECOND_IN_TS,Ae=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)}},Ce=function(p){delete p.minSegmentDts,delete p.maxSegmentDts,delete p.minSegmentPts,delete p.maxSegmentPts},Ue=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/Xe,v*=k,v=Math.floor(v);return v},dt={clearDtsInfo:Ce,calculateTrackBaseMediaDecodeTime:Ue,collectDtsInfo:Ae},ba=4,ji=128,Hr=function(p){var q=0,v={payloadType:-1,payloadSize:0},k=0,_=0;while(q<p.byteLength){if(p[q]===ji)break;while(p[q]===255)k+=255,q++;k+=p[q++];while(p[q]===255)_+=255,q++;if(_+=p[q++],!v.payload&&k===ba){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},xr=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)},cf=function(p,q){var v=[],k,_,B,R;if(!(q[0]&64))return v;_=q[0]&31;for(k=0;k<_;k++)if(B=k*3,R={type:q[B+2]&3,pts:p},q[B+2]&4)R.ccData=q[B+3]<<8|q[B+4],v.push(R);return v},Dr=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 R=0;for(k=0;k<_;R++,k++){if(R===v[0])R++,v.shift();B[k]=p[R]}return B},z1={parseSei:Hr,parseUserData:xr,parseCaptionPackets:cf,discardEmulationPreventionBytes:Dr,USER_DATA_REGISTERED_ITU_T_T35:ba},il=a,w0=z1,fn=function(p){if(p=p||{},fn.prototype.init.call(this),this.parse708captions_=typeof p.parse708captions==="boolean"?p.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new ta(0,0),new ta(0,1),new ta(1,0),new ta(1,1)],this.parse708captions_)this.cc708Stream_=new yt({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"))};fn.prototype=new il,fn.prototype.push=function(p){var q,v,k;if(p.nalUnitType!=="sei_rbsp")return;if(q=w0.parseSei(p.escapedRBSP),!q.payload)return;if(q.payloadType!==w0.USER_DATA_REGISTERED_ITU_T_T35)return;if(v=w0.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=w0.parseCaptionPackets(p.pts,v),this.captionPackets_=this.captionPackets_.concat(k),this.latestDts_!==p.dts)this.numSameDts_=0;this.numSameDts_++,this.latestDts_=p.dts},fn.prototype.flushCCStreams=function(p){this.ccStreams_.forEach(function(q){return p==="flush"?q.flush():q.partialFlush()},this)},fn.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)},fn.prototype.flush=function(){return this.flushStream("flush")},fn.prototype.partialFlush=function(){return this.flushStream("partialFlush")},fn.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(p){p.reset()})},fn.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)},fn.prototype.setsChannel1Active=function(p){return(p.ccData&30720)===4096},fn.prototype.setsChannel2Active=function(p){return(p.ccData&30720)===6144},fn.prototype.setsTextOrXDSActive=function(p){return(p.ccData&28928)===256||(p.ccData&30974)===4138||(p.ccData&30974)===6186},fn.prototype.dispatchCea708Packet=function(p){if(this.parse708captions_)this.cc708Stream_.push(p)};var d0={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},gu=function(p){var q=d0[p]||p;if(p&4096&&p===q)return"";return String.fromCharCode(q)},j0=function(p){return 32<=p&&p<=127||160<=p&&p<=255},Ss=function(p){this.windowNum=p,this.reset()};Ss.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},Ss.prototype.getText=function(){return this.rows.join(`
205
- `)},Ss.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},Ss.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--},Ss.prototype.isEmpty=function(){if(this.rows.length===0)return!0;else if(this.rows.length===1)return this.rows[0]==="";return!1},Ss.prototype.addText=function(p){this.rows[this.rowIdx]+=p},Ss.prototype.backspace=function(){if(!this.isEmpty()){var p=this.rows[this.rowIdx];this.rows[this.rowIdx]=p.substr(0,p.length-1)}};var ll=function(p,q,v){if(this.serviceNum=p,this.text="",this.currentWindow=new Ss(-1),this.windows=[],this.stream=v,typeof q==="string")this.createTextDecoder(q)};ll.prototype.init=function(p,q){this.startPts=p;for(var v=0;v<8;v++)if(this.windows[v]=new Ss(v),typeof q==="function")this.windows[v].beforeRowOverflow=q},ll.prototype.setCurrentWindow=function(p){this.currentWindow=this.windows[p]},ll.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 yt=function(p){p=p||{},yt.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)}}};yt.prototype=new il,yt.prototype.new708Packet=function(){if(this.current708Packet!==null)this.push708Packet();this.current708Packet={data:[],ptsVals:[]}},yt.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)},yt.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}},yt.prototype.pushServiceBlock=function(p,q,v){var k,_=q,B=this.current708Packet.data,R=this.services[p];if(!R)R=this.initService(p,_);for(;_<q+v&&_<B.length;_++)if(k=B[_],j0(k))_=this.handleText(_,R);else if(k===24)_=this.multiByteCharacter(_,R);else if(k===16)_=this.extendedCommands(_,R);else if(128<=k&&k<=135)_=this.setCurrentWindow(_,R);else if(152<=k&&k<=159)_=this.defineWindow(_,R);else if(k===136)_=this.clearWindows(_,R);else if(k===140)_=this.deleteWindows(_,R);else if(k===137)_=this.displayWindows(_,R);else if(k===138)_=this.hideWindows(_,R);else if(k===139)_=this.toggleWindows(_,R);else if(k===151)_=this.setWindowAttributes(_,R);else if(k===144)_=this.setPenAttributes(_,R);else if(k===145)_=this.setPenColor(_,R);else if(k===146)_=this.setPenLocation(_,R);else if(k===143)R=this.reset(_,R);else if(k===8)R.currentWindow.backspace();else if(k===12)R.currentWindow.clearText();else if(k===13)R.currentWindow.pendingNewLine=!0;else if(k===14)R.currentWindow.clearText();else if(k===141)_++},yt.prototype.extendedCommands=function(p,q){var v=this.current708Packet.data,k=v[++p];if(j0(k))p=this.handleText(p,q,{isExtended:!0});return p},yt.prototype.getPts=function(p){return this.current708Packet.ptsVals[Math.floor(p/2)]},yt.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 ll(p,_,v),this.services[p].init(this.getPts(q),function(B){v.flushDisplayed(B,v.services[p])}),this.services[p]},yt.prototype.handleText=function(p,q,v){var k=v&&v.isExtended,_=v&&v.isMultiByte,B=this.current708Packet.data,R=k?4096:0,E=B[p],G=B[p+1],X=q.currentWindow,W,le;function Te(ue){return ue.map((Ke)=>{return("0"+(Ke&255).toString(16)).slice(-2)}).join("")}if(_)le=[E,G],p++;else le=[E];if(q.textDecoder_&&!k)W=q.textDecoder_.decode(new Uint8Array(le));else if(_){let ue=Te(le);W=String.fromCharCode(parseInt(ue,16))}else W=gu(R|E);if(X.pendingNewLine&&!X.isEmpty())X.newLine(this.getPts(p));return X.pendingNewLine=!1,X.addText(W),p},yt.prototype.multiByteCharacter=function(p,q){var v=this.current708Packet.data,k=v[p+1],_=v[p+2];if(j0(k)&&j0(_))p=this.handleText(++p,q,{isMultiByte:!0});return p},yt.prototype.setCurrentWindow=function(p,q){var v=this.current708Packet.data,k=v[p],_=k&7;return q.setCurrentWindow(_),p},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.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},yt.prototype.reset=function(p,q){var v=this.getPts(p);return this.flushDisplayed(v,q),this.initService(q.serviceNum,p)};var Hi={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},xi=function(p){if(p===null)return"";return p=Hi[p]||p,String.fromCharCode(p)},fl=14,hf=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Cs=function(){var p=[],q=fl+1;while(q--)p.push({text:"",indent:0,offset:0});return p},ta=function(p,q){ta.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,R,E;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,R=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_=Cs();else if(k===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Cs();else if(k===this.RESUME_DIRECT_CAPTIONING_){if(this.mode_!=="paintOn")this.flushDisplayed(v.pts),this.displayed_=Cs();this.mode_="paintOn",this.startPts_=v.pts}else if(this.isSpecialCharacter(B,R))B=(B&3)<<8,E=xi(B|R),this[this.mode_](v.pts,E),this.column_++;else if(this.isExtCharacter(B,R)){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,E=xi(B|R),this[this.mode_](v.pts,E),this.column_++}else if(this.isMidRowCode(B,R)){if(this.clearFormatting(v.pts),this[this.mode_](v.pts," "),this.column_++,(R&14)===14)this.addFormatting(v.pts,["i"]);if((R&1)===1)this.addFormatting(v.pts,["u"])}else if(this.isOffsetControlCode(B,R)){let X=R&3;this.nonDisplayed_[this.row_].offset=X,this.column_+=X}else if(this.isPAC(B,R)){var G=hf.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(R&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(R)){if((R&14)===14)this.addFormatting(v.pts,["i"])}}else if(this.isNormalChar(B)){if(R===0)R=null;E=xi(B),E+=xi(R),this[this.mode_](v.pts,E),this.column_+=E.length}}};ta.prototype=new il,ta.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_})},ta.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Cs(),this.nonDisplayed_=Cs(),this.lastControlCode_=null,this.column_=0,this.row_=fl,this.rollUpRows_=2,this.formatting_=[]},ta.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},ta.prototype.isSpecialCharacter=function(p,q){return p===this.EXT_&&q>=48&&q<=63},ta.prototype.isExtCharacter=function(p,q){return(p===this.EXT_+1||p===this.EXT_+2)&&q>=32&&q<=63},ta.prototype.isMidRowCode=function(p,q){return p===this.EXT_&&q>=32&&q<=47},ta.prototype.isOffsetControlCode=function(p,q){return p===this.OFFSET_&&q>=33&&q<=35},ta.prototype.isPAC=function(p,q){return p>=this.BASE_&&p<this.BASE_+8&&q>=64&&q<=127},ta.prototype.isColorPAC=function(p){return p>=64&&p<=79||p>=96&&p<=127},ta.prototype.isNormalChar=function(p){return p>=32&&p<=127},ta.prototype.setRollUp=function(p,q){if(this.mode_!=="rollUp")this.row_=fl,this.mode_="rollUp",this.flushDisplayed(p),this.nonDisplayed_=Cs(),this.displayed_=Cs();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},ta.prototype.addFormatting=function(p,q){this.formatting_=this.formatting_.concat(q);var v=q.reduce(function(k,_){return k+"<"+_+">"},"");this[this.mode_](p,v)},ta.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)},ta.prototype.popOn=function(p,q){var v=this.nonDisplayed_[this.row_].text;v+=q,this.nonDisplayed_[this.row_].text=v},ta.prototype.rollUp=function(p,q){var v=this.displayed_[this.row_].text;v+=q,this.displayed_[this.row_].text=v},ta.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<fl+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}},ta.prototype.paintOn=function(p,q){var v=this.displayed_[this.row_].text;v+=q,this.displayed_[this.row_].text=v};var E1={CaptionStream:fn,Cea608Stream:ta,Cea708Stream:yt},uf={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},I1=a,U1=8589934592,Di=4294967296,Rr="shared",Nr=function(p,q){var v=1;if(p>q)v=-1;while(Math.abs(q-p)>Di)p+=v*U1;return p},Ys=function(p){var q,v;Ys.prototype.init.call(this),this.type_=p||Rr,this.push=function(k){if(k.type==="metadata"){this.trigger("data",k);return}if(this.type_!==Rr&&k.type!==this.type_)return;if(v===void 0)v=k.dts;k.dts=Nr(k.dts,v),k.pts=Nr(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")}};Ys.prototype=new I1;var Rn={TimestampRolloverStream:Ys,handleRollover:Nr},zr=(p,q,v)=>{if(!p)return-1;var k=v;for(;k<p.length;k++)if(p[k]===q)return k;return-1},ma={typedArrayIndexOf:zr},rl=ma.typedArrayIndexOf,ol={Iso88591:0,Utf16:1,Utf16be:2,Utf8:3},G1=function(p,q,v){var k,_="";for(k=q;k<v;k++)_+="%"+("00"+p[k].toString(16)).slice(-2);return _},cl=function(p,q,v){return decodeURIComponent(G1(p,q,v))},mf=function(p,q,v){return unescape(G1(p,q,v))},q0=function(p){return p[0]<<21|p[1]<<14|p[2]<<7|p[3]},v0={APIC:function(p){var q=1,v,k,_="-->";if(p.data[0]!==ol.Utf8)return;if(v=rl(p.data,0,q),v<0)return;if(p.mimeType=mf(p.data,q,v),q=v+1,p.pictureType=p.data[q],q++,k=rl(p.data,0,q),k<0)return;if(p.description=cl(p.data,q,k),q=k+1,p.mimeType===_)p.url=mf(p.data,q,p.data.length);else p.pictureData=p.data.subarray(q,p.data.length)},"T*":function(p){if(p.data[0]!==ol.Utf8)return;p.value=cl(p.data,1,p.data.length).replace(/\0*$/,""),p.values=p.value.split("\x00")},TXXX:function(p){var q;if(p.data[0]!==ol.Utf8)return;if(q=rl(p.data,0,1),q===-1)return;p.description=cl(p.data,1,q),p.value=cl(p.data,q+1,p.data.length).replace(/\0*$/,""),p.data=p.value},"W*":function(p){p.url=mf(p.data,0,p.data.length).replace(/\0.*$/,"")},WXXX:function(p){var q;if(p.data[0]!==ol.Utf8)return;if(q=rl(p.data,0,1),q===-1)return;p.description=cl(p.data,1,q),p.url=mf(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=mf(p.data,0,q);break}p.privateData=p.data.subarray(q+1),p.data=p.privateData}},X1=function(p){var q,v,k=10,_=0,B=[];if(p.length<10||p[0]!==73||p[1]!==68||p[2]!==51)return;_=q0(p.subarray(6,10)),_+=10;var R=p[5]&64;if(R)k+=4,k+=q0(p.subarray(10,14)),_-=q0(p.subarray(16,20));do{if(q=q0(p.subarray(k+4,k+8)),q<1)break;v=String.fromCharCode(p[k],p[k+1],p[k+2],p[k+3]);var E={id:v,data:p.subarray(k+10,k+q+10)};if(E.key=E.id,v0[E.id])v0[E.id](E);else if(E.id[0]==="T")v0["T*"](E);else if(E.id[0]==="W")v0["W*"](E);B.push(E),k+=10,k+=q}while(k<_);return B},rn={parseId3Frames:X1,parseSyncSafeInteger:q0,frameParsers:v0},wa=a,Er=uf,ss=rn,k0;k0=function(p){var q={descriptor:p&&p.descriptor},v=0,k=[],_=0,B;if(k0.prototype.init.call(this),this.dispatchType=Er.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(R){var E,G,X,W,le,Te;if(R.type!=="timed-metadata")return;if(R.dataAlignmentIndicator)_=0,k.length=0;if(k.length===0&&(R.data.length<10||R.data[0]!==73||R.data[1]!==68||R.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(k.push(R),_+=R.data.byteLength,k.length===1)v=ss.parseSyncSafeInteger(R.data.subarray(6,10)),v+=10;if(_<v)return;E={data:new Uint8Array(v),frames:[],pts:k[0].pts,dts:k[0].dts};for(le=0;le<v;)E.data.set(k[0].data.subarray(0,v-le),le),le+=k[0].data.byteLength,_-=k[0].data.byteLength,k.shift();if(G=10,E.data[5]&64)G+=4,G+=ss.parseSyncSafeInteger(E.data.subarray(10,14)),v-=ss.parseSyncSafeInteger(E.data.subarray(16,20));do{if(X=ss.parseSyncSafeInteger(E.data.subarray(G+4,G+8)),X<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(Te=String.fromCharCode(E.data[G],E.data[G+1],E.data[G+2],E.data[G+3]),W={id:Te,data:E.data.subarray(G+10,G+X+10)},W.key=W.id,ss.frameParsers[W.id])ss.frameParsers[W.id](W);else if(W.id[0]==="T")ss.frameParsers["T*"](W);else if(W.id[0]==="W")ss.frameParsers["W*"](W);if(W.owner==="com.apple.streaming.transportStreamTimestamp"){var ue=W.data,Ke=(ue[3]&1)<<30|ue[4]<<22|ue[5]<<14|ue[6]<<6|ue[7]>>>2;if(Ke*=4,Ke+=ue[7]&3,W.timeStamp=Ke,E.pts===void 0&&E.dts===void 0)E.pts=W.timeStamp,E.dts=W.timeStamp;this.trigger("timestamp",W)}E.frames.push(W),G+=10,G+=X}while(G<v);this.trigger("data",E)}},k0.prototype=new wa;var K1=k0,_s=a,hl=E1,Kn=uf,L1=Rn.TimestampRolloverStream,gf,ul,pf,A0=188,Ir=71;gf=function(){var p=new Uint8Array(A0),q=0;gf.prototype.init.call(this),this.push=function(v){var k=0,_=A0,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]===Ir&&B[_]===Ir){this.trigger("data",B.subarray(k,_)),k+=A0,_+=A0;continue}k++,_++}if(k<B.byteLength)p.set(B.subarray(k),0),q=B.byteLength-k},this.flush=function(){if(q===A0&&p[0]===Ir)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")}},gf.prototype=new _s,ul=function(){var p,q,v,k;ul.prototype.init.call(this),k=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,p=function(_,B){var R=0;if(B.payloadUnitStartIndicator)R+=_[R]+1;if(B.type==="pat")q(_.subarray(R),B);else v(_.subarray(R),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 R,E,G,X;if(!(_[5]&1))return;k.programMapTable={video:null,audio:null,"timed-metadata":{}},R=(_[1]&15)<<8|_[2],E=3+R-4,G=(_[10]&15)<<8|_[11],X=12+G;while(X<E){var W=_[X],le=(_[X+1]&31)<<8|_[X+2];if(W===Kn.H264_STREAM_TYPE&&k.programMapTable.video===null)k.programMapTable.video=le;else if(W===Kn.ADTS_STREAM_TYPE&&k.programMapTable.audio===null)k.programMapTable.audio=le;else if(W===Kn.METADATA_STREAM_TYPE)k.programMapTable["timed-metadata"][le]=W;X+=((_[X+3]&15)<<8|_[X+4])+5}B.programMapTable=k.programMapTable},this.push=function(_){var B={},R=4;if(B.payloadUnitStartIndicator=!!(_[1]&64),B.pid=_[1]&31,B.pid<<=8,B.pid|=_[2],(_[3]&48)>>>4>1)R+=_[R]+1;if(B.pid===0)B.type="pat",p(_.subarray(R),B),this.trigger("data",B);else if(B.pid===this.pmtPid){B.type="pmt",p(_.subarray(R),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([_,R,B]);else this.processPes_(_,R,B)},this.processPes_=function(_,B,R){if(R.pid===this.programMapTable.video)R.streamType=Kn.H264_STREAM_TYPE;else if(R.pid===this.programMapTable.audio)R.streamType=Kn.ADTS_STREAM_TYPE;else R.streamType=this.programMapTable["timed-metadata"][R.pid];R.type="pes",R.data=_.subarray(B),this.trigger("data",R)}},ul.prototype=new _s,ul.STREAM_TYPES={h264:27,adts:15},pf=function(){var p=this,q=!1,v={data:[],size:0},k={data:[],size:0},_={data:[],size:0},B,R=function(G,X){var W;let le=G[0]<<16|G[1]<<8|G[2];if(X.data=new Uint8Array,le!==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])},E=function(G,X,W){var le=new Uint8Array(G.size),Te={type:X},ue=0,Ke=0,tt=!1,Ea;if(!G.data.length||G.size<9)return;Te.trackId=G.data[0].pid;for(ue=0;ue<G.data.length;ue++)Ea=G.data[ue],le.set(Ea.data,Ke),Ke+=Ea.data.byteLength;if(R(le,Te),tt=X==="video"||Te.packetLength<=G.size,W||tt)G.size=0,G.data.length=0;if(tt)p.trigger("data",Te)};pf.prototype.init.call(this),this.push=function(G){({pat:function(){},pes:function(){var X,W;switch(G.streamType){case Kn.H264_STREAM_TYPE:X=v,W="video";break;case Kn.ADTS_STREAM_TYPE:X=k,W="audio";break;case Kn.METADATA_STREAM_TYPE:X=_,W="timed-metadata";break;default:return}if(G.payloadUnitStartIndicator)E(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(){E(v,"video"),E(k,"audio"),E(_,"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")}},pf.prototype=new _s;var V1={PAT_PID:0,MP2T_PACKET_LENGTH:A0,TransportPacketStream:gf,TransportParseStream:ul,ElementaryStream:pf,TimestampRolloverStream:L1,CaptionStream:hl.CaptionStream,Cea608Stream:hl.Cea608Stream,Cea708Stream:hl.Cea708Stream,MetadataStream:K1};for(var bf in Kn)if(Kn.hasOwnProperty(bf))V1[bf]=Kn[bf];var pu=V1,x5=a,bu=Re.ONE_SECOND_IN_TS,wf,Y1=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350];wf=function(p){var q,v=0;wf.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,R,E,G,X;if(!p)v=0;if(k.type!=="audio")return;if(q&&q.length)E=q,q=new Uint8Array(E.byteLength+k.data.byteLength),q.set(E),q.set(k.data,E.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(R=(~q[_+1]&1)*2,B=(q[_+3]&3)<<11|q[_+4]<<3|(q[_+5]&224)>>5,G=((q[_+6]&3)+1)*1024,X=G*bu/Y1[(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:Y1[(q[_+2]&60)>>>2],samplingfrequencyindex:(q[_+2]&60)>>>2,samplesize:16,data:q.subarray(_+7+R,_+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")}},wf.prototype=new x5;var J1=wf,Q1;Q1=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),R=Math.min(4,q);if(R===0)throw Error("no bytes available");B.set(p.subarray(_,_+R)),v=new DataView(B.buffer).getUint32(0),k=R*8,q-=R},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,_),R=v>>>32-B;if(k-=B,k>0)v<<=B;else if(q>0)this.loadWord();if(B=_-B,B>0)return R<<B|this.readBits(B);return R},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 wu=Q1,Z1=a,du=wu,df,jf,$1;jf=function(){var p=0,q,v;jf.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")}},jf.prototype=new Z1,$1={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},df=function(){var p=new jf,q,v,k,_,B,R,E;df.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=R(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()},E=function(G,X){var W=8,le=8,Te,ue;for(Te=0;Te<G;Te++){if(le!==0)ue=X.readExpGolomb(),le=(W+ue+256)%256;W=le===0?W:le}},B=function(G){var X=G.byteLength,W=[],le=1,Te,ue;while(le<X-2)if(G[le]===0&&G[le+1]===0&&G[le+2]===3)W.push(le+2),le+=2;else le++;if(W.length===0)return G;Te=X-W.length,ue=new Uint8Array(Te);var Ke=0;for(le=0;le<Te;Ke++,le++){if(Ke===W[0])Ke++,W.shift();ue[le]=G[Ke]}return ue},R=function(G){var X=0,W=0,le=0,Te=0,ue,Ke,tt,Ea,Sn,Ii,Al,yl,Sl,Cl,Uf,Kt=[1,1],ut,Yn;if(ue=new du(G),Ke=ue.readUnsignedByte(),Ea=ue.readUnsignedByte(),tt=ue.readUnsignedByte(),ue.skipUnsignedExpGolomb(),$1[Ke]){if(Sn=ue.readUnsignedExpGolomb(),Sn===3)ue.skipBits(1);if(ue.skipUnsignedExpGolomb(),ue.skipUnsignedExpGolomb(),ue.skipBits(1),ue.readBoolean()){Uf=Sn!==3?8:12;for(Yn=0;Yn<Uf;Yn++)if(ue.readBoolean())if(Yn<6)E(16,ue);else E(64,ue)}}if(ue.skipUnsignedExpGolomb(),Ii=ue.readUnsignedExpGolomb(),Ii===0)ue.readUnsignedExpGolomb();else if(Ii===1){ue.skipBits(1),ue.skipExpGolomb(),ue.skipExpGolomb(),Al=ue.readUnsignedExpGolomb();for(Yn=0;Yn<Al;Yn++)ue.skipExpGolomb()}if(ue.skipUnsignedExpGolomb(),ue.skipBits(1),yl=ue.readUnsignedExpGolomb(),Sl=ue.readUnsignedExpGolomb(),Cl=ue.readBits(1),Cl===0)ue.skipBits(1);if(ue.skipBits(1),ue.readBoolean())X=ue.readUnsignedExpGolomb(),W=ue.readUnsignedExpGolomb(),le=ue.readUnsignedExpGolomb(),Te=ue.readUnsignedExpGolomb();if(ue.readBoolean()){if(ue.readBoolean()){switch(ut=ue.readUnsignedByte(),ut){case 1:Kt=[1,1];break;case 2:Kt=[12,11];break;case 3:Kt=[10,11];break;case 4:Kt=[16,11];break;case 5:Kt=[40,33];break;case 6:Kt=[24,11];break;case 7:Kt=[20,11];break;case 8:Kt=[32,11];break;case 9:Kt=[80,33];break;case 10:Kt=[18,11];break;case 11:Kt=[15,11];break;case 12:Kt=[64,33];break;case 13:Kt=[160,99];break;case 14:Kt=[4,3];break;case 15:Kt=[3,2];break;case 16:Kt=[2,1];break;case 255:{Kt=[ue.readUnsignedByte()<<8|ue.readUnsignedByte(),ue.readUnsignedByte()<<8|ue.readUnsignedByte()];break}}if(Kt)Kt[0]/Kt[1]}}return{profileIdc:Ke,levelIdc:tt,profileCompatibility:Ea,width:(yl+1)*16-X*2-W*2,height:(2-Cl)*(Sl+1)*16-le*2-Te*2,sarRatio:Kt}}},df.prototype=new Z1;var ml={H264Stream:df,NalByteStream:jf},ju=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],qf=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},vf=function(p,q){if(p.length-q<10||p[q]!==73||p[q+1]!==68||p[q+2]!==51)return q;return q+=qf(p,q),vf(p,q)},qu=function(p){var q=vf(p,0);return p.length>=q+2&&(p[q]&255)===255&&(p[q+1]&240)===240&&(p[q+1]&22)===16},Ur=function(p){return p[0]<<21|p[1]<<14|p[2]<<7|p[3]},D5=function(p,q,v){var k,_="";for(k=q;k<v;k++)_+="%"+("00"+p[k].toString(16)).slice(-2);return _},vu=function(p,q,v){return unescape(D5(p,q,v))},ku=function(p,q){var v=(p[q+5]&224)>>5,k=p[q+4]<<3,_=p[q+3]&6144;return _|k|v},Au=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},yu=function(p){var q=0;while(q+5<p.length){if(p[q]!==255||(p[q+1]&246)!==240){q++;continue}return ju[(p[q+2]&60)>>>2]}return null},Su=function(p){var q,v,k,_;if(q=10,p[5]&64)q+=4,q+=Ur(p.subarray(10,14));do{if(v=Ur(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 R=vu(k,0,B);if(R==="com.apple.streaming.transportStreamTimestamp"){var E=k.subarray(B+1),G=(E[3]&1)<<30|E[4]<<22|E[5]<<14|E[6]<<6|E[7]>>>2;return G*=4,G+=E[7]&3,G}break}}q+=10,q+=v}while(q<p.byteLength);return null},kf={isLikelyAacData:qu,parseId3TagSize:qf,parseAdtsSize:ku,parseType:Au,parseSampleRate:yu,parseAacTimestamp:Su},Cu=a,W1=kf,gl;gl=function(){var p=new Uint8Array,q=0;gl.prototype.init.call(this),this.setTimestamp=function(v){q=v},this.push=function(v){var k=0,_=0,B,R,E,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=W1.parseId3TagSize(p,_),_+k>p.length)break;R={type:"timed-metadata",data:p.subarray(_,_+k)},this.trigger("data",R),_+=k;continue}else if((p[_]&255)===255&&(p[_+1]&240)===240){if(p.length-_<7)break;if(k=W1.parseAdtsSize(p,_),_+k>p.length)break;E={type:"audio",data:p.subarray(_,_+k),pts:q,dts:q},this.trigger("data",E),_+=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")}},gl.prototype=new Cu;var _u=gl,Fu=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Ou=Fu,P1=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Bu=P1,Af=a,yf=Oe,Sf=Ka,Cf=ze,An=dt,Fs=pu,y0=Re,ec=J1,Tu=ml.H264Stream,tc=_u,Mu=kf.isLikelyAacData,Hu=Re.ONE_SECOND_IN_TS,qi=Ou,pl=Bu,bl,Ri,_f,Ni,R5=function(p,q){q.stream=p,this.trigger("log",q)},La=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",R5.bind(p,_))}},ac=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},Gr=function(p,q,v,k,_,B){var R=v-q,E=k-q,G=_-v;return{start:{dts:p,pts:p+R},end:{dts:p+E,pts:p+G},prependedContentDuration:B,baseMediaDecodeTime:p}};Ri=function(p,q){var v=[],k,_=0,B=0,R=1/0;q=q||{},k=q.firstSequenceNumber||0,Ri.prototype.init.call(this),this.push=function(E){if(An.collectDtsInfo(p,E),p)qi.forEach(function(G){p[G]=E[G]});v.push(E)},this.setEarliestDts=function(E){_=E},this.setVideoBaseMediaDecodeTime=function(E){R=E},this.setAudioAppendStart=function(E){B=E},this.flush=function(){var E,G,X,W,le,Te,ue;if(v.length===0){this.trigger("done","AudioSegmentStream");return}if(E=Cf.trimAdtsFramesByEarliestDts(v,p,_),p.baseMediaDecodeTime=An.calculateTrackBaseMediaDecodeTime(p,q.keepOriginalTimestamps),ue=Cf.prefixWithSilence(p,E,B,R),p.samples=Cf.generateSampleTable(E),X=yf.mdat(Cf.concatenateFrameData(E)),v=[],G=yf.moof(k,[p]),W=new Uint8Array(G.byteLength+X.byteLength),k++,W.set(G),W.set(X,G.byteLength),An.clearDtsInfo(p),le=Math.ceil(Hu*1024/p.samplerate),E.length)Te=E.length*le,this.trigger("segmentTimingInfo",Gr(y0.audioTsToVideoTs(p.baseMediaDecodeTime,p.samplerate),E[0].dts,E[0].pts,E[0].dts+Te,E[0].pts+Te,ue||0)),this.trigger("timingInfo",{start:E[0].pts,end:E[0].pts+Te});this.trigger("data",{track:p,boxes:W}),this.trigger("done","AudioSegmentStream")},this.reset=function(){An.clearDtsInfo(p),v=[],this.trigger("reset")}},Ri.prototype=new Af,bl=function(p,q){var v,k=[],_=[],B,R;q=q||{},v=q.firstSequenceNumber||0,bl.prototype.init.call(this),delete p.minPTS,this.gopCache_=[],this.push=function(E){if(An.collectDtsInfo(p,E),E.nalUnitType==="seq_parameter_set_rbsp"&&!B)B=E.config,p.sps=[E.data],pl.forEach(function(G){p[G]=B[G]},this);if(E.nalUnitType==="pic_parameter_set_rbsp"&&!R)R=E.data,p.pps=[E.data];k.push(E)},this.flush=function(){var E,G,X,W,le,Te,ue=0,Ke,tt;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(E=Sf.groupNalsIntoFrames(k),X=Sf.groupFramesIntoGops(E),!X[0][0].keyFrame)if(G=this.getGopForFusion_(k[0],p),G)ue=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=Sf.extendFirstKeyFrame(X);if(_.length){var Ea;if(q.alignGopsAtEnd)Ea=this.alignGopsAtEnd_(X);else Ea=this.alignGopsAtStart_(X);if(!Ea){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}An.clearDtsInfo(p),X=Ea}An.collectDtsInfo(p,X),p.samples=Sf.generateSampleTable(X),le=yf.mdat(Sf.concatenateNalData(X)),p.baseMediaDecodeTime=An.calculateTrackBaseMediaDecodeTime(p,q.keepOriginalTimestamps),this.trigger("processedGopsInfo",X.map(function(Sn){return{pts:Sn.pts,dts:Sn.dts,byteLength:Sn.byteLength}})),Ke=X[0],tt=X[X.length-1],this.trigger("segmentTimingInfo",Gr(p.baseMediaDecodeTime,Ke.dts,Ke.pts,tt.dts+tt.duration,tt.pts+tt.duration,ue)),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=yf.moof(v,[p]),Te=new Uint8Array(W.byteLength+le.byteLength),v++,Te.set(W),Te.set(le,W.byteLength),this.trigger("data",{track:p,boxes:Te}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),k=[],this.gopCache_.length=0,_.length=0,this.trigger("reset")},this.resetStream_=function(){An.clearDtsInfo(p),B=void 0,R=void 0},this.getGopForFusion_=function(E){var G=45000,X=1e4,W=1/0,le,Te,ue,Ke,tt;for(tt=0;tt<this.gopCache_.length;tt++){if(Ke=this.gopCache_[tt],ue=Ke.gop,!(p.pps&&ac(p.pps[0],Ke.pps[0]))||!(p.sps&&ac(p.sps[0],Ke.sps[0])))continue;if(ue.dts<p.timelineStartInfo.dts)continue;if(le=E.dts-ue.dts-ue.duration,le>=-X&&le<=G){if(!Te||W>le)Te=Ke,W=le}}if(Te)return Te.gop;return null},this.alignGopsAtStart_=function(E){var G,X,W,le,Te,ue,Ke,tt;Te=E.byteLength,ue=E.nalCount,Ke=E.duration,G=X=0;while(G<_.length&&X<E.length){if(W=_[G],le=E[X],W.pts===le.pts)break;if(le.pts>W.pts){G++;continue}X++,Te-=le.byteLength,ue-=le.nalCount,Ke-=le.duration}if(X===0)return E;if(X===E.length)return null;return tt=E.slice(X),tt.byteLength=Te,tt.duration=Ke,tt.nalCount=ue,tt.pts=tt[0].pts,tt.dts=tt[0].dts,tt},this.alignGopsAtEnd_=function(E){var G,X,W,le,Te,ue;G=_.length-1,X=E.length-1,Te=null,ue=!1;while(G>=0&&X>=0){if(W=_[G],le=E[X],W.pts===le.pts){ue=!0;break}if(W.pts>le.pts){G--;continue}if(G===_.length-1)Te=X;X--}if(!ue&&Te===null)return null;var Ke;if(ue)Ke=X;else Ke=Te;if(Ke===0)return E;var tt=E.slice(Ke),Ea=tt.reduce(function(Sn,Ii){return Sn.byteLength+=Ii.byteLength,Sn.duration+=Ii.duration,Sn.nalCount+=Ii.nalCount,Sn},{byteLength:0,duration:0,nalCount:0});return tt.byteLength=Ea.byteLength,tt.duration=Ea.duration,tt.nalCount=Ea.nalCount,tt.pts=tt[0].pts,tt.dts=tt[0].dts,tt},this.alignGopsWith=function(E){_=E}},bl.prototype=new Af,Ni=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,Ni.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)}},Ni.prototype=new Af,Ni.prototype.flush=function(p){var q=0,v={captions:[],captionStreams:{},metadata:[],info:{}},k,_,B,R=0,E;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)R=this.videoTrack.timelineStartInfo.pts,pl.forEach(function(G){v.info[G]=this.videoTrack[G]},this);else if(this.audioTrack)R=this.audioTrack.timelineStartInfo.pts,qi.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=yf.initSegment(this.pendingTracks),v.initSegment=new Uint8Array(B.byteLength),v.initSegment.set(B),v.data=new Uint8Array(this.pendingBytes);for(E=0;E<this.pendingBoxes.length;E++)v.data.set(this.pendingBoxes[E],q),q+=this.pendingBoxes[E].byteLength;for(E=0;E<this.pendingCaptions.length;E++)k=this.pendingCaptions[E],k.startTime=y0.metadataTsToSeconds(k.startPts,R,this.keepOriginalTimestamps),k.endTime=y0.metadataTsToSeconds(k.endPts,R,this.keepOriginalTimestamps),v.captionStreams[k.stream]=!0,v.captions.push(k);for(E=0;E<this.pendingMetadata.length;E++)_=this.pendingMetadata[E],_.cueTime=y0.metadataTsToSeconds(_.pts,R,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(E=0;E<v.captions.length;E++)k=v.captions[E],this.trigger("caption",k);for(E=0;E<v.metadata.length;E++)_=v.metadata[E],this.trigger("id3Frame",_)}if(this.emittedTracks>=this.numberOfTracks)this.trigger("done"),this.emittedTracks=0},Ni.prototype.setRemux=function(p){this.remuxTracks=p},_f=function(p){var q=this,v=!0,k,_;_f.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 Fs.MetadataStream,B.aacStream=new tc,B.audioTimestampRolloverStream=new Fs.TimestampRolloverStream("audio"),B.timedMetadataTimestampRolloverStream=new Fs.TimestampRolloverStream("timed-metadata"),B.adtsStream=new ec,B.coalesceStream=new Ni(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(R){B.aacStream.setTimestamp(R.timeStamp)}),B.aacStream.on("data",function(R){if(R.type!=="timed-metadata"&&R.type!=="audio"||B.audioSegmentStream)return;_=_||{timelineStartInfo:{baseMediaDecodeTime:q.baseMediaDecodeTime},codec:"adts",type:"audio"},B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new Ri(_,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")),La(this,B)},this.setupTsPipeline=function(){var B={};this.transmuxPipeline_=B,B.type="ts",B.metadataStream=new Fs.MetadataStream,B.packetStream=new Fs.TransportPacketStream,B.parseStream=new Fs.TransportParseStream,B.elementaryStream=new Fs.ElementaryStream,B.timestampRolloverStream=new Fs.TimestampRolloverStream,B.adtsStream=new ec,B.h264Stream=new Tu,B.captionStream=new Fs.CaptionStream(p),B.coalesceStream=new Ni(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(R){var E;if(R.type==="metadata"){E=R.tracks.length;while(E--)if(!k&&R.tracks[E].type==="video")k=R.tracks[E],k.timelineStartInfo.baseMediaDecodeTime=q.baseMediaDecodeTime;else if(!_&&R.tracks[E].type==="audio")_=R.tracks[E],_.timelineStartInfo.baseMediaDecodeTime=q.baseMediaDecodeTime;if(k&&!B.videoSegmentStream)B.coalesceStream.numberOfTracks++,B.videoSegmentStream=new bl(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 Ri(_,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(R){R.dispatchType=B.metadataStream.dispatchType,q.trigger("id3Frame",R)}),B.coalesceStream.on("caption",this.trigger.bind(this,"caption")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),La(this,B)},this.setBaseMediaDecodeTime=function(B){var R=this.transmuxPipeline_;if(!p.keepOriginalTimestamps)this.baseMediaDecodeTime=B;if(_){if(_.timelineStartInfo.dts=void 0,_.timelineStartInfo.pts=void 0,An.clearDtsInfo(_),R.audioTimestampRolloverStream)R.audioTimestampRolloverStream.discontinuity()}if(k){if(R.videoSegmentStream)R.videoSegmentStream.gopCache_=[];k.timelineStartInfo.dts=void 0,k.timelineStartInfo.pts=void 0,An.clearDtsInfo(k),R.captionStream.reset()}if(R.timestampRolloverStream)R.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(B){if(_)this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(B)},this.setRemux=function(B){var R=this.transmuxPipeline_;if(p.remux=B,R&&R.coalesceStream)R.coalesceStream.setRemux(B)},this.alignGopsWith=function(B){if(k&&this.transmuxPipeline_.videoSegmentStream)this.transmuxPipeline_.videoSegmentStream.alignGopsWith(B)},this.getLogTrigger_=function(B){var R=this;return function(E){E.stream=B,R.trigger("log",E)}},this.push=function(B){if(v){var R=Mu(B);if(R&&this.transmuxPipeline_.type!=="aac")this.setupAacPipeline();else if(!R&&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()}},_f.prototype=new Af;var xu={Transmuxer:_f,VideoSegmentStream:bl,AudioSegmentStream:Ri,AUDIO_PROPERTIES:qi,VIDEO_PROPERTIES:pl,generateSegmentTimingInfo:Gr},Du=function(p){return p>>>0},Ff=function(p){return("00"+p.toString(16)).slice(-2)},Of={toUnsigned:Du,toHexString:Ff},Xr=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},Kr=Xr,N5=Of.toUnsigned,Lr=Kr,Vr=function(p,q){var v=[],k,_,B,R,E;if(!q.length)return null;for(k=0;k<p.byteLength;){if(_=N5(p[k]<<24|p[k+1]<<16|p[k+2]<<8|p[k+3]),B=Lr(p.subarray(k+4,k+8)),R=_>1?k+_:p.byteLength,B===q[0]){if(q.length===1)v.push(p.subarray(k+8,R));else if(E=Vr(p.subarray(k+8,R),q.slice(1)),E.length)v=v.concat(E)}k=R}return v},Bf=Vr,Ru=Of.toUnsigned,Nu=i.getUint64,nc=function(p){var q={version:p[0],flags:new Uint8Array(p.subarray(1,4))};if(q.version===1)q.baseMediaDecodeTime=Nu(p.subarray(4));else q.baseMediaDecodeTime=Ru(p[4]<<24|p[5]<<16|p[6]<<8|p[7]);return q},Tf=nc,zu=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,R=v.flags[2]&16,E=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(R)v.defaultSampleSize=q.getUint32(W),W+=4;if(E)v.defaultSampleFlags=q.getUint32(W);if(G)v.durationIsEmpty=!0;if(!k&&X)v.baseDataOffsetIsMoof=!0;return v},Mf=zu,Hf=i.getUint64,sc=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=Hf(p.subarray(k)),v.firstOffset=Hf(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},Eu=sc,ic=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]}},Iu=ic,Js=Iu,lc=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,R=q.flags[1]&2,E=q.flags[1]&4,G=q.flags[1]&8,X=v.getUint32(4),W=8,le;if(k)q.dataOffset=v.getInt32(W),W+=4;if(_&&X){if(le={flags:Js(p.subarray(W,W+4))},W+=4,B)le.duration=v.getUint32(W),W+=4;if(R)le.size=v.getUint32(W),W+=4;if(G){if(q.version===1)le.compositionTimeOffset=v.getInt32(W);else le.compositionTimeOffset=v.getUint32(W);W+=4}q.samples.push(le),X--}while(X--){if(le={},B)le.duration=v.getUint32(W),W+=4;if(R)le.size=v.getUint32(W),W+=4;if(E)le.flags=Js(p.subarray(W,W+4)),W+=4;if(G){if(q.version===1)le.compositionTimeOffset=v.getInt32(W);else le.compositionTimeOffset=v.getUint32(W);W+=4}q.samples.push(le)}return q},Uu=lc,Gu=i,is=Gu.getUint64,za,Yr,Nn=function(p){return new Date(p*1000-2082844800000)},wl=Kr,Xu=Bf,fc=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},Qs={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:za(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,R,E;R=6;for(E=0;E<k;E++)B=q.getUint16(R),R+=2,v.sps.push(new Uint8Array(p.subarray(R,R+B))),R+=B;_=p[R],R++;for(E=0;E<_;E++)B=q.getUint16(R),R+=2,v.pps.push(new Uint8Array(p.subarray(R,R+B))),R+=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:za(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:is(q.subarray(B)),mediaTime:is(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:wl(p.subarray(0,4)),minorVersion:q.getUint32(4),compatibleBrands:[]},k=8;while(k<p.byteLength)v.compatibleBrands.push(wl(p.subarray(k,k+4))),k+=4;return v},dinf:function(p){return{boxes:za(p)}},dref:function(p){return{version:p[0],flags:new Uint8Array(p.subarray(1,4)),dataReferences:za(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:wl(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:fc(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=Nn(q.getUint32(v)),v+=8,_.modificationTime=Nn(q.getUint32(v)),v+=4,_.timescale=q.getUint32(v),v+=8,_.duration=q.getUint32(v);else _.creationTime=Nn(q.getUint32(v)),v+=4,_.modificationTime=Nn(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:za(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:za(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=za(p.subarray(28))[0];return v},moof:function(p){return{boxes:za(p)}},moov:function(p){return{boxes:za(p)}},mvex:function(p){return{boxes:za(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=Nn(q.getUint32(v)),v+=8,k.modificationTime=Nn(q.getUint32(v)),v+=4,k.timescale=q.getUint32(v),v+=8,k.duration=q.getUint32(v);else k.creationTime=Nn(q.getUint32(v)),v+=4,k.modificationTime=Nn(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:Eu,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:za(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:za(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 Qs.ftyp(p)},tfdt:Tf,tfhd:Mf,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=Nn(q.getUint32(v)),v+=8,k.modificationTime=Nn(q.getUint32(v)),v+=4,k.trackId=q.getUint32(v),v+=4,v+=8,k.duration=q.getUint32(v);else k.creationTime=Nn(q.getUint32(v)),v+=4,k.modificationTime=Nn(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:za(p)}},trak:function(p){return{boxes:za(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:Uu,"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)])}}};za=function(p){var q=0,v=[],k,_,B,R,E,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=wl(p.subarray(q+4,q+8)),R=_>1?q+_:p.byteLength,E=(Qs[B]||function(le){return{data:le}})(p.subarray(q+8,R)),E.size=_,E.type=B,v.push(E),q=R;return v},Yr=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 R=v+" "+B+": ",E=k[B];if(E instanceof Uint8Array||E instanceof Uint32Array){var G=Array.prototype.slice.call(new Uint8Array(E.buffer,E.byteOffset,E.byteLength)).map(function(X){return" "+("00"+X.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);if(!G)return R+"<>";if(G.length===1)return R+"<"+G.join("").slice(1)+">";return R+`<
209
- `+G.map(function(X){return v+" "+X}).join(`
210
- `)+`
211
- `+v+" >"}return R+JSON.stringify(E,null,2).split(`
212
- `).map(function(X,W){if(W===0)return X;return v+" "+X}).join(`
213
- `)}).join(`
214
- `)+(k.boxes?`
215
- `+Yr(k.boxes,q+1):"")}).join(`
216
- `)};var rc={inspect:za,textify:Yr,parseType:wl,findBox:Xu,parseTraf:Qs.traf,parseTfdt:Qs.tfdt,parseHdlr:Qs.hdlr,parseTfhd:Qs.tfhd,parseTrun:Qs.trun,parseSidx:Qs.sidx},Jr=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},xf={uint8ToCString:Jr},It=xf.uint8ToCString,z5=i.getUint64,E5=function(p){var q=4,v=p[0],k,_,B,R,E,G,X,W;if(v===0){k=It(p.subarray(q)),q+=k.length,_=It(p.subarray(q)),q+=_.length;var le=new DataView(p.buffer);B=le.getUint32(q),q+=4,E=le.getUint32(q),q+=4,G=le.getUint32(q),q+=4,X=le.getUint32(q),q+=4}else if(v===1){var le=new DataView(p.buffer);B=le.getUint32(q),q+=4,R=z5(p.subarray(q)),q+=8,G=le.getUint32(q),q+=4,X=le.getUint32(q),q+=4,k=It(p.subarray(q)),q+=k.length,_=It(p.subarray(q)),q+=_.length}W=new Uint8Array(p.subarray(q,p.byteLength));var Te={scheme_id_uri:k,value:_,timescale:B?B:1,presentation_time:R,presentation_time_delta:E,event_duration:G,id:X,message_data:W};return Df(v,Te)?Te:void 0},Ku=function(p,q,v,k){return p||p===0?p/q:k+v/q},Df=function(p,q){var v=q.scheme_id_uri!=="\x00",k=p===0&&vi(q.presentation_time_delta)&&v,_=p===1&&vi(q.presentation_time)&&v;return!(p>1)&&k||_},vi=function(p){return p!==void 0||p!==null},Lu={parseEmsgBox:E5,scaleTime:Ku},dl;if(typeof window<"u")dl=window;else if(typeof e<"u")dl=e;else if(typeof self<"u")dl=self;else dl={};var jl=dl,Ln=Of.toUnsigned,ql=Of.toHexString,ra=Bf,S0=Kr,Rf=Lu,oc=Mf,Qr=Uu,Vu=Tf,Yu=i.getUint64,Ju,cc,hc,ls,Zr,$r,uc,mc=jl,Wr=rn.parseId3Frames;Ju=function(p){var q={},v=ra(p,["moov","trak"]);return v.reduce(function(k,_){var B,R,E,G,X;if(B=ra(_,["tkhd"])[0],!B)return null;if(R=B[0],E=R===0?12:20,G=Ln(B[E]<<24|B[E+1]<<16|B[E+2]<<8|B[E+3]),X=ra(_,["mdia","mdhd"])[0],!X)return null;return R=X[0],E=R===0?12:20,k[G]=Ln(X[E]<<24|X[E+1]<<16|X[E+2]<<8|X[E+3]),k},q)},cc=function(p,q){var v=ra(q,["moof","traf"]),k=v.reduce(function(_,B){var R=ra(B,["tfhd"])[0],E=Ln(R[4]<<24|R[5]<<16|R[6]<<8|R[7]),G=p[E]||90000,X=ra(B,["tfdt"])[0],W=new DataView(X.buffer,X.byteOffset,X.byteLength),le;if(X[0]===1)le=Yu(X.subarray(4,12));else le=W.getUint32(4);let Te;if(typeof le==="bigint")Te=le/mc.BigInt(G);else if(typeof le==="number"&&!isNaN(le))Te=le/G;if(Te<Number.MAX_SAFE_INTEGER)Te=Number(Te);if(Te<_)_=Te;return _},1/0);return typeof k==="bigint"||isFinite(k)?k:0},hc=function(p,q){var v=ra(q,["moof","traf"]),k=0,_=0,B;if(v&&v.length){var R=ra(v[0],["tfhd"])[0],E=ra(v[0],["trun"])[0],G=ra(v[0],["tfdt"])[0];if(R){var X=oc(R);B=X.trackId}if(G){var W=Vu(G);k=W.baseMediaDecodeTime}if(E){var le=Qr(E);if(le.samples&&le.samples.length)_=le.samples[0].compositionTimeOffset||0}}var Te=p[B]||90000;if(typeof k==="bigint")_=mc.BigInt(_),Te=mc.BigInt(Te);var ue=(k+_)/Te;if(typeof ue==="bigint"&&ue<Number.MAX_SAFE_INTEGER)ue=Number(ue);return ue},ls=function(p){var q=ra(p,["moov","trak"]),v=[];return q.forEach(function(k){var _=ra(k,["mdia","hdlr"]),B=ra(k,["tkhd"]);_.forEach(function(R,E){var G=S0(R.subarray(8,12)),X=B[E],W,le,Te;if(G==="vide")W=new DataView(X.buffer,X.byteOffset,X.byteLength),le=W.getUint8(0),Te=le===0?W.getUint32(12):W.getUint32(20),v.push(Te)})}),v},$r=function(p){var q=p[0],v=q===0?12:20;return Ln(p[v]<<24|p[v+1]<<16|p[v+2]<<8|p[v+3])},Zr=function(p){var q=ra(p,["moov","trak"]),v=[];return q.forEach(function(k){var _={},B=ra(k,["tkhd"])[0],R,E;if(B)R=new DataView(B.buffer,B.byteOffset,B.byteLength),E=R.getUint8(0),_.id=E===0?R.getUint32(12):R.getUint32(20);var G=ra(k,["mdia","hdlr"])[0];if(G){var X=S0(G.subarray(8,12));if(X==="vide")_.type="video";else if(X==="soun")_.type="audio";else _.type=X}var W=ra(k,["mdia","minf","stbl","stsd"])[0];if(W){var le=W.subarray(8);_.codec=S0(le.subarray(4,8));var Te=ra(le,[_.codec])[0],ue,Ke;if(Te)if(/^[asm]vc[1-9]$/i.test(_.codec))if(ue=Te.subarray(78),Ke=S0(ue.subarray(4,8)),Ke==="avcC"&&ue.length>11)_.codec+=".",_.codec+=ql(ue[9]),_.codec+=ql(ue[10]),_.codec+=ql(ue[11]);else _.codec="avc1.4d400d";else if(/^mp4[a,v]$/i.test(_.codec))if(ue=Te.subarray(28),Ke=S0(ue.subarray(4,8)),Ke==="esds"&&ue.length>20&&ue[19]!==0)_.codec+="."+ql(ue[19]),_.codec+="."+ql(ue[20]>>>2&63).replace(/^0/,"");else _.codec="mp4a.40.2";else _.codec=_.codec.toLowerCase()}var tt=ra(k,["mdia","mdhd"])[0];if(tt)_.timescale=$r(tt);v.push(_)}),v},uc=function(p,q=0){var v=ra(p,["emsg"]);return v.map((k)=>{var _=Rf.parseEmsgBox(new Uint8Array(k)),B=Wr(_.message_data);return{cueTime:Rf.scaleTime(_.presentation_time,_.timescale,_.presentation_time_delta,q),duration:Rf.scaleTime(_.event_duration,_.timescale),frames:B}})};var Ba={findBox:ra,parseType:S0,timescale:Ju,startTime:cc,compositionStartTime:hc,videoTrackIds:ls,tracks:Zr,getTimescaleFromMediaHeader:$r,getEmsgID3:uc};let{parseTrun:Qu}=rc,{findBox:on}=Ba;var gc=jl,ki=function(p){var q=on(p,["moof","traf"]),v=on(p,["mdat"]),k=[];return v.forEach(function(_,B){var R=q[B];k.push({mdat:_,traf:R})}),k},C0=function(p,q,v){var k=q,_=v.defaultSampleDuration||0,B=v.defaultSampleSize||0,R=v.trackId,E=[];return p.forEach(function(G){var X=Qu(G),W=X.samples;W.forEach(function(le){if(le.duration===void 0)le.duration=_;if(le.size===void 0)le.size=B;if(le.trackId=R,le.dts=k,le.compositionTimeOffset===void 0)le.compositionTimeOffset=0;if(typeof k==="bigint")le.pts=k+gc.BigInt(le.compositionTimeOffset),k+=gc.BigInt(le.duration);else le.pts=k+le.compositionTimeOffset,k+=le.duration}),E=E.concat(W)}),E},Zs={getMdatTrafPairs:ki,parseSamples:C0},pc=z1.discardEmulationPreventionBytes,bc=E1.CaptionStream,Vn=Bf,Zu=Tf,vl=Mf,{getMdatTrafPairs:Nf,parseSamples:_0}=Zs,$u=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},Wu=function(p,q,v){var k=new DataView(p.buffer,p.byteOffset,p.byteLength),_={logs:[],seiNals:[]},B,R,E,G;for(R=0;R+4<p.length;R+=E){if(E=k.getUint32(R),R+=4,E<=0)continue;switch(p[R]&31){case 6:var X=p.subarray(R+1,R+1+E),W=$u(R,q);if(B={nalUnitType:"sei_rbsp",size:E,data:X,escapedRBSP:pc(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 "+R+" for trackId "+v+". See mux.js#223."});break}_.seiNals.push(B);break}}return _},zf=function(p,q){var v={},k=Nf(p);return k.forEach(function(_){var{mdat:B,traf:R}=_,E=Vn(R,["tfhd"]),G=vl(E[0]),X=G.trackId,W=Vn(R,["tfdt"]),le=W.length>0?Zu(W[0]).baseMediaDecodeTime:0,Te=Vn(R,["trun"]),ue,Ke;if(q===X&&Te.length>0){if(ue=_0(Te,le,G),Ke=Wu(B,ue,X),!v[X])v[X]={seiNals:[],logs:[]};v[X].seiNals=v[X].seiNals.concat(Ke.seiNals),v[X].logs=v[X].logs.concat(Ke.logs)}}),v},Pu=function(p,q,v){var k;if(q===null)return null;k=zf(p,q);var _=k[q]||{};return{seiNals:_.seiNals,logs:_.logs,timescale:v}},Pr=function(){var p=!1,q,v,k,_,B,R;this.isInitialized=function(){return p},this.init=function(E){q=new bc,p=!0,R=E?E.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(E,G){if(E&&E.length===0||G&&typeof G==="object"&&Object.keys(G).length===0)return!1;return k!==E[0]||_!==G[k]},this.parse=function(E,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(E),null;while(v.length>0){var le=v.shift();this.parse(le,G,X)}if(W=Pu(E,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(E){if(!this.isInitialized()||!E||E.length===0)return null;E.forEach(function(G){q.push(G)})},this.flushStream=function(){if(!this.isInitialized())return null;if(!R)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()},e2=Pr;let{parseTfdt:wc}=rc,$s=Bf,{getTimescaleFromMediaHeader:dc}=Ba,{parseSamples:t2,getMdatTrafPairs:jc}=Zs;var qc=function(){let p=90000;this.init=function(q){let v=$s(q,["moov","trak","mdia","mdhd"])[0];if(v)p=dc(v)},this.parseSegment=function(q){let v=[],k=jc(q),_=0;return k.forEach(function(B){let{mdat:R,traf:E}=B,G=$s(E,["tfdt"])[0],X=$s(E,["tfhd"])[0],W=$s(E,["trun"]);if(G)_=wc(G).baseMediaDecodeTime;if(W.length&&X){let le=t2(W,_,X),Te=0;le.forEach(function(ue){let tt=new TextDecoder("utf-8"),Ea=R.slice(Te,Te+ue.size);if($s(Ea,["vtte"])[0]){Te+=ue.size;return}$s(Ea,["vttc"]).forEach(function(Al){let yl=$s(Al,["payl"])[0],Sl=$s(Al,["sttg"])[0],Cl=ue.pts/p,Uf=(ue.pts+ue.duration)/p,Kt,ut;if(yl)try{Kt=tt.decode(yl)}catch(Yn){console.error(Yn)}if(Sl)try{ut=tt.decode(Sl)}catch(Yn){console.error(Yn)}if(ue.duration&&Kt)v.push({cueText:Kt,start:Cl,end:Uf,settings:ut})}),Te+=ue.size})}}),v}},cn=uf,vc=function(p){var q=p[1]&31;return q<<=8,q|=p[2],q},Ef=function(p){return!!(p[1]&64)},eo=function(p){var q=0;if((p[3]&48)>>>4>1)q+=p[4]+1;return q},zi=function(p,q){var v=vc(p);if(v===0)return"pat";else if(v===q)return"pmt";else if(q)return"pes";return null},a2=function(p){var q=Ef(p),v=4+eo(p);if(q)v+=p[v]+1;return(p[v+10]&31)<<8|p[v+11]},kc=function(p){var q={},v=Ef(p),k=4+eo(p);if(v)k+=p[k]+1;if(!(p[k+5]&1))return;var _,B,R;_=(p[k+1]&15)<<8|p[k+2],B=3+_-4,R=(p[k+10]&15)<<8|p[k+11];var E=12+R;while(E<B){var G=k+E;q[(p[G+1]&31)<<8|p[G+2]]=p[G],E+=((p[G+3]&15)<<8|p[G+4])+5}return q},kl=function(p,q){var v=vc(p),k=q[v];switch(k){case cn.H264_STREAM_TYPE:return"video";case cn.ADTS_STREAM_TYPE:return"audio";case cn.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},n2=function(p){var q=Ef(p);if(!q)return null;var v=4+eo(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},to=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}},s2=function(p){var q=4+eo(p),v=p.subarray(q),k=0,_=0,B=!1,R;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(R=to(v[_+3]&31),R==="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(R=to(v[_+3]&31),R==="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(R=to(v[_+3]&31),R==="slice_layer_without_partitioning_rbsp_idr")B=!0}return B},i2={parseType:zi,parsePat:a2,parsePmt:kc,parsePayloadUnitStartIndicator:Ef,parsePesType:kl,parsePesTime:n2,videoPacketContainsKeyFrame:s2},If=uf,Ei=Rn.handleRollover,Nt={};Nt.ts=i2,Nt.aac=kf;var F0=Re.ONE_SECOND_IN_TS,yn=188,Os=71,l2=function(p,q){var v=0,k=yn,_,B;while(k<p.byteLength){if(p[v]===Os&&p[k]===Os){switch(_=p.subarray(v,k),B=Nt.ts.parseType(_,q.pid),B){case"pat":q.pid=Nt.ts.parsePat(_);break;case"pmt":var R=Nt.ts.parsePmt(_);q.table=q.table||{},Object.keys(R).forEach(function(E){q.table[E]=R[E]});break}v+=yn,k+=yn;continue}v++,k++}},O0=function(p,q,v){var k=0,_=yn,B,R,E,G,X,W=!1;while(_<=p.byteLength){if(p[k]===Os&&(p[_]===Os||_===p.byteLength)){switch(B=p.subarray(k,_),R=Nt.ts.parseType(B,q.pid),R){case"pes":if(E=Nt.ts.parsePesType(B,q.table),G=Nt.ts.parsePayloadUnitStartIndicator(B),E==="audio"&&G){if(X=Nt.ts.parsePesTime(B),X)X.type="audio",v.audio.push(X),W=!0}break}if(W)break;k+=yn,_+=yn;continue}k++,_++}_=p.byteLength,k=_-yn,W=!1;while(k>=0){if(p[k]===Os&&(p[_]===Os||_===p.byteLength)){switch(B=p.subarray(k,_),R=Nt.ts.parseType(B,q.pid),R){case"pes":if(E=Nt.ts.parsePesType(B,q.table),G=Nt.ts.parsePayloadUnitStartIndicator(B),E==="audio"&&G){if(X=Nt.ts.parsePesTime(B),X)X.type="audio",v.audio.push(X),W=!0}break}if(W)break;k-=yn,_-=yn;continue}k--,_--}},ao=function(p,q,v){var k=0,_=yn,B,R,E,G,X,W,le,Te,ue=!1,Ke={data:[],size:0};while(_<p.byteLength){if(p[k]===Os&&p[_]===Os){switch(B=p.subarray(k,_),R=Nt.ts.parseType(B,q.pid),R){case"pes":if(E=Nt.ts.parsePesType(B,q.table),G=Nt.ts.parsePayloadUnitStartIndicator(B),E==="video"){if(G&&!ue){if(X=Nt.ts.parsePesTime(B),X)X.type="video",v.video.push(X),ue=!0}if(!v.firstKeyFrame){if(G){if(Ke.size!==0){W=new Uint8Array(Ke.size),le=0;while(Ke.data.length)Te=Ke.data.shift(),W.set(Te,le),le+=Te.byteLength;if(Nt.ts.videoPacketContainsKeyFrame(W)){var tt=Nt.ts.parsePesTime(W);if(tt)v.firstKeyFrame=tt,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.")}Ke.size=0}}Ke.data.push(B),Ke.size+=B.byteLength}}break}if(ue&&v.firstKeyFrame)break;k+=yn,_+=yn;continue}k++,_++}_=p.byteLength,k=_-yn,ue=!1;while(k>=0){if(p[k]===Os&&p[_]===Os){switch(B=p.subarray(k,_),R=Nt.ts.parseType(B,q.pid),R){case"pes":if(E=Nt.ts.parsePesType(B,q.table),G=Nt.ts.parsePayloadUnitStartIndicator(B),E==="video"&&G){if(X=Nt.ts.parsePesTime(B),X)X.type="video",v.video.push(X),ue=!0}break}if(ue)break;k-=yn,_-=yn;continue}k--,_--}},f2=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=Ei(B.dts,v),B.pts=Ei(B.pts,v),B.dtsTime=B.dts/F0,B.ptsTime=B.pts/F0})}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=Ei(B.dts,k),B.pts=Ei(B.pts,k),B.dtsTime=B.dts/F0,B.ptsTime=B.pts/F0}),p.firstKeyFrame){var _=p.firstKeyFrame;_.dts=Ei(_.dts,k),_.pts=Ei(_.pts,k),_.dtsTime=_.dts/F0,_.ptsTime=_.pts/F0}}},r2=function(p){var q=!1,v=0,k=null,_=null,B=0,R=0,E;while(p.length-R>=3){var G=Nt.aac.parseType(p,R);switch(G){case"timed-metadata":if(p.length-R<10){q=!0;break}if(B=Nt.aac.parseId3TagSize(p,R),B>p.length){q=!0;break}if(_===null)E=p.subarray(R,R+B),_=Nt.aac.parseAacTimestamp(E);R+=B;break;case"audio":if(p.length-R<7){q=!0;break}if(B=Nt.aac.parseAdtsSize(p,R),B>p.length){q=!0;break}if(k===null)E=p.subarray(R,R+B),k=Nt.aac.parseSampleRate(E);v++,R+=B;break;default:R++;break}if(q)return null}if(k===null||_===null)return null;var X=F0/k,W={audio:[{type:"audio",dts:_,pts:_},{type:"audio",dts:_+v*1024*X,pts:_+v*1024*X}]};return W},o2=function(p){var q={pid:null,table:null},v={};l2(p,q);for(var k in q.table)if(q.table.hasOwnProperty(k)){var _=q.table[k];switch(_){case If.H264_STREAM_TYPE:if(v.video=[],ao(p,q,v),v.video.length===0)delete v.video;break;case If.ADTS_STREAM_TYPE:if(v.audio=[],O0(p,q,v),v.audio.length===0)delete v.audio;break}}return v},c2=function(p,q){var v=Nt.aac.isLikelyAacData(p),k;if(v)k=r2(p);else k=o2(p);if(!k||!k.audio&&!k.video)return null;return f2(k,q),k},h2={inspect:c2,parseAudioPes_:O0};let u2=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:Re.videoTsToSeconds(v.start.dts),presentation:Re.videoTsToSeconds(v.start.pts)},end:{decode:Re.videoTsToSeconds(v.end.dts),presentation:Re.videoTsToSeconds(v.end.pts)},baseMediaDecodeTime:Re.videoTsToSeconds(v.baseMediaDecodeTime)};if(v.prependedContentDuration)k.prependedContentDuration=Re.videoTsToSeconds(v.prependedContentDuration);p.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:k})}),q.on("audioSegmentTimingInfo",function(v){let k={start:{decode:Re.videoTsToSeconds(v.start.dts),presentation:Re.videoTsToSeconds(v.start.pts)},end:{decode:Re.videoTsToSeconds(v.end.dts),presentation:Re.videoTsToSeconds(v.end.pts)},baseMediaDecodeTime:Re.videoTsToSeconds(v.baseMediaDecodeTime)};if(v.prependedContentDuration)k.prependedContentDuration=Re.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:Re.videoTsToSeconds(v.start),end:Re.videoTsToSeconds(v.end)}})}),q.on("videoTimingInfo",function(v){p.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:Re.videoTsToSeconds(v.start),end:Re.videoTsToSeconds(v.end)}})}),q.on("log",function(v){p.postMessage({action:"log",log:v})})};class B0{constructor(p,q){this.options=q||{},this.self=p,this.init()}init(){if(this.transmuxer)this.transmuxer.dispose();this.transmuxer=new xu.Transmuxer(this.options),u2(this.self,this.transmuxer)}pushMp4Captions(p){if(!this.captionParser)this.captionParser=new e2,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 qc;let q=new Uint8Array(p.data,p.byteOffset,p.byteLength);this.webVttParser.init(q)}getMp4WebVttText(p){if(!this.webVttParser)this.webVttParser=new qc;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=Ba.startTime(p,q);this.self.postMessage({action:"probeMp4StartTime",startTime:v,data:q},[q.buffer])}probeMp4Tracks({data:p}){let q=Ba.tracks(p);this.self.postMessage({action:"probeMp4Tracks",tracks:q,data:p},[p.buffer])}probeEmsgID3({data:p,offset:q}){let v=Ba.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*Re.ONE_SECOND_IN_TS:void 0,k=h2.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(Re.secondsToVideoTs(q)))}setAudioAppendStart(p){this.transmuxer.setAudioAppendStart(Math.ceil(Re.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 B0(self,p.data.options);return}if(!this.messageHandlers)this.messageHandlers=new B0(self);if(p.data&&p.data.action&&p.data.action!=="init"){if(this.messageHandlers[p.data.action])this.messageHandlers[p.data.action](p.data)}}})),JM=gq(YM),QM=(e,t,a)=>{let{type:n,initSegment:s,captions:i,captionStreams:l,metadata:f,videoFrameDtsTime:c,videoFramePtsTime:h}=e.data.segment;t.buffer.push({captions:i,captionStreams:l,metadata:f});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)},ZM=({transmuxedData:e,callback:t})=>{e.buffer=[],t(e)},$M=(e,t)=>{t.gopInfo=e.data.gopInfo},wq=(e)=>{let{transmuxer:t,bytes:a,audioAppendStart:n,gopsToAlignWith:s,remux:i,onData:l,onTrackInfo:f,onAudioTimingInfo:c,onVideoTimingInfo:h,onVideoSegmentTimingInfo:u,onAudioSegmentTimingInfo:g,onId3:b,onCaptions:d,onDone:j,onEndedTimeline:A,onTransmuxerLog:S,isEndOfTimeline:C,segment:O,triggerSegmentEventFn:T}=e,M={buffer:[]},H=C,D=(z)=>{if(t.currentTransmux!==e)return;if(z.data.action==="data")QM(z,M,l);if(z.data.action==="trackinfo")f(z.data.trackInfo);if(z.data.action==="gopInfo")$M(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")S(z.data.log);if(z.data.type!=="transmuxed")return;if(H)return;t.onmessage=null,ZM({transmuxedData:M,callback:j}),dq(t)},N=()=>{let z={message:"Received an error message from the transmuxer worker",metadata:{errorType:se.Error.StreamingFailedToTransmuxSegment,segmentInfo:cr({segment:O})}};j(null,z)};if(t.onmessage=D,t.onerror=N,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,L=a instanceof ArrayBuffer?0:a.byteOffset;T({type:"segmenttransmuxingstart",segment:O}),t.postMessage({action:"push",data:z,byteOffset:L,byteLength:a.byteLength},[z])}if(C)t.postMessage({action:"endTimeline"});t.postMessage({action:"flush"})},dq=(e)=>{if(e.currentTransmux=null,e.transmuxQueue.length)if(e.currentTransmux=e.transmuxQueue.shift(),typeof e.currentTransmux==="function")e.currentTransmux();else wq(e.currentTransmux)},dd=(e,t)=>{e.postMessage({action:t}),dq(e)},jq=(e,t)=>{if(!t.currentTransmux){t.currentTransmux=e,dd(t,e);return}t.transmuxQueue.push(dd.bind(null,t,e))},WM=(e)=>{jq("reset",e)},PM=(e)=>{jq("endTimeline",e)},qq=(e)=>{if(!e.transmuxer.currentTransmux){e.transmuxer.currentTransmux=e,wq(e);return}e.transmuxer.transmuxQueue.push(e)},eH=(e)=>{let t=new JM;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},U6={reset:WM,endTimeline:PM,transmux:qq,createTransmuxer:eH},e1=function(e){let t=e.transmuxer,a=e.endAction||e.action,n=e.callback,s=va({},e,{endAction:null,transmuxer:null,callback:null}),i=(l)=>{if(l.data.action!==a)return;if(t.removeEventListener("message",i),l.data.data){if(l.data.data=new Uint8Array(l.data.data,e.byteOffset||0,e.byteLength||l.data.data.byteLength),e.data)e.data=l.data.data}n(l.data)};if(t.addEventListener("message",i),e.data){let l=e.data instanceof ArrayBuffer;s.byteOffset=l?0:e.data.byteOffset,s.byteLength=e.data.byteLength;let f=[l?e.data:e.data.buffer];t.postMessage(s,f)}else t.postMessage(s)},Pi={FAILURE:2,TIMEOUT:-101,ABORTED:-102},vq="wvtt",r4=(e)=>{e.forEach((t)=>{t.abort()})},tH=(e)=>{return{bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}},aH=(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},fg=(e,t)=>{let{requestType:a}=t,n=pr({requestType:a,request:t,error:e});if(t.timedout)return{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:Pi.TIMEOUT,xhr:t,metadata:n};if(t.aborted)return{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:Pi.ABORTED,xhr:t,metadata:n};if(e)return{status:t.status,message:"HLS request errored at URL: "+t.uri,code:Pi.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:Pi.FAILURE,xhr:t,metadata:n};return null},jd=(e,t,a,n)=>(s,i)=>{let l=i.response,f=fg(s,i);if(f)return a(f,e);if(l.byteLength!==16)return a({status:i.status,message:"Invalid HLS key at URL: "+i.uri,code:Pi.FAILURE,xhr:i},e);let c=new DataView(l),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)},nH=(e,t)=>{if(t===vq)e.transmuxer.postMessage({action:"initMp4WebVttParser",data:e.map.bytes})},sH=(e,t,a)=>{if(t===vq)e1({action:"getMp4WebVttText",data:e.bytes,transmuxer:e.transmuxer,callback:({data:n,mp4VttCues:s})=>{e.bytes=n,a(null,e,{mp4VttCues:s})}})},kq=(e,t)=>{let a=om(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:Pi.FAILURE,metadata:{mediaType:s}})}e1({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")nH(e,i.codec)}),t(null)}})},iH=({segment:e,finishProcessingFn:t,triggerSegmentEventFn:a})=>(n,s)=>{let i=fg(n,s);if(i)return t(i,e);let l=new Uint8Array(s.response);if(a({type:"segmentloaded",segment:e}),e.map.key)return e.map.encryptedBytes=l,t(null,e);e.map.bytes=l,kq(e,function(f){if(f)return f.xhr=s,f.status=s.status,t(f,e);t(null,e)})},lH=({segment:e,finishProcessingFn:t,responseType:a,triggerSegmentEventFn:n})=>(s,i)=>{let l=fg(s,i);if(l)return t(l,e);n({type:"segmentloaded",segment:e});let f=a==="arraybuffer"||!i.responseText?i.response:LM(i.responseText.substring(e.lastReachedChar||0));if(e.stats=tH(i),e.key)e.encryptedBytes=new Uint8Array(f);else e.bytes=new Uint8Array(f);return t(null,e)},fH=({segment:e,bytes:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,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),S=n.bind(null,e,"audio","start"),C=n.bind(null,e,"audio","end"),O=n.bind(null,e,"video","start"),T=n.bind(null,e,"video","end"),M=()=>qq({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(S&&typeof H.start<"u")S(H.start),S=null;if(C&&typeof H.end<"u")C(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 D={pts:{start:H.start.presentation,end:H.end.presentation},dts:{start:H.start.decode,end:H.end.decode}};d({type:"segmenttransmuxingtiminginfoavailable",segment:e,timingInfo:D}),s(H)},onAudioSegmentTimingInfo:(H)=>{let D={pts:{start:H.start.pts,end:H.end.pts},dts:{start:H.start.dts,end:H.end.dts}};d({type:"segmenttransmuxingtiminginfoavailable",segment:e,timingInfo:D}),i(H)},onId3:(H,D)=>{l(e,H,D)},onCaptions:(H)=>{f(e,[H])},isEndOfTimeline:c,onEndedTimeline:()=>{h()},onTransmuxerLog:b,onDone:(H,D)=>{if(!g)return;H.type=H.type==="combined"?"video":H.type,d({type:"segmenttransmuxingcomplete",segment:e}),g(D,e,H)},segment:e,triggerSegmentEventFn:d});e1({action:"probeTs",transmuxer:e.transmuxer,data:t,baseStartTime:e.baseStartTime,callback:(H)=>{e.bytes=t=H.data;let D=H.result;if(D)a(e,{hasAudio:D.hasAudio,hasVideo:D.hasVideo,isMuxed:A}),a=null;M()}})},Aq=({segment:e,bytes:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{let j=new Uint8Array(t);if(Rw(j)){e.isFmp4=!0;let{tracks:A}=e.map;if(A.text&&(!A.audio||!A.video)){u(e,{data:j,type:"text"}),sH(e,A.text.codec,g);return}let C={isFmp4:!0,hasVideo:!!A.video,hasAudio:!!A.audio};if(A.audio&&A.audio.codec&&A.audio.codec!=="enca")C.audioCodec=A.audio.codec;if(A.video&&A.video.codec&&A.video.codec!=="encv")C.videoCodec=A.video.codec;if(A.video&&A.audio)C.isMuxed=!0;a(e,C);let O=(T,M)=>{if(u(e,{data:j,type:C.hasAudio&&!C.isMuxed?"audio":"video"}),M&&M.length)l(e,M);if(T&&T.length)f(e,T);g(null,e,{})};e1({action:"probeMp4StartTime",timescales:e.map.timescales,data:j,transmuxer:e.transmuxer,callback:({data:T,startTime:M})=>{if(t=T.buffer,e.bytes=j=T,C.hasAudio&&!C.isMuxed)n(e,"audio","start",M);if(C.hasVideo)n(e,"video","start",M);e1({action:"probeEmsgID3",data:j,transmuxer:e.transmuxer,offset:M,callback:({emsgData:H,id3Frames:D})=>{if(t=H.buffer,e.bytes=j=H,!A.video||!H.byteLength||!e.transmuxer){O(void 0,D);return}e1({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:e.transmuxer,data:j,timescales:e.map.timescales,trackIds:[A.video.id],callback:(N)=>{t=N.data.buffer,e.bytes=j=N.data,N.logs.forEach(function(z){b(Gt(z,{stream:"mp4CaptionParser"}))}),O(N.captions,D)}})}})}});return}if(!e.transmuxer){g(null,e,{});return}if(typeof e.container>"u")e.container=om(j);if(e.container!=="ts"&&e.container!=="aac"){a(e,{hasAudio:!1,hasVideo:!1}),g(null,e,{});return}fH({segment:e,bytes:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})},yq=function({id:e,key:t,encryptedBytes:a,decryptionWorker:n,segment:s,doneFn:i},l){let f=(h)=>{if(h.data.source===e){n.removeEventListener("message",f);let u=h.data.decrypted;l(new Uint8Array(u.bytes,u.byteOffset,u.byteLength))}};n.onerror=()=>{let u=cr({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",f);let c;if(t.bytes.slice)c=t.bytes.slice();else c=new Uint32Array(Array.prototype.slice.call(t.bytes));n.postMessage(rq({source:e,encrypted:a,key:c,iv:t.iv}),[a.buffer,c.buffer])},rH=({decryptionWorker:e,segment:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{d({type:"segmentdecryptionstart"}),yq({id:t.requestId,key:t.key,encryptedBytes:t.encryptedBytes,decryptionWorker:e,segment:t,doneFn:g},(j)=>{t.bytes=j,d({type:"segmentdecryptioncomplete",segment:t}),Aq({segment:t,bytes:t.bytes,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})})},oH=({activeXhrs:e,decryptionWorker:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})=>{let j=0,A=!1;return(S,C)=>{if(A)return;if(S)return A=!0,r4(e),g(S,C);if(j+=1,j===e.length){let O=function(){if(C.encryptedBytes)return rH({decryptionWorker:t,segment:C,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d});Aq({segment:C,bytes:C.bytes,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u,doneFn:g,onTransmuxerLog:b,triggerSegmentEventFn:d})};if(C.endOfAllRequests=Date.now(),C.map&&C.map.encryptedBytes&&!C.map.bytes)return d({type:"segmentdecryptionstart",segment:C}),yq({decryptionWorker:t,id:C.requestId+"-init",encryptedBytes:C.map.encryptedBytes,key:C.map.key,segment:C,doneFn:g},(T)=>{C.map.bytes=T,d({type:"segmentdecryptioncomplete",segment:C}),kq(C,(M)=>{if(M)return r4(e),g(M,C);O()})});O()}}},cH=({loadendState:e,abortFn:t})=>(a)=>{if(a.target.aborted&&t&&!e.calledAbortFn)t(),e.calledAbortFn=!0},hH=({segment:e,progressFn:t,trackInfoFn:a,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:i,id3Fn:l,captionsFn:f,isEndOfTimeline:c,endedTimelineFn:h,dataFn:u})=>(g)=>{if(g.target.aborted)return;if(e.stats=Gt(e.stats,aH(g)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived)e.stats.firstBytesReceivedAt=Date.now();return t(g,e)},uH=({xhr:e,xhrOptions:t,decryptionWorker:a,segment:n,abortFn:s,progressFn:i,trackInfoFn:l,timingInfoFn:f,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:h,id3Fn:u,captionsFn:g,isEndOfTimeline:b,endedTimelineFn:d,dataFn:j,doneFn:A,onTransmuxerLog:S,triggerSegmentEventFn:C})=>{let O=[],T=oH({activeXhrs:O,decryptionWorker:a,trackInfoFn:l,timingInfoFn:f,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:h,id3Fn:u,captionsFn:g,isEndOfTimeline:b,endedTimelineFn:d,dataFn:j,doneFn:A,onTransmuxerLog:S,triggerSegmentEventFn:C});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 L=Gt(t,{uri:n.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),ee=jd(n,z,T,C),te={uri:n.key.resolvedUri};C({type:"segmentkeyloadstart",segment:n,keyInfo:te});let J=e(L,ee);O.push(J)}if(n.map&&!n.map.bytes){if(n.map.key&&(!n.key||n.key.resolvedUri!==n.map.key.resolvedUri)){let J=Gt(t,{uri:n.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),ae=jd(n,[n.map.key],T,C),Q={uri:n.map.key.resolvedUri};C({type:"segmentkeyloadstart",segment:n,keyInfo:Q});let Y=e(J,ae);O.push(Y)}let L=Gt(t,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:f4(n.map),requestType:"segment-media-initialization"}),ee=iH({segment:n,finishProcessingFn:T,triggerSegmentEventFn:C});C({type:"segmentloadstart",segment:n});let te=e(L,ee);O.push(te)}let M=Gt(t,{uri:n.part&&n.part.resolvedUri||n.resolvedUri,responseType:"arraybuffer",headers:f4(n),requestType:"segment"}),H=lH({segment:n,finishProcessingFn:T,responseType:M.responseType,triggerSegmentEventFn:C});C({type:"segmentloadstart",segment:n});let D=e(M,H);D.addEventListener("progress",hH({segment:n,progressFn:i,trackInfoFn:l,timingInfoFn:f,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:h,id3Fn:u,captionsFn:g,isEndOfTimeline:b,endedTimelineFn:d,dataFn:j})),O.push(D);let N={};return O.forEach((z)=>{z.addEventListener("loadend",cH({loadendState:N,abortFn:s}))}),()=>r4(O)},mm=ri("PlaylistSelector"),qd=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||""})},t1=function(e,t){if(!e)return"";let a=K.default.getComputedStyle(e);if(!a)return"";return a[t]},a1=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})},rg=function(e,t){let a,n;if(e.attributes.BANDWIDTH)a=e.attributes.BANDWIDTH;if(a=a||K.default.Number.MAX_VALUE,t.attributes.BANDWIDTH)n=t.attributes.BANDWIDTH;return n=n||K.default.Number.MAX_VALUE,a-n},mH=function(e,t){let a,n;if(e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width)a=e.attributes.RESOLUTION.width;if(a=a||K.default.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width)n=t.attributes.RESOLUTION.width;if(n=n||K.default.Number.MAX_VALUE,a===n&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH)return e.attributes.BANDWIDTH-t.attributes.BANDWIDTH;return a-n},Sq=function(e){let{main:t,bandwidth:a,playerWidth:n,playerHeight:s,playerObjectFit:i,limitRenditionByPlayerDimensions:l,playlistController:f}=e;if(!t)return;let c={bandwidth:a,width:n,height:s,limitRenditionByPlayerDimensions:l},h=t.playlists;if(ds.isAudioOnly(t))h=f.getAudioTrackPlaylists_(),c.audioOnly=!0;let u=h.map((N)=>{let z,L=N.attributes&&N.attributes.RESOLUTION&&N.attributes.RESOLUTION.width,ee=N.attributes&&N.attributes.RESOLUTION&&N.attributes.RESOLUTION.height;return z=N.attributes&&N.attributes.BANDWIDTH,z=z||K.default.Number.MAX_VALUE,{bandwidth:z,width:L,height:ee,playlist:N}});a1(u,(N,z)=>N.bandwidth-z.bandwidth),u=u.filter((N)=>!ds.isIncompatible(N.playlist));let g=u.filter((N)=>ds.isEnabled(N.playlist));if(!g.length)g=u.filter((N)=>!ds.isDisabled(N.playlist));let b=g.filter((N)=>N.bandwidth*wn.BANDWIDTH_VARIANCE<a),d=b[b.length-1],j=b.filter((N)=>N.bandwidth===d.bandwidth)[0];if(l===!1){let N=j||g[0]||u[0];if(N&&N.playlist){let z="sortedPlaylistReps";if(j)z="bandwidthBestRep";if(g[0])z="enabledPlaylistReps";return mm(`choosing ${qd(N)} using ${z} with options`,c),N.playlist}return mm("could not choose a playlist with options",c),null}let A=b.filter((N)=>N.width&&N.height);a1(A,(N,z)=>N.width-z.width);let S=A.filter((N)=>N.width===n&&N.height===s);d=S[S.length-1];let C=S.filter((N)=>N.bandwidth===d.bandwidth)[0],O,T,M;if(!C)O=A.filter((N)=>{if(i==="cover")return N.width>n&&N.height>s;return N.width>n||N.height>s}),T=O.filter((N)=>N.width===O[0].width&&N.height===O[0].height),d=T[T.length-1],M=T.filter((N)=>N.bandwidth===d.bandwidth)[0];let H;if(f.leastPixelDiffSelector){let N=A.map((z)=>{return z.pixelDiff=Math.abs(z.width-n)+Math.abs(z.height-s),z});a1(N,(z,L)=>{if(z.pixelDiff===L.pixelDiff)return L.bandwidth-z.bandwidth;return z.pixelDiff-L.pixelDiff}),H=N[0]}let D=H||M||C||j||g[0]||u[0];if(D&&D.playlist){let N="sortedPlaylistReps";if(H)N="leastPixelDiffRep";else if(M)N="resolutionPlusOneRep";else if(C)N="resolutionBestRep";else if(j)N="bandwidthBestRep";else if(g[0])N="enabledPlaylistReps";return mm(`choosing ${qd(D)} using ${N} with options`,c),D.playlist}return mm("could not choose a playlist with options",c),null},vd=function(){let e=this.useDevicePixelRatio?K.default.devicePixelRatio||1:1;if(!isNaN(this.customPixelRatio))e=this.customPixelRatio;return Sq({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(t1(this.tech_.el(),"width"),10)*e,playerHeight:parseInt(t1(this.tech_.el(),"height"),10)*e,playerObjectFit:this.usePlayerObjectFit?t1(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},gH=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?K.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 Sq({main:this.playlists.main,bandwidth:t,playerWidth:parseInt(t1(this.tech_.el(),"width"),10)*n,playerHeight:parseInt(t1(this.tech_.el(),"height"),10)*n,playerObjectFit:this.usePlayerObjectFit?t1(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},pH=function(e){let{main:t,currentTime:a,bandwidth:n,duration:s,segmentDuration:i,timeUntilRebuffer:l,currentTimeline:f,syncController:c}=e,h=t.playlists.filter((j)=>!ds.isIncompatible(j)),u=h.filter(ds.isEnabled);if(!u.length)u=h.filter((j)=>!ds.isDisabled(j));let b=u.filter(ds.hasAttribute.bind(null,"BANDWIDTH")).map((j)=>{let S=c.getSyncPoint(j,s,f,a)?1:2,O=ds.estimateSegmentRequestTime(i,n,j)*S-l;return{playlist:j,rebufferingImpact:O}}),d=b.filter((j)=>j.rebufferingImpact<=0);if(a1(d,(j,A)=>rg(A.playlist,j.playlist)),d.length)return d[0];return a1(b,(j,A)=>j.rebufferingImpact-A.rebufferingImpact),b[0]||null},bH=function(){let e=this.playlists.main.playlists.filter(ds.isEnabled);return a1(e,(a,n)=>rg(a,n)),e.filter((a)=>!!dh(this.playlists.main,a).video)[0]||null},wH=(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 Cq(e){try{return new URL(e).pathname.split("/").slice(-2).join("/")}catch(t){return""}}var dH=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||{},l=a,f=a,c=!1,h=i[n];if(h)l=h.label,f=h.language,c=h.default;e[a]=t.addRemoteTextTrack({kind:"captions",id:n,default:c,label:l,language:f},!1).track}}},jH=function({inbandTextTracks:e,captionArray:t,timestampOffset:a}){if(!t)return;let n=K.default.WebKitDataCue||K.default.VTTCue;t.forEach((s)=>{let i=s.stream;if(s.content)s.content.forEach((l)=>{let f=new n(s.startTime+a,s.endTime+a,l.text);f.line=l.line,f.align="left",f.position=l.position,f.positionAlign="line-left",e[i].addCue(f)});else e[i].addCue(new n(s.startTime+a,s.endTime+a,s.text))})},qH=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}}})},vH=({inbandTextTracks:e,metadataArray:t,timestampOffset:a,videoDuration:n})=>{if(!t)return;let s=K.default.WebKitDataCue||K.default.VTTCue,i=e.metadataTrack_;if(!i)return;if(t.forEach((u)=>{let g=u.cueTime+a;if(typeof g!=="number"||K.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,qH(d),i.addCue(d)})}),!i.cues||!i.cues.length)return;let l=i.cues,f=[];for(let u=0;u<l.length;u++)if(l[u])f.push(l[u]);let c=f.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})})},kH={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"},AH=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),yH=({inbandTextTracks:e,dateRanges:t})=>{let a=e.metadataTrack_;if(!a)return;let n=K.default.WebKitDataCue||K.default.VTTCue;t.forEach((s)=>{for(let i of Object.keys(s)){if(AH.has(i))continue;let l=new n(s.startTime,s.endTime,"");if(l.id=s.id,l.type="com.apple.quicktime.HLS",l.value={key:kH[i],data:s[i]},i==="scte35Out"||i==="scte35In")l.value.data=new Uint8Array(l.value.data.match(/[\da-f]{2}/gi)).buffer;a.addCue(l)}s.processDateRange()})},kd=(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},mh=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)},SH=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}},CH=(e,t,a)=>{if(typeof t>"u"||t===null||!e.length)return[];let n=Math.ceil((t-a+3)*Yl.ONE_SECOND_IN_TS),s;for(s=0;s<e.length;s++)if(e[s].pts>n)break;return e.slice(s)},_H=(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)},FH=(e,t,a,n)=>{let s=Math.ceil((t-n)*Yl.ONE_SECOND_IN_TS),i=Math.ceil((a-n)*Yl.ONE_SECOND_IN_TS),l=e.slice(),f=e.length;while(f--)if(e[f].pts<=i)break;if(f===-1)return l;let c=f+1;while(c--)if(e[c].pts<=s)break;return c=Math.max(c,0),l.splice(c,f-c+1),l},OH=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},BH=function(e,t,a){t=t||[];let n=[],s=0;for(let i=0;i<t.length;i++){let l=t[i];if(e===l.timeline){if(n.push(i),s+=l.duration,s>a)return i}}if(n.length===0)return 0;return n[n.length-1]},hh=1,TH=500,Ad=(e)=>typeof e==="number"&&isFinite(e),gm=0.016666666666666666,MH=(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},HH=(e,t,a)=>{let n=t-wn.BACK_BUFFER_LENGTH;if(e.length)n=Math.max(n,e.start(0));let s=t-a;return Math.min(s,n)},Vo=(e)=>{let{startOfSegment:t,duration:a,segment:n,part:s,playlist:{mediaSequence:i,id:l,segments:f=[]},mediaIndex:c,partIndex:h,timeline:u}=e,g=f.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?Kj({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 [${l}]`},yd=(e)=>`${e}TimingInfo`,xH=({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},o4=({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},DH=(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},RH=(e)=>{let t=e.timelineChangeController_.pendingTimelineChange({type:"audio"}),a=e.timelineChangeController_.pendingTimelineChange({type:"main"});return t&&a&&t.to<a.to},Kl=(e)=>{let t=e.pendingSegment_;if(!t)return;if(o4({timelineChangeController:e.timelineChangeController_,currentTimeline:e.currentTimeline_,segmentTimeline:t.timeline,loaderType:e.loaderType_,audioDisabled:e.audioDisabled_})&&DH(e.timelineChangeController_)){if(RH(e)){e.timelineChangeController_.trigger("audioTimelineBehind");return}e.timelineChangeController_.trigger("fixBadTimelineChange")}},NH=(e)=>{let t=0;if(["video","audio"].forEach(function(a){let n=e[`${a}TimingInfo`];if(!n)return;let{start:s,end:i}=n,l;if(typeof s==="bigint"||typeof i==="bigint")l=K.default.BigInt(i)-K.default.BigInt(s);else if(typeof s==="number"&&typeof i==="number")l=i-s;if(typeof l<"u"&&l>t)t=l}),typeof t==="bigint"&&t<Number.MAX_SAFE_INTEGER)t=Number(t);return t},Sd=({segmentDuration:e,maxDuration:t})=>{if(!e)return!1;return Math.round(e)>t+$i},zH=(e,t)=>{if(t!=="hls")return null;let a=NH({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo});if(!a)return null;let n=e.playlist.targetDuration,s=Sd({segmentDuration:a,maxDuration:n*2}),i=Sd({segmentDuration:a,maxDuration:n}),l=`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:l};return null},cr=({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 Rm 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_=ri(`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 Kl(this)}),this.sourceUpdater_.on("codecschange",(a)=>{this.trigger(va({type:"codecschange"},a))}),this.loaderType_==="main")this.timelineChangeController_.on("pendingtimelinechange",()=>{if(this.hasEnoughInfoToAppend_())this.processCallQueue_();else Kl(this)});if(this.loaderType_==="audio")this.timelineChangeController_.on("timelinechange",(a)=>{if(this.trigger(va({type:"timelinechange"},a)),this.hasEnoughInfoToLoad_())this.processLoadQueue_();else Kl(this);if(this.hasEnoughInfoToAppend_())this.processCallQueue_();else Kl(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return U6.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_)K.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,K.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_)U6.reset(this.transmuxer_);this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){let e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return dn();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=xm(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=oq(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: ${E6(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 l=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!l.parts||!l.parts.length||!l.parts[this.partIndex])){let f=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=f}}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_)K.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_)U6.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_=FH(this.gopBuffer_,e,t,this.timeMapping_),s++,this.sourceUpdater_.removeVideo(e,t,i);for(let l in this.inbandTextTracks_)mh(e,t,this.inbandTextTracks_[l]);mh(e,t,this.segmentMetadataTrack_),i()}monitorBuffer_(){if(this.checkBufferTimeout_)K.default.clearTimeout(this.checkBufferTimeout_);this.checkBufferTimeout_=K.default.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){if(this.state==="READY")this.fillBuffer_();if(this.checkBufferTimeout_)K.default.clearTimeout(this.checkBufferTimeout_);this.checkBufferTimeout_=K.default.setTimeout(this.monitorBufferTick_.bind(this),TH)}fillBuffer_(){if(this.sourceUpdater_.updating())return;let e=this.chooseNextRequest_();if(!e)return;let t={segmentInfo:cr({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=E6(e)||0,a=ng(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 l={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:Boolean(!this.syncPoint_)};if(l.isSyncRequest)l.mediaIndex=BH(this.currentTimeline_,i,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${l.mediaIndex}`);else if(this.mediaIndex!==null){let g=i[this.mediaIndex],b=typeof this.partIndex==="number"?this.partIndex:-1;if(l.startOfSegment=g.end?g.end:t,g.parts&&g.parts[b+1])l.mediaIndex=this.mediaIndex,l.partIndex=b+1;else l.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=ds.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}l.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${j}`:`currentTime ${j}`,l.mediaIndex=g,l.startOfSegment=d,l.partIndex=b,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${l.mediaIndex} `)}let f=i[l.mediaIndex],c=f&&typeof l.partIndex==="number"&&f.parts&&f.parts[l.partIndex];if(!f||typeof l.partIndex==="number"&&!c)return null;if(typeof l.partIndex!=="number"&&f.parts)l.partIndex=0,c=f.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(l.partIndex===0){let g=i[l.mediaIndex-1],b=g.parts&&g.parts.length&&g.parts[g.parts.length-1];if(b&&b.independent)l.mediaIndex-=1,l.partIndex=g.parts.length-1,l.independent="previous segment"}else if(f.parts[l.partIndex-1].independent)l.partIndex-=1,l.independent="previous part"}let u=this.mediaSource_&&this.mediaSource_.readyState==="ended";if(l.mediaIndex>=i.length-1&&u&&!this.seeking_())return null;if(this.shouldForceTimestampOffsetAfterResync_)this.shouldForceTimestampOffsetAfterResync_=!1,l.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync");return this.generateSegmentInfo_(l)}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:l,forceTimestampOffset:f,getMediaInfoForTime:c}=e,h=a.segments[n],u=typeof l==="number"&&h.parts[l],g={requestId:"segment-loader-"+Math.random(),uri:u&&u.resolvedUri||h.resolvedUri,mediaIndex:n,partIndex:u?l: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 f<"u"?f:this.isPendingTimestampOffset_;g.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:h.timeline,currentTimeline:this.currentTimeline_,startOfSegment:s,buffered:this.buffered_(),overrideCheck:b});let d=E6(this.sourceUpdater_.audioBuffered());if(typeof d==="number")g.audioAppendStart=d-this.sourceUpdater_.audioTimestampOffset();if(this.sourceUpdater_.videoBuffered().length)g.gopsToAlignWith=CH(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_);return g}timestampOffsetForSegment_(e){return xH(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=ds.estimateSegmentRequestTime(n,a,this.playlist_,e.bytesReceived),i=aM(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(s<=i)return;let l=pH({main:this.vhs_.playlists.main,currentTime:t,bandwidth:a,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:i,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!l)return;let c=s-i-l.rebufferingImpact,h=0.5;if(i<=$i)h=1;if(!l.playlist||l.playlist.uri===this.playlist_.uri||c<h)return;this.bandwidth=l.playlist.attributes.BANDWIDTH*wn.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort")}handleAbort_(e){this.logger_(`Aborting ${Vo(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:cr({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||{},!OH(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 Kl(this)}handleTimingInfo_(e,t,a,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;let s=this.pendingSegment_,i=yd(t);if(s[i]=s[i]||{},s[i][a]=n,this.logger_(`timinginfo: ${t} - ${a} - ${n}`),this.hasEnoughInfoToAppend_())this.processCallQueue_();else Kl(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 l=s[i.stream];l.startTime=Math.min(l.startTime,i.startTime+n),l.endTime=Math.max(l.endTime,i.endTime+n),l.captions.push(i)}),Object.keys(s).forEach((i)=>{let{startTime:l,endTime:f,captions:c}=s[i],h=this.inbandTextTracks_;this.logger_(`adding cues from ${l} -> ${f} for ${i}`),dH(h,this.vhs_.tech_,i),mh(l,f,h[i]),jH({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(o4({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(o4({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_()){Kl(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[yd(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=xm(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: "+hr(s).join(", "));if(i.length>1)this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+hr(i).join(", "));let l=s.length?s.start(0):0,f=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(f-l<=hh&&h-c<=hh){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${a.byteLength}, audio buffer: ${hr(s).join(", ")}, video buffer: ${hr(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_()-hh;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 ${hh}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=K.default.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},hh*1000)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:a},n){if(!n)return;if(n.code===tq){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 l=[n],f=n.byteLength;if(a)l.unshift(a),f+=a.byteLength;s=wH({bytes:f,segments:l})}let i={segmentInfo:cr({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_()){Kl(this),this.loadQueue_.push(()=>{let t=va({},e,{forceTimestampOffset:!0});va(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
- ${Cq(e.uri)}
226
- ${Vo(e)}`),t.map&&!t.map.bytes)this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0};e.abortRequests=uH({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:l,level:f,stream:c})=>{this.logger_(`${Vo(e)} logged from transmuxer stream ${c} as a ${f}: ${l}`)},triggerSegmentEventFn:({type:l,segment:f,keyInfo:c,trackInfo:h,timingInfo:u})=>{let b={segmentInfo:cr({segment:f})};if(c)b.keyInfo=c;if(h)b.trackInfo=h;if(u)b.timingInfo=u;this.trigger({type:l,metadata:b})}})}trimBackBuffer_(e){let t=HH(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},l=e.playlist.segments[e.mediaIndex-1];if(l&&l.timeline===t.timeline){if(l.videoTimingInfo)i.baseStartTime=l.videoTimingInfo.transmuxedDecodeEnd;else if(l.audioTimingInfo)i.baseStartTime=l.audioTimingInfo.transmuxedDecodeEnd}if(t.key){let f=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);i.key=this.segmentKey(t.key),i.key.iv=f}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<gm){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${gm}`);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===Pi.ABORTED)return;if(this.pause(),e.code===Pi.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_=_H(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:l,audioTimingInfo:f}){if(typeof e<"u")return e;if(!i)return f.start;let c=t.segments[a-1];if(a===0||!c||typeof c.start>"u"||c.end!==n+s)return n;return l.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,l=!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(l)e.waitingOnAppends++;if(i)this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e));if(l)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=MH(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 f={segmentInfo:cr({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:f})}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=zH(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 ${Vo(e)}`);return}}if(this.logger_(`Appended ${Vo(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"} ${Vo(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<gm){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${gm}`);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(!Ad(a)||!Ad(n))return;mh(a,n,this.segmentMetadataTrack_);let s=K.default.WebKitDataCue||K.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},l=JSON.stringify(i),f=new s(a,n,l);f.value=i,this.segmentMetadataTrack_.addCue(f)}}function V0(){}var _q=function(e){if(typeof e!=="string")return e;return e.replace(/./,(t)=>t.toUpperCase())},EH=["video","audio"],c4=(e,t)=>{let a=t[`${e}Buffer`];return a&&a.updating||t.queuePending[e]},IH=(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},n1=(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();n1("audio",t),n1("video",t)}return}if(e==="mediaSource")return;if(!t.ready()||t.mediaSource.readyState==="closed"||c4(e,t))return;if(n.type!==e){if(a=IH(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,n1(e,t);return}},Fq=(e,t)=>{let a=t[`${e}Buffer`],n=_q(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},Qi=(e,t)=>e&&t&&Array.prototype.indexOf.call(e.sourceBuffers,t)!==-1,zs={appendBuffer:(e,t,a)=>(n,s)=>{let i=s[`${n}Buffer`];if(!Qi(s.mediaSource,i))return;s.logger_(`Appending segment ${t.mediaIndex}'s ${e.length} bytes to ${n}Buffer`);try{i.appendBuffer(e)}catch(l){s.logger_(`Error with code ${l.code} `+(l.code===tq?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${t.mediaIndex} to ${n}Buffer`),s.queuePending[n]=null,a(l)}},remove:(e,t)=>(a,n)=>{let s=n[`${a}Buffer`];if(!Qi(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(!Qi(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(!Qi(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=_q(e),s=ir(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(Fq(e,t),!Qi(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=ir(e);if(!Qi(a.mediaSource,n))return;let i=e.substring(0,e.indexOf(".")),l=a.codecs[t];if(l.substring(0,l.indexOf("."))===i)return;let c={codecsChangeInfo:{from:l,to:e}};a.trigger({type:"codecschange",metadata:c}),a.logger_(`changing ${t}Buffer codec from ${l} 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)}}},Es=({type:e,sourceUpdater:t,action:a,doneFn:n,name:s})=>{t.queue.push({type:e,action:a,doneFn:n,name:s}),n1(e,t)},Cd=(e,t)=>(a)=>{let n=t[`${e}Buffered`](),s=PT(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_`])}n1(e,t)};class og extends se.EventTarget{constructor(e){super();this.mediaSource=e,this.sourceopenListener_=()=>n1("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=ri("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=Cd("video",this),this.onAudioUpdateEnd_=Cd("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){Es({type:"mediaSource",sourceUpdater:this,action:zs.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){Es({type:e,sourceUpdater:this,action:zs.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){se.log.error("removeSourceBuffer is not supported!");return}Es({type:"mediaSource",sourceUpdater:this,action:zs.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!se.browser.IS_FIREFOX&&K.default.MediaSource&&K.default.MediaSource.prototype&&typeof K.default.MediaSource.prototype.removeSourceBuffer==="function"}static canChangeType(){return K.default.SourceBuffer&&K.default.SourceBuffer.prototype&&typeof K.default.SourceBuffer.prototype.changeType==="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){se.log.error("changeType is not supported!");return}Es({type:e,sourceUpdater:this,action:zs.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(Es({type:n,sourceUpdater:this,action:zs.appendBuffer(s,a||{mediaIndex:-1},i),doneFn:t,name:"appendBuffer"}),n==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;let l=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${l.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,l.forEach((f)=>{this.appendBuffer.apply(this,f)})}}audioBuffered(){if(!Qi(this.mediaSource,this.audioBuffer))return dn();return this.audioBuffer.buffered?this.audioBuffer.buffered:dn()}videoBuffered(){if(!Qi(this.mediaSource,this.videoBuffer))return dn();return this.videoBuffer.buffered?this.videoBuffer.buffered:dn()}buffered(){let e=Qi(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=Qi(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;if(t&&!e)return this.audioBuffered();if(e&&!t)return this.videoBuffered();return tM(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=V0){Es({type:"mediaSource",sourceUpdater:this,action:zs.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=V0){if(typeof e!=="string")e=void 0;Es({type:"mediaSource",sourceUpdater:this,action:zs.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,a=V0){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){a();return}Es({type:"audio",sourceUpdater:this,action:zs.remove(e,t),doneFn:a,name:"remove"})}removeVideo(e,t,a=V0){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){a();return}Es({type:"video",sourceUpdater:this,action:zs.remove(e,t),doneFn:a,name:"remove"})}updating(){if(c4("audio",this)||c4("video",this))return!0;return!1}audioTimestampOffset(e){if(typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e)Es({type:"audio",sourceUpdater:this,action:zs.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e;return this.audioTimestampOffset_}videoTimestampOffset(e){if(typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e)Es({type:"video",sourceUpdater:this,action:zs.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e;return this.videoTimestampOffset_}audioQueueCallback(e){if(!this.audioBuffer)return;Es({type:"audio",sourceUpdater:this,action:zs.callback(e),name:"callback"})}videoQueueCallback(e){if(!this.videoBuffer)return;Es({type:"video",sourceUpdater:this,action:zs.callback(e),name:"callback"})}dispose(){if(this.trigger("dispose"),EH.forEach((e)=>{if(this.abort(e),this.canRemoveSourceBuffer())this.removeSourceBuffer(e);else this[`${e}QueueCallback`](()=>Fq(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_)this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_);this.off()}}var _d=(e)=>decodeURIComponent(escape(String.fromCharCode.apply(null,e))),UH=(e)=>{let t=new Uint8Array(e);return Array.from(t).map((a)=>a.toString(16).padStart(2,"0")).join("")},Fd=new Uint8Array(`
227
-
228
- `.split("").map((e)=>e.charCodeAt(0)));class Oq extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class Bq extends Rm{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 dn();let e=this.subtitlesTrack_.cues,t=e[0].startTime,a=e[e.length-1].startTime;return dn([[t,a]])}initSegmentForMap(e,t=!1){if(!e)return null;let a=xm(e),n=this.initSegments_[a];if(t&&!n&&e.bytes){let s=Fd.byteLength+e.bytes.byteLength,i=new Uint8Array(s);i.set(e.bytes),i.set(Fd,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){mh(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===Pi.TIMEOUT)this.handleTimeout_();if(e.code===Pi.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 K.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(l){this.stopForError({message:l.message,metadata:{errorType:se.Error.StreamingVttParserError,error:l}});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((l)=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new K.default.VTTCue(l.startTime,l.endTime,l.text):l)}),SH(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 K.default.VTTCue(n,s,a.cueText);if(a.settings)a.settings.split(" ").forEach((l)=>{let f=l.split(":"),c=f[0],h=f[1];i[c]=isNaN(h)?h:Number(h)});e.cues.push(i)})}parseVTTCues_(e){let t,a=!1;if(typeof K.default.WebVTT!=="function")throw new Oq;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}if(typeof K.default.TextDecoder==="function")t=new K.default.TextDecoder("utf8");else t=K.default.WebVTT.StringDecoder(),a=!0;let n=new K.default.WebVTT.Parser(K.default,K.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=_d(i);n.parse(i)}let s=e.bytes;if(a)s=_d(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,f=s/Yl.ONE_SECOND_IN_TS-i+t.mapping;if(e.cues.forEach((c)=>{let h=c.endTime-c.startTime,u=this.handleRollover_(c.startTime+f,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*Yl.ONE_SECOND_IN_TS,n=t*Yl.ONE_SECOND_IN_TS,s;if(n<a)s=-8589934592;else s=8589934592;while(Math.abs(a-n)>4294967296)a+=s;return a/Yl.ONE_SECOND_IN_TS}}var GH=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},XH=function(e,t,a=0){if(!e.segments)return;let n=a,s;for(let i=0;i<e.segments.length;i++){let l=e.segments[i];if(!s)s=GH(t,n+l.duration/2);if(s){if("cueIn"in l){s.endTime=n,s.adEndTime=n,n+=l.duration,s=null;continue}if(n<s.endTime){n+=l.duration;continue}s.endTime+=l.duration}else{if("cueOut"in l)s=new K.default.VTTCue(n,n+l.duration,l.cueOut),s.adStartTime=n,s.adEndTime=n+parseFloat(l.cueOut),t.addCue(s);if("cueOutCont"in l){let[f,c]=l.cueOutCont.split("/").map(parseFloat);s=new K.default.VTTCue(n,n+l.duration,""),s.adStartTime=n-f,s.adEndTime=s.adStartTime+c,t.addCue(s)}}n+=l.duration}};class h4{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 Tq{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 cg{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,l=t;this.start_=i,e.forEach((f,c)=>{let h=this.storage_.get(l),u=i,g=u+f.duration,b=Boolean(h&&h.segmentSyncInfo&&h.segmentSyncInfo.isAppended),d=new h4({start:u,end:g,appended:b,segmentIndex:c});f.syncInfo=d;let j=i,A=(f.parts||[]).map((S,C)=>{let O=j,T=j+S.duration,M=Boolean(h&&h.partsSyncInfo&&h.partsSyncInfo[C]&&h.partsSyncInfo[C].isAppended),H=new h4({start:O,end:T,appended:M,segmentIndex:c,partIndex:C});return j=T,s+=`Media Sequence: ${l}.${C} | Range: ${O} --> ${T} | Appended: ${M}
230
- `,S.syncInfo=H,H});n.set(l,new Tq(d,A)),s+=`${Cq(f.resolvedUri)} | Media Sequence: ${l} | Range: ${u} --> ${g} | Appended: ${b}
231
- `,l++,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 l=0;l<s;l++){let f=t[l];i-=f.duration}return i}return a}isReliablePlaylist_(e,t){return e!==void 0&&e!==null&&Array.isArray(t)&&t.length}}class u4 extends cg{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 KH=86400,G6=[{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 l=e.getMediaSequenceSync(i);if(!l)return null;if(!l.isReliable)return null;let f=l.getSyncInfoForTime(s);if(!f)return null;return{time:f.start,partIndex:f.partIndex,segmentIndex:f.segmentIndex}}},{name:"ProgramDateTime",run:(e,t,a,n,s)=>{if(!Object.keys(e.timelineToDatetimeMappings).length)return null;let i=null,l=null,f=t4(t);s=s||0;for(let c=0;c<f.length;c++){let h=t.endList||s===0?c:f.length-(c+1),u=f[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 S=0;S<u.partIndex;S++)j+=g.parts[S].duration;let A=Math.abs(s-j);if(l!==null&&(A===0||l<A))break;l=A,i={time:j,segmentIndex:u.segmentIndex,partIndex:u.partIndex}}return i}},{name:"Segment",run:(e,t,a,n,s)=>{let i=null,l=null;s=s||0;let f=t4(t);for(let c=0;c<f.length;c++){let h=t.endList||s===0?c:f.length-(c+1),u=f[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(l!==null&&l<d)break;if(!i||l===null||l>=d)l=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 l=null;for(let f=0;f<t.discontinuityStarts.length;f++){let c=t.discontinuityStarts[f],h=t.discontinuitySequence+f+1,u=e.discontinuities[h];if(u){let g=Math.abs(s-u.time);if(l!==null&&l<g)break;if(!i||l===null||l>=g)l=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 Mq extends se.EventTarget{constructor(e={}){super();this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};let t=new cg,a=new u4(t),n=new u4(t);this.mediaSequenceStorage_={main:t,audio:a,vtt:n},this.logger_=ri("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,a,n,s){if(t!==1/0)return G6.find(({name:f})=>f==="VOD").run(this,e,t);let i=this.runStrategies_(e,t,a,n,s);if(!i.length)return null;for(let l of i){let{syncPoint:f,strategy:c}=l,{segmentIndex:h,time:u}=f;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: ",f),f}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+wh({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,a,n,s){let i=[];for(let l=0;l<G6.length;l++){let f=G6[l],c=f.run(this,e,t,a,n,s);if(c)c.strategy=f.name,i.push({strategy:f.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 l=Math.abs(e[i].syncPoint[t.key]-t.value);if(l<n)n=l,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>KH){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],l,f;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}]`);l=e.startOfSegment,f=t.end+i.mapping}else if(i)l=t.start+i.mapping,f=t.end+i.mapping;else return!1;if(s)s.start=l,s.end=f;if(!n.start||l<n.start)n.start=l;return n.end=f,!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,l=s-e.mediaIndex,f=Math.abs(l);if(!this.discontinuities[i]||this.discontinuities[i].accuracy>f){let c;if(l<0)c=a.start-wh({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:s});else c=a.end+wh({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:s});this.discontinuities[i]={time:c,accuracy:f}}}}dispose(){this.trigger("dispose"),this.off()}}class Hq 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 LH=pq(bq(function(){var e=function(){function A(){this.listeners={}}var S=A.prototype;return S.on=function(O,T){if(!this.listeners[O])this.listeners[O]=[];this.listeners[O].push(T)},S.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},S.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 D=Array.prototype.slice.call(arguments,1),N=T.length;for(var z=0;z<N;++z)T[z].apply(this,D)}},S.dispose=function(){this.listeners={}},S.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=[[[],[],[],[],[]],[[],[],[],[],[]]],S=A[0],C=A[1],O=S[4],T=C[4],M,H,D,N=[],z=[],L,ee,te,J,ae,Q;for(M=0;M<256;M++)z[(N[M]=M<<1^(M>>7)*283)^M]=M;for(H=D=0;!O[H];H^=L||1,D=z[D]||1){J=D^D<<1^D<<2^D<<3^D<<4,J=J>>8^J&255^99,O[H]=J,T[J]=H,te=N[ee=N[L=N[H]]],Q=te*16843009^ee*65537^L*257^H*16843008,ae=N[J]*257^J*16843008;for(M=0;M<4;M++)S[M][H]=ae=ae<<24^ae>>>8,C[M][J]=Q=Q<<24^Q>>>8}for(M=0;M<5;M++)S[M]=S[M].slice(0),C[M]=C[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 S,C,O,T=this._tables[0][4],M=this._tables[1],H=A.length,D=1;if(H!==4&&H!==6&&H!==8)throw Error("Invalid aes key size");let N=A.slice(0),z=[];this._key=[N,z];for(S=H;S<4*H+28;S++){if(O=N[S-1],S%H===0||H===8&&S%H===4){if(O=T[O>>>24]<<24^T[O>>16&255]<<16^T[O>>8&255]<<8^T[O&255],S%H===0)O=O<<8^O>>>24^D<<24,D=D<<1^(D>>7)*283}N[S]=N[S-H]^O}for(C=0;S;C++,S--)if(O=N[C&3?S:S-4],S<=4||C<4)z[C]=O;else z[C]=M[0][T[O>>>24]]^M[1][T[O>>16&255]]^M[2][T[O>>8&255]]^M[3][T[O&255]]}decrypt(A,S,C,O,T,M){let H=this._key[1],D=A^H[0],N=O^H[1],z=C^H[2],L=S^H[3],ee,te,J,ae=H.length/4-2,Q,Y=4,$=this._tables[1],fe=$[0],P=$[1],qe=$[2],be=$[3],me=$[4];for(Q=0;Q<ae;Q++)ee=fe[D>>>24]^P[N>>16&255]^qe[z>>8&255]^be[L&255]^H[Y],te=fe[N>>>24]^P[z>>16&255]^qe[L>>8&255]^be[D&255]^H[Y+1],J=fe[z>>>24]^P[L>>16&255]^qe[D>>8&255]^be[N&255]^H[Y+2],L=fe[L>>>24]^P[D>>16&255]^qe[N>>8&255]^be[z&255]^H[Y+3],Y+=4,D=ee,N=te,z=J;for(Q=0;Q<4;Q++)T[(3&-Q)+M]=me[D>>>24]<<24^me[N>>16&255]<<16^me[z>>8&255]<<8^me[L&255]^H[Y++],ee=D,D=N,N=z,z=L,L=ee}}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 l=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},f=function(A,S,C){let O=new Int32Array(A.buffer,A.byteOffset,A.byteLength>>2),T=new s(Array.prototype.slice.call(S)),M=new Uint8Array(A.byteLength),H=new Int32Array(M.buffer),D,N,z,L,ee,te,J,ae,Q;D=C[0],N=C[1],z=C[2],L=C[3];for(Q=0;Q<O.length;Q+=4)ee=l(O[Q]),te=l(O[Q+1]),J=l(O[Q+2]),ae=l(O[Q+3]),T.decrypt(ee,te,J,ae,H,Q),H[Q]=l(H[Q]^D),H[Q+1]=l(H[Q+1]^N),H[Q+2]=l(H[Q+2]^z),H[Q+3]=l(H[Q+3]^L),D=ee,N=te,z=J,L=ae;return M};class c{constructor(A,S,C,O){let T=c.STEP,M=new Int32Array(A.buffer),H=new Uint8Array(A.byteLength),D=0;this.asyncStream_=new i,this.asyncStream_.push(this.decryptChunk_(M.subarray(D,D+T),S,C,H));for(D=T;D<M.length;D+=T)C=new Uint32Array([l(M[D-4]),l(M[D-3]),l(M[D-2]),l(M[D-1])]),this.asyncStream_.push(this.decryptChunk_(M.subarray(D,D+T),S,C,H));this.asyncStream_.push(function(){O(null,t(H))})}static get STEP(){return 32000}decryptChunk_(A,S,C,O){return function(){let T=f(A,S,C);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(S){if(ArrayBuffer.isView==="function")return ArrayBuffer.isView(S);return S&&S.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]),S=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);if(S[0]===255)return"big";if(S[0]===204)return"little";return"unknown"}();let j=function(A){let S={};return Object.keys(A).forEach((C)=>{let O=A[C];if(b(O))S[C]={bytes:O.buffer,byteOffset:O.byteOffset,byteLength:O.byteLength};else S[C]=O}),S};self.onmessage=function(A){let S=A.data,C=new Uint8Array(S.encrypted.bytes,S.encrypted.byteOffset,S.encrypted.byteLength),O=new Uint32Array(S.key.bytes,S.key.byteOffset,S.key.byteLength/4),T=new Uint32Array(S.iv.bytes,S.iv.byteOffset,S.iv.byteLength/4);new c(C,O,T,function(M,H){self.postMessage(j({source:S.source,decrypted:H}),[H.buffer])})}})),VH=gq(LH),YH=(e)=>{let t=e.default?"main":"alternative";if(e.characteristics&&e.characteristics.indexOf("public.accessibility.describes-video")>=0)t="main-desc";return t},xq=(e,t)=>{if(e.abort(),e.pause(),t&&t.activePlaylistLoader)t.activePlaylistLoader.pause(),t.activePlaylistLoader=null},m4=(e,t)=>{t.activePlaylistLoader=e,e.load()},JH=(e,t)=>()=>{let{segmentLoaders:{[e]:a,main:n},mediaTypes:{[e]:s}}=t,i=s.activeTrack(),l=s.getActiveGroup(),f=s.activePlaylistLoader,c=s.lastGroup_;if(l&&c&&l.id===c.id)return;if(s.lastGroup_=l,s.lastTrack_=i,xq(a,s),!l||l.isMainPlaylist)return;if(!l.playlistLoader){if(f)n.resetEverything();return}a.resyncLoader(),m4(l.playlistLoader,s)},QH=(e,t)=>()=>{let{segmentLoaders:{[e]:a},mediaTypes:{[e]:n}}=t;n.lastGroup_=null,a.abort(),a.pause()},ZH=(e,t)=>()=>{let{mainPlaylistLoader:a,segmentLoaders:{[e]:n,main:s},mediaTypes:{[e]:i}}=t,l=i.activeTrack(),f=i.getActiveGroup(),c=i.activePlaylistLoader,h=i.lastTrack_;if(h&&l&&h.id===l.id)return;if(i.lastGroup_=f,i.lastTrack_=l,xq(n,i),!f)return;if(f.isMainPlaylist){if(!l||!h||l.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 ${l.id}`),a.pause(),s.resetEverything(),u.fastQualityChange_(g);return}if(e==="AUDIO"){if(!f.playlistLoader){s.setAudio(!0),s.resetEverything();return}n.setAudio(!0),s.setAudio(!1)}if(c===f.playlistLoader){m4(f.playlistLoader,i);return}if(n.track)n.track(l);n.resetEverything(),m4(f.playlistLoader,i)},Nm={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:a},excludePlaylist:n}=t,s=a.activeTrack(),i=a.activeGroup(),l=(i.filter((c)=>c.default)[0]||i[0]).id,f=a.tracks[l];if(s===f){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]===f;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()}},Od={AUDIO:(e,t,a)=>{if(!t)return;let{tech:n,requestOptions:s,segmentLoaders:{[e]:i}}=a;t.on("loadedmetadata",()=>{let l=t.media();if(i.playlist(l,s),!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",Nm[e](e,a))},SUBTITLES:(e,t,a)=>{let{tech:n,requestOptions:s,segmentLoaders:{[e]:i},mediaTypes:{[e]:l}}=a;t.on("loadedmetadata",()=>{let f=t.media();if(i.playlist(f,s),i.track(l.activeTrack()),!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",Nm[e](e,a))}},$H={AUDIO:(e,t)=>{let{vhs:a,sourceType:n,segmentLoaders:{[e]:s},requestOptions:i,main:{mediaGroups:l},mediaTypes:{[e]:{groups:f,tracks:c,logger_:h}},mainPlaylistLoader:u}=t,g=_h(u.main);if(!l[e]||Object.keys(l[e]).length===0){if(l[e]={main:{default:{default:!0}}},g)l[e].main.default.playlists=u.main.playlists}for(let b in l[e]){if(!f[b])f[b]=[];for(let d in l[e][b]){let j=l[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 ur(j.playlists[0],a,i);else if(j.resolvedUri)A=new ur(j.resolvedUri,a,i);else if(j.playlists&&n==="dash")A=new Dm(j.playlists[0],a,i,u);else A=null;if(j=Gt({id:d,playlistLoader:A},j),Od[e](e,j.playlistLoader,t),f[b].push(j),typeof c[d]>"u"){let S=new se.AudioTrack({id:d,kind:YH(j),enabled:!1,language:j.language,default:j.default,label:d});c[d]=S}}}s.on("error",Nm[e](e,t))},SUBTITLES:(e,t)=>{let{tech:a,vhs:n,sourceType:s,segmentLoaders:{[e]:i},requestOptions:l,main:{mediaGroups:f},mediaTypes:{[e]:{groups:c,tracks:h}},mainPlaylistLoader:u}=t;for(let g in f[e]){if(!c[g])c[g]=[];for(let b in f[e][g]){if(!n.options_.useForcedSubtitles&&f[e][g][b].forced)continue;let d=f[e][g][b],j;if(s==="hls")j=new ur(d.resolvedUri,n,l);else if(s==="dash"){if(!d.playlists.filter((S)=>S.excludeUntil!==1/0).length)return;j=new Dm(d.playlists[0],n,l,u)}else if(s==="vhs-json")j=new ur(d.playlists?d.playlists[0]:d.resolvedUri,n,l);if(d=Gt({id:b,playlistLoader:j},d),Od[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",Nm[e](e,t))},"CLOSED-CAPTIONS":(e,t)=>{let{tech:a,main:{mediaGroups:n},mediaTypes:{[e]:{groups:s,tracks:i}}}=t;for(let l in n[e]){if(!s[l])s[l]=[];for(let f in n[e][l]){let c=n[e][l][f];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;let h=a.options_.vhs&&a.options_.vhs.captionServices||{},u={label:f,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(h[u.instreamId])u=Gt(u,h[u.instreamId]);if(u.default===void 0)delete u.default;if(s[l].push(Gt({id:f},c)),typeof i[f]>"u"){let g=a.addRemoteTextTrack({id:u.instreamId,kind:"captions",default:u.default,language:u.language,label:u.label},!1).track;i[f]=g}}}}},Dq=(e,t)=>{for(let a=0;a<e.length;a++){if(lg(t,e[a]))return!0;if(e[a].playlists&&Dq(e[a].playlists,t))return!0}return!1},WH=(e,t)=>(a)=>{let{mainPlaylistLoader:n,mediaTypes:{[e]:{groups:s}}}=t,i=n.media();if(!i)return null;let l=null;if(i.attributes[e])l=s[i.attributes[e]];let f=Object.keys(s);if(!l){if(e==="AUDIO"&&f.length>1&&_h(t.main))for(let c=0;c<f.length;c++){let h=s[f[c]];if(Dq(h,i)){l=h;break}}else if(s.main)l=s.main;else if(f.length===1)l=s[f[0]]}if(typeof a>"u")return l;if(a===null||!l)return null;return l.filter((c)=>c.id===a.id)[0]||null},PH={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}},ex=(e,{mediaTypes:t})=>()=>{let a=t[e].activeTrack();if(!a)return null;return t[e].activeGroup(a)},tx=(e)=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((h)=>{$H[h](h,e)});let{mediaTypes:t,mainPlaylistLoader:a,tech:n,vhs:s,segmentLoaders:{["AUDIO"]:i,main:l}}=e;["AUDIO","SUBTITLES"].forEach((h)=>{t[h].activeGroup=WH(h,e),t[h].activeTrack=PH[h](h,e),t[h].onGroupChanged=JH(h,e),t[h].onGroupChanging=QH(h,e),t[h].onTrackChanged=ZH(h,e),t[h].getActiveGroup=ex(h,e)});let f=t.AUDIO.activeGroup();if(f){let h=(f.filter((g)=>g.default)[0]||f[0]).id;if(t.AUDIO.tracks[h].enabled=!0,t.AUDIO.onGroupChanged(),t.AUDIO.onTrackChanged(),!t.AUDIO.getActiveGroup().playlistLoader)l.setAudio(!0);else l.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])},ax=()=>{let e={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((t)=>{e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:V0,activeTrack:V0,getActiveGroup:V0,onGroupChanged:V0,onTrackChanged:V0,lastTrack_:null,logger_:ri(`MediaGroups[${t}]`)}}),e};class g4{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_=ws(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 Rq extends se.EventTarget{constructor(e,t){super();this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new g4,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_=ri("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=ws(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 l;try{l=JSON.parse(this.request_.responseText)}catch(c){let h={errorType:se.Error.StreamingContentSteeringParserError,error:c};this.trigger({type:"error",metadata:h})}this.assignSteeringProperties_(l);let f={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:f}),this.startTTLTimeout_()})}setProxyServerUrl_(e){let t=new K.default.URL(e),a=new K.default.URL(this.proxyServerUrl_);return a.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(a.toString())}decodeDataUriManifest_(e){let t=JSON.parse(K.default.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){let t=new K.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_=K.default.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){K.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 g4}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&&(ws(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}var nx=(e,t)=>{let a=null;return(...n)=>{clearTimeout(a),a=setTimeout(()=>{e.apply(null,n)},t)}},sx=10,K0,ix=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],lx=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},fx=function({currentPlaylist:e,buffered:t,currentTime:a,nextPlaylist:n,bufferLowWaterLine:s,bufferHighWaterLine:i,duration:l,bufferBasedABR:f,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(Jo(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=ng(t,a),b=f?wn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:wn.MAX_BUFFER_LOW_WATER_LINE;if(l<b)return c(`${h} as duration < max low water line (${l} < ${b})`),!0;let d=n.attributes.BANDWIDTH,j=e.attributes.BANDWIDTH;if(d<j&&(!f||g<i)){let A=`${h} as next bandwidth < current bandwidth (${d} < ${j})`;if(f)A+=` and forwardBuffer < bufferHighWaterLine (${g} < ${i})`;return c(A),!0}if((!f||d>j)&&g>=s){let A=`${h} as forwardBuffer >= bufferLowWaterLine (${g} >= ${s})`;if(f)A+=` and next bandwidth > current bandwidth (${d} > ${j})`;return c(A),!0}return c(`not ${h} as no switching criteria met`),!1};class Nq extends se.EventTarget{constructor(e){super();this.fastQualityChange_=nx(this.fastQualityChange_.bind(this),100);let{src:t,withCredentials:a,tech:n,bandwidth:s,externVhs:i,useCueTags:l,playlistExclusionDuration:f,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(K0=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_=l,this.playlistExclusionDuration=f,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_=ax(),j&&K.default.ManagedMediaSource)this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new K.default.ManagedMediaSource,this.usingManagedMediaSource_=!0,se.log("Using ManagedMediaSource");else if(K.default.MediaSource)this.mediaSource=new K.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_=dn(),this.hasPlayed_=!1,this.syncController_=new Mq(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new VH,this.sourceUpdater_=new og(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Hq,this.keyStatusMap_=new Map;let S={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 Dm(t,this.vhs_,Gt(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new ur(t,this.vhs_,Gt(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Rm(Gt(S,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new Rm(Gt(S,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new Bq(Gt(S,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((T,M)=>{function H(){n.off("vttjserror",D),T()}function D(){n.off("vttjsloaded",H),M()}n.one("vttjsloaded",H),n.one("vttjserror",D),n.addWebVttScript_()})}),e);let C=()=>{return this.mainSegmentLoader_.bandwidth};if(this.contentSteeringController_=new Rq(this.vhs_.xhr,C),this.setupSegmentLoaderListeners_(),this.bufferBasedABR)this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_());if(ix.forEach((T)=>{this[T+"_"]=lx.bind(this,T)}),this.logger_=ri("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 l={renditionInfo:{id:i,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),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((l)=>l.attributes.serviceLocation===n);if(i.length)this.mediaTypes_[e].activePlaylistLoader.media(i[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=K.default.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){if(this.tech_.scrubbing&&this.tech_.scrubbing())return;K.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 l=a.main||n.length&&a[n[0]];for(let f in l)if(l[f].default){s={label:f};break}}if(!s)return t;let i=[];for(let l in a)if(a[l][s.label]){let f=a[l][s.label];if(f.playlists&&f.playlists.length)i.push.apply(i,f.playlists);else if(f.uri)i.push(f);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===l)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(a4(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(tx({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(a4(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(va({},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 l in a.AUDIO[i])if(!a.AUDIO[i][l].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(K0.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 fx({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:sx})});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(va({},n))}),this.audioSegmentLoader_.on(a,(n)=>{this.player_.trigger(va({},n))}),this.subtitleSegmentLoader_.on(a,(n)=>{this.player_.trigger(va({},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,l=K0.Playlist.liveEdgeDelay(i,e),f=a+l;n=Math.max(Math.min(f+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=K0.Playlist.playlistEnd(e,a),s=this.tech_.currentTime(),i=this.tech_.buffered();if(!i.length)return n-s<=Wi;let l=i.end(i.length-1);return l-s<=Wi&&n-l<=Wi}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(p9),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 l;if(e.playlistErrors_>this.maxPlaylistRetries)l=1/0;else l=Date.now()+a*1000;if(e.excludeUntil=l,t.reason)e.lastExcludeReason_=t.reason;this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});let f=this.selectPlaylist();if(!f){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 ${f.id}.`),f.attributes.AUDIO!==e.attributes.AUDIO)this.delegateLoaders_("audio",["abort","pause"]);if(f.attributes.SUBTITLES!==e.attributes.SUBTITLES)this.delegateLoaders_("subtitle",["abort","pause"]);this.delegateLoaders_("main",["abort","pause"]);let u=f.targetDuration/2*1000||5000,g=typeof f.lastRequest==="number"&&Date.now()-f.lastRequest<=u;return this.switchMedia_(f,"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 l=this.mediaTypes_[i]&&this.mediaTypes_[i].activePlaylistLoader;if(l)a.push(l)}),["main","audio","subtitle"].forEach((i)=>{let l=this[`${i}SegmentLoader_`];if(l&&(e===i||e==="all"))a.push(l)}),a.forEach((i)=>t.forEach((l)=>{if(typeof i[l]==="function")i[l]()}))}setCurrentTime(e){let t=Jo(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 K0.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:l,end:f}=n;if(!isFinite(l)||!isFinite(f))return null;let c=K0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,a),h=Math.max(l,f-c);return dn([[l,h]])}let s=this.syncController_.getExpiredTime(a,this.duration());if(s===null)return null;let i=K0.Playlist.seekable(a,s,K0.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 dn([[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 [${Gj(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=K0.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=dh(this.main(),t),n={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo)n.video=a.video||e.main.videoCodec||cb;if(e.main.isMuxed)n.video+=`,${a.audio||e.main.audioCodec||J3}`;if(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)n.audio=a.audio||e.main.audioCodec||e.audio.audioCodec||J3,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?Mo(h,this.usingManagedMediaSource_):J2(h),l={},f;if(["video","audio"].forEach(function(c){if(n.hasOwnProperty(c)&&!i(e[c].isFmp4,n[c])){let h=e[c].isFmp4?"browser":"muxer";if(l[h]=l[h]||[],l[h].push(n[c]),c==="audio")f=h}}),s&&f&&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 ${f} does not support codec(s): "${n.audio}"`)}if(Object.keys(l).length){let c=Object.keys(l).reduce((h,u)=>{if(h)h+=", ";return h+=`${u} does not support codec(s): "${l[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=(_i(this.sourceUpdater_.codecs[h]||"")[0]||{}).type,g=(_i(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=dh(this.main,n),i=[];if(s.audio&&!J2(s.audio)&&!Mo(s.audio,this.usingManagedMediaSource_))i.push(`audio codec ${s.audio}`);if(s.video&&!J2(s.video)&&!Mo(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=Ah(_i(e)),s=gd(n),i=n.video&&_i(n.video)[0]||null,l=n.audio&&_i(n.audio)[0]||null;Object.keys(a).forEach((f)=>{let c=a[f];if(t.indexOf(c.id)!==-1||c.excludeUntil===1/0)return;t.push(c.id);let h=[],u=dh(this.mainPlaylistLoader_.main,c),g=gd(u);if(!u.audio&&!u.video)return;if(g!==s)h.push(`codec count "${g}" !== "${s}"`);if(!this.sourceUpdater_.canChangeType()){let b=u.video&&_i(u.video)[0]||null,d=u.audio&&_i(u.audio)[0]||null;if(b&&i&&b.type.toLowerCase()!==i.type.toLowerCase())h.push(`video codec "${b.type}" !== "${i.type}"`);if(d&&l&&d.type.toLowerCase()!==l.type.toLowerCase())h.push(`audio codec "${d.type}" !== "${l.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);XH(e,this.cueTagsTrack_,t)}goalBufferLength(){let e=this.tech_.currentTime(),t=wn.GOAL_BUFFER_LENGTH,a=wn.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,wn.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*a,n)}bufferLowWaterLine(){let e=this.tech_.currentTime(),t=wn.BUFFER_LOW_WATER_LINE,a=wn.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,wn.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(t,wn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*a,this.bufferBasedABR?s:n)}bufferHighWaterLine(){return wn.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){kd(this.inbandTextTracks_,"com.apple.streaming",this.tech_),yH({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,a){let n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();kd(this.inbandTextTracks_,e,this.tech_),vH({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(va({},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 l of t.playlists){let f=l.attributes.serviceLocation;if(f){if(i.push(f),!s.has(f))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 l=a[i],f=this.pathwayAttribute_(l),c=f&&e!==f;if(l.excludeUntil===1/0&&l.lastExcludeReason_==="content-steering"&&!c)delete l.excludeUntil,delete l.lastExcludeReason_,s=!0;let u=!l.excludeUntil&&l.excludeUntil!==1/0;if(!(!n.has(l.id)&&c&&u))return;n.add(l.id),l.excludeUntil=1/0,l.lastExcludeReason_="content-steering",this.logger_(`excluding ${l.id} for ${l.lastExcludeReason_}`)}),this.contentSteeringController_.manifestType_==="DASH")Object.keys(this.mediaTypes_).forEach((i)=>{let l=this.mediaTypes_[i];if(l.activePlaylistLoader){let f=l.activePlaylistLoader.media_;if(f&&f.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,l]of a.entries())if(!n.get(i))this.mainPlaylistLoader_.updateOrDeleteClone(l),this.contentSteeringController_.excludePathway(i);for(let[i,l]of n.entries()){let f=a.get(i);if(!f){t.filter((h)=>{return h.attributes["PATHWAY-ID"]===l["BASE-ID"]}).forEach((h)=>{this.mainPlaylistLoader_.addClonePathway(l,h)}),this.contentSteeringController_.addAvailablePathway(i);continue}if(this.equalPathwayClones_(f,l))continue;this.mainPlaylistLoader_.updateOrDeleteClone(l,!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 l=this.keyStatusMap_.has(s)&&this.keyStatusMap_.get(s)==="usable",f=a.lastExcludeReason_===t&&a.excludeUntil===1/0;if(!l){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(l&&f)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:UH(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 rx=(e,t,a)=>(n)=>{let s=e.main.playlists[t],i=ig(s),l=p9(s);if(typeof n>"u")return l;if(n)delete s.disabled;else s.disabled=!0;let f={renditionInfo:{id:t,bandwidth:s.attributes.BANDWIDTH,resolution:s.attributes.RESOLUTION,codecs:s.attributes.CODECS},cause:"fast-quality"};if(n!==l&&!i)if(n)a(s),e.trigger({type:"renditionenabled",metadata:f});else e.trigger({type:"renditiondisabled",metadata:f});return n};class zq{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=dh(n.main(),t),this.playlist=t,this.id=a,this.enabled=rx(e.playlists,t.id,s)}}var ox=function(e){e.representations=()=>{let t=e.playlistController_.main(),a=_h(t)?e.playlistController_.getAudioTrackPlaylists_():t.playlists;if(!a)return[];return a.filter((n)=>!ig(n)).map((n,s)=>new zq(e,n,n.id))}},Bd=["seeking","seeked","pause","playing","error"];class Eq 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_=ri("PlaybackWatcher"),this.logger_("initialize");let t=()=>this.monitorCurrentTime_(),a=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),i=this.playlistController_,l=["main","subtitle","audio"],f={};l.forEach((h)=>{f[h]={reset:()=>this.resetSegmentDownloads_(h),updateend:()=>this.checkSegmentDownloads_(h)},i[`${h}SegmentLoader_`].on("appendsdone",f[h].updateend),i[`${h}SegmentLoader_`].on("playlistupdate",f[h].reset),this.tech_.on(["seeked","seeking"],f[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(Bd,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(Bd,s),this.tech_.off("canplay",a),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach((h)=>{i[`${h}SegmentLoader_`].off("appendsdone",f[h].updateend),i[`${h}SegmentLoader_`].off("playlistupdate",f[h].reset),this.tech_.off(["seeked","seeking"],f[h].reset)}),this.checkCurrentTimeTimeout_)K.default.clearTimeout(this.checkCurrentTimeTimeout_);this.resetTimeUpdate_()}}monitorCurrentTime_(){if(this.checkCurrentTime_(),this.checkCurrentTimeTimeout_)K.default.clearTimeout(this.checkCurrentTimeTimeout_);this.checkCurrentTimeTimeout_=K.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=nM(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:hr(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+Wi>=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(dn([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:Wi)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${a} with seekable range ${Gj(t)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;let i=this.playlistController_.sourceUpdater_,l=this.tech_.buffered(),f=i.audioBuffer?i.audioBuffered():null,c=i.videoBuffer?i.videoBuffered():null,h=this.media(),u=h.partTargetDuration?h.partTargetDuration:(h.targetDuration-$i)*2,g=[f,c];for(let d=0;d<g.length;d++){if(!g[d])continue;if(ng(g[d],a)<u)return!1}let b=um(l,a);if(b.length===0)return!1;return s=b.start(0)+Wi,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=Jo(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 l=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${l}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(l),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=um(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)+Wi,i=!a.endList,l=typeof a.partTargetDuration==="number";if(i&&(l||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=Jo(e,a-3),i=Jo(e,a),l=Jo(t,a);if(l.length&&!i.length&&s.length)n={start:s.end(0),end:l.end(0)}}else if(!um(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=um(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)+$i);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=eM(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 cx={errorInterval:30,getSource(e){let a=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return e(a)}},Iq=function(e,t){let a=0,n=0,s=Gt(cx,t);e.ready(()=>{e.trigger({type:"usage",name:"vhs-error-reload-initialized"})});let i=function(){if(n)e.currentTime(n)},l=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()},f=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,l)},c=function(){e.off("loadedmetadata",i),e.off("error",f),e.off("dispose",c)},h=function(u){c(),Iq(e,u)};e.on("error",f),e.on("dispose",c),e.reloadSourceOnError=h},hx=function(e){Iq(this,e)},Uq="3.17.3",ux="7.1.0",mx="1.3.1",gx="7.2.0",px="4.0.2",ka={PlaylistLoader:ur,Playlist:ds,utils:OM,STANDARD_PLAYLIST_SELECTOR:vd,INITIAL_PLAYLIST_SELECTOR:bH,lastBandwidthSelector:vd,movingAverageBandwidthSelector:gH,comparePlaylistBandwidth:rg,comparePlaylistResolution:mH,xhr:fq()};Object.keys(wn).forEach((e)=>{Object.defineProperty(ka,e,{get(){return se.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),wn[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}wn[e]=t}})});var Gq="videojs-vhs",Xq=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"})},bx=function(e,t){t.representations().forEach((a)=>{e.addQualityLevel(a)}),Xq(e,t.playlists)};ka.canPlaySource=function(){return se.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};var wx=(e,t,a)=>{if(!e)return e;let n={};if(t&&t.attributes&&t.attributes.CODECS)n=Ah(_i(t.attributes.CODECS));if(a&&a.attributes&&a.attributes.CODECS)n.audio=a.attributes.CODECS;let s=ir(n.video),i=ir(n.audio),l={};for(let f in e){if(l[f]={},i)l[f].audioContentType=i;if(s)l[f].videoContentType=s;if(t.contentProtection&&t.contentProtection[f]&&t.contentProtection[f].pssh)l[f].pssh=t.contentProtection[f].pssh;if(typeof e[f]==="string")l[f].url=e[f]}return Gt(e,l)},dx=(e,t)=>{return e.reduce((a,n)=>{if(!n.contentProtection)return a;let s=t.reduce((i,l)=>{let f=n.contentProtection[l];if(f&&f.pssh)i[l]={pssh:f.pssh};return i},{});if(Object.keys(s).length)a.push(s);return a},[])},jx=({player:e,sourceKeySystems:t,audioMedia:a,mainPlaylists:n})=>{if(!e.eme.initializeMediaKeys)return Promise.resolve();let s=a?n.concat([a]):n,i=dx(s,Object.keys(t)),l=[],f=[];return i.forEach((c)=>{f.push(new Promise((h,u)=>{e.tech_.one("keysessioncreated",h)})),l.push(new Promise((h,u)=>{e.eme.initializeMediaKeys({keySystems:c},(g)=>{if(g){u(g);return}h()})}))}),Promise.race([Promise.all(l),Promise.race(f)])},qx=({player:e,sourceKeySystems:t,media:a,audioMedia:n})=>{let s=wx(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},Kq=()=>{if(!K.default.localStorage)return null;let e=K.default.localStorage.getItem(Gq);if(!e)return null;try{return JSON.parse(e)}catch(t){return null}},vx=(e)=>{if(!K.default.localStorage)return!1;let t=Kq();t=t?Gt(t,e):e;try{K.default.localStorage.setItem(Gq,JSON.stringify(t))}catch(a){return!1}return t},kx=(e)=>{if(e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0)return JSON.parse(e.substring(e.indexOf(",")+1));return e},Lq=(e,t)=>{if(!e._requestCallbackSet)e._requestCallbackSet=new Set;e._requestCallbackSet.add(t)},Vq=(e,t)=>{if(!e._responseCallbackSet)e._responseCallbackSet=new Set;e._responseCallbackSet.add(t)},Yq=(e,t)=>{if(!e._requestCallbackSet)return;if(e._requestCallbackSet.delete(t),!e._requestCallbackSet.size)delete e._requestCallbackSet},Jq=(e,t)=>{if(!e._responseCallbackSet)return;if(e._responseCallbackSet.delete(t),!e._responseCallbackSet.size)delete e._responseCallbackSet};ka.supportsNativeHls=function(){if(!Se.default||!Se.default.createElement)return!1;let e=Se.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))})}();ka.supportsNativeDash=function(){if(!Se.default||!Se.default.createElement||!se.getTech("Html5").isSupported())return!1;return/maybe|probably/i.test(Se.default.createElement("video").canPlayType("application/dash+xml"))}();ka.supportsTypeNatively=(e)=>{if(e==="hls")return ka.supportsNativeHls;if(e==="dash")return ka.supportsNativeDash;return!1};ka.isSupported=function(){return se.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};ka.xhr.onRequest=function(e){Lq(ka.xhr,e)};ka.xhr.onResponse=function(e){Vq(ka.xhr,e)};ka.xhr.offRequest=function(e){Yq(ka.xhr,e)};ka.xhr.offResponse=function(e){Jq(ka.xhr,e)};var Ax=se.getComponent("Component");class hg extends Ax{constructor(e,t,a){super(t,a.vhs);if(typeof a.initialBandwidth==="number")this.options_.bandwidth=a.initialBandwidth;if(this.logger_=ri("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(Se.default,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(n)=>{let s=Se.default.fullscreenElement||Se.default.webkitFullscreenElement||Se.default.mozFullScreenElement||Se.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_=Gt(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=Kq();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=wn.INITIAL_BANDWIDTH;this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===wn.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=kx(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=ka,this.options_.sourceType=Q3(t),this.options_.seekTo=(s)=>{this.tech_.setCurrentTime(s)},this.options_.player_=this.player_,this.playlistController_=new Nq(this.options_);let a=Gt({liveRangeSafeTimeDelta:Wi},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new Eq(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?ka.movingAverageBandwidthSelector(0.55):ka.STANDARD_PLAYLIST_SELECTOR;if(this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=ka.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=K.default.navigator.connection||K.default.navigator.mozConnection||K.default.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&i){let f=i.downlink*1000*1000;if(f>=l&&s>=l)s=Math.max(s,f);else s=f}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:()=>hr(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:()=>hr(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)vx({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{ox(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_=K.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"),jx({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=qx({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",()=>{bx(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Xq(this.qualityLevels_,this.playlists)})}static version(){return{"@videojs/http-streaming":Uq,"mux.js":ux,"mpd-parser":mx,"m3u8-parser":gx,"aes-decrypter":px}}version(){return this.constructor.version()}canChangeType(){return og.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_&&K.default.URL.revokeObjectURL)K.default.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null;if(this.tech_)this.tech_.off("waitingforkey",this.handleWaitingForKey_);super.dispose()}convertToProgramTime(e,t){return RM({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,a=!0,n=2){return uq({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)=>{Lq(this.xhr,e)},this.xhr.onResponse=(e)=>{Vq(this.xhr,e)},this.xhr.offRequest=(e)=>{Yq(this.xhr,e)},this.xhr.offResponse=(e)=>{Jq(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(va({},n))})}),t.forEach((a)=>{this.playbackWatcher_.on(a,(n)=>{this.player_.trigger(va({},n))})})}}var zm={name:"videojs-http-streaming",VERSION:Uq,canHandleSource(e,t={}){let a=Gt(se.options,t);if(!a.vhs.experimentalUseMMS&&!Mo("avc1.4d400d,mp4a.40.2",!1))return!1;return zm.canPlayType(e.type,a)},handleSource(e,t,a={}){let n=Gt(se.options,a);return t.vhs=new hg(e,t,n),t.vhs.xhr=fq(),t.vhs.setupXhrHooks_(),t.vhs.src(e.src,e.type),t.vhs},canPlayType(e,t){let a=Q3(e);if(!a)return"";let n=zm.getOverrideNative(t);return!ka.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}},yx=()=>{return Mo("avc1.4d400d,mp4a.40.2",!0)};if(yx())se.getTech("Html5").registerSourceHandler(zm,0);se.VhsHandler=hg;se.VhsSourceHandler=zm;se.Vhs=ka;if(!se.use)se.registerComponent("Vhs",ka);se.options.vhs=se.options.vhs||{};if(!se.getPlugin||!se.getPlugin("reloadSourceOnError"))se.registerPlugin("reloadSourceOnError",hx);var vs=Mt(Za(),1);var Sx=1000;function w9(e,t,a,n){let[s,i]=vs.useState(0),l=vs.useRef(!1),f=vs.useRef(!1),c=vs.useRef(null),h=vs.useRef(s);h.current=s,vs.useEffect(()=>{let g=e.current;if(!g)return;let b=()=>{f.current=!0},d=()=>{f.current=!1};return g.addEventListener("play",b),g.addEventListener("pause",d),f.current=!g.paused,()=>{g.removeEventListener("play",b),g.removeEventListener("pause",d)}},[e.current]),vs.useEffect(()=>{let g=e.current;if(!g)return;let b=null,d=null,j=!0,A=Date.now(),S=!1,C=-1,O=()=>{A=Date.now(),S=!1,C=-1},T=()=>{if(!j)return;if(g.paused||g.ended)return;let N=g,z=!!N.requestVideoFrameCallback,L=ug(t),ee=Date.now()-A,te=S&&ee>L,J=!S&&ee>Sx;if(n||!z||te||J){let Q=Math.floor(g.currentTime*t+0.45),Y=Math.max(0,Math.min(Q,a-1));i(Y)}if(d=requestAnimationFrame(T),N.requestVideoFrameCallback&&b===null)b=N.requestVideoFrameCallback((Q,Y)=>{b=null,A=Date.now(),S=!0,C=Y.mediaTime;let $=Math.floor(Y.mediaTime*t+0.45),fe=Math.max(0,Math.min($,a-1));i(fe)})},M=()=>{O(),T()},H=()=>{if(b!==null){let J=g;if(J.cancelVideoFrameCallback)try{J.cancelVideoFrameCallback(b)}catch{}b=null}if(d!==null)cancelAnimationFrame(d),d=null;let N=ug(t),L=S&&C>=0&&Date.now()-A<=N?C:g.currentTime,ee=Math.floor(L*t+0.45),te=Math.max(0,Math.min(ee,a-1));if(i(te),!g.ended){let J=b9(te,t);g.currentTime=J}},D=()=>{i(a-1)};if(g.addEventListener("play",M),g.addEventListener("pause",H),g.addEventListener("ended",D),!g.paused)O(),T();return()=>{if(j=!1,g.removeEventListener("play",M),g.removeEventListener("pause",H),g.removeEventListener("ended",D),b!==null){let N=g;if(N.cancelVideoFrameCallback)try{N.cancelVideoFrameCallback(b)}catch{}}if(d!==null)cancelAnimationFrame(d)}},[e.current,t,a]);let u=vs.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(l.current){c.current=j,i(j);return}l.current=!0,i(j);let A=async(S)=>{let C=b9(S,t),O=!b.paused;if(b.currentTime=C,await new Promise((D)=>{let N=null,z=()=>{if(N)clearTimeout(N);b.removeEventListener("seeked",z),D()};b.addEventListener("seeked",z),N=setTimeout(()=>{b.removeEventListener("seeked",z),D()},500)}),!O&&!f.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((D,N)=>{let z=Math.floor(N.mediaTime*t+0.45),L=Math.max(0,Math.min(z,a-1));i(L)});if(c.current!==null){let D=c.current;c.current=null,await A(D)}else l.current=!1};await A(j)},[e,t,a]);return vs.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]),vs.useEffect(()=>{let g=e.current;if(!g)return;let b=()=>{if(!l.current){let d=Math.floor(g.currentTime*t+0.45),j=Math.max(0,Math.min(d,a-1));i(j);let A=b9(j,t),S=1/t;if(Math.abs(g.currentTime-A)>S/4)g.currentTime=A}};return g.addEventListener("seeked",b),()=>{g.removeEventListener("seeked",b)}},[e.current,t,a]),{currentFrame:s,setCurrentFrame:i,seekToFrame:u,isSeeking:l}}var Qq=Mt(Za(),1);function Zq({className:e,defaultValue:t,value:a,min:n=0,max:s=100,...i}){let l=Qq.useMemo(()=>Array.isArray(a)?a:Array.isArray(t)?t:[n,s],[a,t,n,s]);return he(Fh.Root,{"data-slot":"slider",defaultValue:t,value:a,min:n,max:s,className:jn("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[I(Fh.Track,{"data-slot":"slider-track",className:jn("relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:I(Fh.Range,{"data-slot":"slider-range",className:jn("absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:l.length},(f,c)=>I(Fh.Thumb,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}var es=Mt(Za(),1);var Cx=(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}`},_x=({totalFrames:e,currentFrame:t,fps:a,previewUrl:n,onSeek:s,buffered:i=0,metadata:l})=>{let f=es.useRef(null),c=es.useRef(null),[h,u]=es.useState(null),[g,b]=es.useState(!1),[d,j]=es.useState(!1),A=es.useRef(s);es.useEffect(()=>{A.current=s},[s]),es.useEffect(()=>{if(c.current&&n)c.current.load()},[n]);let S=es.useCallback((ee)=>{if(!f.current)return 0;let te=f.current.getBoundingClientRect();return Math.max(0,Math.min(ee-te.left,te.width))/te.width},[]),C=es.useCallback((ee)=>{if(d)return;if(!f.current)return;let te=f.current.getBoundingClientRect(),ae=Math.max(0,Math.min(ee.clientX-te.left,te.width))/te.width;if(u(ae),b(!0),c.current&&e){let Q=ae*e,Y=1/a,$=Q*Y+Y/2,fe=c.current;if(Number.isFinite($))fe.currentTime=$}},[e,a,d]),O=()=>{if(!d)b(!1),u(null)},T=(ee)=>{if(ee.button!==0)return;ee.preventDefault(),j(!0);let te=S(ee.clientX);u(te),b(!0),A.current(te*e)},M=(ee)=>{j(!0);let te=S(ee.touches[0].clientX);u(te),b(!0),A.current(te*e)};es.useEffect(()=>{if(!d)return;let ee=(Q)=>{let Y=S(Q.clientX);if(u(Y),b(!0),c.current&&e){let $=Y*e,fe=1/a,P=$*fe+fe/2,qe=c.current;if(Number.isFinite(P))qe.currentTime=P}A.current(Y*e)},te=(Q)=>{j(!1);let Y=!1;if(f.current){let fe=f.current.getBoundingClientRect();Y=Q.clientX>=fe.left&&Q.clientX<=fe.right&&Q.clientY>=fe.top&&Q.clientY<=fe.bottom}if(!Y)b(!1),u(null);let $=S(Q.clientX);A.current($*e)},J=(Q)=>{if(Q.touches.length===0)return;let Y=S(Q.touches[0].clientX);if(u(Y),b(!0),c.current&&e){let $=Y*e,fe=1/a,P=$*fe+fe/2,qe=c.current;if(Number.isFinite(P))qe.currentTime=P}A.current(Y*e)},ae=(Q)=>{j(!1);let Y=Q.changedTouches.length>0?Q.changedTouches[0].clientX:null,$=Q.changedTouches.length>0?Q.changedTouches[0].clientY:null,fe=!1;if(Y!==null&&$!==null&&f.current){let P=f.current.getBoundingClientRect();fe=Y>=P.left&&Y<=P.right&&$>=P.top&&$<=P.bottom}if(!fe)b(!1),u(null);if(Y!==null){let P=S(Y);A.current(P*e)}};return window.addEventListener("mousemove",ee),window.addEventListener("mouseup",te),window.addEventListener("touchmove",J,{passive:!0}),window.addEventListener("touchend",ae),()=>{window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",te),window.removeEventListener("touchmove",J),window.removeEventListener("touchend",ae)}},[d,e,a,S]);let H=d&&h!==null?h*100:e>0?t/e*100:0,D=h!==null?h*100:0,N=()=>{if(h===null)return{};return{left:`${D}%`,transform:`translateX(-${D}%)`}},z=180,L={width:`${z}px`,height:"auto"};if(l&&l.originalWidth&&l.originalHeight){let{originalWidth:ee,originalHeight:te}=l;if(ee>=te){let J=z*te/ee;L={width:`${z}px`,height:`${J}px`}}else L={width:`${z*ee/te}px`,height:`${z}px`}}return he("div",{ref:f,className:"group relative h-1.5 w-full cursor-pointer touch-none rounded-full bg-muted transition-colors duration-200",onMouseMove:C,onMouseLeave:O,onMouseDown:T,onTouchStart:M,"data-testid":"seekbar",children:[I("video",{ref:c,src:n,className:"hidden",preload:"auto",muted:!0,playsInline:!0}),g&&e>0&&I("div",{className:"pointer-events-none absolute bottom-full z-50 mb-3 flex w-max flex-col",style:N(),children:he("div",{className:"relative overflow-hidden rounded-lg border-2 border-border bg-popover shadow-2xl",children:[I("video",{src:n,className:"bg-black object-cover",style:L,muted:!0,ref:(ee)=>{if(ee&&c.current)ee.currentTime=c.current.currentTime}}),I("div",{className:"absolute bottom-0 w-full bg-popover/80 py-0.5 text-center text-xs font-medium text-popover-foreground",children:Cx(h*e/a)})]})}),I("div",{className:"absolute top-0 left-0 h-full rounded-full bg-muted-foreground/30 transition-all duration-200",style:{width:`${i}%`}}),g&&I("div",{className:"absolute top-0 left-0 h-full rounded-full bg-primary/30",style:{width:`${D}%`}}),I("div",{className:"relative absolute top-0 left-0 h-full rounded-full bg-primary",style:{width:`${H}%`},"data-testid":"seekbar-fill",children:I("div",{className:jn("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")})})]})},$q=_x;var sv=({state:e,zoom:t,isControlsVisible:a,buffered:n,data:s,resolutions:i,togglePlay:l,toggleLoop:f,toggleMute:c,handleVolumeChange:h,changePlaybackRate:u,changeResolution:g,handleDownload:b,toggleFullScreen:d,onZoomChange:j,onZoomReset:A,frameRate:S,totalFrames:C,currentFrame:O,seekToFrame:T,floatOverlayInFullScreen:M=!0,onMouseEnter:H,onMouseLeave:D})=>{let{videoTimeDisplayMode:N,setVideoTimeDisplayMode:z}=So();if(!s.media?.metadata)return null;let L=e.isFullScreen&&M,ee=s.proxyType==="audio",te=i.filter((Y)=>!Y.isRaw),J=s.media?.metadata?.startTimecode,ae=Math.max(0,C-1),Q=N==="frames"?`${O} / ${ae} fr`:N==="standard"?`${zl(O,S,"standard")} / ${nv(C/S)}`:`${zl(O,S,N,J)} / ${zl(ae,S,N,J)}`;return he("div",{className:jn("transition-all duration-300 ease-in-out z-20 text-foreground",L?"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:D,children:[I("div",{className:"mb-4 px-1",children:I($q,{totalFrames:C,currentFrame:O,fps:S,buffered:n,previewUrl:s.media.videoPreview?.url,onSeek:T,metadata:{...s.media.metadata,frameRate:S}})}),he("div",{className:"flex items-center justify-between text-foreground",children:[he("div",{className:"flex items-center gap-4",children:[I("button",{onClick:l,className:"hover:text-primary transition-colors","data-testid":"play-toggle","data-playing":e.isPlaying,"aria-label":e.isPlaying?"Pause":"Play",children:e.isPlaying?I(Wq,{className:"w-6 h-6 fill-current"}):I(w1,{className:"w-6 h-6 fill-current"})}),I("button",{onClick:f,className:jn("transition-colors",e.isLooping?"text-primary":"text-muted-foreground"),title:"Loop",children:I(Pq,{className:"w-5 h-5"})}),he("div",{className:"flex items-center gap-3 group/vol",children:[I("button",{onClick:c,className:"hover:text-primary",children:e.isMuted||e.volume===0?I(av,{className:"w-6 h-6"}):I(tv,{className:"w-6 h-6"})}),I("div",{className:"w-0 overflow-hidden group-hover/vol:w-24 transition-all duration-300 ease-in-out",children:I("div",{className:"w-24 px-1",children:I(Zq,{value:e.isMuted?[0]:[e.volume],onValueChange:(Y)=>h(Y[0]),max:1,step:0.05})})})]}),he("div",{className:"flex items-center gap-1 text-sm font-medium tabular-nums select-none min-w-[100px]",children:[I("span",{className:"text-muted-foreground font-mono","data-testid":"time-readout",children:Q}),he(Pf,{modal:!1,children:[I(er,{asChild:!0,children:I("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:I(Co,{className:"h-3.5 w-3.5"})})}),he(tr,{align:"start",className:"w-40 z-30",children:[I(d9,{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Format"}),he(z0,{onClick:()=>z("standard"),className:"flex items-center justify-between cursor-pointer text-xs",children:[I("span",{children:"Standard Time"}),N==="standard"&&I(b1,{className:"h-3.5 w-3.5 text-primary"})]}),he(z0,{onClick:()=>z("frames"),className:"flex items-center justify-between cursor-pointer text-xs",children:[I("span",{children:"Frames"}),N==="frames"&&I(b1,{className:"h-3.5 w-3.5 text-primary"})]}),he(z0,{onClick:()=>z("timecode"),className:"flex items-center justify-between cursor-pointer text-xs",children:[I("span",{children:"Timecode"}),N==="timecode"&&I(b1,{className:"h-3.5 w-3.5 text-primary"})]})]})]})]})]}),he("div",{className:"relative flex items-center gap-3",children:[!ee&&he("div",{className:"flex items-center gap-1",children:[he("div",{className:"flex items-center gap-1 rounded-md bg-muted p-0.5",children:[I("button",{onClick:()=>j(t*0.8),className:"p-1 hover:text-primary rounded",title:Le.zoom_out(),children:I(El,{size:14})}),he("span",{className:"text-xs w-8 text-center tabular-nums",children:[Math.round(t*100),"%"]}),I("button",{onClick:()=>j(t*1.2),className:"p-1 hover:text-primary rounded",title:Le.zoom_in(),children:I(d1,{size:14})})]}),I("button",{onClick:A,className:"text-xs font-medium px-2 py-1 rounded bg-muted hover:text-primary transition-colors",children:Le.fit()})]}),he(Pf,{children:[I(er,{asChild:!0,children:he("button",{className:"w-8 text-sm font-bold hover:text-primary",children:[e.playbackRate,"x"]})}),I(tr,{children:[0.5,1,1.5,2].map((Y)=>he(z0,{onClick:()=>u(Y),className:jn("rounded py-1 px-2 text-left text-xs",e.playbackRate===Y?"bg-primary text-primary-foreground focus:bg-primary focus:text-primary-foreground":"text-foreground"),children:[Y,"x"]},Y))})]}),!ee&&te.length>0&&he(Pf,{children:[I(er,{asChild:!0,children:he("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:[I(ev,{className:"h-3.5 w-3.5"}),I("span",{children:e.currentResolution==="Original"?Le.original():e.currentResolution})]})}),he(tr,{children:[I(d9,{children:Le.quality()}),te.map((Y)=>he(z0,{onClick:()=>g(Y),className:jn("flex w-full items-center justify-between",e.currentResolution===Y.resolution?"text-primary font-medium":"text-foreground"),children:[I("span",{children:Y.resolution==="Original"?Le.original():Y.resolution}),he("span",{className:"pl-5 text-xs text-muted-foreground",children:[Y.width,"x",Y.height]})]},Y.resolution))]})]}),ee?I("button",{onClick:()=>b(s.media?.original?.key||""),className:"transition-colors hover:text-primary",title:Le.download(),disabled:!s.media?.original?.key,children:I(Ci,{className:"h-5 w-5"})}):he(Pf,{children:[I(er,{asChild:!0,children:I("button",{className:"transition-colors hover:text-primary",title:Le.download(),children:I(Ci,{className:"h-5 w-5"})})}),he(tr,{children:[I(d9,{children:Le.download()}),i.map((Y)=>he(z0,{onClick:()=>b(Y.key??""),className:"flex w-full items-center justify-between px-3 py-2 text-left text-sm text-foreground",children:[I("span",{children:Y.resolution==="Original"?Le.original():Y.resolution}),I("span",{className:"text-xs text-muted-foreground",children:Y.isRaw?s.name?.split(".").pop()?.toUpperCase()||"RAW":"MP4"})]},Y.resolution))]})]}),I("button",{onClick:d,className:"transition-colors hover:text-primary",title:Le.fullscreen(),children:e.isFullScreen?I(q9,{className:"h-6 w-6"}):I(j9,{className:"h-6 w-6"})})]})]})]})};var Fx=Math.PI/180;function Ox(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}var Pl=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},je={_global:Pl,version:"10.3.0",isBrowser:Ox(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return je.angleDeg?e*Fx: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 je.DD.isDragging},isTransforming(){var e,t;return(t=(e=je.Transformer)===null||e===void 0?void 0:e.isTransforming())!==null&&t!==void 0?t:!1},isDragReady(){return!!je.DD.node},releaseCanvasOnDestroy:!0,document:Pl.document,_injectGlobal(e){if(typeof Pl.Konva<"u")console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.");Pl.Konva=e}},rt=(e)=>{je[e.prototype.getClassName()]=e};je._injectGlobal(je);var Bx=`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
- `,iv=()=>{if(typeof document>"u")throw Error(Bx)};class Tn{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 Tn(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,l=this.m[1]*-a+this.m[3]*t;return this.m[0]=n,this.m[1]=s,this.m[2]=i,this.m[3]=l,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],l=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]=l,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]),l=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]=l,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],l=e*n-t*a,f={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);f.rotation=t>0?Math.acos(e/c):-Math.acos(e/c),f.scaleX=c,f.scaleY=l/c,f.skewX=(e*a+t*n)/l,f.skewY=0}else if(a!=0||n!=0){let c=Math.sqrt(a*a+n*n);f.rotation=Math.PI/2-(n>0?Math.acos(-a/c):-Math.acos(a/c)),f.scaleX=l/c,f.scaleY=c,f.skewX=0,f.skewY=(e*a+t*n)/l}return f.rotation=Z._getRotation(f.rotation),f}}var Tx="[object Array]",Mx="[object Number]",Hx="[object String]",xx="[object Boolean]",Dx=Math.PI/180,Rx=180/Math.PI,Oh="#",Nx="",zx="0",Ex="Konva warning: ",lv="Konva error: ",Ix="rgb(",mg={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]},Ux=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,v9=[],Bh=null,Gx=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)===Tx},_isNumber(e){return Object.prototype.toString.call(e)===Mx&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===Hx},_isBoolean(e){return Object.prototype.toString.call(e)===xx},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(v9.push(e),v9.length===1)Gx(function(){let t=v9;v9=[],t.forEach(function(a){a()})})},createCanvasElement(){iv();let e=document.createElement("canvas");try{e.style=e.style||{}}catch(t){}return e},createImageElement(){return iv(),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(Oh,Nx);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=zx+e;return Oh+e},isCanvasFarblingActive(){if(Bh!==null)return Bh;if(typeof document>"u")return Bh=!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 Bh=n,this.releaseCanvas(e),Bh},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 Oh+this._rgbToHex(e,t,a)},getSnappedHexColor(e){let t=this._hexToRgb(e);return Oh+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 mg)return t=mg[e],{r:t[0],g:t[1],b:t[2]};else if(e[0]===Oh)return this._hexToRgb(e.substring(1));else if(e.substr(0,4)===Ix)return t=Ux.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=mg[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,l,f,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)l=i*(1+s);else l=i+s-i*s;let h=2*i-l,u=[0,0,0];for(let g=0;g<3;g++){if(f=n+0.3333333333333333*-(g-1),f<0)f++;if(f>1)f--;if(6*f<1)c=h+(l-h)*6*f;else if(2*f<1)c=l;else if(3*f<2)c=h+(l-h)*(0.6666666666666666-f)*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*Dx},radToDeg(e){return e*Rx},_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 je.angleDeg?Z.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw Error(lv+e)},error(e){console.error(lv+e)},warn(e){if(!je.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 l,f,c,h=(e-a)*(e-a)+(t-n)*(t-n);if(h==0)l=e,f=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)l=e,f=t,c=(e-s)*(e-s)+(t-i)*(t-i);else if(u>1)l=a,f=n,c=(a-s)*(a-s)+(n-i)*(n-i);else l=e+u*(a-e),f=t+u*(n-t),c=(l-s)*(l-s)+(f-i)*(f-i)}return[l,f,c]},_getProjectionToLine(e,t,a){let n=Z.cloneObject(e),s=Number.MAX_VALUE;return t.forEach(function(i,l){if(!a&&l===t.length-1)return;let f=t[(l+1)%t.length],c=Z._getProjectionToSegment(i.x,i.y,f.x,f.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 l=t;t=e,e=l}for(let l=0;l<e.length;l+=2)n.push({x:e[l],y:e[l+1]});for(let l=0;l<t.length;l+=2)s.push({x:t[l],y:t[l+1]});let i=[];return s.forEach(function(l){let f=Z._getProjectionToLine(l,n,a);i.push(f.x),i.push(f.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(!je.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 l=0,f=0,c=0,h=0;if(typeof n==="number")l=f=c=h=Math.min(n,t/2,a/2);else l=Math.min(n[0]||0,t/2,a/2),f=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+l,i),e.lineTo(s+t-f,i),e.arc(s+t-f,i+f,f,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+l),e.arc(s+l,i+l,l,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 l=t[(i-1+a)%a],f=t[i],c=t[(i+1)%a],h={x:f.x-l.x,y:f.y-l.y},u={x:c.x-f.x,y:c.y-f.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},S={x:u.x/b,y:u.y/b},C={x:f.x-A.x*d,y:f.y-A.y*d},O={x:f.x+S.x*d,y:f.y+S.y*d};if(i===0)e.moveTo(C.x,C.y);else e.lineTo(C.x,C.y);e.arcTo(f.x,f.y,O.x,O.y,d)}}};function Xx(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 fv=",",Kx="(",Lx=")",Vx="([",Yx="])",Jx=";",Qx="()",Zx="=",rv=["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"],$x=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],Wx=100,k9=null;function gg(){if(k9!==null)return k9;try{let t=Z.createCanvasElement().getContext("2d");if(!t)return k9=!1,!1;return!!t&&"filter"in t}catch(e){return k9=!1,!1}}class j1{constructor(e){if(this.canvas=e,je.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,l,f,c;for(i=0;i<n;i++){if(l=a[i],f=l.method,f)if(c=l.args,s+=f,e)s+=Qx;else if(Z._isArray(c[0]))s+=Vx+c.join(fv)+Yx;else{if(t)c=c.map((h)=>typeof h==="number"?Math.floor(h):h);s+=Kx+c.join(fv)+Lx}else if(s+=l.property,!e)s+=Zx+l.val;s+=Jx}return s}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,a;if(t.push(e),a=t.length,a>=Wx)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,l,f,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,l,f,c)}ellipse(e,t,a,n,s,i,l,f){this._context.ellipse(e,t,a,n,s,i,l,f)}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=rv.length,a=this.setAttr,n,s,i=function(l){let f=e[l],c;e[l]=function(){return s=Xx(Array.prototype.slice.call(arguments,0)),c=f.apply(e,arguments),e._trace({method:l,args:s}),c}};for(n=0;n<t;n++)i(rv[n]);e.setAttr=function(){a.apply(e,arguments);let l=arguments[0],f=arguments[1];if(l==="shadowOffsetX"||l==="shadowOffsetY"||l==="shadowBlur")f=f/this.canvas.getPixelRatio();e._trace({property:l,val:f})}}_applyGlobalCompositeOperation(e){let t=e.attrs.globalCompositeOperation;if(!(!t||t==="source-over"))this.setAttr("globalCompositeOperation",t)}}$x.forEach(function(e){Object.defineProperty(j1.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});class pg extends j1{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,l=(n=e.getShadowOffset())!==null&&n!==void 0?n:{x:0,y:0},f=e.getAbsoluteScale(),c=this.canvas.getPixelRatio(),h=f.x*c,u=f.y*c;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",i*Math.min(Math.abs(h),Math.abs(u))),this.setAttr("shadowOffsetX",l.x*h),this.setAttr("shadowOffsetY",l.y*u)}}class bg extends j1{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 A9;function Px(){if(A9)return A9;let e=Z.createCanvasElement(),t=e.getContext("2d");return A9=function(){let a=je._global.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return a/n}(),Z.releaseCanvas(e),A9}class Th{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;let a=(e||{}).pixelRatio||je.pixelRatio||Px();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 oi extends Th{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e);this.context=new pg(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}}class qr extends Th{constructor(e={width:0,height:0}){super(e);this.hitCanvas=!0,this.context=new bg(this),this.setSize(e.width,e.height)}}var Ct={get isDragging(){let e=!1;return Ct._dragElements.forEach((t)=>{if(t.dragStatus==="dragging")e=!0}),e},justDragged:!1,get node(){let e;return Ct._dragElements.forEach((t)=>{e=t.node}),e},_dragElements:new Map,_drag(e){let t=[];Ct._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 l=i._changedPointerPositions.find((f)=>f.id===a.pointerId);if(!l)return;if(a.dragStatus!=="dragging"){let f=s.dragDistance();if(Math.max(Math.abs(l.x-a.startPointerPos.x),Math.abs(l.y-a.startPointerPos.y))<f)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=[];Ct._dragElements.forEach((a)=>{let{node:n}=a,s=n.getStage();if(e)s.setPointersPositions(e);if(!s._changedPointerPositions.find((f)=>f.id===a.pointerId))return;if(a.dragStatus==="dragging"||a.dragStatus==="stopped")Ct.justDragged=!0,je._mouseListenClick=!1,je._touchListenClick=!1,je._pointerListenClick=!1,a.dragStatus="stopped";let l=a.node.getLayer()||a.node instanceof je.Stage&&a.node;if(l&&t.indexOf(l)===-1)t.push(l)}),t.forEach((a)=>{a.draw()})},_endDragAfter(e){Ct._dragElements.forEach((t,a)=>{if(t.dragStatus==="stopped")t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0);if(t.dragStatus!=="dragging")Ct._dragElements.delete(a)})}};if(je.isBrowser)window.addEventListener("mouseup",Ct._endDragBefore,!0),window.addEventListener("touchend",Ct._endDragBefore,!0),window.addEventListener("touchcancel",Ct._endDragBefore,!0),window.addEventListener("mousemove",Ct._drag),window.addEventListener("touchmove",Ct._drag),window.addEventListener("mouseup",Ct._endDragAfter,!1),window.addEventListener("touchend",Ct._endDragAfter,!1),window.addEventListener("touchcancel",Ct._endDragAfter,!1);function ef(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 y9(e){if(e>255)return 255;else if(e<0)return 0;return Math.round(e)}function ge(){if(je.isUnminified)return function(e,t){if(!Z._isNumber(e))Z.warn(ef(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.');return e}}function tf(e){if(je.isUnminified)return function(t,a){let n=Z._isNumber(t),s=Z._isArray(t)&&t.length==e;if(!n&&!s)Z.warn(ef(t)+' is a not valid value for "'+a+'" attribute. The value should be a number or Array<number>('+e+")");return t}}function Mh(){if(je.isUnminified)return function(e,t){if(!(Z._isNumber(e)||e==="auto"))Z.warn(ef(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".');return e}}function n0(){if(je.isUnminified)return function(e,t){if(!Z._isString(e))Z.warn(ef(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.');return e}}function wg(){if(je.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(ef(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.');return e}}function ov(){if(je.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(ef(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 Mn(){if(je.isUnminified)return function(e,t){if(!(e===!0||e===!1))Z.warn(ef(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.');return e}}function cv(e){if(je.isUnminified)return function(t,a){if(t===void 0||t===null)return t;if(!Z.isObject(t))Z.warn(ef(t)+' is a not valid value for "'+a+'" attribute. The value should be an object with properties '+e);return t}}var Hh="get",xh="set",U={addGetterSetter(e,t,a,n,s){U.addGetter(e,t,a),U.addSetter(e,t,n,s),U.addOverloadedGetterSetter(e,t)},addGetter(e,t,a){let n=Hh+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])U.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,l=Z._capitalize,f=Hh+l(t),c=xh+l(t);e.prototype[f]=function(){let u={};for(let g=0;g<i;g++){let b=a[g];u[b]=this.getAttr(t+l(b))}return u};let h=cv(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+l(b),u[b])}if(!u)a.forEach((b)=>{this._setAttr(t+l(b),void 0)});if(this._fireChangeEvent(t,g,u),s)s.call(this);return this},U.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let a=Z._capitalize(t),n=xh+a,s=Hh+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=Hh+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 l=this.attrs[t];return l===void 0?a:l},U.addSetter(e,t,n,function(){Z.error(i)}),U.addOverloadedGetterSetter(e,t)},backCompat(e,t){Z.each(t,function(a,n){let s=e.prototype[n],i=Hh+Z._capitalize(a),l=xh+Z._capitalize(a);function f(){s.apply(this,arguments),Z.error('"'+a+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}e.prototype[a]=f,e.prototype[i]=f,e.prototype[l]=f})},afterSetFilter(){this._filterUpToDate=!1}};function eD(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(l){this.blurRadius(i*0.5);let f=je.Filters;if(f&&f.Blur)f.Blur.call(this,l)}}case"brightness":{let i=s.includes("%")?parseFloat(s)/100:parseFloat(s);return function(l){this.brightness(i);let f=je.Filters;if(f&&f.Brightness)f.Brightness.call(this,l)}}case"contrast":{let i=parseFloat(s);return function(l){let f=100*(Math.sqrt(i)-1);this.contrast(f);let c=je.Filters;if(c&&c.Contrast)c.Contrast.call(this,l)}}case"grayscale":return function(i){let l=je.Filters;if(l&&l.Grayscale)l.Grayscale.call(this,i)};case"sepia":return function(i){let l=je.Filters;if(l&&l.Sepia)l.Sepia.call(this,i)};case"invert":return function(i){let l=je.Filters;if(l&&l.Invert)l.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 S9="absoluteOpacity",hv="allEventListeners",Q0="absoluteTransform",uv="absoluteScale",vr="canvas",tD="Change",aD="children",nD="konva",dg="listening",sD="mouseenter",iD="mouseleave",lD="pointerenter",fD="pointerleave",rD="touchenter",oD="touchleave";var mv="set",gv="Shape",C9=" ",pv="stage",af="transform",cD="Stage",jg="visible",hD=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(C9),uD=1;class we{constructor(e){this._id=uD++,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===af||e===Q0)&&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===af||e===Q0)&&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(C9);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,a)}_getCanvasCache(){return this._cache.get(vr)}_clearSelfAndDescendantCache(e){if(this._clearCache(e),e===Q0)this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(vr)){let{scene:e,filter:t,hit:a}=this._cache.get(vr);Z.releaseCanvas(e._canvas,t._canvas,a._canvas),this._cache.delete(vr)}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,l=t.x===void 0?Math.floor(a.x):t.x,f=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)-l)>0.5?1:0,b=Math.abs(Math.round(a.y)-f)>0.5?1:0;n+=c*2+g,s+=c*2+b,l-=c,f-=c;let d=new oi({pixelRatio:i,width:n,height:s}),j=new oi({pixelRatio:i,width:0,height:0,willReadFrequently:!0}),A=new qr({pixelRatio:u,width:n,height:s}),S=d.getContext(),C=A.getContext(),O=new oi({width:d.width/d.pixelRatio+Math.abs(l),height:d.height/d.pixelRatio+Math.abs(f),pixelRatio:d.pixelRatio}),T=O.getContext();if(A.isCache=!0,d.isCache=!0,this._cache.delete(vr),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1)d.getContext()._context.imageSmoothingEnabled=!1,j.getContext()._context.imageSmoothingEnabled=!1;if(S.save(),C.save(),T.save(),S.translate(-l,-f),C.translate(-l,-f),T.translate(-l,-f),O.x=l,O.y=f,this._isUnderCache=!0,this._clearSelfAndDescendantCache(S9),this._clearSelfAndDescendantCache(uv),this.drawScene(d,this,O),this.drawHit(A,this),this._isUnderCache=!1,S.restore(),C.restore(),h)S.save(),S.beginPath(),S.rect(0,0,n,s),S.closePath(),S.setAttr("strokeStyle","red"),S.setAttr("lineWidth",5),S.stroke(),S.restore();return Z.releaseCanvas(O._canvas),this._cache.set(vr,{scene:d,filter:j,hit:A,x:l,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(vr)}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,l=-1/0,f=this.getAbsoluteTransform(t);return a.forEach(function(c){let h=f.point(c);if(n===void 0)n=i=h.x,s=l=h.y;n=Math.min(n,h.x),s=Math.min(s,h.y),i=Math.max(i,h.x),l=Math.max(l,h.y)}),{x:n,y:s,width:i-n,height:l-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,l,f,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"&&!gg();if(typeof e[g]!=="string"||!gg()){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),l=s.getImageData(0,0,n.getWidth(),n.getHeight());for(f=0;f<i;f++){if(c=e[f],typeof c==="string")c=eD(c);c.call(this,l),s.putImageData(l,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(hv);if(e.length===3)return this._delegate.apply(this,e);let s=t.split(C9);for(let i=0;i<s.length;i++){let f=s[i].split("."),c=f[0],h=f[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(C9),n=a.length,s,i,l,f,c,h;if(this._cache&&this._cache.delete(hv),!e)for(i in this.eventListeners)this._off(i);for(s=0;s<n;s++)if(l=a[s],f=l.split("."),c=f[0],h=f[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 l=0;l<i.length;l++)s=Z.cloneObject(s),s.currentTarget=i[l],a.call(i[l],s)}),this}remove(){if(this.isDragging())this.stopDrag();return Ct._dragElements.delete(this._id),Ct._dragElements.forEach((e,t)=>{if(this.isAncestorOf(e.node))Ct._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Q0),this._clearSelfAndDescendantCache(S9),this._clearSelfAndDescendantCache(uv),this._clearSelfAndDescendantCache(pv),this._clearSelfAndDescendantCache(jg),this._clearSelfAndDescendantCache(dg)}_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===aD)continue;if(a=mv+Z._capitalize(t),Z._isFunction(this[a]))this[a](e[t]);else this._setAttr(t,e[t])}}),this}isListening(){return this._getCache(dg,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(jg,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;Ct._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&&!je.hitOnDragEnabled&&(n||je.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,l;function f(h){n=[],s=h.length;for(i=0;i<s;i++){if(l=h[i],a++,l.nodeType!==gv)n=n.concat(l.getChildren().slice());if(l._id===t._id)i=s}if(n.length>0&&n[0].getDepth()<=e)f(n)}let c=this.getStage();if(t.nodeType!==cD&&c)f(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(af),this._clearSelfAndDescendantCache(Q0);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 Tn,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(af);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(af),this._clearSelfAndDescendantCache(Q0),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(S9,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,l={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)l.attrs[t]=a}return Z._prepareToStringify(l)}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(pv,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(Q0,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let t;if(e)return t=new Tn,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(Q0)||new Tn,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,l=this.attrs.offsetY||0;t.translate(n-i,s-l)}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(af,this._getTransform)}_getTransform(){var e,t;let a=this._cache.get(af)||new Tn;a.reset();let n=this.x(),s=this.y(),i=je.getAngle(this.rotation()),l=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(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(l!==1||f!==1)a.scale(l,f);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,l;for(a in e)t[a]=e[a];let f=new this.constructor(t);for(a in this.eventListeners){n=this.eventListeners[a],s=n.length;for(i=0;i<s;i++)if(l=n[i],l.name.indexOf(nD)<0){if(!f.eventListeners[a])f.eventListeners[a]=[];f.eventListeners[a].push(l)}}return f}_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,l=new oi({width:e.width||Math.ceil(t.width)||(a?a.width():0),height:e.height||Math.ceil(t.height)||(a?a.height():0),pixelRatio:i}),f=l.getContext(),c=new oi({width:l.width/l.pixelRatio+Math.abs(n),height:l.height/l.pixelRatio+Math.abs(s),pixelRatio:l.pixelRatio});if(e.imageSmoothingEnabled===!1)f._context.imageSmoothingEnabled=!1;if(f.save(),n||s)f.translate(-1*n,-1*s);return this.drawScene(l,void 0,c),f.restore(),l}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 je.dragDistance}_off(e,t,a){let n=this.eventListeners[e],s,i,l;for(s=0;s<n.length;s++)if(i=n[s].name,l=n[s].handler,(i!=="konva"||t==="konva")&&(!t||i===t)&&(!a||a===l)){if(n.splice(s,1),n.length===0){delete this.eventListeners[e];break}s--}}_fireChangeEvent(e,t,a){this._fire(e+tD,{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[mv+Z._capitalize(e)];if(Z._isFunction(a))a.call(this,t);else this._setAttr(e,t);return this}_requestDraw(){if(je.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===gv)t.target=this;let n=[sD,iD,lD,fD,rD,oD];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=we.protoListenerMap.get(n)||{},i=s===null||s===void 0?void 0:s[e];if(i===void 0){i=[];let l=Object.getPrototypeOf(this);while(l){let f=(a=(t=l.eventListeners)===null||t===void 0?void 0:t[e])!==null&&a!==void 0?a:[];i.push(...f),l=Object.getPrototypeOf(l)}s[e]=i,we.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 f=0;f<s.length;f++)s[f].handler.call(this,t);let l=this.eventListeners[e];if(l)for(let f=i;f<l.length;f++)l[f].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;Ct._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(!Ct._dragElements.has(this._id))this._createDragElement(e);let a=Ct._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=Ct._dragElements.get(this._id);if(t)t.dragStatus="stopped";Ct._endDragBefore(e),Ct._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){let e=Ct._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||je.dragButtons.indexOf(e.evt.button)>=0))return;if(this.isDragging())return;let n=!1;if(Ct._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=Ct._dragElements.get(this._id),a=t&&t.dragStatus==="dragging",n=t&&t.dragStatus==="ready";if(a)this.stopDrag();else if(n)Ct._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=we.prototype.getClassName.call(e),n=e.children,s,i,l;if(t)e.attrs.container=t;if(!je[a])Z.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape";if(s=new je[a](e.attrs),n){i=n.length;for(l=0;l<i;l++)s.add(we._createNode(n[l]))}return s}}we.protoListenerMap=new Map;we.prototype.nodeType="Node";we.prototype._attrsAffectingSize=[];we.prototype.eventListeners={};we.prototype.on(hD,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(af),this._clearSelfAndDescendantCache(Q0)});we.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(jg)});we.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(dg)});we.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(S9)});var na=U.addGetterSetter;na(we,"zIndex");na(we,"absolutePosition");na(we,"position");na(we,"x",0,ge());na(we,"y",0,ge());na(we,"globalCompositeOperation","source-over",n0());na(we,"opacity",1,ge());na(we,"name","",n0());na(we,"id","",n0());na(we,"rotation",0,ge());U.addComponentsGetterSetter(we,"scale",["x","y"]);na(we,"scaleX",1,ge());na(we,"scaleY",1,ge());U.addComponentsGetterSetter(we,"skew",["x","y"]);na(we,"skewX",0,ge());na(we,"skewY",0,ge());U.addComponentsGetterSetter(we,"offset",["x","y"]);na(we,"offsetX",0,ge());na(we,"offsetY",0,ge());na(we,"dragDistance",void 0,ge());na(we,"width",0,ge());na(we,"height",0,ge());na(we,"listening",!0,Mn());na(we,"preventDefault",!0,Mn());na(we,"filters",void 0,function(e){return this._filterUpToDate=!1,e});na(we,"visible",!0,Mn());na(we,"transformsEnabled","all",n0());na(we,"size");na(we,"dragBoundFunc");na(we,"draggable",!1,Mn());U.backCompat(we,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class qn extends we{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=we.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=we.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(),l=this._getCanvasCache(),f=l&&l.scene,c=s&&s.isCache;if(!this.isVisible()&&!c)return this;if(f){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 f=this.getAbsoluteTransform(t).getMatrix();s.transform(f[0],f[1],f[2],f[3],f[4],f[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(),l=this.clipWidth(),f=this.clipHeight(),c=this.clipFunc(),h=typeof l==="number"&&typeof f==="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(),S=this.clipY();i.rect(A||0,S||0,l,f)}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,l,f,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,l=d.x+d.width,f=d.y+d.height;else s=Math.min(s,d.x),i=Math.min(i,d.y),l=Math.max(l,d.x+d.width),f=Math.max(f,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:l-s,height:f-i};else c={x:0,y:0,width:0,height:0};if(!a)return this._transformedRect(c,n);return c}}U.addComponentsGetterSetter(qn,"clip",["x","y","width","height"]);U.addGetterSetter(qn,"clipX",void 0,ge());U.addGetterSetter(qn,"clipY",void 0,ge());U.addGetterSetter(qn,"clipWidth",void 0,ge());U.addGetterSetter(qn,"clipHeight",void 0,ge());U.addGetterSetter(qn,"clipFunc");var Dh=new Map,bv=je._global.PointerEvent!==void 0;function _9(e){return Dh.get(e)}function F9(e){return{evt:e,pointerId:e.pointerId}}function O9(e,t){return Dh.get(e)===t}function B9(e,t){if(kr(e),!t.getStage())return;if(Dh.set(e,t),bv)t._fire("gotpointercapture",F9(new PointerEvent("gotpointercapture")))}function kr(e,t){let a=Dh.get(e);if(!a)return;let n=a.getStage();if(n&&n.content);if(Dh.delete(e),bv)a._fire("lostpointercapture",F9(new PointerEvent("lostpointercapture")))}var mD="Stage",gD="string",dv="px",pD="mouseout",qv="mouseleave",vv="mouseover",kv="mouseenter",Av="mousemove",yv="mousedown",Sv="mouseup",Rh="pointermove",Nh="pointerdown",v1="pointerup",zh="pointercancel",bD="lostpointercapture",T9="pointerout",Eh="pointerleave",M9="pointerover",H9="pointerenter",vg="contextmenu",Cv="touchstart",_v="touchend",Fv="touchmove",Ov="touchcancel",kg="wheel",wD=5,dD=[[kv,"_pointerenter"],[yv,"_pointerdown"],[Av,"_pointermove"],[Sv,"_pointerup"],[qv,"_pointerleave"],[Cv,"_pointerdown"],[Fv,"_pointermove"],[_v,"_pointerup"],[Ov,"_pointercancel"],[vv,"_pointerover"],[kg,"_wheel"],[vg,"_contextmenu"],[Nh,"_pointerdown"],[Rh,"_pointermove"],[v1,"_pointerup"],[zh,"_pointercancel"],[Eh,"_pointerleave"],[bD,"_lostpointercapture"]],qg={mouse:{[T9]:pD,[Eh]:qv,[M9]:vv,[H9]:kv,[Rh]:Av,[Nh]:yv,[v1]:Sv,[zh]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[T9]:"touchout",[Eh]:"touchleave",[M9]:"touchover",[H9]:"touchenter",[Rh]:Fv,[Nh]:Cv,[v1]:_v,[zh]:Ov,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[T9]:T9,[Eh]:Eh,[M9]:M9,[H9]:H9,[Rh]:Rh,[Nh]:Nh,[v1]:v1,[zh]:zh,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Ih=(e)=>{if(e.indexOf("pointer")>=0)return"pointer";if(e.indexOf("touch")>=0)return"touch";return"mouse"},q1=(e)=>{let t=Ih(e);if(t==="pointer")return je.pointerEventsEnabled&&qg.pointer;if(t==="touch")return qg.touch;if(t==="mouse")return qg.mouse};function jv(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 jD="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);",k1=[];class A1 extends qn{constructor(e){super(jv(e));this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),k1.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{jv(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===gD){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"),qn.prototype.clone.call(this,e)}destroy(){super.destroy();let e=this.content;if(e&&Z._isInDocument(e))this.container().removeChild(e);let t=k1.indexOf(this);if(t>-1)k1.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(jD),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 oi({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+dv,this.content.style.height=t+dv;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>wD)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(),je.isBrowser)this.content.appendChild(e.canvas._canvas);return this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return O9(e,this)}setPointerCapture(e){B9(e,this)}releaseCapture(e){kr(e,this)}getLayers(){return this.children}_bindContentEvents(){if(!je.isBrowser)return;dD.forEach(([e,t])=>{this.content.addEventListener(e,(a)=>{this[t](a)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);let t=q1(e.type);if(t)this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=q1(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=q1(e.type),a=Ih(e.type);if(!t)return;this.setPointersPositions(e);let n=this._getTargetShape(a),s=!(je.isDragging()||je.isTransforming())||je.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=q1(e.type),a=Ih(e.type);if(!t)return;this.setPointersPositions(e);let n=!1;if(this._changedPointerPositions.forEach((s)=>{let i=this.getIntersection(s);if(Ct.justDragged=!1,je["_"+a+"ListenClick"]=!0,!i||!i.isListening()){this[a+"ClickStartShape"]=void 0;return}if(je.capturePointerEventsEnabled)i.setPointerCapture(s.id);this[a+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:s.id}),n=!0;let l=e.type.indexOf("touch")>=0;if(i.preventDefault()&&e.cancelable&&l)e.preventDefault()}),!n)this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){let t=q1(e.type),a=Ih(e.type);if(!t)return;let n=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(je.isDragging()&&Ct.node.preventDefault()&&e.cancelable&&n)e.preventDefault();if(this.setPointersPositions(e),!(!(je.isDragging()||je.isTransforming())||je.hitOnDragEnabled))return;let i={},l=!1,f=this._getTargetShape(a);if(this._changedPointerPositions.forEach((c)=>{let h=_9(c.id)||this.getIntersection(c),u=c.id,g={evt:e,pointerId:u},b=f!==h;if(b&&f)f._fireAndBubble(t.pointerout,{...g},h),f._fireAndBubble(t.pointerleave,{...g},h);if(h){if(i[h._id])return;i[h._id]=!0}if(h&&h.isListening()){if(l=!0,b)h._fireAndBubble(t.pointerover,{...g},f),h._fireAndBubble(t.pointerenter,{...g},f),this[a+"targetShape"]=h;h._fireAndBubble(t.pointermove,{...g})}else if(f)this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u}),this[a+"targetShape"]=null}),!l)this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=q1(e.type),a=Ih(e.type);if(!t)return;this.setPointersPositions(e);let n=this[a+"ClickStartShape"],s=this[a+"ClickEndShape"],i={},l=!1;if(this._changedPointerPositions.forEach((f)=>{let c=_9(f.id)||this.getIntersection(f);if(c){if(c.releaseCapture(f.id),i[c._id])return;i[c._id]=!0}let h=f.id,u={evt:e,pointerId:h},g=!1;if(je["_"+a+"InDblClickWindow"])g=!0,clearTimeout(this[a+"DblTimeout"]);else if(!Ct.justDragged)je["_"+a+"InDblClickWindow"]=!0,clearTimeout(this[a+"DblTimeout"]);if(this[a+"DblTimeout"]=setTimeout(function(){je["_"+a+"InDblClickWindow"]=!1},je.dblClickWindow),c&&c.isListening()){if(l=!0,this[a+"ClickEndShape"]=c,c._fireAndBubble(t.pointerup,{...u}),je["_"+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,!l)this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),l=!0;if(je["_"+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})}}),!l)this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id});if(je["_"+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(vg,{evt:e});else this._fire(vg,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());if(t&&t.isListening())t._fireAndBubble(kg,{evt:e});else this._fire(kg,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=_9(e.pointerId)||this.getIntersection(this.getPointerPosition());if(t)t._fireAndBubble(v1,F9(e));kr(e.pointerId)}_lostpointercapture(e){kr(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 oi({width:this.width(),height:this.height()}),this.bufferHitCanvas=new qr({pixelRatio:1,width:this.width(),height:this.height()}),!je.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}}A1.prototype.nodeType=mD;rt(A1);U.addGetterSetter(A1,"container");if(je.isBrowser)document.addEventListener("visibilitychange",()=>{k1.forEach((e)=>{e.batchDraw()})});var Bv="hasShadow",Tv="shadowRGBA",Mv="patternImage",Hv="linearGradient",xv="radialGradient",x9;function Ag(){if(x9)return x9;return x9=Z.createCanvasElement().getContext("2d"),x9}var Ar={};function qD(e){let t=this.attrs.fillRule;if(t)e.fill(t);else e.fill()}function vD(e){e.stroke()}function kD(e){let t=this.attrs.fillRule;if(t)e.fill(t);else e.fill()}function AD(e){e.stroke()}function yD(){this._clearCache(Bv)}function SD(){this._clearCache(Tv)}function CD(){this._clearCache(Mv)}function _D(){this._clearCache(Hv)}function FD(){this._clearCache(xv)}class pe extends we{constructor(e){super(e);let t,a=0;while(!0){if(t=Z.getHitColor(),t&&!(t in Ar))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,Ar[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(Bv,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Mv,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let t=Ag().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){let a=new Tn;a.translate(this.fillPatternX(),this.fillPatternY()),a.rotate(je.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(Hv,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Ag(),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(xv,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=Ag(),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(Tv,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 we.prototype.destroy.call(this),delete Ar[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 l=this.hasShadow(),f=this.shadowForStrokeEnabled();if(n&&s&&l&&f)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(),f=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,c=i.width+f,h=i.height+f,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,S=d+A*2,C=j+A*2,O={width:S,height:C,x:-(f/2+A)+Math.min(g,0)+i.x,y:-(f/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(),l=this._getCanvasCache(),f=this.getSceneFunc(),c=this.hasShadow(),h,u=!1,g=t===this;if(!this.isVisible()&&!g)return this;if(l){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(!f)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]),f.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);f.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(),l=this.hitFunc()||this.sceneFunc(),f=this._getCanvasCache(),c=f&&f.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(!l)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 l.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(),l=n.getHeight();s.clear(),s.drawImage(a._canvas,0,0,i,l);try{let f=s.getImageData(0,0,i,l),c=f.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(f,0,0)}catch(f){Z.error("Unable to draw hit graph from cached scene canvas. "+f.message)}return this}hasPointerCapture(e){return O9(e,this)}setPointerCapture(e){B9(e,this)}releaseCapture(e){kr(e,this)}}pe.prototype._fillFunc=qD;pe.prototype._strokeFunc=vD;pe.prototype._fillFuncHit=kD;pe.prototype._strokeFuncHit=AD;pe.prototype._centroid=!1;pe.prototype.nodeType="Shape";rt(pe);pe.prototype.eventListeners={};pe.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",yD);pe.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",SD);pe.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",CD);pe.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",_D);pe.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",FD);U.addGetterSetter(pe,"stroke",void 0,wg());U.addGetterSetter(pe,"strokeWidth",2,ge());U.addGetterSetter(pe,"fillAfterStrokeEnabled",!1);U.addGetterSetter(pe,"hitStrokeWidth","auto",Mh());U.addGetterSetter(pe,"strokeHitEnabled",!0,Mn());U.addGetterSetter(pe,"perfectDrawEnabled",!0,Mn());U.addGetterSetter(pe,"shadowForStrokeEnabled",!0,Mn());U.addGetterSetter(pe,"lineJoin");U.addGetterSetter(pe,"lineCap");U.addGetterSetter(pe,"miterLimit");U.addGetterSetter(pe,"sceneFunc");U.addGetterSetter(pe,"hitFunc");U.addGetterSetter(pe,"dash");U.addGetterSetter(pe,"dashOffset",0,ge());U.addGetterSetter(pe,"shadowColor",void 0,n0());U.addGetterSetter(pe,"shadowBlur",0,ge());U.addGetterSetter(pe,"shadowOpacity",1,ge());U.addComponentsGetterSetter(pe,"shadowOffset",["x","y"]);U.addGetterSetter(pe,"shadowOffsetX",0,ge());U.addGetterSetter(pe,"shadowOffsetY",0,ge());U.addGetterSetter(pe,"fillPatternImage");U.addGetterSetter(pe,"fill",void 0,wg());U.addGetterSetter(pe,"fillPatternX",0,ge());U.addGetterSetter(pe,"fillPatternY",0,ge());U.addGetterSetter(pe,"fillLinearGradientColorStops");U.addGetterSetter(pe,"strokeLinearGradientColorStops");U.addGetterSetter(pe,"fillRadialGradientStartRadius",0);U.addGetterSetter(pe,"fillRadialGradientEndRadius",0);U.addGetterSetter(pe,"fillRadialGradientColorStops");U.addGetterSetter(pe,"fillPatternRepeat","repeat");U.addGetterSetter(pe,"fillEnabled",!0);U.addGetterSetter(pe,"strokeEnabled",!0);U.addGetterSetter(pe,"shadowEnabled",!0);U.addGetterSetter(pe,"dashEnabled",!0);U.addGetterSetter(pe,"strokeScaleEnabled",!0);U.addGetterSetter(pe,"fillPriority","color");U.addComponentsGetterSetter(pe,"fillPatternOffset",["x","y"]);U.addGetterSetter(pe,"fillPatternOffsetX",0,ge());U.addGetterSetter(pe,"fillPatternOffsetY",0,ge());U.addComponentsGetterSetter(pe,"fillPatternScale",["x","y"]);U.addGetterSetter(pe,"fillPatternScaleX",1,ge());U.addGetterSetter(pe,"fillPatternScaleY",1,ge());U.addComponentsGetterSetter(pe,"fillLinearGradientStartPoint",["x","y"]);U.addComponentsGetterSetter(pe,"strokeLinearGradientStartPoint",["x","y"]);U.addGetterSetter(pe,"fillLinearGradientStartPointX",0);U.addGetterSetter(pe,"strokeLinearGradientStartPointX",0);U.addGetterSetter(pe,"fillLinearGradientStartPointY",0);U.addGetterSetter(pe,"strokeLinearGradientStartPointY",0);U.addComponentsGetterSetter(pe,"fillLinearGradientEndPoint",["x","y"]);U.addComponentsGetterSetter(pe,"strokeLinearGradientEndPoint",["x","y"]);U.addGetterSetter(pe,"fillLinearGradientEndPointX",0);U.addGetterSetter(pe,"strokeLinearGradientEndPointX",0);U.addGetterSetter(pe,"fillLinearGradientEndPointY",0);U.addGetterSetter(pe,"strokeLinearGradientEndPointY",0);U.addComponentsGetterSetter(pe,"fillRadialGradientStartPoint",["x","y"]);U.addGetterSetter(pe,"fillRadialGradientStartPointX",0);U.addGetterSetter(pe,"fillRadialGradientStartPointY",0);U.addComponentsGetterSetter(pe,"fillRadialGradientEndPoint",["x","y"]);U.addGetterSetter(pe,"fillRadialGradientEndPointX",0);U.addGetterSetter(pe,"fillRadialGradientEndPointY",0);U.addGetterSetter(pe,"fillPatternRotation",0);U.addGetterSetter(pe,"fillRule",void 0,n0());U.backCompat(pe,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var OD="beforeDraw",BD="draw",Dv=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],TD=Dv.length;class s0 extends qn{constructor(e){super(e);this.canvas=new oi,this.hitCanvas=new qr({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(){we.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(!we.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(we.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(we.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(we.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(),we.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<TD;n++){let s=Dv[n],i=this._getIntersection({x:e.x+s.x*t,y:e.y+s.y*t}),l=i.shape;if(l)return l;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=Ar[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(OD,{node:this}),this.clearBeforeDraw())s.getContext().clear();return qn.prototype.drawScene.call(this,s,t,a),this._fire(BD,{node:this}),this}drawHit(e,t){let a=this.getLayer(),n=e||a&&a.hitCanvas;if(a&&a.clearBeforeDraw())a.getHitCanvas().getContext().clear();return qn.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()}}s0.prototype.nodeType="Layer";rt(s0);U.addGetterSetter(s0,"imageSmoothingEnabled",!0);U.addGetterSetter(s0,"clearBeforeDraw",!0);U.addGetterSetter(s0,"hitGraphEnabled",!0,Mn());class Uh extends s0{constructor(e){super(e);this.listening(!1),Z.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Uh.prototype.nodeType="FastLayer";rt(Uh);class i0 extends qn{_validateAdd(e){let t=e.getType();if(t!=="Group"&&t!=="Shape")Z.throw("You may only add groups and shapes to groups.")}}i0.prototype.nodeType="Group";rt(i0);var yg=function(){if(Pl.performance&&Pl.performance.now)return function(){return Pl.performance.now()};return function(){return new Date().getTime()}}();class ts{constructor(e,t){this.id=ts.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:yg(),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=ts.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=yg(),ts._addAnimation(this),this}stop(){return ts._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(yg());let l=s.length,f;if(i)f=i.call(n,n.frame)!==!1;else f=!0;if(!f)continue;for(let c=0;c<l;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=ts;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)}}ts.animations=[];ts.animIdCounter=0;ts.animRunning=!1;var MD={node:1,duration:1,easing:1,onFinish:1,yoyo:1},HD=1,Rv=2,Nv=3,zv=["fill","stroke","shadowColor"],xD=0;class Ev{constructor(e,t,a,n,s,i,l){this.prop=e,this.propFunc=t,this.begin=n,this._pos=n,this.duration=i,this._change=0,this.prevPos=0,this.yoyo=l,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=Rv,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=Nv,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===Rv)this.setTime(e);else if(this.state===Nv)this.setTime(this.duration-e)}pause(){this.state=HD,this.fire("onPause")}getTimer(){return new Date().getTime()}}class sa{constructor(e){let t=this,a=e.node,n=a._id,s=e.easing||y1.Linear,i=!!e.yoyo,l,f;if(typeof e.duration>"u")l=0.3;else if(e.duration===0)l=0.001;else l=e.duration;this.node=a,this._id=xD++;let c=a.getLayer()||(a instanceof je.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 ts(function(){t.tween.onEnterFrame()},c),this.tween=new Ev(f,function(h){t._tweenFunc(h)},s,0,1,l*1000,i),this._addListeners(),!sa.attrs[n])sa.attrs[n]={};if(!sa.attrs[n][this._id])sa.attrs[n][this._id]={};if(!sa.tweens[n])sa.tweens[n]={};for(f in e)if(MD[f]===void 0)this._addAttr(f,e[f]);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,l,f,c,h=sa.tweens[n][e];if(h)delete sa.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)f=u,u=Z._prepareArrayForTween(u,t,a.closed());else l=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;sa.attrs[n][this._id][e]={start:u,diff:s,end:t,trueEnd:l,trueStart:f},sa.tweens[n][e]=this._id}_tweenFunc(e){let t=this.node,a=sa.attrs[t._id][this._id],n,s,i,l,f,c,h,u;for(n in a){if(s=a[n],i=s.start,l=s.diff,u=s.end,Z._isArray(i))if(f=[],h=Math.max(i.length,u.length),n.indexOf("fill")===0)for(c=0;c<h;c++)if(c%2===0)f.push((i[c]||0)+l[c]*e);else f.push("rgba("+Math.round(i[c].r+l[c].r*e)+","+Math.round(i[c].g+l[c].g*e)+","+Math.round(i[c].b+l[c].b*e)+","+(i[c].a+l[c].a*e)+")");else for(c=0;c<h;c++)f.push((i[c]||0)+l[c]*e);else if(zv.indexOf(n)!==-1)f="rgba("+Math.round(i.r+l.r*e)+","+Math.round(i.g+l.g*e)+","+Math.round(i.b+l.b*e)+","+(i.a+l.a*e)+")";else f=i+l*e;t.setAttr(n,f)}}_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=sa.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=sa.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=sa.tweens[e];if(this.pause(),this.anim)this.anim.stop();for(let n in a)delete sa.tweens[e][n];if(delete sa.attrs[e][t],sa.tweens[e]){if(Object.keys(sa.tweens[e]).length===0)delete sa.tweens[e];if(Object.keys(sa.attrs[e]).length===0)delete sa.attrs[e]}}}sa.attrs={};sa.tweens={};we.prototype.to=function(e){let t=e.onFinish;e.node=this,e.onFinish=function(){if(this.destroy(),t)t()},new sa(e).play()};var y1={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 l=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,l=i/4;else l=i/(2*Math.PI)*Math.asin(a/s);return-(s*Math.pow(2,10*(e-=1))*Math.sin((e*n-l)*(2*Math.PI)/i))+t},ElasticEaseOut(e,t,a,n,s,i){let l=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,l=i/4;else l=i/(2*Math.PI)*Math.asin(a/s);return s*Math.pow(2,-10*e)*Math.sin((e*n-l)*(2*Math.PI)/i)+a+t},ElasticEaseInOut(e,t,a,n,s,i){let l=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,l=i/4;else l=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-l)*(2*Math.PI)/i))+t;return s*Math.pow(2,-10*(e-=1))*Math.sin((e*n-l)*(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-y1.BounceEaseOut(n-e,0,a,n)+t},BounceEaseInOut(e,t,a,n){if(e<n/2)return y1.BounceEaseIn(e*2,0,a,n)*0.5+t;else return y1.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 S1=Z._assign(je,{Util:Z,Transform:Tn,Node:we,Container:qn,Stage:A1,stages:k1,Layer:s0,FastLayer:Uh,Group:i0,DD:Ct,Shape:pe,shapes:Ar,Animation:ts,Tween:sa,Easings:y1,Context:j1,Canvas:Th});class Ti extends pe{_sceneFunc(e){let t=je.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=je.getAngle(a?360-this.angle():this.angle()),s=Math.cos(Math.min(n,Math.PI)),i=1,l=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),f=Math.sin(Math.min(n,Math.PI/2)),c=s*(s>0?e:t),h=1*t,u=l*(l>0?e:t),g=f*(f>0?t:e);return{x:c,y:a?-1*g:u,width:h-c,height:g-u}}}Ti.prototype._centroid=!0;Ti.prototype.className="Arc";Ti.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"];rt(Ti);U.addGetterSetter(Ti,"innerRadius",0,ge());U.addGetterSetter(Ti,"outerRadius",0,ge());U.addGetterSetter(Ti,"angle",0,ge());U.addGetterSetter(Ti,"clockwise",!1,Mn());function Sg(e,t,a,n,s,i,l){let f=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=l*f/(f+c),u=l*c/(f+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 Iv(e,t){let a=e.length,n=[];for(let s=2;s<a-2;s+=2){let i=Sg(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 DD(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],l=-3*n[0]+3*n[1],f=i*i-4*s*l;if(f>=0){let c=Math.sqrt(f);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 ci extends pe{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 l=0;if(e.beginPath(),e.moveTo(t[0],t[1]),n!==0&&a>4){let f=this.getTensionPoints(),c=f.length;if(l=s?0:4,!s)e.quadraticCurveTo(f[0],f[1],f[2],f[3]);while(l<c-2)e.bezierCurveTo(f[l++],f[l++],f[l++],f[l++],f[l++],f[l++]);if(!s)e.quadraticCurveTo(f[c-2],f[c-1],t[a-2],t[a-1])}else if(i){l=2;while(l<a)e.bezierCurveTo(t[l++],t[l++],t[l++],t[l++],t[l++],t[l++])}else for(l=2;l<a;l+=2)e.lineTo(t[l],t[l+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 Iv(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,a=this.tension(),n=Sg(e[t-2],e[t-1],e[0],e[1],e[2],e[3],a),s=Sg(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],a),i=Iv(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],...DD(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,l;for(let f=0;f<e.length/2;f++)i=e[f*2],l=e[f*2+1],t=Math.min(t,i),a=Math.max(a,i),n=Math.min(n,l),s=Math.max(s,l);return{x:t,y:n,width:a-t,height:s-n}}}ci.prototype.className="Line";ci.prototype._attrsAffectingSize=["points","bezier","tension"];rt(ci);U.addGetterSetter(ci,"closed",!1);U.addGetterSetter(ci,"bezier",!1);U.addGetterSetter(ci,"tension",0,ge());U.addGetterSetter(ci,"points",[],ov());var RD=[[],[],[-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]],ND=[[],[],[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]],zD=[[1],[1,1],[1,2,1],[1,3,3,1]],_g=(e,t,a)=>{let n,s,i=20,l=a/2;n=0;for(let f=0;f<20;f++)s=l*RD[20][f]+l,n+=ND[20][f]*ED(e,t,s);return l*n},Fg=(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],l=2*t[1]-2*t[0],f=4*(n*n+s*s),c=4*(n*i+s*l),h=i*i+l*l;if(f===0)return a*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));let u=c/(2*f),g=h/f,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,S=u+Math.sqrt(u*u+d)!==0?d*Math.log(Math.abs((b+j)/(u+A))):0;return Math.sqrt(f)/2*(b*j-u*A+S)};function ED(e,t,a){let n=Cg(1,a,e),s=Cg(1,a,t),i=n*n+s*s;return Math.sqrt(i)}var Cg=(e,t,a)=>{let n=a.length-1,s,i;if(n===0)return 0;if(e===0){i=0;for(let l=0;l<=n;l++)i+=zD[n][l]*Math.pow(1-t,n-l)*Math.pow(t,l)*a[l];return i}else{s=Array(n);for(let l=0;l<n;l++)s[l]=n*(a[l+1]-a[l]);return Cg(e-1,t,s)}},Og=(e,t,a)=>{let n=1,s=e/t,i=(e-a(s))/t,l=0;while(n>0.001){let f=a(s+i),c=Math.abs(e-f)/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(l++,l>500)break}return s};class Jt extends pe{constructor(e){super(e);this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Jt.parsePathData(this.data()),this.pathLength=Jt.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 l=i[0],f=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,S=c>h?h/c:1;e.translate(l,f),e.rotate(b),e.scale(A,S),e.arc(0,0,j,u,u+g,1-d),e.scale(1/A,1/S),e.rotate(-b),e.translate(-l,-f);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(f){if(f.command==="A"){let c=f.points[4],h=f.points[5],u=f.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=Jt.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],b,0);e.push(d.x,d.y)}else for(let b=c+g;b<u;b+=g){let d=Jt.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],b,0);e.push(d.x,d.y)}}else if(f.command==="C")for(let c=0;c<=1;c+=0.01){let h=Jt.getPointOnCubicBezier(c,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3],f.points[4],f.points[5]);e.push(h.x,h.y)}else e=e.concat(f.points)});let t=e[0],a=e[0],n=e[1],s=e[1],i,l;for(let f=0;f<e.length/2;f++){if(i=e[f*2],l=e[f*2+1],!isNaN(i))t=Math.min(t,i),a=Math.max(a,i);if(!isNaN(l))n=Math.min(n,l),s=Math.max(s,l)}return{x:t,y:n,width:a-t,height:s-n}}getLength(){return this.pathLength}getPointAtLength(e){return Jt.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],l=i.points;switch(i.command){case"L":return Jt.getPointOnLine(e,i.start.x,i.start.y,l[0],l[1]);case"C":return Jt.getPointOnCubicBezier(Og(e,Jt.getPathLength(t),(j)=>{return _g([i.start.x,l[0],l[2],l[4]],[i.start.y,l[1],l[3],l[5]],j)}),i.start.x,i.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return Jt.getPointOnQuadraticBezier(Og(e,Jt.getPathLength(t),(j)=>{return Fg([i.start.x,l[0],l[2]],[i.start.y,l[1],l[3]],j)}),i.start.x,i.start.y,l[0],l[1],l[2],l[3]);case"A":let f=l[0],c=l[1],h=l[2],u=l[3],g=l[5],b=l[6],d=l[4];return d+=g*e/i.pathLength,Jt.getPointOnEllipticalArc(f,c,h,u,d,b)}return null}static getPointOnLine(e,t,a,n,s,i,l){i=i!==null&&i!==void 0?i:t,l=l!==null&&l!==void 0?l:a;let f=this.getLineLength(t,a,n,s);if(f<0.0000000001)return{x:t,y:a};if(n===t)return{x:i,y:l+(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(l-a-c*(i-t))<0.0000000001)return{x:i+h,y:l+u};let g=((i-t)*(n-t)+(l-a)*(s-a))/(f*f),b=t+g*(n-t),d=a+g*(s-a),j=this.getLineLength(i,l,b,d),A=Math.sqrt(e*e-j*j),S=Math.sqrt(A*A/(1+c*c))*(n<t?-1:1),C=c*S;return{x:b+S,y:d+C}}static getPointOnCubicBezier(e,t,a,n,s,i,l,f,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=f*h(e)+i*u(e)+n*g(e)+t*b(e),j=c*h(e)+l*u(e)+s*g(e)+a*b(e);return{x:d,y:j}}static getPointOnQuadraticBezier(e,t,a,n,s,i,l){function f(b){return b*b}function c(b){return 2*b*(1-b)}function h(b){return(1-b)*(1-b)}let u=i*f(e)+n*c(e)+t*h(e),g=l*f(e)+s*c(e)+a*h(e);return{x:u,y:g}}static getPointOnEllipticalArc(e,t,a,n,s,i){let l=Math.cos(i),f=Math.sin(i),c={x:a*Math.cos(s),y:n*Math.sin(s)};return{x:e+(c.x*l-c.y*f),y:t+(c.x*f+c.y*l)}}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=[],l=0,f=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,S=i.length;A<S;A++){let C=i[A];if(C==="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(C)){if(d.push(parseInt(C[0],10)),d.push(parseInt(C[1],10)),d.push(parseFloat(C.slice(2))),j+=3,j>=7)j-=7;continue}if(C==="11"||C==="10"||C==="01"){if(d.push(parseInt(C[0],10)),d.push(parseInt(C[1],10)),j+=2,j>=7)j-=7;continue}if(C==="0"||C==="1"){if(d.push(parseInt(C,10)),j+=1,j>=7)j-=7;continue}}else if(j===4){if(/^[01]\d+(?:\.\d+)?$/.test(C)){if(d.push(parseInt(C[0],10)),d.push(parseFloat(C.slice(1))),j+=2,j>=7)j-=7;continue}if(C==="0"||C==="1"){if(d.push(parseInt(C,10)),j+=1,j>=7)j-=7;continue}}let O=parseFloat(C);if(!isNaN(O))d.push(O);else d.push(0);if(j+=1,j>=7)j-=7}else{let O=parseFloat(C);if(!isNaN(O))d.push(O);else d.push(0)}}while(d.length>0){if(isNaN(d[0]))break;let A="",S=[],C=l,O=f,T,M,H,D,N,z,L,ee,te,J;switch(b){case"l":l+=d.shift(),f+=d.shift(),A="L",S.push(l,f);break;case"L":l=d.shift(),f=d.shift(),S.push(l,f);break;case"m":let ae=d.shift(),Q=d.shift();if(l+=ae,f+=Q,A="M",s.length>2&&s[s.length-1].command==="z"){for(let Y=s.length-2;Y>=0;Y--)if(s[Y].command==="M"){l=s[Y].points[0]+ae,f=s[Y].points[1]+Q;break}}S.push(l,f),b="l";break;case"M":l=d.shift(),f=d.shift(),A="M",S.push(l,f),b="L";break;case"h":l+=d.shift(),A="L",S.push(l,f);break;case"H":l=d.shift(),A="L",S.push(l,f);break;case"v":f+=d.shift(),A="L",S.push(l,f);break;case"V":f=d.shift(),A="L",S.push(l,f);break;case"C":S.push(d.shift(),d.shift(),d.shift(),d.shift()),l=d.shift(),f=d.shift(),S.push(l,f);break;case"c":S.push(l+d.shift(),f+d.shift(),l+d.shift(),f+d.shift()),l+=d.shift(),f+=d.shift(),A="C",S.push(l,f);break;case"S":if(M=l,H=f,T=s[s.length-1],T.command==="C")M=l+(l-T.points[2]),H=f+(f-T.points[3]);S.push(M,H,d.shift(),d.shift()),l=d.shift(),f=d.shift(),A="C",S.push(l,f);break;case"s":if(M=l,H=f,T=s[s.length-1],T.command==="C")M=l+(l-T.points[2]),H=f+(f-T.points[3]);S.push(M,H,l+d.shift(),f+d.shift()),l+=d.shift(),f+=d.shift(),A="C",S.push(l,f);break;case"Q":S.push(d.shift(),d.shift()),l=d.shift(),f=d.shift(),S.push(l,f);break;case"q":S.push(l+d.shift(),f+d.shift()),l+=d.shift(),f+=d.shift(),A="Q",S.push(l,f);break;case"T":if(M=l,H=f,T=s[s.length-1],T.command==="Q")M=l+(l-T.points[0]),H=f+(f-T.points[1]);l=d.shift(),f=d.shift(),A="Q",S.push(M,H,l,f);break;case"t":if(M=l,H=f,T=s[s.length-1],T.command==="Q")M=l+(l-T.points[0]),H=f+(f-T.points[1]);l+=d.shift(),f+=d.shift(),A="Q",S.push(M,H,l,f);break;case"A":D=d.shift(),N=d.shift(),z=d.shift(),L=d.shift(),ee=d.shift(),te=l,J=f,l=d.shift(),f=d.shift(),A="A",S=this.convertEndpointToCenterParameterization(te,J,l,f,L,ee,D,N,z);break;case"a":D=d.shift(),N=d.shift(),z=d.shift(),L=d.shift(),ee=d.shift(),te=l,J=f,l+=d.shift(),f+=d.shift(),A="A",S=this.convertEndpointToCenterParameterization(te,J,l,f,L,ee,D,N,z);break}s.push({command:A||b,points:S,start:{x:C,y:O},pathLength:this.calcLength(C,O,A||b,S)})}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,l,f,c=Jt;switch(a){case"L":return c.getLineLength(e,t,n[0],n[1]);case"C":return _g([e,n[0],n[2],n[4]],[t,n[1],n[3],n[5]],1);case"Q":return Fg([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(f=h-b;f>g;f-=b)l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),s+=c.getLineLength(i.x,i.y,l.x,l.y),i=l;else for(f=h+b;f<g;f+=b)l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),s+=c.getLineLength(i.x,i.y,l.x,l.y),i=l;return l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],g,0),s+=c.getLineLength(i.x,i.y,l.x,l.y),s}return 0}static convertEndpointToCenterParameterization(e,t,a,n,s,i,l,f,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/(l*l)+g*g/(f*f);if(b>1)l*=Math.sqrt(b),f*=Math.sqrt(b);let d=Math.sqrt((l*l*(f*f)-l*l*(g*g)-f*f*(u*u))/(l*l*(g*g)+f*f*(u*u)));if(s===i)d*=-1;if(isNaN(d))d=0;let j=d*l*g/f,A=d*-f*u/l,S=(e+a)/2+Math.cos(h)*j-Math.sin(h)*A,C=(t+n)/2+Math.sin(h)*j+Math.cos(h)*A,O=function(L){return Math.sqrt(L[0]*L[0]+L[1]*L[1])},T=function(L,ee){return(L[0]*ee[0]+L[1]*ee[1])/(O(L)*O(ee))},M=function(L,ee){return(L[0]*ee[1]<L[1]*ee[0]?-1:1)*Math.acos(T(L,ee))},H=M([1,0],[(u-j)/l,(g-A)/f]),D=[(u-j)/l,(g-A)/f],N=[(-1*u-j)/l,(-1*g-A)/f],z=M(D,N);if(T(D,N)<=-1)z=Math.PI;if(T(D,N)>=1)z=0;if(i===0&&z>0)z=z-2*Math.PI;if(i===1&&z<0)z=z+2*Math.PI;return[S,C,l,f,H,z,h,i]}}Jt.prototype.className="Path";Jt.prototype._attrsAffectingSize=["data"];rt(Jt);U.addGetterSetter(Jt,"data");class Z0 extends ci{_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(),l=a.length,f,c;if(s){let g=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],a[l-2],a[l-1]],b=Jt.calcLength(n[n.length-4],n[n.length-3],"C",g),d=Jt.getPointOnQuadraticBezier(Math.min(1,1-i/b),g[0],g[1],g[2],g[3],g[4],g[5]);f=a[l-2]-d.x,c=a[l-1]-d.y}else f=a[l-2]-a[l-4],c=a[l-1]-a[l-3];let h=(Math.atan2(c,f)+t)%t,u=this.pointerWidth();if(this.pointerAtEnding())e.save(),e.beginPath(),e.translate(a[l-2],a[l-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)f=(n[0]+n[2])/2-a[0],c=(n[1]+n[3])/2-a[1];else f=a[2]-a[0],c=a[3]-a[1];e.rotate((Math.atan2(-c,-f)+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}}}Z0.prototype.className="Arrow";rt(Z0);U.addGetterSetter(Z0,"pointerLength",10,ge());U.addGetterSetter(Z0,"pointerWidth",10,ge());U.addGetterSetter(Z0,"pointerAtBeginning",!1);U.addGetterSetter(Z0,"pointerAtEnding",!0);class nf extends pe{_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)}}nf.prototype._centroid=!0;nf.prototype.className="Circle";nf.prototype._attrsAffectingSize=["radius"];rt(nf);U.addGetterSetter(nf,"radius",0,ge());class l0 extends pe{_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)}}l0.prototype.className="Ellipse";l0.prototype._centroid=!0;l0.prototype._attrsAffectingSize=["radiusX","radiusY"];rt(l0);U.addComponentsGetterSetter(l0,"radius",["x","y"]);U.addGetterSetter(l0,"radiusX",0,ge());U.addGetterSetter(l0,"radiusY",0,ge());class ks extends pe{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 l=this.attrs.cropWidth,f=this.attrs.cropHeight;if(l&&f)i=[s,this.cropX(),this.cropY(),l,f,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 ks({image:n});t(s)},n.onerror=a,n.crossOrigin="Anonymous",n.src=e}}ks.prototype.className="Image";ks.prototype._attrsAffectingSize=["image"];rt(ks);U.addGetterSetter(ks,"cornerRadius",0,tf(4));U.addGetterSetter(ks,"image");U.addComponentsGetterSetter(ks,"crop",["x","y","width","height"]);U.addGetterSetter(ks,"cropX",0,ge());U.addGetterSetter(ks,"cropY",0,ge());U.addGetterSetter(ks,"cropWidth",0,ge());U.addGetterSetter(ks,"cropHeight",0,ge());var Uv=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],ID="Change.konva",UD="none",Bg="up",Tg="right",Mg="down",Hg="left",GD=Uv.length;class Gh extends i0{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<GD;a++)e.on(Uv[a]+ID,n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),a,n,s,i,l,f,c;if(e&&t){switch(a=e.width(),n=e.height(),s=t.pointerDirection(),i=t.pointerWidth(),c=t.pointerHeight(),l=0,f=0,s){case Bg:l=a/2,f=-1*c;break;case Tg:l=a+i,f=n/2;break;case Mg:l=a/2,f=n+c;break;case Hg:l=-1*i,f=n/2;break}t.setAttrs({x:-1*l,y:-1*f,width:a,height:n}),e.setAttrs({x:-1*l,y:-1*f})}}}Gh.prototype.className="Label";rt(Gh);class $0 extends pe{_sceneFunc(e){let t=this.width(),a=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),i=this.pointerHeight(),l=this.cornerRadius(),f=0,c=0,h=0,u=0;if(typeof l==="number")f=c=h=u=Math.min(l,t/2,a/2);else f=Math.min(l[0]||0,t/2,a/2),c=Math.min(l[1]||0,t/2,a/2),u=Math.min(l[2]||0,t/2,a/2),h=Math.min(l[3]||0,t/2,a/2);if(e.beginPath(),e.moveTo(f,0),n===Bg)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===Tg)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===Mg)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===Hg)e.lineTo(0,(a+i)/2),e.lineTo(-1*s,a/2),e.lineTo(0,(a-i)/2);e.lineTo(0,f),e.arc(f,f,f,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(),l=this.height();if(s===Bg)t-=n,l+=n;else if(s===Mg)l+=n;else if(s===Hg)e-=a*1.5,i+=a;else if(s===Tg)i+=a*1.5;return{x:e,y:t,width:i,height:l}}}$0.prototype.className="Tag";rt($0);U.addGetterSetter($0,"pointerDirection",UD);U.addGetterSetter($0,"pointerWidth",0,ge());U.addGetterSetter($0,"pointerHeight",0,ge());U.addGetterSetter($0,"cornerRadius",0,tf(4));class sf extends pe{_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)}}sf.prototype.className="Rect";rt(sf);U.addGetterSetter(sf,"cornerRadius",0,tf(4));class f0 extends pe{_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)}}f0.prototype.className="RegularPolygon";f0.prototype._centroid=!0;f0.prototype._attrsAffectingSize=["radius"];rt(f0);U.addGetterSetter(f0,"radius",0,ge());U.addGetterSetter(f0,"sides",0,ge());U.addGetterSetter(f0,"cornerRadius",0,tf(4));var Gv=Math.PI*2;class W0 extends pe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Gv,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Gv,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)}}W0.prototype.className="Ring";W0.prototype._centroid=!0;W0.prototype._attrsAffectingSize=["innerRadius","outerRadius"];rt(W0);U.addGetterSetter(W0,"innerRadius",0,ge());U.addGetterSetter(W0,"outerRadius",0,ge());class hi extends pe{constructor(e){super(e);this._updated=!0,this.anim=new ts(()=>{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(),l=s[n+0],f=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,l,f,c,h,g[b+0],g[b+1],c,h)}else e.drawImage(u,l,f,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(),l=s[n+2],f=s[n+3];if(e.beginPath(),i){let c=i[t],h=a*2;e.rect(c[h+0],c[h+1],l,f)}else e.rect(0,0,l,f);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)}}hi.prototype.className="Sprite";rt(hi);U.addGetterSetter(hi,"animation");U.addGetterSetter(hi,"animations");U.addGetterSetter(hi,"frameOffsets");U.addGetterSetter(hi,"image");U.addGetterSetter(hi,"frameIndex",0,ge());U.addGetterSetter(hi,"frameRate",17,ge());U.backCompat(hi,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class r0 extends pe{_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,l=i*Math.sin(s*Math.PI/n),f=-1*i*Math.cos(s*Math.PI/n);e.lineTo(l,f)}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)}}r0.prototype.className="Star";r0.prototype._centroid=!0;r0.prototype._attrsAffectingSize=["innerRadius","outerRadius"];rt(r0);U.addGetterSetter(r0,"numPoints",5,ge());U.addGetterSetter(r0,"innerRadius",0,ge());U.addGetterSetter(r0,"outerRadius",0,ge());function P0(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 C1="auto",XD="center",Yv="inherit",Xh="justify",KD="Change.konva",Jv="2d",Xv="-",Qv="left",LD="text",VD="Text",YD="top",JD="bottom",Kv="middle",Zv="normal",QD="px ",D9=" ",ZD="right",Lv="rtl",$D="word",WD="char",Vv="none",xg="…",$v=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],PD=$v.length,Kh=null;function eR(){if(Kh!==null)return Kh;Kh=!1;try{let e=document.createElement("canvas");e.width=10,e.height=10;let t=e.getContext(Jv);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){Kh=!0;break}}}catch(e){}return Kh}function tR(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 R9;function Dg(){if(R9)return R9;return R9=Z.createCanvasElement().getContext(Jv),R9}function aR(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function nR(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function sR(e){if(e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage)e.fill=e.fill||"black";return e}class Qt extends pe{constructor(e){super(sR(e));this._partialTextX=0,this._partialTextY=0;for(let t=0;t<PD;t++)this.on($v[t]+KD,this._setTextData);this._setTextData()}_sceneFunc(e){var t,a;let n=this.textArr,s=n.length;if(!this.text())return;let i=this.padding(),l=this.fontSize(),f=this.lineHeight()*l,c=this.verticalAlign(),h=this.direction(),u=0,g=this.align(),b=this.getWidth(),d=this.letterSpacing(),j=this.charRenderFunc(),A=this.fill(),S=this.textDecoration(),C=this.underlineOffset(),O=S.indexOf("underline")!==-1,T=S.indexOf("line-through")!==-1,M;h=h===Yv?e.direction:h;let H=f/2,D=Kv;if(!je.legacyTextRendering){let N=this.measureSize("M");D="alphabetic";let z=(t=N.fontBoundingBoxAscent)!==null&&t!==void 0?t:N.actualBoundingBoxAscent,L=(a=N.fontBoundingBoxDescent)!==null&&a!==void 0?a:N.actualBoundingBoxDescent;H=(z-L)/2+f/2}if(h===Lv)e.setAttr("direction",h);if(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",D),e.setAttr("textAlign",Qv),c===Kv)u=(this.getHeight()-s*f-i*2)/2;else if(c===JD)u=this.getHeight()-s*f-i*2;e.translate(i,u+i);for(M=0;M<s;M++){let N=0,z=0,L=n[M],ee=L.text,te=L.width,J=L.lastInParagraph;if(e.save(),g===ZD)N+=b-te-i*2;else if(g===XD)N+=(b-te-i*2)/2;if(O){e.save(),e.beginPath();let Q=C!==null&&C!==void 0?C:!je.legacyTextRendering?Math.round(l/4):Math.round(l/2),Y=N,$=H+z+Q;e.moveTo(Y,$);let fe=g===Xh&&!J?b-i*2:te;e.lineTo(Y+Math.round(fe),$),e.lineWidth=l/15;let P=this._getLinearGradient();e.strokeStyle=P||A,e.stroke(),e.restore()}let ae=N;if(h!==Lv&&(d!==0||g===Xh||j)){let Q=ee.split(" ").length-1,Y=P0(ee);for(let $=0;$<Y.length;$++){let fe=Y[$];if(fe===" "&&!J&&g===Xh)N+=(b-i*2-te)/Q;if(this._partialTextX=N,this._partialTextY=H+z,this._partialText=fe,j){e.save();let qe=n.slice(0,M).reduce((me,de)=>me+P0(de.text).length,0),be=$+qe;j({char:fe,index:be,x:N,y:H+z,lineIndex:M,column:$,isLastInLine:J,width:this.measureSize(fe).width,context:e})}if(e.fillStrokeShape(this),j)e.restore();N+=this.measureSize(fe).width+d}}else{if(d!==0)e.setAttr("letterSpacing",`${d}px`);this._partialTextX=N,this._partialTextY=H+z,this._partialText=ee,e.fillStrokeShape(this)}if(T){e.save(),e.beginPath();let Q=!je.legacyTextRendering?-Math.round(l/4):0,Y=ae;e.moveTo(Y,H+z+Q);let $=g===Xh&&!J?b-i*2:te;e.lineTo(Y+Math.round($),H+z+Q),e.lineWidth=l/15;let fe=this._getLinearGradient();e.strokeStyle=fe||A,e.stroke(),e.restore()}if(e.restore(),s>1)H+=f}}_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(LD,t),this}getWidth(){return this.attrs.width===C1||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===C1||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,l,f,c,h,u,g;let b=Dg(),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:(l=j.emHeightAscent)!==null&&l!==void 0?l:100*A,emHeightDescent:(f=j.emHeightDescent)!==null&&f!==void 0?f:-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()+D9+this.fontVariant()+D9+(this.fontSize()+QD)+tR(this.fontFamily())}_addTextLine(e){if(this.align()===Xh)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 Dg().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,l=s!==C1&&s!==void 0,f=i!==C1&&i!==void 0,c=this.padding(),h=s-c*2,u=i-c*2,g=0,b=this.wrap(),d=b!==Vv,j=b!==WD&&d,A=this.ellipsis();this.textArr=[],Dg().font=this._getContextFont();let S=A?this._getTextWidth(xg):0;for(let C=0,O=e.length;C<O;++C){let T=e[C],M=this._getTextWidth(T);if(l&&M>h)while(T.length>0){let H=0,D=P0(T).length,N="",z=0;while(H<D){let L=H+D>>>1,ee=P0(T),te=ee.slice(0,L+1).join(""),J=this._getTextWidth(te);if((A&&f&&g+n>u?J+S:J)<=h)H=L+1,N=te,z=J;else D=L}if(N){if(j){let te=P0(T),J=P0(N),ae=te[J.length],Q=ae===D9||ae===Xv,Y;if(Q&&z<=h)Y=J.length;else{let $=J.lastIndexOf(D9),fe=J.lastIndexOf(Xv);Y=Math.max($,fe)+1}if(Y>0)H=Y,N=te.slice(0,H).join(""),z=this._getTextWidth(N)}if(N=N.trimRight(),this._addTextLine(N),a=Math.max(a,z),g+=n,this._shouldHandleEllipsis(g)){this._tryToAddEllipsisToLastLine();break}if(T=P0(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)&&C<O-1)this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1])this.textArr[this.textArr.length-1].lastInParagraph=!0;if(f&&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!==C1&&n!==void 0,i=this.padding(),l=n-i*2;return this.wrap()===Vv||s&&e+a>l}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==C1&&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+xg)<n))i.text=i.text.slice(0,i.text.length-3)}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+xg)}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&&eR())return!0;return super._useBufferCanvas()}}Qt.prototype._fillFunc=aR;Qt.prototype._strokeFunc=nR;Qt.prototype.className=VD;Qt.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];rt(Qt);U.overWriteSetter(Qt,"width",Mh());U.overWriteSetter(Qt,"height",Mh());U.addGetterSetter(Qt,"direction",Yv);U.addGetterSetter(Qt,"fontFamily","Arial");U.addGetterSetter(Qt,"fontSize",12,ge());U.addGetterSetter(Qt,"fontStyle",Zv);U.addGetterSetter(Qt,"fontVariant",Zv);U.addGetterSetter(Qt,"padding",0,ge());U.addGetterSetter(Qt,"align",Qv);U.addGetterSetter(Qt,"verticalAlign",YD);U.addGetterSetter(Qt,"lineHeight",1,ge());U.addGetterSetter(Qt,"wrap",$D);U.addGetterSetter(Qt,"ellipsis",!1,Mn());U.addGetterSetter(Qt,"letterSpacing",0,ge());U.addGetterSetter(Qt,"text","",n0());U.addGetterSetter(Qt,"textDecoration","");U.addGetterSetter(Qt,"underlineOffset",void 0,ge());U.addGetterSetter(Qt,"charRenderFunc",void 0);var iR="",Wv="normal";function Pv(e){e.fillText(this.partialText,0,0)}function ek(e){e.strokeText(this.partialText,0,0)}class Ha extends pe{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 Jt.getPathLength(this.dataArray)}_getPointAtLength(e){if(!this.attrs.data)return null;let t=this.pathLength;if(e>t)return null;return Jt.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Jt.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,l=t.indexOf("line-through")!==-1;if(i)e.beginPath();for(let f=0;f<s.length;f++){e.save();let c=s[f].p0;if(e.translate(c.x,c.y),e.rotate(s[f].rotation),this.partialText=s[f].text,e.fillStrokeShape(this),i){if(f===0)e.moveTo(0,n/2+1);e.lineTo(s[f].width,n/2+1)}e.restore()}if(i)e.strokeStyle=a,e.lineWidth=n/20,e.stroke();if(l){e.beginPath();for(let f=0;f<s.length;f++){e.save();let c=s[f].p0;if(e.translate(c.x,c.y),e.rotate(s[f].rotation),f===0)e.moveTo(0,0);e.lineTo(s[f].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 Qt.prototype.setText.call(this,e)}_getContextFont(){return Qt.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=P0(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(),l=this.align(),f=this.kerningFunc(),c=Math.max(0,a-n),h=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0),u=0;if(l==="center")u=Math.max(0,this.pathLength/2-h/2);if(l==="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===" "&&l==="justify"){let D=this.text().split(" ").length-1;A+=(this.pathLength-h)/D}let S=g+A,C=this._getPointAtLength(S>this.pathLength&&S-this.pathLength<=c?this.pathLength:S);if(!C)return;let O=Jt.getLineLength(d.x,d.y,C.x,C.y),T=0;if(f)try{T=f(t[b-1].char,j)*this.fontSize()}catch(D){T=0}d.x+=T,C.x+=T,this.textWidth+=T;let M=Jt.getPointOnLine(T+O/2,d.x,d.y,C.x,C.y),H=Math.atan2(C.y-d.y,C.x-d.x);this.glyphInfo.push({transposeX:M.x,transposeY:M.y,text:e[b],rotation:H,p0:d,p1:C,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,l;for(let c=0;c<e.length/2;c++)i=e[c*2],l=e[c*2+1],t=Math.min(t,i),a=Math.max(a,i),n=Math.min(n,l),s=Math.max(s,l);let f=this.fontSize();return{x:t-f/2,y:n-f/2,width:a-t+f,height:s-n+f}}destroy(){return Z.releaseCanvas(this.dummyCanvas),super.destroy()}}Ha.prototype._fillFunc=Pv;Ha.prototype._strokeFunc=ek;Ha.prototype._fillFuncHit=Pv;Ha.prototype._strokeFuncHit=ek;Ha.prototype.className="TextPath";Ha.prototype._attrsAffectingSize=["text","fontSize","data"];rt(Ha);U.addGetterSetter(Ha,"data");U.addGetterSetter(Ha,"fontFamily","Arial");U.addGetterSetter(Ha,"fontSize",12,ge());U.addGetterSetter(Ha,"fontStyle",Wv);U.addGetterSetter(Ha,"align","left");U.addGetterSetter(Ha,"letterSpacing",0,ge());U.addGetterSetter(Ha,"textBaseline","middle");U.addGetterSetter(Ha,"fontVariant",Wv);U.addGetterSetter(Ha,"text",iR);U.addGetterSetter(Ha,"textDecoration","");U.addGetterSetter(Ha,"kerningFunc",void 0);U.addGetterSetter(Ha,"direction","inherit");var nk="tr-konva",lR=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((e)=>e+`.${nk}`).join(" "),tk="nodesRect",fR=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],rR={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},oR="ontouchstart"in je._global;function cR(e,t,a){if(e==="rotater")return a;t+=Z.degToRad(rR[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 N9=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],ak=1e8;function hR(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 sk(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 uR(e,t){let a=hR(e);return sk(e,t,a)}function mR(e,t,a){let n=t;for(let s=0;s<e.length;s++){let i=je.getAngle(e[s]),l=Math.abs(i-t)%(Math.PI*2);if(Math.min(l,Math.PI*2-l)<a)n=i}return n}var Rg=0;class vt extends i0{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(lR,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 nk+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((l)=>l+"Change."+this._getEventNamespace()).join(" ");n.on(i,s)}n.on(fR.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((l)=>{if(l===e)return;if(l.isDragging())return;let f=l.getAbsolutePosition();l.setAbsolutePosition({x:f.x+s,y:f.y+i}),l.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(tk),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(tk,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),l=n.x*s.x-e.offsetX()*s.x,f=n.y*s.y-e.offsetY()*s.y,c=(je.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),h={x:i.x+l*Math.cos(c)+f*Math.sin(-c),y:i.y+f*Math.cos(c)+l*Math.sin(c),width:n.width*s.x,height:n.height*s.y,rotation:c};return sk(h,-je.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-ak,y:-ak,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 Tn;a.rotate(-je.getAngle(this.rotation()));let n=1/0,s=1/0,i=-1/0,l=-1/0;t.forEach(function(c){let h=a.point(c);if(n===void 0)n=i=h.x,s=l=h.y;n=Math.min(n,h.x),s=Math.min(s,h.y),i=Math.max(i,h.x),l=Math.max(l,h.y)}),a.invert();let f=a.point({x:n,y:s});return{x:f.x,y:f.y,width:i-n,height:l-s,rotation:je.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(),N9.forEach((e)=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){let t=new sf({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:oR?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=je.getAngle(this.rotation()),s=this.rotateAnchorCursor(),i=cR(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 pe({name:"back",width:0,height:0,sceneFunc(t,a){let n=a.getParent(),s=n.padding(),i=a.width(),l=a.height();if(t.beginPath(),t.rect(-s,-s,i+s*2,l+s*2),n.rotateEnabled()&&n.rotateLineVisible()){let f=n.rotateAnchorAngle(),c=n.rotateAnchorOffset(),h=Z.degToRad(f),u=Math.sin(h),g=-Math.cos(h),b=i/2,d=l/2,j=1/0;if(g<0)j=Math.min(j,-d/g);else if(g>0)j=Math.min(j,(l-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,S=d+g*j,C=Z._sign(l),O=A+u*c*C,T=S+g*c*C;t.moveTo(A,S),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(),l=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:l.x-i.x,y:l.y-i.y},Rg++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach((f)=>{f._fire("transformstart",{evt:e.evt,target:f})})}_handleMouseMove(e){let t,a,n,s=this.findOne("."+this._movingAnchorName),i=s.getStage();i.setPointersPositions(e);let l=i.getPointerPosition(),f={x:l.x-this._anchorDragOffset.x,y:l.y-this._anchorDragOffset.y},c=s.getAbsolutePosition();if(this.anchorDragBoundFunc())f=this.anchorDragBoundFunc()(c,f,e);s.setAbsolutePosition(f);let h=s.getAbsolutePosition();if(c.x===h.x&&c.y===h.y)return;if(this._movingAnchorName==="rotater"){let C=this._getNodeRect();t=s.x()-C.width/2,a=-s.y()+C.height/2;let O=je.getAngle(this.rotateAnchorAngle()),T=Math.atan2(-a,t)+Math.PI/2-O;if(C.height<0)T-=Math.PI;let H=je.getAngle(this.rotation())+T,D=je.getAngle(this.rotationSnapTolerance()),z=mR(this.rotationSnaps(),H,D)-C.rotation,L=uR(C,z);this._fitNodesInto(L,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 C=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(C.x-s.x(),2)+Math.pow(C.y-s.y(),2));let O=this.findOne(".top-left").x()>C.x?-1:1,T=this.findOne(".top-left").y()>C.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,this.findOne(".top-left").x(C.x-t),this.findOne(".top-left").y(C.y-a)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(s.y());else if(this._movingAnchorName==="top-right"){if(g){let C=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()-C.x,2)+Math.pow(C.y-s.y(),2));let O=this.findOne(".top-right").x()<C.x?-1:1,T=this.findOne(".top-right").y()>C.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,this.findOne(".top-right").x(C.x+t),this.findOne(".top-right").y(C.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 C=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(C.x-s.x(),2)+Math.pow(s.y()-C.y,2));let O=C.x<s.x()?-1:1,T=s.y()<C.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,s.x(C.x-t),s.y(C.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 C=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()-C.x,2)+Math.pow(s.y()-C.y,2));let O=this.findOne(".bottom-right").x()<C.x?-1:1,T=this.findOne(".bottom-right").y()<C.y?-1:1;t=n*this.cos*O,a=n*this.sin*T,this.findOne(".bottom-right").x(C.x+t),this.findOne(".bottom-right").y(C.y+a)}}else console.error(Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(b=this.centeredScaling()||e.altKey,b){let C=this.findOne(".top-left"),O=this.findOne(".bottom-right"),T=C.x(),M=C.y(),H=this.getWidth()-O.x(),D=this.getHeight()-O.y();O.move({x:-T,y:-M}),C.move({x:H,y:D})}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(),S=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:a,width:A,height:S,rotation:je.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(Rg--,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 Tn;if(s.rotate(je.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,l=new Tn;l.translate(a.x,a.y),l.rotate(a.rotation),l.scale(a.width/i,a.height/i);let f=new Tn,c=e.width/i,h=e.height/i;if(this.flipEnabled()===!1)f.translate(e.x,e.y),f.rotate(e.rotation),f.translate(e.width<0?e.width:0,e.height<0?e.height:0),f.scale(Math.abs(c),Math.abs(h));else f.translate(e.x,e.y),f.rotate(e.rotation),f.scale(c,h);let u=f.multiply(l.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 Tn;A.multiply(d.copy().invert()).multiply(u).multiply(d).multiply(j);let S=A.decompose();g.setAttrs(S),(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(),l=this.padding(),f=this.anchorSize(),c=this.find("._anchor");c.forEach((H)=>{H.setAttrs({width:f,height:f,offsetX:f/2,offsetY:f/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:f/2+l,offsetY:f/2+l,visible:i&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:a/2,y:0,offsetY:f/2+l,visible:i&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:a,y:0,offsetX:f/2-l,offsetY:f/2+l,visible:i&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:f/2+l,visible:i&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:a,y:n/2,offsetX:f/2-l,visible:i&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:f/2+l,offsetY:f/2-l,visible:i&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:a/2,y:n,offsetY:f/2-l,visible:i&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:a,y:n,offsetX:f/2-l,offsetY:f/2-l,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,S=1/0;if(d<0)S=Math.min(S,-A/d);else if(d>0)S=Math.min(S,(n-A)/d);if(b<0)S=Math.min(S,-j/b);else if(b>0)S=Math.min(S,(a-j)/b);let C=j+b*S,O=A+d*S,T=Z._sign(n);this._batchChangeChild(".rotater",{x:C+b*u*T,y:O+d*u*T-l*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 i0.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 we.prototype.toObject.call(this)}clone(e){return we.prototype.clone.call(this,e)}getClientRect(){if(this.nodes().length>0)return super.getClientRect();else return{x:0,y:0,width:0,height:0}}}vt.isTransforming=()=>{return Rg>0};function gR(e){if(!(e instanceof Array))Z.warn("enabledAnchors value should be an array");if(e instanceof Array)e.forEach(function(t){if(N9.indexOf(t)===-1)Z.warn("Unknown anchor name: "+t+". Available names are: "+N9.join(", "))});return e||[]}vt.prototype.className="Transformer";rt(vt);U.addGetterSetter(vt,"enabledAnchors",N9,gR);U.addGetterSetter(vt,"flipEnabled",!0,Mn());U.addGetterSetter(vt,"resizeEnabled",!0);U.addGetterSetter(vt,"anchorSize",10,ge());U.addGetterSetter(vt,"rotateEnabled",!0);U.addGetterSetter(vt,"rotateLineVisible",!0);U.addGetterSetter(vt,"rotationSnaps",[]);U.addGetterSetter(vt,"rotateAnchorOffset",50,ge());U.addGetterSetter(vt,"rotateAnchorAngle",0,ge());U.addGetterSetter(vt,"rotateAnchorCursor","crosshair");U.addGetterSetter(vt,"rotationSnapTolerance",5,ge());U.addGetterSetter(vt,"borderEnabled",!0);U.addGetterSetter(vt,"anchorStroke","rgb(0, 161, 255)");U.addGetterSetter(vt,"anchorStrokeWidth",1,ge());U.addGetterSetter(vt,"anchorFill","white");U.addGetterSetter(vt,"anchorCornerRadius",0,ge());U.addGetterSetter(vt,"borderStroke","rgb(0, 161, 255)");U.addGetterSetter(vt,"borderStrokeWidth",1,ge());U.addGetterSetter(vt,"borderDash");U.addGetterSetter(vt,"keepRatio",!0);U.addGetterSetter(vt,"shiftBehavior","default");U.addGetterSetter(vt,"centeredScaling",!1);U.addGetterSetter(vt,"ignoreStroke",!1);U.addGetterSetter(vt,"padding",0,ge());U.addGetterSetter(vt,"nodes");U.addGetterSetter(vt,"node");U.addGetterSetter(vt,"boundBoxFunc");U.addGetterSetter(vt,"anchorDragBoundFunc");U.addGetterSetter(vt,"anchorStyleFunc");U.addGetterSetter(vt,"shouldOverdrawWholeArea",!1);U.addGetterSetter(vt,"useSingleNodeRotation",!0);U.backCompat(vt,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Mi extends pe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,je.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)}}Mi.prototype.className="Wedge";Mi.prototype._centroid=!0;Mi.prototype._attrsAffectingSize=["radius"];rt(Mi);U.addGetterSetter(Mi,"radius",0,ge());U.addGetterSetter(Mi,"angle",0,ge());U.addGetterSetter(Mi,"clockwise",!1);U.backCompat(Mi,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function ik(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var pR=[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],bR=[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 wR(e,t){let{data:a,width:n,height:s}=e,i,l,f,c,h,u,g,b,d,j,A,S,C,O,T,M,H,D,N,z,L=t+t+1,ee=n-1,te=s-1,J=t+1,ae=J*(J+1)/2,Q=new ik,Y=pR[t],$=bR[t],fe=null,P=Q,qe=null,be=null;for(let me=1;me<L;me++)if(P=P.next=new ik,me===J)fe=P;P.next=Q,f=l=0;for(let me=0;me<s;me++){S=C=O=T=c=h=u=g=0,b=J*(M=a[l]),d=J*(H=a[l+1]),j=J*(D=a[l+2]),A=J*(N=a[l+3]),c+=ae*M,h+=ae*H,u+=ae*D,g+=ae*N,P=Q;for(let de=0;de<J;de++)P.r=M,P.g=H,P.b=D,P.a=N,P=P.next;for(let de=1;de<J;de++)i=l+((ee<de?ee:de)<<2),c+=(P.r=M=a[i])*(z=J-de),h+=(P.g=H=a[i+1])*z,u+=(P.b=D=a[i+2])*z,g+=(P.a=N=a[i+3])*z,S+=M,C+=H,O+=D,T+=N,P=P.next;qe=Q,be=fe;for(let de=0;de<n;de++){if(a[l+3]=N=g*Y>>$,N!==0)N=255/N,a[l]=(c*Y>>$)*N,a[l+1]=(h*Y>>$)*N,a[l+2]=(u*Y>>$)*N;else a[l]=a[l+1]=a[l+2]=0;c-=b,h-=d,u-=j,g-=A,b-=qe.r,d-=qe.g,j-=qe.b,A-=qe.a,i=f+((i=de+t+1)<ee?i:ee)<<2,S+=qe.r=a[i],C+=qe.g=a[i+1],O+=qe.b=a[i+2],T+=qe.a=a[i+3],c+=S,h+=C,u+=O,g+=T,qe=qe.next,b+=M=be.r,d+=H=be.g,j+=D=be.b,A+=N=be.a,S-=M,C-=H,O-=D,T-=N,be=be.next,l+=4}f+=n}for(let me=0;me<n;me++){C=O=T=S=h=u=g=c=0,l=me<<2,b=J*(M=a[l]),d=J*(H=a[l+1]),j=J*(D=a[l+2]),A=J*(N=a[l+3]),c+=ae*M,h+=ae*H,u+=ae*D,g+=ae*N,P=Q;for(let ye=0;ye<J;ye++)P.r=M,P.g=H,P.b=D,P.a=N,P=P.next;let de=n;for(let ye=1;ye<=t;ye++)if(l=de+me<<2,c+=(P.r=M=a[l])*(z=J-ye),h+=(P.g=H=a[l+1])*z,u+=(P.b=D=a[l+2])*z,g+=(P.a=N=a[l+3])*z,S+=M,C+=H,O+=D,T+=N,P=P.next,ye<te)de+=n;l=me,qe=Q,be=fe;for(let ye=0;ye<s;ye++){if(i=l<<2,a[i+3]=N=g*Y>>$,N>0)N=255/N,a[i]=(c*Y>>$)*N,a[i+1]=(h*Y>>$)*N,a[i+2]=(u*Y>>$)*N;else a[i]=a[i+1]=a[i+2]=0;c-=b,h-=d,u-=j,g-=A,b-=qe.r,d-=qe.g,j-=qe.b,A-=qe.a,i=me+((i=ye+J)<te?i:te)*n<<2,c+=S+=qe.r=a[i],h+=C+=qe.g=a[i+1],u+=O+=qe.b=a[i+2],g+=T+=qe.a=a[i+3],qe=qe.next,b+=M=be.r,d+=H=be.g,j+=D=be.b,A+=N=be.a,S-=M,C-=H,O-=D,T-=N,be=be.next,l+=n}}}var lk=function(t){let a=Math.round(this.blurRadius());if(a>0)wR(t,a)};U.addGetterSetter(we,"blurRadius",0,ge(),U.afterSetFilter);var fk=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};U.addGetterSetter(we,"brightness",0,ge(),U.afterSetFilter);var rk=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 ok=function(e){let t=Math.pow((this.contrast()+100)/100,2),a=e.data,n=a.length,s=150,i=150,l=150;for(let f=0;f<n;f+=4)s=a[f],i=a[f+1],l=a[f+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,l/=255,l-=0.5,l*=t,l+=0.5,l*=255,s=s<0?0:s>255?255:s,i=i<0?0:i>255?255:i,l=l<0?0:l>255?255:l,a[f]=s,a[f+1]=i,a[f+2]=l};U.addGetterSetter(we,"contrast",0,ge(),U.afterSetFilter);var ck=function(e){var t,a,n,s,i,l,f,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)),S=(f={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(l=(i=this.embossDirection)===null||i===void 0?void 0:i.call(this))!==null&&l!==void 0?l:"top-left"])!==null&&f!==void 0?f:315,C=!!((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=S*Math.PI/180,H=Math.cos(M),D=Math.sin(M),N=0.12549019607843137*O,z=new Uint8ClampedArray(u),L=new Float32Array(g*b);for(let Q=0,Y=0;Y<u.length;Y+=4,Q++)L[Q]=0.2126*z[Y]+0.7152*z[Y+1]+0.0722*z[Y+2];let ee=[-1,0,1,-2,0,2,-1,0,1],te=[-1,-2,-1,0,0,0,1,2,1],J=[-g-1,-g,-g+1,-1,0,1,g-1,g,g+1],ae=(Q)=>Q<0?0:Q>255?255:Q;for(let Q=1;Q<b-1;Q++)for(let Y=1;Y<g-1;Y++){let $=Q*g+Y,fe=0,P=0;fe+=L[$+J[0]]*ee[0],P+=L[$+J[0]]*te[0],fe+=L[$+J[1]]*ee[1],P+=L[$+J[1]]*te[1],fe+=L[$+J[2]]*ee[2],P+=L[$+J[2]]*te[2],fe+=L[$+J[3]]*ee[3],P+=L[$+J[3]]*te[3],fe+=L[$+J[5]]*ee[5],P+=L[$+J[5]]*te[5],fe+=L[$+J[6]]*ee[6],P+=L[$+J[6]]*te[6],fe+=L[$+J[7]]*ee[7],P+=L[$+J[7]]*te[7],fe+=L[$+J[8]]*ee[8],P+=L[$+J[8]]*te[8];let qe=H*fe+D*P,be=ae(T+qe*N),me=$*4;if(C){let de=be-T;u[me]=ae(z[me]+de),u[me+1]=ae(z[me+1]+de),u[me+2]=ae(z[me+2]+de),u[me+3]=z[me+3]}else u[me]=u[me+1]=u[me+2]=be,u[me+3]=z[me+3]}for(let Q=0;Q<g;Q++){let Y=Q*4,$=((b-1)*g+Q)*4;u[Y]=z[Y],u[Y+1]=z[Y+1],u[Y+2]=z[Y+2],u[Y+3]=z[Y+3],u[$]=z[$],u[$+1]=z[$+1],u[$+2]=z[$+2],u[$+3]=z[$+3]}for(let Q=1;Q<b-1;Q++){let Y=Q*g*4,$=(Q*g+(g-1))*4;u[Y]=z[Y],u[Y+1]=z[Y+1],u[Y+2]=z[Y+2],u[Y+3]=z[Y+3],u[$]=z[$],u[$+1]=z[$+1],u[$+2]=z[$+2],u[$+3]=z[$+3]}return e};U.addGetterSetter(we,"embossStrength",0.5,ge(),U.afterSetFilter);U.addGetterSetter(we,"embossWhiteLevel",0.5,ge(),U.afterSetFilter);U.addGetterSetter(we,"embossDirection","top-left",void 0,U.afterSetFilter);U.addGetterSetter(we,"embossBlend",!1,void 0,U.afterSetFilter);function Ng(e,t,a,n,s){let i=a-t,l=s-n;if(i===0)return n+l/2;if(l===0)return n;let f=(e-t)/i;return f=l*f+n,f}var hk=function(e){let t=e.data,a=t.length,n=t[0],s=n,i,l=t[1],f=l,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<l)l=c;else if(c>f)f=c;if(g=t[T+2],g<h)h=g;else if(g>u)u=g}if(s===n)s=255,n=0;if(f===l)f=255,l=0;if(u===h)u=255,h=0;let d,j,A,S,C,O;if(b>0)d=s+b*(255-s),j=n-b*(n-0),A=f+b*(255-f),S=l-b*(l-0),C=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=(f+l)*0.5;A=f+b*(f-M),S=l+b*(l-M);let H=(u+h)*0.5;C=u+b*(u-H),O=h+b*(h-H)}for(let T=0;T<a;T+=4)t[T+0]=Ng(t[T+0],n,s,j,d),t[T+1]=Ng(t[T+1],l,f,S,A),t[T+2]=Ng(t[T+2],h,u,O,C)};U.addGetterSetter(we,"enhance",0,ge(),U.afterSetFilter);var uk=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}};U.addGetterSetter(we,"hue",0,ge(),U.afterSetFilter);U.addGetterSetter(we,"saturation",0,ge(),U.afterSetFilter);U.addGetterSetter(we,"luminance",0,ge(),U.afterSetFilter);var mk=function(e){let t=e.data,a=t.length,s=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,l=this.luminance()*127,f=1*s*Math.cos(i*Math.PI/180),c=1*s*Math.sin(i*Math.PI/180),h=0.299+0.701*f+0.167*c,u=0.587-0.587*f+0.33*c,g=0.114-0.114*f-0.497*c,b=0.299-0.299*f-0.328*c,d=0.587+0.413*f+0.035*c,j=0.114-0.114*f+0.293*c,A=0.299-0.3*f+1.25*c,S=0.587-0.586*f-1.05*c,C=0.114+0.886*f-0.2*c,O,T,M,H;for(let D=0;D<a;D+=4)O=t[D+0],T=t[D+1],M=t[D+2],H=t[D+3],t[D+0]=h*O+u*T+g*M+l,t[D+1]=b*O+d*T+j*M+l,t[D+2]=A*O+S*T+C*M+l,t[D+3]=H};var gk=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,l=n*s*Math.cos(i*Math.PI/180),f=n*s*Math.sin(i*Math.PI/180),c=0.299*n+0.701*l+0.167*f,h=0.587*n-0.587*l+0.33*f,u=0.114*n-0.114*l-0.497*f,g=0.299*n-0.299*l-0.328*f,b=0.587*n+0.413*l+0.035*f,d=0.114*n-0.114*l+0.293*f,j=0.299*n-0.3*l+1.25*f,A=0.587*n-0.586*l-1.05*f,S=0.114*n+0.886*l-0.2*f;for(let C=0;C<a;C+=4){let O=t[C+0],T=t[C+1],M=t[C+2],H=t[C+3];t[C+0]=c*O+h*T+u*M,t[C+1]=g*O+b*T+d*M,t[C+2]=j*O+A*T+S*M,t[C+3]=H}};U.addGetterSetter(we,"hue",0,ge(),U.afterSetFilter);U.addGetterSetter(we,"saturation",0,ge(),U.afterSetFilter);U.addGetterSetter(we,"value",0,ge(),U.afterSetFilter);var pk=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 dR=function(e,t,a){let n=e.data,s=t.data,i=e.width,l=e.height,f=a.polarCenterX||i/2,c=a.polarCenterY||l/2,h=Math.sqrt(f*f+c*c),u=i-f,g=l-c,b=Math.sqrt(u*u+g*g);h=b>h?b:h;let d=l,j=i,A=360/j*Math.PI/180;for(let S=0;S<j;S+=1){let C=Math.sin(S*A),O=Math.cos(S*A);for(let T=0;T<d;T+=1){u=Math.floor(f+h*T/d*O),g=Math.floor(c+h*T/d*C);let M=(g*i+u)*4,H=n[M+0],D=n[M+1],N=n[M+2],z=n[M+3];M=(S+T*i)*4,s[M+0]=H,s[M+1]=D,s[M+2]=N,s[M+3]=z}}},jR=function(e,t,a){let n=e.data,s=t.data,i=e.width,l=e.height,f=a.polarCenterX||i/2,c=a.polarCenterY||l/2,h=Math.sqrt(f*f+c*c),u=i-f,g=l-c,b=Math.sqrt(u*u+g*g);h=b>h?b:h;let d=l,j=i,A=a.polarRotation||0,S,C;for(u=0;u<i;u+=1)for(g=0;g<l;g+=1){let O=u-f,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,S=Math.floor(H),C=Math.floor(M);let D=(C*i+S)*4,N=n[D+0],z=n[D+1],L=n[D+2],ee=n[D+3];D=(g*i+u)*4,s[D+0]=N,s[D+1]=z,s[D+2]=L,s[D+3]=ee}},bk=function(e){let{width:t,height:a}=e,n,s,i,l,f,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 S=Z.createCanvasElement();S.width=t,S.height=a;let C=S.getContext("2d").getImageData(0,0,t,a);Z.releaseCanvas(S),dR(e,C,{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,D=1;if(A+O>t)M=T,H=0,D=-1;for(s=0;s<a;s+=1)for(n=M;n!==H;n+=D)i=Math.round(n+A)%t,g=(t*s+i)*4,f=C.data[g+0],c=C.data[g+1],h=C.data[g+2],u=C.data[g+3],b=(t*s+n)*4,C.data[b+0]=f,C.data[b+1]=c,C.data[b+2]=h,C.data[b+3]=u;for(s=0;s<a;s+=1){T=Math.floor(O);for(l=0;l<d;l+=1){for(n=0;n<T+1;n+=1)g=(t*s+n)*4,f=C.data[g+0],c=C.data[g+1],h=C.data[g+2],u=C.data[g+3],b=(t*s+T*2-n-1)*4,C.data[b+0]=f,C.data[b+1]=c,C.data[b+2]=h,C.data[b+3]=u;T*=2}}jR(C,e,{polarRotation:0})};U.addGetterSetter(we,"kaleidoscopePower",2,ge(),U.afterSetFilter);U.addGetterSetter(we,"kaleidoscopeAngle",0,ge(),U.afterSetFilter);function z9(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 Lh(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 qR(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 vR(e,t){let a=z9(e,0,0),n=z9(e,e.width-1,0),s=z9(e,0,e.height-1),i=z9(e,e.width-1,e.height-1),l=t||10;if(Lh(a,n)<l&&Lh(n,i)<l&&Lh(i,s)<l&&Lh(s,a)<l){let f=qR([n,a,i,s]),c=[];for(let h=0;h<e.width*e.height;h++){let u=Lh(f,[e.data[h*4],e.data[h*4+1],e.data[h*4+2]]);c[h]=u<l?0:255}return c}}function kR(e,t){for(let a=0;a<e.width*e.height;a++)e.data[4*a+3]=t[a]}function AR(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),l=[];for(let f=0;f<a;f++)for(let c=0;c<t;c++){let h=f*t+c,u=0;for(let g=0;g<s;g++)for(let b=0;b<s;b++){let d=f+g-i,j=c+b-i;if(d>=0&&d<a&&j>=0&&j<t){let A=d*t+j,S=n[g*s+b];u+=e[A]*S}}l[h]=u===2040?255:0}return l}function yR(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),l=[];for(let f=0;f<a;f++)for(let c=0;c<t;c++){let h=f*t+c,u=0;for(let g=0;g<s;g++)for(let b=0;b<s;b++){let d=f+g-i,j=c+b-i;if(d>=0&&d<a&&j>=0&&j<t){let A=d*t+j,S=n[g*s+b];u+=e[A]*S}}l[h]=u>=1020?255:0}return l}function SR(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),l=[];for(let f=0;f<a;f++)for(let c=0;c<t;c++){let h=f*t+c,u=0;for(let g=0;g<s;g++)for(let b=0;b<s;b++){let d=f+g-i,j=c+b-i;if(d>=0&&d<a&&j>=0&&j<t){let A=d*t+j,S=n[g*s+b];u+=e[A]*S}}l[h]=u}return l}var wk=function(e){let t=this.threshold(),a=vR(e,t);if(a)a=AR(a,e.width,e.height),a=yR(a,e.width,e.height),a=SR(a,e.width,e.height),kR(e,a);return e};U.addGetterSetter(we,"threshold",0,ge(),U.afterSetFilter);var dk=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()};U.addGetterSetter(we,"noise",0.2,ge(),U.afterSetFilter);var jk=function(e){let t=Math.ceil(this.pixelSize()),a=e.width,n=e.height,s=Math.ceil(a/t),i=Math.ceil(n/t),l=e.data;if(t<=0){Z.error("pixelSize value can not be <= 0");return}for(let f=0;f<s;f+=1)for(let c=0;c<i;c+=1){let h=0,u=0,g=0,b=0,d=f*t,j=d+t,A=c*t,S=A+t,C=0;for(let O=d;O<j;O+=1){if(O>=a)continue;for(let T=A;T<S;T+=1){if(T>=n)continue;let M=(a*T+O)*4;h+=l[M+0],u+=l[M+1],g+=l[M+2],b+=l[M+3],C+=1}}h=h/C,u=u/C,g=g/C,b=b/C;for(let O=d;O<j;O+=1){if(O>=a)continue;for(let T=A;T<S;T+=1){if(T>=n)continue;let M=(a*T+O)*4;l[M+0]=h,l[M+1]=u,l[M+2]=g,l[M+3]=b}}}};U.addGetterSetter(we,"pixelSize",8,ge(),U.afterSetFilter);var qk=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};U.addGetterSetter(we,"levels",0.5,ge(),U.afterSetFilter);var vk=function(e){let t=e.data,a=t.length,n=this.red(),s=this.green(),i=this.blue();for(let l=0;l<a;l+=4){let f=(0.34*t[l]+0.5*t[l+1]+0.16*t[l+2])/255;t[l]=f*n,t[l+1]=f*s,t[l+2]=f*i,t[l+3]=t[l+3]}};U.addGetterSetter(we,"red",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});U.addGetterSetter(we,"green",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});U.addGetterSetter(we,"blue",0,y9,U.afterSetFilter);var kk=function(e){let t=e.data,a=t.length,n=this.red(),s=this.green(),i=this.blue(),l=this.alpha();for(let f=0;f<a;f+=4){let c=1-l;t[f]=n*l+t[f]*c,t[f+1]=s*l+t[f+1]*c,t[f+2]=i*l+t[f+2]*c}};U.addGetterSetter(we,"red",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});U.addGetterSetter(we,"green",0,function(e){if(this._filterUpToDate=!1,e>255)return 255;else if(e<0)return 0;else return Math.round(e)});U.addGetterSetter(we,"blue",0,y9,U.afterSetFilter);U.addGetterSetter(we,"alpha",1,function(e){if(this._filterUpToDate=!1,e>1)return 1;else if(e<0)return 0;else return e});var Ak=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],l=t[n+2];t[n+0]=Math.min(255,s*0.393+i*0.769+l*0.189),t[n+1]=Math.min(255,s*0.349+i*0.686+l*0.168),t[n+2]=Math.min(255,s*0.272+i*0.534+l*0.131)}};var yk=function(e){let a=e.data;for(let n=0;n<a.length;n+=4){let s=a[n],i=a[n+1],l=a[n+2];if(0.2126*s+0.7152*i+0.0722*l>=128)a[n]=255-s,a[n+1]=255-i,a[n+2]=255-l}return e};var Sk=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};U.addGetterSetter(we,"threshold",0.5,ge(),U.afterSetFilter);var Ck=S1.Util._assign(S1,{Arc:Ti,Arrow:Z0,Circle:nf,Ellipse:l0,Image:ks,Label:Gh,Tag:$0,Line:ci,Path:Jt,Rect:sf,RegularPolygon:f0,Ring:W0,Sprite:hi,Star:r0,Text:Qt,TextPath:Ha,Transformer:vt,Wedge:Mi,Filters:{Blur:lk,Brightness:rk,Brighten:fk,Contrast:ok,Emboss:ck,Enhance:hk,Grayscale:uk,HSL:mk,HSV:gk,Invert:pk,Kaleidoscope:bk,Mask:wk,Noise:dk,Pixelate:jk,Posterize:qk,RGB:vk,RGBA:kk,Sepia:Ak,Solarize:yk,Threshold:Sk}});var _k=Ck;var ui=Mt(Za(),1);var an=Mt(Za(),1);var _1=S1;var Vk=Mt(xk(),1);var Ug=1;var U9=32,Gg=2;var Xg={};HR(Xg,{warnsIfNotActing:()=>tN,waitForCommitToBeReady:()=>NN,unhideTextInstance:()=>bN,unhideInstance:()=>pN,trackSchedulerEvent:()=>ON,suspendInstance:()=>RN,supportsPersistence:()=>nN,supportsMutation:()=>aN,supportsMicrotasks:()=>ZR,supportsHydration:()=>sN,startSuspendingCommit:()=>DN,shouldSetTextContent:()=>PR,shouldDeprioritizeSubtree:()=>LR,shouldAttemptEagerTransition:()=>FN,setCurrentUpdatePriority:()=>SN,scheduleTimeout:()=>JR,scheduleMicrotask:()=>$R,run:()=>zk,resolveUpdatePriority:()=>_N,resolveEventType:()=>BN,resolveEventTimeStamp:()=>TN,resetTextContent:()=>KR,resetFormInstance:()=>IN,resetAfterCommit:()=>XR,requestPostPaintCallback:()=>MN,removeChildFromContainer:()=>oN,removeChild:()=>rN,prepareUpdate:()=>GR,prepareScopeUpdate:()=>AN,preparePortalMount:()=>UR,prepareForCommit:()=>IR,preloadInstance:()=>xN,now:()=>E9,noTimeout:()=>WR,maySuspendCommit:()=>HN,isPrimaryRenderer:()=>eN,insertInContainerBefore:()=>fN,insertBefore:()=>Gk,idlePriority:()=>I9,hideTextInstance:()=>gN,hideInstance:()=>mN,getRootHostContext:()=>VR,getPublicInstance:()=>ER,getInstanceFromScope:()=>yN,getInstanceFromNode:()=>jN,getCurrentUpdatePriority:()=>CN,getCurrentEventPriority:()=>kN,getChildHostContext:()=>YR,finalizeInitialChildren:()=>zR,detachDeletedInstance:()=>dN,createTextInstance:()=>NR,createInstance:()=>RR,commitUpdate:()=>uN,commitTextUpdate:()=>cN,commitMount:()=>hN,clearContainer:()=>wN,cancelTimeout:()=>QR,beforeActiveInstanceBlur:()=>qN,appendInitialChild:()=>DR,appendChildToContainer:()=>lN,appendChild:()=>iN,afterActiveInstanceBlur:()=>vN,NotPendingTransition:()=>zN,HostTransitionContext:()=>EN});var Ek=Mt(Za(),1);var Dk={children:!0,ref:!0,key:!0,style:!0,forwardedRef:!0,unstable_applyCache:!0,unstable_applyDrawHitFromCache:!0},Rk=!1,Nk=!1,Yh=".react-konva-event",OR=!1;var BR=`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
- `,TR=`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
- `,MR={};function F1(e,t,a=MR){if(!Rk&&"zIndex"in t)console.warn(TR),Rk=!0;if(!Nk&&t.draggable){var n=t.x!==void 0||t.y!==void 0,s=t.onDragEnd||t.onDragMove;if(n&&!s)console.warn(BR),Nk=!0}for(var i in a){if(Dk[i])continue;var l=i.slice(0,2)==="on",f=a[i]!==t[i];if(l&&f){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=OR||t._useStrictMode,g={},b=!1;let d={};for(var i in t){if(Dk[i])continue;var l=i.slice(0,2)==="on",j=a[i]!==t[i];if(l&&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(!l&&(t[i]!==a[i]||u&&t[i]!==e.getAttr(i)))b=!0,g[i]=t[i]}if(b)e.setAttrs(g),el(e);for(var c in d)e.off(c+Yh),e.on(c+Yh,d[c])}function el(e){if(!je.autoDrawEnabled){var t=e.getLayer()||e.getStage();t&&t.batchDraw()}}Hk();var Ik={},xR={};_1.Node.prototype._applyProps=F1;var Uk=U9;function DR(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),el(e)}function RR(e,t,a){let n=_1[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=_1.Group;let s={},i={};for(var l in t){if(l==="ref")continue;var f=l.slice(0,2)==="on";if(f)i[l]=t[l];else s[l]=t[l]}let c=new n(s);return F1(c,i),c}function NR(e,t,a){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${e}"`)}function zR(e,t,a){return!1}function ER(e){return e}function IR(){return null}function UR(){return null}function GR(e,t,a,n){return xR}function XR(){}function KR(e){}function LR(e,t){return!1}function VR(){return Ik}function YR(){return Ik}var JR=setTimeout,QR=clearTimeout,ZR=!0,$R=typeof queueMicrotask==="function"?queueMicrotask:(e)=>Promise.resolve(null).then(e),WR=-1;function PR(e,t){return!1}var eN=!1,tN=!1,aN=!0,nN=!1,sN=!1;function iN(e,t){if(t.parent===e)t.moveToTop();else e.add(t);el(e)}function lN(e,t){if(t.parent===e)t.moveToTop();else e.add(t);el(e)}function Gk(e,t,a){t._remove(),e.add(t),t.setZIndex(a.getZIndex()),el(e)}function fN(e,t,a){Gk(e,t,a)}function rN(e,t){t.destroy(),t.off(Yh),el(e)}function oN(e,t){t.destroy(),t.off(Yh),el(e)}function cN(e,t,a){console.error(`Text components are not yet supported in ReactKonva. You text is: "${a}"`)}function hN(e,t,a){}function uN(e,t,a,n){F1(e,n,a)}function mN(e){e.hide(),el(e)}function gN(e){}function pN(e,t){if(t.visible==null||t.visible)e.show()}function bN(e,t){}function wN(e){}function dN(){}function jN(){return null}function qN(){}function vN(){}function kN(){return U9}function AN(){}function yN(){return null}function SN(e){Uk=e}function CN(){return Uk}function _N(){return Gg}function FN(){return!1}function ON(){}function BN(){return null}function TN(){return-1.1}function MN(){}function HN(){return!1}function xN(){return!0}function DN(){}function RN(){}function NN(){return null}var zN=null,EN=Ek.default.createContext(null);function IN(){}var ya=Mt(Za(),1);function Xk(e,t,a){if(!e)return;if(a(e)===!0)return e;let n=t?e.return:e.child;for(;n;){let s=Xk(n,t,a);if(s)return s;n=t?null:n.sibling}}function Kk(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch(t){return e}}var Kg=Kk(ya.createContext(null));class G9 extends ya.Component{render(){return ya.createElement(Kg.Provider,{value:this._reactInternals},this.props.children)}}function UN(){let e=ya.useContext(Kg);if(e===null)throw Error("its-fine: useFiber must be called within a <FiberProvider />!");let t=ya.useId();return ya.useMemo(()=>{for(let a of[e,e==null?void 0:e.alternate]){if(!a)continue;let n=Xk(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 GN=Symbol.for("react.context"),XN=(e)=>e!==null&&typeof e=="object"&&("$$typeof"in e)&&e.$$typeof===GN;function KN(){let e=UN(),[t]=ya.useState(()=>new Map);t.clear();let a=e;for(;a;){let n=a.type;XN(n)&&n!==Kg&&!t.has(n)&&t.set(n,ya.use(Kk(n))),a=a.return}return t}function Lk(){let e=KN();return ya.useMemo(()=>Array.from(e.keys()).reduce((t,a)=>(n)=>ya.createElement(t,null,ya.createElement(a.Provider,{...n,value:e.get(a)})),(t)=>ya.createElement(G9,{...t})),[e])}if(an.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 LN(e){let t=an.default.useRef({});return an.default.useLayoutEffect(()=>{t.current=e}),an.default.useLayoutEffect(()=>{return()=>{t.current={}}},[]),t.current}var VN=()=>{let e=an.default.useRef(0);return an.default.useMemo(()=>{e.current++},[]),e.current>1},YN=(e)=>{let t=an.default.useRef(null),a=an.default.useRef(null),n=an.default.useRef(null),s=LN(e),i=Lk(),l=an.default.useRef(null),f=(u)=>{let{forwardedRef:g}=e;if(!g)return;if(typeof g==="function")g(u);else g.current=u},c=VN(),h=()=>{f(null),O1.flushSyncFromReconciler(()=>{O1.updateContainer(null,n.current,null)}),a.current?.destroy(),a.current=null};return an.default.useLayoutEffect(()=>{if(l.current)clearTimeout(l.current),l.current=null;if(a.current)f(a.current);else a.current=new _1.Stage({width:e.width,height:e.height,container:t.current}),f(a.current),n.current=O1.createContainer(a.current,Ug,null,!1,null,"",console.error,console.error,console.error,null),O1.updateContainer(an.default.createElement(i,{},e.children),n.current,null,()=>{});return()=>{if(c)l.current=setTimeout(h,0);else h()}},[]),an.default.useLayoutEffect(()=>{f(a.current),F1(a.current,e,s),O1.updateContainer(an.default.createElement(i,{},e.children),n.current,null),O1.flushSyncWork()}),an.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})},Yk="Layer";var Jk="Group";var Lg="Rect";var Vg="Line";var Qk="Image";var Yg="Arrow";var O1=Vk.default(Xg),Zk=an.default.forwardRef((e,t)=>{return an.default.createElement(G9,{},an.default.createElement(YN,{...e,forwardedRef:t}))});var Pk=Mt(Wk(),1);var JN=({width:e,height:t,mediaDimensions:a,imageUrl:n,videoElement:s,annotations:i,scale:l,offset:f,onPan:c,onClick:h,className:u,isDrawing:g=!1,currentTool:b="arrow",currentColor:d="#ef4444",onAddAnnotation:j})=>{let[A]=Pk.default(n||"","anonymous"),S=ui.useRef(null),C=ui.useRef(!1),O=ui.useRef({x:0,y:0}),T=ui.useRef(null),M=ui.useRef(null),H=ui.useRef(null),D=ui.useRef(null);ui.useEffect(()=>{if(s&&S.current){let J=S.current.getLayer();if(!J)return;let ae=new _k.Animation(()=>{},J);return ae.start(),()=>{ae.stop()}}},[s]);let N=(J,ae=!1,Q)=>{let Y=J.getAbsoluteTransform().copy();Y.invert();let $=Q||J.getStage()?.getPointerPosition();if($){let fe=Y.point($);if(ae)return{x:Math.max(0,Math.min(a.width,fe.x)),y:Math.max(0,Math.min(a.height,fe.y))};return fe}return null},z=ui.useRef({isDrawing:g,currentTool:b,currentColor:d,onPan:c,offset:f,scale:l,mediaDimensions:a,onAddAnnotation:j});z.current={isDrawing:g,currentTool:b,currentColor:d,onPan:c,offset:f,scale:l,mediaDimensions:a,onAddAnnotation:j};let L=()=>{if(!C.current)return;C.current=!1;let{isDrawing:J,onAddAnnotation:ae,mediaDimensions:Q,currentTool:Y,currentColor:$}=z.current;if(J&&ae){let{width:fe,height:P}=Q,qe=(be,me)=>be/me;if(Y==="freehand"&&M.current){M.current.visible(!1);let be=M.current.points(),me=[];for(let de=0;de<be.length;de+=2)me.push([qe(be[de],fe),qe(be[de+1],P)]);if(me.length>1)ae({type:"freehand",color:$,points:me})}else if(Y==="line"&&M.current){M.current.visible(!1);let be=M.current.points(),me={type:"line",color:$,points:[[qe(be[0],fe),qe(be[1],P)],[qe(be[2],fe),qe(be[3],P)]]};ae(me)}else if(Y==="box"&&H.current){H.current.visible(!1);let be=H.current.x(),me=H.current.y(),de=H.current.width(),ye=H.current.height(),xe=[qe(be,fe),qe(me,P)],Qe=[qe(be+de,fe),qe(me+ye,P)];ae({type:"box",color:$,points:[xe,Qe]})}else if(Y==="arrow"&&D.current){D.current.visible(!1);let be=D.current.points(),me={type:"arrow",color:$,points:[[qe(be[0],fe),qe(be[1],P)],[qe(be[2],fe),qe(be[3],P)]]};ae(me)}}};ui.useEffect(()=>{let J=(Q)=>{if(!C.current)return;let Y=S.current?.getStage();if(!Y)return;let fe=Y.container().getBoundingClientRect(),P,qe;if("clientX"in Q)P=Q.clientX,qe=Q.clientY;else P=Q.touches[0].clientX,qe=Q.touches[0].clientY;let be={x:P-fe.left,y:qe-fe.top},{isDrawing:me,currentTool:de,onPan:ye,offset:xe}=z.current;if(me){if(de==="select")return;let Qe=N(S.current,!0,be);if(!Qe||!T.current)return;let ht=T.current,Oe=S.current?.getLayer();if(de==="freehand"&&M.current){let Ge=M.current.points().concat([Qe.x,Qe.y]);M.current.points(Ge)}else if(de==="line"&&M.current)M.current.points([ht.x,ht.y,Qe.x,Qe.y]);else if(de==="box"&&H.current)H.current.width(Qe.x-ht.x),H.current.height(Qe.y-ht.y);else if(de==="arrow"&&D.current)D.current.points([ht.x,ht.y,Qe.x,Qe.y]);Oe?.batchDraw()}else{if(!ye)return;let Qe=be.x-O.current.x,ht=be.y-O.current.y;O.current=be,ye({x:xe.x+Qe,y:xe.y+ht})}},ae=()=>{L()};return window.addEventListener("mousemove",J),window.addEventListener("mouseup",ae),window.addEventListener("touchmove",J),window.addEventListener("touchend",ae),()=>{window.removeEventListener("mousemove",J),window.removeEventListener("mouseup",ae),window.removeEventListener("touchmove",J),window.removeEventListener("touchend",ae)}},[]);let ee=(J)=>{if(g){if(b==="select")return;if(!J.target.getStage())return;let Q=N(S.current);if(!Q)return;if(Q.x<0||Q.x>a.width||Q.y<0||Q.y>a.height)return;C.current=!0,T.current=Q;let Y=S.current?.getLayer();if(!Y)return;if(b==="freehand"&&M.current)M.current.points([Q.x,Q.y]),M.current.stroke(d),M.current.visible(!0);else if(b==="line"&&M.current)M.current.points([Q.x,Q.y,Q.x,Q.y]),M.current.stroke(d),M.current.visible(!0);else if(b==="box"&&H.current)H.current.position(Q),H.current.width(0),H.current.height(0),H.current.stroke(d),H.current.visible(!0);else if(b==="arrow"&&D.current)D.current.points([Q.x,Q.y,Q.x,Q.y]),D.current.stroke(d),D.current.fill(d),D.current.visible(!0);Y.batchDraw()}else{if(!c)return;C.current=!0;let ae=J.target.getStage();if(ae){let Q=ae.getPointerPosition();if(Q)O.current=Q}}},te=(J,ae)=>{let{width:Q,height:Y}=a;switch(J.type){case"box":{let[$,fe]=J.points,P=Math.min($[0],fe[0])*Q,qe=Math.min($[1],fe[1])*Y,be=Math.abs(fe[0]-$[0])*Q,me=Math.abs(fe[1]-$[1])*Y;return I(Lg,{x:P,y:qe,width:be,height:me,stroke:J.color,strokeWidth:2.6/l,listening:!1},ae)}case"arrow":{let $=J.points.flat().map((fe,P)=>P%2===0?fe*Q:fe*Y);return I(Yg,{points:$,stroke:J.color,strokeWidth:2.6/l,fill:J.color,pointerLength:10/l,pointerWidth:10/l,listening:!1},ae)}case"line":case"freehand":{let $=J.points.flat().map((fe,P)=>P%2===0?fe*Q:fe*Y);return I(Vg,{points:$,stroke:J.color,strokeWidth:2.6/l,tension:0.5,lineCap:"round",lineJoin:"round",listening:!1},ae)}default:return null}};return I("div",{className:u,style:{width:e,height:t,overflow:"hidden",pointerEvents:!g&&!c?"none":"auto",cursor:g&&b!=="select"?"crosshair":c?C.current?"grabbing":"grab":"default"},children:I(Zk,{width:e,height:t,scaleX:l,scaleY:l,x:f.x,y:f.y,onMouseDown:ee,onClick:!g?h:void 0,onTap:!g?h:void 0,onTouchStart:ee,children:he(Yk,{children:[I(Qk,{ref:S,image:s||A,width:a.width,height:a.height}),i.map(te),he(Jk,{listening:!1,children:[I(Vg,{ref:M,strokeWidth:2.6/l,lineCap:"round",lineJoin:"round",visible:!1}),I(Lg,{ref:H,strokeWidth:2.6/l,visible:!1}),I(Yg,{ref:D,points:[],strokeWidth:2.6/l,pointerLength:10/l,pointerWidth:10/l,visible:!1})]})]})})})},c0=JN;var QN=jt.default.forwardRef(({file:e,onPlay:t,onPause:a,onTimeUpdate:n,annotations:s,startTime:i,shareId:l,children:f},c)=>{let h=jt.useRef(null),u=h,g=!!e.media?.original?.downloadUrl&&!!e.media?.metadata,b=jt.useRef(null),d=jt.useRef(null),j=jt.useRef(null),A=jt.useRef(null);jt.useImperativeHandle(c,()=>({play:()=>{if(h.current)h.current.play()},pause:()=>{if(h.current)h.current.pause()},seekTo:(Ae)=>{if(h.current)h.current.currentTime(Ae)},getCurrentTime:()=>{return(h.current?h.current.currentTime():0)??0},getDuration:()=>{return(h.current?h.current.duration():0)??0}}));let S=jt.useRef(!1),[C,O]=jt.useState(void 0),T=jt.useRef(null),[M,H]=jt.useState(1),[D,N]=jt.useState(!1),[z,L]=jt.useState({width:0,height:0}),ee=(Ae)=>{H(Ae),N(!0)},te=()=>{N(!1)},{isDrawing:J,currentTool:ae,currentColor:Q,addAnnotation:Y,annotations:$}=us(),fe=[...s||[],...$];jt.useEffect(()=>{if(!d.current)return;let Ae=new ResizeObserver((Ce)=>{let Ue=Ce[0];if(Ue)L({width:Ue.contentRect.width,height:Ue.contentRect.height})});return Ae.observe(d.current),()=>Ae.disconnect()},[]),jt.useEffect(()=>{if(z.width>0&&z.height>0){let Ae=e.media?.metadata?.originalWidth||1920,Ce=e.media?.metadata?.originalHeight||1080,Ue=Math.min(z.width/Ae,z.height/Ce);if(!D)H(Ue)}},[z.width,z.height,e.media?.metadata,D]),jt.useEffect(()=>{return()=>{T.current=null}},[]);let P={id:"original",url:e.media?.original?.downloadUrl||"",key:e.media?.original?.key??"",width:e.media?.metadata?.originalWidth??0,height:e.media?.metadata?.originalHeight??0,size:0,isRaw:!0,resolution:"Original"},qe=(e.media?.videoTranscodes??[]).map((Ae)=>{let Ce=Math.max(Ae.width,Ae.height),Ue=`${Ae.height}p`;if(Ce>=3840)Ue="2160p";else if(Ce>=1920)Ue="1080p";else if(Ce>=1280)Ue="720p";else if(Ce>=960)Ue="540p";else if(Ce>=640)Ue="360p";else if(Ce>=320)Ue="180p";return{...Ae,resolution:Ae.isRaw?"Original":Ue}}),be=qe.filter((Ae)=>!Ae.isRaw),de=(()=>{if(be.length===0)return P;if(typeof window>"u")return be[0];let Ae=window.innerWidth*(window.devicePixelRatio||1),Ce=[...be].sort((dt,ba)=>{let ji=dt.width??0,Hr=ba.width??0;return ji-Hr});return Ce.find((dt)=>(dt.width??0)>=Ae)||Ce[Ce.length-1]})(),[ye,xe]=jt.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:de?.resolution||"Original",currentSrc:de?.url||""}),[Qe,ht]=jt.useState(0),[Oe,Ge]=jt.useState(!0),[ft,Ie]=jt.useState(!1),He=jt.useRef(null),Ze=e.media?.metadata,Je=Ze?.frameRate||30,$e=Ze?.totalFrames||0,Xt=Ze?.duration||0,$t=e.proxyType==="audio",Ka=K9({dbTotalFrames:$e,containerDuration:Xt,frameRate:Je}),{currentFrame:Ht,seekToFrame:_a}=w9(T,Je,Ka,$t),st=Ht/Je,sn=Ka/Je,Ot=sn>0?st/sn*100:0,Xn={...ye,currentTime:st,duration:sn,progress:Ot};jt.useEffect(()=>{if(n)n(Ht/Je)},[Ht,Je,n]),jt.useEffect(()=>{if(!b.current)return;let Ae=document.createElement("video-js");Ae.classList.add("vjs-big-play-centered","!h-full","!w-full"),Ae.style.opacity="0",Ae.style.pointerEvents="none",b.current.appendChild(Ae);let Ce=u.current=se(Ae,{controls:!1,autoplay:!1,preload:"auto",playsinline:!0,sources:[{src:ye.currentSrc,type:"video/mp4"}]}),Ue=Ae.querySelector("video");if(Ue)O(Ue),T.current=Ue;else Ce.ready(()=>{let dt=Ce.tech({iWillNotUseThisInPlugins:!0})?.el();if(dt)O(dt),T.current=dt});return Ce.on("play",()=>{xe((dt)=>({...dt,isPlaying:!0})),t?.()}),Ce.on("pause",()=>{xe((dt)=>({...dt,isPlaying:!1})),a?.()}),Ce.on("ended",()=>xe((dt)=>({...dt,isPlaying:!1}))),Ce.on("loadedmetadata",()=>{Ie(!0)}),Ce.on("loadstart",()=>{Ie(!1)}),Ce.on("timeupdate",()=>{let dt=Ce.duration()||e.media?.metadata?.duration||0,ba=Ce.bufferedEnd();if(dt>0)ht(ba/dt*100)}),Ce.on("volumechange",()=>{let dt=Ce.volume(),ba=Ce.muted();xe((ji)=>({...ji,volume:dt||0,isMuted:ba||!1}))}),Ce.on("ratechange",()=>{xe((dt)=>({...dt,playbackRate:Ce.playbackRate()||1}))}),Ce.on("error",()=>{console.error("VideoJS Error:",Ce.error())}),Ce.volume(ye.volume),()=>{if(Ce&&!Ce.isDisposed())Ce.dispose(),u.current=null,T.current=null}},[e]),jt.useEffect(()=>{if(!ft)return;if(i!==void 0&&i!==null&&i>0){if(i!==He.current){He.current=i;let Ae=Math.floor(i*Je+0.45);_a(Ae)}}},[i,Je,_a,ft]);let kn=jt.useCallback(()=>{if(A.current)clearTimeout(A.current);if(ye.isFullScreen&&!S.current)A.current=setTimeout(()=>{Ge(!1)},1200)},[ye.isFullScreen]),Dn=jt.useCallback(()=>{Ge(!0),kn()},[kn]),Da=jt.useCallback(()=>{if(S.current=!0,A.current)clearTimeout(A.current);Ge(!0)},[]),Fa=jt.useCallback(()=>{S.current=!1,kn()},[kn]),Ra=jt.useCallback(()=>{if(ye.isFullScreen){if(A.current)clearTimeout(A.current);Ge(!1)}},[ye.isFullScreen]);jt.useEffect(()=>{return()=>{if(A.current)clearTimeout(A.current)}},[]),jt.useEffect(()=>{if(!ye.isFullScreen){if(Ge(!0),A.current)clearTimeout(A.current)}else Dn()},[ye.isPlaying,ye.isFullScreen,Dn]);let Na=jt.useCallback(()=>{if(us.getState().isDrawing)return;let Ae=u.current;if(!Ae)return;if(Ae.paused()||Ae.ended()){let Ce=Ae.play();if(Ce!==void 0)Ce.catch((Ue)=>{if(Ue.name==="AbortError")return;console.error("Play failed:",Ue)})}else Ae.pause()},[]);jt.useEffect(()=>{let Ae=(Ce)=>{let Ue=document.activeElement;if(Ue&&(Ue.tagName==="INPUT"||Ue.tagName==="TEXTAREA"||Ue instanceof HTMLElement&&Ue.isContentEditable))return;let dt=Ce.key===" ",ba=Ue&&(Ue.tagName==="BUTTON"||Ue.tagName==="A"||Ue.tagName==="SELECT"||Ue.tagName==="OPTION"||Ue.getAttribute("role")==="button"||Ue.getAttribute("role")==="link"||Ue.getAttribute("role")==="checkbox"||Ue.getAttribute("role")==="radio"||Ue.getAttribute("role")==="menuitem");if(dt&&ba)return;if(Ce.key===" "||Ce.key.toLowerCase()==="k")Ce.preventDefault(),Na()};return window.addEventListener("keydown",Ae),()=>{window.removeEventListener("keydown",Ae)}},[Na]);let ns=()=>{let Ae=u.current;if(!Ae)return;let Ce=!ye.isLooping;Ae.loop(Ce),xe((Ue)=>({...Ue,isLooping:Ce}))},ve=(Ae)=>{xe((Ue)=>({...Ue,volume:Ae,isMuted:Ae===0}));let Ce=u.current;if(!Ce)return;if(Ce.volume(Ae),Ae>0&&Ce.muted())Ce.muted(!1);else if(Ae===0&&!Ce.muted())Ce.muted(!0)},Re=()=>{let Ae=u.current;if(!Ae)return;if(Ae.muted()){if(Ae.muted(!1),Ae.volume()===0)Ae.volume(0.5)}else Ae.muted(!0)},et=(Ae)=>{let Ce=u.current;if(!Ce)return;Ce.playbackRate(Ae)},_t=(Ae)=>{let Ce=u.current;if(!Ce)return;let Ue=!Ce.paused(),dt=Ce.currentTime();xe((ba)=>({...ba,currentResolution:Ae.resolution,currentSrc:Ae.url})),Ce.src({type:"video/mp4",src:Ae.url}),Ce.one("loadedmetadata",()=>{if(Ce.currentTime(dt),Ue){let ba=Ce.play();if(ba!==void 0)ba.catch((ji)=>{if(ji.name==="AbortError")return;console.error("Play after seek failed:",ji)})}Ce.playbackRate(ye.playbackRate)})},Oa=()=>{if(!j.current)return;if(!document.fullscreenElement)j.current.requestFullscreen(),xe((Ae)=>({...Ae,isFullScreen:!0}));else document.exitFullscreen(),xe((Ae)=>({...Ae,isFullScreen:!1}))},ia=async(Ae)=>{try{let Ce=l?await Bt.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:l,fileId:e.id},json:{key:Ae}}):await Bt.api.files["download-url"].$post({json:{key:Ae,assetId:e.id}});if(!Ce.ok)return;let{url:Ue}=await Ce.json(),dt=document.createElement("a");dt.href=Ue,dt.download="",document.body.appendChild(dt),dt.click(),document.body.removeChild(dt)}catch{}};jt.useEffect(()=>{let Ae=()=>{xe((Ce)=>({...Ce,isFullScreen:!!document.fullscreenElement}))};return document.addEventListener("fullscreenchange",Ae),()=>document.removeEventListener("fullscreenchange",Ae)},[]);let ln=e.media?.metadata?.originalWidth||1920,Pa=e.media?.metadata?.originalHeight||1080,Vs=M,ze=(z.width-ln*Vs)/2,Xe=(z.height-Pa*Vs)/2;if(!g)return I("div",{className:"flex h-full w-full items-center justify-center",children:I("p",{className:"text-muted-foreground",children:"Media is not available."})});return he("div",{ref:j,className:jn("group shadow-2xl font-sans select-none flex flex-col mx-auto transition-all duration-300 relative",ye.isFullScreen?"h-full w-full rounded-none bg-black":"w-full h-full",!Oe&&ye.isFullScreen?"cursor-none":""),onMouseMove:Dn,onMouseLeave:Ra,children:[he("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[!ye.isFullScreen&&f,he("div",{ref:d,className:jn("flex-1 bg-black cursor-pointer relative flex items-center justify-center overflow-hidden min-h-0"),onClick:Na,"data-vjs-player":!0,"data-testid":"video-area",children:[I("div",{ref:b,className:"absolute inset-0 z-[-1]"}),$t?I("div",{className:"flex flex-col items-center justify-center text-muted-foreground w-full h-full pointer-events-none select-none",children:I(X9,{className:jn("w-16 h-16 text-foreground/75 transition-transform duration-500",ye.isPlaying?"animate-pulse scale-110 text-primary":"")})}):C&&z.width>0&&I(c0,{width:z.width,height:z.height,mediaDimensions:{width:ln,height:Pa},videoElement:C,annotations:fe,scale:Vs,offset:{x:ze,y:Xe},className:"absolute inset-0",onClick:Na,isDrawing:J,currentTool:ae,currentColor:Q,onAddAnnotation:Y}),!ye.isPlaying&&!J&&I("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20 pointer-events-none z-10",children:I("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:I(w1,{className:"w-10 h-10 text-white ml-1 fill-white"})})})]})]}),I(sv,{state:Xn,zoom:M,isControlsVisible:Oe,buffered:Qe,data:e,resolutions:qe,togglePlay:Na,toggleLoop:ns,toggleMute:Re,handleVolumeChange:ve,changePlaybackRate:et,changeResolution:_t,handleDownload:ia,toggleFullScreen:Oa,onZoomChange:ee,onZoomReset:te,frameRate:Je,totalFrames:Ka,currentFrame:Ht,seekToFrame:_a,onMouseEnter:Da,onMouseLeave:Fa})]})}),eA=QN;var wt=Mt(Za(),1);function ZN(e){let t=e.media?.original?.downloadUrl?{id:"original",url:e.media.original.downloadUrl,key:e.media.original.key??"",width:e.media?.metadata?.originalWidth??0,height:e.media?.metadata?.originalHeight??0,size:0,isRaw:!0,resolution:"Original"}:null,a=(e.media?.videoTranscodes??[]).map((s)=>{let i=Math.max(s.width,s.height),l=`${s.height}p`;if(i>=3840)l="2160p";else if(i>=1920)l="1080p";else if(i>=1280)l="720p";else if(i>=960)l="540p";else if(i>=640)l="360p";else if(i>=320)l="180p";return{...s,resolution:s.isRaw?"Original":l}});if(!a.some((s)=>s.isRaw)&&t)return[...a,t];return a}var tA=wt.forwardRef(function({file:t,shareId:a,isActive:n,muted:s=!0,volume:i=1,annotations:l,onStateChange:f,onActivate:c,onRequestTogglePlay:h,onTimeUpdate:u,onPlay:g},b){let d=wt.useRef(null),j=wt.useRef(null),A=wt.useRef(null),S=wt.useRef(null),[C,O]=wt.useState(void 0),{isDrawing:T,currentTool:M,currentColor:H,addAnnotation:D,annotations:N}=us(),[z,L]=wt.useState({width:0,height:0}),[ee,te]=wt.useState(1),[J,ae]=wt.useState(!1),[Q,Y]=wt.useState(null),[$,fe]=wt.useState(!1),[P,qe]=wt.useState(!1),[be,me]=wt.useState(1),[de,ye]=wt.useState(0),[xe,Qe]=wt.useState(i),[ht,Oe]=wt.useState(s),[Ge,ft]=wt.useState(!1),Ie=t.media?.metadata,He=Ie?.frameRate||30,Ze=Ie?.totalFrames||0,Je=Ie?.duration||0,$e=K9({dbTotalFrames:Ze,containerDuration:Je,frameRate:He}),Xt=ZN(t),Ka=Xt.filter((ze)=>!ze.isRaw)[0]??Xt[0],[Ht,_a]=wt.useState(Ka?.resolution??"Original"),st=wt.useRef(Ka?.url),sn=t.proxyType==="audio",{currentFrame:Ot,seekToFrame:Xn}=w9(S,He,$e,sn),kn=wt.useRef(ee);kn.current=ee;let Dn=wt.useRef(Ot);Dn.current=Ot,wt.useEffect(()=>{if(!A.current)return;let ze=new ResizeObserver((Xe)=>{let Ae=Xe[0];if(Ae)L({width:Ae.contentRect.width,height:Ae.contentRect.height})});return ze.observe(A.current),()=>ze.disconnect()},[]);let Da=Ie?.originalWidth||1920,Fa=Ie?.originalHeight||1080;wt.useEffect(()=>{if(z.width>0&&z.height>0&&!J){let ze=Math.min(z.width/Da,z.height/Fa);te(ze)}},[z.width,z.height,Da,Fa,J]),wt.useEffect(()=>{_a(Ka?.resolution??"Original"),st.current=Ka?.url},[t.id]),wt.useEffect(()=>{if(!j.current)return;let ze=document.createElement("video-js");ze.classList.add("vjs-big-play-centered","!h-full","!w-full"),ze.style.opacity="0",ze.style.pointerEvents="none",j.current.appendChild(ze);let Xe=d.current=se(ze,{controls:!1,autoplay:!1,preload:"auto",playsinline:!0,sources:[{src:st.current??"",type:"video/mp4"}]}),Ae=ze.querySelector("video");if(Ae)O(Ae),S.current=Ae;else Xe.ready(()=>{let Ce=Xe.tech({iWillNotUseThisInPlugins:!0})?.el();if(Ce)O(Ce),S.current=Ce});return Xe.on("play",()=>{fe(!0),g?.()}),Xe.on("pause",()=>fe(!1)),Xe.on("ended",()=>fe(!1)),Xe.on("loadedmetadata",()=>ft(!0)),Xe.on("loadstart",()=>ft(!1)),Xe.on("timeupdate",()=>{let Ce=Xe.duration()||Je||0,Ue=Xe.bufferedEnd();if(Ce>0)ye(Ue/Ce*100)}),Xe.on("volumechange",()=>{Qe(Xe.volume()||0),Oe(Xe.muted()||!1)}),Xe.on("ratechange",()=>me(Xe.playbackRate()||1)),()=>{if(Xe&&!Xe.isDisposed())Xe.dispose(),d.current=null,S.current=null}},[t.id]),wt.useEffect(()=>{let ze=d.current;if(!ze||!Ge)return;ze.muted(s),ze.volume(i)},[s,i,Ge]),wt.useEffect(()=>{f({kind:"video",zoom:ee,video:{frameRate:He,totalFrames:$e,currentFrame:Ot,isPlaying:$,volume:xe,isMuted:ht,playbackRate:be,isLooping:P,currentResolution:Ht,resolutions:Xt,buffered:de}})},[ee,He,$e,Ot,$,xe,ht,be,P,Ht,de]),wt.useEffect(()=>{if(n)u?.(Ot/He)},[Ot,He,n,u]);let Ra=wt.useCallback((ze)=>{let Ae=kn.current*ze;if(Ae<0.01||Ae>50)return;te(Ae),ae(!0)},[]),Na=wt.useCallback(()=>{ae(!1),Y(null)},[]),ns=wt.useCallback((ze)=>yp(ze,$e),[$e]),ve=wt.useCallback(async(ze)=>{let Xe=ze??t.media?.original?.key;if(!Xe||!t.id)return;try{let Ae=a?await Bt.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:t.id},json:{key:Xe}}):await Bt.api.files["download-url"].$post({json:{key:Xe,assetId:t.id}});if(!Ae.ok)return;let{url:Ce}=await Ae.json(),Ue=document.createElement("a");Ue.href=Ce,Ue.download="",document.body.appendChild(Ue),Ue.click(),document.body.removeChild(Ue)}catch{}},[t.id,t.media?.original?.key,a]),Re=wt.useCallback((ze)=>{let Xe=d.current;if(!Xe)return;let Ae=Xt.find((dt)=>dt.resolution===ze);if(!Ae)return;let Ce=!Xe.paused(),Ue=Xe.currentTime();_a(ze),st.current=Ae.url,Xe.src({type:"video/mp4",src:Ae.url}),Xe.one("loadedmetadata",()=>{if(Xe.currentTime(Ue),Ce){let dt=Xe.play();if(dt!==void 0)dt.catch(()=>{})}})},[Xt]);wt.useImperativeHandle(b,()=>({getKind:()=>"video",play:()=>{let ze=d.current?.play();if(ze!==void 0)ze.catch(()=>{})},pause:()=>d.current?.pause(),togglePlay:()=>{let ze=d.current;if(!ze)return;if(ze.paused()||ze.ended()){let Xe=ze.play();if(Xe!==void 0)Xe.catch(()=>{})}else ze.pause()},seekToFrame:(ze)=>Xn(ns(ze)),seekToSecond:(ze)=>{let Xe=Math.floor(ze*He+0.45);Xn(ns(Xe))},stepFrame:(ze)=>Xn(ns(Dn.current+ze)),setMuted:(ze)=>d.current?.muted(ze),setVolume:(ze)=>{let Xe=d.current;if(!Xe)return;if(Xe.volume(ze),ze>0&&Xe.muted())Xe.muted(!1);else if(ze===0&&!Xe.muted())Xe.muted(!0)},setPlaybackRate:(ze)=>d.current?.playbackRate(ze),toggleLoop:()=>{let ze=d.current;if(!ze)return;let Xe=!ze.loop();ze.loop(Xe),qe(Xe)},changeResolution:Re,zoomBy:Ra,fit:Na,panBy:(ze,Xe)=>Y((Ae)=>{let Ce=kn.current,Ue=Ae??{x:(z.width-Da*Ce)/2,y:(z.height-Fa*Ce)/2};return{x:Ue.x+ze,y:Ue.y+Xe}}),download:(ze)=>ve(ze)}),[Xn,ns,He,Ra,Na,Re,ve,z.width,z.height,Da,Fa]);let et=[...l,...n?N:[]],_t=ee,Oa=(z.width-Da*_t)/2,ia=(z.height-Fa*_t)/2,ln=Q?.x??Oa,Pa=Q?.y??ia,Vs=wt.useCallback(()=>{if(us.getState().isDrawing)return;if(!n){c?.();return}h?.()},[n,c,h]);if(!t.media?.original?.downloadUrl||!Ie)return I("div",{className:"flex h-full w-full items-center justify-center bg-black",children:I("p",{className:"text-muted-foreground",children:"Media is not available."})});return he("div",{ref:A,className:jn("relative flex flex-1 cursor-pointer items-center justify-center overflow-hidden bg-black"),onClick:Vs,"data-testid":"compare-video-area",children:[I("div",{ref:j,className:"absolute inset-0 z-[-1]"}),sn?I("div",{className:"flex flex-col items-center justify-center text-muted-foreground w-full h-full pointer-events-none select-none",children:I(X9,{className:jn("w-16 h-16 text-foreground/75 transition-transform duration-500",$?"animate-pulse scale-110 text-primary":"")})}):C&&z.width>0&&I(c0,{width:z.width,height:z.height,mediaDimensions:{width:Da,height:Fa},videoElement:C,annotations:et,scale:_t,offset:{x:ln,y:Pa},className:"absolute inset-0",onClick:Vs,isDrawing:n&&T,currentTool:M,currentColor:H,onAddAnnotation:n?D:void 0}),!$&&!T&&I("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/20",children:I("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:I(w1,{className:"ml-1 h-8 w-8 fill-white text-white"})})})]})});var aA={id:"video",name:"Video",match:(e)=>e.proxyType==="video"||e.proxyType==="audio",viewer:eA,comparePane:tA,commentsConfig:{hasTimestamp:!0,hasAnnotations:!0,hasAiBots:!0}};var L9=Mt(Za(),1);function V9(){let[e,t]=L9.useState({width:window.innerWidth,height:window.innerHeight});return L9.useLayoutEffect(()=>{function a(){t({width:window.innerWidth,height:window.innerHeight})}return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),e}function Y9(e,t){if(!e||e.length===0)return null;let a=e.filter((l)=>!l.isRaw),s=[...a.length>0?a:e].sort((l,f)=>{let c=l.width??0,h=f.width??0;if(c!==h)return h-c;return(l.isRaw?1:0)-(f.isRaw?1:0)}),i=s.filter((l)=>(l.width??0)>=t);if(i.length>0)return i.sort((l,f)=>{let c=l.width??0,h=f.width??0;if(c!==h)return c-h;return(l.isRaw?1:0)-(f.isRaw?1:0)}),i[0];return s[0]}var as=Mt(Za(),1);function sA({zoom:e,onZoomIn:t,onZoomOut:a,onFit:n,onDownload:s,canDownload:i,onCopy:l,copied:f=!1,canCopy:c=!0,fullscreen:h}){return he("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:[he("div",{className:"flex items-center gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5 mr-auto",children:[I("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:Le.zoom_out(),children:I(El,{size:16})}),he("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),"%"]}),I("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:Le.zoom_in(),children:I(d1,{size:16})})]}),I("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:Le.fit()}),l&&he("button",{onClick:l,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:Le.copy_image_to_clipboard(),children:[f?I(b1,{size:14,className:"text-green-500"}):I(nA,{size:14}),f?Le.copied():Le.copy()]}),he("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:Le.download_original_image(),children:[I(Ci,{size:14}),Le.download()]}),h&&I("button",{onClick:h.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:Le.fullscreen(),children:h.isFullScreen?I(q9,{size:16}):I(j9,{size:16})})]})}var $N=as.default.forwardRef(({file:e,annotations:t,shareId:a,children:n},s)=>{as.useImperativeHandle(s,()=>({play:()=>{},pause:()=>{},seekTo:()=>{}}));let{width:i}=V9(),{isDrawing:l,currentTool:f,currentColor:c,addAnnotation:h,annotations:u}=us(),[g,b]=as.useState({width:0,height:0}),[d,j]=as.useState(1),[A,S]=as.useState({x:0,y:0}),[C,O]=as.useState(!1),T=as.useRef(null),M=as.useCallback((fe)=>{if(T.current)T.current.disconnect(),T.current=null;if(fe!==null){let P=new ResizeObserver((qe)=>{let be=qe[0];if(be)b({width:be.contentRect.width,height:be.contentRect.height})});P.observe(fe),T.current=P}},[]),H=e.media?.metadata?.originalWidth??1920,D=e.media?.metadata?.originalHeight??1080,N=g.width,z=g.height,L=1;if(N>0&&z>0)L=Math.min(N/H,z/D);as.useEffect(()=>{if(N>0&&z>0){j(L);let fe=(N-H*L)/2,P=(z-D*L)/2;S({x:fe,y:P})}},[e.id,N,z,L,H,D]);let ee=(fe)=>{let P=N/2,qe=z/2,be=d*fe;if(be<0.01||be>50)return;let me=P-(P-A.x)*(be/d),de=qe-(qe-A.y)*(be/d);j(be),S({x:me,y:de})},te=()=>{j(L);let fe=(N-H*L)/2,P=(z-D*L)/2;S({x:fe,y:P})},J=e.media?.original?.downloadUrl,ae=Y9(e.media?.imageTranscodes,i);if(ae?.url)J=ae.url;let Q=async()=>{let fe=e.media?.original?.key;if(!fe||!e.id)return;try{let P=a?await Bt.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:e.id},json:{key:fe}}):await Bt.api.files["download-url"].$post({json:{key:fe,assetId:e.id}});if(!P.ok)return;let{url:qe}=await P.json(),be=document.createElement("a");be.href=qe,be.download="",document.body.appendChild(be),be.click(),document.body.removeChild(be)}catch{}},Y=async()=>{let fe=J;if(!fe)return;try{let P=(async()=>{let be=await(await fetch(fe)).blob(),me=new Image;me.crossOrigin="anonymous";let de=URL.createObjectURL(be);me.src=de;try{await new Promise((ht,Oe)=>{me.onload=ht,me.onerror=(Ge)=>Oe(Error("Failed to load image: "+String(Ge)))});let ye=document.createElement("canvas");ye.width=me.width,ye.height=me.height;let xe=ye.getContext("2d");if(!xe)throw Error("Could not get canvas context");xe.drawImage(me,0,0);let Qe=await new Promise((ht)=>{ye.toBlob(ht,"image/png")});if(!Qe)throw Error("Failed to convert image to PNG");return Qe}finally{URL.revokeObjectURL(de)}})();await navigator.clipboard.write([new ClipboardItem({"image/png":P})]),O(!0),setTimeout(()=>O(!1),2000)}catch(P){console.error("Failed to copy image to clipboard:",P)}},$=[...t||[],...u];return he("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[he("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[n,I("div",{ref:M,className:"flex-1 relative overflow-hidden",children:I(c0,{width:N,height:z,mediaDimensions:{width:H,height:D},imageUrl:J,annotations:$,scale:d,offset:A,onPan:S,className:"absolute inset-0 z-0",isDrawing:l,currentTool:f,currentColor:c,onAddAnnotation:h})})]}),I(sA,{zoom:d,onZoomIn:()=>ee(1.2),onZoomOut:()=>ee(0.8),onFit:te,onDownload:Q,canDownload:!!e.media?.original?.key,onCopy:Y,copied:C,canCopy:!!J})]})}),iA=$N;var Ga=Mt(Za(),1);var WN=0.01,PN=50,lA=Ga.forwardRef(function({file:t,shareId:a,isActive:n,annotations:s,onStateChange:i,onUserPan:l,onActivate:f},c){let{width:h}=V9(),{isDrawing:u,currentTool:g,currentColor:b,addAnnotation:d,annotations:j}=us(),[A,S]=Ga.useState({width:0,height:0}),[C,O]=Ga.useState(1),[T,M]=Ga.useState({x:0,y:0}),H=Ga.useRef(null),D=Ga.useRef(C);D.current=C;let N=Ga.useRef(T);N.current=T;let z=Ga.useCallback((me)=>{if(H.current)H.current.disconnect(),H.current=null;if(me!==null){let de=new ResizeObserver((ye)=>{let xe=ye[0];if(xe)S({width:xe.contentRect.width,height:xe.contentRect.height})});de.observe(me),H.current=de}},[]),L=t.media?.metadata?.originalWidth??1920,ee=t.media?.metadata?.originalHeight??1080,te=A.width,J=A.height,ae=1;if(te>0&&J>0)ae=Math.min(te/L,J/ee);Ga.useEffect(()=>{if(te>0&&J>0)O(ae),M({x:(te-L*ae)/2,y:(J-ee*ae)/2})},[t.id,te,J,ae,L,ee]);let Q=Ga.useCallback((me)=>{let de=te/2,ye=J/2,xe=D.current,Qe=xe*me;if(Qe<WN||Qe>PN)return;let ht=N.current;M({x:de-(de-ht.x)*(Qe/xe),y:ye-(ye-ht.y)*(Qe/xe)}),O(Qe)},[te,J]),Y=Ga.useCallback(()=>{O(ae),M({x:(te-L*ae)/2,y:(J-ee*ae)/2})},[ae,te,J,L,ee]),$=t.media?.original?.downloadUrl,fe=Y9(t.media?.imageTranscodes,h);if(fe?.url)$=fe.url;let P=Ga.useCallback(async()=>{let me=t.media?.original?.key;if(!me||!t.id)return;try{let de=a?await Bt.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:t.id},json:{key:me}}):await Bt.api.files["download-url"].$post({json:{key:me,assetId:t.id}});if(!de.ok)return;let{url:ye}=await de.json(),xe=document.createElement("a");xe.href=ye,xe.download="",document.body.appendChild(xe),xe.click(),document.body.removeChild(xe)}catch{}},[t.id,t.media?.original?.key,a]);Ga.useImperativeHandle(c,()=>({getKind:()=>"image",play:()=>{},pause:()=>{},togglePlay:()=>{},seekToFrame:()=>{},seekToSecond:()=>{},stepFrame:()=>{},setMuted:()=>{},setVolume:()=>{},setPlaybackRate:()=>{},toggleLoop:()=>{},changeResolution:()=>{},zoomBy:(me)=>Q(me),fit:Y,panBy:(me,de)=>M((ye)=>({x:ye.x+me,y:ye.y+de})),download:P}),[Q,Y,P]),Ga.useEffect(()=>{i({kind:"image",zoom:C})},[C,i]);let qe=[...s,...n?j:[]],be=Ga.useCallback((me)=>{let de=N.current,ye=me.x-de.x,xe=me.y-de.y;if(M(me),ye!==0||xe!==0)l?.(ye,xe)},[l]);if(!$)return I("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:I("p",{className:"text-muted-foreground",children:"Preview unavailable"})});return I("div",{ref:z,className:"relative flex-1 overflow-hidden bg-black",onMouseDown:f,children:I(c0,{width:te,height:J,mediaDimensions:{width:L,height:ee},imageUrl:$,annotations:qe,scale:C,offset:T,onPan:be,className:"absolute inset-0 z-0",isDrawing:n&&u,currentTool:g,currentColor:b,onAddAnnotation:n?d:void 0})})});var fA={id:"image",name:"Image",match:(e)=>e.proxyType==="image",viewer:iA,comparePane:lA,commentsConfig:{hasTimestamp:!1,hasAnnotations:!0,hasAiBots:!0}};var Xs=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),al=[1/0,1/0,-1/0,-1/0],_r=new Float32Array(al),Pg=[0.001,0,0,0.001,0,0];var Us={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ff={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};var ot={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},ez={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 nn={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},a5={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},xa={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 T1={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var b5={ERRORS:0,WARNINGS:1,INFOS:5},g0={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},Jh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},tz={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},w5=b5.WARNINGS;function az(e){if(Number.isInteger(e))w5=e}function nz(){return w5}function d5(e){if(w5>=b5.INFOS)console.info(`Info: ${e}`)}function ct(e){if(w5>=b5.WARNINGS)console.warn(`Warning: ${e}`)}function Rt(e){throw Error(e)}function Ca(e,t){if(!e)Rt(t)}function sz(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function MA(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=lz(e)}catch{}}let n=t?URL.parse(e,t):URL.parse(e);return sz(n)?n:null}function HA(e,t,a=!1){let n=URL.parse(e);if(n)return n.hash=t,n.href;if(a&&MA(e,"http://example.com"))return e.split("#",1)[0]+`${t?`#${t}`:""}`;return""}function e8(e){return e.substring(e.lastIndexOf("/")+1)}function lt(e,t,a,n=!1){return Object.defineProperty(e,t,{value:a,enumerable:!n,configurable:!0,writable:!1}),a}var Mr=function(){function t(a,n){this.message=a,this.name=n}return t.prototype=Error(),t.constructor=t,t}();class l5 extends Mr{constructor(e,t){super(e,"PasswordException");this.code=t}}class n5 extends Mr{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class f5 extends Mr{constructor(e){super(e,"InvalidPDFException")}}class tu extends Mr{constructor(e,t,a){super(e,"ResponseException");this.status=t,this.missing=a}}class xA extends Mr{constructor(e){super(e,"FormatError")}}class sl extends Mr{constructor(e){super(e,"AbortException")}}function iz(e){if(typeof e!=="object"||e?.length===void 0)Rt("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),l=e.subarray(s,i);n.push(String.fromCharCode.apply(null,l))}return n.join("")}function j5(e){if(typeof e!=="string")Rt("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 Zt{static get isLittleEndian(){let e=new Uint8Array(4);e[0]=1;let t=new Uint32Array(e.buffer,0,1);return lt(this,"isLittleEndian",t[0]===1)}static get isOffscreenCanvasSupported(){return lt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return lt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return lt(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return lt(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:e,userAgent:t}=navigator;return lt(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 lt(this,"isCanvasFilterSupported",e?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return lt(this,"isAlphaColorInputSupported",!1);let e=document.createElement("input");return e.type="color",e.setAttribute("alpha",""),e.value="#ff000080",lt(this,"isAlphaColorInputSupported",e.value!=="#ff0000")}static get isBackdropFilterSupported(){return lt(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class Be{static get hexNums(){return lt(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],l=t[3],f=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+f,e[a+h+1]=u*s+g*l+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],l=t[3],f=t[4],c=t[5],h=e[0],u=e[1],g=e[2],b=e[3],d=n*h+f,j=d,A=n*g+f,S=A,C=l*u+c,O=C,T=l*b+c,M=T;if(s!==0||i!==0){let H=s*h,D=s*g,N=i*u,z=i*b;d+=N,S+=N,A+=z,j+=z,C+=H,M+=H,T+=D,O+=D}a[0]=Math.min(a[0],d,A,j,S),a[1]=Math.min(a[1],C,T,O,M),a[2]=Math.max(a[2],d,A,j,S),a[3]=Math.max(a[3],C,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],l=a**2+n**2,f=a*s+n*i,c=s**2+i**2,h=(l+c)/2,u=Math.sqrt(h**2-(l*c-f**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,l,f,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*l)+b*f;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,l,f,c,h,u,g){if(Math.abs(c)<0.000000000001){if(Math.abs(h)>=0.000000000001)this.#e(e,t,a,n,s,i,l,f,-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,l,f,(-h+d)/j,g),this.#e(e,t,a,n,s,i,l,f,(-h-d)/j,g)}static bezierBoundingBox(e,t,a,n,s,i,l,f,c){c[0]=Math.min(c[0],e,l),c[1]=Math.min(c[1],t,f),c[2]=Math.max(c[2],e,l),c[3]=Math.max(c[3],t,f),this.#t(e,a,s,l,t,n,i,f,3*(-e+3*(a-s)+l),6*(e-2*a+s),3*(a-e),c),this.#t(e,a,s,l,t,n,i,f,3*(-t+3*(n-i)+f),6*(t-2*n+i),3*(n-t),c)}}function lz(e){return decodeURIComponent(escape(e))}var Jg=null,rA=null;function fz(e){if(!Jg)Jg=/([\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,rA=new Map([["ſt","ſt"]]);return e.replaceAll(Jg,(t,a,n)=>a?a.normalize("NFKC"):rA.get(n))}function DA(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),iz(e)}function rz(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 l=i.length,f=!0;switch(s.name){case"XYZ":if(l<2||l>3)return!1;break;case"Fit":case"FitB":return l===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(l>1)return!1;break;case"FitR":if(l!==4)return!1;f=!1;break;default:return!1}for(let c of i){if(typeof c==="number"||f&&c===null)continue;return!1}return!0}var fu=()=>[],c8=()=>new Map,t8=()=>Object.create(null);function ha(e,t,a){return Math.min(Math.max(e,t),a)}class ru{constructor({viewBox:e,userUnit:t,scale:a,rotation:n,offsetX:s=0,offsetY:i=0,dontFlip:l=!1}){this.viewBox=e,this.userUnit=t,this.scale=a,this.rotation=n,this.offsetX=s,this.offsetY=i,a*=t;let f=(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(l)g=-g,b=-b;let d,j,A,S;if(h===0)d=Math.abs(c-e[1])*a+s,j=Math.abs(f-e[0])*a+i,A=(e[3]-e[1])*a,S=(e[2]-e[0])*a;else d=Math.abs(f-e[0])*a+s,j=Math.abs(c-e[1])*a+i,A=(e[2]-e[0])*a,S=(e[3]-e[1])*a;this.transform=[h*a,u*a,g*a,b*a,d-h*a*f-g*a*c,j-u*a*f-b*a*c],this.width=A,this.height=S}get rawDims(){let e=this.viewBox;return lt(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 ru({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 Be.applyTransform(a,this.transform),a}convertToPdfPoint(e,t){let a=[e,t];return Be.applyInverseTransform(a,this.transform),a}}class au{static textContent(e){let t=[],a={items:t,styles:Object.create(null)};function n(s){if(!s)return;let i=null,l=s.name;if(l==="#text")i=s.value;else if(!au.shouldBuildText(l))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 f of s.children)n(f)}return n(e),a}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class h8{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",(l)=>{n.setValue(t,{value:l.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",(l)=>{n.setValue(t,{value:l.target.checked?l.target.getAttribute("xfaOn"):l.target.getAttribute("xfaOff")})})}else{if(i.value!==null)e.setAttribute("value",i.value);if(s==="print")break;e.addEventListener("input",(l)=>{n.setValue(t,{value:l.target.value})})}break;case"select":if(i.value!==null){e.setAttribute("value",i.value);for(let l of a.children)if(l.attributes.value===i.value)l.attributes.selected=!0;else if(Object.hasOwn(l.attributes,"selected"))delete l.attributes.selected}e.addEventListener("input",(l)=>{let f=l.target.options,c=f.selectedIndex===-1?"":f[f.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,l=e instanceof HTMLAnchorElement;if(i.type==="radio")i.name=`${i.name}-${n}`;for(let[f,c]of Object.entries(i)){if(c===null||c===void 0)continue;switch(f){case"class":if(c.length)e.setAttribute(f,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(!l||f!=="href"&&f!=="newWindow")e.setAttribute(f,c)}}if(l)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 l=s!=="richText",f=e.div;if(f.append(i),e.viewport){let u=`matrix(${e.viewport.transform.join(",")})`;f.style.transform=u}if(l)f.setAttribute("class","xfaLayer xfaFont");let c=[];if(n.children.length===0){if(n.value){let u=document.createTextNode(n.value);if(i.append(u),l&&au.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 S=document.createTextNode(d.value);c.push(S),b.append(S);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 S=document.createTextNode(d.value);if(l&&au.shouldBuildText(j))c.push(S);A.append(S)}}for(let u of f.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 ru({viewBox:[0,0,parseInt(n,10),parseInt(s,10)],userUnit:1,scale:t,rotation:a})}}class Or{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function u8(e,t="text"){if(Wh(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 q5 extends Mr{constructor(e,t=0){super(e,"RenderingCancelledException");this.extraDelay=t}}function v5(e){let t=e.length,a=0;while(a<t&&e[a].trim()==="")a++;return e.substring(a,a+5).toLowerCase()==="data:"}function m8(e){return typeof e==="string"&&/\.pdf$/i.test(e)}function oz(e){return[e]=e.split(/[#?]/,1),e8(e)}function cz(e,t="document.pdf"){if(typeof e!=="string")return t;if(v5(e))return ct('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let n=((f)=>{try{return new URL(f)}catch{}try{return new URL(decodeURIComponent(f))}catch{}try{return new URL(f,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(f),"https://foo.bar")}catch{}return null})(e);if(!n)return t;let s=(f)=>{try{let c=decodeURIComponent(f);if(c.includes("/")){if(c=e8(c),c.length===4&&i.test(c))return f}return c}catch{return f}},i=/\.pdf$/i,l=e8(n.pathname);if(i.test(l))return s(l);if(n.searchParams.size>0){let f=(h)=>[...h].findLast((u)=>i.test(u)),c=f(n.searchParams.values())??f(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 a8{#e=new Map;times=[];time(e){if(this.#e.has(e))ct(`Timer is already running for ${e}`);this.#e.set(e,Date.now())}timeEnd(e){if(!this.#e.has(e))ct(`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 Wh(e,t){let a=t?URL.parse(e,t):URL.parse(e);return/https?:/.test(a?.protocol??"")}function wi(e){e.preventDefault()}function Sa(e){e.preventDefault(),e.stopPropagation()}class r5{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 l=parseInt(t[5],10);l=l>=0&&l<=59?l:0;let f=parseInt(t[6],10);f=f>=0&&f<=59?f: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,l+=u;else if(c==="+")i-=h,l-=u;return new Date(Date.UTC(a,n,s,i,l,f))}}function ou(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 cu(e){let t=ou(e);if(!t)return ct(`Not a valid color format: "${e}"`),[0,0,0];return t.slice(0,3)}function hz(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,cu(n))}t.remove()}function fa(e){let{a:t,b:a,c:n,d:s,e:i,f:l}=e.getTransform();return[t,a,n,s,i,l]}function h0(e){let{a:t,b:a,c:n,d:s,e:i,f:l}=e.getTransform().invertSelf();return[t,a,n,s,i,l]}function Br(e,t,a=!1,n=!0){if(t instanceof ru){let{pageWidth:s,pageHeight:i}=t.rawDims,{style:l}=e,f=`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)l.width=f,l.height=c;else l.width=c,l.height=f}if(n)e.setAttribute("data-main-rotation",t.rotation)}class b0{constructor(){let{pixelRatio:e}=b0;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,l=1/0,f=1/0;if(a=b0.capPixels(a,s),a>0)i=Math.sqrt(a/(e*t));if(n!==-1)l=n/e,f=n/t;let c=Math.min(i,l,f);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 n8=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class RA{static get isDarkMode(){return lt(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class NA{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(),lt(this,"commentForegroundColor",cu(a))}}function uz(e,t){t=ha(t??1,0,1);let a=255*(1-t);return e.map((n)=>Math.round(n*t+a))}function oA(e,t){let a=e[0]/255,n=e[1]/255,s=e[2]/255,i=Math.max(a,n,s),l=Math.min(a,n,s),f=(i+l)/2;if(i===l)t[0]=t[1]=0;else{let c=i-l;switch(t[1]=f<0.5?c/(i+l):c/(2-i-l),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]=f}function s8(e,t){let a=e[0],n=e[1],s=e[2],i=(1-Math.abs(2*s-1))*n,l=i*(1-Math.abs(a/60%2-1)),f=s-i/2;switch(Math.floor(a/60)){case 0:t[0]=i+f,t[1]=l+f,t[2]=f;break;case 1:t[0]=l+f,t[1]=i+f,t[2]=f;break;case 2:t[0]=f,t[1]=i+f,t[2]=l+f;break;case 3:t[0]=f,t[1]=l+f,t[2]=i+f;break;case 4:t[0]=l+f,t[1]=f,t[2]=i+f;break;case 5:case 6:t[0]=i+f,t[1]=f,t[2]=l+f;break}}function cA(e){return e<=0.03928?e/12.92:((e+0.055)/1.055)**2.4}function hA(e,t,a){s8(e,a),a.map(cA);let n=0.2126*a[0]+0.7152*a[1]+0.0722*a[2];s8(t,a),a.map(cA);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 uA=new Map;function mz(e,t){let a=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,n=uA.get(a);if(n)return n;let s=new Float32Array(9),i=s.subarray(0,3),l=s.subarray(3,6);oA(e,l);let f=s.subarray(6,9);oA(t,f);let c=f[2]<0.5,h=c?12:4.5;if(l[2]=c?Math.sqrt(l[2]):1-Math.sqrt(1-l[2]),hA(l,f,i)<h){let u,g;if(c)u=l[2],g=1;else u=0,g=l[2];let b=0.005;while(g-u>b){let d=l[2]=(u+g)/2;if(c===hA(l,f,i)<h)u=d;else g=d}l[2]=c?g:u}return s8(l,i),n=Be.makeHexColor(Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255)),uA.set(a,n),n}function zA({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 l=e.split(/\r\n?|\n/);for(let f=0,c=l.length;f<c;++f){let h=l[f];if(i.append(document.createTextNode(h)),f<c-1)i.append(document.createElement("br"))}s.append(i)}else h8.render({xfaHtml:e,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",a),n.append(s)}function EA(e){let t=new Path2D;if(!e)return t;for(let a=0,n=e.length;a<n;)switch(e[a++]){case Jh.moveTo:t.moveTo(e[a++],e[a++]);break;case Jh.lineTo:t.lineTo(e[a++],e[a++]);break;case Jh.curveTo:t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);break;case Jh.quadraticCurveTo:t.quadraticCurveTo(e[a++],e[a++],e[a++],e[a++]);break;case Jh.closePath:t.closePath();break;default:ct(`Unrecognized drawing path operator: ${e[a-1]}`);break}return t}class Ph{#e=null;#t=null;#a;#n=null;#s=null;#l=null;#i=null;#f=null;static#o=null;constructor(e){this.#a=e,Ph.#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",wi,{signal:t}),e.addEventListener("pointerdown",Ph.#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,Sa(e)}#h(e){this.#a._focusEventsAllowed=!0,Sa(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",wi,{signal:t}),!0}hide(){this.#e.classList.add("hidden"),this.#t?.hideDropdown()}show(){this.#e.classList.remove("hidden"),this.#s?.shown(),this.#l?.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",Ph.#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.#l)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.#l=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.#f=await e.renderEditButton(this.#a);this.#g(t),this.#n.append(t,this.#b)}removeButton(e){switch(e){case"comment":this.#l?.removeToolbarCommentButton(),this.#l=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.#f)this.#f.title=e}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}}class IA{#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",wi,{signal:t});let a=this.#e=document.createElement("div");if(a.className="buttons",e.append(a),this.#a.hasCommentManager())this.#l("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#a.commentSelection("floating_button")});return this.#l("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 l=s.x+(t?s.width:0);if(i>a){n=l,a=i;continue}if(t){if(l>n)n=l}else if(l<n)n=l}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()}#l(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 l=this.#a._signal;if(l instanceof AbortSignal&&!l.aborted)s.addEventListener("contextmenu",wi,{signal:l}),s.addEventListener("click",n,{signal:l});this.#e.append(s)}}var gz="068f09d6-5b37-4f77-a97a-f8ff4f253b68",Qg=Object.freeze({internal:gz});function UA(e,t,a){for(let n of a)t.addEventListener(n,e[n].bind(e))}class Et{static#e=NaN;static#t=null;static#a=NaN;static#n=null;static initializeAndAddPointerId(e){(Et.#t||=new Set).add(e)}static setPointer(e,t){Et.#e||=t,Et.#n??=e}static setTimeStamp(e){Et.#a=e}static isSamePointerId(e){return Et.#e===e}static isSamePointerIdOrRemove(e){if(Et.#e===e)return!0;return Et.#t?.delete(e),!1}static isSamePointerType(e){return Et.#n===e}static isInitializedAndDifferentPointerType(e){return Et.#n!==null&&!Et.isSamePointerType(e)}static isSameTimeStamp(e){return Et.#a===e}static isUsingMultiplePointers(){return Et.#t?.size>=1}static clearPointerType(){Et.#n=null}static clearPointerIds(){Et.#e=NaN,Et.#t=null}static clearTimeStamp(){Et.#a=NaN}}class GA{#e=0;get id(){return`pdfjs_internal_editor_${this.#e++}`}}class g8{#e=DA();#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 lt(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 u8(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=g8._isSVGFittingCanvas,i=new FileReader,l=new Image,f=new Promise((c,h)=>{l.onload=()=>{a.bitmap=l,a.isSvg=!0,c()},i.onload=async()=>{let u=a.svgUrl=i.result;l.src=await s?`${u}#svgView(preserveAspectRatio(none))`:u},l.onerror=i.onerror=h});i.readAsDataURL(n),await f}else a.bitmap=await createImageBitmap(n);a.refCounter=1}catch(n){ct(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 XA{#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:l=!1}){if(n)e();if(this.#t)return;let f={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(f);return}if(i&&this.#e[this.#n].type===s){if(l)f.undo=this.#e[this.#n].undo;this.#e[this.#n]=f;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(f)}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 Ks{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(e){this.callbacks=new Map;let{isMac:t}=Zt.platform;for(let[a,n,s={}]of e){let i=a.some((l)=>l.startsWith("mac+"));for(let l of a){let f=l;if(i){let u=l.startsWith("mac+");if(t!==u)continue;if(u)f=l.slice(4)}let[c,h]=Ks.#e(f);if(c===null)continue;this.callbacks.getOrInsertComputed(c,fu).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=Ks[s];if(i){a|=i;continue}if(t!==null){ct(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t=s==="SPACE"?" ":n}if(t===null)ct(`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=Ks.#t(t.code);if(h===null||h===t.key)return;if(a=this.callbacks.get(h),!a)return}let n=(t.altKey?Ks.ALT:0)|(t.ctrlKey?Ks.CTRL:0)|(t.metaKey?Ks.META:0)|(t.shiftKey?Ks.SHIFT:0),s=a.find((h)=>h.modifiers===n);if(!s)return;let{callback:i,options:{bubbles:l=!1,args:f=[],checker:c=null}}=s;if(c&&!c(e,t))return;if(i.bind(e,...f,t)(),!l)Sa(t)}}class p8{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let e=new Map([["CanvasText",null],["Canvas",null]]);return hz(e),lt(this,"_colors",e)}convert(e){let t=cu(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 p8._colorsMapping.get(a);return t}getHexCode(e){let t=this._colors.get(e);if(!t)return e;return Be.makeHexColor(...t)}}class rf{#e=new AbortController;#t=null;#a=null;#n=new Map;#s=new Map;#l=null;#i=null;#f=null;#o=null;#r=new XA;#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 GA;#F=!1;#H=!1;#x=!1;#M=null;#D=null;#N=null;#E=null;#L=null;#C=ot.NONE;#v=new Set;#R=null;#U=null;#X=null;#Q=null;#Y=null;#J={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#z=[0,0];#K=null;#V=null;#P=null;#ee=null;#I=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let e=rf.prototype,t=(i)=>i.#V.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&i.hasSomethingToControl(),a=(i,{target:l})=>{if(l instanceof HTMLInputElement){let{type:f}=l;return f!=="text"&&f!=="number"}return!0},n=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return lt(this,"_keyboardManager",new Ks([[["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:l})=>!(l instanceof HTMLButtonElement)&&i.#V.contains(l)&&!i.isEnterHandled}],[["Space"],e.addNewEditorFromKeyboard,{checker:(i,{target:l})=>!(l 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,l,f,c,h,u,g,b,d,j,A){let S=this._signal=this.#e.signal;this.#V=e,this.#P=t,this.#ee=a,this.#i=n,this.#u=s,this.#U=i,this.#Y=f,this._eventBus=l;let C={signal:S,...Qg};l.on("editingaction",this.onEditingAction.bind(this),C),l.on("pagechanging",this.onPageChanging.bind(this),C),l.on("scalechanging",this.onScaleChanging.bind(this),C),l.on("rotationchanging",this.onRotationChanging.bind(this),C),l.on("setpreference",this.onSetPreference.bind(this),C),l.on("switchannotationeditorparams",(O)=>this.updateParams(O.type,O.value),C),window.addEventListener("pointerdown",()=>{this.#H=!0},{capture:!0,signal:S}),window.addEventListener("pointerup",()=>{this.#H=!1},{capture:!0,signal:S}),window.addEventListener("beforeunload",this.#ie.bind(this),{capture:!0,signal:S}),this.#re(),this.#ge(),this.#ae(),this.#f=f.annotationStorage,this.#y=f.filterFactory,this.#X=c,this.#k=h||null,this.#j=u,this.#w=g,this.#A=b,this.#L=d||null,this.viewParameters={realScale:Or.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=j||null,this._supportsPinchToZoom=A!==!1,s?.setSidebarUiManager(this)}destroy(){this.#I?.resolve(),this.#I=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.#E?.clear(),this.#t=null,this.#v.clear(),this.#r.destroy(),this.#i?.destroy(),this.#u?.destroy(),this.#U?.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 lt(this,"hcmFilter",this.#X?this.#y.addHCMFilter(this.#X.foreground,this.#X.background):"none")}get direction(){return lt(this,"direction",getComputedStyle(this.#V).direction)}get _highlightColors(){return lt(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 lt(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 lt(this,"highlightColors",t)}get highlightColorNames(){return lt(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,Qg),await a}getSignature(e){this.#U?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#U}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal,...Qg}),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:l}=a.div.getBoundingClientRect();if(e>=n&&e<=n+i&&t>=s&&t<=s+l)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*Or.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:l}=a,f=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===ot.NONE,d=()=>{let j=g?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:u,anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:l,text:f});if(b)this.showAllEditors("highlight",!0,!0);if(t)j?.editComment()};if(b){this.switchToMode(ot.HIGHLIGHT,d);return}d()}commentSelection(e=""){this.highlightSelection(e,!0)}#ie(e){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#le(){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 IA(this),this.#O.show(a,n,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage(e){if(!this.#f)return null;let t=`pdfjs_internal_editor_${e}`,a=this.#f.getRawValue(t);if(a)this.#f.remove(t);return a}addToAnnotationStorage(e){if(!e.isEmpty()&&this.#f&&!this.#f.has(e.id))this.#f.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")}#fe(){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!==ot.HIGHLIGHT&&this.#C!==ot.NONE)return;if(this.#C===ot.HIGHLIGHT)this.showAllEditors("highlight",!0,!0);if(this.#_=this.isShiftKeyDown,!this.isShiftKeyDown){let s=this.#C===ot.HIGHLIGHT?this.#te(n):null;if(s?.toggleDrawing(),this.#H){let i=new AbortController,l=this.combinedSignal(i),f=(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",f,{signal:l}),window.addEventListener("blur",f,{signal:l})}else s?.toggleDrawing(!0),this.#Z("main_toolbar")}}#Z(e=""){if(this.#C===ot.HIGHLIGHT)this.highlightSelection(e);else if(this.#j)this.#le()}#re(){document.addEventListener("selectionchange",this.#fe.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.#D=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#D)return;let[e,t]=this.#D;this.#D=null,t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ae(){if(this.#M)return;this.#M=new AbortController;let e=this.combinedSignal(this.#M);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#he(){this.#M?.abort(),this.#M=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){ct(`paste: "${s.message}".`);return}if(!Array.isArray(a))return;this.unselectAll();let n=this.currentLayer;try{let s=[];for(let f of a){let c=await n.deserialize(f);if(!c)return;s.push(c)}let i=()=>{for(let f of s)this.#ne(f);this.#se(s)},l=()=>{for(let f of s)f.remove()};this.addCommands({cmd:i,undo:l,mustExec:!0})}catch(s){ct(`paste: "${s.message}".`)}}keydown(e){if(!this.isShiftKeyDown&&e.key==="Shift")this.isShiftKeyDown=!0;if(this.#C!==ot.NONE&&!this.isEditorHandlingKeyboard)rf._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.#l.get(e);if(a)if(a.pageIndex=t,this.#s.set(t,a),this.#F)a.enable();else a.disable()}startUpdatePages(){this.#l=new Map(this.#s),this.#s.clear()}endUpdatePages(){this.#l=null}clonePage(e,t){for(let a of this.getEditors(e)){let n=a.serialize(a.mode!==ot.HIGHLIGHT);if(!n)continue;n.pageIndex=t,n.id=this.getId(),n.isClone=!0,delete n.popupRef,this.#f.setValue(n.id,n)}}findClonesForPage(e){let t=[],{pageIndex:a}=e;for(let[n,s]of this.#f)if(s.pageIndex===a&&s.isClone)this.#f.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===ot.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!==ot.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.#I){if(await this.#I.promise,!this.#I)return}if(this.#I=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===ot.POPUP)this.#u?.hideSidebar();if(this.#u?.destroyPopup(),this.#C=e,e===ot.NONE){this.setEditingState(!1),this.#be();for(let l of this.#n.values())l.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#I.resolve();return}for(let l of this.#n.values())l.addStandaloneCommentButton();if(e===ot.SIGNATURE)await this.#U?.loadSignatures();if(a)Et.clearPointerType();this.setEditingState(!0),await this.#pe(),this.unselectAll();for(let l of this.#s.values())l.updateMode(e);if(e===ot.POPUP){this.#a||=await this.#Y.getAnnotationsByType(new Set(this.#m.map((c)=>c._editorType)));let l=new Set,f=[];for(let c of this.#n.values()){let{annotationElementId:h,hasComment:u,deleted:g}=c;if(h)l.add(h);if(u&&!g)f.push(c.getData())}for(let c of this.#a){let{id:h,popupRef:u,contentsObj:g}=c;if(u&&g?.str&&!l.has(h)&&!this.#p.has(h))f.push(c)}this.#u?.showSidebar(f)}if(!t){if(n)this.addNewEditorFromKeyboard();this.#I.resolve();return}for(let l of this.#n.values())if(l.uid===t)if(this.setSelected(l),i)l.editComment();else if(s)l.enterInEditMode();else l.focus();else l.unselect();this.#I.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.#x===e)return;this.#x=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.#E?.delete(e.annotationElementId);if(this.unselect(e),!e.annotationElementId||!this.#p.has(e.annotationElementId))this.#f?.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!==ot.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.#z[0]+=e,this.#z[1]+=t;let[n,s]=this.#z,i=[...this.#v],l=1000;if(this.#K)clearTimeout(this.#K);this.#K=setTimeout(()=>{this.#K=null,this.#z[0]=this.#z[1]=0,this.addCommands({cmd:()=>{for(let f of i)if(this.#n.has(f.id))f.translateInPage(n,s),f.translationDone()},undo:()=>{for(let f of i)if(this.#n.has(f.id))f.translateInPage(-n,-s),f.translationDone()},mustExec:!1})},l);for(let f of i)f.translateInPage(e,t),f.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},l]of e)l.newX=n,l.newY=s,l.newPageIndex=i,t||=n!==l.savedX||s!==l.savedY||i!==l.savedPageIndex;if(!t)return!1;let a=(n,s,i,l)=>{if(this.#n.has(n.id)){let f=this.#s.get(l);if(f)n._setParentAndPosition(f,s,i);else n.pageIndex=l,n.x=s,n.y=i}};return this.addCommands({cmd:()=>{for(let[n,{newX:s,newY:i,newPageIndex:l}]of e)a(n,s,i,l)},undo:()=>{for(let[n,{savedX:s,savedY:i,savedPageIndex:l}]of e)a(n,s,i,l)},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!==ot.NONE}get imageManager(){return lt(this,"imageManager",new g8)}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(),l;switch(e.getAttribute("data-main-rotation")){case"90":l=(c,h,u,g)=>({x:(h-n)/i,y:1-(c+u-a)/s,width:g/i,height:u/s});break;case"180":l=(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":l=(c,h,u,g)=>({x:1-(h+g-n)/i,y:(c-a)/s,width:g/i,height:u/s});break;default:l=(c,h,u,g)=>({x:(c-a)/s,y:(h-n)/i,width:u/s,height:g/i});break}let f=[];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;f.push(l(g,b,d,j))}}return f.length===0?null:f}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.#f.getRawValue(t);if(!a)return;if(this.#C===ot.NONE&&!a.hasBeenModified)return;a.renderAnnotationElement(e)}setMissingCanvas(e,t,a){let n=this.#E?.get(e);if(!n)return;n.setCanvas(t,a),this.#E.delete(e)}addMissingCanvas(e,t){(this.#E||=new Map).set(e,t)}}class p0{#e=null;#t=!1;#a=null;#n=null;#s=null;#l=null;#i=!1;#f=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,p0.#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){p0._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",p0.#g.missing),t.setAttribute("data-l10n-id",p0.#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",wi,{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 p0._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.#f?.remove(),this.#f=null;return}if(!this.#f){let t=this.#f=document.createElement("div");t.className="noAltTextBadge",this.#o.div.append(t)}this.#f.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.#l)clearTimeout(this.#l),this.#l=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.#f?.remove(),this.#f=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",p0.#g[this.#b]),this.#n?.setAttribute("data-l10n-id",p0.#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.#l),this.#l=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#l=setTimeout(()=>{this.#l=null,this.#s.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:s}),e.addEventListener("mouseleave",()=>{if(this.#l)clearTimeout(this.#l),this.#l=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 $h{#e=null;#t=null;#a=!1;#n=null;#s=null;#l=null;#i=null;#f=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:l}=this.#n.parent.boundingClientRect;return[(e-n)/i,(t+a-s)/l]}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",wi,{signal:a}),t)e.addEventListener("focusin",(s)=>{this.#n._focusEventsAllowed=!1,Sa(s)},{capture:!0,signal:a}),e.addEventListener("focusout",(s)=>{this.#n._focusEventsAllowed=!0,Sa(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:l,width:f,height:c}=s;this.#n._uiManager.editComment(this.#n,i+a*f,l+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.#l,date:this.#f,deleted:this.isDeleted()}}set data(e){if(e!==this.#i)this.#l=null;if(e===null){this.#i="",this.#o=!0;return}this.#i=e,this.#f=new Date,this.#o=!1}restoreData({text:e,richText:t,date:a}){this.#i=e,this.#l=t,this.#f=a,this.#o=!1}setInitialText(e,t=null){this.#s=e,this.data=e,this.#f=null,this.#l=t}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#i="",this.#l=null,this.#f=null,this.#n=null,this.#a=!1,this.#o=!1}}class k5{#e;#t=!1;#a=null;#n;#s;#l;#i;#f=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:l}){this.#e=e,this.#a=a,this.#n=t,this.#s=n,this.#l=s,this.#i=i,this.#u=new AbortController,this.#o=AbortSignal.any([l,this.#u.signal]),e.addEventListener("touchstart",this.#g.bind(this),{passive:!1,signal:this.#o})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/b0.pixelRatio}#g(e){if(this.#n?.())return;if(e.touches.length===1){if(this.#f)return;let n=this.#f=new AbortController,s=AbortSignal.any([this.#o,n.signal]),i=this.#e,l={capture:!0,signal:s,passive:!1},f=(c)=>{if(c.pointerType==="touch")this.#f?.abort(),this.#f=null};i.addEventListener("pointerdown",(c)=>{if(c.pointerType==="touch")Sa(c),f(c)},l),i.addEventListener("pointerup",f,l),i.addEventListener("pointercancel",f,l);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 l=this.#p.bind(this);s.addEventListener("touchend",l,i),s.addEventListener("touchcancel",l,i),i.capture=!0,s.addEventListener("pointerdown",Sa,i),s.addEventListener("pointermove",Sa,i),s.addEventListener("pointercancel",Sa,i),s.addEventListener("pointerup",Sa,i),this.#s?.()}if(Sa(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;Sa(e);let[t,a]=e.touches;if(t.identifier>a.identifier)[t,a]=[a,t];let{screenX:n,screenY:s}=t,{screenX:i,screenY:l}=a,f=this.#r,{touch0X:c,touch0Y:h,touch1X:u,touch1Y:g}=f,b=u-c,d=g-h,j=i-n,A=l-s,S=Math.hypot(j,A)||1,C=Math.hypot(b,d)||1;if(!this.#t&&Math.abs(C-S)<=k5.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(f.touch0X=n,f.touch0Y=s,f.touch1X=i,f.touch1Y=l,!this.#t){this.#t=!0;return}let O=[(n+i)/2,(s+l)/2];this.#l?.(O,C,S)}#p(e){if(e.touches.length>=2)return;if(this.#h)this.#h.abort(),this.#h=null,this.#i?.();if(!this.#r)return;Sa(e),this.#r=null,this.#t=!1}destroy(){this.#u?.abort(),this.#u=null,this.#f?.abort(),this.#f=null}}class Ye{#e=null;#t=null;#a=null;#n=null;#s=null;#l=!1;#i=null;#f="";#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;#_=Ye._zIndex++;static _borderLineWidth=-1;static _colorManager=new p8;static _zIndex=1;static _telemetryTimeout=1000;static get _resizerKeyboardManager(){let e=Ye.prototype._resizeWithKeyboard,t=rf.TRANSLATE_SMALL,a=rf.TRANSLATE_BIG;return lt(this,"_resizerKeyboardManager",new Ks([[["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"],Ye.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[l,f]=this.parentDimensions;this.x=e.x/l,this.y=e.y/f,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 lt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new KA({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(Ye._l10n??=e,Ye._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"}),Ye._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"}),Ye._borderLineWidth!==-1)return;let a=getComputedStyle(document.documentElement);Ye._borderLineWidth=parseFloat(a.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Rt("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.#z(),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:l}=this,[f,c]=this.getBaseTranslation();i+=f,l+=c;let{style:h}=a;h.left=`${(100*i).toFixed(2)}%`,h.top=`${(100*l).toFixed(2)}%`,this._onTranslating(i,l),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}=Ye,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:l,height:f}=this;if(l*=a,f*=n,s*=a,i*=n,this._mustFixPosition)switch(e){case 0:s=ha(s,0,a-l),i=ha(i,0,n-f);break;case 90:s=ha(s,0,a-f),i=ha(i,l,n);break;case 180:s=ha(s,l,a),i=ha(i,f,n);break;case 270:s=ha(s,f,a),i=ha(i,0,n-l);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 Ye.#B(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return Ye.#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]}#H(){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.#x.bind(this,a),{signal:t}),n.addEventListener("contextmenu",wi,{signal:t}),n.tabIndex=-1}this.div.prepend(this.#o)}#x(e,t){t.preventDefault();let{isMac:a}=Zt.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",Sa,{passive:!1,signal:i}),window.addEventListener("contextmenu",wi,{signal:i}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let l=this.parent.div.style.cursor,f=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=l,this.div.style.cursor=f,this.#D()};window.addEventListener("pointerup",c,{signal:i}),window.addEventListener("blur",c,{signal:i})}#M(e,t,a,n){this.width=a,this.height=n,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#D(){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,l=this.width,f=this.height;if(s===e&&i===t&&l===a&&f===n)return;this.addCommands({cmd:this.#M.bind(this,s,i,l,f),undo:this.#M.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,l=this.width,f=this.height,c=Ye.MIN_SIZE/a,h=Ye.MIN_SIZE/n,u=this.#F(this.rotation),g=(Y,$)=>[u[0]*Y+u[2]*$,u[1]*Y+u[3]*$],b=this.#F(360-this.rotation),d=(Y,$)=>[b[0]*Y+b[2]*$,b[1]*Y+b[3]*$],j,A,S=!1,C=!1;switch(e){case"topLeft":S=!0,j=(Y,$)=>[0,0],A=(Y,$)=>[Y,$];break;case"topMiddle":j=(Y,$)=>[Y/2,0],A=(Y,$)=>[Y/2,$];break;case"topRight":S=!0,j=(Y,$)=>[Y,0],A=(Y,$)=>[0,$];break;case"middleRight":C=!0,j=(Y,$)=>[Y,$/2],A=(Y,$)=>[0,$/2];break;case"bottomRight":S=!0,j=(Y,$)=>[Y,$],A=(Y,$)=>[0,0];break;case"bottomMiddle":j=(Y,$)=>[Y/2,$],A=(Y,$)=>[Y/2,0];break;case"bottomLeft":S=!0,j=(Y,$)=>[0,$],A=(Y,$)=>[Y,0];break;case"middleLeft":C=!0,j=(Y,$)=>[0,$/2],A=(Y,$)=>[Y,$/2];break}let O=j(l,f),T=A(l,f),M=g(...T),H=Ye._round(s+M[0]),D=Ye._round(i+M[1]),N=1,z=1,L,ee;if(!t.fromKeyboard){let{screenX:Y,screenY:$}=t,[fe,P]=this.#r;[L,ee]=this.screenToPageTranslation(Y-fe,$-P),this.#r[0]=Y,this.#r[1]=$}else({deltaX:L,deltaY:ee}=t);if([L,ee]=d(L/a,ee/n),S){let Y=Math.hypot(l,f);N=z=Math.max(Math.min(Math.hypot(T[0]-O[0]-L,T[1]-O[1]-ee)/Y,1/l,1/f),c/l,h/f)}else if(C)N=ha(Math.abs(T[0]-O[0]-L),c,1)/l;else z=ha(Math.abs(T[1]-O[1]-ee),h,1)/f;let te=Ye._round(l*N),J=Ye._round(f*z);M=g(...A(te,J));let ae=H-M[0],Q=D-M[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=te,this.height=J,this.x=ae,this.y=Q,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 Ph(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(p0.initialize(Ye._l10n),this.#a=new p0(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 $h(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 $h(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 $h(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 $h(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,l=i+s+1,f=n-100,c=l+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[l,f,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.#l?-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.#U();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),UA(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom)this.#S||=new k5({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#E.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#C.bind(this),signal:this._uiManager._signal});return this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#E(){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),l=(H,D)=>[i[0]*H+i[2]*D,i[1]*H+i[3]*D],[f,c]=this.parentDimensions,h=this.x,u=this.y,g=this.width,b=this.height,d=Ye.MIN_SIZE/f,j=Ye.MIN_SIZE/c;s=Math.max(Math.min(s,1/g,1/b),d/g,j/b);let A=Ye._round(g*s),S=Ye._round(b*s);if(A===g&&S===b)return;this.#c||=[h,u,g,b];let C=l(g/2,b/2),O=Ye._round(h+C[0]),T=Ye._round(u+C[1]),M=l(A/2,S/2);this.x=O-M[0],this.y=T-M[1],this.width=A,this.height=S,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#C(){this.#a?.toggle(!0),this.parent.togglePointerEvents(!0),this.#D()}pointerdown(e){let{isMac:t}=Zt.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}=Zt.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},l=(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.#f=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){Sa(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",Sa,i),window.addEventListener("pointerdown",(c)=>{if(c.pointerType===this.#f){if(this.#S||c.isPrimary)l(c)}Sa(c)},i);let f=(c)=>{if(!this.#i||this.#i===c.pointerId){l(c);return}Sa(c)};window.addEventListener("pointerup",f,{signal:s}),window.addEventListener("blur",f,{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,[l,f]=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+l,i-g-h-d+f,u+c+b+l,i-g-h+f];case 90:return[u+h+l,i-g+c+f,u+h+d+l,i-g+c+b+f];case 180:return[u-c-b+l,i-g+h+f,u-c+l,i-g+h+d+f];case 270:return[u-h-d+l,i-g-c-b+f,u-h+l,i-g-c+f];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[a,n,s,i]=e,l=s-a,f=i-n;switch(this.rotation){case 0:return[a,t-i,l,f];case 90:return[a,t-n,f,l];case 180:return[s,t-n,l,f];case 270:return[s,t-i,f,l];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Ye._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:l,pageIndex:f,creationDate:c,modificationDate:h}=this;return{id:l,pageIndex:f,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}#U(){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.#U()}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,[l,f,c,h]=n.getRectInCurrentCoords(e.rect,i);return n.x=l/s,n.y=f/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.#z(),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.#H(),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[Ye._round(a+(s-a)*e),Ye._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),l=this.#Q.bind(this),f=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:f}),c.addEventListener("blur",l,{signal:f}),c.addEventListener("focus",this.#Y.bind(this,h),{signal:f}),c.setAttribute("data-l10n-id",Ye._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 l=0;l<n-s;l++)this.#o.append(this.#o.firstElementChild);else if(s>n)for(let l=0;l<s-n;l++)this.#o.firstElementChild.before(this.#o.lastElementChild);let i=0;for(let l of t){let c=this.#t[i++].getAttribute("data-resizer-name");l.setAttribute("data-l10n-id",Ye._l10nResizer[c])}}this.#J(0),this.#j=!0,this.#o.firstElementChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#X(e){Ye._resizerKeyboardManager.exec(this,e)}#Q(e){if(this.#j&&e.relatedTarget?.parentNode!==this.#o)this.#z()}#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})}#z(){this.#j=!1,this.#J(-1),this.#D()}_stopResizingWithKeyboard(){this.#z(),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},Ye._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.#l=!1}disable(){if(this.div)this.div.tabIndex=-1;this.#l=!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 KA extends Ye{constructor(e){super(e);this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var mA=3285377520,mi=4294901760,u0=65535;class o5{constructor(e){this.h1=e?e&4294967295:mA,this.h2=e?e&4294967295:mA}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 S=e.charCodeAt(j);if(S<=255)t[a++]=S;else t[a++]=S>>>8,t[a++]=S&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),l=0,f=0,c=this.h1,h=this.h2,u=3432918353,g=461845907,b=u&u0,d=g&u0;for(let j=0;j<n;j++)if(j&1)l=i[j],l=l*u&mi|l*b&u0,l=l<<15|l>>>17,l=l*g&mi|l*d&u0,c^=l,c=c<<13|c>>>19,c=c*5+3864292196;else f=i[j],f=f*u&mi|f*b&u0,f=f<<15|f>>>17,f=f*g&mi|f*d&u0,h^=f,h=h<<13|h>>>19,h=h*5+3864292196;switch(l=0,s){case 3:l^=t[n*4+2]<<16;case 2:l^=t[n*4+1]<<8;case 1:if(l^=t[n*4],l=l*u&mi|l*b&u0,l=l<<15|l>>>17,l=l*g&mi|l*d&u0,n&1)c^=l;else h^=l}this.h1=c,this.h2=h}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&mi|e*36045&u0,t=t*4283543511&mi|((t<<16|e>>>16)*2950163797&mi)>>>16,e^=t>>>1,e=e*444984403&mi|e*60499&u0,t=t*3301882366&mi|((t<<16|e>>>16)*3120437893&mi)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}var nu=Object.freeze({map:null,hash:"",transfer:void 0});class A5{#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 Ye)this.#a.delete(t.annotationElementId);if(this.#n.delete(e),this.#n.size===0)this.resetModified();if(this.#n.values().some((a)=>a instanceof Ye))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 Ye)(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 b8(this)}get serializable(){if(this.#n.size===0)return nu;let e=new Map,t=new o5,a=[],n=Object.create(null),s=!1;for(let[i,l]of this.#n){let f=l instanceof Ye?l.serialize(!1,n):l;if(l.page)l.pageIndex=l.page._pageIndex,delete l.page;if(f)e.set(i,f),t.update(`${i}:${JSON.stringify(f)}`),s||=!!f.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}:nu}get editorStats(){let e=null,t=new Map,a=0,n=0;for(let s of this.#n.values()){if(!(s instanceof Ye)){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:l}=i;t.getOrInsertComputed(l,()=>Object.getPrototypeOf(s).constructor),e||=Object.create(null);let f=e[l]||=new Map;for(let[c,h]of Object.entries(i)){if(c==="type")continue;let u=f.getOrInsertComputed(c,c8);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 o5;a.update(e.join(",")),t=a.hexdigest()}return this.#t={ids:new Set(e),hash:t}}[Symbol.iterator](){return this.#n.entries()}}class b8 extends A5{#e=nu;constructor(e){super();let{serializable:t}=e;if(t===nu)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(){Rt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#e}get modifiedIds(){return lt(this,"modifiedIds",{ids:new Set,hash:""})}}var B1="__forcedDependency",{floor:gA,ceil:pA}=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 pz(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 i8=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class LA{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===i8}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 wA=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class VA{#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#a=new Float64Array(al);_pendingBBoxIdx=-1;#n;#s;#l;#i;_savesStack=[];_markedContentStack=[];constructor(e,t){this.#n=e.width,this.#s=e.height,this.#f(t)}growOperationsCount(e){if(e>=this.#i.length)this.#f(e,this.#i)}#f(e,t){let a=new ArrayBuffer(e*4);if(this.#l=new Uint8ClampedArray(a),this.#i=new Uint32Array(a),t&&t.length>0)this.#i.set(t),this.#i.fill(i8,t.length);else this.#i.fill(i8)}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(Be.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(al,0);return this}recordClipBox(e,t,a,n,s,i){let l=Be.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform()),f=al.slice();Be.axialAlignedBoundingBox([a,s,n,i],l,f);let c=Be.intersect(this.#t,f);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 l=this.#t;if(l[0]===1/0)return this;let f=Be.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform());if(l[0]===-1/0)return Be.axialAlignedBoundingBox([a,s,n,i],f,this.#a),this;let c=al.slice();return Be.axialAlignedBoundingBox([a,s,n,i],f,c),this.#a[0]=ha(c[0],l[0],this.#a[0]),this.#a[1]=ha(c[1],l[1],this.#a[1]),this.#a[2]=ha(c[2],this.#a[2],l[2]),this.#a[3]=ha(c[3],this.#a[3],l[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=gA(this.#a[0]*256/this.#n),s=gA(this.#a[1]*256/this.#s),i=pA(this.#a[2]*256/this.#n),l=pA(this.#a[3]*256/this.#s);if(bA(this.#l,e,n,s,i,l),a){for(let f of a)for(let c of f)if(c!==e)bA(this.#l,c,n,s,i,l)}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 LA(this.#i,this.#l)}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,l){return this}getSimpleIndex(e){return}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}}class YA{#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[B1]:[]};#a=new Map;#n=new Set;#s=new Map;#l;#i;#f;constructor(e,t=!1){if(this.#f=e,t)this.#l=new Map,this.#i=(a,n)=>{wA(this.#l,n).dependencies.add(a)}}get clipBox(){return this.#f.clipBox}growOperationsCount(e){this.#f.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},[B1]:{__proto__:this.#t[B1]}},this.#f.save(e),this}restore(e){this.#f.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.#f.recordOpenMarker(e,this.#i),this}getOpenMarker(){return this.#f.getOpenMarker()}recordCloseMarker(e){return this.#f.recordCloseMarker(e,this.#i),this}beginMarkedContent(e){return this.#f.beginMarkedContent(e),this}endMarkedContent(e){return this.#f.endMarkedContent(e,this.#i),this}pushBaseTransform(e){return this.#f.pushBaseTransform(e),this}popBaseTransform(){return this.#f.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(B1,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(B1,e);return this}resetBBox(e){return this.#f.resetBBox(e),this}recordClipBox(e,t,a,n,s,i){return this.#f.recordClipBox(e,t,a,n,s,i),this}recordBBox(e,t,a,n,s,i){return this.#f.recordBBox(e,t,a,n,s,i),this}recordCharacterBBox(e,t,a,n=1,s=0,i=0,l){let f=a.bbox,c,h;if(f){if(c=f[2]!==f[0]&&f[3]!==f[1]&&this.#s.get(a),c!==!1){if(h=[0,0,0,0],Be.axialAlignedBoundingBox(f,a.fontMatrix,h),n!==1||s!==0||i!==0)pz(n,-n,s,i,h);if(c)return this.recordBBox(e,t,h[0],h[2],h[1],h[3])}}if(!l)return this.recordFullPageBBox(e);let u=l();if(f&&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.#f.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,[B1]),this.#l){let n=wA(this.#l,e),{dependencies:s}=n;this.#n.forEach(s.add,s),this.#f._savesStack.forEach(s.add,s),this.#f._markedContentStack.forEach(s.add,s),s.delete(e),n.isRenderingOperation=!0}let a=!t&&e===this.#f._pendingBBoxIdx;if(this.#f.recordOperation(e,t,[this.#n,this.#f._savesStack,this.#f._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.#f._pendingBBoxIdx;if(this.#f.bboxToClipBoxDropOperation(e),a)this.#n.clear();return this}take(){return this.#s.clear(),this.#f.take()}takeDebugMetadata(){return this.#l}}class su{#e;#t;#a;#n=0;#s=0;constructor(e,t,a){if(e instanceof su&&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,l){if(!this.#a)this.#e.recordCharacterBBox(this.#t,t,a,n,s,i,l);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 gi={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 c5{#e;#t;#a=4;#n=0;#s=new c5.#l(this.#a*6);static#l=Zt.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 l=new c5.#l(this.#a*6);l.set(this.#s),this.#s=l}let s=fa(e),i;if(n[0]!==1/0){let l=al.slice();Be.axialAlignedBoundingBox([0,-a,t,0],s,l);let f=Be.intersect(n,l);if(!f)return;let[c,h,u,g]=f;if(c!==l[0]||h!==l[1]||u!==l[2]||g!==l[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,S=g-h,C=d*d,O=j*j,T=j*d,M=O-C,H=(S*O-A*T)/M,D=(S*T-A*C)/M;i=[c+D,h,c,h+H,u,g-H]}}}if(!i)i=[0,-a,0,0,t,-a],Be.applyTransform(i,s,0),Be.applyTransform(i,s,2),Be.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 JA{#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(Ca(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:s,style:i}=e,l=new FontFace(n,s,i);this.addNativeFontFace(l);try{await l.load(),this.#e.add(n),a?.(e)}catch{ct(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}Rt("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 ct(`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 lt(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return lt(this,"isSyncFontLoadingSupported",Xs||Zt.platform.isFirefox)}_queueLoadingCallback(e){function t(){Ca(!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 lt(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,D,N){let z=M.substring(0,H),L=M.substring(H+D);return z+N+L}let i,l,f=this._document.createElement("canvas");f.width=1,f.height=1;let c=f.getContext("2d"),h=0;function u(M,H){if(++h>30){ct("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,S=a(b,j);for(i=0,l=g.length-3;i<l;i+=4)S=S-A+a(g,i)|0;if(i<g.length)S=S-A+a(g+"XXX",i)|0;b=s(b,j,4,n(S));let C=`url(data:font/opentype;base64,${btoa(b)});`,O=`@font-face {font-family:"${g}";src:${C}}`;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 QA{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){ct(`getPathGenerator - ignoring character: "${i}".`)}let s=EA(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){lt(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 ZA{static strings=["fontFamily","fontWeight","italicAngle"]}class $A{static strings=["css","loadedName","baseFontName","src"]}class pi{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 lf{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 WA{#e;#t=new TextDecoder;#a;constructor(e){this.#e=e,this.#a=new DataView(e)}#n(e){Ca(e<ZA.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 PA{#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){Ca(e<$A.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 ey{#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){Ca(e<pi.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 Ca(e<pi.numbers.length,"Invalid number index"),this.#a.getFloat64(pi.OFFSET_NUMBERS+e*8)}get ascent(){return this.#s(0)}get defaultWidth(){return this.#s(1)}get descent(){return this.#s(2)}#l(e,t,a,n){let s=this.#a.getUint8(e);if(s===0)return;Ca(s===t,"Invalid array length."),e+=1;let i=Array(s);for(let l=0;l<s;l++)i[l]=this.#a[a](e,!0),e+=n;return i}get bbox(){return this.#l(pi.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#l(pi.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#l(pi.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#i(e){Ca(e<pi.strings.length,"Invalid string index");let t=pi.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)}#f(){let e=pi.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.#f();return t===0?void 0:new Uint8Array(this.#e,e+4,t)}clearData(){let{offset:e,length:t}=this.#f();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=pi.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 WA(s.buffer)}get systemFontInfo(){let e=pi.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 PA(n.buffer)}}class ty{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){let e=this.view,t=this.data[lf.KIND],a=!!this.data[lf.HAS_BBOX],n=!!this.data[lf.HAS_BACKGROUND],s=e.getUint32(lf.N_COORD,!0),i=e.getUint32(lf.N_COLOR,!0),l=e.getUint32(lf.N_STOP,!0),f=20,c=new Float32Array(this.buffer,f,s*2);f+=s*8;let h=new Uint8Array(this.buffer,f,i*4);f+=i*4;let u=[];for(let d=0;d<l;++d){let j=e.getFloat32(f,!0);f+=4;let A=e.getUint32(f,!0);f+=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(f,!0)),f+=4}let b=null;if(n)b=new Uint8Array(this.buffer,f,3),f+=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[lf.SHADING_TYPE],j=null;if(c.length>0){j=al.slice();for(let A=0,S=c.length;A<S;A+=2)Be.pointBoundingBox(c[A],c[A+1],j)}return["Mesh",d,c,h,s,j,g,b]}throw Error(`Unsupported pattern kind: ${t}`)}}class ay{#e;constructor(e){this.#e=e}get path(){if(Zt.isFloat16ArraySupported)return new Float16Array(this.#e);return new Float32Array(this.#e)}}function bz(e){if(e instanceof URL)return e;if(typeof e==="string"){if(Xs){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 wz(e){if(Xs&&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 j5(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 J9(e){if(typeof e!=="string")return null;if(e.endsWith("/"))return e;throw Error(`Invalid factory url: "${e}" must include trailing slash.`)}var l8=(e)=>typeof e==="object"&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,dz=(e)=>typeof e==="object"&&typeof e?.name==="string",jz=rz.bind(null,l8,dz);class ny{#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){ct("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 Q9={DATA:1,ERROR:2},Wa={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function dA(){}function As(e){if(e instanceof sl||e instanceof f5||e instanceof l5||e instanceof tu||e instanceof n5)return e;if(!(e instanceof Error||typeof e==="object"&&e!==null))Rt('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(e.name){case"AbortException":return new sl(e.message);case"InvalidPDFException":return new f5(e.message);case"PasswordException":return new l5(e.message,e.code);case"ResponseException":return new tu(e.message,e.status,e.missing);case"UnknownErrorException":return new n5(e.message,e.details)}return new n5(e.message,e.toString())}class H1{#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===Q9.DATA)n.resolve(e.data);else if(e.callback===Q9.ERROR)n.reject(As(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:Q9.DATA,callbackId:e.callbackId,data:i})},function(i){s.postMessage({sourceName:a,targetName:n,callback:Q9.ERROR,callbackId:e.callbackId,reason:As(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,l=this.targetName,f=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},f.postMessage({sourceName:i,targetName:l,action:e,streamId:s,data:t,desiredSize:c.desiredSize},n),h.promise},pull:(c)=>{let h=Promise.withResolvers();return this.streamControllers[s].pullCall=h,f.postMessage({sourceName:i,targetName:l,stream:Wa.PULL,streamId:s,desiredSize:c.desiredSize}),h.promise},cancel:(c)=>{Ca(c instanceof Error,"cancel must have a valid reason");let h=Promise.withResolvers();return this.streamControllers[s].cancelCall=h,this.streamControllers[s].isClosed=!0,f.postMessage({sourceName:i,targetName:l,stream:Wa.CANCEL,streamId:s,reason:As(c)}),h.promise}},a)}#a(e){let t=e.streamId,a=this.sourceName,n=e.sourceName,s=this.comObj,i=this,l=this.actionHandler[e.action],f={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:Wa.ENQUEUE,streamId:t,chunk:c},u)},close(){if(this.isCancelled)return;this.isCancelled=!0,s.postMessage({sourceName:a,targetName:n,stream:Wa.CLOSE,streamId:t}),delete i.streamSinks[t]},error(c){if(Ca(c instanceof Error,"error must have a valid reason"),this.isCancelled)return;this.isCancelled=!0,s.postMessage({sourceName:a,targetName:n,stream:Wa.ERROR,streamId:t,reason:As(c)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};f.sinkCapability.resolve(),f.ready=f.sinkCapability.promise,this.streamSinks[t]=f,Promise.try(l,e.data,f).then(function(){s.postMessage({sourceName:a,targetName:n,stream:Wa.START_COMPLETE,streamId:t,success:!0})},function(c){s.postMessage({sourceName:a,targetName:n,stream:Wa.START_COMPLETE,streamId:t,reason:As(c)})})}#n(e){let t=e.streamId,a=this.sourceName,n=e.sourceName,s=this.comObj,i=this.streamControllers[t],l=this.streamSinks[t];switch(e.stream){case Wa.START_COMPLETE:if(e.success)i.startCall.resolve();else i.startCall.reject(As(e.reason));break;case Wa.PULL_COMPLETE:if(e.success)i.pullCall.resolve();else i.pullCall.reject(As(e.reason));break;case Wa.PULL:if(!l){s.postMessage({sourceName:a,targetName:n,stream:Wa.PULL_COMPLETE,streamId:t,success:!0});break}if(l.desiredSize<=0&&e.desiredSize>0)l.sinkCapability.resolve();l.desiredSize=e.desiredSize,Promise.try(l.onPull||dA).then(function(){s.postMessage({sourceName:a,targetName:n,stream:Wa.PULL_COMPLETE,streamId:t,success:!0})},function(c){s.postMessage({sourceName:a,targetName:n,stream:Wa.PULL_COMPLETE,streamId:t,reason:As(c)})});break;case Wa.ENQUEUE:if(Ca(i,"enqueue should have stream controller"),i.isClosed)break;i.controller.enqueue(e.chunk);break;case Wa.CLOSE:if(Ca(i,"close should have stream controller"),i.isClosed)break;i.isClosed=!0,i.controller.close(),this.#s(i,t);break;case Wa.ERROR:Ca(i,"error should have stream controller"),i.controller.error(As(e.reason)),this.#s(i,t);break;case Wa.CANCEL_COMPLETE:if(e.success)i.cancelCall.resolve();else i.cancelCall.reject(As(e.reason));this.#s(i,t);break;case Wa.CANCEL:if(!l)break;let f=As(e.reason);Promise.try(l.onCancel||dA,f).then(function(){s.postMessage({sourceName:a,targetName:n,stream:Wa.CANCEL_COMPLETE,streamId:t,success:!0})},function(c){s.postMessage({sourceName:a,targetName:n,stream:Wa.CANCEL_COMPLETE,streamId:t,reason:As(c)})}),l.sinkCapability.reject(f),l.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 w8{#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:Rt(`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){Rt("Abstract method `_fetch` called.")}}class f8 extends w8{async _fetch(e,t){let a=t==="cMapUrl"&&!e.endsWith(".bcmap")?"text":"bytes",n=await u8(e,a);return n instanceof Uint8Array?n:j5(n)}}class d8{#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){Rt("Abstract method `_createCanvas` called.")}}class sy extends d8{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 j8{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 iy extends j8{#e;#t;#a;#n;#s;#l;#i=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super();this.#n=e,this.#s=t}get#f(){return this.#t||=new Map}get#o(){return this.#l||=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 f=e[0],c=Array(256);for(let u=0;u<256;u++)c[u]=f[u]/255;let h=c.join(",");return[h,h,h]}let[t,a,n]=e,s=Array(256),i=Array(256),l=Array(256);for(let f=0;f<256;f++)s[f]=t[f]/255,i[f]=a[f]/255,l[f]=n[f]/255;return[s.join(","),i.join(","),l.join(",")]}#h(e){if(this.#e===void 0){this.#e="";let t=this.#s.URL;if(t!==this.#s.baseURI)if(v5(t))ct('#createUrl: ignore "data:"-URL for performance reasons.');else this.#e=HA(t,"")}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return"none";let t=this.#f.get(e);if(t)return t;let[a,n,s]=this.#u(e),i=e.length===1?a:`${a}${n}${s}`;if(t=this.#f.get(i),t)return this.#f.set(e,t),t;let l=`g_${this.#n}_transfer_map_${this.#i++}`,f=this.#h(l);this.#f.set(e,f),this.#f.set(i,f);let c=this.#p(l);return this.#m(a,n,s,c),f}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=Be.makeHexColor(...i);let l=this.#j(t);if(t=Be.makeHexColor(...l),this.#r.style.color="",e==="#000000"&&t==="#ffffff"||e===t)return s.url;let f=Array(256);for(let b=0;b<=255;b++){let d=b/255;f[b]=d<=0.03928?d/12.92:((d+0.055)/1.055)**2.4}let c=f.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=l[b]/255,S=Array(d+1);for(let C=0;C<=d;C++)S[C]=j+C/d*(A-j);return S.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"||!Zt.platform.isFirefox)return null;return{"backdrop-filter":t,"background-color":"transparent"}}addAlphaFilter(e){let t=this.#f.get(e);if(t)return t;let[a]=this.#u([e]),n=`alpha_${a}`;if(t=this.#f.get(n),t)return this.#f.set(e,t),t;let s=`g_${this.#n}_alpha_map_${this.#i++}`,i=this.#h(s);this.#f.set(e,i),this.#f.set(n,i);let l=this.#p(s);return this.#d(a,l),i}addLuminosityFilter(e){let t=this.#f.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.#f.get(n),t)return this.#f.set(e,t),t;let s=`g_${this.#n}_luminosity_map_${this.#i++}`,i=this.#h(s);this.#f.set(e,i),this.#f.set(n,i);let l=this.#p(s);if(this.#g(l),e)this.#d(a,l);return i}addKnockoutFilter(e=0){let t=e>0?Math.min(1/e,1e6):1e6,a=`knockout_${t}`,n=this.#f.get(a);if(n)return n;let s=`g_${this.#n}_knockout_filter_${this.#i++}`,i=this.#h(s);this.#f.set(a,i);let l=this.#p(s),f=this.#s.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer");l.append(f);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"),f.append(c),i}addHighlightHCMFilter(e,t,a,n,s){let i=`${t}-${a}-${n}-${s}`,l=this.#o.get(e);if(l?.key===i)return l.url;if(l)l.filter?.remove(),l.key=i,l.url="none",l.filter=null;else l={key:i,url:"none",filter:null},this.#o.set(e,l);if(!t||!a)return l.url;let[f,c]=[t,a].map(this.#j.bind(this)),h=Math.round(0.2126*f[0]+0.7152*f[1]+0.0722*f[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=(S,C,O)=>{let T=Array(256),M=(u-h)/O,H=S/255,D=(C-S)/(255*O),N=0;for(let z=0;z<=O;z++){let L=Math.round(h+z*M),ee=H+z*D;for(let te=N;te<=L;te++)T[te]=ee;N=L+1}for(let z=N;z<256;z++)T[z]=T[N-1];return T.join(",")},j=`g_${this.#n}_hcm_${e}_filter`,A=l.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),l.url=this.#h(j),l.url}destroy(e=!1){if(e&&this.#l?.size)return;this.#a?.parentNode.parentNode.remove(),this.#a=null,this.#t?.clear(),this.#t=null,this.#l?.clear(),this.#l=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,cu(getComputedStyle(this.#r).getPropertyValue("color"))}#w(e){return this.#r.style.color=e,ou(getComputedStyle(this.#r).getPropertyValue("color"))}#A(e){let[t,a,n,s]=this.#w(e);if(s===1)return[t,a,n];let[i,l,f]=this.#j("Canvas");return[Zg(t,i,s),Zg(a,l,s),Zg(n,f,s)]}}function Zg(e,t,a){return Math.round(a*e+(1-a)*t)}if(Xs)ct("Please use the `legacy` build in Node.js environments.");async function qz(e){let a=await process.getBuiltinModule("fs/promises").readFile(e);return new Uint8Array(a)}class ly extends j8{}class fy extends d8{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}class ry extends w8{async _fetch(e,t){return qz(e)}}function oy({src:e,srcPos:t=0,dest:a,width:n,height:s,nonBlackColor:i=4294967295,inverseDecode:l=!1}){let f=Zt.isLittleEndian?4278190080:255,[c,h]=l?[i,f]:[f,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 C=t+u;t<C;++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 S=t<d?e[t++]:255;for(let C=0;C<g;++C,++j)a[j]=c^-(S>>7-C&1)&b}return{srcPos:t,destPos:j}}function vz({src:e,srcPos:t=0,dest:a,destPos:n=0,width:s,height:i}){let l=0,f=s*i*3,c=f>>2,h=new Uint32Array(e.buffer,t,c),u=Zt.isLittleEndian?4278190080:255;if(Zt.isLittleEndian){for(;l<c-2;l+=3,n+=4){let g=h[l],b=h[l+1],d=h[l+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=l*4,b=t+f;g<b;g+=3)a[n++]=e[g]|e[g+1]<<8|e[g+2]<<16|u}else{for(;l<c-2;l+=3,n+=4){let g=h[l],b=h[l+1],d=h[l+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=l*4,b=t+f;g<b;g+=3)a[n++]=e[g]<<24|e[g+1]<<16|e[g+2]<<8|u}return{srcPos:t+f,destPos:n}}var kz=`
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 cy{#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:kz});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,l,f){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,l,f,0]));let S=c.createBindGroup({layout:this.#a.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:A}}]}),C=new OffscreenCanvas(i,l),O=C.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,S),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(),C.transferToImageBitmap()}}var y5=new cy;function Az(){return y5.init()}function yz(){return y5.isReady}function Sz(){y5.loadMeshShader()}function Cz(e,t,a,n,s,i,l,f){return y5.draw(e,t,a,n,s,i,l,f)}var xn={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function s5(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 S5{isModifyingCurrentTransform(){return!1}getPattern(){Rt("Abstract method `getPattern` called.")}}class hy extends S5{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(),Be.applyTransform(n,t),Be.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,l=this._r1;if(t){let f=new Float32Array(2);Be.singularValueDecompose2dScale(t,f),i*=f[0],l*=f[0]}a=e.createRadialGradient(n[0],n[1],i,s[0],s[1],l)}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(),Be.applyTransform(a,t),Be.applyTransform(n,t);let s=this._r1,i=this._r0;if(t){let c=new Float32Array(2);Be.singularValueDecompose2dScale(t,c),s*=c[0],i*=c[0]}let l=e.createRadialGradient(a[0],a[1],s,n[0],n[1],i),f=this._colorStops.map(([c,h])=>[1-c,h]).reverse();for(let[c,h]of f)l.addColorStop(c,h);return l}getPattern(e,t,a,n){let s;if(n===xn.STROKE||n===xn.FILL){if(this.isOriginBased()){let g=Be.transform(a,t.baseTransform);if(this.matrix)g=Be.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,fa(e))||[0,0,0,0],l=Math.ceil(i[2]-i[0])||1,f=Math.ceil(i[3]-i[1])||1,c=t.canvasFactory.create(l,f),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=Be.transform(a,[1,0,0,1,i[0],i[1]]),h.transform(...t.baseTransform),this.matrix)h.transform(...this.matrix);if(s5(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(),s5(e,this._bbox),e.fillStyle=this._createReversedGradient(e),e.fillRect(-10000000000,-10000000000,20000000000,20000000000),e.restore();s5(e,this._bbox),s=this._createGradient(e)}return s}}function _z(e,t,a,n,s,i,l,f){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=l,l=b;if(c[n*2+1]>c[s*2+1])b=n,n=s,s=b,b=l,l=f,f=b;if(c[a*2+1]>c[n*2+1])b=a,a=n,n=b,b=i,i=l,l=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,S=(c[n*2+1]+t.offsetY)*t.scaleY,C=(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],D=h[l*4],N=h[l*4+1],z=h[l*4+2],L=h[f*4],ee=h[f*4+1],te=h[f*4+2],J=Math.round(j),ae=Math.round(O),Q,Y,$,fe,P,qe,be,me;for(let de=J;de<=ae;de++){if(de<S){let Oe=de<j?0:(j-de)/(j-S);Q=d-(d-A)*Oe,Y=T-(T-D)*Oe,$=M-(M-N)*Oe,fe=H-(H-z)*Oe}else{let Oe;if(de>O)Oe=1;else if(S===O)Oe=0;else Oe=(S-de)/(S-O);Q=A-(A-C)*Oe,Y=D-(D-L)*Oe,$=N-(N-ee)*Oe,fe=z-(z-te)*Oe}let ye;if(de<j)ye=0;else if(de>O)ye=1;else ye=(j-de)/(j-O);P=d-(d-C)*ye,qe=T-(T-L)*ye,be=M-(M-ee)*ye,me=H-(H-te)*ye;let xe=Math.round(Math.min(Q,P)),Qe=Math.round(Math.max(Q,P)),ht=g*de+xe*4;for(let Oe=xe;Oe<=Qe;Oe++){if(ye=(Q-Oe)/(Q-P),ye<0)ye=0;else if(ye>1)ye=1;u[ht++]=Y-(Y-qe)*ye|0,u[ht++]=$-($-be)*ye|0,u[ht++]=fe-(fe-me)*ye|0,u[ht++]=255}}}class uy extends S5{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,Sz()}_createMeshCanvas(e,t,a){let l=Math.floor(this._bounds[0]),f=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-l,h=Math.ceil(this._bounds[3])-f,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:-l,offsetY:-f,scaleX:1/b,scaleY:1/d},A=u+4,S=g+4,C=a.create(A,S);if(yz()&&this._vertexCount>48)C.context.drawImage(Cz(this._posData,this._colData,this._vertexCount,j,t,A,S,2),0,0);else{let O=C.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)_z(O,j,T,T+1,T+2,T,T+1,T+2);C.context.putImageData(O,2,2)}return{canvas:C.canvas,offsetX:l-2*b,offsetY:f-2*d,scaleX:b,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(e,t,a,n){s5(e,this._bbox);let s=new Float32Array(2);if(n===xn.SHADING)Be.singularValueDecompose2dScale(fa(e),s);else if(this.matrix){Be.singularValueDecompose2dScale(this.matrix,s);let[f,c]=s;Be.singularValueDecompose2dScale(t.baseTransform,s),s[0]*=f,s[1]*=c}else Be.singularValueDecompose2dScale(t.baseTransform,s);let i=this._createMeshCanvas(s,n===xn.SHADING?null:this._background,t.canvasFactory);if(n!==xn.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 l=e.createPattern(i.canvas,"no-repeat");return t.canvasFactory.destroy(i),l}}class my extends S5{getPattern(){return"hotpink"}}function Fz(e){switch(e[0]){case"RadialAxial":return new hy(e);case"Mesh":return new uy(e);case"Dummy":return new my}throw Error(`Unknown IR type: ${e[0]}`)}var jA={COLORED:1,UNCOLORED:2};class eu{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?Be.transform(n,this.matrix):n}canSkipPatternCanvas([e,t,a,n]){let[s,i,l,f]=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-l)/c)+1,g=Math.ceil((a+e-s)/c)-1,b=Math.floor((n-f)/h)+1,d=Math.ceil((n+t-i)/h)-1;return g<=u&&d<=b?[u,b]:null}updatePatternDims(e,t){let a=Be.inverseTransform(this.patternBaseMatrix),n=[e[0],e[1]],s=[e[2],e[3]];Be.applyTransform(n,a),Be.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,l,f]=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,l,f),u.baseTransform=fa(u.ctx),u.executeOperatorList(this.operatorList),u.endDrawing(),u.dependencyTracker?.restore(),h.restore(),c}_getCombinedScales(){let e=new Float32Array(2);Be.singularValueDecompose2dScale(this.matrix,e);let[t,a]=e;return Be.singularValueDecompose2dScale(this.baseTransform,e),[t*e[0],a*e[1]]}drawPattern(e,t,a=!1,[n,s],i){let[l,f,c,h]=this.bbox,u=e.dependencyTracker;if(u)e.dependencyTracker=new su(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-l,b=h-f,[d,j]=this._getCombinedScales(),A=this.getSizeAndScale(g,this.ctx.canvas.width,d),S=this.getSizeAndScale(b,this.ctx.canvas.height,j),C=this._renderTileCanvas(e,i,A,S);e.ctx.drawImage(C.canvas,l,f,g,b),e.canvasFactory.destroy(C)}else this.setFillAndStrokeStyleToContext(e,this.paintType,this.color),this.clipBbox(e,l,f,c,h),e.baseTransformStack.push(e.baseTransform),e.baseTransform=fa(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,l=s-a,f=i-n,{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),d5("TilingType: "+this.tilingType);let[u,g]=this._getCombinedScales(),b=l,d=f,j=!1,A=!1;if(Math.ceil(c*u)>=Math.ceil(l*u))b=c;else j=!0;if(Math.ceil(h*g)>=Math.ceil(f*g))d=h;else A=!0;let S=this.getSizeAndScale(b,this.ctx.canvas.width,u),C=this.getSizeAndScale(d,this.ctx.canvas.height,g),O=this._renderTileCanvas(e,t,S,C);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),D=M.size,N=H.size,z=e.canvasFactory.create(D,N),L=z.context,ee=j?Math.floor(l/c):0,te=A?Math.floor(f/h):0;for(let J=0;J<=ee;J++)for(let ae=0;ae<=te;ae++)L.drawImage(T,D*J,N*ae,D,N,0,0,D,N);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:S.scale,scaleY:C.scale,offsetX:a,offsetY:n}}getSizeAndScale(e,t,a){let n=Math.max(eu.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,l=s-a,f=new Path2D;f.rect(t,a,i,l),Be.axialAlignedBoundingBox([t,a,n,s],fa(e.ctx),e.current.minMax),e.ctx.clip(f),e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,a){let{ctx:n,current:s}=e;switch(s.patternFill=s.patternStroke=!1,t){case jA.COLORED:let{fillStyle:i,strokeStyle:l}=this.ctx;n.fillStyle=s.fillColor=i,n.strokeStyle=s.strokeColor=l;break;case jA.UNCOLORED:n.fillStyle=n.strokeStyle=a,s.fillColor=s.strokeColor=a;break;default:throw new xA(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,a,n,s){let i=n!==xn.SHADING?Be.transform(a,this.patternBaseMatrix):a,l=this.createPatternCanvas(t,s),f=new DOMMatrix(i);f=f.translate(l.offsetX,l.offsetY),f=f.scale(1/l.scaleX,1/l.scaleY);let c=e.createPattern(l.canvas,"repeat");return t.canvasFactory.destroy(l.canvasEntry),c.setTransform(f),c}}var Oz=16,Bz=100,Tz=15,qA=10,ys=16,$g=new DOMMatrix,Ls=new Float32Array(2);function vA(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 Z9(e,t,a,n,s,i,l,f,c,h){let[u,g,b,d,j,A]=fa(e);if(g===0&&b===0){let O=l*u+j,T=Math.round(O),M=f*d+A,H=Math.round(M),D=(l+c)*u+j,N=Math.abs(Math.round(D)-T)||1,z=(f+h)*d+A,L=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,N,L),e.setTransform(u,g,b,d,j,A),[N,L]}if(u===0&&d===0){let O=f*b+j,T=Math.round(O),M=l*g+A,H=Math.round(M),D=(f+h)*b+j,N=Math.abs(Math.round(D)-T)||1,z=(l+c)*g+A,L=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,L,N),e.setTransform(u,g,b,d,j,A),[L,N]}e.drawImage(t,a,n,s,i,l,f,c,h);let S=Math.hypot(u,g),C=Math.hypot(b,d);return[S*c,C*h]}class r8{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Pg;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=nn.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=_r.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=xn.FILL,t=null){let a=this.minMax.slice();if(e===xn.STROKE){if(!t)Rt("Stroke bounding box must include transform.");Be.singularValueDecompose2dScale(t,Ls);let n=Ls[0]*this.lineWidth/2,s=Ls[1]*this.lineWidth/2;a[0]-=n,a[1]-=s,a[2]+=n,a[3]+=s}return a}updateClipFromPath(){let e=Be.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(_r,0)}getClippedPathBoundingBox(e=xn.FILL,t=null){return Be.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function kA(e,t){let{width:a,height:n,kind:s}=t,i=n%ys,l=(n-i)/ys,f=i===0?l:l+1,c=e.createImageData(a,ys),h=0,u=t.data,g=c.data,b;if(s===a5.GRAYSCALE_1BPP)for(b=0;b<f;b++)({srcPos:h}=oy({src:u,srcPos:h,dest:g,width:a,height:b<l?ys:i})),e.putImageData(c,0,b*ys);else if(s===a5.RGBA_32BPP){let d=0,j=a*ys*4;for(b=0;b<l;b++)g.set(u.subarray(h,h+j)),h+=j,e.putImageData(c,0,d),d+=ys;if(b<f)j=a*i*4,g.set(u.subarray(h,h+j)),e.putImageData(c,0,d)}else if(s===a5.RGB_24BPP)for(b=0;b<f;b++)({srcPos:h}=vz({src:u,srcPos:h,dest:new Uint32Array(g.buffer),width:a,height:b<l?ys:i})),e.putImageData(c,0,b*ys);else throw Error(`bad image kind: ${s}`)}function AA(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let{width:a,height:n}=t,s=n%ys,i=(n-s)/ys,l=s===0?i:i+1,f=e.createImageData(a,ys),c=0,h=t.data,u=f.data;for(let g=0;g<l;g++)({srcPos:c}=oy({src:h,srcPos:c,dest:u,width:a,height:g<i?ys:s,nonBlackColor:0})),e.putImageData(f,0,g*ys)}function yr(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 $9(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 yA(e,t){if(t)return!0;Be.singularValueDecompose2dScale(e,Ls);let a=Math.fround(b0.pixelRatio*Or.PDF_TO_CSS_UNITS);return Ls[0]<=a&&Ls[1]<=a}var Mz=["butt","round","square"],Hz=["miter","round","bevel"],xz={},SA={};class D1{#e=0;#t=0;#a=null;#n=null;#s=null;#l=null;#i=1;#f;#o=null;#r=[];constructor(e,t,a,n,s,{optionalContentConfig:i,markedContentStack:l=null},f,c,h,u){this.ctx=e,this.current=new r8(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=l||[],this.optionalContentConfig=i,this.cachedPatterns=new Map,this.annotationCanvasMap=f,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,l=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,s,i),this.ctx.fillStyle=l,a){let f=this.transparentCanvasEntry=this.canvasFactory.create(s,i);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=f,this.ctx.save(),this.ctx.transform(...fa(this.compositeCtx))}if(this.ctx.save(),$9(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=fa(this.ctx)}executeOperatorList(e,t,a,n,s){let{argsArray:i,fnArray:l}=e,f=t||0,c=i.length;if(c===f)return f;let h=c-f>qA&&typeof a==="function",u=h?Date.now()+Tz:0,g=0,b=this.commonObjs,d=this.objs,j,A;while(!0){if(n!==void 0){if(f===n.nextBreakPoint)return n.breakIt(f,a),f;if(n.shouldSkip(f)){if(++f===c)return f;continue}}if(!s||s(f))if(j=l[f],A=i[f]??null,j!==g0.dependency)if(A===null)this[j](f);else this[j](f,...A);else for(let S of A){this.dependencyTracker?.recordNamedData(S,f);let C=S.startsWith("g_")?b:d;if(!C.has(S))return C.get(S,a),f}if(f++,f===c)return f;if(h&&++g>qA){if(Date.now()>u)return a(),f;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.#l=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),l=[],f=s,c=i,h=a,u=n;while(f>2&&h>1||c>2&&u>1){let S=h,C=u;if(f>2&&h>1)S=Math.ceil(h/2),f/=h/S;if(c>2&&u>1)C=Math.ceil(u/2),c/=u/C;l.push({newWidth:S,newHeight:C}),h=S,u=C}if(l.length===0)return{img:e,paintWidth:a,paintHeight:n,tmpCanvas:null};if(l.length===1){let{newWidth:S,newHeight:C}=l[0],O=this.canvasFactory.create(S,C);return O.context.drawImage(e,0,0,a,n,0,0,S,C),{img:O.canvas,paintWidth:S,paintHeight:C,tmpCanvas:O}}let g=this.canvasFactory.create(1,1),b=this.canvasFactory.create(1,1),d=a,j=n,A=e;for(let{newWidth:S,newHeight:C}of l)this.canvasFactory.reset(b,S,C),b.context.drawImage(A,0,0,d,j,0,0,S,C),[g,b]=[b,g],A=g.canvas,d=S,j=C;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,l=this.current.patternFill,f=fa(a),c,h,u,g;if((t.bitmap||t.data)&&t.count>1){let ee=t.bitmap||t.data.buffer;h=JSON.stringify(l?f:[f.slice(0,4),i]),c=this._cachedBitmapsMap.getOrInsertComputed(ee,c8);let te=c.get(h);if(te&&!l){let J=Math.round(Math.min(f[0],f[2])+f[4]),ae=Math.round(Math.min(f[1],f[3])+f[5]);return this.dependencyTracker?.recordDependencies(e,gi.transformAndFill),{canvas:te,offsetX:J,offsetY:ae}}u=te}if(!u)g=this.canvasFactory.create(n,s),AA(g.context,t);let b=Be.transform(f,[1/n,0,0,-1/s,0,0]);b=Be.transform(b,[1,0,0,1,0,-s]);let d=_r.slice();Be.axialAlignedBoundingBox([0,0,n,s],b,d);let[j,A,S,C]=d,O=Math.round(S-j)||1,T=Math.round(C-A)||1,M=this.canvasFactory.create(O,T),H=M.context,D=j,N=A;H.translate(-D,-N),H.transform(...b);let z=null;if(!u){let ee=this._scaleImage(g.canvas,h0(H));if(u=ee.img,z=ee.tmpCanvas,u!==g.canvas)this.canvasFactory.destroy(g),g=null;if(c&&l)c.set(h,u),z=null,g=null}if(H.imageSmoothingEnabled=yA(fa(H),t.interpolate),Z9(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 L=Be.transform(h0(H),[1,0,0,1,-D,-N]);if(H.fillStyle=l?i.getPattern(a,this,L,xn.FILL,e):i,H.fillRect(0,0,n,s),c&&!l)c.set(h,M.canvas);return this.dependencyTracker?.recordDependencies(e,gi.transformAndFill),{canvas:M.canvas,canvasEntry:c&&!l?null:M,offsetX:Math.round(D),offsetY:Math.round(N)}}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=Mz[t]}setLineJoin(e,t){this.dependencyTracker?.recordSimpleData("lineJoin",e),this.ctx.lineJoin=Hz[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 l;if(a==="Luminosity"&&n){let[C,O,T]=ou(n),M=Math.round(0.3*C+0.59*O+0.11*T);l=s?.[M]??M}else l=s?.[0]??0;let f=4,{width:c,height:h}=this.ctx.canvas,u=t.width*t.height,g=c*h<f*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,S;if(g)j=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,c,h,d,b),A=0,S=0;else j=this._bakeSMaskCanvas(t,0,0,t.width,t.height,d,b),A=e.offsetX,S=e.offsetY;this.smaskPreparedEntry=j,this.smaskPreparedFor=e,this.smaskPreparedOffsetX=A,this.smaskPreparedOffsetY=S,this.smaskPreparedOOBAlpha=!g&&l!==0?l:null}_bakeSMaskCanvas(e,t,a,n,s,i,l){if(!i&&!l)Rt("_bakeSMaskCanvas with neither backdrop nor filter");let f=this.canvasFactory.create(n,s),c=f.context;if(c.drawImage(e,t,a),i)c.globalCompositeOperation="destination-atop",c.fillStyle=i,c.fillRect(0,0,n,s);if(!l)return f;let h=this.canvasFactory.create(n,s),u=h.context;u.filter=l.url;let g=Zt.isCanvasFilterSupported&&u.filter!=="none"&&u.filter!=="";if(u.drawImage(f.canvas,0,0),Zt.isCanvasFilterSupported)u.filter="none";if(!g){let b=u.getImageData(0,0,n,s),{data:d}=b,{transferMap:j}=l;if(l.subtype==="Luminosity")for(let A=0,S=d.length;A<S;A+=4){let C=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?.[C]??C}else for(let A=3,S=d.length;A<S;A+=4)d[A]=j[d[A]];u.putImageData(b,0,0)}return this.canvasFactory.destroy(f),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()),yr(this.suspendedCtx,s),vA(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(),yr(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),l=i.context;a=Math.round(a*255)/255;let f=a<1;if(f&&this.#f===void 0)this.#f=Zt.isCanvasFilterSupported?new Map:"none";let c="none";if(f&&this.#f instanceof Map)c=this.#f.getOrInsertComputed(a,()=>this.filterFactory.addKnockoutFilter(a));if(!f||c!=="none"){if(t)l.save(),l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,n,s),l.restore();return l.filter=c,l.drawImage(e,0,0),l.filter="none",i}let h=e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,n,s),u=l.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 l.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:l=null,poolMeta:f=null,sourceAlpha:c=1,sourceFilter:h="none",knockoutAlpha:u=1}=a,{width:g,height:b}=t,d=this.#g(t,l,u),j=e.globalCompositeOperation;if(e.save(),e.setTransform(...s),e.globalAlpha=1,Zt.isCanvasFilterSupported)e.filter="none";if(e.globalCompositeOperation="destination-out",e.drawImage(d.canvas,0,0),n){let[A,S]=i,C=this.#b(f,"knockoutBackdropEntry",g,b),O=C.context;if(O.drawImage(n,A,S,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(C.canvas,0,0),!f)this.canvasFactory.destroy(C)}if(e.globalCompositeOperation=j,e.globalAlpha=c,Zt.isCanvasFilterSupported)e.filter=h??"none";if(e.drawImage(t,0,0),e.restore(),!l)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()),yr(this.ctx,s),this.#l=s.globalCompositeOperation,s.globalCompositeOperation="source-over",vA(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.#l,this.#l=null,yr(this.ctx,a),this.ctx=a;let i=this.#o;this.#o=null;let l=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:l})}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],l=n[2]-s,f=n[3]-i;if(l===0||f===0)return;let c=this.smaskPreparedEntry;if(c){let h=s,u=i,g=l,b=f,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+l,t.offsetX+t.canvas.width),S=Math.min(i+f,t.offsetY+t.canvas.height);g=A-h,b=S-u}if(g>0&&b>0){let A=h-this.smaskPreparedOffsetX,S=u-this.smaskPreparedOffsetY;a.save(),a.globalAlpha=1,a.setTransform(1,0,0,1,0,0);let C=new Path2D;C.rect(h,u,g,b),a.clip(C),a.globalCompositeOperation="destination-in",a.drawImage(c.canvas,A,S,g,b,h,u,g,b),a.restore()}if(j&&d<255)this._applySMaskOOBAlpha(a,s,i,l,f,h,u,h+g,u+b,d)}else this.genericComposeSMask(t,a,l,f,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,l,f,s,i,l,f),e.restore()}_applySMaskOOBAlpha(e,t,a,n,s,i,l,f,c,h){let u=i<f&&l<c;if(u&&i===t&&l===a&&f===t+n&&c===a+s)return;let g=new Path2D;if(g.rect(t,a,n,s),u)g.rect(i,l,f-i,c-l);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:l,offsetX:f,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(l.canvas,s-f,i-c,a,n,s,i,a,n),t.restore()}save(e){if(this.inSMaskMode)yr(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)yr(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,l){this.dependencyTracker?.recordIncrementalData("transform",e),this.ctx.transform(t,a,n,s,i,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,a,n){let[s]=a;if(!n){if(s||=a[0]=new Path2D,t!==g0.stroke&&t!==g0.closeStroke)this.current.tilingPatternDims=null;this[t](e,s);return}if(this.dependencyTracker!==null){let l=t===g0.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,n[0]-l,n[2]+l,n[1]-l,n[3]+l).recordDependencies(e,["transform"])}if(!(s instanceof Path2D))s=a[0]=EA(s);Be.axialAlignedBoundingBox(n,fa(this.ctx),this.current.minMax);let i=this.current.tilingPatternDims;if(i&&t!==g0.stroke&&t!==g0.closeStroke&&this.current.fillColor instanceof eu){let l=Be.intersect(this.current.clipBox,this.current.minMax);if(!l)this.current.tilingPatternDims=null;else this.current.fillColor.updatePatternDims(l,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 l=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=i.getPattern(s,this,h0(s),xn.STROKE,e),l){let f=new Path2D;f.addPath(t,s.getTransform().invertSelf().multiplySelf(l)),t=f}this.rescaleAndStroke(t,!1),s.restore()}else this.rescaleAndStroke(t,!0);if(this.dependencyTracker?.recordDependencies(e,gi.stroke),a)this.consumePath(e,t,this.current.getClippedPathBoundingBox(xn.STROKE,fa(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,l=this.current.patternFill,f=!1,c=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(e,gi.fill),l){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,h0(s),xn.FILL,e),g){let b=new Path2D;b.addPath(t,s.getTransform().invertSelf().multiplySelf(g)),t=b}f=!0}if(this.contentVisible&&c!==null)if(this.pendingEOFill)s.fill(t,"evenodd"),this.pendingEOFill=!1;else s.fill(t);if(f)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,gi.rawFillPath).recordOperation(e),this.#m(a)}clip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e),this.pendingClip=xz}eoClip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e),this.pendingClip=SA}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:l,y:f,fontSize:c,path:h}of t){if(!h)continue;n.addPath(h,new DOMMatrix(i).preMultiplySelf(s).translate(l,f).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||Pg,s.fontMatrix[0]===0||s.fontMatrix[3]===0)ct("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",l=n.systemFontInfo?.css||`"${i}", ${n.fallbackName}`,f="normal";if(n.black)f="900";else if(n.bold)f="bold";let c=n.italic?"italic":"normal",h=ha(a,Oz,Bz);this.current.fontSizeScale=a/h,this.ctx.font=`${c} ${f} ${h}px ${l}`}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 l=this.ctx,f=this.current,c=f.font,h=f.textRenderingMode,u=f.fontSize/f.fontSizeScale,g=h&nn.FILL_STROKE_MASK,b=!!(h&nn.ADD_TO_PATH_FLAG),d=f.patternFill&&!c.missingFile,j=f.patternStroke&&!c.missingFile,A;if((c.disableFontFace||b||d||j)&&!c.missingFile)A=c.getPathGenerator(this.commonObjs,t);if(A&&(c.disableFontFace||d||j)){l.save(),l.translate(a,n),l.scale(u,-u),this.dependencyTracker?.recordCharacterBBox(e,l,c);let S;if(g===nn.FILL||g===nn.FILL_STROKE)if(s){S=l.getTransform(),l.setTransform(...s);let C=this.#d(A,S,s);l.fill(C)}else l.fill(A);if(g===nn.STROKE||g===nn.FILL_STROKE)if(i){S||=l.getTransform(),l.setTransform(...i);let{a:C,b:O,c:T,d:M}=S,H=Be.inverseTransform(i),D=Be.transform([C,O,T,M,0,0],H);Be.singularValueDecompose2dScale(D,Ls),l.lineWidth*=Math.max(Ls[0],Ls[1])/u,l.stroke(this.#d(A,S,i))}else l.lineWidth/=u,l.stroke(A);l.restore()}else{if(g===nn.FILL||g===nn.FILL_STROKE)l.fillText(t,a,n),this.dependencyTracker?.recordCharacterBBox(e,l,c,u,a,n,()=>l.measureText(t));if(g===nn.STROKE||g===nn.FILL_STROKE){if(this.dependencyTracker)this.dependencyTracker?.recordCharacterBBox(e,l,c,u,a,n,()=>l.measureText(t)).recordDependencies(e,gi.stroke);l.strokeText(t,a,n)}}if(b)(this.pendingTextPaths||=[]).push({transform:fa(l),x:a,y:n,fontSize:u,path:A}),this.dependencyTracker?.recordCharacterBBox(e,l,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 lt(this,"isFontSubpixelAAEnabled",n)}showText(e,t){if(this.dependencyTracker){if(this.dependencyTracker.recordDependencies(e,gi.showText).resetBBox(e),this.current.textRenderingMode&nn.ADD_TO_PATH_FLAG)this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies()}let a=this.current,n=a.font;if(n.isType3Font){let te=this.#c(a.fillAlpha);this.showType3Text(e,t),this.dependencyTracker?.recordShowTextOperation(e),this.#m(te);return}let s=a.fontSize;if(s===0){this.dependencyTracker?.recordOperation(e);return}let i=this.#c(a.fillAlpha),l=this.ctx,f=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,S=s*a.fontMatrix[0],C=a.textRenderingMode===nn.FILL&&!n.disableFontFace&&!a.patternFill;if(l.save(),a.textMatrix)l.transform(...a.textMatrix);if(l.translate(a.x,a.y+a.textRise),u>0)l.scale(g,-1);else l.scale(g,1);let O,T,M=a.textRenderingMode&nn.FILL_STROKE_MASK,H=M===nn.FILL||M===nn.FILL_STROKE,D=M===nn.STROKE||M===nn.FILL_STROKE,N=a.lineWidth,z=a.textMatrixScale;if(z===0||N===0){if(D)N=this.getSinglePixelWidth()}else N/=z;if(f!==1)l.scale(f,f),N/=f;if(l.lineWidth=N,H&&a.patternFill){l.save();let te=a.fillColor.getPattern(l,this,h0(l),xn.FILL,e);O=fa(l),l.restore(),l.fillStyle=te}if(D&&a.patternStroke){l.save();let te=a.strokeColor.getPattern(l,this,h0(l),xn.STROKE,e);T=fa(l),l.restore(),l.strokeStyle=te}if(n.isInvalidPDFjsFont){let te=[],J=0;for(let Q of t)te.push(Q.unicode),J+=Q.width;let ae=te.join("");if(l.fillText(ae,0,0),this.dependencyTracker!==null){let Q=l.measureText(ae);this.dependencyTracker.recordBBox(e,this.ctx,-Q.actualBoundingBoxLeft,Q.actualBoundingBoxRight,-Q.actualBoundingBoxAscent,Q.actualBoundingBoxDescent).recordShowTextOperation(e)}a.x+=J*S*g,l.restore(),this.compose(),this.#m(i);return}let L=0,ee;for(ee=0;ee<b;++ee){let te=t[ee];if(typeof te==="number"){L+=j*te*s/1000;continue}let J=!1,ae=(te.isSpace?h:0)+c,Q=te.fontChar,Y=te.accent,$,fe,P=te.width;if(d){let me=te.vmetric||A,de=-(te.vmetric?me[1]:P*0.5)*S,ye=me[2]*S;P=me?-me[0]:P,$=de/f,fe=(L+ye)/f}else $=L/f,fe=0;let qe;if(n.remeasure&&P>0){qe=l.measureText(Q);let me=qe.width*1000/s*f;if(P<me&&this.isFontSubpixelAAEnabled){let de=P/me;J=!0,l.save(),l.scale(de,1),$/=de}else if(P!==me)$+=(P-me)/2000*s/f}if(this.contentVisible&&(te.isInFont||n.missingFile)){if(C&&!Y)l.fillText(Q,$,fe),this.dependencyTracker?.recordCharacterBBox(e,l,qe?{bbox:null}:n,s/f,$,fe,()=>qe??l.measureText(Q));else if(this.paintChar(e,Q,$,fe,O,T),Y){let me=$+s*Y.offset.x/f,de=fe-s*Y.offset.y/f;this.paintChar(e,Y.fontChar,me,de,O,T)}}let be=d?P*S-ae*u:P*S+ae*u;if(L+=be,J)l.restore()}if(d)a.y-=L;else a.x+=L*g;l.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,l=n.fontDirection,f=s.vertical?1:-1,c=n.charSpacing,h=n.wordSpacing,u=n.textHScale*l,g=n.fontMatrix||Pg,b=t.length,d=n.textRenderingMode===nn.INVISIBLE,j,A,S,C;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,l);let O=this.dependencyTracker;this.dependencyTracker=O?new su(O,e):null;for(j=0;j<b;++j){if(A=t[j],typeof A==="number"){C=f*A*i/1000,this.ctx.translate(C,0),n.x+=C*u;continue}let T=(A.isSpace?h:0)+c,M=s.charProcOperatorList[A.operatorListId];if(!M)ct(`Type3 character "${A.operatorListId}" is not available.`);else if(this.contentVisible){if(this.save(),M.fnArray[0]===g0.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];Be.applyTransform(H,g),S=H[0]*i+T,a.translate(S,0),n.x+=S*u}if(a.restore(),O)this.dependencyTracker=O}setCharWidth(e,t,a){}setCharWidthAndBounds(e,t,a,n,s,i,l){let f=new Path2D;f.rect(n,s,i-n,l-s),this.ctx.clip(f),this.dependencyTracker?.recordBBox(e,this.ctx,n,i,s,l).recordClipBox(e,this.ctx,n,i,s,l),this.endPath(e)}getColorN_Pattern(e,t){let a;if(t[0]==="TilingPattern"){let n=this.baseTransform||fa(this.ctx),s={createCanvasGraphics:(i,l)=>new D1(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new su(this.dependencyTracker,l,!0):null)};a=new eu(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 eu?[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=Fz(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,h0(n),xn.SHADING,e);let i=h0(n);if(i){let{width:l,height:f}=n.canvas,c=_r.slice();Be.axialAlignedBoundingBox([0,0,l,f],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,gi.transform).recordDependencies(e,gi.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e),this.#m(a)}beginInlineImage(){Rt("Should not call beginInlineImage")}beginImageData(){Rt("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=fa(this.ctx),a){Be.axialAlignedBoundingBox(a,this.baseTransform,this.current.minMax);let[n,s,i,l]=a,f=new Path2D;f.rect(n,s,i-n,l-s),this.ctx.clip(f),this.dependencyTracker?.recordClipBox(e,this.ctx,n,i,s,l),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 C=new Path2D,[O,T,M,H]=t.bbox;if(C.rect(O,T,M-O,H-T),t.matrix){let D=new Path2D;D.addPath(C,new DOMMatrix(t.matrix)),C=D}n.clip(C)}this.groupStack.push(null),this.#r.push(null),this.groupLevel++;return}if(!t.isolated&&!t.knockout&&this.#e===0)d5("TODO: Fully support non-isolated non-knockout groups.");let s=fa(n);if(t.matrix)n.transform(...t.matrix);let i=[0,0,n.canvas.width,n.canvas.height],l;if(t.bbox)l=_r.slice(),Be.axialAlignedBoundingBox(t.bbox,fa(n),l),l=Be.intersect(l,i)||[0,0,0,0];else l=i;let f=Math.floor(l[0]),c=Math.floor(l[1]),h=Math.max(Math.ceil(l[2])-f,1),u=Math.max(Math.ceil(l[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,S=this.#e;if(t.knockout)this.#e++;else this.#e=0;if(b.translate(-f,-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,-f,-c),b.restore();if(t.bbox){let C=new Path2D,[O,T,M,H]=t.bbox;if(C.rect(O,T,M-O,H-T),t.matrix){let D=new Path2D;D.addPath(C,new DOMMatrix(t.matrix)),C=D}b.clip(C)}if(t.smask)this.smaskStack.push({canvas:g.canvas,context:b,offsetX:f,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(f,c),n.save();yr(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:S,offsetX:f,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=fa(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...i);let l=_r.slice();Be.axialAlignedBoundingBox([0,0,a.canvas.width,a.canvas.height],i,l);let f=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,Zt.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,Zt.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=f?.backdropCtx??null;this.#p(this.ctx,a.canvas,{backdropCanvas:c?.canvas??null,destTransform:i,backdropOffset:c?[f.offsetX+s.offsetX,f.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(l)}}#j(e){let{canvas:t}=e,{width:a,height:n}=t;if(Zt.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 l=0,f=i.length;l<f;l+=4){let c=i[l]*0.2126+i[l+1]*0.7152+i[l+2]*0.0722+0.5|0;i[l]=i[l+1]=i[l+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,l){if(this.#u(),$9(this.ctx),this.ctx.save(),this.save(e),this.baseTransform)this.ctx.setTransform(...this.baseTransform);if(a){let f=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]=f,a[3]=c,Be.singularValueDecompose2dScale(fa(this.ctx),Ls);let{viewportScale:h}=this,u=Math.ceil(f*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(l){let j=this.annotationCanvasMap.getOrInsertComputed(t,fu);b.setAttribute("data-canvas-name",l);let A=j.findIndex((S)=>S.getAttribute("data-canvas-name")===l);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(Ls[0],0,0,-Ls[1],0,c*Ls[1]),$9(this.ctx)}else{$9(this.ctx),this.endPath(e);let h=new Path2D;h.rect(a[0],a[1],f,c),this.ctx.clip(h)}}this.current=new r8(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(e,...n),this.transform(e,...s),this.baseTransform=fa(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),l=i.canvas;if(s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(l,i.offsetX,i.offsetY),this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,i.offsetX,i.offsetX+l.width,i.offsetY,i.offsetY+l.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,l){if(!this.contentVisible)return;t=this.getObject(e,t.data,t);let f=this.#c(this.current.fillAlpha),c=this.ctx;c.save();let h=fa(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=l.length;g<b;g+=2){let d=Be.transform(h,[a,n,s,i,l[g],l[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(f)}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,gi.transformAndFill);for(let l of t){let{data:f,width:c,height:h,transform:u}=l,g=this.canvasFactory.create(c,h),b=g.context;b.save();let d=this.getObject(e,f,l);AA(b,d),b.globalCompositeOperation="source-in",b.fillStyle=i?s.getPattern(b,this,h0(n),xn.FILL,e):s,b.fillRect(0,0,c,h),b.restore(),n.save(),n.transform(...u),n.scale(1,-1),Z9(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){ct("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){ct("Dependent image isn't ready yet");return}let{width:l,height:f}=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:l,h:f});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:l}=i;if(l!=="none"&&l!=="")i.filter="none";i.scale(1/a,-1/n);let f,c=null;if(t.bitmap){let u=this.applyTransferMapsToBitmap(t);f=u.img,c=u.canvasEntry}else{let u=this.canvasFactory.create(a,n);kA(u.context,t),f=this.applyTransferMapsToCanvas(u.context),c=u}let h=this._scaleImage(f,h0(i));if(i.imageSmoothingEnabled=yA(fa(i),t.interpolate),this.dependencyTracker)this.dependencyTracker.resetBBox(e).recordBBox(e,i,0,a,-n,0).recordDependencies(e,gi.imageXObject).recordOperation(e),this.imagesTracker?.record(i,a,n,this.dependencyTracker.clipBox);if(Z9(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,l=null;if(t.bitmap)i=t.bitmap;else{let{width:f,height:c}=t,h=this.canvasFactory.create(f,c);kA(h.context,t),i=this.applyTransferMapsToCanvas(h.context),l=h}this.dependencyTracker?.resetBBox(e);for(let f of a)s.save(),s.transform(...f.transform),s.scale(1,-1),Z9(s,i,f.x,f.y,f.w,f.h,0,-1,1,1),this.dependencyTracker?.recordBBox(e,s,0,1,-1,0),s.restore();if(l)this.canvasFactory.destroy(l);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,gi.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===SA)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=fa(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,l;if(a===0&&n===0){let f=Math.abs(t),c=Math.abs(s);if(f===c)if(e===0)i=l=1/f;else{let h=f*e;i=l=h<1?1/h:1}else if(e===0)i=1/f,l=1/c;else{let h=f*e,u=c*e;i=h<1?1/h:1,l=u<1?1/u:1}}else{let f=Math.abs(t*s-a*n),c=Math.hypot(t,a),h=Math.hypot(n,s);if(e===0)i=h/f,l=c/f;else{let u=e*f;i=h>u?h/u:1,l=c>u?c/u:1}}this._cachedScaleForStroking[0]=i,this._cachedScaleForStroking[1]=l}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 l=a.getLineDash();if(t)a.save();a.scale(s,i),$g.a=1/s,$g.d=1/i;let f=new Path2D;if(f.addPath(e,$g),l.length>0){let c=Math.max(s,i);a.setLineDash(l.map((h)=>h/c)),a.lineDashOffset/=c}if(a.lineWidth=n||1,a.stroke(f),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 g0)if(D1.prototype[e]!==void 0)D1.prototype[g0[e]]=D1.prototype[e];class hu{#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 Ca(!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 uu{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(){Rt("Abstract method `read` called")}cancel(e){Rt("Abstract method `cancel` called")}}class mu{_stream=null;constructor(e,t,a){this._stream=e}async read(){Rt("Abstract method `read` called")}cancel(e){Rt("Abstract method `cancel` called")}}function Dz(e){let t=!0,a=n("filename\\*","i").exec(e);if(a){a=a[1];let u=f(a);return u=unescape(u),u=c(u),u=h(u),i(u)}if(a=l(e),a){let u=h(a);return i(u)}if(a=n("filename","i").exec(e),a){a=a[1];let u=f(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=j5(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 l(u){let g=[],b,d=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((b=d.exec(u))!==null){let[,A,S,C]=b;if(A=parseInt(A,10),A in g){if(A===0)break;continue}g[A]=[S,C]}let j=[];for(let A=0;A<g.length;++A){if(!(A in g))break;let[S,C]=g[A];if(C=f(C),S){if(C=unescape(C),A===0)C=c(C)}j.push(C)}return j.join("")}function f(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,S){return String.fromCharCode(parseInt(S,16))}),s(b,j);try{j=atob(j)}catch{}return s(b,j)})}return""}function gy(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 C5(e){return URL.parse(e)?.origin??null}function py({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=Dz(t);if(a.includes("%"))try{a=decodeURIComponent(a)}catch{}if(m8(a))return a}return null}function _5(e,t){return new tu(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,e===404||e===0&&t.protocol==="file:")}function wy(e,t){if(e!==t)throw Error(`Expected range response-origin "${e}" to match "${t}".`)}function dy(e,t,a,n){return fetch(e,{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:a?"include":"same-origin",redirect:"follow"})}function jy(e,t){if(e!==200&&e!==206)throw _5(e,t)}function F5(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw Error(`getArrayBuffer - unexpected data: ${e}`)}class qy extends hu{_responseOrigin=null;constructor(e){super(e,vy,ky);let{httpHeaders:t,url:a}=e;Ca(/https?:/.test(a.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=gy(!0,t)}}class vy extends uu{_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 l=new Headers(e.headers);dy(s,l,i,this._abortController).then((f)=>{e._responseOrigin=C5(f.url),jy(f.status,s),this._reader=f.body.getReader();let c=f.headers,{contentLength:h,isRangeSupported:u}=py({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 sl("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:F5(e),done:!1}}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class ky extends mu{_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}`),dy(n,i,s,this._abortController).then((l)=>{let f=C5(l.url);wy(f,e._responseOrigin),jy(l.status,n),this._reader=l.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:F5(e),done:!1}}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}function CA(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function O5(){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}class Ay extends hu{_progressiveDone=!1;_queuedChunks=[];constructor(e){super(e,yy,Sy);let{pdfDataRangeTransport:t}=e,{initialData:a,progressiveDone:n}=t;if(a?.length>0){let i=CA(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=CA(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);Ca(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 yy extends uu{#e=O5.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 f of this._queuedChunks)this._loaded+=f.byteLength;if(this._done=e._progressiveDone,this._contentLength=s,this._isStreamingSupported=!n,this._isRangeSupported=!a,m8(i))this._filename=i;this._headersCapability.resolve();let l=this._loaded;Promise.resolve().then(()=>{if(l>0&&this._loaded===l)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 Sy extends mu{#e=O5.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 Wg=200,_A=206;function Rz(e){return typeof e!=="string"?e:j5(e).buffer}class Cy extends hu{#e=new WeakMap;_responseOrigin=null;constructor(e){super(e,_y,Fy);let{httpHeaders:t,url:a}=e;this.url=a,this.isHttp=/https?:/.test(a.protocol),this.headers=gy(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===_A||n===Wg;else a.validateStatus=(n)=>n===Wg;return t.responseType="arraybuffer",Ca(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||Wg;if(!a.validateStatus(n)){a.onError(e.status);return}let s=Rz(e.response);if(n===_A){let i=e.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(i))a.onDone(s);else ct('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 _y extends uu{#e=O5.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=C5(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:l,isRangeSupported:f}=py({responseHeaders:i,isHttp:e.isHttp,rangeChunkSize:a,disableRange:t});if(this._contentLength=l,this._isRangeSupported=f,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=_5(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 Fy extends mu{#e=O5.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=C5(this._requestXhr?.responseURL);try{wy(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??=_5(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 Oy(e,t=null){let a=process.getBuiltinModule("fs"),{Readable:n}=process.getBuiltinModule("stream"),s=a.createReadStream(e,t);return n.toWeb(s)}class By extends hu{constructor(e){super(e,Ty,My);let{url:t}=e;Ca(t.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class Ty extends uu{_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((l)=>{let f=Oy(s);this._reader=f.getReader();let{size:c}=l;if(this._contentLength=c,this._isRangeSupported=!t&&c>2*n,!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new sl("Streaming is disabled."));this._headersCapability.resolve()}).catch((l)=>{if(l.code==="ENOENT")l=_5(0,s);this._headersCapability.reject(l)})}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:F5(e),done:!1}}cancel(e){this._reader?.cancel(e)}}class My extends mu{_readCapability=Promise.withResolvers();_reader=null;constructor(e,t,a){super(e,t,a);let{url:n}=e._source;try{let s=Oy(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:F5(e),done:!1}}cancel(e){this._reader?.cancel(e)}}function Nz(e){return Wh(e)?qy:Xs?By:Cy}class nl{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 Hy{#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 Sr=Symbol("INTERNAL");class xy{#e=!1;#t=!1;#a=!1;#n=!0;constructor(e,{name:t,intent:a,usage:n,rbGroups:s}){this.#e=!!(e&Us.DISPLAY),this.#t=!!(e&Us.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!==Sr)Rt("Internal method `_setVisible` called.");this.#a=a,this.#n=t}get serializable(){return{userSet:this.#a,visible:this.#n}}}class q8{#e=null;#t=new Map;#a=null;#n=null;#s;creator=null;name=null;constructor(e,t=Us.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 xy(t,n));if(a){if(a.size!==this.#t.size)Rt("Incorrect serialized groupState.");for(let[n,s]of a)this.#t.get(n)._setVisible(Sr,s.visible,s.userSet)}else{if(e.baseState==="OFF")for(let n of this.#t.values())n._setVisible(Sr,!1);for(let n of e.on)this.#t.get(n)._setVisible(Sr,!0);for(let n of e.off)this.#t.get(n)._setVisible(Sr,!1)}this.#a=this.getHash()}#l(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.#l(s);else if(this.#t.has(s))i=this.#t.get(s).visible;else return ct(`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 d5("Optional content group not defined."),!0;if(e.type==="OCG"){if(!this.#t.has(e.id))return ct(`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.#l(e.expression);if(!e.policy||e.policy==="AnyOn"){for(let t of e.ids){if(!this.#t.has(t))return ct(`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 ct(`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 ct(`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 ct(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return ct(`Unknown optional content policy ${e.policy}.`),!0}return ct(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,a=!0){let n=this.#t.get(e);if(!n){ct(`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(Sr,!1,!0)}n._setVisible(Sr,!!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 o5;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 q8(e,t,a)}}class Dy{#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}#l(){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.#l();let n=this.#e,s=this.#i(),i=t.length,l=new Uint32Array(i),f=0;for(let g=0;g<i;g++){let b=t[g]-1;if(l[g]=n[b],b<a)f++}let c=this.#a,h=c-i,u=ha(a-f,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(l,u),this.#f(s),n.every((g,b)=>g===b+1))this.#e=null}deletePages(e){this.#l();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,l=0;for(let f of e){let c=f-1;if(c!==i)s.set(t.subarray(i,c),l),l+=c-i;i=c+1}if(i<t.length)s.set(t.subarray(i),l);this.#f(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.#l(),this.#n={pageNumbers:e,pageIds:e.map((t)=>this.#e[t-1])}}cancelCopy(){this.#n=null}pastePages(e){this.#l();let t=this.#e,a=this.#i(),{pageNumbers:n,pageIds:s}=this.#n,i=this.#a+n.length;this.#a=i;let l=this.#e=new Uint32Array(i);this.#t=new Int32Array(i),l.set(t.subarray(0,e),0),l.set(s,e),l.set(t.subarray(e),e+n.length),this.#f(a,null,e,n),this.#n=null}#f(e,t=null,a=-1,n=null){let s=this.#t,i=this.#e,l=a+(n?.length??0),f=new Map;for(let c=0,h=this.#a;c<h;c++){if(c>=a&&c<l){s[c]=-n[c-a];continue}let u=i[c],g=e.get(u),b=f.get(u)||0;if(t&&g)while(b<g.length&&t.has(g[b]))b++;s[c]=g?.[b],f.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,l=s.length;i<l;i++)a[i].includePages.push([n-1,s[i]-1]);for(let{includePages:n,pageIndices:s}of a){n.sort((i,l)=>i[0]-l[0]);for(let i=0,l=n.length;i<l;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,fu).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 M1=Symbol("INITIAL_DATA"),FA=()=>({...Promise.withResolvers(),data:M1});class v8{#e=new Map;get(e,t=null){if(t){let n=this.#e.getOrInsertComputed(e,FA);return n.promise.then(()=>t(n.data)),null}let a=this.#e.get(e);if(!a||a.data===M1)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!==M1}delete(e){let t=this.#e.get(e);if(!t||t.data===M1)return!1;return this.#e.delete(e),!0}resolve(e,t=null){let a=this.#e.getOrInsertComputed(e,FA);if(a.data!==M1)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!==M1)yield[e,t]}}var zz=1e5,OA=30;class Gs{#e=Promise.withResolvers();#t=null;#a=!1;#n=!!globalThis.FontInspector?.enabled;#s=null;#l=null;#i=null;#f=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*b0.pixelRatio,this.#h=n.rotation,this.#i={div:null,properties:null,ctx:null};let{pageWidth:s,pageHeight:i,pageX:l,pageY:f}=n.rawDims;this.#j=[1,0,0,-1,-l,f+i],this.#o=s,this.#f=i,Gs.#H(),a.style.setProperty("--min-font-size",Gs.#q),Br(a,n),this.#e.promise.finally(()=>{Gs.#S.delete(this),this.#i=null,this.#b=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=Zt.platform;return lt(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.#l??=t.lang,Object.assign(this.#b,t.styles),this.#k(t.items),e()},this.#e.reject)};return this.#r=this.#c.getReader(),Gs.#S.add(this),e(),this.#e.promise}update({viewport:e,onBefore:t=null}){let a=e.scale*b0.pixelRatio,n=e.rotation;if(n!==this.#h)t?.(),this.#h=n,Br(this.#u,{rotation:n});if(a!==this.#g){t?.(),this.#g=a;let s={div:null,properties:null,ctx:Gs.#B(this.#l)};for(let i of this.#m)s.properties=this.#d.get(i),s.div=i,this.#O(s)}}cancel(){let e=new sl("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??=Gs.#B(this.#l);let t=this.#m,a=this.#p;for(let n of e){if(t.length>zz){ct("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=Be.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 l=this.#n&&i.fontSubstitution||i.fontFamily;l=Gs.fontFamilyMap.get(l)||l;let f=Math.hypot(n[2],n[3]),c=f*Gs.#x(l,i,this.#l),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.#f).toFixed(2)}%`,g.setProperty("--font-height",`${f.toFixed(2)}px`),g.fontFamily=l,a.fontSize=f,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:l,fontSize:f}=a;Gs.#F(n,f*this.#g,i);let{width:c}=n.measureText(t.textContent);if(c>0)s.setProperty("--scale-x",l*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#H(){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#x(e,t,a){let n=this.#w.get(e);if(n)return n;let s=this.#B(a);s.canvas.width=s.canvas.height=OA,this.#F(s,OA,e);let i=s.measureText(""),l=i.fontBoundingBoxAscent,f=Math.abs(i.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let c=0.8;if(l)c=l/(l+f);else{if(Zt.platform.isFirefox)ct("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 Ez=100;function k8(e={}){let t=new A8,{docId:a}=t,n=e.url?bz(e.url):null,s=e.data?wz(e.data):null,i=e.httpHeaders||null,l=e.withCredentials===!0,f=e.password??null,c=e.range instanceof y8?e.range:null,h=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536,u=e.worker instanceof Hn?e.worker:null,g=e.verbosity,b=typeof e.docBaseUrl==="string"&&!v5(e.docBaseUrl)?e.docBaseUrl:null,d=J9(e.cMapUrl),j=e.cMapPacked!==!1,A=J9(e.iccUrl),S=J9(e.standardFontDataUrl),C=J9(e.wasmUrl),O=e.stopAtErrors!==!0,T=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,M=typeof e.isOffscreenCanvasSupported==="boolean"?e.isOffscreenCanvasSupported:!Xs,H=typeof e.isImageDecoderSupported==="boolean"?e.isImageDecoderSupported:!Xs,D=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,N=typeof e.disableFontFace==="boolean"?e.disableFontFace:Xs,z=e.fontExtraProperties===!0,L=e.enableXfa===!0,ee=e.ownerDocument||globalThis.document,te=e.disableRange===!0,J=e.disableStream===!0,ae=e.disableAutoFetch===!0,Q=e.pdfBug===!0,Y=e.CanvasFactory||(Xs?fy:sy),$=e.FilterFactory||(Xs?ly:iy),fe=e.BinaryDataFactory||(Xs?ry:f8),P=e.enableHWA===!0,be=e.enableWebGPU===!0?Az():Promise.resolve(!1),me=e.useWasm!==!1,de=e.pagesMapper||new Dy,ye=typeof e.useSystemFonts==="boolean"?e.useSystemFonts:!Xs&&!N,xe=typeof e.useWorkerFetch==="boolean"?e.useWorkerFetch:!!(fe===f8&&d&&j&&S&&C&&Wh(d,document.baseURI)&&Wh(S,document.baseURI)&&Wh(C,document.baseURI)),Qe=null;az(g);let ht={canvasFactory:new Y({ownerDocument:ee,enableHWA:P}),filterFactory:new $({docId:a,ownerDocument:ee}),binaryDataFactory:xe?null:new fe({cMapUrl:d,standardFontDataUrl:S,wasmUrl:C})};if(!u)u=Hn.create({verbosity:g,port:nl.workerPort}),t._worker=u;let Oe={docId:a,apiVersion:"6.1.200",data:s,password:f,disableAutoFetch:ae,rangeChunkSize:h,docBaseUrl:b,enableXfa:L,evaluatorOptions:{maxImageSize:T,disableFontFace:N,ignoreErrors:O,isOffscreenCanvasSupported:M,isImageDecoderSupported:H,canvasMaxAreaInBytes:D,fontExtraProperties:z,useSystemFonts:ye,useWasm:me,useWorkerFetch:xe,cMapUrl:d,cMapPacked:j,iccUrl:A,standardFontDataUrl:S,wasmUrl:C,hasGPU:!1}},Ge={ownerDocument:ee,pdfBug:Q,styleElement:Qe,enableHWA:P,loadingParams:{disableAutoFetch:ae,enableXfa:L}};return Promise.all([u.promise,be]).then(function([,ft]){if(u.destroyed)throw Error("Worker was destroyed");Oe.evaluatorOptions.hasGPU=ft;let Ie=u.messageHandler.sendWithPromise("GetDocRequest",Oe,s?[s.buffer]:null),He;if(s);else if(c)He=new Ay({pdfDataRangeTransport:c,disableRange:te,disableStream:J});else if(n)He=new(Nz(n))({url:n,httpHeaders:i,withCredentials:l,rangeChunkSize:h,disableRange:te,disableStream:J});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return Ie.then((Ze)=>{if(u.destroyed)throw Error("Worker was destroyed");let Je=new H1(a,Ze,u.port),$e=new Ny(Je,t,He,Ge,ht,de);if(t._transport=$e,t.destroyed)throw Error("Loading aborted");Je.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}class A8{static#e=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${A8.#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 y8{#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){Rt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ry{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 lt(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 S8{#e=!1;#t=null;constructor(e,t,a,n,s=!1){this._pageIndex=e,this._pageInfo=t,this._transport=a,this._stats=s?new a8:null,this._pdfBug=s,this.commonObjs=a.commonObjs,this.objs=new v8,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#t=n,this.imageCoordinates=null}clone(e){let t=new S8(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 ru({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 lt(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=ff.ENABLE,transform:i=null,background:l=null,optionalContentConfigPromise:f=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:S,cacheKey:C}=A;this.#e=!1,f||=this._transport.getOptionalContentConfig(S);let O=this._intentStates.getOrInsertComputed(C,t8);if(O.streamReaderCancelTimeout)clearTimeout(O.streamReaderCancelTimeout),O.streamReaderCancelTimeout=null;let T=!!(S&Us.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),D=!!t&&!this.imageCoordinates&&b,N=(J)=>{if(O.renderTasks.delete(ee),H){let ae=ee.gfx?.dependencyTracker.take();if(ae){if(ee.stepper?.setOperatorBBoxes(ae,ee.gfx.dependencyTracker.takeDebugMetadata()),d)this.recordedBBoxes=ae}}if(D&&!J)this.imageCoordinates=ee.gfx?.imagesTracker.take();if(T)this.#e=!0;if(this.#a(),J)ee.capability.reject(J),this._abortOperatorList({intentState:O,reason:J instanceof Error?J:Error(J)});else ee.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,L=null;if(H||D)L=new VA(t,O.operatorList.length);if(H)z=new YA(L,M);let ee=new x1({callback:N,params:{canvas:t,canvasContext:e,dependencyTracker:z??L,imagesTracker:D?new c5(t):null,viewport:a,transform:i,background:l},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(ee);let te=ee.task;return Promise.all([O.displayReadyCapability.promise,f]).then(([J,ae])=>{if(this.destroyed){N();return}if(this._stats?.time("Rendering"),!(ae.renderingIntent&S))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");ee.initializeGraphics({transparency:J,optionalContentConfig:ae}),ee.operatorListChanged()}).catch(N),te}getOperatorList({intent:e="display",annotationMode:t=ff.ENABLE,printAnnotationStorage:a=null,isEditing:n=!1}={}){function s(){if(l.operatorList.lastChunk)l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(f)}let i=this._transport.getRenderingIntent(e,t,a,n,!0),l=this._intentStates.getOrInsertComputed(i.cacheKey,t8),f;if(!l.opListReadCapability)f=Object.create(null),f.operatorListChanged=s,l.opListReadCapability=Promise.withResolvers(),(l.renderTasks||=new Set).add(f),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(i);return l.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)=>au.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 a8;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,f=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=f;let h=()=>{f.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 q5){let n=Ez;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 sl(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 Hn{#e=Promise.withResolvers();#t=null;#a=null;#n=null;static#s=0;static#l=!1;static#i=new WeakMap;static{if(Xs)this.#l=!0,nl.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=nz()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=a,t){if(Hn.#i.has(t))throw Error("Cannot use more than one PDFWorker per port.");Hn.#i.set(t,this),this.#o(t)}else this.#r()}get promise(){return this.#e.promise}#f(){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 H1("main","worker",e),this.#t.on("ready",()=>{}),this.#f()}#r(){if(Hn.#l||Hn.#h){this.#u();return}let{workerSrc:e}=Hn;try{if(!Hn._isSameOrigin(window.location,e))e=Hn._createCDNWrapper(new URL(e,window.location).href);let t=new Worker(e,{type:"module"}),a=new H1("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",(l)=>{if(s.abort(),this.destroyed||!l){n();return}this.#t=a,this.#a=t,this.#n=t,this.#f()}),a.on("ready",(l)=>{if(s.abort(),this.destroyed){n();return}try{i()}catch{this.#u()}});let i=()=>{let l=new Uint8Array;a.send("test",l,[l.buffer])};i();return}catch{d5("The worker has been disabled.")}this.#u()}#u(){if(!Hn.#l)ct("Setting up fake worker."),Hn.#l=!0;Hn._setupFakeWorkerGlobal.then((e)=>{if(this.destroyed){this.#e.reject(Error("Worker was destroyed"));return}let t=new ny;this.#a=t;let a=`fake${Hn.#s++}`,n=new H1(a+"_worker",a,t);e.setup(n,t),this.#t=new H1(a,a+"_worker",t),this.#f()}).catch((e)=>{this.#e.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this.#n?.terminate(),this.#n=null,Hn.#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 Hn(e)}static get workerSrc(){if(nl.workerSrc)return nl.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#h(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return lt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#h)return this.#h;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class Ny{downloadInfoCapability=Promise.withResolvers();#e=null;#t=new Map;#a=null;#n=new Map;#s=new Map;#l=new Map;#i=null;constructor(e,t,a,n,s,i){this.messageHandler=e,this.loadingTask=t,this.#a=a,this.commonObjs=new v8,this.fontLoader=new JA({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))}#f(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?ha(Math.round(e/t*100),0,100):NaN})}get annotationStorage(){return lt(this,"annotationStorage",new A5)}getRenderingIntent(e,t=ff.ENABLE,a=null,n=!1,s=!1){let i=Us.DISPLAY,l=nu;switch(e){case"any":i=Us.ANY;break;case"display":break;case"print":i=Us.PRINT;break;default:ct(`getRenderingIntent - invalid intent: ${e}`)}let f=i&Us.PRINT&&a instanceof b8?a:this.annotationStorage;switch(t){case ff.DISABLE:i+=Us.ANNOTATIONS_DISABLE;break;case ff.ENABLE:break;case ff.ENABLE_FORMS:i+=Us.ANNOTATIONS_FORMS;break;case ff.ENABLE_STORAGE:i+=Us.ANNOTATIONS_STORAGE,l=f.serializable;break;default:ct(`getRenderingIntent - invalid annotationMode: ${t}`)}if(n)i+=Us.IS_EDITING;if(s)i+=Us.OPLIST;let{ids:c,hash:h}=f.modifiedIds,u=[i,l.hash,h];return{renderingIntent:i,cacheKey:u.join("_"),annotationStorageSerializable:l,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.#l.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(),Gs.cleanup(),this.#a?.cancelAllRequests(new sl("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)=>{Ca(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}Ca(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)=>{Ca(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:l}){if(l){n.close();return}Ca(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((l)=>{if(this.destroyed)return;throw l})}}),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 Ry(a,this))}),e.on("DocException",(a)=>{t._capability.reject(As(a))}),e.on("PasswordRequest",(a)=>{this.#i=Promise.withResolvers();try{if(!t.onPassword)throw As(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;ct(`Error during font loading: ${u}`),this.commonObjs.resolve(a,u);break}let i=new ey(s),l=this._params.pdfBug&&globalThis.FontInspector?.enabled?(u,g)=>globalThis.FontInspector.fontAdded(u,g):null,f=new QA(i,l,s.charProcOperatorList,s.extra);this.fontLoader.bind(f).catch(()=>e.sendWithPromise("FontFallback",{id:a})).finally(()=>{if(!f.fontExtraProperties)f.clearData();this.commonObjs.resolve(a,f)});break;case"CopyLocalImage":let{imageRef:c}=s;Ca(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 ay(s));break;case"Image":this.commonObjs.resolve(a,s);break;case"Pattern":let h=new ty(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 l=this.#n.get(n);if(l.objs.has(a))return;if(l._intentStates.size===0){i?.bitmap?.close();return}switch(s){case"Image":case"Pattern":l.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)ct("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 l=this.pagesMapper.getMapping();if(l){let f=new Map;for(let[c,h]of i){if(h?.pageIndex!==void 0&&h.pageIndex>=0&&h.pageIndex<l.length){let u=l[h.pageIndex]-1;if(u!==h.pageIndex){f.set(c,{...h,pageIndex:u});continue}}f.set(c,h)}i=f}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.#l.set(i.refStr,a);let l=new S8(t,i,this,this.pagesMapper,this._params.pdfBug);return this.#n.set(t,l),l});return this.#s.set(t,s),s}async getPageIndex(e){if(!l8(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.#f("GetFieldObjects")}hasJSActions(){return this.#f("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.#f("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.#f("GetOptionalContentConfig").then((t)=>new q8(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 Hy(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),Gs.cleanup()}cachedPageNumber(e){if(!l8(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`,a=this.#l.get(t);if(a>=0){let n=this.pagesMapper.getPageNumber(a+1);if(n!==0)return n}return null}}class zy{_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 x1{#e=null;static#t=new WeakSet;constructor({callback:e,params:t,objs:a,commonObjs:n,annotationCanvasMap:s,operatorList:i,pageIndex:l,canvasFactory:f,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=l,this.canvasFactory=f,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 zy(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(x1.#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.");x1.#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:l}=this.params,f=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new D1(f,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,i,l),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;x1.#t.delete(this._canvas),e||=new q5(`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(),x1.#t.delete(this._canvas),this.callback()}}}var Iz="6.1.200",Uz="6353acefe";class bi{#e=null;#t=null;#a;#n=null;#s=!1;#l=!1;#i=null;#f;#o=null;#r=null;static#u=null;static get _keyboardManager(){return lt(this,"_keyboardManager",new Ks([[["Escape"],bi.prototype._hideDropdownFromKeyboard],[["Space"],bi.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],bi.prototype._moveToNext],[["ArrowUp","ArrowLeft"],bi.prototype._moveToPrevious],[["Home"],bi.prototype._moveToBeginning],[["End"],bi.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){if(e)this.#l=!1,this.#i=e;else this.#l=!0;this.#r=e?._uiManager||t,this.#f=this.#r._eventBus,this.#a=e?.color?.toUpperCase()||this.#r?.highlightColors.values().next().value||"#FFFF98",bi.#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",wi,{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",bi.#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.#f.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){bi._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.#l)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 iu{#e=null;#t=!1;#a=null;#n=null;static#s=null;constructor(e){this.#a=e,this.#n=e._uiManager,iu.#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,l=this.#t=Zt.isAlphaColorInputSupported&&n!==void 0,f=this.#e=document.createElement("input");if(f.type="color",l){f.setAttribute("alpha","");let c=Be.hexNums[Math.round((i??1)*255)];f.value=(s||"#000000")+c}else f.value=s||"#000000";return f.className="basicColorPicker",f.tabIndex=0,f.setAttribute("data-l10n-id",iu.#s[e]),f.addEventListener("input",()=>{if(l){let c=ou(f.value);if(!c)return;let[h,u,g,b]=c,d=Be.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,f.value)},{signal:this.#n._signal}),f}update(e){if(!this.#e)return;if(this.#t){let t=Be.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=Be.hexNums[Math.round(e*255)];this.#e.value=this.#a.color+t}destroy(){this.#e?.remove(),this.#e=null}hideDropdown(){}}function BA(e){return Math.floor(ha(e,0,1)*255).toString(16).padStart(2,"0")}function Qh(e){return ha(e,0,1)*255}class o8{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=Qh(e),[e,e,e]}static G_HTML([e]){let t=BA(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(Qh)}static RGB_HTML(e){return`#${e.map(BA).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[Qh(1-Math.min(1,e+n)),Qh(1-Math.min(1,a+n)),Qh(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,l=Math.min(n,s,i);return["CMYK",n,s,i,l]}}class Ey{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){Rt("Abstract method `_createSVG` called.")}}class lu extends Ey{_createSVG(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}}var Gz=9,Tr=new WeakSet,Xz=new Date().getTimezoneOffset()*60*1000;class i5{static create(e){switch(e.data.annotationType){case xa.LINK:return new B5(e);case xa.TEXT:return new Uy(e);case xa.WIDGET:switch(e.data.fieldType){case"Tx":return new Gy(e);case"Btn":if(e.data.radioButton)return new Ly(e);else if(e.data.checkBox)return new Ky(e);return new Vy(e);case"Ch":return new Yy(e);case"Sig":return new Xy(e)}return new of(e);case xa.POPUP:return new h5(e);case xa.FREETEXT:return new C8(e);case xa.LINE:return new Qy(e);case xa.SQUARE:return new Zy(e);case xa.CIRCLE:return new $y(e);case xa.POLYLINE:return new _8(e);case xa.CARET:return new Py(e);case xa.INK:return new T5(e);case xa.POLYGON:return new Wy(e);case xa.HIGHLIGHT:return new F8(e);case xa.UNDERLINE:return new eS(e);case xa.SQUIGGLY:return new tS(e);case xa.STRIKEOUT:return new aS(e);case xa.STAMP:return new O8(e);case xa.FILEATTACHMENT:return new nS(e);case xa.RICHMEDIA:case xa.SCREEN:return new B8(e);default:return new pa(e)}}}class pa{#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 pa._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 l=0;l<t.length;l+=8)if(t[l+1]>i)i=t[l+1],s=t[l+2];else if(t[l+1]===i)s=Math.max(s,t[l+2]);return[s,i]}if(a?.length>=1){for(let l of a)for(let f=0,c=l.length;f<c;f+=2)if(l[f+1]>i)i=l[f+1],s=l[f];else if(l[f+1]===i)s=Math.max(s,l[f]);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:l,pageY:f}}}}=this;if(a?.splice(0,4,...e),t.left=`${100*(e[0]-l)/s}%`,t.top=`${100*(i-e[3]+f)/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 of)&&!(this instanceof B5)&&!(this instanceof B8))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 h5){let{rotation:j}=t;if(!t.hasOwnCanvas&&j!==0)this.setRotation(j,s);return s}let{width:l,height:f}=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 C=`calc(${j}px * var(--total-scale-factor)) / calc(${A}px * var(--total-scale-factor))`;i.borderRadius=C}switch(t.borderStyle.style){case T1.SOLID:i.borderStyle="solid";break;case T1.DASHED:i.borderStyle="dashed";break;case T1.BEVELED:ct("Unimplemented border style: beveled");break;case T1.INSET:ct("Unimplemented border style: inset");break;case T1.UNDERLINE:i.borderBottomStyle="solid";break;default:break}let S=t.borderColor||null;if(S)this.#t=!0,i.borderColor=Be.makeHexColor(...S);else i.borderWidth=0}let c=Be.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*l/h}%`,i.height=`${100*f/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],l=s.slice(1);n.target.style[a]=o8[`${i}_HTML`](l),this.annotationStorage.setValue(this.data.id,{[a]:o8[`${i}_rgb`](l)})};return lt(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 l={detail:{[n]:s},target:e};i(l),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,S,C]=e.subarray(2,6);if(n===j&&s===A&&t===S&&a===C)return}let{style:i}=this.container,l;if(this.#t){let{borderColor:j,borderWidth:A}=i;i.borderWidth=0,l=["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 f=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 S=e[j],C=e[j+1],O=e[j+2],T=e[j+3],M=h.createElement("rect"),H=(O-t)/f,D=(s-C)/c,N=(S-O)/f,z=(C-T)/c;M.setAttribute("x",H),M.setAttribute("y",D),M.setAttribute("width",N),M.setAttribute("height",z),b.append(M),l?.push(`<rect vector-effect="non-scaling-stroke" x="${H}" y="${D}" width="${N}" height="${z}"/>`)}if(this.#t)l.push("</g></svg>')"),i.backgroundImage=l.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 h5({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(){Rt("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:l}of n){if(s===-1)continue;if(i===t)continue;let f=typeof l==="string"?l:null,c=document.querySelector(`[data-element-id="${i}"]`);if(c&&!Tr.has(c)){ct(`_getElementsByName - element not allowed: ${i}`);continue}a.push({id:i,exportValue:f,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(!Tr.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":Be.makeHexColor(...t)}}class Iy extends pa{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 B5 extends pa{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 l=await this.linkService.getAttachmentContent(t);if(l)this.downloadManager?.openOrDownloadData(l,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(ct('_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,l=[];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)l.push(g)}else for(let h of Object.values(this._fieldObjects))l.push(...h);let f=this.annotationStorage,c=[];for(let h of l){let{id:u}=h;switch(c.push(u),h.type){case"text":{let b=h.defaultValue||"";f.setValue(u,{value:b});break}case"checkbox":case"radiobutton":{let b=h.defaultValue===h.exportValues;f.setValue(u,{value:b});break}case"combobox":case"listbox":{let b=h.defaultValue||"";f.setValue(u,{value:b});break}default:continue}let g=document.querySelector(`[data-element-id="${u}"]`);if(!g)continue;else if(!Tr.has(g)){ct(`_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 Uy extends pa{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 of extends pa{render(){return this.container}_getKeyModifier(e){return Zt.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||Gz,s=e.style,i,l=2,f=(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,f(u/1.35))}else{let c=Math.abs(this.data.rect[3]-this.data.rect[1]-2);i=Math.min(n,f(c/1.35))}if(s.fontSize=`calc(${i}px * var(--total-scale-factor))`,s.color=Be.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 Gy extends of{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 l=n.formattedValue||this.data.textContent?.join(`
297
- `)||null;if(l&&this.data.comb)l=l.replaceAll(/\s+/g,"");let f={userValue:s,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){if(a=document.createElement("textarea"),a.textContent=l??s,this.data.doNotScroll)a.style.overflowY="hidden"}else if(a=document.createElement("input"),a.type=this.data.password?"password":"text",a.setAttribute("value",l??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")}Tr.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"),f.formattedValue=null}),a.addEventListener("resetform",(d)=>{let j=this.data.defaultFieldValue??"";a.value=f.userValue=j,f.formattedValue=null});let b=(d)=>{let{formattedValue:j}=f;if(j!==null&&j!==void 0)d.target.value=j;d.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){a.addEventListener("focus",(j)=>{if(f.focused)return;let{target:A}=j;if(g){if(A.type=h,u)A.step=u}if(f.userValue){let S=f.userValue;if(g)if(h==="time"){let C=new Date(S),O=[C.getHours(),C.getMinutes(),C.getSeconds()];A.value=O.map((T)=>T.toString().padStart(2,"0")).join(":")}else A.value=new Date(S-Xz).toISOString().split(h==="date"?"T":".",1)[0];else A.value=S}if(f.lastCommittedValue=A.value,f.commitKey=1,!this.data.actions?.Focus)f.focused=!0}),a.addEventListener("updatefromsandbox",(j)=>{this.container.classList.add("sandboxModified");let A={value(S){if(f.userValue=S.detail.value??"",!g)e.setValue(t,{value:f.userValue.toString()});S.target.value=f.userValue},formattedValue(S){let{formattedValue:C}=S.detail;if(f.formattedValue=C,C!==null&&C!==void 0&&S.target!==document.activeElement)S.target.value=C;let O={formattedValue:C};if(g)O.value=C;e.setValue(t,O)},selRange(S){S.target.setSelectionRange(...S.detail.selRange)},charLimit:(S)=>{let{charLimit:C}=S.detail,{target:O}=S;if(C===0){O.removeAttribute("maxLength");return}O.setAttribute("maxLength",C);let T=f.userValue;if(!T||T.length<=C)return;T=T.slice(0,C),O.value=f.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)=>{f.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")f.commitKey=3;if(A===-1)return;let{value:S}=j.target;if(f.lastCommittedValue===S)return;f.lastCommittedValue=S,f.userValue=S,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:S,willCommit:!0,commitKey:A,selStart:j.target.selectionStart,selEnd:j.target.selectionEnd}})});let d=b;if(b=null,a.addEventListener("blur",(j)=>{if(!f.focused||!j.relatedTarget)return;if(!this.data.actions?.Blur)f.focused=!1;let{target:A}=j,{value:S}=A;if(g){if(S&&h==="time"){let C=S.split(":").map((O)=>parseInt(O,10));S=new Date(2000,0,1,C[0],C[1],C[2]||0).valueOf(),A.step=""}else{if(!S.includes("T"))S=`${S}T00:00`;S=new Date(S).valueOf()}A.type="text"}if(f.userValue=S,f.lastCommittedValue!==S)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:S,willCommit:!0,commitKey:f.commitKey,selStart:j.target.selectionStart,selEnd:j.target.selectionEnd}});d(j)}),this.data.actions?.Keystroke)a.addEventListener("beforeinput",(j)=>{f.lastCommittedValue=null;let{data:A,target:S}=j,{value:C,selectionStart:O,selectionEnd:T}=S,M=O,H=T;switch(j.inputType){case"deleteWordBackward":{let D=C.substring(0,O).match(/\w*\W*$/);if(D)M-=D[0].length;break}case"deleteWordForward":{let D=C.substring(O).match(/^\W*\w*/);if(D)H+=D[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:C,change:A||"",willCommit:!1,selStart:M,selEnd:H}})});this._setEventListeners(a,f,[["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 S=()=>{let C=i-a.value.length;a.style.setProperty("--comb-offset",`${A===1?C>>1:C}`)};S();for(let C of["input","blur","resetform","updatefromsandbox"])a.addEventListener(C,S)}}}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 Xy extends of{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class Ky extends of{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(Tr.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:l,checked:f}=i.target;for(let c of this._getElementsByName(l,a)){let h=f&&c.exportValue===t.exportValue;if(c.domElement)c.domElement.checked=h;e.setValue(c.id,{value:h})}e.setValue(a,{value:f})}),s.addEventListener("resetform",(i)=>{let l=t.defaultFieldValue||"Off";i.target.checked=l===t.exportValue}),this.enableScripting&&this.hasJSActions)s.addEventListener("updatefromsandbox",(i)=>{let l={value(f){f.target.checked=f.detail.value!=="Off",e.setValue(a,{value:f.target.checked})}};this._dispatchEventFromSandbox(l,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 Ly extends of{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(Tr.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:l,checked:f}=i.target;for(let c of this._getElementsByName(l,a))e.setValue(c.id,{value:!1});e.setValue(a,{value:f})}),s.addEventListener("resetform",(i)=>{let l=t.defaultFieldValue;i.target.checked=l!==null&&l!==void 0&&l===t.buttonValue}),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;s.addEventListener("updatefromsandbox",(l)=>{let f={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(f,l)}),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(l)=>l.target.checked)}return this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Vy extends B5{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 Yy extends of{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");Tr.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 l=null;if(s){let u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),n.prepend(u),l=()=>{u.remove(),n.removeEventListener("input",l),l=null},n.addEventListener("input",l)}let f=(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=f(!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){l?.();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:f(!0)}),c=f(!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,(S)=>S.selected)===-1)d[0].selected=!0}e.setValue(t,{value:f(!0),items:h(b)}),c=f(!1)},clear(b){while(n.length!==0)n.remove(0);e.setValue(t,{value:null,items:[]}),c=f(!1)},insert(b){let{index:d,displayValue:j,exportValue:A}=b.detail.insert,S=n.children[d],C=document.createElement("option");if(i(C,j),C.value=A,S)S.before(C);else n.append(C);e.setValue(t,{value:f(!0),items:h(b)}),c=f(!1)},items(b){let{items:d}=b.detail;while(n.length!==0)n.remove(0);for(let j of d){let{displayValue:A,exportValue:S}=j,C=document.createElement("option");i(C,A),C.value=S,n.append(C)}if(n.options.length>0)n.options[0].selected=!0;e.setValue(t,{value:f(!0),items:h(b)}),c=f(!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:f(!0)}),c=f(!1)},editable(b){b.target.disabled=!b.detail.editable}};this._dispatchEventFromSandbox(g,u)}),n.addEventListener("input",(u)=>{let g=f(!0),b=f(!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:f(!0)})});if(this.data.combo)this._setTextStyle(n);return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class h5 extends pa{constructor(e){let{data:t,elements:a,parent:n}=e,s=!!n._commentManager;super(e,{isRenderable:!s&&pa._hasPopupData(t)});if(this.elements=a,s&&pa._hasPopupData(t)){let i=this.popup=this.#e();for(let l of a)l.popup=i}else this.popup=null}#e(){return new Jy({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 Jy{#e=null;#t=this.#E.bind(this);#a=this.#R.bind(this);#n=this.#v.bind(this);#s=this.#C.bind(this);#l=null;#i=null;#f=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:l,parent:f,rect:c,parentRect:h,open:u,commentManager:g=null}){if(this.#i=e,this.#y=n,this.#f=i,this.#A=l,this.#u=f,this.#l=t,this.#w=c,this.#h=h,this.#r=a,this.#e=g,this.#k=a[0],this.#o=r5.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 l=this.#k.container;i.style.zIndex=parseInt(l.style.zIndex,10)+1,i.tabIndex=0,i.ariaHasPopup="dialog",i.ariaControls="commentPopup",i.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#H(),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}),l.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))`}#H(){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:l}=this.#k.layer.getBoundingClientRect();return[(e-n)/i,(t+a-s)/l]}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:l,height:f}=n;this.#e.showDialog(null,this,s+t*l,i+a*f,{...e,parentDimensions:n})}render(){if(this.#b)return;let e=this.#b=document.createElement("div");if(e.className="popup",this.#l){let a=e.style.outlineColor=Be.makeHexColor(...this.#l);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)}zA({html:this.#x||this.#f.str,dir:this.#f?.dir,className:"popupContent"},e),this.#i.append(e)}get#x(){let e=this.#A,t=this.#f;if(e?.str&&(!t?.str||t.str===e.str))return this.#A.html||null;return null}get#M(){return this.#x?.attributes?.style?.fontSize||0}get#D(){return this.#x?.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.#D,fontSize:this.#M?`calc(${this.#M}px * var(--total-scale-factor))`:""}};for(let s of e.split(`
298
- `))t.push({name:"span",value:s,attributes:n});return a}#E(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.#H(),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.#f,richText:this.#A},e)this.#c=null;if(t&&t.text)this.#A=this.#N(t.text),this.#o=r5.toDateObject(t.date),this.#f=null;this.#b?.remove(),this.#b=null}resetEdited(){if(!this.#q)return;({contentsObj:this.#f,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,l=i?this.#h:this.#w;for(let d of this.#r)if(!l||Be.intersect(d.data.rect,l)!==null){l=d.data.rect,i=!0;break}let f=Be.normalizeRect([l[0],e[3]-l[1]+e[1],l[2],e[3]-l[3]+e[1]]),c=5,h=i?l[2]-l[0]+c:0,u=f[0]+h,g=f[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 C8 extends pa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=ot.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 Qy extends pa{#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 Zy extends pa{#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 $y extends pa{#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 _8 extends pa{#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 l=this.svgFactory.create(s,i,!0),f=[];for(let h=0,u=t.length;h<u;h+=2){let g=t[h]-e[0],b=e[3]-t[h+1];f.push(`${g},${b}`)}f=f.join(" ");let c=this.#e=this.svgFactory.createElement(this.svgElementName);if(c.setAttribute("points",f),c.setAttribute("stroke-width",a.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!n&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Wy extends _8{constructor(e){super(e);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Py extends pa{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 T5 extends pa{#e=null;#t=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?ot.HIGHLIGHT:ot.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:l,height:f}=this.#a(t,e),c=this.svgFactory.create(l,f,!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,l=this.#t.length;i<l;i++)this.#t[i].setAttribute("points",a[i].join(","));if(n){let{transform:i,width:l,height:f}=this.#a(this.data.rotation,n);s.parentElement.setAttribute("viewBox",`0 0 ${l} ${f}`),s.setAttribute("transform",i)}}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class F8 extends pa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=ot.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 eS extends pa{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 tS extends pa{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 aS extends pa{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 O8 extends pa{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=ot.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 nS extends pa{#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}=Zt.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 B8 extends pa{#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,l=URL.createObjectURL(new Blob([s],{type:n}));this.#t=l;let f=n.startsWith("audio/"),c=document.createElement(f?"audio":"video");if(this.#a=c,c.className="mediaContent",this._setBackgroundColor(c),c.src=l,c.title=a,c.controls=!0,c.autoplay=!0,c.tabIndex=0,f){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(l),{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 T8{#e=null;#t=null;#a=null;#n=new Map;#s=null;#l=null;#i=[];#f=!1;zIndex=0;constructor({div:e,accessibilityManager:t,annotationCanvasMap:a,annotationEditorUIManager:n,page:s,viewport:i,structTreeLayer:l,commentManager:f,linkService:c,annotationStorage:h}){this.div=e,this.#e=t,this.#t=a,this.#s=l||null,this.#l=c||null,this.#a=h||new A5,this.page=s,this.viewport=i,this._annotationEditorUIManager=n,this._commentManager=f||null}hasEditableAnnotations(){return this.#n.size>0}async render(e){let{annotations:t,optionalContentConfig:a}=e,n=this.div;Br(n,this.viewport);let s=new Map,i=[],l={data:null,layer:n,linkService:this.#l,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new lu,annotationStorage:this.#a,enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let f of t){if(f.noHTML)continue;let c=f.annotationType===xa.POPUP;if(!c){if(f.rect[2]===f.rect[0]||f.rect[3]===f.rect[1])continue}else{let g=s.get(f.id);if(!g)continue;if(!this._commentManager){i.push(f);continue}l.elements=g}l.data=f;let h=i5.create(l);if(!h.isRenderable)continue;if(!c){if(this.#i.push(h),f.popupRef)s.getOrInsertComputed(f.popupRef,fu).push(h)}let u=h.render();if(f.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 f of i){let c=l.elements=s.get(f.id);l.data=f;let h=i5.create(l);if(!h.isRenderable)continue;let u=h.render();if(h.contentElement.id=`pdfjs_internal_id_${f.id}`,f.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.#f){this.#f=!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[l,f]of i)a.setAttribute(l,f)}))}}this.#i.sort(({data:{rect:[a,n,s,i]}},{data:{rect:[l,f,c,h]}})=>{if(a===s&&n===i)return 1;if(l===c&&f===h)return-1;let u=i,g=n,b=(n+i)/2,d=h,j=f,A=(f+h)/2;if(b>=d&&A<=g)return-1;if(A>=u&&b<=j)return 1;let S=(a+s)/2,C=(l+c)/2;return S-C});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.#l,svgFactory:new lu,parent:this};for(let a of e){a.borderStyle||=T8._defaultBorderStyle,t.data=a;let n=i5.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,Br(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:l}=n;if(!l)n.append(i);else if(!l.classList.contains("annotationContent"))l.before(i);else l.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 f=this.#n.get(t);if(!f)continue;if(f._hasNoCanvas)this._annotationEditorUIManager?.setMissingCanvas(t,n.id,a),f._hasNoCanvas=!1;else f.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 Iy({data:{id:a,rect:e.getPDFRect(),rotation:n},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:this.#l,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 lt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:T1.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}var W9=/\r\n?|\n/g;class vn extends Ye{#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=vn.prototype,t=(s)=>s.isEmpty(),a=rf.TRANSLATE_SMALL,n=rf.TRANSLATE_BIG;return lt(this,"_keyboardManager",new Ks([[["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=ot.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"});if(this.color=e.color||vn._defaultColor||Ye._defaultLineColor,this.#n=e.fontSize||vn._defaultFontSize,!this.annotationElementId)this._uiManager.a11yAlert(Ye._l10nAlert.freetext);this.canAddComment=!1}static initialize(e,t){Ye.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:vn._defaultFontSize=t;break;case bt.FREETEXT_COLOR:vn._defaultColor=t;break}}updateParams(e,t){switch(e){case bt.FREETEXT_SIZE:this.#s(t);break;case bt.FREETEXT_COLOR:this.#l(t);break}}static get defaultPropertiesToUpdate(){return[[bt.FREETEXT_SIZE,vn._defaultFontSize],[bt.FREETEXT_COLOR,vn._defaultColor||Ye._defaultLineColor]]}get propertiesToUpdate(){return[[bt.FREETEXT_SIZE,this.#n],[bt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new iu(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.#f()},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()}#l(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[-vn._internalPadding*e,-(vn._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(vn.#o(a)),t=a}return e.join(`
299
- `)}#f(){let[e,t]=this.parentDimensions,a;if(this.isAttachedToDOM)a=this.div.getBoundingClientRect();else{let{currentLayer:n,div:s}=this,i=s.style.display,l=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",l)}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.#f()};this.addCommands({cmd:()=>{a(t)},undo:()=>{a(e)},mustExec:!1}),this.#f()}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){vn._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,[l,f]=this.getInitialTranslation();[l,f]=this.pageTranslationToScreen(l,f);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,[l,f]=[f,-l];break;case 180:b=e-this.width+(i[0]-u)/c,d=t-(i[1]-g)/h,[l,f]=[-l,-f];break;case 270:b=e+(i[0]-u-this.height*h)/c,d=t+(i[1]-g-this.width*c)/h,[l,f]=[-f,l];break}this.setAt(b*n,d*s,l,f)}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(W9,"")}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:a}=t;if(a.length===1&&a[0]==="text/plain")return;e.preventDefault();let n=vn.#h(t.getData("text")||"").replaceAll(W9,`
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:l,startOffset:f}=i,c=[],h=[];if(l.nodeType===Node.TEXT_NODE){let b=l.parentElement;if(h.push(l.nodeValue.slice(f).replaceAll(W9,"")),b!==this.editorDiv){let d=c;for(let j of this.editorDiv.childNodes){if(j===b){d=h;continue}d.push(vn.#o(j))}}c.push(l.nodeValue.slice(0,f).replaceAll(W9,""))}else if(l===this.editorDiv){let b=c,d=0;for(let j of this.editorDiv.childNodes){if(d++===f)b=h;b.push(vn.#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=vn._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,a){let n=null;if(e instanceof C8){let{data:{defaultAppearanceData:{fontSize:i,fontColor:l},rect:f,rotation:c,id:h,popupRef:u,richText:g,contentsObj:b,creationDate:d,modificationDate:j},textContent:A,textPosition:S,parent:{page:{pageNumber:C}}}=e;if(!A?.length)return null;n=e={annotationType:ot.FREETEXT,color:Array.from(l),fontSize:i,value:A.join(`
305
- `),position:S,pageIndex:C-1,rect:f.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=Be.makeHexColor(...e.color),s.#e=vn.#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=Ye._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,l)=>i!==n[l])||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(){Rt("Abstract method `toSVGPath` must be implemented.")}get box(){Rt("Abstract getter `box` must be implemented.")}serialize(e,t){Rt("Abstract method `serialize` must be implemented.")}static _rescale(e,t,a,n,s,i){i||=new Float32Array(e.length);for(let l=0,f=e.length;l<f;l+=2)i[l]=t+e[l]*n,i[l+1]=a+e[l+1]*s;return i}static _rescaleAndSwap(e,t,a,n,s,i){i||=new Float32Array(e.length);for(let l=0,f=e.length;l<f;l+=2)i[l]=t+e[l+1]*n,i[l+1]=a+e[l]*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 Fr{#e;#t=[];#a;#n;#s=[];#l=new Float32Array(18);#i;#f;#o;#r;#u;#h;#g=[];static#b=8;static#p=2;static#c=Fr.#b+Fr.#p;constructor({x:e,y:t},a,n,s,i,l=0){this.#e=a,this.#h=s*n,this.#n=i,this.#l.set([NaN,NaN,NaN,NaN,e,t],6),this.#a=l,this.#r=Fr.#b*n,this.#o=Fr.#c*n,this.#u=n,this.#g.push(e,t)}isEmpty(){return isNaN(this.#l[8])}#m(){let e=this.#l.subarray(4,6),t=this.#l.subarray(16,18),[a,n,s,i]=this.#e;return[(this.#i+(e[0]-t[0])/2-a)/s,(this.#f+(e[1]-t[1])/2-n)/i,(this.#i+(t[0]-e[0])/2-a)/s,(this.#f+(t[1]-e[1])/2-n)/i]}add({x:e,y:t}){this.#i=e,this.#f=t;let[a,n,s,i]=this.#e,[l,f,c,h]=this.#l.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,S=j*g,C=l,O=f;l=c,f=h,c+=A,h+=S,this.#g?.push(e,t);let T=-S/d,M=A/d,H=T*this.#h,D=M*this.#h;if(this.#l.set(this.#l.subarray(2,8),0),this.#l.set([c+H,h+D],4),this.#l.set(this.#l.subarray(14,18),12),this.#l.set([c-H,h-D],16),isNaN(this.#l[6])){if(this.#s.length===0)this.#l.set([l+H,f+D],2),this.#s.push(NaN,NaN,NaN,NaN,(l+H-a)/s,(f+D-n)/i),this.#l.set([l-H,f-D],14),this.#t.push(NaN,NaN,NaN,NaN,(l-H-a)/s,(f-D-n)/i);return this.#l.set([C,O,l,f,c,h],6),!this.isEmpty()}if(this.#l.set([C,O,l,f,c,h],6),Math.abs(Math.atan2(O-f,C-l)-Math.atan2(S,A))<Math.PI/2)return[l,f,c,h]=this.#l.subarray(2,6),this.#s.push(NaN,NaN,NaN,NaN,((l+c)/2-a)/s,((f+h)/2-n)/i),[l,f,C,O]=this.#l.subarray(14,18),this.#t.push(NaN,NaN,NaN,NaN,((C+l)/2-a)/s,((O+f)/2-n)/i),!0;return[C,O,l,f,c,h]=this.#l.subarray(0,6),this.#s.push(((C+5*l)/6-a)/s,((O+5*f)/6-n)/i,((5*l+c)/6-a)/s,((5*f+h)/6-n)/i,((l+c)/2-a)/s,((f+h)/2-n)/i),[c,h,l,f,C,O]=this.#l.subarray(12,18),this.#t.push(((C+5*l)/6-a)/s,((O+5*f)/6-n)/i,((5*l+c)/6-a)/s,((5*f+h)/6-n)/i,((l+c)/2-a)/s,((f+h)/2-n)/i),!0}toSVGPath(){if(this.isEmpty())return"";let e=this.#s,t=this.#t;if(isNaN(this.#l[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,l,f]=this.#m();return`M${(this.#l[2]-e)/a} ${(this.#l[3]-t)/n} L${(this.#l[4]-e)/a} ${(this.#l[5]-t)/n} L${s} ${i} L${l} ${f} L${(this.#l[16]-e)/a} ${(this.#l[17]-t)/n} L${(this.#l[14]-e)/a} ${(this.#l[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.#l.subarray(4,6),l=this.#l.subarray(16,18),[f,c,h,u]=this.#m();e.push(`L${(i[0]-t)/n} ${(i[1]-a)/s} L${f} ${c} L${h} ${u} L${(l[0]-t)/n} ${(l[1]-a)/s}`)}newFreeDrawOutline(e,t,a,n,s,i){return new M8(e,t,a,n,s,i)}getOutlines(){let e=this.#s,t=this.#t,a=this.#l,[n,s,i,l]=this.#e,f=new Float32Array((this.#g?.length??0)+2);for(let u=0,g=f.length-2;u<g;u+=2)f[u]=(this.#g[u]-n)/i,f[u+1]=(this.#g[u+1]-s)/l;if(f[f.length-2]=(this.#i-n)/i,f[f.length-1]=(this.#f-s)/l,isNaN(a[6])&&!this.isEmpty())return this.#A(f);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,f,this.#e,this.#u,this.#a,this.#n)}#A(e){let t=this.#l,[a,n,s,i]=this.#e,[l,f,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,l,f,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.#l.subarray(4,6),n=this.#l.subarray(16,18),[s,i,l,f]=this.#e,[c,h,u,g]=this.#m();return e.set([NaN,NaN,NaN,NaN,(a[0]-s)/l,(a[1]-i)/f,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,u,g,NaN,NaN,NaN,NaN,(n[0]-s)/l,(n[1]-i)/f],t),t+=24}}class M8 extends Ee{#e;#t=new Float32Array(4);#a;#n;#s;#l;#i;constructor(e,t,a,n,s,i){super();this.#i=e,this.#s=t,this.#e=a,this.#l=n,this.#a=s,this.#n=i,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#f(i);let[l,f,c,h]=this.#t;for(let u=0,g=e.length;u<g;u+=2)e[u]=(e[u]-l)/c,e[u+1]=(e[u+1]-f)/h;for(let u=0,g=t.length;u<g;u+=2)t[u]=(t[u]-l)/c,t[u+1]=(t[u+1]-f)/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,l=n-t,f,c;switch(s){case 0:f=Ee._rescale(this.#i,e,n,i,-l),c=Ee._rescale(this.#s,e,n,i,-l);break;case 90:f=Ee._rescaleAndSwap(this.#i,e,t,i,l),c=Ee._rescaleAndSwap(this.#s,e,t,i,l);break;case 180:f=Ee._rescale(this.#i,a,t,-i,l),c=Ee._rescale(this.#s,a,t,-i,l);break;case 270:f=Ee._rescaleAndSwap(this.#i,a,n,-i,-l),c=Ee._rescaleAndSwap(this.#s,a,n,-i,-l);break}return{outline:Array.from(f),points:[Array.from(c)]}}#f(e){let t=this.#i,a=t[4],n=t[5],s=[a,n,a,n],i=a,l=n,f=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(Be.pointBoundingBox(j,A,s),l>A)i=j,l=A;else if(l===A)i=h(i,j);if(c<A)f=j,c=A;else if(c===A)f=h(f,j)}else{if(u.set(al,0),Be.bezierBoundingBox(a,n,...t.slice(b,b+6),u),Be.rectBoundingBox(...u,s),l>u[1])i=u[0],l=u[1];else if(l===u[1])i=h(i,u[0]);if(c<u[3])f=u[2],c=u[3];else if(c===u[3])f=h(f,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,l],this.lastPoint=[f,c]}get box(){return this.#t}newOutliner(e,t,a,n,s,i=0){return new Fr(e,t,a,n,s,i)}getNewOutline(e,t){let[a,n,s,i]=this.#t,[l,f,c,h]=this.#e,u=s*c,g=i*h,b=a*c+l,d=n*h+f,j=this.newOutliner({x:this.#s[0]*u+b,y:this.#s[1]*g+d},this.#e,this.#l,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 u5{#e;#t;#a;#n=[];#s=[];constructor(e,t=0,a=0,n=!0){let s=al.slice(),i=4,l=0.0001;for(let{x:A,y:S,width:C,height:O}of e){let T=Math.floor((A-t)/0.0001)*0.0001,M=Math.ceil((A+C+t)/0.0001)*0.0001,H=Math.floor((S-t)/0.0001)*0.0001,D=Math.ceil((S+O+t)/0.0001)*0.0001,N=[T,H,D,!0],z=[M,H,D,!1];this.#n.push(N,z),Be.rectBoundingBox(T,H,M,D,s)}let f=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[S,C,O,T]=A;if(!T&&n){if(C<b)b=C,g=S;else if(C===b)g=Math.max(g,S)}else if(T&&!n){if(C<b)b=C,g=S;else if(C===b)g=Math.min(g,S)}A[0]=(S-h)/f,A[1]=(C-u)/c,A[2]=(O-u)/c}this.#e=new Float32Array([h,u,f,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.#f(t);else this.#o(t),e.push(...this.#r(t));return this.#l(e)}#l(e){let t=[],a=new Set;for(let i of e){let[l,f,c]=i;t.push([l,f,i],[l,c,i])}t.sort((i,l)=>i[1]-l[1]||i[0]-l[0]);for(let i=0,l=t.length;i<l;i+=2){let f=t[i][2],c=t[i+1][2];f.push(c),c.push(f),a.add(f),a.add(c)}let n=[],s;while(a.size>0){let i=a.values().next().value,[l,f,c,h,u]=i;a.delete(i);let g=l,b=f;s=[l,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),[l,f,c,h,u]=d,g!==l)s.push(g,b,l,b===f?f:c),g=l;b=b===f?c:f}s.push(g,b)}return new sS(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}#f([,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 l=0;l<i;l++){let[f,c]=this.#s[l];for(let h=0,u=s.length;h<u;h++){let[,g,b]=s[h];if(c<=g||b<=f)continue;if(g>=f){if(b>c)s[h][1]=c;else{if(u===1)return[];s.splice(h,1),h--,u--}continue}if(s[h][2]=f,b>c)s.push([t,c,b])}}return s}}class sS 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],l=t[s+1];if(i===a)e.push(`V${l}`),n=l;else if(l===n)e.push(`H${i}`),a=i}e.push("Z")}return e.join(" ")}serialize([e,t,a,n],s){let i=[],l=a-e,f=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]*l,h[u+1]=n-c[u+1]*f;i.push(h)}return i}get box(){return this.#e}}class m5 extends Fr{newFreeDrawOutline(e,t,a,n,s,i){return new iS(e,t,a,n,s,i)}}class iS extends M8{newOutliner(e,t,a,n,s,i=0){return new m5(e,t,a,n,s,i)}}class Xa extends Ye{#e=null;#t=0;#a;#n=null;#s=null;#l=null;#i=null;#f=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=ot.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let e=Xa.prototype;return lt(this,"_keyboardManager",new Ks([[["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||Xa._defaultColor,this.#m=e.thickness||Xa._defaultThickness,this.opacity=e.opacity||Xa._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.#f=e.focusOffset,this.#j(),this.#k(),this.rotate(this.rotation);if(!this.annotationElementId)this._uiManager.a11yAlert(Ye._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 u5(this.#a,0.001);this.#r=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#r.box;let t=new u5(this.#a,0.0025,0.001,this._uiManager.direction==="ltr");this.#l=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.#l;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.#l=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.#l.box,path:{d:this.#l.toSVGPath()}},!0);else if(this.parent){let u=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Xa.#_(this.#r.box,(u-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:Xa.#_(this.#l.box,u),path:{d:this.#l.toSVGPath()}})}let[s,i,l,f]=e.box;switch(this.rotation){case 0:this.x=s,this.y=i,this.width=l,this.height=f;break;case 90:{let[u,g]=this.parentDimensions;this.x=i,this.y=1-s,this.width=l*g/u,this.height=f*u/g;break}case 180:this.x=1-s,this.y=1-i,this.width=l,this.height=f;break;case 270:{let[u,g]=this.parentDimensions;this.x=1-i,this.y=s,this.width=l*g/u,this.height=f*u/g;break}}let{firstPoint:c}=e;this.#g=[(c[0]-s)/l,(c[1]-i)/f];let{lastPoint:h}=this.#l;this.#b=[(h[0]-s)/l,(h[1]-i)/f]}static initialize(e,t){Ye.initialize(e,t),Xa._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case bt.HIGHLIGHT_COLOR:Xa._defaultColor=t;break;case bt.HIGHLIGHT_THICKNESS:Xa._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,Xa._defaultColor],[bt.HIGHLIGHT_THICKNESS,Xa._defaultThickness]]}get propertiesToUpdate(){return[[bt.HIGHLIGHT_COLOR,this.color||Xa._defaultColor],[bt.HIGHLIGHT_THICKNESS,this.#m||Xa._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,Xa._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 bi({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.#l.box,path:{d:this.#l.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=Xa.#_(this.#r.box,e);else a=Xa.#_([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:Xa.#_(this.#l.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(),UA(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){Xa._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.#f)}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}#H(){if(this.#h)return null;let[e,t]=this.pageDimensions,[a,n]=this.pageTranslation,s=this.#a,i=new Float32Array(s.length*8),l=0;for(let{x:f,y:c,width:h,height:u}of s){let g=f*e+a,b=(1-c)*t+n;i[l]=i[l+4]=g,i[l+1]=i[l+3]=b,i[l+2]=i[l+6]=g+h*e,i[l+5]=i[l+7]=b-u*t,l+=8}return i}#x(e){return this.#r.serialize(e,this.#F())}static startHighlighting(e,t,{target:a,x:n,y:s}){let{x:i,y:l,width:f,height:c}=a.getBoundingClientRect(),h=new AbortController,u=e.combinedSignal(h),g=(b)=>{h.abort(),this.#D(e,b)};window.addEventListener("blur",g,{signal:u}),window.addEventListener("pointerup",g,{signal:u}),window.addEventListener("pointerdown",Sa,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",wi,{signal:u}),a.addEventListener("pointermove",this.#M.bind(this,e),{signal:u}),this._freeHighlight=new m5({x:n,y:s},[i,l,f,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#M(e,t){if(this._freeHighlight.add(t))e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#D(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 F8){let{data:{quadPoints:j,rect:A,rotation:S,id:C,color:O,opacity:T,popupRef:M,richText:H,contentsObj:D,creationDate:N,modificationDate:z},parent:{page:{pageNumber:L}}}=e;n=e={annotationType:ot.HIGHLIGHT,color:Array.from(O),opacity:T,quadPoints:j,boxes:null,pageIndex:L-1,rect:A.slice(0),rotation:S,annotationElementId:C,id:C,deleted:!1,popupRef:M,richText:H,comment:D?.str||null,creationDate:N,modificationDate:z}}else if(e instanceof T5){let{data:{inkLists:j,rect:A,rotation:S,id:C,color:O,borderStyle:{rawWidth:T},popupRef:M,richText:H,contentsObj:D,creationDate:N,modificationDate:z},parent:{page:{pageNumber:L}}}=e;n=e={annotationType:ot.HIGHLIGHT,color:Array.from(O),thickness:T,inkLists:j,boxes:null,pageIndex:L-1,rect:A.slice(0),rotation:S,annotationElementId:C,id:C,deleted:!1,popupRef:M,richText:H,comment:D?.str||null,creationDate:N,modificationDate:z}}let{color:s,quadPoints:i,inkLists:l,outlines:f,opacity:c}=e,h=await super.deserialize(e,t,a);if(h.color=Be.makeHexColor(...s),h.opacity=c||1,l)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(l||f){h.#h=!0;let j=(l||f.points)[0],A={x:j[0]-b,y:g-(j[1]-d)},S=new m5(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),S.add(A);let{id:C,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:S.toSVGPath()}},!0,!0);h.#w({highlightOutlines:S.getOutlines(),highlightId:C,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=Ye._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.#H(),outlines:this.#x(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 H8{#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(){Rt("Not implemented")}}class zt extends Ye{#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.#l(e),this.#o()}#l({drawOutlines:e,drawId:t,drawingOptions:a}){if(this.#e=e,this._drawingOptions||=a,!this.annotationElementId)this._uiManager.a11yAlert(Ye._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(zt._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){Rt("Not implemented")}static get typesMap(){Rt("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)zt.#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=(l)=>{n.updateProperty(t,l);let f=this.#e.updateProperty(t,l);if(f)this.#h(f);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],l=s[n],f=(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:f.bind(this,e,t),undo:f.bind(this,i,l),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,zt._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,zt._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,zt._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.#f(),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.#f();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()}#f(){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:l}=this;switch(l){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:l}=this;switch(l){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:[l,f]}=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*(l/f),n*(f/l),a*(l/f)];case 5:return[1-t,e,a*(l/f),n*(f/l)];case 6:return[1-e-n*(f/l),1-t,n*(f/l),a*(l/f)];case 7:return[t-a*(l/f),1-e-n*(f/l),a*(l/f),n*(f/l)];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*(f/l),t,n*(f/l),a*(l/f)];case 13:return[1-t-a*(l/f),e-n*(f/l),a*(l/f),n*(f/l)];case 14:return[1-e,1-t-a*(l/f),n*(f/l),a*(l/f)];case 15:return[t,1-e,a*(l/f),n*(f/l)];default:return[e,t,a,n]}}rotate(){if(!this.parent)return;this.parent.drawLayer.updateProperties(this._drawId,zt._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){Rt("Not implemented")}static startDrawing(e,t,a,n){let{target:s,offsetX:i,offsetY:l,pointerId:f,pointerType:c}=n;if(Et.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:h}}=e,{width:u,height:g}=s.getBoundingClientRect(),b=zt.#n=new AbortController,d=e.combinedSignal(b);if(Et.setPointer(c,f),window.addEventListener("pointerup",(j)=>{if(Et.isSamePointerIdOrRemove(j.pointerId))this._endDraw(j)},{signal:d}),window.addEventListener("pointercancel",(j)=>{if(Et.isSamePointerIdOrRemove(j.pointerId))this._currentParent.endDrawingSession()},{signal:d}),window.addEventListener("pointerdown",(j)=>{if(!Et.isSamePointerType(j.pointerType))return;if(Et.initializeAndAddPointerId(j.pointerId),zt.#a.isCancellable())if(zt.#a.removeLastElement(),zt.#a.isEmpty())this._currentParent.endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",wi,{signal:d}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:d}),s.addEventListener("touchmove",(j)=>{if(Et.isSameTimeStamp(j.timeStamp))Sa(j)},{signal:d}),e.toggleDrawing(),t._editorUndoBar?.hide(),zt.#a){e.drawLayer.updateProperties(this._currentDrawId,zt.#a.startNew(i,l,u,g,h));return}t.updateUIForDefaultProperties(this),zt.#a=this.createDrawerInstance(i,l,u,g,h),zt.#s=this.getDefaultDrawingOptions(),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(zt.#s.toSVGProperties(),zt.#a.defaultSVGProperties),!0,!1)}static _drawMove(e){if(Et.isSameTimeStamp(e.timeStamp),!zt.#a)return;let{offsetX:t,offsetY:a,pointerId:n}=e;if(!Et.isSamePointerId(n))return;if(Et.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,zt.#a.add(t,a)),Et.setTimeStamp(e.timeStamp),Sa(e)}static _cleanup(e){if(e)this._currentDrawId=-1,this._currentParent=null,zt.#a=null,zt.#s=null,Et.clearTimeStamp();if(zt.#n)zt.#n.abort(),zt.#n=null,Et.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,zt.#a.end(e.offsetX,e.offsetY));if(this.supportMultipleDrawings){let a=zt.#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),!zt.#a.isEmpty()){let{pageDimensions:[a,n],scale:s}=t,i=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:zt.#a.getOutlines(a*s,n*s,s,this._INNER_MARGIN),drawingOptions:zt.#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){Rt("Not implemented")}static async deserialize(e,t,a){let{rawDims:{pageWidth:n,pageHeight:s,pageX:i,pageY:l}}=t.viewport,f=this.deserializeDraw(i,l,n,s,this._INNER_MARGIN,e),c=await super.deserialize(e,t,a);return c.createDrawingOptions(e),c.#l({drawOutlines:f}),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 lS{#e=new Float64Array(6);#t;#a;#n;#s;#l;#i="";#f=0;#o=new R1;#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 l=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#l=[e,t],this.#a=[{line:l,points:this.#l}],this.#e.set(l,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.#l.length<=10}add(e,t){[e,t]=this.#h(e,t);let[a,n,s,i]=this.#e.subarray(2,6),l=e-s,f=t-i;if(Math.hypot(this.#r*l,this.#u*f)<=2)return null;if(this.#l.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.#l.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.#l=[e,t];let l=this.#a.at(-1);if(l)l.line=new Float32Array(l.line),l.points=new Float32Array(l.points);return this.#a.push({line:i,points:this.#l}),this.#e.set(i,0),this.#f=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.#l=e.points,this.#f=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.#l=n,this.#f=0,this.toSVGPath()}return{path:{d:this.#i}}}toSVGPath(){let e=Ee.svgRound(this.#t[4]),t=Ee.svgRound(this.#t[5]);if(this.#l.length===2)return this.#i=`${this.#i} M ${e} ${t} Z`,this.#i;if(this.#l.length<=6){let n=this.#i.lastIndexOf("M");this.#i=`${this.#i.slice(0,n)} M ${e} ${t}`,this.#f=6}if(this.#l.length===4){let n=Ee.svgRound(this.#t[10]),s=Ee.svgRound(this.#t[11]);return this.#i=`${this.#i} L ${n} ${s}`,this.#f=12,this.#i}let a=[];if(this.#f===0)a.push(`M ${e} ${t}`),this.#f=6;for(let n=this.#f,s=this.#t.length;n<s;n+=6){let[i,l,f,c,h,u]=this.#t.slice(n,n+6).map(Ee.svgRound);a.push(`C${i} ${l} ${f} ${c} ${h} ${u}`)}return this.#i+=a.join(" "),this.#f=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 R1 extends Ee{#e;#t=0;#a;#n;#s;#l;#i;#f;#o;build(e,t,a,n,s,i,l){this.#s=t,this.#l=a,this.#i=n,this.#f=s,this.#o=i,this.#a=l??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,l,f,c,h]=t.subarray(a,a+6).map(Ee.svgRound);e.push(`C${s} ${i} ${l} ${f} ${c} ${h}`)}}return e.join("")}serialize([e,t,a,n],s){let i=[],l=[],[f,c,h,u]=this.#u(),g,b,d,j,A,S,C,O,T;switch(this.#f){case 0:T=Ee._rescale,g=e,b=t+n,d=a,j=-n,A=e+f*a,S=t+(1-c-u)*n,C=e+(f+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,S=t+f*n,C=e+(c+u)*a,O=t+(f+h)*n;break;case 180:T=Ee._rescale,g=e+a,b=t,d=-a,j=n,A=e+(1-f-h)*a,S=t+c*n,C=e+(1-f)*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,S=t+(1-f-h)*n,C=e+(1-c)*a,O=t+(1-f)*n;break}for(let{line:M,points:H}of this.#n)i.push(T(M,g,b,d,j,s?Array(M.length):null)),l.push(T(H,g,b,d,j,s?Array(H.length):null));return{lines:i,points:l,rect:[A,S,C,O]}}static deserialize(e,t,a,n,s,{paths:{lines:i,points:l},rotation:f,thickness:c}){let h=[],u,g,b,d,j;switch(f){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 S of l){let C=S.length;if(C===2){i.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(C===4){i.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}let O=new Float32Array(3*(C-2));i.push(O);let[T,M,H,D]=S.subarray(0,4);O.set([NaN,NaN,NaN,NaN,T,M],0);for(let N=4;N<C;N+=2){let z=S[N],L=S[N+1];O.set(Ee.createBezierPoints(T,M,H,D,z,L),(N-2)*3),[T,M,H,D]=[H,D,z,L]}}}for(let S=0,C=i.length;S<C;S++)h.push({line:j(i[S].map((O)=>O??NaN),u,g,b,d),points:j(l[S].map((O)=>O??NaN),u,g,b,d)});let A=new this.prototype.constructor;return A.build(h,a,n,1,f,c,s),A}#r(e=this.#o){let t=this.#a+e/2*this.#i;return this.#f%180===0?[t/this.#s,t/this.#l]:[t/this.#l,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=_r.slice();for(let{line:n}of this.#n){if(n.length<=12){for(let l=4,f=n.length;l<f;l+=6)Be.pointBoundingBox(n[l],n[l+1],e);continue}let s=n[4],i=n[5];for(let l=6,f=n.length;l<f;l+=6){let[c,h,u,g,b,d]=n.subarray(l,l+6);Be.bezierBoundingBox(s,i,c,h,u,g,b,d,e),s=b,i=d}}let[t,a]=this.#r();e[0]=ha(e[0]-t,0,1),e[1]=ha(e[1]-a,0,1),e[2]=ha(e[2]+t,0,1),e[3]=ha(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,l]=[n-t,s-a],f=this.#e;return f[0]-=i,f[1]-=l,f[2]+=2*i,f[3]+=2*l,f}updateParentDimensions([e,t],a){let[n,s]=this.#r();this.#s=e,this.#l=t,this.#i=a;let[i,l]=this.#r(),f=i-n,c=l-s,h=this.#e;return h[0]-=f,h[1]-=c,h[2]+=2*f,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,l=0,f=0;switch(this.#t){case 90:n=t/e,s=-e/t,l=e;break;case 180:a=-1,i=-1,l=e,f=t;break;case 270:n=-t/e,s=e/t,f=t;break;default:return""}return`matrix(${a} ${n} ${s} ${i} ${Ee.svgRound(l)} ${Ee.svgRound(f)})`}getPathResizingSVGProperties([e,t,a,n]){let[s,i]=this.#r(),[l,f,c,h]=this.#e;if(Math.abs(c-s)<=Ee.PRECISION||Math.abs(h-i)<=Ee.PRECISION){let j=e+a/2-(l+c/2),A=t+n/2-(f+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(l)} ${Ee.svgRound(f)}`,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(),l=this.#e,[f,c,h,u]=l;if(l[0]=e,l[1]=t,l[2]=a,l[3]=n,Math.abs(h-s)<=Ee.PRECISION||Math.abs(u-i)<=Ee.PRECISION){let A=e+a/2-(f+h/2),S=t+n/2-(c+u/2);for(let{line:C,points:O}of this.#n)Ee._translate(C,A,S,C),Ee._translate(O,A,S,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*(f+s)+e+s,j=-b*(c+i)+t+i;if(g!==1||b!==1||d!==0||j!==0)for(let{line:A,points:S}of this.#n)Ee._rescale(A,d,j,g,b,A),Ee._rescale(S,d,j,g,b,S);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,l=e-i[0],f=t-i[1];if(this.#s===n&&this.#l===s)for(let{line:c,points:h}of this.#n)Ee._translate(c,l,f,c),Ee._translate(h,l,f,h);else{let c=this.#s/n,h=this.#l/s;this.#s=n,this.#l=s;for(let{line:u,points:g}of this.#n)Ee._rescale(u,l,f,c,h,u),Ee._rescale(g,l,f,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 M5 extends H8{constructor(e){super();this._viewParameters=e,super.updateProperties({fill:"none",stroke:Ye._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 M5(this._viewParameters);return e.updateAll(this),e}}class x8 extends zt{static _type="ink";static _editorType=ot.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,t){Ye.initialize(e,t),this._defaultDrawingOptions=new M5(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return lt(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 lS(e,t,a,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,a,n,s,i){return R1.deserialize(e,t,a,n,s,i)}static async deserialize(e,t,a){let n=null;if(e instanceof T5){let{data:{inkLists:i,rect:l,rotation:f,id:c,color:h,opacity:u,borderStyle:{rawWidth:g},popupRef:b,richText:d,contentsObj:j,creationDate:A,modificationDate:S},parent:{page:{pageNumber:C}}}=e;n=e={annotationType:ot.INK,color:Array.from(h),thickness:g,opacity:u,paths:{points:i},boxes:null,pageIndex:C-1,rect:l.slice(0),rotation:f,annotationElementId:c,id:c,deleted:!1,popupRef:b,richText:d,comment:j?.str||null,creationDate:A,modificationDate:S}}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 iu(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=x8.getDefaultDrawingOptions({stroke:Be.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,l=Object.assign(super.serialize(e),{color:Ye._colorManager.convert(n),opacity:s,thickness:i,paths:{lines:t,points:a}});if(this.addComment(l),e)return l.isCopy=!0,l;if(this.annotationElementId&&!this.#e(l))return null;return l.id=this.annotationElementId,l}#e(e){let{color:t,thickness:a,opacity:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((i,l)=>i!==t[l])||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 g5 extends R1{toSVGPath(){let e=super.toSVGPath();if(!e.endsWith("Z"))e+="Z";return e}}var P9=8,Zh=3;class Cr{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,l){let f=this.#t(a,n,s,i);for(let c=0;c<8;c++){let h=(-c+f-l+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,l){let f=this.#t(a,n,s,i);for(let c=0;c<8;c++){let h=(c+f+l+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#l(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 l=1,f,c=[];for(let h=1;h<a-1;h++){f=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)l+=1,j-=1;else if(b>=1&&i[g+1]===0){if(l+=1,j+=1,b>1)f=b}else{if(b!==1)f=Math.abs(b);continue}let A=[u,h],S=j===u+1,C={isHole:S,points:A,id:l,parent:0};c.push(C);let O;for(let ee of c)if(ee.id===f){O=ee;break}if(!O)C.parent=S?f:0;else if(O.isHole)C.parent=S?O.parent:f;else C.parent=S?f:O.parent;let T=this.#n(i,t,h,u,d,j,0);if(T===-1){if(i[g]=-l,i[g]!==1)f=Math.abs(i[g]);continue}let M=this.#a[2*T],H=this.#a[2*T+1],D=h+M,N=u+H;d=D,j=N;let z=h,L=u;while(!0){let ee=this.#s(i,t,z,L,d,j,1);M=this.#a[2*ee],H=this.#a[2*ee+1];let te=z+M,J=L+H;A.push(J,te);let ae=z*t+L;if(i[ae+1]===0)i[ae]=-l;else if(i[ae]===1)i[ae]=l;if(te===h&&J===u&&z===D&&L===N){if(i[g]!==1)f=Math.abs(i[g]);break}else d=z,j=L,z=te,L=J}}}return c}static#i(e,t,a,n){if(a-t<=4){for(let D=t;D<a-2;D+=2)n.push(e[D],e[D+1]);return}let s=e[t],i=e[t+1],l=e[a-4]-s,f=e[a-3]-i,c=Math.hypot(l,f),h=l/c,u=f/c,g=h*i-u*s,b=f/l,d=1/c,j=Math.atan(b),A=Math.cos(j),S=Math.sin(j),C=d*(Math.abs(A)+Math.abs(S)),O=d*(1-C+C**2),T=Math.max(Math.atan(Math.abs(S+A)*O),Math.atan(Math.abs(S-A)*O)),M=0,H=t;for(let D=t+2;D<a-2;D+=2){let N=Math.abs(g-h*e[D+1]+u*e[D]);if(N>M)H=D,M=N}if(M>(c*T)**2)this.#i(e,t,H+2,n),this.#i(e,H,a,n);else n.push(s,i)}static#f(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 l=new Float32Array(i**2),f=-2*n**2,c=i>>1;for(let j=0;j<i;j++){let A=(j-c)**2;for(let S=0;S<i;S++)l[j*i+S]=Math.exp((A+(S-c)**2)/f)}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 S=j*t+A,C=e[S],O=0,T=0;for(let H=0;H<i;H++){let D=j+H-c;if(D<0||D>=a)continue;for(let N=0;N<i;N++){let z=A+N-c;if(z<0||z>=t)continue;let L=e[D*t+z],ee=l[H*i+N]*h[Math.abs(L-C)];O+=L*ee,T+=ee}}let M=b[S]=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 l=0,f=a.length;l<f;l++){let c=a[l]=e[l<<2];n=Math.max(n,c),s=Math.min(s,c)}let i=255/(n-s);for(let l=0,f=a.length;l<f;l++)a[l]=(a[l]-s)*i;return a}static#h(e){let t,a=-1/0,n=-1/0,s=e.findIndex((f)=>f!==0),i=s,l=s;for(t=s;t<256;t++){let f=e[t];if(f>a){if(t-i>n)n=t-i,l=t-1;a=f,i=t}}for(t=l-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,l=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 S=0;S<d;S++){i=Math.ceil(g/2),l=Math.ceil(b/2);let C=new OffscreenCanvas(i,l);if(C.getContext("2d").drawImage(e,0,0,g,b,0,0,i,l),g=i,b=l,e!==t)e.close();e=C.transferToImageBitmap()}let A=Math.min(s/i,s/l);i=Math.round(i*A),l=Math.round(l*A)}let c=new OffscreenCanvas(i,l).getContext("2d",{willReadFrequently:!0});c.fillStyle="white",c.fillRect(0,0,i,l),c.filter="grayscale(1)",c.drawImage(e,0,0,e.width,e.height,0,0,i,l);let h=c.getImageData(0,0,i,l).data;return[this.#u(h),i,l]}static extractContoursFromText(e,{fontFamily:t,fontStyle:a,fontWeight:n},s,i,l,f){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:S,fontBoundingBoxDescent:C,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(S)+Math.abs(C)||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 D=this.#u(h.getImageData(0,0,M,H).data),N=this.#r(D),z=this.#h(N),L=this.#l(D,M,H,z);return this.processDrawnLines({lines:{curves:L,width:M,height:H},pageWidth:s,pageHeight:i,rotation:l,innerMargin:f,mustSmooth:!0,areContours:!0})}static process(e,t,a,n,s){let[i,l,f]=this.#g(e),[c,h]=this.#o(i,l,f,Math.hypot(l,f)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#h(h),g=this.#l(c,l,f,u);return this.processDrawnLines({lines:{curves:g,width:l,height:f},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:l}){if(n%180!==0)[t,a]=[a,t];let{curves:f,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:C}of f){let O=i?this.#f(C):C;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[D,N,z,L]=O;D*=d,N*=j,z*=d,L*=j,M.set([D,N,z,L],0),H.set([NaN,NaN,NaN,NaN,D,N],0);for(let ee=4;ee<T;ee+=2){let te=M[ee]=O[ee]*d,J=M[ee+1]=O[ee+1]*j;H.set(Ee.createBezierPoints(D,N,z,L,te,J),(ee-2)*3),[D,N,z,L]=[z,L,te,J]}}if(g.length===0)return null;let S=l?new g5:new R1;return S.build(g,t,a,1,n,l?0:u,s),{outline:S,newCurves:A,areContours:l,thickness:u,width:c,height:h}}static async compressSignature({outlines:e,areContours:t,thickness:a,width:n,height:s}){let i=1/0,l=-1/0,f=0;for(let C of e){f+=C.length;for(let O=2,T=C.length;O<T;O++){let M=C[O]-C[O-2];i=Math.min(i,M),l=Math.max(l,M)}}let c;if(i>=-128&&l<=127)c=Int8Array;else if(i>=-32768&&l<=32767)c=Int16Array;else c=Int32Array;let h=e.length,u=P9+Zh*h,g=new Uint32Array(u),b=0;g[b++]=u*Uint32Array.BYTES_PER_ELEMENT+(f-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 C of e)g[b++]=C.length-2,g[b++]=C[0],g[b++]=C[1];let d=new CompressionStream("deflate-raw"),j=d.writable.getWriter();await j.ready,j.write(g);let A=c.prototype.constructor;for(let C of e){let O=new A(C.length-2);for(let T=2,M=C.length;T<M;T++)O[T-2]=C[T]-C[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,l=0;for await(let O of a)i||=new Uint8Array(new Uint32Array(O.buffer,0,4)[0]),i.set(O,l),l+=O.length;let f=new Uint32Array(i.buffer,0,i.length>>2),c=f[1];if(c!==0)throw Error(`Invalid version: ${c}`);let h=f[2],u=f[3],g=f[4]===0,b=f[5],d=f[6],j=f[7],A=[],S=(P9+Zh*d)*Uint32Array.BYTES_PER_ELEMENT,C;switch(j){case Int8Array.BYTES_PER_ELEMENT:C=new Int8Array(i.buffer,S);break;case Int16Array.BYTES_PER_ELEMENT:C=new Int16Array(i.buffer,S);break;case Int32Array.BYTES_PER_ELEMENT:C=new Int32Array(i.buffer,S);break}l=0;for(let O=0;O<d;O++){let T=f[Zh*O+P9],M=new Float32Array(T+2);A.push(M);for(let H=0;H<Zh-1;H++)M[H]=f[Zh*O+P9+H+1];for(let H=0;H<T;H++)M[H+2]=M[H]+C[l++]}return{areContours:g,thickness:b,outlines:A,width:h,height:u}}catch(t){return ct(`decompressSignature: ${t}`),null}}}class D8 extends H8{constructor(){super();super.updateProperties({fill:Ye._defaultLineColor,"stroke-width":0})}clone(){let e=new D8;return e.updateAll(this),e}}class R8 extends M5{constructor(e){super(e);super.updateProperties({stroke:Ye._defaultLineColor,"stroke-width":1})}clone(){let e=new R8(this._viewParameters);return e.updateAll(this),e}}class m0 extends zt{#e=!1;#t=null;#a=null;#n=null;static _type="signature";static _editorType=ot.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){Ye.initialize(e,t),this._defaultDrawingOptions=new D8,this._defaultDrawnSignatureOptions=new R8(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!1}static get typesMap(){return lt(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:l,uuid:f,heightInPage:c}=this.#a,{rawDims:{pageWidth:h,pageHeight:u},rotation:g}=this.parent.viewport,b=Cr.processDrawnLines({lines:n,pageWidth:h,pageHeight:u,rotation:g,innerMargin:m0._INNER_MARGIN,mustSmooth:s,areContours:i});this.addSignature(b,c,l,f)}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),l=Cr.processDrawnLines({lines:{curves:e.map((f)=>({points:f})),thickness:a,width:n,height:s},pageWidth:i,pageHeight:i,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t});return{areContours:t,outline:l.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:l}=this.#a=e;this.#e=l instanceof g5,this.description=a;let f;if(this.#e)f=m0.getDefaultDrawingOptions();else f=m0._defaultDrawnSignatureOptions.clone(),f.updateProperties({"stroke-width":l.thickness});this._addOutlines({drawOutlines:l,drawingOptions:f});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 Cr.process(e,t,a,n,m0._INNER_MARGIN)}getFromText(e,t){let{rawDims:{pageWidth:a,pageHeight:n},rotation:s}=this.parent.viewport;return Cr.extractContoursFromText(e,t,a,n,s,m0._INNER_MARGIN)}getDrawnSignature(e){let{rawDims:{pageWidth:t,pageHeight:a},rotation:n}=this.parent.viewport;return Cr.processDrawnLines({lines:e,pageWidth:t,pageHeight:a,rotation:n,innerMargin:m0._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=m0.getDefaultDrawingOptions();else this._drawingOptions=m0._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 g5.deserialize(e,t,a,n,s,i);return R1.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 fS extends Ye{#e=null;#t=null;#a=null;#n=null;#s=null;#l="";#i=null;#f=!1;#o=null;#r=!1;#u=!1;static _type="stamp";static _editorType=ot.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){Ye.initialize(e,t)}static isHandlingMimeForPasting(e){return n8.includes(e)}static paste(e,t){t.pasteEditor({mode:ot.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.#l=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,l=await a.guess({name:"altText",request:{data:n,width:s,height:i,channels:n.length/(s*i)}});if(!l)throw Error("No response from the AI service.");if(l.error)throw Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw Error("No valid response from the AI service.");let f=l.output;if(await this.setGuessedAltText(f),t&&!this.hasAltTextData())this.altTextData={alt:f,decorative:!1};return f}#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=n8.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.#f)}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.#f)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.#f=!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 f=Math.min(0.75*n/t,0.75*s/a);t*=f,a*=f}this._uiManager.enableWaiting(!1);let l=this.#i=document.createElement("canvas");if(l.setAttribute("role","img"),this.addContainer(l),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.#l)this.div.setAttribute("aria-description",this.#l);if(!this.annotationElementId)this._uiManager.a11yAlert(Ye._l10nAlert.stamp)}copyCanvas(e,t,a=!1){if(!e)e=224;let{width:n,height:s}=this.#e,i=new b0,l=this.#e,f=n,c=s,h=null;if(t){if(n>t||s>t){let H=Math.min(t/n,t/s);f=Math.floor(n*H),c=Math.floor(s*H)}h=document.createElement("canvas");let g=h.width=Math.ceil(f*i.sx),b=h.height=Math.ceil(c*i.sy);if(!this.#r)l=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(RA.isDarkMode)j="#8f8f9d",A="#42414d";let S=15,C=S*i.sx,O=S*i.sy,T=new OffscreenCanvas(C*2,O*2),M=T.getContext("2d");M.fillStyle=j,M.fillRect(0,0,C*2,O*2),M.fillStyle=A,M.fillRect(0,0,C,O),M.fillRect(C,O,C,O),d.fillStyle=d.createPattern(T,"repeat"),d.fillRect(0,0,g,b),d.drawImage(l,0,0,l.width,l.height,0,0,g,b)}let u=null;if(a){let g,b;if(i.symmetric&&l.width<e&&l.height<e)g=l.width,b=l.height;else if(l=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)l=this.#c(g,b)}let j=new OffscreenCanvas(g,b).getContext("2d",{willReadFrequently:!0});j.drawImage(l,0,0,l.width,l.height,0,0,g,b),u={width:g,height:b,data:j.getImageData(0,0,g,b).data}}return{canvas:h,width:f,height:c,imageData:u}}#c(e,t){let{width:a,height:n}=this.#e,s=a,i=n,l=this.#e;while(s>2*e||i>2*t){let f=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(l,0,0,f,c,0,0,s,i),l=h.transferToImageBitmap()}return l}#m(){let[e,t]=this.parentDimensions,{width:a,height:n}=this,s=new b0,i=Math.ceil(a*e*s.sx),l=Math.ceil(n*t*s.sy),f=this.#i;if(!f||f.width===i&&f.height===l)return;f.width=i,f.height=l;let c=this.#r?this.#e:this.#c(i,l),h=f.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(c,0,0,c.width,c.height,0,0,i,l)}#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*Or.PDF_TO_CSS_UNITS),s=Math.round(this.height*a*Or.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 O8){let{data:{rect:j,rotation:A,id:S,structParent:C,popupRef:O,richText:T,contentsObj:M,creationDate:H,modificationDate:D},container:N,parent:{page:{pageNumber:z}},canvas:L}=e,ee,te;if(L)delete e.canvas,{id:ee,bitmap:te}=a.imageManager.getFromCanvas(N.id,L),L.remove();else s=!0,e._hasNoCanvas=!0;let J=(await t._structTree.getAriaAttributes(`pdfjs_internal_id_${S}`))?.get("aria-label")||"";n=e={annotationType:ot.STAMP,bitmapId:ee,bitmap:te,pageIndex:z-1,rect:j.slice(0),rotation:A,annotationElementId:S,id:S,deleted:!1,accessibilityData:{decorative:!1,altText:J},isSvg:!1,structParent:C,popupRef:O,richText:T,comment:M?.str||null,creationDate:H,modificationDate:D}}let i=await super.deserialize(e,t,a),{rect:l,bitmap:f,bitmapUrl:c,bitmapId:h,isSvg:u,accessibilityData:g}=e;if(s)a.addMissingCanvas(e.id,i),i.#f=!0;else if(h&&a.imageManager.isValidId(h)){if(i.#t=h,f)i.#e=f}else i.#n=c;i.#r=u;let[b,d]=i.pageDimensions;if(i.width=(l[2]-l[0])/b,i.height=(l[3]-l[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 l=this.#j(a);if(l.isSame)return null;if(l.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 l=t.stamps.get(this.#t);if(i>l.area)l.area=i,l.serialized.bitmap.close(),l.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 tl{#e;#t=!1;#a=null;#n=null;#s=null;#l=new Map;#i=!1;#f=!1;#o=!1;#r=null;#u=null;#h=null;#g=null;#b=null;#p=-1;#c;static _initialized=!1;static#m=new Map([vn,x8,fS,Xa,m0].map((e)=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:a,structTreeLayer:n,accessibilityManager:s,annotationLayer:i,drawLayer:l,textLayer:f,viewport:c,l10n:h}){let u=[...tl.#m.values()];if(!tl._initialized){tl._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=f,this.drawLayer=l,this._structTree=n,this.#c.addLayer(this)}get isEmpty(){return this.#l.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===ot.NONE}updateToolbar(e){this.#c.updateToolbar(e)}updateMode(e=this.#c.getMode()){switch(this.#q(),e){case ot.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case ot.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case ot.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===ot.POPUP)t.toggle("commentEditing",!0);else{t.toggle("commentEditing",!1);for(let a of tl.#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.#l.size!==0?this.#l.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.#f=!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:l,clientY:f,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(l,f);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.#l.get(b);if(j?.annotationElementId===null)Sa(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:l}=i.data;if(this.#c.isDeletedAnnotationElement(l)){i.updateEdited({deleted:!0});continue}let f=s.get(l);if(f){f.resetAnnotationElement(i),f.show(!1),i.show();continue}if(f=n.get(l),f){if(this.#c.addChangedExistingAnnotation(f),f.renderAnnotationElement(i))f.show(!1)}i.show()}}if(this.#q(),this.isEmpty)this.div.hidden=!0;let{classList:a}=this.div;for(let n of tl.#m.values())a.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e?.updateFakeAnnotations(t),this.#f=!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}=Zt.platform;if(e.button!==0||e.ctrlKey&&a)return;this.#c.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),Xa.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.#l.set(e.id,e);let{annotationElementId:t}=e;if(t&&this.#c.isDeletedAnnotationElement(t))this.#c.removeDeletedAnnotationElement(e)}detach(e){if(this.#l.delete(e.id),this.#e?.removePointerInTextLayer(e.contentDiv),!this.#f&&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),Ye.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.#l.values())if(t.uid===e)return t;return null}get#w(){return tl.#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 tl.#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),l=Math.min(window.innerWidth,e+a),f=Math.min(window.innerHeight,t+n),c=(s+l)/2-e,h=(i+f)/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}=Zt.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===ot.STAMP||a===ot.POPUP||a===ot.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){if(this.#c.getMode()===ot.HIGHLIGHT)this.enableTextSelection();if(this.#i){this.#i=!1;return}let{isMac:t}=Zt.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.#l.values())this.#e?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#l.clear(),this.#c.removeLayer(this)}#q(){for(let e of this.#l.values())if(e.isEmpty())e.remove()}async render({viewport:e}){this.viewport=e,Br(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,Br(this.div,{rotation:a}),t!==a)for(let n of this.#l.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 Kz(e,t){if(e===t)return 0;return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function e5(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 TA(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;#l=null;#i=new Map;static#f=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.#l=new MutationObserver((i)=>{if(!this.#e||!this.#a?.isConnected||!it.#c())return;for(let{addedNodes:l}of i)for(let f of l)if(f.nodeType===Node.ELEMENT_NODE&&f.classList.contains("endOfContent")){it.#d();return}}),this.#l.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(Kz)}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,l=e.rangeCount;i<l;i++){let f=e.getRangeAt(i);if(f.collapsed)continue;let{startContainer:c,startOffset:h,endContainer:u,endOffset:g}=f,b=e5(c),d=e5(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,D=e5(O),N=e5(M),z=Lz(O,T,M,H);if(D&&N&&z!==null)if(z)c=O,h=T,b=D,u=M,g=H,d=N;else c=M,h=H,b=N,u=O,g=T,d=D}let S=a.filter((O)=>f.intersectsNode(O));if(S.length===0)continue;let C=!1;if(!b)b=S[0],c=b,h=0,C=!0;if(!d)d=S.at(-1),u=d,g=d.childNodes.length,C=!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=TA(u,g,d);if(!O)continue;u=O.container,g=O.offset}}if(c.nodeType===Node.ELEMENT_NODE){let O=TA(c,h,b);if(!O)continue;c=O.container,h=O.offset}if(b===d&&!C&&S.includes(b)){n.push([f,b]);continue}for(let O of S){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 D=H.previousSibling;if(!D)continue;M.setEndAfter(D)}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,l]of n){let f=it.#b.get(l);if(!f)continue;let c=t.get(l);if(!c){let d=l.getBoundingClientRect();c=(j,A,S,C)=>({x:(j-d.x)/d.width,y:(A-d.y)/d.height,width:S/d.width,height:C/d.height}),t.set(l,c)}let h=[];for(let{x:d,y:j,width:A,height:S}of i.getClientRects()){if(A===0||S===0)continue;if({x:d,y:j,width:A,height:S}=c(d,j,A,S),A===1&&S===1)continue;h.push(`M${d} ${j} h${A} v${S} h-${A} Z`)}if(h.length===0)continue;let{drawLayer:u,selectionDiv:g,path:b}=f;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[C,O]of Object.entries(j))g.style.setProperty(C,O);let A=it._svgFactory.create(1,1,!0);A.setAttribute("aria-hidden","true"),A.setAttribute("width","100%"),A.setAttribute("height","100%");let S=it._svgFactory.createElement("clipPath");S.setAttribute("id",d),S.setAttribute("clipPathUnits","objectBoundingBox"),b=it._svgFactory.createElement("path"),S.append(b),A.append(S),g.append(A),f.path=b,f.selectionDiv=g}if(!g.parentNode&&u.#e)u.#e.append(g),this.#u.add(g);b.setAttribute("d",h.join(" "))}}static get _svgFactory(){return lt(this,"_svgFactory",new lu)}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.#f++,s=this.#w(),i=it._svgFactory.createElement("defs");s.append(i);let l=it._svgFactory.createElement("path");i.append(l);let f=`path_${n}`;if(l.setAttribute("id",f),l.setAttribute("vector-effect","non-scaling-stroke"),t)this.#i.set(n,l);let c=a?this.#A(i,f):null,h=it._svgFactory.createElement("use");return s.append(h),h.setAttribute("href",`#${f}`),this.updateProperties(s,e),this.#t.set(n,s),{id:n,clipPathId:`url(#${c})`}}drawOutline(e,t){let a=it.#f++,n=this.#w(),s=it._svgFactory.createElement("defs");n.append(s);let i=it._svgFactory.createElement("path");s.append(i);let l=`path_${a}`;i.setAttribute("id",l),i.setAttribute("vector-effect","non-scaling-stroke");let f;if(t){let u=it._svgFactory.createElement("mask");s.append(u),f=`mask_${a}`,u.setAttribute("id",f),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",`#${l}`),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",`#${l}`),f)c.setAttribute("mask",`url(#${f})`);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,l=typeof e==="number"?this.#t.get(e):e;if(!l)return;if(a)this.#y(l,a);if(n)it.#j(l,n);if(s){let{classList:f}=l;for(let[c,h]of Object.entries(s))f.toggle(c,h)}if(i){let c=l.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.#l?.disconnect(),this.#l=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 t5(e){return`${(e*100).toFixed(2)}%`}class p5{#e=[];#t=new Map;#a=null;#n=0;#s=0;#l=0;static#i=null;constructor(e,t,a,n){this.#n=e,this.#e=t,this.#s=a.rawDims.pageWidth,this.#l=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.#f(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=p5.#i?.deref();if(s===a)return;if(s)s.width=0,s.height=0;p5.#i=new WeakRef(a);let{inverseTransform:i,x1:l,y1:f,width:c,height:h}=n,u=this.#a(),g=Math.ceil(l*u.width),b=Math.ceil(f*u.height),d=Math.floor((l+c/this.#s)*u.width),j=Math.floor((f+h/this.#l)*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}#f([e,t,a,n,s,i]){let l=Math.hypot((s-e)*this.#s,(i-t)*this.#l),f=Math.hypot((a-e)*this.#s,(n-t)*this.#l);if(l<this.#n||f<this.#n)return null;let c=[(s-e)*this.#s/l,(i-t)*this.#l/l,(a-e)*this.#s/f,(n-t)*this.#l/f,0,0],h=Be.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:t5(e),top:t5(t),width:t5(l/this.#s),height:t5(f/this.#l),transformOrigin:"0% 0%",transform:`matrix(${c.join(",")})`}),this.#t.set(u,{inverseTransform:h,width:l,height:f,x1:e,y1:t}),u}}globalThis._pdfjsTestingUtils={HighlightOutliner:u5};globalThis.pdfjsLib={AbortException:sl,AnnotationEditorLayer:tl,AnnotationEditorParamsType:bt,AnnotationEditorType:ot,AnnotationEditorUIManager:rf,AnnotationLayer:T8,AnnotationMode:ff,AnnotationType:xa,applyOpacity:uz,build:Uz,ColorPicker:bi,createValidAbsoluteUrl:MA,CSSConstants:NA,DOMSVGFactory:lu,DrawLayer:it,FeatureTest:Zt,fetchData:u8,findContrastColor:mz,getDocument:k8,getFilenameFromUrl:oz,getPdfFilenameFromUrl:cz,getRGB:cu,getRGBA:ou,getUuid:DA,GlobalWorkerOptions:nl,ImageKind:a5,InvalidPDFException:f5,isDataScheme:v5,isPdfFile:m8,isValidExplicitDest:jz,makeArr:fu,makeMap:c8,makeObj:t8,MathClamp:ha,noContextMenu:wi,normalizeUnicode:fz,OPS:g0,OutputScale:b0,PasswordException:l5,PasswordResponses:tz,PDFDataRangeTransport:y8,PDFDateString:r5,PDFWorker:Hn,PermissionFlag:ez,PixelsPerInch:Or,RenderingCancelledException:q5,renderRichText:zA,ResponseException:tu,setLayerDimensions:Br,shadow:lt,SignatureExtractor:Cr,stopEvent:Sa,SupportedImageMimeTypes:n8,TextLayer:Gs,TextLayerImages:p5,TouchManager:k5,updateUrlHash:HA,Util:Be,VerbosityLevel:b5,version:Iz,XfaLayer:h8};var ua=Mt(Za(),1);function cS({currentPage:e,totalPages:t,onPageChange:a,zoom:n,onZoomIn:s,onZoomOut:i,onFit:l,onDownload:f,canDownload:c}){return he("div",{className:"relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-between gap-2 transition-colors duration-200",children:[he("div",{className:"flex items-center gap-1.5 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5",children:[I("button",{onClick:()=>a(Math.max(1,e-1)),disabled:e<=1,className:"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:Le.previous_page(),children:I(rS,{size:16})}),I("span",{className:"px-2 text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none",children:Le.page_of_pages({current:e,total:t||1})}),I("button",{onClick:()=>a(Math.min(t,e+1)),disabled:e>=t,className:"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:Le.next_page(),children:I(oS,{size:16})})]}),he("div",{className:"flex items-center gap-2",children:[he("div",{className:"flex items-center gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5",children:[I("button",{onClick:i,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:Le.zoom_out(),children:I(El,{size:16})}),he("span",{className:"w-12 text-center text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none",children:[Math.round(n*100),"%"]}),I("button",{onClick:s,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:Le.zoom_in(),children:I(d1,{size:16})})]}),I("button",{onClick:l,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",children:Le.fit()}),he("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",title:Le.download_original_file(),children:[I(Ci,{size:14}),Le.download()]})]})]})}var N1="./pdf.worker.min-szxdj13d.mjs";if(typeof window<"u"&&nl){let e=typeof N1==="string"?N1.startsWith("/")?N1:"/"+N1.replace(/^\.\//,""):N1;nl.workerSrc=e}var Jz=ua.default.forwardRef(({file:e,annotations:t,shareId:a,children:n,onPlay:s,onPause:i,onTimeUpdate:l,startTime:f},c)=>{let{isDrawing:h,currentTool:u,currentColor:g,addAnnotation:b,annotations:d}=us(),[j,A]=ua.useState(null),[S,C]=ua.useState(()=>f&&!isNaN(f)?Math.max(1,Math.round(f)):1),[O,T]=ua.useState(1),[M,H]=ua.useState(""),[D,N]=ua.useState({width:800,height:1000}),[z,L]=ua.useState(!0),[ee,te]=ua.useState(null);ua.useImperativeHandle(c,()=>({play:()=>{s?.()},pause:()=>{i?.()},seekTo:(Ie)=>{if(Ie&&!isNaN(Ie)){let He=Math.max(1,Math.min(O,Math.round(Ie)));C(He)}}}),[O,s,i]),ua.useEffect(()=>{l?.(S)},[S,l]),ua.useEffect(()=>{let Ie=(He)=>{let Ze=document.activeElement;if(Ze&&(Ze.tagName==="INPUT"||Ze.tagName==="TEXTAREA"||Ze instanceof HTMLElement&&Ze.isContentEditable))return;if(He.key==="ArrowRight"||He.key==="ArrowDown"||He.key==="PageDown")He.preventDefault(),C((Je)=>{let $e=Math.min(O,Je+1);if($e!==Je)s?.();return $e});else if(He.key==="ArrowLeft"||He.key==="ArrowUp"||He.key==="PageUp")He.preventDefault(),C((Je)=>{let $e=Math.max(1,Je-1);if($e!==Je)s?.();return $e});else if(He.key==="Home")He.preventDefault(),C(1),s?.();else if(He.key==="End")He.preventDefault(),C(O),s?.()};return window.addEventListener("keydown",Ie),()=>{window.removeEventListener("keydown",Ie)}},[O,s]);let[J,ae]=ua.useState({width:0,height:0}),[Q,Y]=ua.useState(1),[$,fe]=ua.useState({x:0,y:0}),P=ua.useRef(null),qe=ua.useCallback((Ie)=>{if(P.current)P.current.disconnect(),P.current=null;if(Ie!==null){let He=new ResizeObserver((Ze)=>{let Je=Ze[0];if(Je)ae({width:Je.contentRect.width,height:Je.contentRect.height})});He.observe(Ie),P.current=He}},[]),be=e.media?.pdfTranscode?.url||e.media?.original?.downloadUrl;ua.useEffect(()=>{if(!be){te("No PDF URL available"),L(!1);return}let Ie=!0;L(!0),te(null);let He=k8({url:be});return He.promise.then((Ze)=>{if(!Ie)return;A(Ze),T(Ze.numPages),C((Je)=>f&&!isNaN(f)?Math.max(1,Math.min(Ze.numPages,Math.round(f))):Je),L(!1)}).catch((Ze)=>{if(!Ie)return;console.error("Failed to load PDF:",Ze),te("Failed to load PDF document"),L(!1)}),()=>{Ie=!1,He.destroy().catch(()=>{})}},[be,f]),ua.useEffect(()=>{if(!j)return;let Ie=!0,He=null;return j.getPage(S).then((Ze)=>{if(!Ie)return;let Je=Ze.getViewport({scale:1}),$e=2,Xt=Ze.getViewport({scale:$e}),$t=document.createElement("canvas");$t.width=Xt.width,$t.height=Xt.height;let Ka=$t.getContext("2d");if(!Ka)return;if(He=Ze.render({canvasContext:Ka,viewport:Xt,canvas:$t}),!Ie){He.cancel();return}He.promise.then(()=>{if(!Ie)return;H($t.toDataURL("image/png")),N({width:Je.width,height:Je.height})}).catch((Ht)=>{if(!Ie||Ht&&typeof Ht==="object"&&"name"in Ht&&Ht.name==="RenderingCancelledException")return;console.error("Failed to render page:",Ht)})}).catch((Ze)=>{if(!Ie)return;console.error("Failed to get page:",Ze)}),()=>{if(Ie=!1,He)He.cancel()}},[j,S]);let{width:me,height:de}=J,ye=D.width,xe=D.height,Qe=1;if(me>0&&de>0&&ye>0&&xe>0)Qe=Math.min(me/ye,de/xe);ua.useEffect(()=>{if(me>0&&de>0&&ye>0&&xe>0){Y(Qe);let Ie=(me-ye*Qe)/2,He=(de-xe*Qe)/2;fe({x:Ie,y:He})}},[e.id,S,me,de,Qe,ye,xe]);let ht=(Ie)=>{let He=me/2,Ze=de/2,Je=Q*Ie;if(Je<0.01||Je>50)return;let $e=He-(He-$.x)*(Je/Q),Xt=Ze-(Ze-$.y)*(Je/Q);Y(Je),fe({x:$e,y:Xt})},Oe=()=>{Y(Qe);let Ie=(me-ye*Qe)/2,He=(de-xe*Qe)/2;fe({x:Ie,y:He})},Ge=async()=>{let Ie=e.media?.original?.key;if(!Ie||!e.id)return;try{let He=a?await Bt.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:e.id},json:{key:Ie}}):await Bt.api.files["download-url"].$post({json:{key:Ie,assetId:e.id}});if(!He.ok)return;let{url:Ze}=await He.json(),Je=document.createElement("a");Je.href=Ze,Je.download=e.name||"document.pdf",document.body.appendChild(Je),Je.click(),document.body.removeChild(Je)}catch{}},ft=[...t||[],...d];return he("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[he("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[n,I("div",{ref:qe,className:"flex-1 relative overflow-hidden",children:z?I("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 z-20",children:I("div",{className:"w-8 h-8 border-4 border-white/30 border-t-white rounded-full animate-spin"})}):ee?I("div",{className:"absolute inset-0 flex items-center justify-center text-gray-500 text-sm",children:ee}):I(c0,{width:me,height:de,mediaDimensions:D,imageUrl:M,annotations:ft,scale:Q,offset:$,onPan:fe,className:"absolute inset-0 z-0",isDrawing:h,currentTool:u,currentColor:g,onAddAnnotation:b})})]}),I(cS,{currentPage:S,totalPages:O,onPageChange:(Ie)=>{C(Ie),s?.()},zoom:Q,onZoomIn:()=>ht(1.2),onZoomOut:()=>ht(0.8),onFit:Oe,onDownload:Ge,canDownload:!!e.media?.original?.key})]})}),hS=Jz;var uS={id:"pdf",name:"PDF",match:(e)=>e.proxyType==="pdf",viewer:hS,commentsConfig:{hasTimestamp:!0,hasAnnotations:!0,hasAiBots:!0,formatTimestamp:(e)=>`P${Math.round(e)}`}};var H5=Mt(Za(),1);var Qz=H5.default.forwardRef(({file:e,shareId:t,children:a},n)=>{return H5.useImperativeHandle(n,()=>({play:()=>{},pause:()=>{},seekTo:()=>{}})),he("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[he("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[a,I("div",{className:"flex-1 flex items-center justify-center",children:I("p",{className:"text-muted-foreground",children:"Preview unavailable"})})]}),I("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:he("button",{onClick:async()=>{let i=e.media?.original?.key;if(!i||!e.id)return;try{let l=t?await Bt.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:t,fileId:e.id},json:{key:i}}):await Bt.api.files["download-url"].$post({json:{key:i,assetId:e.id}});if(!l.ok)return;let{url:f}=await l.json(),c=document.createElement("a");c.href=f,c.download="",document.body.appendChild(c),c.click(),document.body.removeChild(c)}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:[I(Ci,{size:14}),"Download"]})})]})}),mS=Qz;var N8={id:"default",name:"Default",match:()=>!0,viewer:mS,commentsConfig:{hasTimestamp:!1,hasAnnotations:!1,hasAiBots:!1}};var Zz=[uS,aA,fA];function gS(e){if(!e)return N8;return Zz.find((a)=>a.match(e))||N8}function HQ({teamId:e,projectId:t,file:a,onSaveField:n,members:s,onCommentSelect:i,hideAnnotationControl:l=!1,readOnly:f=!1,publicFields:c,isPublic:h=!1,shareId:u,currentTime:g,onTyping:b,selectedCommentId:d}){let{canEdit:j}=jS(t),{fields:A,setFields:S}=qS(),C=N2(),{ref:O,inView:T}=dS(),[M,H]=di.useState(null),[D,N]=di.useState(null),[z,L]=di.useState(!1),[ee,te]=di.useState(null),{data:J}=Ec({queryKey:["fields",t],queryFn:async()=>{let Oe=await Bt.api.projects[":projectId"].fields.$get({param:{projectId:t}});if(!Oe.ok)throw Error("Failed to fetch fields");return await Oe.json()},enabled:!!t&&!c}),{data:ae}=Ec({queryKey:["projects",t,"bots"],queryFn:async()=>{let Oe=await Bt.api.projects[":projectId"].bots.$get({param:{projectId:t}});if(!Oe.ok)throw Error("Failed to fetch bots");return await Oe.json()},enabled:!!t&&!f}),Q=gS(a),$=Q?.commentsConfig?.hasAiBots?ae||[]:[];di.useEffect(()=>{if(c)S(c,t);else if(J)S(J,t)},[J,c,t,S]);let{data:fe,fetchNextPage:P,hasNextPage:qe}=pS({queryKey:h?["shares",u,"files",a?.id,"comments"]:["files",a?.id,"comments"],queryFn:async({pageParam:Oe})=>{if(h){let Ge=localStorage.getItem(`share_pwd_${u}`)||"",ft=await Bt.api.shares[":shareId"].files[":fileId"].comments.$get({param:{shareId:u,fileId:a.id},query:{after:Oe}},{headers:{"x-share-password":Ge}});if(!ft.ok)throw Error("Failed to fetch comments");return await ft.json()}else{let Ge=await Bt.api.files[":fileId"].comments.$get({param:{fileId:a.id},query:{after:Oe}});if(!Ge.ok)throw Error("Failed to fetch comments");return await Ge.json()}},enabled:!!a?.id&&(!h||!!u),initialPageParam:"",refetchInterval:2000,getNextPageParam:(Oe)=>Oe.pageInfo?.cursor||void 0}),{mutate:be}=Wf({mutationFn:async({text:Oe,attachmentIds:Ge,annotations:ft,replyToId:Ie,guestUserId:He,second:Ze})=>{if(h){let Je=localStorage.getItem(`share_pwd_${u}`)||"",$e=await Bt.api.shares[":shareId"].files[":fileId"].comments.$post({param:{shareId:u,fileId:a.id},json:{message:Oe,attachmentIds:Ge,replyToId:Ie??void 0,annotations:ft,second:Ze??void 0}},{headers:{"x-share-password":Je,...He?{"x-guest-user-id":He}:{}}});if(!$e.ok)throw Error("Failed to create comment");return await $e.json()}else{let Je=await Bt.api.files[":fileId"].comments.$post({param:{fileId:a.id},json:{message:Oe,attachmentIds:Ge,replyToId:Ie??void 0,annotations:ft,second:Ze??void 0}});if(!Je.ok)throw Error("Failed to create comment");return await Je.json()}},onSuccess:()=>{C.invalidateQueries({queryKey:h?["shares",u,"files",a?.id,"comments"]:["files",a?.id,"comments"]})}});di.default.useEffect(()=>{if(T&&qe)P()},[T,P,qe]);let me=di.useMemo(()=>{return(a?.fieldValues||[]).reduce((Oe,Ge)=>{return Oe[Ge.fieldId]=Ge,Oe},{})},[a?.fieldValues]),de=di.useMemo(()=>{return[...A].sort((Oe,Ge)=>{let ft=Oe.config?.name?.toLowerCase()||"",Ie=Ge.config?.name?.toLowerCase()||"";if(ft<Ie)return-1;if(ft>Ie)return 1;return 0})},[A]),ye=fe?.pages.flatMap((Oe)=>Oe.data??[])??[],xe=async(Oe,Ge,ft,Ie,He)=>{if(!a?.id)return;if(h){console.log("[handleSendMessage] checking auth status");let Ze=await Bt.api.me.$get(),{id:Je}=await Ze.json();if(console.log("[handleSendMessage] loggedInUserId:",Je),!Je){let $e=localStorage.getItem("guest_user_id");if(console.log("[handleSendMessage] guestUserId from storage:",$e),!$e){console.log("[handleSendMessage] no guest ID, opening popup"),te({text:Oe,attachmentIds:Ge,annotations:ft,replyToId:Ie,second:He}),L(!0);return}be({text:Oe,attachmentIds:Ge,annotations:ft,replyToId:Ie,guestUserId:$e,second:He})}else be({text:Oe,attachmentIds:Ge,annotations:ft,replyToId:Ie,second:He})}else be({text:Oe,attachmentIds:Ge,annotations:ft,replyToId:Ie,second:He});H(null)},Qe=(Oe)=>{if(console.log("[handleGuestSuccess] guestUserId:",Oe),ee)be({...ee,guestUserId:Oe}),te(null),H(null)},ht=(Oe)=>{let Ge=s.find((ft)=>ft.id===Oe);if(Ge)return Ge;if(ae){let ft=ae.find((Ie)=>Ie.id===Oe);if(ft)return{id:ft.id,name:ft.name,role:"bot"}}return{id:"unknown",name:"Unknown",role:"unknown"}};if(!a)return I("div",{className:"flex h-full items-center justify-center p-8 text-center bg-background",children:he("div",{className:"space-y-2",children:[I("p",{className:"text-sm font-medium text-foreground",children:Le.no_item_selected()}),I("p",{className:"text-xs text-muted-foreground",children:Le.select_file_to_view_details()})]})});return he("div",{className:"bg-background h-full flex flex-col overflow-hidden",children:[D&&D.proxyType==="image"&&he("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:()=>N(null),children:[I("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white bg-white/10 hover:bg-white/20 rounded-full p-2 transition-colors z-50",children:I(_o,{className:"w-8 h-8"})}),I("div",{className:"w-full h-full flex items-center justify-center p-2",children:I("img",{src:D.url,alt:"Enlarged view",className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:()=>N(null)})})]}),he(bS,{defaultValue:"comments",className:"p-1 flex-1 flex flex-col px-2 min-h-0",children:[he(wS,{className:"w-full shrink-0",children:[I(z8,{value:"comments",className:"flex-1",children:Le.comments()}),I(z8,{value:"fields",className:"flex-1",children:Le.fields()})]}),he(E8,{value:"comments",className:"flex-1 flex flex-col overflow-hidden min-h-0 mt-0",children:[I(I8,{className:"flex-1 min-h-0 [&>div>div]:block!",children:he("div",{className:"space-y-4",children:[ye.map((Oe)=>he("div",{children:[I(q3,{teamId:e,message:Oe,getUser:ht,onReply:H,onViewAttachment:N,hasReplies:!!Oe.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===Oe.id,onSelect:()=>{i?.(Oe)}}),Oe.replies?.map((Ge,ft)=>I("div",{children:I(q3,{teamId:e,isReply:!0,message:Ge,getUser:ht,onReply:H,onViewAttachment:N,hasReplies:!1,isLastReply:ft===(Oe.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===Ge.id,onSelect:()=>{i?.(Ge)}})},Ge.id))]},Oe.id)),I("div",{ref:O})]})}),(!f||h)&&I("div",{className:"mt-4 shrink-0",children:I(n7,{isOpen:z,onClose:()=>L(!1),onSuccess:Qe,children:I(k3,{projectId:t,onSendMessage:xe,replyingTo:M,onCancelReply:()=>H(null),bots:$,hideAnnotationControl:l,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})})})]}),I(E8,{value:"fields",className:"flex-1 flex flex-col overflow-hidden min-h-0 mt-4",children:I(I8,{className:"flex-1 px-4 min-h-0 [&>div>div]:block!",children:de&&de.length>0&&I("div",{className:"space-y-4 pb-4",children:de.map((Oe)=>he("div",{className:"space-y-1",children:[I("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:Oe.config?.name}),I("div",{className:"min-h-[28px]",children:I(vS,{config:Oe.config,value:me[Oe.id]?.value,onSave:j?(Ge)=>n(Oe.id,Ge):void 0,readOnly:f||Oe.readOnly||!j})})]},Oe.id))})})})]})]})}
307
- export{sv as n,$z as o,sA as p,gS as q,HQ as r};