@accounter/client
Version:
Accounter client application
159 lines • 1.53 MB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html2canvas-pro.esm-Byf5I_tX.js","assets/dist-ypP48_Ax.js","assets/index.es-Ckt5H9Kz.js","assets/dist-DY51vb3q.js","assets/defineProperty-CHyAdSol.js","assets/typeof-B5XbjTb1.js"])))=>i.map(i=>d[i]);
import{a as e,n as t,r as n,s as r,t as i}from"./dist-ypP48_Ax.js";import{i as a,o,t as s}from"./utils-CbS-oR5I.js";import{$o as c,A as l,Ai as u,At as d,Bi as f,Br as p,Cs as m,Da as h,Di as g,Do as _,E as v,Ei as y,F as b,Fn as x,Gn as S,Hn as C,Jo as w,Jr as T,Kr as E,L as D,Li as O,Ln as k,Lr as A,Lt as j,M,Oi as N,P,Pt as F,Qo as I,Ri as L,S as R,Sr as z,Ss as B,T as V,Ta as ee,V as te,Vr as ne,Wr as re,Xo as H,Ya as ie,Yr as U,Zo as W,_a as ae,_o as G,_s as oe,as as se,at as ce,b as le,br as ue,bs as de,bt as fe,cs as pe,do as me,dr as he,ds as ge,es as _e,fr as ve,fs as ye,g as be,gi as xe,gs as Se,hs as Ce,ir as we,is as Te,ji as Ee,jo as De,ki as Oe,lr as ke,ls as Ae,mo as je,mr as Me,ms as Ne,no as Pe,nr as Fe,ns as Ie,os as Le,po as Re,ps as ze,qr as Be,r as K,rr as Ve,rs as He,s as Ue,so as We,ss as Ge,t as Ke,to as qe,tr as Je,ts as Ye,ur as Xe,us as Ze,va as Qe,vi as $e,vn as et,vs as tt,wo as nt,x as rt,xa as it,xn as at,xr as ot,xs as st,ya as ct,yi as lt,ys as ut,z as dt,zr as ft}from"./error-handling-Ba16dd60.js";import{n as pt,t as mt}from"./dist-DY51vb3q.js";import{C as ht,a as gt,r as _t,s as vt,t as yt}from"./routes-BB3QY9SQ.js";import{n as bt}from"./auth0-react.esm-BPcKmtgZ.js";import{$ as xt,A as St,C as Ct,D as wt,E as Tt,F as Et,G as Dt,H as Ot,I as kt,J as At,K as jt,L as Mt,M as Nt,N as Pt,O as Ft,P as It,Q as Lt,R as Rt,S as zt,T as Bt,U as Vt,V as Ht,W as Ut,X as Wt,Y as Gt,Z as Kt,a as qt,at as Jt,b as Yt,c as Xt,d as Zt,dt as Qt,et as $t,f as en,ft as tn,g as nn,gt as rn,h as an,ht as on,i as sn,j as cn,k as ln,l as un,lt as dn,m as fn,mt as pn,n as mn,nt as hn,o as gn,p as _n,pt as vn,q as yn,r as bn,rt as xn,s as Sn,st as Cn,t as wn,tt as Tn,u as En,ut as Dn,v as On,w as kn,x as An,y as jn,z as Mn}from"./select-CGZdhlc6.js";import{_ as Nn,a as Pn,b as Fn,d as In,f as Ln,g as Rn,h as zn,i as Bn,l as Vn,m as Hn,n as Un,o as Wn,p as Gn,r as Kn,t as qn,v as Jn,x as Yn,y as Xn}from"./separator-PpapAwKS.js";import{c as Zn,i as Qn,n as $n,o as er,s as tr,t as q}from"./button-DUNsVBiu.js";import{$c as nr,$l as rr,Al as ir,Bc as ar,Cn as or,Dl as sr,El as J,Fl as cr,Gc as lr,Gl as ur,Hc as dr,Ht as fr,Jc as pr,Jl as mr,Kc as hr,Kl as gr,Ln as _r,Ml as vr,Nl as yr,Nt as br,Ol as Y,Pl as xr,Ql as Sr,Rc as Cr,Rt as wr,Sl as Tr,Tl as Er,Uc as Dr,Ul as Or,Vc as kr,Wc as Ar,Wl as jr,Xc as Mr,Xl as Nr,Xn as Pr,Yc as Fr,Yl as Ir,Zc as Lr,Zl as Rr,a as zr,al as Br,au as Vr,c as Hr,cl as Ur,cu as Wr,d as Gr,dl as Kr,dn as qr,dr as Jr,du as Yr,en as Xr,eu as Zr,f as Qr,fu as $r,i as ei,il as ti,iu as ni,jl as ri,jt as ii,kl as ai,lu as oi,ml as si,n as ci,nl as li,nu as ui,o as di,ol as fi,ou as pi,qc as mi,ql as hi,r as gi,rl as _i,ru as vi,s as yi,sl as bi,su as xi,t as Si,tl as Ci,tu as wi,ul as X,ur as Ti,uu as Ei,wl as Di}from"./table-Bh5lVpZi.js";import{a as Oi,n as ki,o as Ai,r as ji,t as Mi}from"./card-DR4aRSHr.js";import{t as Ni}from"./html2canvas-pro.esm-Byf5I_tX.js";import{t as Pi}from"./typeof-B5XbjTb1.js";var Fi=rn(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ii=rn(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),Li=rn(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ri=rn(`calendar`,[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),zi=rn(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Bi=rn(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Vi=rn(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Hi=rn(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Ui=rn(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Wi=rn(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Gi=rn(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),Ki=rn(`combine`,[[`path`,{d:`M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`1l7d7l`}],[`path`,{d:`M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`9955pe`}],[`path`,{d:`m7 15 3 3`,key:`4hkfgk`}],[`path`,{d:`m7 21 3-3H5a2 2 0 0 1-2-2v-2`,key:`1xljwe`}],[`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1cdgtw`}],[`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`,key:`zi3rio`}]]),qi=rn(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ji=rn(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),Yi=rn(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Xi=rn(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Zi=rn(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Qi=rn(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),$i=rn(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ea=rn(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ta=rn(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),na=rn(`gift`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]),ra=rn(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ia=rn(`hand-coins`,[[`path`,{d:`M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17`,key:`geh8rc`}],[`path`,{d:`m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9`,key:`1fto5m`}],[`path`,{d:`m2 16 6 6`,key:`1pfhp9`}],[`circle`,{cx:`16`,cy:`9`,r:`2.9`,key:`1n0dlu`}],[`circle`,{cx:`6`,cy:`5`,r:`3`,key:`151irh`}]]),aa=rn(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),oa=rn(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),sa=rn(`list-plus`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]),ca=rn(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),la=rn(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),ua=rn(`map-plus`,[[`path`,{d:`m11 19-1.106-.552a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0l4.212 2.106a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619V12`,key:`svfegj`}],[`path`,{d:`M15 5.764V12`,key:`1ocw4k`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),da=rn(`merge`,[[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}],[`path`,{d:`M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22`,key:`1hyw0i`}],[`path`,{d:`m20 22-5-5`,key:`1m27yz`}]]),fa=rn(`panel-top-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m9 16 3-3 3 3`,key:`1idcnm`}]]),pa=rn(`panel-top-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`m15 14-3 3-3-3`,key:`g215vf`}]]),ma=rn(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),ha=rn(`piggy-bank`,[[`path`,{d:`M11 17h3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a3.16 3.16 0 0 0 2-2h1a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a5 5 0 0 0-2-4V3a4 4 0 0 0-3.2 1.6l-.3.4H11a6 6 0 0 0-6 6v1a5 5 0 0 0 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1z`,key:`1piglc`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M2 8v1a2 2 0 0 0 2 2h1`,key:`1env43`}]]),ga=rn(`plane`,[[`path`,{d:`M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z`,key:`1v9wt8`}]]),_a=rn(`printer`,[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]),va=rn(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),ya=rn(`refresh-ccw-dot`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),ba=rn(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),xa=rn(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Sa=rn(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ca=rn(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),wa=rn(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Ta=rn(`square-x`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Ea=rn(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Da=rn(`trending-up-down`,[[`path`,{d:`M14.828 14.828 21 21`,key:`ar5fw7`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`m21 3-9 9-4-4-6 6`,key:`1h02xo`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}]]),Oa=rn(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),ka=rn(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Aa=rn(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]),ja=rn(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),Ma=rn(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Na=rn(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Z=r(o(),1),Q=a(),Pa=Object.defineProperty,Fa=(e,t)=>Pa(e,`name`,{value:t,configurable:!0}),Ia=`Checkbox`,[La,Ra]=Jt(Ia),[za,Ba]=La(Ia);function Va(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Tn({prop:n,defaultProp:i??!1,onChange:c,caller:Ia}),[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useRef(!1),[y,b]=Z.useReducer(e=>e+1,0),x=!m||!!o||!!m.closest(`form`),S={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:!Xa(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,Q.jsx)(za,{scope:t,...S,children:Ya(d)?d(S):r})}Fa(Va,`CheckboxProvider`);var Ha=`CheckboxTrigger`,Ua=Z.forwardRef(Fa(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=Ba(Ha,e),g=tr(i,u),_=Z.useRef(c);return Z.useEffect(()=>{let e=a?.form;if(e){let t=Fa(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,Q.jsx)(Cn.button,{type:`button`,role:`checkbox`,"aria-checked":Xa(c)?`mixed`:c,"aria-required":l,"data-state":Za(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:xn(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:xn(n,e=>{p(),d(e=>Xa(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),Wa=Z.forwardRef(Fa(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(Va,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ua,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Q.jsx)(Ja,{__scopeCheckbox:n})]})})},`Checkbox`)),Ga=`CheckboxIndicator`,Ka=Z.forwardRef(Fa(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=Ba(Ga,n);return(0,Q.jsx)($t,{present:r||Xa(a.checked)||a.checked===!0,children:(0,Q.jsx)(Cn.span,{"data-state":Za(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),qa=`CheckboxBubbleInput`,Ja=Z.forwardRef(Fa(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=Ba(qa,e),g=tr(r,h),_=cn(i),v=Z.useRef(!1),y=Z.useRef(s),b=Z.useRef(o);Z.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=Xa(s),n.call(e,!Xa(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=Z.useRef(!Xa(s)&&s);return(0,Q.jsx)(Cn.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:xn(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function Ya(e){return typeof e==`function`}Fa(Ya,`isFunction`);function Xa(e){return e===`indeterminate`}Fa(Xa,`isIndeterminate`);function Za(e){return Xa(e)?`indeterminate`:e?`checked`:`unchecked`}Fa(Za,`getState`);var Qa=Object.defineProperty,$a=(e,t)=>Qa(e,`name`,{value:t,configurable:!0}),eo=`Popover`,[to,no]=Jt(eo,[Yt]),ro=Yt(),[io,ao]=to(eo),oo=$a(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ro(t),c=Z.useRef(null),[l,u]=Z.useState(!1),[d,f]=Tn({prop:r,defaultProp:i??!1,onChange:a,caller:eo});return(0,Q.jsx)(jn,{...s,children:(0,Q.jsx)(io,{scope:t,contentId:xt(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Z.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Z.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Z.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),so=`PopoverTrigger`,co=Z.forwardRef($a(function(e,t){let{__scopePopover:n,...r}=e,i=ao(so,n),a=ro(n),o=tr(t,i.triggerRef),s=(0,Q.jsx)(Cn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":bo(i.open),...r,ref:o,onClick:xn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Q.jsx)(nn,{asChild:!0,...a,children:s})},`PopoverTrigger`)),lo=`PopoverPortal`,[uo,fo]=to(lo,{forceMount:void 0}),po=$a(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ao(lo,t);return(0,Q.jsx)(uo,{scope:t,forceMount:n,children:(0,Q.jsx)($t,{present:n||a.open,children:(0,Q.jsx)(At,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),mo=`PopoverContent`,ho=Z.forwardRef($a(function(e,t){let n=fo(mo,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=ao(mo,e.__scopePopover);return(0,Q.jsx)($t,{present:r||a.open,children:a.modal?(0,Q.jsx)(_o,{...i,ref:t}):(0,Q.jsx)(vo,{...i,ref:t})})},`PopoverContent`)),go=Qn(`PopoverContent.RemoveScroll`),_o=Z.forwardRef($a(function(e,t){let n=ao(mo,e.__scopePopover),r=Z.useRef(null),i=tr(t,r),a=Z.useRef(!1);return Z.useEffect(()=>{let e=r.current;if(e)return Ht(e)},[]),(0,Q.jsx)(Ot,{as:go,allowPinchZoom:!0,children:(0,Q.jsx)(yo,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xn(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:xn(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:xn(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),vo=Z.forwardRef($a(function(e,t){let n=ao(mo,e.__scopePopover),r=Z.useRef(!1),i=Z.useRef(!1);return(0,Q.jsx)(yo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),yo=Z.forwardRef($a(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=ao(mo,n),p=ro(n);return yn(),(0,Q.jsx)(Gt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Q.jsx)(Wt,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,Q.jsx)(On,{"data-state":bo(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function bo(e){return e?`open`:`closed`}$a(bo,`getState`);var xo=oo,So=co,Co=po,wo=ho,To=Object.defineProperty,Eo=(e,t)=>To(e,`name`,{value:t,configurable:!0});function Do(e,t){return Z.useReducer((e,n)=>t[e][n]??e,e)}Eo(Do,`useStateMachine`);var Oo=`ScrollArea`,[ko,Ao]=Jt(Oo),[jo,Mo]=ko(Oo),No=Z.forwardRef(Eo(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=Z.useState(null),[l,u]=Z.useState(null),[d,f]=Z.useState(null),[p,m]=Z.useState(null),[h,g]=Z.useState(null),[_,v]=Z.useState(0),[y,b]=Z.useState(0),[x,S]=Z.useState(!1),[C,w]=Z.useState(!1),T=tr(t,c),E=Lt(i);return(0,Q.jsx)(jo,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:w,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,Q.jsx)(Cn.div,{dir:E,...o,ref:T,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})},`ScrollArea`)),Po=`ScrollAreaViewport`,Fo=Z.forwardRef(Eo(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=Mo(Po,n),s=Z.useRef(null),c=tr(t,s,o.onViewportChange);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Io,{nonce:i}),(0,Q.jsx)(Cn.div,{"data-radix-scroll-area-viewport":``,...a,ref:c,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,Q.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),Io=Z.memo(Eo(function({nonce:e}){return(0,Q.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),Lo=`ScrollAreaScrollbar`,Ro=Z.forwardRef(Eo(function(e,t){let{forceMount:n,...r}=e,i=Mo(Lo,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return Z.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,Q.jsx)(zo,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,Q.jsx)(Bo,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,Q.jsx)(Vo,{...r,ref:t,forceMount:n}):i.type===`always`?(0,Q.jsx)(Ho,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),zo=Z.forwardRef(Eo(function(e,t){let{forceMount:n,...r}=e,i=Mo(Lo,e.__scopeScrollArea),[a,o]=Z.useState(!1);return Z.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=Eo(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=Eo(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,Q.jsx)($t,{present:n||a,children:(0,Q.jsx)(Vo,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),Bo=Z.forwardRef(Eo(function(e,t){let{forceMount:n,...r}=e,i=Mo(Lo,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=cs(()=>c(`SCROLL_END`),100),[s,c]=Do(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return Z.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),Z.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=Eo(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,Q.jsx)($t,{present:n||s!==`hidden`,children:(0,Q.jsx)(Ho,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:xn(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:xn(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),Vo=Z.forwardRef(Eo(function(e,t){let n=Mo(Lo,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=Z.useState(!1),s=e.orientation===`horizontal`,c=cs(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return ls(n.viewport,c),ls(n.content,c),(0,Q.jsx)($t,{present:r||a,children:(0,Q.jsx)(Ho,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),Ho=Z.forwardRef(Eo(function(e,t){let{orientation:n=`vertical`,...r}=e,i=Mo(Lo,e.__scopeScrollArea),a=Z.useRef(null),o=Z.useRef(0),[s,c]=Z.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=ts(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:Eo(e=>a.current=e,`onThumbChange`),onThumbPointerUp:Eo(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:Eo(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return rs(e,o.current,s,t)}return Eo(d,`getScrollPosition`),n===`horizontal`?(0,Q.jsx)(Uo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=is(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,Q.jsx)(Wo,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=is(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),Uo=Z.forwardRef(Eo(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=Mo(Lo,e.__scopeScrollArea),[o,s]=Z.useState(),c=Z.useRef(null),l=tr(t,c,a.onScrollbarXChange);return Z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,Q.jsx)(qo,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":ns(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),os(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:es(o.paddingLeft),paddingEnd:es(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),Wo=Z.forwardRef(Eo(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=Mo(Lo,e.__scopeScrollArea),[o,s]=Z.useState(),c=Z.useRef(null),l=tr(t,c,a.onScrollbarYChange);return Z.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,Q.jsx)(qo,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":ns(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),os(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:es(o.paddingTop),paddingEnd:es(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[Go,Ko]=ko(Lo),qo=Z.forwardRef(Eo(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=Mo(Lo,n),[m,h]=Z.useState(null),g=tr(t,h),_=Z.useRef(null),v=Z.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Kt(u),S=Kt(c),C=cs(d,10);function w(e){if(_.current){let t=e.clientX-_.current.left,n=e.clientY-_.current.top;l({x:t,y:n})}}return Eo(w,`handleDragScroll`),Z.useEffect(()=>{let e=Eo(e=>{let t=e.target;m?.contains(t)&&x(e,b)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),Z.useEffect(S,[r,S]),ls(m,C),ls(p.content,C),(0,Q.jsx)(Go,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Kt(a),onThumbPointerUp:Kt(o),onThumbPositionChange:S,onThumbPointerDown:Kt(s),children:(0,Q.jsx)(Cn.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:xn(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),w(e))}),onPointerMove:xn(e.onPointerMove,w),onPointerUp:xn(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})},`ScrollAreaScrollbarImpl`)),Jo=`ScrollAreaThumb`,Yo=Z.forwardRef(Eo(function(e,t){let{forceMount:n,...r}=e,i=Ko(Jo,e.__scopeScrollArea);return(0,Q.jsx)($t,{present:n||i.hasThumb,children:(0,Q.jsx)(Xo,{ref:t,...r})})},`ScrollAreaThumb`)),Xo=Z.forwardRef(Eo(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=Mo(Jo,n),o=Ko(Jo,n),{onThumbPositionChange:s}=o,c=tr(t,o.onThumbChange),l=Z.useRef(void 0),u=cs(()=>{l.current&&=(l.current(),void 0)},100);return Z.useEffect(()=>{let e=a.viewport;if(e){let t=Eo(()=>{if(u(),!l.current){let t=ss(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,Q.jsx)(Cn.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:xn(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:xn(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),Zo=`ScrollAreaCorner`,Qo=Z.forwardRef(Eo(function(e,t){let n=Mo(Zo,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,Q.jsx)($o,{...e,ref:t}):null},`ScrollAreaCorner`)),$o=Z.forwardRef(Eo(function(e,t){let{__scopeScrollArea:n,...r}=e,i=Mo(Zo,n),[a,o]=Z.useState(0),[s,c]=Z.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return ls(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),ls(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),Z.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,Q.jsx)(Cn.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function es(e){return e?parseInt(e,10):0}Eo(es,`toInt`);function ts(e,t){let n=e/t;return isNaN(n)?0:n}Eo(ts,`getThumbRatio`);function ns(e){let t=ts(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}Eo(ns,`getThumbSize`);function rs(e,t,n,r=`ltr`){let i=ns(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return as([c,l],d)(e)}Eo(rs,`getScrollPositionFromPointer`);function is(e,t,n=`ltr`){let r=ns(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=n===`ltr`?[0,o]:[o*-1,0],l=an(e,c);return as([0,o],[0,s])(l)}Eo(is,`getThumbOffsetFromScroll`);function as(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}Eo(as,`linearScale`);function os(e,t){return e>0&&e<t}Eo(os,`isScrollingWithinScrollbarBounds`);var ss=Eo((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return Eo((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function cs(e,t){let n=Kt(e),r=Z.useRef(0);return Z.useEffect(()=>()=>window.clearTimeout(r.current),[]),Z.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}Eo(cs,`useDebounceCallback`);function ls(e,t){let n=Kt(t);hn(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}Eo(ls,`useResizeObserver`);var us=No,ds=Fo,fs=Qo,ps=Object.defineProperty,ms=(e,t)=>ps(e,`name`,{value:t,configurable:!0}),hs=`Switch`,[gs,_s]=Jt(hs),[vs,ys]=gs(hs);function bs(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Tn({prop:n,defaultProp:i??!1,onChange:c,caller:hs}),[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useRef(!1),[y,b]=Z.useReducer(e=>e+1,0),x={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,Q.jsx)(vs,{scope:t,...x,children:Os(d)?d(x):r})}ms(bs,`SwitchProvider`);var xs=`SwitchTrigger`,Ss=Z.forwardRef(ms(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=ys(xs,e),g=tr(r,u),_=Z.useRef(c);return Z.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=ms(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,Q.jsx)(Cn.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":ks(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:g,onClick:xn(t,e=>{p(),d(e=>!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`SwitchTrigger`)),Cs=Z.forwardRef(ms(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(bs,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ss,{...d,ref:t,__scopeSwitch:n}),e&&(0,Q.jsx)(Ds,{__scopeSwitch:n})]})})},`Switch`)),ws=`SwitchThumb`,Ts=Z.forwardRef(ms(function(e,t){let{__scopeSwitch:n,...r}=e,i=ys(ws,n);return(0,Q.jsx)(Cn.span,{"data-state":ks(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),Es=`SwitchBubbleInput`,Ds=Z.forwardRef(ms(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=ys(Es,e),g=tr(r,h),_=cn(i),v=Z.useRef(!1),y=Z.useRef(s),b=Z.useRef(o);Z.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=Z.useRef(s);return(0,Q.jsx)(Cn.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:xn(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function Os(e){return typeof e==`function`}ms(Os,`isFunction`);function ks(e){return e?`checked`:`unchecked`}ms(ks,`getState`);var As=Object.defineProperty,js=(e,t)=>As(e,`name`,{value:t,configurable:!0}),Ms=`Tabs`,[Ns,Ps]=Jt(Ms,[Jn]),Fs=Jn(),[Is,Ls]=Ns(Ms),Rs=Z.forwardRef(js(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Lt(s),[d,f]=Tn({prop:r,onChange:i,defaultProp:a??``,caller:Ms});return(0,Q.jsx)(Is,{scope:n,baseId:xt(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,Q.jsx)(Cn.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),zs=`TabsList`,Bs=Z.forwardRef(js(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=Ls(zs,n),o=Fs(n);return(0,Q.jsx)(Nn,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,Q.jsx)(Cn.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),Vs=`TabsTrigger`,Hs=Z.forwardRef(js(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Ls(Vs,n),s=Fs(n),c=Gs(o.baseId,r),l=Ks(o.baseId,r),u=r===o.value;return(0,Q.jsx)(Rn,{asChild:!0,...s,focusable:!i,active:u,children:(0,Q.jsx)(Cn.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:xn(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:xn(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:xn(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),Us=`TabsContent`,Ws=Z.forwardRef(js(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Ls(Us,n),c=Gs(s.baseId,r),l=Ks(s.baseId,r),u=r===s.value,d=Z.useRef(u);return Z.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Q.jsx)($t,{present:i||u,children:({present:n})=>(0,Q.jsx)(Cn.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function Gs(e,t){return`${e}-trigger-${t}`}js(Gs,`makeTriggerId`);function Ks(e,t){return`${e}-content-${t}`}js(Ks,`makeContentId`);var qs=Rs,Js=Bs,Ys=Hs,Xs=Ws;function Zs({className:e,...t}){return(0,Q.jsx)(`div`,{className:s(`animate-pulse rounded-md bg-gray-900/10 dark:bg-gray-50/10`,e),...t})}function Qs(e,t,n){let r=Wr(e,n?.in);return isNaN(t)?oi(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function $s(e,t,n){let r=Wr(e,n?.in);if(isNaN(t))return oi(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=oi(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}function ec(e,t,n){return Qs(e,t*7,n)}function tc(e,t,n){return $s(e,t*12,n)}function nc(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=oi.bind(null,e));let t=Wr(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),oi(r,n||NaN)}function rc(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=oi.bind(null,e));let t=Wr(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),oi(r,n||NaN)}function ic(e,t,n){let[r,i]=vi(n?.in,e,t);return+ui(r)==+ui(i)}function ac(e,t,n){let[r,i]=vi(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function oc(e,t,n){let[r,i]=vi(n?.in,e,t),a=sc(r,i),o=Math.abs(wi(r,i));r.setDate(r.getDate()-a*o);let s=a*(o-Number(sc(r,i)===-a));return s===0?0:s}function sc(e,t){let n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function cc(e,t){let n=Wr(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function lc(e,t){let[n,r]=vi(e,t.start,t.end);return{start:n,end:r}}function uc(e,t){let{start:n,end:r}=lc(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(oi(n,o)),o.setMonth(o.getMonth()+s);return i?c.reverse():c}function dc(e,t){let n=Wr(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function fc(e,t){let n=Wr(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function pc(e,t){let{start:n,end:r}=lc(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setMonth(0,1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(oi(n,o)),o.setFullYear(o.getFullYear()+s);return i?c.reverse():c}function mc(e,t){let n=xi(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Wr(e,t?.in),a=i.getDay(),o=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function hc(e,t){return mc(e,{...t,weekStartsOn:1})}function gc(e,t){let n=Wr(e,t?.in),r=n.getFullYear(),i=n.getMonth(),a=oi(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function _c(){return Object.assign({},xi())}function vc(e,t){let n=Wr(e,t?.in).getDay();return n===0?7:n}function yc(e,t){return Wr(e,t?.in).getMonth()}function bc(e,t){return Wr(e,t?.in).getFullYear()}function xc(e,t){return+Wr(e)>+Wr(t)}function Sc(e,t){return+Wr(e)<+Wr(t)}function Cc(e,t){let n=wc(t)?new t(0):oi(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function wc(e){return typeof e==`function`&&e.prototype?.constructor===e}var Tc=10,Ec=class{subPriority=0;validate(e,t){return!0}},Dc=class extends Ec{constructor(e,t,n,r,i){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=r,i&&(this.subPriority=i)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}},Oc=class extends Ec{priority=Tc;subPriority=-1;constructor(e,t){super(),this.context=e||(e=>oi(t,e))}set(e,t){return t.timestampIsSet?e:oi(e,Cc(e,this.context))}},kc=class{run(e,t,n,r){let i=this.parse(e,t,n,r);return i?{setter:new Dc(i.value,this.validate,this.set,this.priority,this.subPriority),rest:i.rest}:null}validate(e,t,n){return!0}},Ac=class extends kc{priority=140;parse(e,t,n){switch(t){case`G`:case`GG`:case`GGG`:return n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`});case`GGGGG`:return n.era(e,{width:`narrow`});default:return n.era(e,{width:`wide`})||n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`})}}set(e,t,n){return t.era=n,e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`R`,`u`,`t`,`T`]},jc={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},Mc={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function Nc(e,t){return e&&{value:t(e.value),rest:e.rest}}function Pc(e,t){let n=t.match(e);return n?{value:parseInt(n[0],10),rest:t.slice(n[0].length)}:null}function Fc(e,t){let n=t.match(e);if(!n)return null;if(n[0]===`Z`)return{value:0,rest:t.slice(1)};let r=n[1]===`+`?1:-1,i=n[2]?parseInt(n[2],10):0,a=n[3]?parseInt(n[3],10):0,o=n[5]?parseInt(n[5],10):0;return{value:r*(i*Ei+a*Yr+o*$r),rest:t.slice(n[0].length)}}function Ic(e){return Pc(jc.anyDigitsSigned,e)}function Lc(e,t){switch(e){case 1:return Pc(jc.singleDigit,t);case 2:return Pc(jc.twoDigits,t);case 3:return Pc(jc.threeDigits,t);case 4:return Pc(jc.fourDigits,t);default:return Pc(RegExp(`^\\d{1,`+e+`}`),t)}}function Rc(e,t){switch(e){case 1:return Pc(jc.singleDigitSigned,t);case 2:return Pc(jc.twoDigitsSigned,t);case 3:return Pc(jc.threeDigitsSigned,t);case 4:return Pc(jc.fourDigitsSigned,t);default:return Pc(RegExp(`^-?\\d{1,`+e+`}`),t)}}function zc(e){switch(e){case`morning`:return 4;case`evening`:return 17;case`pm`:case`noon`:case`afternoon`:return 12;default:return 0}}function Bc(e,t){let n=t>0,r=n?t:1-t,i;if(r<=50)i=e||100;else{let t=r+50,n=Math.trunc(t/100)*100,a=e>=t%100;i=e+n-(a?100:0)}return n?i:1-i}function Vc(e){return e%400==0||e%4==0&&e%100!=0}var Hc=class extends kc{priority=130;incompatibleTokens=[`Y`,`R`,`u`,`w`,`I`,`i`,`e`,`c`,`t`,`T`];parse(e,t,n){let r=e=>({year:e,isTwoDigitYear:t===`yy`});switch(t){case`y`:return Nc(Lc(4,e),r);case`yo`:return Nc(n.ordinalNumber(e,{unit:`year`}),r);default:return Nc(Lc(t.length,e),r)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n){let r=e.getFullYear();if(n.isTwoDigitYear){let t=Bc(n.year,r);return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}let i=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setFullYear(i,0,1),e.setHours(0,0,0,0),e}},Uc=class extends kc{priority=130;parse(e,t,n){let r=e=>({year:e,isTwoDigitYear:t===`YY`});switch(t){case`Y`:return Nc(Lc(4,e),r);case`Yo`:return Nc(n.ordinalNumber(e,{unit:`year`}),r);default:return Nc(Lc(t.length,e),r)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n,r){let i=Ir(e,r);if(n.isTwoDigitYear){let t=Bc(n.year,i);return e.setFullYear(t,0,r.firstWeekContainsDate),e.setHours(0,0,0,0),pi(e,r)}let a=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setFullYear(a,0,r.firstWeekContainsDate),e.setHours(0,0,0,0),pi(e,r)}incompatibleTokens=[`y`,`R`,`u`,`Q`,`q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]},Wc=class extends kc{priority=130;parse(e,t){return Rc(t===`R`?4:t.length,e)}set(e,t,n){let r=oi(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),Vr(r)}incompatibleTokens=[`G`,`y`,`Y`,`u`,`Q`,`q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]},Gc=class extends kc{priority=130;parse(e,t){return Rc(t===`u`?4:t.length,e)}set(e,t,n){return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`G`,`y`,`Y`,`R`,`w`,`I`,`i`,`e`,`c`,`t`,`T`]},Kc=class extends kc{priority=120;parse(e,t,n){switch(t){case`Q`:case`QQ`:return Lc(t.length,e);case`Qo`:return n.ordinalNumber(e,{unit:`quarter`});case`QQQ`:return n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`});case`QQQQQ`:return n.quarter(e,{width:`narrow`,context:`formatting`});default:return n.quarter(e,{width:`wide`,context:`formatting`})||n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`M`,`L`,`w`,`I`,`d`,`D`,`i`,`e`,`c`,`t`,`T`]},qc=class extends kc{priority=120;parse(e,t,n){switch(t){case`q`:case`qq`:return Lc(t.length,e);case`qo`:return n.ordinalNumber(e,{unit:`quarter`});case`qqq`:return n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`});case`qqqqq`:return n.quarter(e,{width:`narrow`,context:`standalone`});default:return n.quarter(e,{width:`wide`,context:`standalone`})||n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`Q`,`M`,`L`,`w`,`I`,`d`,`D`,`i`,`e`,`c`,`t`,`T`]},Jc=class extends kc{incompatibleTokens=[`Y`,`R`,`q`,`Q`,`L`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`];priority=110;parse(e,t,n){let r=e=>e-1;switch(t){case`M`:return Nc(Pc(jc.month,e),r);case`MM`:return Nc(Lc(2,e),r);case`Mo`:return Nc(n.ordinalNumber(e,{unit:`month`}),r);case`MMM`:return n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`});case`MMMMM`:return n.month(e,{width:`narrow`,context:`formatting`});default:return n.month(e,{width:`wide`,context:`formatting`})||n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}},Yc=class extends kc{priority=110;parse(e,t,n){let r=e=>e-1;switch(t){case`L`:return Nc(Pc(jc.month,e),r);case`LL`:return Nc(Lc(2,e),r);case`Lo`:return Nc(n.ordinalNumber(e,{unit:`month`}),r);case`LLL`:return n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`});case`LLLLL`:return n.month(e,{width:`narrow`,context:`standalone`});default:return n.month(e,{width:`wide`,context:`standalone`})||n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`M`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]};function Xc(e,t,n){let r=Wr(e,n?.in),i=mr(r,n)-t;return r.setDate(r.getDate()-i*7),Wr(r,n?.in)}var Zc=class extends kc{priority=100;parse(e,t,n){switch(t){case`w`:return Pc(jc.week,e);case`wo`:return n.ordinalNumber(e,{unit:`week`});default:return Lc(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n,r){return pi(Xc(e,n,r),r)}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]};function Qc(e,t,n){let r=Wr(e,n?.in),i=Nr(r,n)-t;return r.setDate(r.getDate()-i*7),r}var $c=class extends kc{priority=100;parse(e,t,n){switch(t){case`I`:return Pc(jc.week,e);case`Io`:return n.ordinalNumber(e,{unit:`week`});default:return Lc(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n){return Vr(Qc(e,n))}incompatibleTokens=[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]},el=[31,28,31,30,31,30,31,31,30,31,30,31],tl=[31,29,31,30,31,30,31,31,30,31,30,31],nl=class extends kc{priority=90;subPriority=1;parse(e,t,n){switch(t){case`d`:return Pc(jc.date,e);case`do`:return n.ordinalNumber(e,{unit:`date`});default:return Lc(t.length,e)}}validate(e,t){let n=Vc(e.getFullYear()),r=e.getMonth();return n?t>=1&&t<=tl[r]:t>=1&&t<=el[r]}set(e,t,n){return e.setDate(n),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]},rl=class extends kc{priority=90;subpriority=1;parse(e,t,n){switch(t){case`D`:case`DD`:return Pc(jc.dayOfYear,e);case`Do`:return n.ordinalNumber(e,{unit:`date`});default:return Lc(t.length,e)}}validate(e,t){return Vc(e.getFullYear())?t>=1&&t<=366:t>=1&&t<=365}set(e,t,n){return e.setMonth(0,n),e.setHours(0,0,0,0),e}incompatibleTokens=[`Y`,`R`,`q`,`Q`,`M`,`L`,`w`,`I`,`d`,`E`,`i`,`e`,`c`,`t`,`T`]};function il(e,t,n){let r=xi(),i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Wr(e,n?.in),o=a.getDay(),s=(t%7+7)%7,c=7-i;return Qs(a,t<0||t>6?t-(o+c)%7:(s+c)%7-(o+c)%7,n)}var al=class extends kc{priority=90;parse(e,t,n){switch(t){case`E`:case`EE`:case`EEE`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`EEEEE`:return n.day(e,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=il(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`D`,`i`,`e`,`c`,`t`,`T`]},ol=class extends kc{priority=90;parse(e,t,n,r){let i=e=>{let t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`e`:case`ee`:return Nc(Lc(t.length,e),i);case`eo`:return Nc(n.ordinalNumber(e,{unit:`day`}),i);case`eee`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`eeeee`:return n.day(e,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=il(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`c`,`t`,`T`]},sl=class extends kc{priority=90;parse(e,t,n,r){let i=e=>{let t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`c`:case`cc`:return Nc(Lc(t.length,e),i);case`co`:return Nc(n.ordinalNumber(e,{unit:`day`}),i);case`ccc`:return n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});case`ccccc`:return n.day(e,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});default:return n.day(e,{width:`wide`,context:`standalone`})||n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,r){return e=il(e,n,r),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`e`,`t`,`T`]};function cl(e,t,n){let r=Wr(e,n?.in);return Qs(r,t-vc(r,n),n)}var ll=class extends kc{priority=90;parse(e,t,n){let r=e=>e===0?7:e;switch(t){case`i`:case`ii`:return Lc(t.length,e);case`io`:return n.ordinalNumber(e,{unit:`day`});case`iii`:return Nc(n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiii`:return Nc(n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiiii`:return Nc(n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);default:return Nc(n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r)}}validate(e,t){return t>=1&&t<=7}set(e,t,n){return e=cl(e,n),e.setHours(0,0,0,0),e}incompatibleTokens=[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`E`,`e`,`c`,`t`,`T`]},ul=class extends kc{priority=80;parse(e,t,n){switch(t){case`a`:case`aa`:case`aaa`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`aaaaa`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(zc(n),0,0,0),e}incompatibleTokens=[`b`,`B`,`H`,`k`,`t`,`T`]},dl=class extends kc{priority=80;parse(e,t,n){switch(t){case`b`:case`bb`:case`bbb`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`bbbbb`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(zc(n),0,0,0),e}incompatibleTokens=[`a`,`B`,`H`,`k`,`t`,`T`]},fl=class extends kc{priority=80;parse(e,t,n){switch(t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`BBBBB`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}set(e,t,n){return e.setHours(zc(n),0,0,0),e}incompatibleTokens=[`a`,`b`,`t`,`T`]},pl=class extends kc{priority=70;parse(e,t,n){switch(t){case`h`:return Pc(jc.hour12h,e);case`ho`:return n.ordinalNumber(e,{unit:`hour`});default:return Lc(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,n){let r=e.getHours()>=12;return r&&n<12?e.setHours(n+12,0,0,0):!r&&n===12?e.setHours(0,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=[`H`,`K`,`k`,`t`,`T`]},ml=class extends kc{priority=70;parse(e,t,n){switch(t){case`H`:return Pc(jc.hour23h,e);case`Ho`:return n.ordinalNumber(e,{unit:`hour`});default:return Lc(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,n){return e.setHours(n,0,0,0),e}incompatibleTokens=[`a`,`b`,`h`,`K`,`k`,`t`,`T`]},hl=class extends kc{priority=70;parse(e,t,n){switch(t){case`K`:return Pc(jc.hour11h,e);case`Ko`:return n.ordinalNumber(e,{unit:`hour`});default:return Lc(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.getHours()>=12&&n<12?e.setHours(n+12,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=[`h`,`H`,`k`,`t`,`T`]},gl=class extends kc{priority=70;parse(e,t,n){switch(t){case`k`:return Pc(jc.hour24h,e);case`ko`:return n.ordinalNumber(e,{unit:`hour`});default:return Lc(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,n){let r=n<=24?n%24:n;return e.setHours(r,0,0,0),e}incompatibleTokens=[`a`,`b`,`h`,`H`,`K`,`t`,`T`]},_l=class extends kc{priority=60;parse(e,t,n){switch(t){case`m`:return Pc(jc.minute,e);case`mo`:return n.ordinalNumber(e,{unit:`minute`});default:return Lc(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setMinutes(n,0,0),e}incompatibleTokens=[`t`,`T`]},vl=class extends kc{priority=50;parse(e,t,n){switch(t){case`s`:return Pc(jc.second,e);case`so`:return n.ordinalNumber(e,{unit:`second`});default:return Lc(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setSeconds(n,0),e}incompatibleTokens=[`t`,`T`]},yl=class extends kc{priority=30;parse(e,t){return Nc(Lc(t.length,e),e=>Math.trunc(e*10**(-t.length+3)))}set(e,t,n){return e.setMilliseconds(n),e}incompatibleTokens=[`t`,`T`]},bl=class extends kc{priority=10;parse(e,t){switch(t){case`X`:return Fc(Mc.basicOptionalMinutes,e);case`XX`:return Fc(Mc.basic,e);case`XXXX`:return Fc(Mc.basicOptionalSeconds,e);case`XXXXX`:return Fc(Mc.extendedOptionalSeconds,e);default:return Fc(Mc.extended,e)}}set(e,t,n){return t.timestampIsSet?e:oi(e,e.getTime()-ni(e)-n)}incompatibleTokens=[`t`,`T`,`x`]},xl=class extends kc{priority=10;parse(e,t){switch(t){case`x`:return Fc(Mc.basicOptionalMinutes,e);case`xx`:return Fc(Mc.basic,e);case`xxxx`:return Fc(Mc.basicOptionalSeconds,e);case`xxxxx`:return Fc(Mc.extendedOptionalSeconds,e);default:return Fc(Mc.extended,e)}}set(e,t,n){return t.timestampIsSet?e:oi(e,e.getTime()-ni(e)-n)}incompatibleTokens=[`t`,`T`,`X`]},Sl=class extends kc{priority=40;parse(e){return Ic(e)}set(e,t,n){return[oi(e,n*1e3),{timestampIsSet:!0}]}incompatibleTokens=`*`},Cl=class extends kc{priority=20;parse(e){return Ic(e)}set(e,t,n){return[oi(e,n),{timestampIsSet:!0}]}incompatibleTokens=`*`},wl={G:new Ac,y:new Hc,Y:new Uc,R:new Wc,u:new Gc,Q:new Kc,q:new qc,M:new Jc,L:new Yc,w:new Zc,I:new $c,d:new nl,D:new rl,E:new al,e:new ol,c:new sl,i:new ll,a:new ul,b:new dl,B:new fl,h:new pl,H:new ml,K:new hl,k:new gl,m:new _l,s:new vl,S:new yl,X:new bl,x:new xl,t:new Sl,T:new Cl},Tl=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,El=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Dl=/^'([^]*?)'?$/,Ol=/''/g,kl=/\S/,Al=/[a-zA-Z]/;function jl(e,t,n,r){let i=()=>oi(r?.in||n,NaN),a=_c(),o=r?.locale??a.locale??Rr,s=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,c=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0;if(!t)return e?i():Wr(n,r?.in);let l={firstWeekContainsDate:s,weekStartsOn:c,locale:o},u=[new Oc(r?.in,n)],d=t.match(El).map(e=>{let t=e[0];if(t in hi){let n=hi[t];return n(e,o.formatLong)}return e}).join(``).match(Tl),f=[];for(let n of d){!r?.useAdditionalWeekYearTokens&&ur(n)&&gr(n,t,e),!r?.useAdditionalDayOfYearTokens&&jr(n)&&gr(n,t,e);let a=n[0],s=wl[a];if(s){let{incompatibleTokens:t}=s;if(Array.isArray(t)){let e=f.find(e=>t.includes(e.token)||e.token===a);if(e)throw RangeError(`The format string mustn't contain \`${e.fullToken}\` and \`${n}\` at the same time`)}else if(s.incompatibleTokens===`*`&&f.length>0)throw RangeError(`The format string mustn't contain \`${n}\` and any other token at the same time`);f.push({token:a,fullToken:n});let r=s.run(e,n,o.match,l);if(!r)return i();u.push(r.setter),e=r.rest}else{if(a.match(Al))throw RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");if(n===`''`?n=`'`:a===`'`&&(n=Ml(n)),e.indexOf(n)===0)e=e.slice(n.length);else return i()}}if(e.length>0&&kl.test(e))return i();let p=u.map(e=>e.priority).sort((e,t)=>t-e).filter((e,t,n)=>n.indexOf(e)===t).map(e=>u.filter(t=>t.priority===e).sort((e,t)=>t.subPriority-e.subPriority)).map(e=>e[0]),m=Wr(n,r?.in);if(isNaN(+m))return i();let h={};for(let e of p){if(!e.validate(m,l))return i();let t=e.set(m,h,l);Array.isArray(t)?(m=t[0],Object.assign(h,t[1])):m=t}return m}function Ml(e){return e.match(Dl)[1].replace(Ol,`'`)}function Nl(e,t,n){let[r,i]=vi(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function Pl(e,t,n){let[r,i]=vi(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function Fl(e,t,n){let r=Wr(e,n?.in),i=r.getFullYear(),a=r.getDate(),o=oi(n?.in||e,0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);let s=gc(o);return r.setMonth(t,Math.min(a,s)),r}function Il(e,t,n){let r=Wr(e,n?.in);return r.setHours(t),r}function Ll(e,t,n){let r=Wr(e,n?.in);return isNaN(+r)?oi(n?.in||e,NaN):(r.setFullYear(t),r)}function Rl(e){var t=t=>e(t);return t.toPromise=()=>B(ut(1)(Te((e=>!e.stale&&!e.hasNext))(t))),t.then=(e,n)=>t.toPromise().then(e,n),t.subscribe=e=>oe(e)(t),t}function zl(e,t,n){return{...t,kind:e,context:t.context?{...t.context,...n}:n||t.context}}var Bl=()=>{},Vl=({forward:e,dispatchDebug:t})=>t=>{var n=ge((e=>{var n=_e(e),r=He(e,n),i=Ye(e,n);return de(Te((t=>t.kind===`teardown`&&t.key===e.key))(t))(Ie(e,r,i))}))(Te((e=>e.kind!==`teardown`&&(e.kind!==`subscription`||!!e.context.fetchSubscriptions)))(t)),r=e(Te((e=>e.kind===`teardown`||e.kind===`subscription`&&!e.context.fetchSubscriptions))(t));return Ze([n,r])},Hl=e=>({client:t,forward:n,dispatchDebug:r})=>e.reduceRight(((e,n)=>n({client:t,forward(t){return Se(e(Se(t)))},dispatchDebug(e){}})),n),Ul=({onOperation:e,onResult:t,onError:n})=>({forward:r})=>i=>ge((e=>{n&&e.error&&n(e.error,e.operation);var r=t&&t(e)||e;return`then`in r?se(r):Le(r)}))(r(ge((t=>{if(t.kind===`teardown`)return Le(t);var n=e&&e(t)||t;return`then`in n?de(Te((e=>e.kind===`teardown`&&e.key===t.key))(i))(se(n)):Le(n)}))(i))),Wl=({dispatchDebug:e})=>e=>Te((e=>!1))(e),Gl=function e(t){var n=0,r=new Map,i=new Map,a=new Set,o=[],s={url:t.url,fetchSubscriptions:t.fetchSubscriptions,fetchOptions:t.fetchOptions,fetch:t.fetch,preferGetMethod:t.preferGetMethod==null?`within-url-limit`:t.preferGetMethod,requestPolicy:t.requestPolicy||`cache-first`},c=pe();function l(e){(e.kind===`mutation`||e.kind===`teardown`||!a.has(e.key))&&(e.kind===`teardown`?a.delete(e.key):e.kind!==`mutation`&&a.add(e.key),c.next(e))}var u=!1;function d(e){if(e&&l(e),!u){for(u=!0;u&&(e=o.shift());)l(e);u=!1}}var f=e=>{var t=de(Te((t=>t.kind===`teardown`&&t.key===e.key))(c.source))(Te((t=>t.operation.kind===e.kind&&t.operation.key===e.key&&(!t.operation.context._instance||t.operation.context._instance===e.context._instance)))(_));return t=e.kind===`query`?tt((t=>{var n=Le(t);return t.stale||t.hasNext?n:Ze([n,Ae((()=>(t.stale=!0,t)))(ut(1)(Te((t=>t.key===e.key))(c.source)))])}))(t):st((e=>!!e.hasNext),!0)(t),t=e.kind===`mutation`?Ne((()=>{l(e)}))(t):ye((()=>{a.delete(e.key),r.delete(e.key),i.delete(e.key),u=!1;for(var t=o.length-1;t>=0;t--)o[t].key===e.key&&o.splice(t,1);l(zl(`teardown`,e,e.context))}))(ze((t=>{if(t.stale){if(!t.hasNext)a.delete(e.key);else for(var n=0;n<o.length;n++){var i=o[n];if(i.key===t.operation.key){a.delete(i.key);break}}}else t.hasNext||a.delete(e.key);r.set(e.key,t)}))(t)),Se(t)},p=this instanceof e?this:Object.create(e.prototype),m=Object.assign(p,{suspense:!!t.suspense,operations$:c.source,reexecuteOperation(e){if(e.kind===`teardown`)d(e);else if(e.kind===`mutation`)o.push(e),Promise.resolve().then(d);else if(i.has(e.key)){for(var t=!1,n=0;n<o.length;n++)o[n].key===e.key&&(o[n]=e,t=!0);t||a.has(e.key)&&e.context.requestPolicy!==`network-only`?(a.delete(e.key),Promise.resolve().then(d)):(o.push(e),Promise.resolve().then(d))}},createRequestOperation(e,t,r){return r||={},zl(e,t,{_instance:e===`mutation`?n=n+1|0:void 0,...s,...r,requestPolicy:r.requestPolicy||s.requestPolicy,suspense:r.suspense||!1!==r.suspense&&m.suspense})},executeRequestOperation(e){return e.kind===`mutation`?Rl(f(e)):Rl(Ge((()=>{var t=i.get(e.key);t||i.set(e.key,t=f(e)),t=Ne((()=>{d(e)}))(t);var n=r.get(e.key);return e.kind===`query`&&n&&(n.stale||n.hasNext)?tt(Le)(Ze([t,Te((t=>t===r.get(e.key)))(Le(n))])):t})))},executeQuery(e,t){var n=m.createRequestOperation(`query`,e,t);return m.executeRequestOperation(n)},executeSubscription(e,t){var n=m.createRequestOperation(`subscription`,e,t);return m.executeRequestOperation(n)},executeMutation(e,t){var n=m.createRequestOperation(`mutation`,e,t);return m.executeRequestOperation(n)},readQuery(e,t,n){var r=null;return oe((e=>{r=e}))(m.query(e,t,n)).unsubscribe(),r},query:(e,t,n)=>m.executeQuery(I(e,t),n),subscription:(e,t,n)=>m.executeSubscription(I(e,t),n),mutation:(e,t,n)=>m.executeMutation(I(e,t),n)}),h=Bl,g=Hl(t.exchanges),_=Se(g({client:m,dispatchDebug:h,forward:Wl({dispatchDebug:h})})(c.source));return Ce(_),m},Kl={CommonCharge:`Common`,BusinessTripCharge:`Business Trip`,DividendCharge:`Dividend`,ConversionCharge:`Conversion`,SalaryCharge:`Salary`,InternalTransferCharge:`Internal Transfer`,MonthlyVatCharge:`Monthly VAT`,BankDepositCharge:`Bank Deposit`,ForeignSecuritiesCharge:`Foreign Securities`,CreditcardBankCharge:`Credit Card Bank Charge`,FinancialCharge:`Financial Charge`},ql=e=>!e||!(e in Kl)?`Unknown`:Kl[e],Jl={CommonCharge:(0,Q.jsx)(Gi,{}),BusinessTripCharge:(0,Q.jsx)(ga,{}),DividendCharge:(0,Q.jsx)(na,{}),ConversionCharge:(0,Q.jsx)(ra,{}),SalaryCharge:(0,Q.jsx)(Aa,{}),InternalTransferCharge:(0,Q.jsx)(Ii,{}),MonthlyVatCharge:(0,Q.jsx)(va,{}),BankDepositCharge:(0,Q.jsx)(ha,{}),ForeignSecuritiesCharge:(0,Q.jsx)(Da,{}),CreditcardBankCharge:(0,Q.jsx)(Ji,{}),FinancialCharge:(0,Q.jsx)(ba,{})},Yl=e=>!e||!(e in Jl)?(0,Q.jsx)(Gi,{}):Jl[e];function Xl(e){switch(e){case`CommonCharge`:return`COMMON`;case`BusinessTripCharge`:return`BUSINESS_TRIP`;case`DividendCharge`:return`DIVIDEND`;case`ConversionCharge`:return`CONVERSION`;case`SalaryCharge`:return`PAYROLL`;case`InternalTransferCharge`:return`INTERNAL`;case`MonthlyVatCharge`:return`VAT`;case`BankDepositCharge`:return`BANK_DEPOSIT`;case`ForeignSecuritiesCharge`:return`FOREIGN_SECURITIES`;case`CreditcardBankCharge`:return`CREDITCARD_BANK`;case`FinancialCharge`:return`FINANCIAL`;default:throw Error(`Unsupported charge type: ${e}`)}}var Zl=e=>{navigator.clipboard.writeText(e).then(()=>{console.log(`clipboard successfully set`)},()=>{console.log(`clipboard failed`)})},Ql=/^((?:1[6-9]|[2]\d)\d{2})(-)(?:((?:0[13578]|1[02])(-31))|(?:(?:0[1,3-9]|1[0-2])(-)(?:29|30)))$|^(?:(?:(?:1[6-9]|[2]\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(-02-29)$|^(?:(?:1[6-9]|[2-9]\d)\d{2})(-)(?:(?:0[1-9])|(?:1[0-2]))(-)(?:0[1-9]|1\d|2[0-8])$/,$l=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,eu=`00000000-0000-0000-0000-000000000000`,tu=[k.Ils,k.Eur,k.Usd,k.Gbp,k.Cad,k.Jpy,k.Aud,k.Sek];function nu(e,t){if(!tu.includes(e)){let n=new Intl.NumberFormat(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2,...t,style:`decimal`});return{format:t=>{let r=ru(e),i=n.format(Math.abs(t));return t<0?`-${r} ${i}`:`${r} ${i}`}}}return new Intl.NumberFormat(`en-US`,{style:`currency`,...t,currency:e})}function ru(e){let t=`₪`;switch(e){case`USD`:t=`$`;break;case`EUR`:t=`€`;break;case`GBP`:t=`£`;break;case`CAD`:t=`C$`;break;case`JPY`:t=`¥`;break;case`AUD`:t=`A$`;break;case`SEK`:t=`kr`;break;case`GRT`:t=`GRT`;break;case`USDC`:t=`USDC`;break;case`ETH`:t=`ETH`}return t}function iu(e,t,n=2){return`${ru(t)} ${ou(e,n)}`}function au(e){switch(e){case Ve.Invoice:return`Tax Invoice`;case Ve.Proforma:return`Proforma Invoice`;case Ve.InvoiceReceipt:return`Invoice / Receipt`;case Ve.CreditInvoice:return`Credit Note`;case Ve.Receipt:return`Receipt`;case Ve.Other:return`Other Document`;case Ve.Unprocessed:return`Unprocessed Document`;default:throw Error(`Unsupported document type: ${e}`)}}var ou=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e),su={C:`INPUT_SELF_INVOICE`,H:`INPUT_SINGLE_DOC_BY_LAW`,I:`SALE_PALESTINIAN_CUSTOMER`,K:`INPUT_PETTY_CASH`,L1:`SALE_UNIDENTIFIED_CUSTOMER`,L2:`SALE_UNIDENTIFIED_ZERO_OR_EXEMPT`,M:`SALE_SELF_INVOICE`,P:`INPUT_PALESTINIAN_SUPPLIER`,R:`INPUT_IMPORT`,S1:`SALE_REGULAR`,S2:`SALE_ZERO_OR_EXEMPT`,T:`INPUT_REGULAR`,Y:`SALE_EXPORT`};function cu(e){return e.sort((e,t)=>{let n=[...e.namePath??[],e.name],r=[...t.namePath??[],t.name];for(let e=0;e<Math.max(n.length,r.length);e++){if(n[e]&&r[e]&&n[e]!==r[e])return n[e].localeCompare(r[e]);if(n[e]&&!r[e])return 1;if(!n[e]&&r[e])return-1}return e.name.localeCompare(t.name)})}function lu({className:e,children:t,...n}){return(0,Q.jsxs)(us,{"data-slot":`scroll-area`,className:s(`relative`,e),...n,children:[(0,Q.jsx)(ds,{"data-slot":`scroll-area-viewport`,className:`focus-visible:ring-gray-950/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 dark:focus-visible:ring-gray-300/50`,children:t}),(0,Q.jsx)(uu,{}),(0,Q.jsx)(fs,{})]})}function uu({className:e,orientation:t=`vertical`,...n}){return(0,Q.jsx)(Ro,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:s(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,Q.jsx)(Yo,{"data-slot":`scroll-area-thumb`,className:`bg-gray-200 relative flex-1 rounded-full dark:bg-gray-800`})})}var du=(e,t)=>zl(e.kind,e,{...e.context,authAttempt:t});function fu(e){return({client:t,forward:n})=>{var r=new Set,i=pe(),a=pe(),o=new Map;function s(){u=void 0;var e=o;o=new Map,e.forEach(i.next)}function l(e){u=void 0;var t=o;o=new Map,t.forEach((t=>{a.next(c(t,e))}))}var u,d=null;return c=>{function f(){u=Promise.resolve().then((()=>e({mutate(e,n,a){var o=t.createRequestOperation(`mutation`,I(e,n),a);return B(ut(1)(Te((e=>e.operation.key===o.key&&o.context._instance===e.operation.context._instance))(Ne((()=>{var e=m(o);r.add(e.context._instance),i.next(e)}))(h))))},appendHeaders(e,t){var n=typeof e.context.fetchOptions==`function`?e.context.fetchOptions():e.context.fetchOptions||{};return zl(e.kind,e,{...e.context,fetchOptions:{...n,headers:{...n.headers,...t}}})}}))).then((e=>{e&&(d=e),s()})).catch((e=>{l(e)}))}f();function p(e){o.set(e.key,du(e,!0)),d&&!u&&(u=d.refreshAuth().then(s).catch(l))}function m(e){return d?d.addAuthToOperation(e):e}var h=n(Te(Boolean)(Ae((e=>e.kind===`teardown`?(o.delete(e.key),e):e.context._instance&&r.has(e.context._instance)?e:e.context.authAttempt?m(e):u||!d?(u||f(),o.has(e.key)||o.set(e.key,du(e,!1)),null):function(e){return!e.context.authAttempt&&d&&d.willAuthError&&d.willAuthError(e)}(e)?(p(e),null):m(du(e,!1))))(Ze([i.source,c]))));return Ze([a.source,Te((e=>!r.has(e.operation.context._instance)&&e.error&&function(e){return d&&d.didAuthError&&d.didAuthError(e.error,e.operation)}(e)&&!e.operation.context.authAttempt?(p(e.operation),!1):(r.has(e.operation.context._instance)&&r.delete(e.operation.context._instance),!0)))(h)])}}}var pu=null,mu=null;function hu(e){pu=e}function gu(){return pu?(mu||=pu().finally(()=>{mu=null}),mu):Promise.resolve(`redirect`)}function _u(e){if(e.error?.networkError){console.error(`Network Error:`,e.error.networkError),K.error(`Network Error`,{description:`Failed to connect to the server. Please check your connection.`,duration:5e3});return}if(e.error?.graphQLErrors?.length){let t=e.error.graphQLErrors[0],{message:n}=t;console.error(`GraphQL Error:`,t),K.error(`Operation Error`,{description:n||`An error occurred while processing your request.`,duration:5e3})}}var vu=`urql:businessScope`,yu=null,bu=null,xu=!1,Su=(()=>{try{return localStorage.getItem(vu)}catch{return null}})(),Cu=null;function wu(e){yu=e,e||(bu=null,xu=!1)}function Tu(){return Su?Su.split(`,`):[]}function Eu(e){Su=e.length>0?e.join(`,`):null;try{Su?localStorage.setItem(vu,Su):localStorage.removeItem(vu)}catch{}Nu(),Cu?.(Mu())}function Du(e){return typeof e==`string`?{status:`token`,token:e}:e?e.status===`token`?{status:`token`,token:e.token}:e.status===`unauthenticated`?{status:`unauthenticated`}:{status:`error`,error:e.error}:{status:`unauthenticated`}}async function Ou(e){if(!yu)return{status:`unauthenticated`};try{return Du(await yu(e))}catch(e){return{status:`error`,error:e}}}function ku(e){return e instanceof Error?e:Error(`Failed to refresh access token`)}function Au(){if(!xu){if(typeof window<`u`&&window.location){if(window.location.pathname===yt.LOGIN||window.location.pathname===yt.AUTH_CALLBACK)return;try{if(window.sessionStorage){let{pathname:e,search:t,hash:n}=window.location,r=`${e}${t}${n}`;window.sessionStorage.setItem(`auth:returnTo`,r)}}catch{}xu=!0,window.location.href=`${yt.LOGIN}?reauth=1`;return}if(typeof globalThis<`u`&&`location`in globalThis&&globalThis.location){if(globalThis.location.pathname===yt.LOGIN||globalThis.location.pathname===yt.AUTH_CALLBACK)return;xu=!0,globalThis.location.href=`${yt.LOGIN}?reauth=1`}}}var ju=null;function Mu(){if(ju)return ju;let e;switch(`production`){case`production`:e=`https://accounter.onrender.com/graphql`;break;case`staging`:e=`https://accounter-staging.onrender.com/graphql`;break;default:e=`http://localhost:4000/graphql`}return ju=Gl({url:e,exchanges:[Ul({onResult(e){_u(e)}}),fu(async e=>{{let e=await Ou();bu=e.status===`token`?`Bearer ${e.token}`:null}return{willAuthError(){return!1},addAuthToOperation(t){if(!bu)return t;let n={Authorization:bu};return Su&&(n[`x-business-scope`]=Su),e.appendHeaders(t,n)},didAuthError(e){return e.graphQLErrors?.some(e=>e.extensions?.code===`UNAUTHENTICATED`)??!1},async refreshAuth(){let e=await Ou({cacheMode:`off`});if(e.status===`error`)throw ku(e.error);if(e.status===`unauthenticated`){if(bu=null,await gu()===`authenticated`){let e=await Ou({cacheMode:`off`});if(e.status===`token`){xu=!1,bu=`Bearer ${e.token}`;return}}Au();return}xu=!1,bu=`Bearer ${e.token}`}}}),Vl]}),ju}function Nu(){ju=null,bu=null,xu=!1}function Pu({children:e}){let[t,n]=(0,Z.useState)(Mu);return(0,Z.useEffect)(()=>(Cu=n,()=>{Cu===n&&(Cu=null)}),[]),(0,Q.jsx)(w,{value:t,children:e})}function Fu(e){let t=(0,Z.createContext)(null);return[({children:e,value:n})=>Z.createElement(t.Provider,{value:n},e),()=>{let n=(0,Z.useContext)(t);if(n===null)throw Error(e);return n}]}function Iu(e){return Array.isArray(e)?e:[e]}var Lu=()=>{};function Ru(e,t={active:!0}){return typeof e!=`function`||!t.active?t.onKeyDown||Lu:n=>{var r;n.key===`Escape`&&(e(n),(r=t.onTrigger)==null||r.call(t))}}function zu({data:e}){let t=[],n=[],r=e.reduce((e,t,r)=>(t.group?e[t.group]?e[t.group].push(r):e[t.group]=[r]:n.push(r),e),{});return Object.keys(r).forEach(n=>{t.push(...r[n].map(t=>e[t]))}),t.push(...n.map(t=>e[t])),t}function Bu(e){return Array.isArray(e)||e===null?!1:typeof e==`object`&&e.type!==Z.Fragment}var Vu={app:100,modal:200,popover:300,overlay:400,max:9999};function Hu(e){return Vu[e]}function Uu(e){return`___ref-${e||``}`}var Wu=Object.defineProperty,Gu=Object.defineProperties,Ku=Object.getOwnPropertyDescriptors,qu=Object.getOwnPropertySymbols,Ju=Object.prototype.hasOwnProperty,Yu=Object.prototype.propertyIsEnumerable,Xu=(e,t,n)=>t in e?Wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zu=(e,t)=>{for(var n in t||={})Ju.call(t,n)&&Xu(e,n,t[n]);if(qu)for(var n of qu(t))Yu.call(t,n)&&Xu(e,n,t[n]);return e},Qu=(e,t)=>Gu(e,Ku(t)),$u={in:{opacity:1,transform:`scale(1)`},out:{opacity:0,transform:`scale(.9) translateY(${Y(10)})`},transitionProperty:`transform, opacity`},ed={fade:{in:{opacity:1},out:{opacity:0},transitionProperty:`opacity`},scale:{in:{opacity:1,transform:`scale(1)`},out:{opacity:0,transform:`scale(0)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"scale-y":{in:{opacity:1,transform:`scaleY(1)`},out:{opacity:0,transform:`scaleY(0)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"scale-x":{in:{opacity:1,transform:`scaleX(1)`},out:{opacity:0,transform:`scaleX(0)`},common:{transformOrigin:`left`},transitionProperty:`transform, opacity`},"skew-up":{in:{opacity:1,transform:`translateY(0) skew(0deg, 0deg)`},out:{opacity:0,transform:`translateY(-${Y(20)}) skew(-10deg, -5deg)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"skew-down":{in:{opacity:1,transform:`translateY(0) skew(0deg, 0deg)`},out:{opacity:0,transform:`translateY(${Y(20)}) skew(-10deg, -5deg)`},common:{transformOrigin:`bottom`},transitionProperty:`transform, opacity`},"rotate-left":{in:{opacity:1,transform:`translateY(0) rotate(0deg)`},out:{opacity:0,transform:`translateY(${Y(20)}) rotate(-5deg)`},common:{transformOrigin:`bottom`},transitionProperty:`transform, opacity`},"rotate-right":{in:{opacity:1,transform:`translateY(0) rotate(0deg)`},out:{opacity:0,transform:`translateY(${Y(20)}) rotate(5deg)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"slide-down":{in:{opacity:1,transform:`translateY(0)`},out:{opacity:0,transform:`translateY(-100%)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"slide-up":{in:{opacity:1,transform:`translateY(0)`},out:{opacity:0,transform:`translateY(100%)`},common:{transformOrigin:`bottom`},transitionProperty:`transform, opacity`},"slide-left":{in:{opacity:1,transform:`translateX(0)`},out:{opacity:0,transform:`translateX(100%)`},common:{transformOrigin:`left`},transitionProperty:`transform, opacity`},"slide-right":{in:{opacity:1,transform:`translateX(0)`},out:{opacity:0,transform:`translateX(-100%)`},common:{transformOrigin:`right`},transitionProperty:`transform, opacity`},pop:Qu(Zu({},$u),{common:{transformOrigin:`center center`}}),"pop-bottom-left":Qu(Zu({},$u),{common:{transformOrigin:`bottom left`}}),"pop-bottom-right":Qu(Zu({},$u),{common:{transformOrigin:`bottom right`}}),"pop-top-left":Qu(Zu({},$u),{common:{transformOrigin:`top left`}}),"pop-top-right":Qu(Zu({},$u),{common:{transformOrigin:`top right`}})},td=[`mousedown`,`touchstart`];function nd(e,t,n){let r=(0,Z.useRef)();return(0,Z.useEffect)(()=>{let i=t=>{let{target:i}=t??{};if(Array.isArray(n)){let r=i?.hasAttribute(`data-ignore-outside-clicks`)||!document.body.contains(i)&&i.tagName!==`HTML`;n.every(e=>!!e&&!t.composedPath().includes(e))&&!r&&e()}else r.current&&!r.current.contains(i)&&e()};return(t||td).forEach(e=>document.addEventListener(e,i)),()=>{(t||td).forEach(e=>document.removeEventListener(e,i))}},[r,e,n]),r}function rd(e,t){try{return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}catch{return e.addListener(t),()=>e.removeListener(t)}}function id(e,t){return typeof t==`boolean`?t:typeof window<`u`&&`matchMedia`in window&&window.matchMedia(e).matches}function ad(e,t,{getInitialValueInEffect:n}={getInitialValueInEffect:!0}){let[r,i]=(0,Z.useState)(n?t:id(e,t)),a=(0,Z.useRef)();return(0,Z.useEffect)(()=>{if(`matchMedia`in window)return a.current=window.matchMedia(e),i(a.current.matches),rd(a.current,e=>i(e.matches))},[e]),r}function od(e,t,n){return Math.min(Math.max(e,t),n)}var sd=typeof document<`u`?Z.useLayoutEffect:Z.useEffect;function cd({opened:e,shouldReturnFocus:t=!0}){let n=(0,Z.useRef)(),r=()=>{var e;n.current&&`focus`in n.current&&typeof n.current.focus==`function`&&((e=n.current)==null||e.focus({preventScroll:!0}))};return bi(()=>{let i=-1,a=e=>{e.key===`Tab`&&window.clearTimeout(i)};return document.addEventListener(`keydown`,a),e?n.current=document.activeElement:t&&(i=window.setTimeout(r,10)),()=>{window.clearTimeout(i),document.removeEventListener(`keydown`,a)}},[e,t]),r}var ld=/input|select|textarea|button|object/,ud=`a, input, select, textarea, button, object, [tabindex]`;function dd(e){return e.style.display===`none`}function fd(e){if(e.getAttribute(`aria-hidden`)||e.getAttribute(`hidden`)||e.getAttribute(`type`)===`hidden`)return!1;let t=e;for(;t&&t!==document.body&&t.nodeType!==11;){if(dd(t))return!1;t=t.parentNode}return!0}function pd(e){let t=e.getAttribute(`tabindex`);return t===null&&(t=void 0),parseInt(t,10)}function md(e){let t=e.nodeName.toLowerCase(),n=!Number.isNaN(pd(e));return(ld.test(t)&&!e.disabled||e instanceof HTMLAnchorElement&&e.href||n)&&fd(e)}function hd(e){let t=pd(e);return(Number.isNaN(t)||t>=0)&&md(e)}function gd(e){return Array.from(e.querySelectorAll(ud)).filter(hd)}function _d(e,t){let n=gd(e);if(!n.length){t.preventDefault();return}let r=n[t.shiftKey?0:n.length-1],i=e.getRootNode();if(r!==i.activeElement&&e!==i.activeElement)return;t.preventDefault();let a=n[t.shiftKey?n.length-1:0];a&&a.focus()}function vd(){return`mantine-${Math.random().toString(36).slice(2,11)}`}function yd(e,t=`body > :not(script)`){let n=vd(),r=Array.from(document.querySelectorAll(t)).map(t=>{if((t?.shadowRoot)?.contains(e)||t.contains(e))return;let r=t.getAttribute(`aria-hidden`),i=t.getAttribute(`data-hidden`),a=t.getAttribute(`data-focus-id`);return t.setAttribute(`data-focus-id`,n),r===null||r===`false`?t.setAttribute(`aria-hidden`,`true`):!i&&!a&&t.setAttribute(`data-hidden`,r),{node:t,ariaHidden:i||null}});return()=>{r.forEach(e=>{!e||n!==e.node.getAttribute(`data-focus-id`)||(e.ariaHidden===null?e.node.removeAttribute(`aria-hidden`):e.node.setAttribute(`aria-hidden`,e.ariaHidden),e.node.removeAttribute(`data-focus-id`),e.node.removeAttribute(`data-hidden`))})}}function bd(e=!0){let t=(0,Z.useRef)(),n=(0,Z.useRef)(null),r=e=>{let t=e.querySelector(`[data-autofocus]`);if(!t){let n=Array.from(e.querySelectorAll(ud));t=n.find(hd)||n.find(md)||null,!t&&md(e)&&(t=e)}t&&t.focus({preventScroll:!0})},i=(0,Z.useCallback)(i=>{if(e){if(i===null){n.current&&=(n.current(),null);return}n.current=yd(i),t.current!==i&&(i?(setTimeout(()=>{i.getRootNode()&&r(i)}),t.current=i):t.current=null)}},[e]);return(0,Z.useEffect)(()=>{if(!e)return;t.current&&setTimeout(()=>r(t.current));let i=e=>{e.key===`Tab`&&t.current&&_d(t.current,e)};return document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`keydown`,i),n.current&&n.current()}},[e]),i}var xd=Z.default.useId||(()=>void 0);function Sd(){let e=xd();return e?`mantine-${e.replace(/:/g,``)}`:``}function Cd(e){let t=Sd(),[n,r]=(0,Z.useState)(t);return sd(()=>{r(vd())},[]),typeof e==`string`?e:typeof window>`u`?t:n}function wd(e,t,n){(0,Z.useEffect)(()=>(window.addEventListener(e,t,n),()=>window.removeEventListener(e,t,n)),[e,t])}function Td(e,t){typeof e==`function`?e(t):typeof e==`object`&&e&&`current`in e&&(e.current=t)}function Ed(...e){return t=>{e.forEach(e=>Td(e,t))}}function Dd(...e){return(0,Z.useCallback)(Ed(...e),e)}function Od({value:e,defaultValue:t,finalValue:n,onChange:r=()=>{}}){let[i,a]=(0,Z.useState)(t===void 0?n:t);return e===void 0?[i,e=>{a(e),r?.(e)},!1]:[e,r,!0]}function kd(e,t){return ad(`(prefers-reduced-motion: reduce)`,e,t)}var Ad=e=>e<.5?2*e*e:-1+(4-2*e)*e,jd=({axis:e,target:t,parent:n,alignment:r,offset:i,isList:a})=>{if(!t||!n&&typeof document>`u`)return 0;let o=!!n,s=(n||document.body).getBoundingClientRect(),c=t.getBoundingClientRect(),l=e=>c[e]-s[e];if(e===`y`){let e=l(`top`);if(e===0)return 0;if(r===`start`){let t=e-i;return t<=c.height*+!a||!a?t:0}let t=o?s.height:window.innerHeight;if(r===`end`){let n=e+i-t+c.height;return n>=-c.height*+!a||!a?n:0}return r===`center`?e-t/2+c.height/2:0}if(e===`x`){let e=l(`left`);if(e===0)return 0;if(r===`start`){let t=e-i;return t<=c.width||!a?t:0}let t=o?s.width:window.innerWidth;if(r===`end`){let n=e+i-t+c.width;return n>=-c.width||!a?n:0}return r===`center`?e-t/2+c.width/2:0}return 0},Md=({axis:e,parent:t})=>{if(!t&&typeof document>`u`)return 0;let n=e===`y`?`scrollTop`:`scrollLeft`;if(t)return t[n];let{body:r,documentElement:i}=document;return r[n]+i[n]},Nd=({axis:e,parent:t,distance:n})=>{if(!t&&typeof document>`u`)return;let r=e===`y`?`scrollTop`:`scrollLeft`;if(t)t[r]=n;else{let{body:e,documentElement:t}=document;e[r]=n,t[r]=n}};function Pd({duration:e=1250,axis:t=`y`,onScrollFinish:n,easing:r=Ad,offset:i=0,cancelable:a=!0,isList:o=!1}={}){let s=(0,Z.useRef)(0),c=(0,Z.useRef)(0),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=kd(),p=()=>{s.current&&cancelAnimationFrame(s.current)},m=(0,Z.useCallback)(({alignment:a=`start`}={})=>{l.current=!1,s.current&&p();let m=Md({parent:u.current,axis:t})??0,h=jd({parent:u.current,target:d.current,axis:t,alignment:a,offset:i,isList:o})-(u.current?0:m);function g(){c.current===0&&(c.current=performance.now());let i=performance.now()-c.current,a=f||e===0?1:i/e,o=m+h*r(a);Nd({parent:u.current,axis:t,distance:o}),!l.current&&a<1?s.current=requestAnimationFrame(g):(typeof n==`function`&&n(),c.current=0,s.current=0,p())}g()},[t,e,r,o,i,n,f]),h=()=>{a&&(l.current=!0)};return wd(`wheel`,h,{passive:!0}),wd(`touchmove`,h,{passive:!0}),(0,Z.useEffect)(()=>p,[]),{scrollableRef:u,targetRef:d,scrollIntoView:m,cancel:p}}function Fd(){if(typeof window>`u`)return`undetermined`;let{userAgent:e}=window.navigator;return/(Macintosh)|(MacIntel)|(MacPPC)|(Mac68K)/i.test(e)?`macos`:/(iPhone)|(iPad)|(iPod)/i.test(e)?`ios`:/(Win32)|(Win64)|(Windows)|(WinCE)/i.test(e)?`windows`:/Android/i.test(e)?`android`:/Linux/i.test(e)?`linux`:`undetermined`}function Id(e={getValueInEffect:!0}){let[t,n]=(0,Z.useState)(e.getValueInEffect?`undetermined`:Fd());return sd(()=>{e.getValueInEffect&&n(Fd)},[]),t}function Ld(e=!1,t){let{onOpen:n,onClose:r}=t||{},[i,a]=(0,Z.useState)(e),o=(0,Z.useCallback)(()=>{a(e=>e||(n?.(),!0))},[n]),s=(0,Z.useCallback)(()=>{a(e=>e&&(r?.(),!1))},[r]);return[i,{open:o,close:s,toggle:(0,Z.useCallback)(()=>{i?s():o()},[s,o,i])}]}function Rd(e){return typeof e==`string`?e.charAt(0).toUpperCase()+e.slice(1):``}var zd=Object.defineProperty,Bd=Object.defineProperties,Vd=Object.getOwnPropertyDescriptors,Hd=Object.getOwnPropertySymbols,Ud=Object.prototype.hasOwnProperty,Wd=Object.prototype.propertyIsEnumerable,Gd=(e,t,n)=>t in e?zd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kd=(e,t)=>{for(var n in t||={})Ud.call(t,n)&&Gd(e,n,t[n]);if(Hd)for(var n of Hd(t))Wd.call(t,n)&&Gd(e,n,t[n]);return e},qd=(e,t)=>Bd(e,Vd(t)),Jd=Ur(e=>({root:qd(Kd(Kd({},e.fn.focusStyles()),e.fn.fontStyles()),{cursor:`pointer`,border:0,padding:0,appearance:`none`,fontSize:e.fontSizes.md,backgroundColor:`transparent`,textAlign:`left`,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,textDecoration:`none`,boxSizing:`border-box`})})),Yd=Object.defineProperty,Xd=Object.getOwnPropertySymbols,Zd=Object.prototype.hasOwnProperty,Qd=Object.prototype.propertyIsEnumerable,$d=(e,t,n)=>t in e?Yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ef=(e,t)=>{for(var n in t||={})Zd.call(t,n)&&$d(e,n,t[n]);if(Xd)for(var n of Xd(t))Qd.call(t,n)&&$d(e,n,t[n]);return e},tf=(e,t)=>{var n={};for(var r in e)Zd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Xd)for(var r of Xd(e))t.indexOf(r)<0&&Qd.call(e,r)&&(n[r]=e[r]);return n},nf=(0,Z.forwardRef)((e,t)=>{let n=X(`UnstyledButton`,{},e),{className:r,component:i=`button`,unstyled:a,variant:o}=n,s=tf(n,[`className`,`component`,`unstyled`,`variant`]),{classes:c,cx:l}=Jd(null,{name:`UnstyledButton`,unstyled:a,variant:o});return Z.createElement(Br,ef({component:i,ref:t,className:l(c.root,r),type:i===`button`?`button`:void 0},s))});nf.displayName=`@mantine/core/UnstyledButton`;var rf=ir(nf),af=Object.defineProperty,of=Object.getOwnPropertySymbols,sf=Object.prototype.hasOwnProperty,cf=Object.prototype.propertyIsEnumerable,lf=(e,t,n)=>t in e?af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uf=(e,t)=>{for(var n in t||={})sf.call(t,n)&&lf(e,n,t[n]);if(of)for(var n of of(t))cf.call(t,n)&&lf(e,n,t[n]);return e},df=(e,t)=>{var n={};for(var r in e)sf.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&of)for(var r of of(e))t.indexOf(r)<0&&cf.call(e,r)&&(n[r]=e[r]);return n};function ff(e){let t=e,{style:n}=t,r=df(t,[`style`]);return Z.createElement(`svg`,uf({viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:uf({width:Y(16),height:Y(16)},n)},r),Z.createElement(`path`,{d:`M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`}))}var pf=Object.defineProperty,mf=Object.defineProperties,hf=Object.getOwnPropertyDescriptors,gf=Object.getOwnPropertySymbols,_f=Object.prototype.hasOwnProperty,vf=Object.prototype.propertyIsEnumerable,yf=(e,t,n)=>t in e?pf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bf=(e,t)=>{for(var n in t||={})_f.call(t,n)&&yf(e,n,t[n]);if(gf)for(var n of gf(t))vf.call(t,n)&&yf(e,n,t[n]);return e},xf=(e,t)=>mf(e,hf(t)),Sf=[`subtle`,`filled`,`outline`,`light`,`default`,`transparent`,`gradient`],Cf={xs:Y(18),sm:Y(22),md:Y(28),lg:Y(34),xl:Y(44)};function wf({variant:e,theme:t,color:n,gradient:r}){let i=t.fn.variant({color:n,variant:e,gradient:r});return e===`gradient`?{border:0,backgroundImage:i.background,color:i.color,"&:hover":t.fn.hover({backgroundSize:`200%`})}:Sf.includes(e)?bf({border:`${Y(1)} solid ${i.border}`,backgroundColor:i.background,color:i.color},t.fn.hover({backgroundColor:i.hover})):null}var Tf=Ur((e,{radius:t,color:n,gradient:r},{variant:i,size:a})=>({root:xf(bf({position:`relative`,borderRadius:e.fn.radius(t),padding:0,lineHeight:1,display:`flex`,alignItems:`center`,justifyContent:`center`,height:J({size:a,sizes:Cf}),minHeight:J({size:a,sizes:Cf}),width:J({size:a,sizes:Cf}),minWidth:J({size:a,sizes:Cf})},wf({variant:i,theme:e,color:n,gradient:r})),{"&:active":e.activeStyles,"& [data-action-icon-loader]":{maxWidth:`70%`},"&:disabled, &[data-disabled]":{color:e.colors.gray[e.colorScheme===`dark`?6:4],cursor:`not-allowed`,backgroundColor:i===`transparent`?void 0:e.fn.themeColor(`gray`,e.colorScheme===`dark`?8:1),borderColor:i===`transparent`?void 0:e.fn.themeColor(`gray`,e.colorScheme===`dark`?8:1),backgroundImage:`none`,pointerEvents:`none`,"&:active":{transform:`none`}},"&[data-loading]":{pointerEvents:`none`,"&::before":xf(bf({content:`""`},e.fn.cover(Y(-1))),{backgroundColor:e.colorScheme===`dark`?e.fn.rgba(e.colors.dark[7],.5):`rgba(255, 255, 255, .5)`,borderRadius:e.fn.radius(t),cursor:`not-allowed`})}})})),Ef=Object.defineProperty,Df=Object.getOwnPropertySymbols,Of=Object.prototype.hasOwnProperty,kf=Object.prototype.propertyIsEnumerable,Af=(e,t,n)=>t in e?Ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jf=(e,t)=>{for(var n in t||={})Of.call(t,n)&&Af(e,n,t[n]);if(Df)for(var n of Df(t))kf.call(t,n)&&Af(e,n,t[n]);return e},Mf=(e,t)=>{var n={};for(var r in e)Of.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Df)for(var r of Df(e))t.indexOf(r)<0&&kf.call(e,r)&&(n[r]=e[r]);return n},Nf={color:`gray`,size:`md`,variant:`subtle`},Pf=(0,Z.forwardRef)((e,t)=>{let n=X(`ActionIcon`,Nf,e),{className:r,color:i,children:a,radius:o,size:s,variant:c,gradient:l,disabled:u,loaderProps:d,loading:f,unstyled:p,__staticSelector:m}=n,h=Mf(n,[`className`,`color`,`children`,`radius`,`size`,`variant`,`gradient`,`disabled`,`loaderProps`,`loading`,`unstyled`,`__staticSelector`]),{classes:g,cx:_,theme:v}=Tf({radius:o,color:i,gradient:l},{name:[`ActionIcon`,m],unstyled:p,size:s,variant:c}),y=Z.createElement(ti,jf({color:v.fn.variant({color:i,variant:c}).color,size:`100%`,"data-action-icon-loader":!0},d));return Z.createElement(rf,jf({className:_(g.root,r),ref:t,disabled:u,"data-disabled":u||void 0,"data-loading":f||void 0,unstyled:p},h),f?y:a)});Pf.displayName=`@mantine/core/ActionIcon`;var Ff=ir(Pf),If=r(m()),Lf=Object.defineProperty,Rf=Object.defineProperties,zf=Object.getOwnPropertyDescriptors,Bf=Object.getOwnPropertySymbols,Vf=Object.prototype.hasOwnProperty,Hf=Object.prototype.propertyIsEnumerable,Uf=(e,t,n)=>t in e?Lf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wf=(e,t)=>{for(var n in t||={})Vf.call(t,n)&&Uf(e,n,t[n]);if(Bf)for(var n of Bf(t))Hf.call(t,n)&&Uf(e,n,t[n]);return e},Gf=(e,t)=>Rf(e,zf(t)),Kf=(e,t)=>{var n={};for(var r in e)Vf.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Bf)for(var r of Bf(e))t.indexOf(r)<0&&Hf.call(e,r)&&(n[r]=e[r]);return n};function qf(e){let t=X(`Portal`,{},e),{children:n,target:r,className:i,innerRef:a}=t,o=Kf(t,[`children`,`target`,`className`,`innerRef`]),s=Kr(),[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)();return sd(()=>(l(!0),u.current=r?typeof r==`string`?document.querySelector(r):r:document.createElement(`div`),r||document.body.appendChild(u.current),()=>{!r&&document.body.removeChild(u.current)}),[r]),c?(0,If.createPortal)(Z.createElement(`div`,Gf(Wf({className:i,dir:s.dir},o),{ref:a}),n),u.current):null}qf.displayName=`@mantine/core/Portal`;var Jf=Object.defineProperty,Yf=Object.getOwnPropertySymbols,Xf=Object.prototype.hasOwnProperty,Zf=Object.prototype.propertyIsEnumerable,Qf=(e,t,n)=>t in e?Jf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$f=(e,t)=>{for(var n in t||={})Xf.call(t,n)&&Qf(e,n,t[n]);if(Yf)for(var n of Yf(t))Zf.call(t,n)&&Qf(e,n,t[n]);return e},ep=(e,t)=>{var n={};for(var r in e)Xf.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Yf)for(var r of Yf(e))t.indexOf(r)<0&&Zf.call(e,r)&&(n[r]=e[r]);return n};function tp(e){var t=e,{withinPortal:n=!0,children:r}=t,i=ep(t,[`withinPortal`,`children`]);return n?Z.createElement(qf,$f({},i),r):Z.createElement(Z.Fragment,null,r)}tp.displayName=`@mantine/core/OptionalPortal`;var np=Object.defineProperty,rp=Object.getOwnPropertySymbols,ip=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,op=(e,t,n)=>t in e?np(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sp=(e,t)=>{for(var n in t||={})ip.call(t,n)&&op(e,n,t[n]);if(rp)for(var n of rp(t))ap.call(t,n)&&op(e,n,t[n]);return e},cp=(e,t)=>{var n={};for(var r in e)ip.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rp)for(var r of rp(e))t.indexOf(r)<0&&ap.call(e,r)&&(n[r]=e[r]);return n};function lp(e){let t=e,{width:n,height:r,style:i}=t,a=cp(t,[`width`,`height`,`style`]);return Z.createElement(`svg`,sp({viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:sp({width:n,height:r},i)},a),Z.createElement(`path`,{d:`M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`}))}lp.displayName=`@mantine/core/CloseIcon`;var up=Object.defineProperty,dp=Object.getOwnPropertySymbols,fp=Object.prototype.hasOwnProperty,pp=Object.prototype.propertyIsEnumerable,mp=(e,t,n)=>t in e?up(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hp=(e,t)=>{for(var n in t||={})fp.call(t,n)&&mp(e,n,t[n]);if(dp)for(var n of dp(t))pp.call(t,n)&&mp(e,n,t[n]);return e},gp=(e,t)=>{var n={};for(var r in e)fp.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&dp)for(var r of dp(e))t.indexOf(r)<0&&pp.call(e,r)&&(n[r]=e[r]);return n},_p={xs:Y(12),sm:Y(16),md:Y(20),lg:Y(28),xl:Y(34)},vp={size:`sm`},yp=(0,Z.forwardRef)((e,t)=>{let n=X(`CloseButton`,vp,e),{iconSize:r,size:i,children:a}=n,o=gp(n,[`iconSize`,`size`,`children`]),s=Y(r||_p[i]);return Z.createElement(Ff,hp({ref:t,__staticSelector:`CloseButton`,size:i},o),a||Z.createElement(lp,{width:s,height:s}))});yp.displayName=`@mantine/core/CloseButton`;var bp=ir(yp),xp={xs:Y(1),sm:Y(2),md:Y(3),lg:Y(4),xl:Y(5)};function Sp(e,t){let n=e.fn.variant({variant:`outline`,color:t}).border;return typeof t==`string`&&(t in e.colors||t.split(`.`)[0]in e.colors)?n:t===void 0?e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[4]:t}var Cp=Ur((e,{color:t},{size:n,variant:r})=>({root:{},withLabel:{borderTop:`0 !important`},left:{"&::before":{display:`none`}},right:{"&::after":{display:`none`}},label:{display:`flex`,alignItems:`center`,"&::before":{content:`""`,flex:1,height:Y(1),borderTop:`${J({size:n,sizes:xp})} ${r} ${Sp(e,t)}`,marginRight:e.spacing.xs},"&::after":{content:`""`,flex:1,borderTop:`${J({size:n,sizes:xp})} ${r} ${Sp(e,t)}`,marginLeft:e.spacing.xs}},labelDefaultStyles:{color:t===`dark`?e.colors.dark[1]:e.fn.themeColor(t,e.colorScheme===`dark`?5:e.fn.primaryShade(),!1)},horizontal:{border:0,borderTopWidth:Y(J({size:n,sizes:xp})),borderTopColor:Sp(e,t),borderTopStyle:r,margin:0},vertical:{border:0,alignSelf:`stretch`,height:`auto`,borderLeftWidth:Y(J({size:n,sizes:xp})),borderLeftColor:Sp(e,t),borderLeftStyle:r}})),wp=Object.defineProperty,Tp=Object.defineProperties,Ep=Object.getOwnPropertyDescriptors,Dp=Object.getOwnPropertySymbols,Op=Object.prototype.hasOwnProperty,kp=Object.prototype.propertyIsEnumerable,Ap=(e,t,n)=>t in e?wp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jp=(e,t)=>{for(var n in t||={})Op.call(t,n)&&Ap(e,n,t[n]);if(Dp)for(var n of Dp(t))kp.call(t,n)&&Ap(e,n,t[n]);return e},Mp=(e,t)=>Tp(e,Ep(t)),Np=(e,t)=>{var n={};for(var r in e)Op.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Dp)for(var r of Dp(e))t.indexOf(r)<0&&kp.call(e,r)&&(n[r]=e[r]);return n},Pp={orientation:`horizontal`,size:`xs`,labelPosition:`left`,variant:`solid`},Fp=(0,Z.forwardRef)((e,t)=>{let n=X(`Divider`,Pp,e),{className:r,color:i,orientation:a,size:o,label:s,labelPosition:c,labelProps:l,variant:u,styles:d,classNames:f,unstyled:p}=n,m=Np(n,[`className`,`color`,`orientation`,`size`,`label`,`labelPosition`,`labelProps`,`variant`,`styles`,`classNames`,`unstyled`]),{classes:h,cx:g}=Cp({color:i},{classNames:f,styles:d,unstyled:p,name:`Divider`,variant:u,size:o}),_=a===`vertical`,v=a===`horizontal`,y=!!s&&v,b=!l?.color;return Z.createElement(Br,jp({ref:t,className:g(h.root,{[h.vertical]:_,[h.horizontal]:v,[h.withLabel]:y},r),role:`separator`},m),y&&Z.createElement(_i,Mp(jp({},l),{size:l?.size||`xs`,mt:Y(2),className:g(h.label,h[c],{[h.labelDefaultStyles]:b})}),s))});Fp.displayName=`@mantine/core/Divider`;var Ip=Object.defineProperty,Lp=Object.defineProperties,Rp=Object.getOwnPropertyDescriptors,zp=Object.getOwnPropertySymbols,Bp=Object.prototype.hasOwnProperty,Vp=Object.prototype.propertyIsEnumerable,Hp=(e,t,n)=>t in e?Ip(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Up=(e,t)=>{for(var n in t||={})Bp.call(t,n)&&Hp(e,n,t[n]);if(zp)for(var n of zp(t))Vp.call(t,n)&&Hp(e,n,t[n]);return e},Wp=(e,t)=>Lp(e,Rp(t)),Gp=Ur((e,t,{size:n})=>({item:Wp(Up({},e.fn.fontStyles()),{boxSizing:`border-box`,wordBreak:`break-all`,textAlign:`left`,width:`100%`,padding:`calc(${J({size:n,sizes:e.spacing})} / 1.5) ${J({size:n,sizes:e.spacing})}`,cursor:`pointer`,fontSize:J({size:n,sizes:e.fontSizes}),color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,borderRadius:e.fn.radius(),"&[data-hovered]":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[1]},"&[data-selected]":Up({backgroundColor:e.fn.variant({variant:`filled`}).background,color:e.fn.variant({variant:`filled`}).color},e.fn.hover({backgroundColor:e.fn.variant({variant:`filled`}).hover})),"&[data-disabled]":{cursor:`default`,color:e.colors.dark[2]}}),nothingFound:{boxSizing:`border-box`,color:e.colors.gray[6],paddingTop:`calc(${J({size:n,sizes:e.spacing})} / 2)`,paddingBottom:`calc(${J({size:n,sizes:e.spacing})} / 2)`,textAlign:`center`},separator:{boxSizing:`border-box`,textAlign:`left`,width:`100%`,padding:`calc(${J({size:n,sizes:e.spacing})} / 1.5) ${J({size:n,sizes:e.spacing})}`},separatorLabel:{color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[5]}})),Kp=Object.defineProperty,qp=Object.getOwnPropertySymbols,Jp=Object.prototype.hasOwnProperty,Yp=Object.prototype.propertyIsEnumerable,Xp=(e,t,n)=>t in e?Kp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zp=(e,t)=>{for(var n in t||={})Jp.call(t,n)&&Xp(e,n,t[n]);if(qp)for(var n of qp(t))Yp.call(t,n)&&Xp(e,n,t[n]);return e};function Qp({data:e,hovered:t,classNames:n,styles:r,isItemSelected:i,uuid:a,__staticSelector:o,onItemHover:s,onItemSelect:c,itemsRefs:l,itemComponent:u,size:d,nothingFound:f,creatable:p,createLabel:m,unstyled:h,variant:g}){let{classes:_}=Gp(null,{classNames:n,styles:r,unstyled:h,name:o,variant:g,size:d}),v=[],y=[],b=null,x=(e,n)=>{let r=typeof i==`function`&&i(e.value);return Z.createElement(u,Zp({key:e.value,className:_.item,"data-disabled":e.disabled||void 0,"data-hovered":!e.disabled&&t===n||void 0,"data-selected":!e.disabled&&r||void 0,selected:r,onMouseEnter:()=>s(n),id:`${a}-${n}`,role:`option`,tabIndex:-1,"aria-selected":t===n,ref:t=>{l&&l.current&&(l.current[e.value]=t)},onMouseDown:e.disabled?null:t=>{t.preventDefault(),c(e)},disabled:e.disabled,variant:g},e))},S=null;if(e.forEach((e,t)=>{e.creatable?b=t:e.group?(S!==e.group&&(S=e.group,y.push(Z.createElement(`div`,{className:_.separator,key:`__mantine-divider-${t}`},Z.createElement(Fp,{classNames:{label:_.separatorLabel},label:e.group})))),y.push(x(e,t))):v.push(x(e,t))}),p){let n=e[b];v.push(Z.createElement(`div`,{key:vd(),className:_.item,"data-hovered":t===b||void 0,onMouseEnter:()=>s(b),onMouseDown:e=>{e.preventDefault(),c(n)},tabIndex:-1,ref:e=>{l&&l.current&&(l.current[n.value]=e)}},m))}return y.length>0&&v.length>0&&v.unshift(Z.createElement(`div`,{className:_.separator,key:`empty-group-separator`},Z.createElement(Fp,null))),y.length>0||v.length>0?Z.createElement(Z.Fragment,null,y,v):Z.createElement(_i,{size:d,unstyled:h,className:_.nothingFound},f)}Qp.displayName=`@mantine/core/SelectItems`;var $p=Object.defineProperty,em=Object.getOwnPropertySymbols,tm=Object.prototype.hasOwnProperty,nm=Object.prototype.propertyIsEnumerable,rm=(e,t,n)=>t in e?$p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,im=(e,t)=>{for(var n in t||={})tm.call(t,n)&&rm(e,n,t[n]);if(em)for(var n of em(t))nm.call(t,n)&&rm(e,n,t[n]);return e},am=(e,t)=>{var n={};for(var r in e)tm.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&em)for(var r of em(e))t.indexOf(r)<0&&nm.call(e,r)&&(n[r]=e[r]);return n},om=(0,Z.forwardRef)((e,t)=>{var n=e,{label:r,value:i}=n,a=am(n,[`label`,`value`]);return Z.createElement(`div`,im({ref:t},a),r||i)});om.displayName=`@mantine/core/DefaultItem`;function sm(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}function cm(...e){return t=>e.forEach(e=>sm(e,t))}function lm(...e){return(0,Z.useCallback)(cm(...e),e)}var um=(0,Z.forwardRef)((e,t)=>{let{children:n,...r}=e,i=Z.Children.toArray(n),a=i.find(pm);if(a){let e=a.props.children,n=i.map(t=>t===a?Z.Children.count(e)>1?Z.Children.only(null):(0,Z.isValidElement)(e)?e.props.children:null:t);return(0,Z.createElement)(dm,Tr({},r,{ref:t}),(0,Z.isValidElement)(e)?(0,Z.cloneElement)(e,void 0,n):null)}return(0,Z.createElement)(dm,Tr({},r,{ref:t}),n)});um.displayName=`Slot`;var dm=(0,Z.forwardRef)((e,t)=>{let{children:n,...r}=e;return(0,Z.isValidElement)(n)?(0,Z.cloneElement)(n,{...mm(r,n.props),ref:cm(t,n.ref)}):Z.Children.count(n)>1?Z.Children.only(null):null});dm.displayName=`SlotClone`;var fm=({children:e})=>(0,Z.createElement)(Z.Fragment,null,e);function pm(e){return(0,Z.isValidElement)(e)&&e.type===fm}function mm(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}var hm=[`a`,`button`,`div`,`h2`,`h3`,`img`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=(0,Z.forwardRef)((e,n)=>{let{asChild:r,...i}=e,a=r?um:t;return(0,Z.useEffect)(()=>{window[Symbol.for(`radix-ui`)]=!0},[]),(0,Z.createElement)(a,Tr({},i,{ref:n}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),gm=globalThis!=null&&globalThis.document?Z.useLayoutEffect:()=>{};function _m(e,t){return(0,Z.useReducer)((e,n)=>t[e][n]??e,e)}var vm=e=>{let{present:t,children:n}=e,r=ym(t),i=typeof n==`function`?n({present:r.isPresent}):Z.Children.only(n),a=lm(r.ref,i.ref);return typeof n==`function`||r.isPresent?(0,Z.cloneElement)(i,{ref:a}):null};vm.displayName=`Presence`;function ym(e){let[t,n]=(0,Z.useState)(),r=(0,Z.useRef)({}),i=(0,Z.useRef)(e),a=(0,Z.useRef)(`none`),[o,s]=_m(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return(0,Z.useEffect)(()=>{let e=bm(r.current);a.current=o===`mounted`?e:`none`},[o]),gm(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=bm(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),gm(()=>{if(t){let e=e=>{let n=bm(r.current).includes(e.animationName);e.target===t&&n&&(0,If.flushSync)(()=>s(`ANIMATION_END`))},n=e=>{e.target===t&&(a.current=bm(r.current))};return t.addEventListener(`animationstart`,n),t.addEventListener(`animationcancel`,e),t.addEventListener(`animationend`,e),()=>{t.removeEventListener(`animationstart`,n),t.removeEventListener(`animationcancel`,e),t.removeEventListener(`animationend`,e)}}s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:(0,Z.useCallback)(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function bm(e){return e?.animationName||`none`}function xm(e,t=[]){let n=[];function r(t,r){let i=(0,Z.createContext)(r),a=n.length;n=[...n,r];function o(t){let{scope:n,children:r,...o}=t,s=n?.[e][a]||i,c=(0,Z.useMemo)(()=>o,Object.values(o));return(0,Z.createElement)(s.Provider,{value:c},r)}function s(n,o){let s=o?.[e][a]||i,c=(0,Z.useContext)(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return o.displayName=t+`Provider`,[o,s]}let i=()=>{let t=n.map(e=>(0,Z.createContext)(e));return function(n){let r=n?.[e]||t;return(0,Z.useMemo)(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Sm(i,...t)]}function Sm(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return(0,Z.useMemo)(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Cm(e){let t=(0,Z.useRef)(e);return(0,Z.useEffect)(()=>{t.current=e}),(0,Z.useMemo)(()=>(...e)=>t.current?.call(t,...e),[])}var wm=(0,Z.createContext)(void 0);function Tm(e){let t=(0,Z.useContext)(wm);return e||t||`ltr`}function Em(e,[t,n]){return Math.min(n,Math.max(t,e))}function Dm(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Om(e,t){return(0,Z.useReducer)((e,n)=>t[e][n]??e,e)}var km=`ScrollArea`,[Am,jm]=xm(km),[Mm,Nm]=Am(km),Pm=(0,Z.forwardRef)((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(0),[y,b]=(0,Z.useState)(0),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),T=lm(t,e=>c(e)),E=Tm(i);return(0,Z.createElement)(Mm,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:w,onCornerWidthChange:v,onCornerHeightChange:b},(0,Z.createElement)(hm.div,Tr({dir:E},o,{ref:T,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})))}),Fm=`ScrollAreaViewport`,Im=(0,Z.forwardRef)((e,t)=>{let{__scopeScrollArea:n,children:r,...i}=e,a=Nm(Fm,n),o=lm(t,(0,Z.useRef)(null),a.onViewportChange);return(0,Z.createElement)(Z.Fragment,null,(0,Z.createElement)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`}}),(0,Z.createElement)(hm.div,Tr({"data-radix-scroll-area-viewport":``},i,{ref:o,style:{overflowX:a.scrollbarXEnabled?`scroll`:`hidden`,overflowY:a.scrollbarYEnabled?`scroll`:`hidden`,...e.style}}),(0,Z.createElement)(`div`,{ref:a.onContentChange,style:{minWidth:`100%`,display:`table`}},r)))}),Lm=`ScrollAreaScrollbar`,Rm=(0,Z.forwardRef)((e,t)=>{let{forceMount:n,...r}=e,i=Nm(Lm,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return(0,Z.useEffect)(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,Z.createElement)(zm,Tr({},r,{ref:t,forceMount:n})):i.type===`scroll`?(0,Z.createElement)(Bm,Tr({},r,{ref:t,forceMount:n})):i.type===`auto`?(0,Z.createElement)(Vm,Tr({},r,{ref:t,forceMount:n})):i.type===`always`?(0,Z.createElement)(Hm,Tr({},r,{ref:t})):null}),zm=(0,Z.forwardRef)((e,t)=>{let{forceMount:n,...r}=e,i=Nm(Lm,e.__scopeScrollArea),[a,o]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,Z.createElement)(vm,{present:n||a},(0,Z.createElement)(Vm,Tr({"data-state":a?`visible`:`hidden`},r,{ref:t})))}),Bm=(0,Z.forwardRef)((e,t)=>{let{forceMount:n,...r}=e,i=Nm(Lm,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=ch(()=>c(`SCROLL_END`),100),[s,c]=Om(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return(0,Z.useEffect)(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),(0,Z.useEffect)(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,Z.createElement)(vm,{present:n||s!==`hidden`},(0,Z.createElement)(Hm,Tr({"data-state":s===`hidden`?`hidden`:`visible`},r,{ref:t,onPointerEnter:Dm(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:Dm(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})))}),Vm=(0,Z.forwardRef)((e,t)=>{let n=Nm(Lm,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=(0,Z.useState)(!1),s=e.orientation===`horizontal`,c=ch(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return lh(n.viewport,c),lh(n.content,c),(0,Z.createElement)(vm,{present:r||a},(0,Z.createElement)(Hm,Tr({"data-state":a?`visible`:`hidden`},i,{ref:t})))}),Hm=(0,Z.forwardRef)((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=Nm(Lm,e.__scopeScrollArea),a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),[s,c]=(0,Z.useState)({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=th(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return rh(e,o.current,s,t)}return n===`horizontal`?(0,Z.createElement)(Um,Tr({},u,{ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ih(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}})):n===`vertical`?(0,Z.createElement)(Wm,Tr({},u,{ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ih(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}})):null}),Um=(0,Z.forwardRef)((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Nm(Lm,e.__scopeScrollArea),[o,s]=(0,Z.useState)(),c=(0,Z.useRef)(null),l=lm(t,c,a.onScrollbarXChange);return(0,Z.useEffect)(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,Z.createElement)(qm,Tr({"data-orientation":`horizontal`},i,{ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":nh(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),oh(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:eh(o.paddingLeft),paddingEnd:eh(o.paddingRight)}})}}))}),Wm=(0,Z.forwardRef)((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=Nm(Lm,e.__scopeScrollArea),[o,s]=(0,Z.useState)(),c=(0,Z.useRef)(null),l=lm(t,c,a.onScrollbarYChange);return(0,Z.useEffect)(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,Z.createElement)(qm,Tr({"data-orientation":`vertical`},i,{ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":nh(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),oh(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:eh(o.paddingTop),paddingEnd:eh(o.paddingBottom)}})}}))}),[Gm,Km]=Am(Lm),qm=(0,Z.forwardRef)((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=Nm(Lm,n),[m,h]=(0,Z.useState)(null),g=lm(t,e=>h(e)),_=(0,Z.useRef)(null),v=(0,Z.useRef)(``),y=p.viewport,b=r.content-r.viewport,x=Cm(u),S=Cm(c),C=ch(d,10);function w(e){if(_.current){let t=e.clientX-_.current.left,n=e.clientY-_.current.top;l({x:t,y:n})}}return(0,Z.useEffect)(()=>{let e=e=>{let t=e.target;m?.contains(t)&&x(e,b)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),(0,Z.useEffect)(S,[r,S]),lh(m,C),lh(p.content,C),(0,Z.createElement)(Gm,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Cm(a),onThumbPointerUp:Cm(o),onThumbPositionChange:S,onThumbPointerDown:Cm(s)},(0,Z.createElement)(hm.div,Tr({},f,{ref:g,style:{position:`absolute`,...f.style},onPointerDown:Dm(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,w(e))}),onPointerMove:Dm(e.onPointerMove,w),onPointerUp:Dm(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,_.current=null})})))}),Jm=`ScrollAreaThumb`,Ym=(0,Z.forwardRef)((e,t)=>{let{forceMount:n,...r}=e,i=Km(Jm,e.__scopeScrollArea);return(0,Z.createElement)(vm,{present:n||i.hasThumb},(0,Z.createElement)(Xm,Tr({ref:t},r)))}),Xm=(0,Z.forwardRef)((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=Nm(Jm,n),o=Km(Jm,n),{onThumbPositionChange:s}=o,c=lm(t,e=>o.onThumbChange(e)),l=(0,Z.useRef)(),u=ch(()=>{l.current&&=(l.current(),void 0)},100);return(0,Z.useEffect)(()=>{let e=a.viewport;if(e){let t=()=>{if(u(),!l.current){let t=sh(e,s);l.current=t,s()}};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,Z.createElement)(hm.div,Tr({"data-state":o.hasThumb?`visible`:`hidden`},i,{ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:Dm(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:Dm(e.onPointerUp,o.onThumbPointerUp)}))}),Zm=`ScrollAreaCorner`,Qm=(0,Z.forwardRef)((e,t)=>{let n=Nm(Zm,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,Z.createElement)($m,Tr({},e,{ref:t})):null}),$m=(0,Z.forwardRef)((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=Nm(Zm,n),[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(0),l=!!(a&&s);return lh(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),lh(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,Z.createElement)(hm.div,Tr({},r,{ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}})):null});function eh(e){return e?parseInt(e,10):0}function th(e,t){let n=e/t;return isNaN(n)?0:n}function nh(e){let t=th(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rh(e,t,n,r=`ltr`){let i=nh(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return ah([c,l],d)(e)}function ih(e,t,n=`ltr`){let r=nh(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Em(e,n===`ltr`?[0,o]:[o*-1,0]);return ah([0,o],[0,s])(c)}function ah(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function oh(e,t){return e>0&&e<t}var sh=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function ch(e,t){let n=Cm(e),r=(0,Z.useRef)(0);return(0,Z.useEffect)(()=>()=>window.clearTimeout(r.current),[]),(0,Z.useCallback)(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function lh(e,t){let n=Cm(t);gm(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var uh=Pm,dh=Im,fh=Rm,ph=Ym,mh=Qm,hh=Ur((e,{scrollbarSize:t,offsetScrollbars:n,scrollbarHovered:r,hidden:i})=>({root:{overflow:`hidden`},viewport:{width:`100%`,height:`100%`,paddingRight:n?Y(t):void 0,paddingBottom:n?Y(t):void 0},scrollbar:{display:i?`none`:`flex`,userSelect:`none`,touchAction:`none`,boxSizing:`border-box`,padding:`calc(${Y(t)} / 5)`,transition:`background-color 150ms ease, opacity 150ms ease`,"&:hover":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[8]:e.colors.gray[0],[`& .${Uu(`thumb`)}`]:{backgroundColor:e.colorScheme===`dark`?e.fn.rgba(e.white,.5):e.fn.rgba(e.black,.5)}},'&[data-orientation="vertical"]':{width:Y(t)},'&[data-orientation="horizontal"]':{flexDirection:`column`,height:Y(t)},'&[data-state="hidden"]':{display:`none`,opacity:0}},thumb:{ref:Uu(`thumb`),flex:1,backgroundColor:e.colorScheme===`dark`?e.fn.rgba(e.white,.4):e.fn.rgba(e.black,.4),borderRadius:Y(t),position:`relative`,transition:`background-color 150ms ease`,display:i?`none`:void 0,overflow:`hidden`,"&::before":{content:`""`,position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,width:`100%`,height:`100%`,minWidth:Y(44),minHeight:Y(44)}},corner:{backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.colors.gray[0],transition:`opacity 150ms ease`,opacity:+!!r,display:i?`none`:void 0}})),gh=Object.defineProperty,_h=Object.defineProperties,vh=Object.getOwnPropertyDescriptors,yh=Object.getOwnPropertySymbols,bh=Object.prototype.hasOwnProperty,xh=Object.prototype.propertyIsEnumerable,Sh=(e,t,n)=>t in e?gh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ch=(e,t)=>{for(var n in t||={})bh.call(t,n)&&Sh(e,n,t[n]);if(yh)for(var n of yh(t))xh.call(t,n)&&Sh(e,n,t[n]);return e},wh=(e,t)=>_h(e,vh(t)),Th=(e,t)=>{var n={};for(var r in e)bh.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&yh)for(var r of yh(e))t.indexOf(r)<0&&xh.call(e,r)&&(n[r]=e[r]);return n},Eh={scrollbarSize:12,scrollHideDelay:1e3,type:`hover`,offsetScrollbars:!1},Dh=(0,Z.forwardRef)((e,t)=>{let n=X(`ScrollArea`,Eh,e),{children:r,className:i,classNames:a,styles:o,scrollbarSize:s,scrollHideDelay:c,type:l,dir:u,offsetScrollbars:d,viewportRef:f,onScrollPositionChange:p,unstyled:m,variant:h,viewportProps:g}=n,_=Th(n,[`children`,`className`,`classNames`,`styles`,`scrollbarSize`,`scrollHideDelay`,`type`,`dir`,`offsetScrollbars`,`viewportRef`,`onScrollPositionChange`,`unstyled`,`variant`,`viewportProps`]),[v,y]=(0,Z.useState)(!1),b=Kr(),{classes:x,cx:S}=hh({scrollbarSize:s,offsetScrollbars:d,scrollbarHovered:v,hidden:l===`never`},{name:`ScrollArea`,classNames:a,styles:o,unstyled:m,variant:h});return Z.createElement(uh,{type:l===`never`?`always`:l,scrollHideDelay:c,dir:u||b.dir,ref:t,asChild:!0},Z.createElement(Br,Ch({className:S(x.root,i)},_),Z.createElement(dh,wh(Ch({},g),{className:x.viewport,ref:f,onScroll:typeof p==`function`?({currentTarget:e})=>p({x:e.scrollLeft,y:e.scrollTop}):void 0}),r),Z.createElement(fh,{orientation:`horizontal`,className:x.scrollbar,forceMount:!0,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)},Z.createElement(ph,{className:x.thumb})),Z.createElement(fh,{orientation:`vertical`,className:x.scrollbar,forceMount:!0,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)},Z.createElement(ph,{className:x.thumb})),Z.createElement(mh,{className:x.corner})))}),Oh=(0,Z.forwardRef)((e,t)=>{let n=X(`ScrollAreaAutosize`,Eh,e),{children:r,classNames:i,styles:a,scrollbarSize:o,scrollHideDelay:s,type:c,dir:l,offsetScrollbars:u,viewportRef:d,onScrollPositionChange:f,unstyled:p,sx:m,variant:h,viewportProps:g}=n,_=Th(n,[`children`,`classNames`,`styles`,`scrollbarSize`,`scrollHideDelay`,`type`,`dir`,`offsetScrollbars`,`viewportRef`,`onScrollPositionChange`,`unstyled`,`sx`,`variant`,`viewportProps`]);return Z.createElement(Br,wh(Ch({},_),{ref:t,sx:[{display:`flex`},...Iu(m)]}),Z.createElement(Br,{sx:{display:`flex`,flexDirection:`column`,flex:1}},Z.createElement(Dh,{classNames:i,styles:a,scrollHideDelay:s,scrollbarSize:o,type:c,dir:l,offsetScrollbars:u,viewportRef:d,onScrollPositionChange:f,unstyled:p,variant:h,viewportProps:g},r)))});Oh.displayName=`@mantine/core/ScrollAreaAutosize`,Dh.displayName=`@mantine/core/ScrollArea`,Dh.Autosize=Oh;var kh=Dh,Ah=Object.defineProperty,jh=Object.defineProperties,Mh=Object.getOwnPropertyDescriptors,Nh=Object.getOwnPropertySymbols,Ph=Object.prototype.hasOwnProperty,Fh=Object.prototype.propertyIsEnumerable,Ih=(e,t,n)=>t in e?Ah(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lh=(e,t)=>{for(var n in t||={})Ph.call(t,n)&&Ih(e,n,t[n]);if(Nh)for(var n of Nh(t))Fh.call(t,n)&&Ih(e,n,t[n]);return e},Rh=(e,t)=>jh(e,Mh(t)),zh=(e,t)=>{var n={};for(var r in e)Ph.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Nh)for(var r of Nh(e))t.indexOf(r)<0&&Fh.call(e,r)&&(n[r]=e[r]);return n},Bh=(0,Z.forwardRef)((e,t)=>{var n=e,{style:r}=n,i=zh(n,[`style`]);return Z.createElement(kh,Rh(Lh({},i),{style:Lh({width:`100%`},r),viewportProps:{tabIndex:-1},viewportRef:t}),i.children)});Bh.displayName=`@mantine/core/SelectScrollArea`;var Vh=Ur(()=>({dropdown:{},itemsWrapper:{padding:Y(4),display:`flex`,width:`100%`,boxSizing:`border-box`}})),Hh=e=>{let{element:t,padding:n}=e;function r(e){return Object.prototype.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(e){return r(t)?t.current==null?{}:An({element:t.current,padding:n}).fn(e):t?An({element:t,padding:n}).fn(e):{}}}},Uh=typeof document<`u`?Z.useLayoutEffect:Z.useEffect;function Wh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Wh(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Wh(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Gh(e){let t=Z.useRef(e);return Uh(()=>{t.current=e}),t}function Kh(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,whileElementsMounted:a,open:o}=e,[s,c]=Z.useState({x:null,y:null,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[l,u]=Z.useState(r);Wh(l,r)||u(r);let d=Z.useRef(null),f=Z.useRef(null),p=Z.useRef(s),m=Gh(a),h=Gh(i),[g,_]=Z.useState(null),[v,y]=Z.useState(null),b=Z.useCallback(e=>{d.current!==e&&(d.current=e,_(e))},[]),x=Z.useCallback(e=>{f.current!==e&&(f.current=e,y(e))},[]),S=Z.useCallback(()=>{if(!d.current||!f.current)return;let e={placement:t,strategy:n,middleware:l};h.current&&(e.platform=h.current),Ct(d.current,f.current,e).then(e=>{let t={...e,isPositioned:!0};C.current&&!Wh(p.current,t)&&(p.current=t,If.flushSync(()=>{c(t)}))})},[l,t,n,h]);Uh(()=>{o===!1&&p.current.isPositioned&&(p.current.isPositioned=!1,c(e=>({...e,isPositioned:!1})))},[o]);let C=Z.useRef(!1);Uh(()=>(C.current=!0,()=>{C.current=!1}),[]),Uh(()=>{if(g&&v){if(m.current)return m.current(g,v,S);S()}},[g,v,S,m]);let w=Z.useMemo(()=>({reference:d,floating:f,setReference:b,setFloating:x}),[b,x]),T=Z.useMemo(()=>({reference:g,floating:v}),[g,v]);return Z.useMemo(()=>({...s,update:S,refs:w,elements:T,reference:b,floating:x}),[s,S,w,T,b,x])}var qh=typeof document<`u`?Z.useLayoutEffect:Z.useEffect,Jh=!1,Yh=0,Xh=()=>`floating-ui-`+Yh++;function Zh(){let[e,t]=Z.useState(()=>Jh?Xh():void 0);return qh(()=>{e??t(Xh())},[]),Z.useEffect(()=>{Jh||=!0},[]),e}var Qh=Z.useId||Zh;function $h(){let e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(e=>e(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter(e=>e!==n))}}}var eg=Z.createContext(null),tg=Z.createContext(null),ng=()=>Z.useContext(eg)?.id||null,rg=()=>Z.useContext(tg);function ig(e){return e?.ownerDocument||document}function ag(){let e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function og(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(e=>{let{brand:t,version:n}=e;return t+`/`+n}).join(` `):navigator.userAgent}function sg(e){return ig(e).defaultView||window}function cg(e){return e?e instanceof sg(e).Element:!1}function lg(e){return e?e instanceof sg(e).HTMLElement:!1}function ug(e){return typeof ShadowRoot>`u`?!1:e instanceof sg(e).ShadowRoot||e instanceof ShadowRoot}function dg(e){if(e.mozInputSource===0&&e.isTrusted)return!0;let t=/Android/i;return(t.test(ag())||t.test(og()))&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function fg(e){return e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType!==`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0}function pg(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function mg(e){let t=(0,Z.useRef)(e);return qh(()=>{t.current=e}),t}var hg=`data-floating-ui-safe-polygon`;function gg(e,t,n){return n&&!pg(n)?0:typeof e==`number`?e:e?.[t]}var _g=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0}=t===void 0?{}:t,{open:c,onOpenChange:l,dataRef:u,events:d,elements:{domReference:f,floating:p},refs:m}=e,h=rg(),g=ng(),_=mg(i),v=mg(r),y=Z.useRef(),b=Z.useRef(),x=Z.useRef(),S=Z.useRef(),C=Z.useRef(!0),w=Z.useRef(!1),T=Z.useRef(()=>{}),E=Z.useCallback(()=>{let e=u.current.openEvent?.type;return e?.includes(`mouse`)&&e!==`mousedown`},[u]);Z.useEffect(()=>{if(!n)return;function e(){clearTimeout(b.current),clearTimeout(S.current),C.current=!0}return d.on(`dismiss`,e),()=>{d.off(`dismiss`,e)}},[n,d]),Z.useEffect(()=>{if(!n||!_.current||!c)return;function e(){E()&&l(!1)}let t=ig(p).documentElement;return t.addEventListener(`mouseleave`,e),()=>{t.removeEventListener(`mouseleave`,e)}},[p,c,l,n,_,u,E]);let D=Z.useCallback(function(e){e===void 0&&(e=!0);let t=gg(v.current,`close`,y.current);t&&!x.current?(clearTimeout(b.current),b.current=setTimeout(()=>l(!1),t)):e&&(clearTimeout(b.current),l(!1))},[v,l]),O=Z.useCallback(()=>{T.current(),x.current=void 0},[]),k=Z.useCallback(()=>{if(w.current){let e=ig(m.floating.current).body;e.style.pointerEvents=``,e.removeAttribute(hg),w.current=!1}},[m]);return Z.useEffect(()=>{if(!n)return;function t(){return u.current.openEvent?[`click`,`mousedown`].includes(u.current.openEvent.type):!1}function r(e){if(clearTimeout(b.current),C.current=!1,a&&!pg(y.current)||o>0&&gg(v.current,`open`)===0)return;u.current.openEvent=e;let t=gg(v.current,`open`,y.current);t?b.current=setTimeout(()=>{l(!0)},t):l(!0)}function i(n){if(t())return;T.current();let r=ig(p);if(clearTimeout(S.current),_.current){c||clearTimeout(b.current),x.current=_.current({...e,tree:h,x:n.clientX,y:n.clientY,onClose(){k(),O(),D()}});let t=x.current;r.addEventListener(`mousemove`,t),T.current=()=>{r.removeEventListener(`mousemove`,t)};return}D()}function d(n){t()||_.current==null||_.current({...e,tree:h,x:n.clientX,y:n.clientY,onClose(){k(),O(),D()}})(n)}if(cg(f)){let e=f;return c&&e.addEventListener(`mouseleave`,d),p?.addEventListener(`mouseleave`,d),s&&e.addEventListener(`mousemove`,r,{once:!0}),e.addEventListener(`mouseenter`,r),e.addEventListener(`mouseleave`,i),()=>{c&&e.removeEventListener(`mouseleave`,d),p?.removeEventListener(`mouseleave`,d),s&&e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseenter`,r),e.removeEventListener(`mouseleave`,i)}}},[f,p,n,e,a,o,s,D,O,k,l,c,h,v,_,u]),qh(()=>{var e;if(n&&c&&(e=_.current)!=null&&e.__options.blockPointerEvents&&E()){let e=ig(p).body;if(e.setAttribute(hg,``),e.style.pointerEvents=`none`,w.current=!0,cg(f)&&p){var t;let e=f,n=h==null||(t=h.nodesRef.current.find(e=>e.id===g))==null?void 0:t.context?.elements.floating;return n&&(n.style.pointerEvents=``),e.style.pointerEvents=`auto`,p.style.pointerEvents=`auto`,()=>{e.style.pointerEvents=``,p.style.pointerEvents=``}}}},[n,c,g,p,f,h,_,u,E]),qh(()=>{c||(y.current=void 0,O(),k())},[c,O,k]),Z.useEffect(()=>()=>{O(),clearTimeout(b.current),clearTimeout(S.current),k()},[n,O,k]),Z.useMemo(()=>{if(!n)return{};function e(e){y.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){c||o===0||(clearTimeout(S.current),S.current=setTimeout(()=>{C.current||l(!0)},o))}},floating:{onMouseEnter(){clearTimeout(b.current)},onMouseLeave(){d.emit(`dismiss`,{type:`mouseLeave`,data:{returnFocus:!1}}),D(!1)}}}},[d,n,o,c,l,D])},vg=Z.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:()=>{},setState:()=>{},isInstantPhase:!1}),yg=()=>Z.useContext(vg),bg=e=>{let{children:t,delay:n,timeoutMs:r=0}=e,[i,a]=Z.useReducer((e,t)=>({...e,...t}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),o=Z.useRef(null),s=Z.useCallback(e=>{a({currentId:e})},[]);return qh(()=>{i.currentId?o.current===null?o.current=i.currentId:a({isInstantPhase:!0}):(a({isInstantPhase:!1}),o.current=null)},[i.currentId]),Z.createElement(vg.Provider,{value:Z.useMemo(()=>({...i,setState:a,setCurrentId:s}),[i,a,s])},t)},xg=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:i}=t,{currentId:a,setCurrentId:o,initialDelay:s,setState:c,timeoutMs:l}=yg();Z.useEffect(()=>{a&&(c({delay:{open:1,close:gg(s,`close`)}}),a!==i&&r(!1))},[i,r,c,a,s]),Z.useEffect(()=>{function e(){r(!1),c({delay:s,currentId:null})}if(!n&&a===i){if(l){let t=window.setTimeout(e,l);return()=>{clearTimeout(t)}}e()}},[n,c,a,i,r,s,l]),Z.useEffect(()=>{n&&o(i)},[n,o,i])};function Sg(e){let t=e.activeElement;for(;((n=t)==null?void 0:(r=n.shadowRoot)?.activeElement)!=null;){var n,r;t=t.shadowRoot.activeElement}return t}function Cg(e,t){if(!e||!t)return!1;let n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&ug(n)){let n=t;do{if(n&&e===n)return!0;n=n.parentNode||n.host}while(n)}return!1}function wg(e,t){let n=e.filter(e=>e.parentId===t&&e.context?.open)||[],r=n;for(;r.length;)r=e.filter(e=>r?.some(t=>e.parentId===t.id&&e.context?.open))||[],n=n.concat(r);return n}function Tg(e){return`composedPath`in e?e.composedPath()[0]:e.target}var Eg=Z.useInsertionEffect||(e=>e());function Dg(e){let t=Z.useRef(()=>{});return Eg(()=>{t.current=e}),Z.useCallback(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Og(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}var kg={pointerdown:`onPointerDown`,mousedown:`onMouseDown`,click:`onClick`},Ag={pointerdown:`onPointerDownCapture`,mousedown:`onMouseDownCapture`,click:`onClickCapture`},jg=function(e){return e===void 0&&(e=!0),{escapeKeyBubbles:typeof e==`boolean`?e:e.escapeKey??!0,outsidePressBubbles:typeof e==`boolean`?e:e.outsidePress??!0}},Mg=function(e,t){let{open:n,onOpenChange:r,events:i,nodeId:a,elements:{reference:o,domReference:s,floating:c},dataRef:l}=e,{enabled:u=!0,escapeKey:d=!0,outsidePress:f=!0,outsidePressEvent:p=`pointerdown`,referencePress:m=!1,referencePressEvent:h=`pointerdown`,ancestorScroll:g=!1,bubbles:_=!0}=t===void 0?{}:t,v=rg(),y=ng()!=null,b=Dg(typeof f==`function`?f:()=>!1),x=typeof f==`function`?b:f,S=Z.useRef(!1),{escapeKeyBubbles:C,outsidePressBubbles:w}=jg(_);return Z.useEffect(()=>{if(!n||!u)return;l.current.__escapeKeyBubbles=C,l.current.__outsidePressBubbles=w;function e(e){if(e.key===`Escape`){let e=v?wg(v.nodesRef.current,a):[];if(e.length>0){let t=!0;if(e.forEach(e=>{var n;if((n=e.context)!=null&&n.open&&!e.context.dataRef.current.__escapeKeyBubbles){t=!1;return}}),!t)return}i.emit(`dismiss`,{type:`escapeKey`,data:{returnFocus:{preventScroll:!1}}}),r(!1)}}function t(e){let t=S.current;if(S.current=!1,t||typeof x==`function`&&!x(e))return;let n=Tg(e);if(lg(n)&&c){let t=c.ownerDocument.defaultView||window,r=n.scrollWidth>n.clientWidth,i=n.scrollHeight>n.clientHeight,a=i&&e.offsetX>n.clientWidth;if(i&&t.getComputedStyle(n).direction===`rtl`&&(a=e.offsetX<=n.offsetWidth-n.clientWidth),a||r&&e.offsetY>n.clientHeight)return}let o=v&&wg(v.nodesRef.current,a).some(t=>Og(e,t.context?.elements.floating));if(Og(e,c)||Og(e,s)||o)return;let l=v?wg(v.nodesRef.current,a):[];if(l.length>0){let e=!0;if(l.forEach(t=>{var n;if((n=t.context)!=null&&n.open&&!t.context.dataRef.current.__outsidePressBubbles){e=!1;return}}),!e)return}i.emit(`dismiss`,{type:`outsidePress`,data:{returnFocus:y?{preventScroll:!0}:dg(e)||fg(e)}}),r(!1)}function f(){r(!1)}let m=ig(c);d&&m.addEventListener(`keydown`,e),x&&m.addEventListener(p,t);let h=[];return g&&(cg(s)&&(h=St(s)),cg(c)&&(h=h.concat(St(c))),!cg(o)&&o&&o.contextElement&&(h=h.concat(St(o.contextElement)))),h=h.filter(e=>e!==m.defaultView?.visualViewport),h.forEach(e=>{e.addEventListener(`scroll`,f,{passive:!0})}),()=>{d&&m.removeEventListener(`keydown`,e),x&&m.removeEventListener(p,t),h.forEach(e=>{e.removeEventListener(`scroll`,f)})}},[l,c,s,o,d,x,p,i,v,a,n,r,g,u,C,w,y]),Z.useEffect(()=>{S.current=!1},[x,p]),Z.useMemo(()=>u?{reference:{[kg[h]]:()=>{m&&(i.emit(`dismiss`,{type:`referencePress`,data:{returnFocus:!1}}),r(!1))}},floating:{[Ag[p]]:()=>{S.current=!0}}}:{},[u,i,m,p,h,r])},Ng=function(e,t){let{open:n,onOpenChange:r,dataRef:i,events:a,refs:o,elements:{floating:s,domReference:c}}=e,{enabled:l=!0,keyboardOnly:u=!0}=t===void 0?{}:t,d=Z.useRef(``),f=Z.useRef(!1),p=Z.useRef();return Z.useEffect(()=>{if(!l)return;let e=ig(s).defaultView||window;function t(){!n&&lg(c)&&c===Sg(ig(c))&&(f.current=!0)}return e.addEventListener(`blur`,t),()=>{e.removeEventListener(`blur`,t)}},[s,c,n,l]),Z.useEffect(()=>{if(!l)return;function e(e){(e.type===`referencePress`||e.type===`escapeKey`)&&(f.current=!0)}return a.on(`dismiss`,e),()=>{a.off(`dismiss`,e)}},[a,l]),Z.useEffect(()=>()=>{clearTimeout(p.current)},[]),Z.useMemo(()=>l?{reference:{onPointerDown(e){let{pointerType:t}=e;d.current=t,f.current=!!(t&&u)},onMouseLeave(){f.current=!1},onFocus(e){f.current||e.type===`focus`&&i.current.openEvent?.type===`mousedown`&&i.current.openEvent&&Og(i.current.openEvent,c)||(i.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){f.current=!1;let t=e.relatedTarget,n=cg(t)&&t.hasAttribute(`data-floating-ui-focus-guard`)&&t.getAttribute(`data-type`)===`outside`;p.current=setTimeout(()=>{Cg(o.floating.current,t)||Cg(c,t)||n||r(!1)})}}}:{},[l,u,c,o,i,r])},Pg=function(e,t){let{open:n}=e,{enabled:r=!0,role:i=`dialog`}=t===void 0?{}:t,a=Qh(),o=Qh();return Z.useMemo(()=>{let e={id:a,role:i};return r?i===`tooltip`?{reference:{"aria-describedby":n?a:void 0},floating:e}:{reference:{"aria-expanded":n?`true`:`false`,"aria-haspopup":i===`alertdialog`?`dialog`:i,"aria-controls":n?a:void 0,...i===`listbox`&&{role:`combobox`},...i===`menu`&&{id:o}},floating:{...e,...i===`menu`&&{"aria-labelledby":o}}}:{}},[r,i,n,a,o])};function Fg(e){e===void 0&&(e={});let{open:t=!1,onOpenChange:n,nodeId:r}=e,i=Kh(e),a=rg(),o=Z.useRef(null),s=Z.useRef({}),c=Z.useState(()=>$h())[0],[l,u]=Z.useState(null),d=Z.useCallback(e=>{let t=cg(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;i.refs.setReference(t)},[i.refs]),f=Z.useCallback(e=>{(cg(e)||e===null)&&(o.current=e,u(e)),(cg(i.refs.reference.current)||i.refs.reference.current===null||e!==null&&!cg(e))&&i.refs.setReference(e)},[i.refs]),p=Z.useMemo(()=>({...i.refs,setReference:f,setPositionReference:d,domReference:o}),[i.refs,f,d]),m=Z.useMemo(()=>({...i.elements,domReference:l}),[i.elements,l]),h=Dg(n),g=Z.useMemo(()=>({...i,refs:p,elements:m,dataRef:s,nodeId:r,events:c,open:t,onOpenChange:h}),[i,r,c,t,h,p,m]);return qh(()=>{let e=a?.nodesRef.current.find(e=>e.id===r);e&&(e.context=g)}),Z.useMemo(()=>({...i,context:g,refs:p,reference:f,positionReference:d}),[i,p,g,f,d])}function Ig(e,t,n){let r=new Map;return{...n===`floating`&&{tabIndex:-1},...e,...t.map(e=>e?e[n]:null).concat(e).reduce((e,t)=>(t&&Object.entries(t).forEach(t=>{let[n,i]=t;if(n.indexOf(`on`)===0){if(r.has(n)||r.set(n,[]),typeof i==`function`){var a;(a=r.get(n))==null||a.push(i),e[n]=function(){var e,t=[...arguments];(e=r.get(n))==null||e.forEach(e=>e(...t))}}}else e[n]=i}),e),{})}}var Lg=function(e){e===void 0&&(e=[]);let t=e,n=Z.useCallback(t=>Ig(t,e,`reference`),t),r=Z.useCallback(t=>Ig(t,e,`floating`),t),i=Z.useCallback(t=>Ig(t,e,`item`),e.map(e=>e?.item));return Z.useMemo(()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:i}),[n,r,i])};function Rg({opened:e,floating:t,position:n,positionDependencies:r}){let[i,a]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{if(t.refs.reference.current&&t.refs.floating.current)return zt(t.refs.reference.current,t.refs.floating.current,t.update)},[t.refs.reference.current,t.refs.floating.current,e,i,n]),bi(()=>{t.update()},r),bi(()=>{a(e=>e+1)},[e])}function zg(e,t){let n=[wt(e.offset)];return e.middlewares.shift&&n.push(Ft({limiter:Tt()})),e.middlewares.flip&&n.push(kn()),e.middlewares.inline&&n.push(Bt()),n.push(Hh({element:e.arrowRef,padding:e.arrowOffset})),(e.middlewares.size||e.width===`target`)&&n.push(ln({apply({rects:n,availableWidth:r,availableHeight:i}){let a=t().refs.floating.current?.style??{};e.middlewares.size&&Object.assign(a,{maxWidth:`${r}px`,maxHeight:`${i}px`}),e.width===`target`&&Object.assign(a,{width:`${n.reference.width}px`})}})),n}function Bg(e){let[t,n]=Od({value:e.opened,defaultValue:e.defaultOpened,finalValue:!1,onChange:e.onChange}),r=()=>{var t;(t=e.onClose)==null||t.call(e),n(!1)},i=()=>{var r,i;t?((r=e.onClose)==null||r.call(e),n(!1)):((i=e.onOpen)==null||i.call(e),n(!0))},a=Fg({placement:e.position,middleware:zg(e,()=>a)});return Rg({opened:e.opened,position:e.position,positionDependencies:e.positionDependencies,floating:a}),bi(()=>{var t;(t=e.onPositionChange)==null||t.call(e,a.placement)},[a.placement]),bi(()=>{var t,n;e.opened?(n=e.onOpen)==null||n.call(e):(t=e.onClose)==null||t.call(e)},[e.opened]),{floating:a,controlled:typeof e.opened==`boolean`,opened:t,onClose:r,onToggle:i}}var Vg={context:`Popover component was not found in the tree`,children:`Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`},[Hg,Ug]=Fu(Vg.context),Wg=Object.defineProperty,Gg=Object.defineProperties,Kg=Object.getOwnPropertyDescriptors,qg=Object.getOwnPropertySymbols,Jg=Object.prototype.hasOwnProperty,Yg=Object.prototype.propertyIsEnumerable,Xg=(e,t,n)=>t in e?Wg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zg=(e,t)=>{for(var n in t||={})Jg.call(t,n)&&Xg(e,n,t[n]);if(qg)for(var n of qg(t))Yg.call(t,n)&&Xg(e,n,t[n]);return e},Qg=(e,t)=>Gg(e,Kg(t)),$g=(e,t)=>{var n={};for(var r in e)Jg.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qg)for(var r of qg(e))t.indexOf(r)<0&&Yg.call(e,r)&&(n[r]=e[r]);return n},e_={refProp:`ref`,popupType:`dialog`,shouldOverrideDefaultTargetId:!0},t_=(0,Z.forwardRef)((e,t)=>{let n=X(`PopoverTarget`,e_,e),{children:r,refProp:i,popupType:a,shouldOverrideDefaultTargetId:o}=n,s=$g(n,[`children`,`refProp`,`popupType`,`shouldOverrideDefaultTargetId`]);if(!Bu(r))throw Error(Vg.children);let c=s,l=Ug(),u=Dd(l.reference,r.ref,t),d=l.withRoles?{"aria-haspopup":a,"aria-expanded":l.opened,"aria-controls":l.getDropdownId(),id:o?l.getTargetId():r.props.id}:{};return(0,Z.cloneElement)(r,Zg(Qg(Zg(Zg(Zg({},c),d),l.targetProps),{className:ai(l.targetProps.className,c.className,r.props.className),[i]:u}),l.controlled?null:{onClick:l.onToggle}))});t_.displayName=`@mantine/core/PopoverTarget`;var n_=Ur((e,{radius:t,shadow:n})=>({dropdown:{position:`absolute`,backgroundColor:e.white,background:e.colorScheme===`dark`?e.colors.dark[6]:e.white,border:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[2]}`,padding:`${e.spacing.sm} ${e.spacing.md}`,boxShadow:e.shadows[n]||n||`none`,borderRadius:e.fn.radius(t),"&:focus":{outline:0}},arrow:{backgroundColor:`inherit`,border:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[2]}`,zIndex:1}})),r_=Object.defineProperty,i_=Object.getOwnPropertySymbols,a_=Object.prototype.hasOwnProperty,o_=Object.prototype.propertyIsEnumerable,s_=(e,t,n)=>t in e?r_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c_=(e,t)=>{for(var n in t||={})a_.call(t,n)&&s_(e,n,t[n]);if(i_)for(var n of i_(t))o_.call(t,n)&&s_(e,n,t[n]);return e},l_={entering:`in`,entered:`in`,exiting:`out`,exited:`out`,"pre-exiting":`out`,"pre-entering":`out`};function u_({transition:e,state:t,duration:n,timingFunction:r}){let i={transitionDuration:`${n}ms`,transitionTimingFunction:r};return typeof e==`string`?e in ed?c_(c_(c_({transitionProperty:ed[e].transitionProperty},i),ed[e].common),ed[e][l_[t]]):null:c_(c_(c_({transitionProperty:e.transitionProperty},i),e.common),e[l_[t]])}function d_({duration:e,exitDuration:t,timingFunction:n,mounted:r,onEnter:i,onExit:a,onEntered:o,onExited:s}){let c=Kr(),l=kd(),u=c.respectReducedMotion?l:!1,[d,f]=(0,Z.useState)(u?0:e),[p,m]=(0,Z.useState)(r?`entered`:`exited`),h=(0,Z.useRef)(-1),g=n=>{let r=n?i:a,c=n?o:s;m(n?`pre-entering`:`pre-exiting`),window.clearTimeout(h.current);let l=u?0:n?e:t;if(f(l),l===0)typeof r==`function`&&r(),typeof c==`function`&&c(),m(n?`entered`:`exited`);else{let e=window.setTimeout(()=>{typeof r==`function`&&r(),m(n?`entering`:`exiting`)},10);h.current=window.setTimeout(()=>{window.clearTimeout(e),typeof c==`function`&&c(),m(n?`entered`:`exited`)},l)}};return bi(()=>{g(r)},[r]),(0,Z.useEffect)(()=>()=>window.clearTimeout(h.current),[]),{transitionDuration:d,transitionStatus:p,transitionTimingFunction:n||c.transitionTimingFunction}}function f_({keepMounted:e,transition:t,duration:n=250,exitDuration:r=n,mounted:i,children:a,timingFunction:o,onExit:s,onEntered:c,onEnter:l,onExited:u}){let{transitionDuration:d,transitionStatus:f,transitionTimingFunction:p}=d_({mounted:i,exitDuration:r,duration:n,timingFunction:o,onExit:s,onEntered:c,onEnter:l,onExited:u});return d===0?i?Z.createElement(Z.Fragment,null,a({})):e?a({display:`none`}):null:f===`exited`?e?a({display:`none`}):null:Z.createElement(Z.Fragment,null,a(u_({transition:t,duration:d,state:f,timingFunction:p})))}f_.displayName=`@mantine/core/Transition`;function p_({children:e,active:t=!0,refProp:n=`ref`}){let r=Dd(bd(t),e?.ref);return Bu(e)?(0,Z.cloneElement)(e,{[n]:r}):e}p_.displayName=`@mantine/core/FocusTrap`;var m_=Object.defineProperty,h_=Object.defineProperties,g_=Object.getOwnPropertyDescriptors,__=Object.getOwnPropertySymbols,v_=Object.prototype.hasOwnProperty,y_=Object.prototype.propertyIsEnumerable,b_=(e,t,n)=>t in e?m_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x_=(e,t)=>{for(var n in t||={})v_.call(t,n)&&b_(e,n,t[n]);if(__)for(var n of __(t))y_.call(t,n)&&b_(e,n,t[n]);return e},S_=(e,t)=>h_(e,g_(t));function C_(e,t,n,r){return e===`center`||r===`center`?{top:t}:e===`end`?{bottom:n}:e===`start`?{top:n}:{}}function w_(e,t,n,r,i){return e===`center`||r===`center`?{left:t}:e===`end`?{[i===`ltr`?`right`:`left`]:n}:e===`start`?{[i===`ltr`?`left`:`right`]:n}:{}}var T_={bottom:`borderTopLeftRadius`,left:`borderTopRightRadius`,right:`borderBottomLeftRadius`,top:`borderBottomRightRadius`};function E_({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:i,arrowX:a,arrowY:o,dir:s}){let[c,l=`center`]=e.split(`-`),u={width:Y(t),height:Y(t),transform:`rotate(45deg)`,position:`absolute`,[T_[c]]:Y(r)},d=Y(-t/2);return c===`left`?S_(x_(x_({},u),C_(l,o,n,i)),{right:d,borderLeftColor:`transparent`,borderBottomColor:`transparent`}):c===`right`?S_(x_(x_({},u),C_(l,o,n,i)),{left:d,borderRightColor:`transparent`,borderTopColor:`transparent`}):c===`top`?S_(x_(x_({},u),w_(l,a,n,i,s)),{bottom:d,borderTopColor:`transparent`,borderLeftColor:`transparent`}):c===`bottom`?S_(x_(x_({},u),w_(l,a,n,i,s)),{top:d,borderBottomColor:`transparent`,borderRightColor:`transparent`}):{}}var D_=Object.defineProperty,O_=Object.defineProperties,k_=Object.getOwnPropertyDescriptors,A_=Object.getOwnPropertySymbols,j_=Object.prototype.hasOwnProperty,M_=Object.prototype.propertyIsEnumerable,N_=(e,t,n)=>t in e?D_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P_=(e,t)=>{for(var n in t||={})j_.call(t,n)&&N_(e,n,t[n]);if(A_)for(var n of A_(t))M_.call(t,n)&&N_(e,n,t[n]);return e},F_=(e,t)=>O_(e,k_(t)),I_=(e,t)=>{var n={};for(var r in e)j_.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&A_)for(var r of A_(e))t.indexOf(r)<0&&M_.call(e,r)&&(n[r]=e[r]);return n},L_=(0,Z.forwardRef)((e,t)=>{var n=e,{position:r,arrowSize:i,arrowOffset:a,arrowRadius:o,arrowPosition:s,visible:c,arrowX:l,arrowY:u}=n,d=I_(n,[`position`,`arrowSize`,`arrowOffset`,`arrowRadius`,`arrowPosition`,`visible`,`arrowX`,`arrowY`]);let f=Kr();return c?Z.createElement(`div`,F_(P_({},d),{ref:t,style:E_({position:r,arrowSize:i,arrowOffset:a,arrowRadius:o,arrowPosition:s,dir:f.dir,arrowX:l,arrowY:u})})):null});L_.displayName=`@mantine/core/FloatingArrow`;var R_=Object.defineProperty,z_=Object.defineProperties,B_=Object.getOwnPropertyDescriptors,V_=Object.getOwnPropertySymbols,H_=Object.prototype.hasOwnProperty,U_=Object.prototype.propertyIsEnumerable,W_=(e,t,n)=>t in e?R_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,G_=(e,t)=>{for(var n in t||={})H_.call(t,n)&&W_(e,n,t[n]);if(V_)for(var n of V_(t))U_.call(t,n)&&W_(e,n,t[n]);return e},K_=(e,t)=>z_(e,B_(t)),q_=(e,t)=>{var n={};for(var r in e)H_.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&V_)for(var r of V_(e))t.indexOf(r)<0&&U_.call(e,r)&&(n[r]=e[r]);return n},J_={};function Y_(e){let t=X(`PopoverDropdown`,J_,e),{style:n,className:r,children:i,onKeyDownCapture:a}=t,o=q_(t,[`style`,`className`,`children`,`onKeyDownCapture`]),s=Ug(),{classes:c,cx:l}=n_({radius:s.radius,shadow:s.shadow},{name:s.__staticSelector,classNames:s.classNames,styles:s.styles,unstyled:s.unstyled,variant:s.variant}),u=cd({opened:s.opened,shouldReturnFocus:s.returnFocus}),d=s.withRoles?{"aria-labelledby":s.getTargetId(),id:s.getDropdownId(),role:`dialog`}:{};return s.disabled?null:Z.createElement(tp,K_(G_({},s.portalProps),{withinPortal:s.withinPortal}),Z.createElement(f_,K_(G_({mounted:s.opened},s.transitionProps),{transition:s.transitionProps.transition||`fade`,duration:s.transitionProps.duration??150,keepMounted:s.keepMounted,exitDuration:typeof s.transitionProps.exitDuration==`number`?s.transitionProps.exitDuration:s.transitionProps.duration}),e=>Z.createElement(p_,{active:s.trapFocus},Z.createElement(Br,G_(K_(G_({},d),{tabIndex:-1,ref:s.floating,style:K_(G_(G_({},n),e),{zIndex:s.zIndex,top:s.y??0,left:s.x??0,width:s.width===`target`?void 0:Y(s.width)}),className:l(c.dropdown,r),onKeyDownCapture:Ru(s.onClose,{active:s.closeOnEscape,onTrigger:u,onKeyDown:a}),"data-position":s.placement}),o),i,Z.createElement(L_,{ref:s.arrowRef,arrowX:s.arrowX,arrowY:s.arrowY,visible:s.withArrow,position:s.placement,arrowSize:s.arrowSize,arrowRadius:s.arrowRadius,arrowOffset:s.arrowOffset,arrowPosition:s.arrowPosition,className:c.arrow})))))}Y_.displayName=`@mantine/core/PopoverDropdown`;function X_(e,t){if(e===`rtl`&&(t.includes(`right`)||t.includes(`left`))){let[e,n]=t.split(`-`),r=e===`right`?`left`:`right`;return n===void 0?r:`${r}-${n}`}return t}var Z_=Object.getOwnPropertySymbols,Q_=Object.prototype.hasOwnProperty,$_=Object.prototype.propertyIsEnumerable,ev=(e,t)=>{var n={};for(var r in e)Q_.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Z_)for(var r of Z_(e))t.indexOf(r)<0&&$_.call(e,r)&&(n[r]=e[r]);return n},tv={position:`bottom`,offset:8,positionDependencies:[],transitionProps:{transition:`fade`,duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,closeOnClickOutside:!0,withinPortal:!1,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,clickOutsideEvents:[`mousedown`,`touchstart`],zIndex:Hu(`popover`),__staticSelector:`Popover`,width:`max-content`};function nv(e){let t=(0,Z.useRef)(null),n=X(`Popover`,tv,e),{children:r,position:i,offset:a,onPositionChange:o,positionDependencies:s,opened:c,transitionProps:l,width:u,middlewares:d,withArrow:f,arrowSize:p,arrowOffset:m,arrowRadius:h,arrowPosition:g,unstyled:_,classNames:v,styles:y,closeOnClickOutside:b,withinPortal:x,portalProps:S,closeOnEscape:C,clickOutsideEvents:w,trapFocus:T,onClose:E,onOpen:D,onChange:O,zIndex:k,radius:A,shadow:j,id:M,defaultOpened:N,__staticSelector:P,withRoles:F,disabled:I,returnFocus:L,variant:R,keepMounted:z}=n,B=ev(n,`children.position.offset.onPositionChange.positionDependencies.opened.transitionProps.width.middlewares.withArrow.arrowSize.arrowOffset.arrowRadius.arrowPosition.unstyled.classNames.styles.closeOnClickOutside.withinPortal.portalProps.closeOnEscape.clickOutsideEvents.trapFocus.onClose.onOpen.onChange.zIndex.radius.shadow.id.defaultOpened.__staticSelector.withRoles.disabled.returnFocus.variant.keepMounted`.split(`.`)),[V,ee]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(null),re=Cd(M),H=Bg({middlewares:d,width:u,position:X_(Kr().dir,i),offset:typeof a==`number`?a+(f?p/2:0):a,arrowRef:t,arrowOffset:m,onPositionChange:o,positionDependencies:s,opened:c,defaultOpened:N,onChange:O,onOpen:D,onClose:E});nd(()=>H.opened&&b&&H.onClose(),w,[V,te]);let ie=(0,Z.useCallback)(e=>{ee(e),H.floating.reference(e)},[H.floating.reference]),U=(0,Z.useCallback)(e=>{ne(e),H.floating.floating(e)},[H.floating.floating]);return Z.createElement(Hg,{value:{returnFocus:L,disabled:I,controlled:H.controlled,reference:ie,floating:U,x:H.floating.x,y:H.floating.y,arrowX:H.floating?.middlewareData?.arrow?.x,arrowY:H.floating?.middlewareData?.arrow?.y,opened:H.opened,arrowRef:t,transitionProps:l,width:u,withArrow:f,arrowSize:p,arrowOffset:m,arrowRadius:h,arrowPosition:g,placement:H.floating.placement,trapFocus:T,withinPortal:x,portalProps:S,zIndex:k,radius:A,shadow:j,closeOnEscape:C,onClose:H.onClose,onToggle:H.onToggle,getTargetId:()=>`${re}-target`,getDropdownId:()=>`${re}-dropdown`,withRoles:F,targetProps:B,__staticSelector:P,classNames:v,styles:y,unstyled:_,variant:R,keepMounted:z}},r)}nv.Target=t_,nv.Dropdown=Y_,nv.displayName=`@mantine/core/Popover`;var rv=Object.defineProperty,iv=Object.getOwnPropertySymbols,av=Object.prototype.hasOwnProperty,ov=Object.prototype.propertyIsEnumerable,sv=(e,t,n)=>t in e?rv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cv=(e,t)=>{for(var n in t||={})av.call(t,n)&&sv(e,n,t[n]);if(iv)for(var n of iv(t))ov.call(t,n)&&sv(e,n,t[n]);return e},lv=(e,t)=>{var n={};for(var r in e)av.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&iv)for(var r of iv(e))t.indexOf(r)<0&&ov.call(e,r)&&(n[r]=e[r]);return n};function uv(e){var t=e,{children:n,component:r=`div`,maxHeight:i=220,direction:a=`column`,id:o,innerRef:s,__staticSelector:c,styles:l,classNames:u,unstyled:d}=t,f=lv(t,[`children`,`component`,`maxHeight`,`direction`,`id`,`innerRef`,`__staticSelector`,`styles`,`classNames`,`unstyled`]);let{classes:p}=Vh(null,{name:c,styles:l,classNames:u,unstyled:d});return Z.createElement(nv.Dropdown,cv({p:0,onMouseDown:e=>e.preventDefault()},f),Z.createElement(`div`,{style:{maxHeight:Y(i),display:`flex`}},Z.createElement(Br,{component:r||`div`,id:`${o}-items`,"aria-labelledby":`${o}-label`,role:`listbox`,onMouseDown:e=>e.preventDefault(),style:{flex:1,overflowY:r===Bh?void 0:`auto`},"data-combobox-popover":!0,tabIndex:-1,ref:s},Z.createElement(`div`,{className:p.itemsWrapper,style:{flexDirection:a}},n))))}function dv({opened:e,transitionProps:t={transition:`fade`,duration:0},shadow:n,withinPortal:r,portalProps:i,children:a,__staticSelector:o,onDirectionChange:s,switchDirectionOnFlip:c,zIndex:l,dropdownPosition:u,positionDependencies:d=[],classNames:f,styles:p,unstyled:m,readOnly:h,variant:g}){return Z.createElement(nv,{unstyled:m,classNames:f,styles:p,width:`target`,withRoles:!1,opened:e,middlewares:{flip:u===`flip`,shift:!1},position:u===`flip`?`bottom`:u,positionDependencies:d,zIndex:l,__staticSelector:o,withinPortal:r,portalProps:i,transitionProps:t,shadow:n,disabled:h,onPositionChange:e=>c&&s?.(e===`top`?`column-reverse`:`column`),variant:g},a)}dv.Target=nv.Target,dv.Dropdown=uv;var fv=Object.defineProperty,pv=Object.defineProperties,mv=Object.getOwnPropertyDescriptors,hv=Object.getOwnPropertySymbols,gv=Object.prototype.hasOwnProperty,_v=Object.prototype.propertyIsEnumerable,vv=(e,t,n)=>t in e?fv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yv=(e,t)=>{for(var n in t||={})gv.call(t,n)&&vv(e,n,t[n]);if(hv)for(var n of hv(t))_v.call(t,n)&&vv(e,n,t[n]);return e},bv=(e,t)=>pv(e,mv(t)),xv=(e,t)=>{var n={};for(var r in e)gv.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hv)for(var r of hv(e))t.indexOf(r)<0&&_v.call(e,r)&&(n[r]=e[r]);return n};function Sv(e,t,n){let r=X(e,t,n),{label:i,description:a,error:o,required:s,classNames:c,styles:l,className:u,unstyled:d,__staticSelector:f,sx:p,errorProps:m,labelProps:h,descriptionProps:g,wrapperProps:_,id:v,size:y,style:b,inputContainer:x,inputWrapperOrder:S,withAsterisk:C,variant:w}=r,T=xv(r,[`label`,`description`,`error`,`required`,`classNames`,`styles`,`className`,`unstyled`,`__staticSelector`,`sx`,`errorProps`,`labelProps`,`descriptionProps`,`wrapperProps`,`id`,`size`,`style`,`inputContainer`,`inputWrapperOrder`,`withAsterisk`,`variant`]),E=Cd(v),{systemStyles:D,rest:O}=fi(T),k=yv({label:i,description:a,error:o,required:s,classNames:c,className:u,__staticSelector:f,sx:p,errorProps:m,labelProps:h,descriptionProps:g,unstyled:d,styles:l,id:E,size:y,style:b,inputContainer:x,inputWrapperOrder:S,withAsterisk:C,variant:w},_);return bv(yv({},O),{classNames:c,styles:l,unstyled:d,wrapperProps:yv(yv({},k),D),inputProps:{required:s,classNames:c,styles:l,unstyled:d,id:E,size:y,__staticSelector:f,error:o,variant:w}})}var Cv=Ur((e,t,{size:n})=>({label:{display:`inline-block`,fontSize:J({size:n,sizes:e.fontSizes}),fontWeight:500,color:e.colorScheme===`dark`?e.colors.dark[0]:e.colors.gray[9],wordBreak:`break-word`,cursor:`default`,WebkitTapHighlightColor:`transparent`},required:{color:e.fn.variant({variant:`filled`,color:`red`}).background}})),wv=Object.defineProperty,Tv=Object.getOwnPropertySymbols,Ev=Object.prototype.hasOwnProperty,Dv=Object.prototype.propertyIsEnumerable,Ov=(e,t,n)=>t in e?wv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kv=(e,t)=>{for(var n in t||={})Ev.call(t,n)&&Ov(e,n,t[n]);if(Tv)for(var n of Tv(t))Dv.call(t,n)&&Ov(e,n,t[n]);return e},Av=(e,t)=>{var n={};for(var r in e)Ev.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Tv)for(var r of Tv(e))t.indexOf(r)<0&&Dv.call(e,r)&&(n[r]=e[r]);return n},jv={labelElement:`label`,size:`sm`},Mv=(0,Z.forwardRef)((e,t)=>{let n=X(`InputLabel`,jv,e),{labelElement:r,children:i,required:a,size:o,classNames:s,styles:c,unstyled:l,className:u,htmlFor:d,__staticSelector:f,variant:p,onMouseDown:m}=n,h=Av(n,[`labelElement`,`children`,`required`,`size`,`classNames`,`styles`,`unstyled`,`className`,`htmlFor`,`__staticSelector`,`variant`,`onMouseDown`]),{classes:g,cx:_}=Cv(null,{name:[`InputWrapper`,f],classNames:s,styles:c,unstyled:l,variant:p,size:o});return Z.createElement(Br,kv({component:r,ref:t,className:_(g.label,u),htmlFor:r===`label`?d:void 0,onMouseDown:e=>{m?.(e),!e.defaultPrevented&&e.detail>1&&e.preventDefault()}},h),i,a&&Z.createElement(`span`,{className:g.required,"aria-hidden":!0},` *`))});Mv.displayName=`@mantine/core/InputLabel`;var Nv=Ur((e,t,{size:n})=>({error:{wordBreak:`break-word`,color:e.fn.variant({variant:`filled`,color:`red`}).background,fontSize:`calc(${J({size:n,sizes:e.fontSizes})} - ${Y(2)})`,lineHeight:1.2,display:`block`}})),Pv=Object.defineProperty,Fv=Object.getOwnPropertySymbols,Iv=Object.prototype.hasOwnProperty,Lv=Object.prototype.propertyIsEnumerable,Rv=(e,t,n)=>t in e?Pv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zv=(e,t)=>{for(var n in t||={})Iv.call(t,n)&&Rv(e,n,t[n]);if(Fv)for(var n of Fv(t))Lv.call(t,n)&&Rv(e,n,t[n]);return e},Bv=(e,t)=>{var n={};for(var r in e)Iv.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Fv)for(var r of Fv(e))t.indexOf(r)<0&&Lv.call(e,r)&&(n[r]=e[r]);return n},Vv={size:`sm`},Hv=(0,Z.forwardRef)((e,t)=>{let n=X(`InputError`,Vv,e),{children:r,className:i,classNames:a,styles:o,unstyled:s,size:c,__staticSelector:l,variant:u}=n,d=Bv(n,[`children`,`className`,`classNames`,`styles`,`unstyled`,`size`,`__staticSelector`,`variant`]),{classes:f,cx:p}=Nv(null,{name:[`InputWrapper`,l],classNames:a,styles:o,unstyled:s,variant:u,size:c});return Z.createElement(_i,zv({className:p(f.error,i),ref:t},d),r)});Hv.displayName=`@mantine/core/InputError`;var Uv=Ur((e,t,{size:n})=>({description:{wordBreak:`break-word`,color:e.colorScheme===`dark`?e.colors.dark[2]:e.colors.gray[6],fontSize:`calc(${J({size:n,sizes:e.fontSizes})} - ${Y(2)})`,lineHeight:1.2,display:`block`}})),Wv=Object.defineProperty,Gv=Object.getOwnPropertySymbols,Kv=Object.prototype.hasOwnProperty,qv=Object.prototype.propertyIsEnumerable,Jv=(e,t,n)=>t in e?Wv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yv=(e,t)=>{for(var n in t||={})Kv.call(t,n)&&Jv(e,n,t[n]);if(Gv)for(var n of Gv(t))qv.call(t,n)&&Jv(e,n,t[n]);return e},Xv=(e,t)=>{var n={};for(var r in e)Kv.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Gv)for(var r of Gv(e))t.indexOf(r)<0&&qv.call(e,r)&&(n[r]=e[r]);return n},Zv={size:`sm`},Qv=(0,Z.forwardRef)((e,t)=>{let n=X(`InputDescription`,Zv,e),{children:r,className:i,classNames:a,styles:o,unstyled:s,size:c,__staticSelector:l,variant:u}=n,d=Xv(n,[`children`,`className`,`classNames`,`styles`,`unstyled`,`size`,`__staticSelector`,`variant`]),{classes:f,cx:p}=Uv(null,{name:[`InputWrapper`,l],classNames:a,styles:o,unstyled:s,variant:u,size:c});return Z.createElement(_i,Yv({color:`dimmed`,className:p(f.description,i),ref:t,unstyled:s},d),r)});Qv.displayName=`@mantine/core/InputDescription`;var $v=(0,Z.createContext)({offsetBottom:!1,offsetTop:!1,describedBy:void 0}),ey=$v.Provider,ty=()=>(0,Z.useContext)($v);function ny(e,{hasDescription:t,hasError:n}){let r=e.findIndex(e=>e===`input`),i=e[r-1],a=e[r+1];return{offsetBottom:t&&a===`description`||n&&a===`error`,offsetTop:t&&i===`description`||n&&i===`error`}}var ry=Object.defineProperty,iy=Object.defineProperties,ay=Object.getOwnPropertyDescriptors,oy=Object.getOwnPropertySymbols,sy=Object.prototype.hasOwnProperty,cy=Object.prototype.propertyIsEnumerable,ly=(e,t,n)=>t in e?ry(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uy=(e,t)=>{for(var n in t||={})sy.call(t,n)&&ly(e,n,t[n]);if(oy)for(var n of oy(t))cy.call(t,n)&&ly(e,n,t[n]);return e},dy=(e,t)=>iy(e,ay(t)),fy=Ur(e=>({root:dy(uy({},e.fn.fontStyles()),{lineHeight:e.lineHeight})})),py=Object.defineProperty,my=Object.defineProperties,hy=Object.getOwnPropertyDescriptors,gy=Object.getOwnPropertySymbols,_y=Object.prototype.hasOwnProperty,vy=Object.prototype.propertyIsEnumerable,yy=(e,t,n)=>t in e?py(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,by=(e,t)=>{for(var n in t||={})_y.call(t,n)&&yy(e,n,t[n]);if(gy)for(var n of gy(t))vy.call(t,n)&&yy(e,n,t[n]);return e},xy=(e,t)=>my(e,hy(t)),Sy=(e,t)=>{var n={};for(var r in e)_y.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&gy)for(var r of gy(e))t.indexOf(r)<0&&vy.call(e,r)&&(n[r]=e[r]);return n},Cy={labelElement:`label`,size:`sm`,inputContainer:e=>e,inputWrapperOrder:[`label`,`description`,`input`,`error`]},wy=(0,Z.forwardRef)((e,t)=>{let n=X(`InputWrapper`,Cy,e),{className:r,label:i,children:a,required:o,id:s,error:c,description:l,labelElement:u,labelProps:d,descriptionProps:f,errorProps:p,classNames:m,styles:h,size:g,inputContainer:_,__staticSelector:v,unstyled:y,inputWrapperOrder:b,withAsterisk:x,variant:S}=n,C=Sy(n,[`className`,`label`,`children`,`required`,`id`,`error`,`description`,`labelElement`,`labelProps`,`descriptionProps`,`errorProps`,`classNames`,`styles`,`size`,`inputContainer`,`__staticSelector`,`unstyled`,`inputWrapperOrder`,`withAsterisk`,`variant`]),{classes:w,cx:T}=fy(null,{classNames:m,styles:h,name:[`InputWrapper`,v],unstyled:y,variant:S,size:g}),E={classNames:m,styles:h,unstyled:y,size:g,variant:S,__staticSelector:v},D=typeof x==`boolean`?x:o,O=s?`${s}-error`:p?.id,k=s?`${s}-description`:f?.id,A=`${c&&typeof c!=`boolean`?O:``} ${l?k:``}`,j=A.trim().length>0?A.trim():void 0,M=i&&Z.createElement(Mv,by(by({key:`label`,labelElement:u,id:s?`${s}-label`:void 0,htmlFor:s,required:D},E),d),i),N=l&&Z.createElement(Qv,xy(by(by({key:`description`},f),E),{size:f?.size||E.size,id:f?.id||k}),l),P=Z.createElement(Z.Fragment,{key:`input`},_(a)),F=typeof c!=`boolean`&&c&&Z.createElement(Hv,xy(by(by({},p),E),{size:p?.size||E.size,key:`error`,id:p?.id||O}),c),I=b.map(e=>{switch(e){case`label`:return M;case`input`:return P;case`description`:return N;case`error`:return F;default:return null}});return Z.createElement(ey,{value:by({describedBy:j},ny(b,{hasDescription:!!N,hasError:!!F}))},Z.createElement(Br,by({className:T(w.root,r),ref:t},C),I))});wy.displayName=`@mantine/core/InputWrapper`;var Ty=Object.defineProperty,Ey=Object.getOwnPropertySymbols,Dy=Object.prototype.hasOwnProperty,Oy=Object.prototype.propertyIsEnumerable,ky=(e,t,n)=>t in e?Ty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ay=(e,t)=>{for(var n in t||={})Dy.call(t,n)&&ky(e,n,t[n]);if(Ey)for(var n of Ey(t))Oy.call(t,n)&&ky(e,n,t[n]);return e},jy=(e,t)=>{var n={};for(var r in e)Dy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ey)for(var r of Ey(e))t.indexOf(r)<0&&Oy.call(e,r)&&(n[r]=e[r]);return n},My={},Ny=(0,Z.forwardRef)((e,t)=>{let n=X(`InputPlaceholder`,My,e),{sx:r}=n,i=jy(n,[`sx`]);return Z.createElement(Br,Ay({component:`span`,sx:[e=>e.fn.placeholderStyles(),...Iu(r)],ref:t},i))});Ny.displayName=`@mantine/core/InputPlaceholder`;var Py=Object.defineProperty,Fy=Object.defineProperties,Iy=Object.getOwnPropertyDescriptors,Ly=Object.getOwnPropertySymbols,Ry=Object.prototype.hasOwnProperty,zy=Object.prototype.propertyIsEnumerable,By=(e,t,n)=>t in e?Py(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vy=(e,t)=>{for(var n in t||={})Ry.call(t,n)&&By(e,n,t[n]);if(Ly)for(var n of Ly(t))zy.call(t,n)&&By(e,n,t[n]);return e},Hy=(e,t)=>Fy(e,Iy(t)),Uy={xs:Y(30),sm:Y(36),md:Y(42),lg:Y(50),xl:Y(60)},Wy=[`default`,`filled`,`unstyled`];function Gy({theme:e,variant:t}){return Wy.includes(t)?t==="default"?{border:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[4]}`,backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.white,transition:`border-color 100ms ease`,"&:focus, &:focus-within":e.focusRingStyles.inputStyles(e)}:t===`filled`?{border:`${Y(1)} solid transparent`,backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[1],"&:focus, &:focus-within":e.focusRingStyles.inputStyles(e)}:{borderWidth:0,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,backgroundColor:`transparent`,minHeight:Y(28),outline:0,"&:focus, &:focus-within":{outline:`none`,borderColor:`transparent`},"&:disabled":{backgroundColor:`transparent`,"&:focus, &:focus-within":{outline:`none`,borderColor:`transparent`}}}:null}var Ky=Ur((e,{multiline:t,radius:n,invalid:r,rightSectionWidth:i,withRightSection:a,iconWidth:o,offsetBottom:s,offsetTop:c,pointer:l},{variant:u,size:d})=>{let f=e.fn.variant({variant:`filled`,color:`red`}).background,p=u==="default"||u===`filled`?{minHeight:J({size:d,sizes:Uy}),paddingLeft:`calc(${J({size:d,sizes:Uy})} / 3)`,paddingRight:a?i||J({size:d,sizes:Uy}):`calc(${J({size:d,sizes:Uy})} / 3)`,borderRadius:e.fn.radius(n)}:u===`unstyled`&&a?{paddingRight:i||J({size:d,sizes:Uy})}:null;return{wrapper:{position:`relative`,marginTop:c?`calc(${e.spacing.xs} / 2)`:void 0,marginBottom:s?`calc(${e.spacing.xs} / 2)`:void 0,"&:has(input:disabled)":{"& .mantine-Input-rightSection":{display:`none`}}},input:Hy(Vy(Vy(Hy(Vy({},e.fn.fontStyles()),{height:t?u===`unstyled`?void 0:`auto`:J({size:d,sizes:Uy}),WebkitTapHighlightColor:`transparent`,lineHeight:t?e.lineHeight:`calc(${J({size:d,sizes:Uy})} - ${Y(2)})`,appearance:`none`,resize:`none`,boxSizing:`border-box`,fontSize:J({size:d,sizes:e.fontSizes}),width:`100%`,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,display:`block`,textAlign:`left`,cursor:l?`pointer`:void 0}),Gy({theme:e,variant:u})),p),{"&:disabled, &[data-disabled]":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.colors.gray[1],color:e.colors.dark[2],opacity:.6,cursor:`not-allowed`,pointerEvents:`none`,"&::placeholder":{color:e.colors.dark[2]}},"&[data-invalid]":{color:f,borderColor:f,"&::placeholder":{opacity:1,color:f}},"&[data-with-icon]":{paddingLeft:typeof o==`number`?Y(o):J({size:d,sizes:Uy})},"&::placeholder":Hy(Vy({},e.fn.placeholderStyles()),{opacity:1}),"&::-webkit-inner-spin-button, &::-webkit-outer-spin-button, &::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{appearance:`none`},"&[type=number]":{MozAppearance:`textfield`}}),icon:{pointerEvents:`none`,position:`absolute`,zIndex:1,left:0,top:0,bottom:0,display:`flex`,alignItems:`center`,justifyContent:`center`,width:o?Y(o):J({size:d,sizes:Uy}),color:r?e.colors.red[e.colorScheme===`dark`?6:7]:e.colorScheme===`dark`?e.colors.dark[2]:e.colors.gray[5]},rightSection:{position:`absolute`,top:0,bottom:0,right:0,display:`flex`,alignItems:`center`,justifyContent:`center`,width:i||J({size:d,sizes:Uy})}}}),qy=Object.defineProperty,Jy=Object.defineProperties,Yy=Object.getOwnPropertyDescriptors,Xy=Object.getOwnPropertySymbols,Zy=Object.prototype.hasOwnProperty,Qy=Object.prototype.propertyIsEnumerable,$y=(e,t,n)=>t in e?qy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eb=(e,t)=>{for(var n in t||={})Zy.call(t,n)&&$y(e,n,t[n]);if(Xy)for(var n of Xy(t))Qy.call(t,n)&&$y(e,n,t[n]);return e},tb=(e,t)=>Jy(e,Yy(t)),nb=(e,t)=>{var n={};for(var r in e)Zy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Xy)for(var r of Xy(e))t.indexOf(r)<0&&Qy.call(e,r)&&(n[r]=e[r]);return n},rb={size:`sm`,variant:`default`},ib=(0,Z.forwardRef)((e,t)=>{let n=X(`Input`,rb,e),{className:r,error:i,required:a,disabled:o,variant:s,icon:c,style:l,rightSectionWidth:u,iconWidth:d,rightSection:f,rightSectionProps:p,radius:m,size:h,wrapperProps:g,classNames:_,styles:v,__staticSelector:y,multiline:b,sx:x,unstyled:S,pointer:C}=n,w=nb(n,[`className`,`error`,`required`,`disabled`,`variant`,`icon`,`style`,`rightSectionWidth`,`iconWidth`,`rightSection`,`rightSectionProps`,`radius`,`size`,`wrapperProps`,`classNames`,`styles`,`__staticSelector`,`multiline`,`sx`,`unstyled`,`pointer`]),{offsetBottom:T,offsetTop:E,describedBy:D}=ty(),{classes:O,cx:k}=Ky({radius:m,multiline:b,invalid:!!i,rightSectionWidth:u?Y(u):void 0,iconWidth:d,withRightSection:!!f,offsetBottom:T,offsetTop:E,pointer:C},{classNames:_,styles:v,name:[`Input`,y],unstyled:S,variant:s,size:h}),{systemStyles:A,rest:j}=fi(w);return Z.createElement(Br,eb(eb({className:k(O.wrapper,r),sx:x,style:l},A),g),c&&Z.createElement(`div`,{className:O.icon},c),Z.createElement(Br,tb(eb({component:`input`},j),{ref:t,required:a,"aria-invalid":!!i,"aria-describedby":D,disabled:o,"data-disabled":o||void 0,"data-with-icon":!!c||void 0,"data-invalid":!!i||void 0,className:O.input})),f&&Z.createElement(`div`,tb(eb({},p),{className:O.rightSection}),f))});ib.displayName=`@mantine/core/Input`,ib.Wrapper=wy,ib.Label=Mv,ib.Description=Qv,ib.Error=Hv,ib.Placeholder=Ny;var ab=ir(ib),ob=Ur((e,{radius:t,shadow:n})=>({root:{outline:0,WebkitTapHighlightColor:`transparent`,display:`block`,textDecoration:`none`,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,backgroundColor:e.colorScheme===`dark`?e.colors.dark[7]:e.white,boxSizing:`border-box`,borderRadius:e.fn.radius(t),boxShadow:e.shadows[n]||n||`none`,"&[data-with-border]":{border:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[3]}`}}})),sb=Object.defineProperty,cb=Object.getOwnPropertySymbols,lb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,db=(e,t,n)=>t in e?sb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fb=(e,t)=>{for(var n in t||={})lb.call(t,n)&&db(e,n,t[n]);if(cb)for(var n of cb(t))ub.call(t,n)&&db(e,n,t[n]);return e},pb=(e,t)=>{var n={};for(var r in e)lb.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&cb)for(var r of cb(e))t.indexOf(r)<0&&ub.call(e,r)&&(n[r]=e[r]);return n},mb={},hb=(0,Z.forwardRef)((e,t)=>{let n=X(`Paper`,mb,e),{className:r,children:i,radius:a,withBorder:o,shadow:s,unstyled:c,variant:l}=n,u=pb(n,[`className`,`children`,`radius`,`withBorder`,`shadow`,`unstyled`,`variant`]),{classes:d,cx:f}=ob({radius:a,shadow:s},{name:`Paper`,unstyled:c,variant:l});return Z.createElement(Br,fb({className:f(d.root,r),"data-with-border":o||void 0,ref:t},u),i)});hb.displayName=`@mantine/core/Paper`;var gb=ir(hb),_b=(0,Z.createContext)(null),vb=_b.Provider,yb=()=>(0,Z.useContext)(_b),bb=Object.defineProperty,xb=Object.getOwnPropertySymbols,Sb=Object.prototype.hasOwnProperty,Cb=Object.prototype.propertyIsEnumerable,wb=(e,t,n)=>t in e?bb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tb=(e,t)=>{for(var n in t||={})Sb.call(t,n)&&wb(e,n,t[n]);if(xb)for(var n of xb(t))Cb.call(t,n)&&wb(e,n,t[n]);return e},Eb=(e,t)=>{var n={};for(var r in e)Sb.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&xb)for(var r of xb(e))t.indexOf(r)<0&&Cb.call(e,r)&&(n[r]=e[r]);return n},Db={size:`sm`},Ob=(0,Z.forwardRef)((e,t)=>{let n=X(`CheckboxGroup`,Db,e),{children:r,value:i,defaultValue:a,onChange:o,size:s,wrapperProps:c}=n,l=Eb(n,[`children`,`value`,`defaultValue`,`onChange`,`size`,`wrapperProps`]),[u,d]=Od({value:i,defaultValue:a,finalValue:[],onChange:o});return Z.createElement(vb,{value:{value:u,onChange:e=>{let t=e.currentTarget.value;d(u.includes(t)?u.filter(e=>e!==t):[...u,t])},size:s}},Z.createElement(ab.Wrapper,Tb(Tb({labelElement:`div`,size:s,__staticSelector:`CheckboxGroup`,ref:t},c),l),r))});Ob.displayName=`@mantine/core/CheckboxGroup`;var kb=Object.defineProperty,Ab=Object.getOwnPropertySymbols,jb=Object.prototype.hasOwnProperty,Mb=Object.prototype.propertyIsEnumerable,Nb=(e,t,n)=>t in e?kb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pb=(e,t)=>{for(var n in t||={})jb.call(t,n)&&Nb(e,n,t[n]);if(Ab)for(var n of Ab(t))Mb.call(t,n)&&Nb(e,n,t[n]);return e},Fb=(e,t)=>{var n={};for(var r in e)jb.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ab)for(var r of Ab(e))t.indexOf(r)<0&&Mb.call(e,r)&&(n[r]=e[r]);return n};function Ib(e){let t=e,{width:n,height:r,style:i}=t,a=Fb(t,[`width`,`height`,`style`]);return Z.createElement(`svg`,Pb({viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:Pb({width:n,height:r},i)},a),Z.createElement(`path`,{d:`M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`}))}function Lb(e){var t=e,{indeterminate:n}=t,r=Fb(t,[`indeterminate`]);return n?Z.createElement(`svg`,Pb({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 32 6`},r),Z.createElement(`rect`,{width:`32`,height:`6`,fill:`currentColor`,rx:`3`})):Z.createElement(Ib,Pb({},r))}var Rb=Object.defineProperty,zb=Object.defineProperties,Bb=Object.getOwnPropertyDescriptors,Vb=Object.getOwnPropertySymbols,Hb=Object.prototype.hasOwnProperty,Ub=Object.prototype.propertyIsEnumerable,Wb=(e,t,n)=>t in e?Rb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gb=(e,t)=>{for(var n in t||={})Hb.call(t,n)&&Wb(e,n,t[n]);if(Vb)for(var n of Vb(t))Ub.call(t,n)&&Wb(e,n,t[n]);return e},Kb=(e,t)=>zb(e,Bb(t)),qb={xs:Y(16),sm:Y(20),md:Y(24),lg:Y(30),xl:Y(36)},Jb=Ur((e,{radius:t,color:n,transitionDuration:r,labelPosition:i,error:a,indeterminate:o},{size:s})=>{let c=J({size:s,sizes:qb}),l=e.fn.variant({variant:`filled`,color:n});return{icon:Kb(Gb({},e.fn.cover()),{ref:Uu(`icon`),color:o?`inherit`:e.white,transform:o?`none`:`translateY(${Y(5)}) scale(0.5)`,opacity:+!!o,transitionProperty:`opacity, transform`,transitionTimingFunction:`ease`,transitionDuration:`${r}ms`,pointerEvents:`none`,width:`60%`,position:`absolute`,zIndex:1,margin:`auto`,"@media (prefers-reduced-motion)":{transitionDuration:e.respectReducedMotion?`0ms`:void 0}}),inner:{position:`relative`,width:c,height:c,order:i===`left`?2:1},input:Kb(Gb({},e.fn.focusStyles()),{appearance:`none`,backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.white,border:`${Y(1)} solid ${a?e.fn.variant({variant:`filled`,color:`red`}).background:e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[4]}`,width:c,height:c,borderRadius:e.fn.radius(t),padding:0,display:`block`,margin:0,transition:`border-color ${r}ms ease, background-color ${r}ms ease`,cursor:e.cursorType,"&:checked":{backgroundColor:l.background,borderColor:l.background,[`& + .${Uu(`icon`)}`]:{opacity:1,color:e.white,transform:`translateY(0) scale(1)`}},"&:disabled":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[2],borderColor:e.colorScheme===`dark`?e.colors.dark[6]:e.colors.gray[3],cursor:`not-allowed`,pointerEvents:`none`,[`& + .${Uu(`icon`)}`]:{color:e.colorScheme===`dark`?e.colors.dark[6]:e.colors.gray[5]}}})}}),Yb=Object.defineProperty,Xb=Object.defineProperties,Zb=Object.getOwnPropertyDescriptors,Qb=Object.getOwnPropertySymbols,$b=Object.prototype.hasOwnProperty,ex=Object.prototype.propertyIsEnumerable,tx=(e,t,n)=>t in e?Yb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nx=(e,t)=>{for(var n in t||={})$b.call(t,n)&&tx(e,n,t[n]);if(Qb)for(var n of Qb(t))ex.call(t,n)&&tx(e,n,t[n]);return e},rx=(e,t)=>Xb(e,Zb(t)),ix={xs:Y(16),sm:Y(20),md:Y(24),lg:Y(30),xl:Y(36)},ax=Ur((e,{labelPosition:t},{size:n})=>({root:{},body:{display:`flex`,"&:has(input:disabled) label":{color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[5]}},labelWrapper:rx(nx({},e.fn.fontStyles()),{display:`inline-flex`,flexDirection:`column`,WebkitTapHighlightColor:`transparent`,fontSize:n in ix?J({size:n,sizes:e.fontSizes}):void 0,lineHeight:n in ix?J({size:n,sizes:ix}):void 0,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,cursor:e.cursorType,order:t===`left`?1:2}),description:{marginTop:`calc(${e.spacing.xs} / 2)`,[t===`left`?`paddingRight`:`paddingLeft`]:e.spacing.sm},error:{marginTop:`calc(${e.spacing.xs} / 2)`,[t===`left`?`paddingRight`:`paddingLeft`]:e.spacing.sm},label:{cursor:e.cursorType,[t===`left`?`paddingRight`:`paddingLeft`]:e.spacing.sm,"&:disabled, &[data-disabled]":{color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[5]}}})),ox=Object.defineProperty,sx=Object.getOwnPropertySymbols,cx=Object.prototype.hasOwnProperty,lx=Object.prototype.propertyIsEnumerable,ux=(e,t,n)=>t in e?ox(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dx=(e,t)=>{for(var n in t||={})cx.call(t,n)&&ux(e,n,t[n]);if(sx)for(var n of sx(t))lx.call(t,n)&&ux(e,n,t[n]);return e},fx=(e,t)=>{var n={};for(var r in e)cx.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&sx)for(var r of sx(e))t.indexOf(r)<0&&lx.call(e,r)&&(n[r]=e[r]);return n},px=(0,Z.forwardRef)((e,t)=>{var n=e,{__staticSelector:r,className:i,classNames:a,styles:o,unstyled:s,children:c,label:l,description:u,id:d,disabled:f,error:p,size:m,labelPosition:h,bodyElement:g=`div`,labelElement:_=`label`,variant:v}=n,y=fx(n,[`__staticSelector`,`className`,`classNames`,`styles`,`unstyled`,`children`,`label`,`description`,`id`,`disabled`,`error`,`size`,`labelPosition`,`bodyElement`,`labelElement`,`variant`]);let{classes:b,cx:x}=ax({labelPosition:h},{name:r,styles:o,classNames:a,unstyled:s,variant:v,size:m});return Z.createElement(Br,dx({className:x(b.root,i),ref:t},y),Z.createElement(Br,{component:g,htmlFor:g===`label`?d:void 0,className:x(b.body)},c,Z.createElement(`div`,{className:b.labelWrapper},l!=null&&Z.createElement(Br,{component:_,htmlFor:_===`label`?d:void 0,className:b.label,"data-disabled":f||void 0},l),u&&Z.createElement(ab.Description,{className:b.description},u),p&&p!==`boolean`&&Z.createElement(ab.Error,{className:b.error},p))))});px.displayName=`@mantine/core/InlineInput`;var mx=Object.defineProperty,hx=Object.getOwnPropertySymbols,gx=Object.prototype.hasOwnProperty,_x=Object.prototype.propertyIsEnumerable,vx=(e,t,n)=>t in e?mx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yx=(e,t)=>{for(var n in t||={})gx.call(t,n)&&vx(e,n,t[n]);if(hx)for(var n of hx(t))_x.call(t,n)&&vx(e,n,t[n]);return e},bx=(e,t)=>{var n={};for(var r in e)gx.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hx)for(var r of hx(e))t.indexOf(r)<0&&_x.call(e,r)&&(n[r]=e[r]);return n},xx={size:`sm`,transitionDuration:100,icon:Lb,labelPosition:`right`},Sx=(0,Z.forwardRef)((e,t)=>{let n=X(`Checkbox`,xx,e),{className:r,style:i,sx:a,checked:o,disabled:s,color:c,label:l,indeterminate:u,id:d,size:f,radius:p,wrapperProps:m,children:h,classNames:g,styles:_,transitionDuration:v,icon:y,unstyled:b,labelPosition:x,description:S,error:C,variant:w}=n,T=bx(n,[`className`,`style`,`sx`,`checked`,`disabled`,`color`,`label`,`indeterminate`,`id`,`size`,`radius`,`wrapperProps`,`children`,`classNames`,`styles`,`transitionDuration`,`icon`,`unstyled`,`labelPosition`,`description`,`error`,`variant`]),E=yb(),D=Cd(d),{systemStyles:O,rest:k}=fi(T),{classes:A}=Jb({radius:p,color:c,transitionDuration:v,labelPosition:x,error:!!C,indeterminate:u},{name:`Checkbox`,classNames:g,styles:_,unstyled:b,variant:w,size:E?.size||f}),j=E?{checked:E.value.includes(k.value),onChange:E.onChange}:{};return Z.createElement(px,yx(yx({className:r,sx:a,style:i,id:D,size:E?.size||f,labelPosition:x,label:l,description:S,error:C,disabled:s,__staticSelector:`Checkbox`,classNames:g,styles:_,unstyled:b,"data-checked":j.checked||void 0,variant:w},O),m),Z.createElement(`div`,{className:A.inner},Z.createElement(`input`,yx(yx({id:D,ref:t,type:`checkbox`,className:A.input,checked:o,disabled:s},k),j)),Z.createElement(y,{indeterminate:u,className:A.icon})))});Sx.displayName=`@mantine/core/Checkbox`,Sx.Group=Ob;var[Cx,wx]=Fu(`Drawer component was not found in tree`),Tx={xs:Y(320),sm:Y(380),md:Y(440),lg:Y(620),xl:Y(780)},Ex=Ur((e,{position:t},{size:n})=>({header:{zIndex:1e3},content:{flex:t===`right`||t===`left`?`0 0 ${J({size:n,sizes:Tx})}`:`0 0 100%`,maxWidth:`100%`,maxHeight:`100%`,height:t===`right`||t===`left`?`100%`:J({size:n,sizes:Tx}),borderRadius:0,overflowY:`auto`},inner:{display:`flex`,justifyContent:t===`right`?`flex-end`:`flex-start`,alignItems:t===`bottom`?`flex-end`:`flex-start`}})),[Dx,Ox]=Fu(`ModalBase component was not found in tree`),kx=Ur(()=>({close:{marginLeft:`auto`,marginRight:0}})),Ax=Object.defineProperty,jx=Object.getOwnPropertySymbols,Mx=Object.prototype.hasOwnProperty,Nx=Object.prototype.propertyIsEnumerable,Px=(e,t,n)=>t in e?Ax(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fx=(e,t)=>{for(var n in t||={})Mx.call(t,n)&&Px(e,n,t[n]);if(jx)for(var n of jx(t))Nx.call(t,n)&&Px(e,n,t[n]);return e},Ix=(e,t)=>{var n={};for(var r in e)Mx.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&jx)for(var r of jx(e))t.indexOf(r)<0&&Nx.call(e,r)&&(n[r]=e[r]);return n},Lx={size:`sm`},Rx=(0,Z.forwardRef)((e,t)=>{let n=Ox(),r=X(`${n.__staticSelector}CloseButton`,Lx,e),{className:i}=r,a=Ix(r,[`className`]),{classes:o,cx:s}=kx(null,n.stylesApi);return Z.createElement(bp,Fx({className:s(o.close,i),ref:t,onClick:n.onClose},a))}),zx=Ur(()=>({overlay:{}})),Bx=Object.defineProperty,Vx=Object.defineProperties,Hx=Object.getOwnPropertyDescriptors,Ux=Object.getOwnPropertySymbols,Wx=Object.prototype.hasOwnProperty,Gx=Object.prototype.propertyIsEnumerable,Kx=(e,t,n)=>t in e?Bx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qx=(e,t)=>{for(var n in t||={})Wx.call(t,n)&&Kx(e,n,t[n]);if(Ux)for(var n of Ux(t))Gx.call(t,n)&&Kx(e,n,t[n]);return e},Jx=(e,t)=>Vx(e,Hx(t)),Yx=Ur((e,{color:t,opacity:n,blur:r,radius:i,gradient:a,fixed:o,zIndex:s})=>({root:Jx(qx({},e.fn.cover(0)),{position:o?`fixed`:`absolute`,backgroundColor:a?void 0:e.fn.rgba(t,n),backgroundImage:a,backdropFilter:r?`blur(${Y(r)})`:void 0,borderRadius:e.fn.radius(i),zIndex:s,"&[data-center]":{display:`flex`,alignItems:`center`,justifyContent:`center`}})})),Xx=Object.defineProperty,Zx=Object.getOwnPropertySymbols,Qx=Object.prototype.hasOwnProperty,$x=Object.prototype.propertyIsEnumerable,eS=(e,t,n)=>t in e?Xx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,tS=(e,t)=>{for(var n in t||={})Qx.call(t,n)&&eS(e,n,t[n]);if(Zx)for(var n of Zx(t))$x.call(t,n)&&eS(e,n,t[n]);return e},nS=(e,t)=>{var n={};for(var r in e)Qx.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Zx)for(var r of Zx(e))t.indexOf(r)<0&&$x.call(e,r)&&(n[r]=e[r]);return n},rS={opacity:.6,color:`#000`,zIndex:Hu(`modal`),radius:0},iS=(0,Z.forwardRef)((e,t)=>{let n=X(`Overlay`,rS,e),{variant:r,opacity:i,color:a,blur:o,gradient:s,zIndex:c,radius:l,children:u,className:d,classNames:f,styles:p,unstyled:m,center:h,fixed:g}=n,_=nS(n,[`variant`,`opacity`,`color`,`blur`,`gradient`,`zIndex`,`radius`,`children`,`className`,`classNames`,`styles`,`unstyled`,`center`,`fixed`]),{classes:v,cx:y}=Yx({color:a,opacity:i,blur:o,radius:l,gradient:s,fixed:g,zIndex:c},{name:`Overlay`,classNames:f,styles:p,unstyled:m,variant:r});return Z.createElement(Br,tS({ref:t,className:y(v.root,d),"data-center":h||void 0},_),u)});iS.displayName=`@mantine/core/Overlay`;var aS=ir(iS),oS=Object.defineProperty,sS=Object.defineProperties,cS=Object.getOwnPropertyDescriptors,lS=Object.getOwnPropertySymbols,uS=Object.prototype.hasOwnProperty,dS=Object.prototype.propertyIsEnumerable,fS=(e,t,n)=>t in e?oS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pS=(e,t)=>{for(var n in t||={})uS.call(t,n)&&fS(e,n,t[n]);if(lS)for(var n of lS(t))dS.call(t,n)&&fS(e,n,t[n]);return e},mS=(e,t)=>sS(e,cS(t)),hS=(e,t)=>{var n={};for(var r in e)uS.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&lS)for(var r of lS(e))t.indexOf(r)<0&&dS.call(e,r)&&(n[r]=e[r]);return n},gS={},_S=(0,Z.forwardRef)((e,t)=>{let n=Ox(),r=X(`${n.__staticSelector}Overlay`,gS,e),{onClick:i,transitionProps:a,style:o,className:s}=r,c=hS(r,[`onClick`,`transitionProps`,`style`,`className`]),{classes:l,cx:u}=zx(null,n.stylesApi),d=e=>{i?.(e),n.closeOnClickOutside&&n.onClose()};return Z.createElement(f_,mS(pS(pS({mounted:n.opened},n.transitionProps),a),{transition:`fade`}),e=>Z.createElement(aS,pS({ref:t,onClick:d,fixed:!0,style:pS(pS({},o),e),className:u(l.overlay,s),zIndex:n.zIndex},c)))}),vS=Ur((e,{zIndex:t})=>({inner:{position:`fixed`,width:`100%`,top:0,bottom:0,maxHeight:`100%`,zIndex:t,pointerEvents:`none`},content:{pointerEvents:`all`}})),yS=Object.defineProperty,bS=Object.getOwnPropertySymbols,xS=Object.prototype.hasOwnProperty,SS=Object.prototype.propertyIsEnumerable,CS=(e,t,n)=>t in e?yS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wS=(e,t)=>{for(var n in t||={})xS.call(t,n)&&CS(e,n,t[n]);if(bS)for(var n of bS(t))SS.call(t,n)&&CS(e,n,t[n]);return e},TS=(e,t)=>{var n={};for(var r in e)xS.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bS)for(var r of bS(e))t.indexOf(r)<0&&SS.call(e,r)&&(n[r]=e[r]);return n},ES={},DS=(0,Z.forwardRef)((e,t)=>{let n=Ox(),r=X(`${n.__staticSelector}Content`,ES,e),{className:i,transitionProps:a,style:o,onKeyDown:s}=r,c=TS(r,[`className`,`transitionProps`,`style`,`onKeyDown`]),{classes:l,cx:u}=vS({zIndex:n.zIndex},n.stylesApi),d=e=>{e.target?.getAttribute(`data-mantine-stop-propagation`)!==`true`&&e.key===`Escape`&&n.closeOnEscape&&n.onClose(),s?.(e)};return Z.createElement(f_,wS(wS({mounted:n.opened,transition:`pop`},n.transitionProps),a),e=>Z.createElement(`div`,{className:u(l.inner)},Z.createElement(p_,{active:n.opened&&n.trapFocus},Z.createElement(gb,wS({component:`section`,role:`dialog`,tabIndex:-1,"aria-modal":!0,"aria-describedby":n.bodyMounted?n.getBodyId():void 0,"aria-labelledby":n.titleMounted?n.getTitleId():void 0,onKeyDown:d,ref:t,className:u(l.content,i),style:wS(wS({},o),e),shadow:n.shadow},c),c.children))))}),OS=Ur((e,{padding:t})=>{let n=J({size:t,sizes:e.spacing});return{header:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:n,paddingRight:`calc(${n} - ${Y(5)})`,position:`sticky`,top:0,backgroundColor:e.colorScheme===`dark`?e.colors.dark[7]:e.white,zIndex:1e3}}}),kS=Object.defineProperty,AS=Object.getOwnPropertySymbols,jS=Object.prototype.hasOwnProperty,MS=Object.prototype.propertyIsEnumerable,NS=(e,t,n)=>t in e?kS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,PS=(e,t)=>{for(var n in t||={})jS.call(t,n)&&NS(e,n,t[n]);if(AS)for(var n of AS(t))MS.call(t,n)&&NS(e,n,t[n]);return e},FS=(e,t)=>{var n={};for(var r in e)jS.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&AS)for(var r of AS(e))t.indexOf(r)<0&&MS.call(e,r)&&(n[r]=e[r]);return n},IS={},LS=(0,Z.forwardRef)((e,t)=>{let n=Ox(),r=X(`${n.__staticSelector}Header`,IS,e),{className:i}=r,a=FS(r,[`className`]),{classes:o,cx:s}=OS({padding:n.padding},n.stylesApi);return Z.createElement(Br,PS({ref:t,className:s(o.header,i)},a))}),RS=Ur(e=>({title:{lineHeight:1,padding:0,margin:0,fontWeight:400,fontSize:e.fontSizes.md}})),zS=Object.defineProperty,BS=Object.getOwnPropertySymbols,VS=Object.prototype.hasOwnProperty,HS=Object.prototype.propertyIsEnumerable,US=(e,t,n)=>t in e?zS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,WS=(e,t)=>{for(var n in t||={})VS.call(t,n)&&US(e,n,t[n]);if(BS)for(var n of BS(t))HS.call(t,n)&&US(e,n,t[n]);return e},GS=(e,t)=>{var n={};for(var r in e)VS.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&BS)for(var r of BS(e))t.indexOf(r)<0&&HS.call(e,r)&&(n[r]=e[r]);return n},KS={},qS=(0,Z.forwardRef)((e,t)=>{let n=Ox(),r=X(`${n.__staticSelector}Title`,KS,e),{className:i}=r,a=GS(r,[`className`]),{classes:o,cx:s}=RS(null,n.stylesApi);return(0,Z.useEffect)(()=>(n.setTitleMounted(!0),()=>n.setTitleMounted(!1)),[]),Z.createElement(Br,WS({component:`h2`,id:n.getTitleId(),className:s(o.title,i),ref:t},a))}),JS=Ur((e,{padding:t})=>({body:{padding:J({size:t,sizes:e.spacing}),"&:not(:only-child)":{paddingTop:0}}})),YS=Object.defineProperty,XS=Object.getOwnPropertySymbols,ZS=Object.prototype.hasOwnProperty,QS=Object.prototype.propertyIsEnumerable,$S=(e,t,n)=>t in e?YS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eC=(e,t)=>{for(var n in t||={})ZS.call(t,n)&&$S(e,n,t[n]);if(XS)for(var n of XS(t))QS.call(t,n)&&$S(e,n,t[n]);return e},tC=(e,t)=>{var n={};for(var r in e)ZS.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&XS)for(var r of XS(e))t.indexOf(r)<0&&QS.call(e,r)&&(n[r]=e[r]);return n},nC={},rC=(0,Z.forwardRef)((e,t)=>{let n=Ox(),r=X(`${n.__staticSelector}Body`,nC,e),{className:i}=r,a=tC(r,[`className`]),{classes:o,cx:s}=JS({padding:n.padding},n.stylesApi);return(0,Z.useEffect)(()=>(n.setBodyMounted(!0),()=>n.setBodyMounted(!1)),[]),Z.createElement(Br,eC({id:n.getBodyId(),className:s(o.body,i),ref:t},a))});function iC({children:e}){return Z.createElement(Z.Fragment,null,e)}function aC({opened:e,transitionDuration:t}){let[n,r]=(0,Z.useState)(e),i=(0,Z.useRef)(),a=kd()?0:t;return(0,Z.useEffect)(()=>(e?(r(!0),window.clearTimeout(i.current)):a===0?r(!1):i.current=window.setTimeout(()=>r(!1),a),()=>window.clearTimeout(i.current)),[e,a]),n}var oC=Ur(()=>({root:{}})),sC=Object.defineProperty,cC=Object.defineProperties,lC=Object.getOwnPropertyDescriptors,uC=Object.getOwnPropertySymbols,dC=Object.prototype.hasOwnProperty,fC=Object.prototype.propertyIsEnumerable,pC=(e,t,n)=>t in e?sC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mC=(e,t)=>{for(var n in t||={})dC.call(t,n)&&pC(e,n,t[n]);if(uC)for(var n of uC(t))fC.call(t,n)&&pC(e,n,t[n]);return e},hC=(e,t)=>cC(e,lC(t)),gC=(e,t)=>{var n={};for(var r in e)dC.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&uC)for(var r of uC(e))t.indexOf(r)<0&&fC.call(e,r)&&(n[r]=e[r]);return n},_C={closeOnClickOutside:!0,withinPortal:!0,lockScroll:!0,trapFocus:!0,returnFocus:!0,closeOnEscape:!0,keepMounted:!1,zIndex:Hu(`modal`),padding:`md`,size:`md`,shadow:`xl`};function vC(e){let t=X(`ModalBase`,_C,e),{opened:n,onClose:r,children:i,closeOnClickOutside:a,__staticSelector:o,transitionProps:s,withinPortal:c,portalProps:l,keepMounted:u,target:d,zIndex:f,lockScroll:p,trapFocus:m,closeOnEscape:h,returnFocus:g,padding:_,shadow:v,id:y,size:b,variant:x,classNames:S,unstyled:C,styles:w,className:T}=t,E=gC(t,[`opened`,`onClose`,`children`,`closeOnClickOutside`,`__staticSelector`,`transitionProps`,`withinPortal`,`portalProps`,`keepMounted`,`target`,`zIndex`,`lockScroll`,`trapFocus`,`closeOnEscape`,`returnFocus`,`padding`,`shadow`,`id`,`size`,`variant`,`classNames`,`unstyled`,`styles`,`className`]),{classes:D,cx:O}=oC(null,{name:o,classNames:S,styles:w,unstyled:C,variant:x,size:b}),k=Cd(y),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=typeof s?.duration==`number`?s?.duration:200,F=aC({opened:n,transitionDuration:P});return wd(`keydown`,e=>{!m&&e.key===`Escape`&&h&&r()}),cd({opened:n,shouldReturnFocus:m&&g}),Z.createElement(tp,hC(mC({},l),{withinPortal:c,target:d}),Z.createElement(Dx,{value:{__staticSelector:o,opened:n,onClose:r,closeOnClickOutside:a,transitionProps:hC(mC({},s),{duration:P,keepMounted:u}),zIndex:f,padding:_,id:k,getTitleId:()=>`${k}-title`,getBodyId:()=>`${k}-body`,titleMounted:A,bodyMounted:M,setTitleMounted:j,setBodyMounted:N,trapFocus:m,closeOnEscape:h,shadow:v,stylesApi:{name:o,size:b,variant:x,classNames:S,styles:w,unstyled:C}}},Z.createElement(Ot,{enabled:F&&p},Z.createElement(Br,mC({className:O(D.root,T)},E),i))))}vC.CloseButton=Rx,vC.Overlay=_S,vC.Content=DS,vC.Header=LS,vC.Title=qS,vC.Body=rC,vC.NativeScrollArea=iC;var yC=Object.defineProperty,bC=Object.defineProperties,xC=Object.getOwnPropertyDescriptors,SC=Object.getOwnPropertySymbols,CC=Object.prototype.hasOwnProperty,wC=Object.prototype.propertyIsEnumerable,TC=(e,t,n)=>t in e?yC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,EC=(e,t)=>{for(var n in t||={})CC.call(t,n)&&TC(e,n,t[n]);if(SC)for(var n of SC(t))wC.call(t,n)&&TC(e,n,t[n]);return e},DC=(e,t)=>bC(e,xC(t)),OC=(e,t)=>{var n={};for(var r in e)CC.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&SC)for(var r of SC(e))t.indexOf(r)<0&&wC.call(e,r)&&(n[r]=e[r]);return n},kC={top:`slide-down`,bottom:`slide-up`,left:`slide-right`,right:`slide-left`},AC={top:`slide-down`,bottom:`slide-up`,right:`slide-right`,left:`slide-left`},jC=DC(EC({},_C),{position:`left`});function MC(e){let t=X(`DrawerRoot`,jC,e),{classNames:n,variant:r,size:i,scrollAreaComponent:a,position:o,transitionProps:s}=t,c=OC(t,[`classNames`,`variant`,`size`,`scrollAreaComponent`,`position`,`transitionProps`]),{classes:l,cx:u,theme:d}=Ex({position:o},{name:`Drawer`,variant:r,size:i}),f=(d.dir===`rtl`?AC:kC)[o];return Z.createElement(Cx,{value:{scrollAreaComponent:a}},Z.createElement(vC,EC({__staticSelector:`Drawer`,size:i,variant:r,transitionProps:EC({transition:f,duration:200},s),classNames:DC(EC({},n),{content:u(l.content,n?.content),inner:u(l.inner,n?.inner)})},c)))}var NC=Object.defineProperty,PC=Object.getOwnPropertySymbols,FC=Object.prototype.hasOwnProperty,IC=Object.prototype.propertyIsEnumerable,LC=(e,t,n)=>t in e?NC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,RC=(e,t)=>{for(var n in t||={})FC.call(t,n)&&LC(e,n,t[n]);if(PC)for(var n of PC(t))IC.call(t,n)&&LC(e,n,t[n]);return e},zC=(e,t)=>{var n={};for(var r in e)FC.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&PC)for(var r of PC(e))t.indexOf(r)<0&&IC.call(e,r)&&(n[r]=e[r]);return n},BC={shadow:`xl`},VC=(0,Z.forwardRef)((e,t)=>{let n=X(`ModalContent`,BC,e),{children:r,scrollAreaComponent:i}=n,a=zC(n,[`children`,`scrollAreaComponent`]),o=wx(),s=i||o.scrollAreaComponent||vC.NativeScrollArea;return Z.createElement(vC.Content,RC({ref:t,radius:0},a),Z.createElement(s,{style:{height:`100vh`}},r))}),HC=Object.defineProperty,UC=Object.defineProperties,WC=Object.getOwnPropertyDescriptors,GC=Object.getOwnPropertySymbols,KC=Object.prototype.hasOwnProperty,qC=Object.prototype.propertyIsEnumerable,JC=(e,t,n)=>t in e?HC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,YC=(e,t)=>{for(var n in t||={})KC.call(t,n)&&JC(e,n,t[n]);if(GC)for(var n of GC(t))qC.call(t,n)&&JC(e,n,t[n]);return e},XC=(e,t)=>UC(e,WC(t)),ZC=(e,t)=>{var n={};for(var r in e)KC.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&GC)for(var r of GC(e))t.indexOf(r)<0&&qC.call(e,r)&&(n[r]=e[r]);return n},QC=XC(YC({},_C),{withOverlay:!0,withCloseButton:!0});function $C(e){let t=X(`Drawer`,QC,e),{title:n,withOverlay:r,overlayProps:i,withCloseButton:a,closeButtonProps:o,children:s}=t,c=ZC(t,[`title`,`withOverlay`,`overlayProps`,`withCloseButton`,`closeButtonProps`,`children`]),l=!!n||a;return Z.createElement(MC,YC({},c),r&&Z.createElement(vC.Overlay,YC({},i)),Z.createElement(VC,null,l&&Z.createElement(vC.Header,null,n&&Z.createElement(vC.Title,null,n),a&&Z.createElement(vC.CloseButton,YC({},o))),Z.createElement(vC.Body,null,s)))}$C.Root=MC,$C.CloseButton=vC.CloseButton,$C.Overlay=vC.Overlay,$C.Content=VC,$C.Header=vC.Header,$C.Title=vC.Title,$C.Body=vC.Body,$C.NativeScrollArea=vC.NativeScrollArea;var ew=Object.defineProperty,tw=Object.getOwnPropertySymbols,nw=Object.prototype.hasOwnProperty,rw=Object.prototype.propertyIsEnumerable,iw=(e,t,n)=>t in e?ew(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,aw=(e,t)=>{for(var n in t||={})nw.call(t,n)&&iw(e,n,t[n]);if(tw)for(var n of tw(t))rw.call(t,n)&&iw(e,n,t[n]);return e},ow=(e,t)=>{var n={};for(var r in e)nw.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&tw)for(var r of tw(e))t.indexOf(r)<0&&rw.call(e,r)&&(n[r]=e[r]);return n},sw={multiple:!1},cw=(0,Z.forwardRef)((e,t)=>{let n=X(`FileButton`,sw,e),{onChange:r,children:i,multiple:a,accept:o,name:s,form:c,resetRef:l,disabled:u,capture:d,inputProps:f}=n,p=ow(n,[`onChange`,`children`,`multiple`,`accept`,`name`,`form`,`resetRef`,`disabled`,`capture`,`inputProps`]),m=(0,Z.useRef)();return Td(l,()=>{m.current.value=``}),Z.createElement(Z.Fragment,null,i(aw({onClick:()=>{!u&&m.current.click()}},p)),Z.createElement(`input`,aw({style:{display:`none`},type:`file`,accept:o,multiple:a,onChange:e=>{r(a?Array.from(e.currentTarget.files):e.currentTarget.files[0]||null)},ref:Dd(t,m),name:s,form:c,capture:d},f)))});cw.displayName=`@mantine/core/FileButton`;var lw=Ur(()=>({placeholder:{},input:{cursor:`pointer`}})),uw=Object.defineProperty,dw=Object.defineProperties,fw=Object.getOwnPropertyDescriptors,pw=Object.getOwnPropertySymbols,mw=Object.prototype.hasOwnProperty,hw=Object.prototype.propertyIsEnumerable,gw=(e,t,n)=>t in e?uw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_w=(e,t)=>{for(var n in t||={})mw.call(t,n)&&gw(e,n,t[n]);if(pw)for(var n of pw(t))hw.call(t,n)&&gw(e,n,t[n]);return e},vw=(e,t)=>dw(e,fw(t)),yw=(e,t)=>{var n={};for(var r in e)mw.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&pw)for(var r of pw(e))t.indexOf(r)<0&&hw.call(e,r)&&(n[r]=e[r]);return n},bw={size:`sm`,valueComponent:({value:e})=>Z.createElement(_i,{sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},Array.isArray(e)?e.map(e=>e.name).join(`, `):e?.name)},xw=(0,Z.forwardRef)((e,t)=>{let n=Sv(`FileInput`,bw,e),{inputProps:r,wrapperProps:i,placeholder:a,value:o,defaultValue:s,onChange:c,multiple:l,accept:u,name:d,form:f,classNames:p,styles:m,unstyled:h,valueComponent:g,rightSection:_,clearable:v,clearButtonProps:y,readOnly:b,capture:x,fileInputProps:S}=n,C=yw(n,[`inputProps`,`wrapperProps`,`placeholder`,`value`,`defaultValue`,`onChange`,`multiple`,`accept`,`name`,`form`,`classNames`,`styles`,`unstyled`,`valueComponent`,`rightSection`,`clearable`,`clearButtonProps`,`readOnly`,`capture`,`fileInputProps`]),w=(0,Z.useRef)(),{classes:T,cx:E}=lw(null,{name:`FileInput`,classNames:p,styles:m,unstyled:h}),[D,O]=Od({value:o,defaultValue:s,onChange:c,finalValue:l?[]:null}),k=Array.isArray(D)?D.length!==0:D!==null,A=_||(v&&k&&!b?Z.createElement(bp,vw(_w({},y),{variant:`transparent`,onClick:()=>O(l?[]:null),size:r.size,unstyled:h})):null);return(0,Z.useEffect)(()=>{(Array.isArray(D)&&D.length===0||D===null)&&w.current()},[D]),Z.createElement(ab.Wrapper,vw(_w({},i),{__staticSelector:`FileInput`}),Z.createElement(cw,{onChange:O,multiple:l,accept:u,name:d,form:f,resetRef:w,disabled:b,capture:x,inputProps:S},e=>Z.createElement(ab,vw(_w(_w(_w({multiline:!0},e),r),C),{component:`button`,type:`button`,ref:t,__staticSelector:`FileInput`,rightSection:A,classNames:vw(_w({},p),{input:E(T.input,p?.input)})}),k?Z.createElement(g,{value:D}):Z.createElement(ab.Placeholder,{className:T.placeholder},a))))});xw.displayName=`@mantine/core/FileInput`;var Sw=xw,[Cw,ww]=Fu(`Grid component was not found in tree`),Tw=Object.defineProperty,Ew=Object.getOwnPropertySymbols,Dw=Object.prototype.hasOwnProperty,Ow=Object.prototype.propertyIsEnumerable,kw=(e,t,n)=>t in e?Tw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Aw=(e,t)=>{for(var n in t||={})Dw.call(t,n)&&kw(e,n,t[n]);if(Ew)for(var n of Ew(t))Ow.call(t,n)&&kw(e,n,t[n]);return e},jw=(e,t)=>e===`content`?`auto`:e===`auto`?`0rem`:e?`${100/(t/e)}%`:void 0,Mw=(e,t,n)=>n||e===`auto`||e===`content`?`unset`:jw(e,t),Nw=(e,t)=>{if(e)return e===`auto`||t?1:0},Pw=(e,t)=>e===0?0:e?`${100/(t/e)}%`:void 0,Fw=(e,t)=>e===void 0?void 0:`calc(${J({size:e,sizes:t.spacing})} / 2)`;function Iw({sizes:e,offsets:t,orders:n,theme:r,columns:i,gutters:a,grow:o}){return Di.reduce((s,c)=>(s[`@media (min-width: ${sr(r.breakpoints[c])})`]={order:n[c],flexBasis:jw(e[c],i),padding:Fw(a[c],r),flexShrink:0,width:e[c]===`content`?`auto`:void 0,maxWidth:Mw(e[c],i,o),marginLeft:Pw(t[c],i),flexGrow:Nw(e[c],o)},s),{})}var Lw=Ur((e,{gutter:t,gutterXs:n,gutterSm:r,gutterMd:i,gutterLg:a,gutterXl:o,grow:s,offset:c,offsetXs:l,offsetSm:u,offsetMd:d,offsetLg:f,offsetXl:p,columns:m,span:h,xs:g,sm:_,md:v,lg:y,xl:b,order:x,orderXs:S,orderSm:C,orderMd:w,orderLg:T,orderXl:E})=>({col:Aw({boxSizing:`border-box`,flexGrow:Nw(h,s),order:x,padding:Fw(t,e),marginLeft:Pw(c,m),flexBasis:jw(h,m),flexShrink:0,width:h===`content`?`auto`:void 0,maxWidth:Mw(h,m,s)},Iw({sizes:{xs:g,sm:_,md:v,lg:y,xl:b},offsets:{xs:l,sm:u,md:d,lg:f,xl:p},orders:{xs:S,sm:C,md:w,lg:T,xl:E},gutters:{xs:n,sm:r,md:i,lg:a,xl:o},theme:e,columns:m,grow:s}))})),Rw=Object.defineProperty,zw=Object.getOwnPropertySymbols,Bw=Object.prototype.hasOwnProperty,Vw=Object.prototype.propertyIsEnumerable,Hw=(e,t,n)=>t in e?Rw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uw=(e,t)=>{for(var n in t||={})Bw.call(t,n)&&Hw(e,n,t[n]);if(zw)for(var n of zw(t))Vw.call(t,n)&&Hw(e,n,t[n]);return e},Ww=(e,t)=>{var n={};for(var r in e)Bw.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&zw)for(var r of zw(e))t.indexOf(r)<0&&Vw.call(e,r)&&(n[r]=e[r]);return n},Gw={};function Kw(e){return e===`auto`||e===`content`||typeof e==`number`&&e>0&&e%1==0}var qw=(0,Z.forwardRef)((e,t)=>{let n=X(`GridCol`,Gw,e),{children:r,span:i,offset:a,offsetXs:o,offsetSm:s,offsetMd:c,offsetLg:l,offsetXl:u,xs:d,sm:f,md:p,lg:m,xl:h,order:g,orderXs:_,orderSm:v,orderMd:y,orderLg:b,orderXl:x,className:S,unstyled:C,variant:w}=n,T=Ww(n,[`children`,`span`,`offset`,`offsetXs`,`offsetSm`,`offsetMd`,`offsetLg`,`offsetXl`,`xs`,`sm`,`md`,`lg`,`xl`,`order`,`orderXs`,`orderSm`,`orderMd`,`orderLg`,`orderXl`,`className`,`unstyled`,`variant`]),E=ww(),D=i||E.columns,{classes:O,cx:k}=Lw({gutter:E.gutter,gutterXs:E.gutterXs,gutterSm:E.gutterSm,gutterMd:E.gutterMd,gutterLg:E.gutterLg,gutterXl:E.gutterXl,offset:a,offsetXs:o,offsetSm:s,offsetMd:c,offsetLg:l,offsetXl:u,xs:d,sm:f,md:p,lg:m,xl:h,order:g,orderXs:_,orderSm:v,orderMd:y,orderLg:b,orderXl:x,grow:E.grow,columns:E.columns,span:D},{unstyled:C,name:`Grid`,variant:w});return!Kw(D)||D>E.columns?null:Z.createElement(Br,Uw({className:k(O.col,S),ref:t},T),r)});qw.displayName=`@mantine/core/Col`;var Jw=Object.defineProperty,Yw=Object.getOwnPropertySymbols,Xw=Object.prototype.hasOwnProperty,Zw=Object.prototype.propertyIsEnumerable,Qw=(e,t,n)=>t in e?Jw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$w=(e,t)=>{for(var n in t||={})Xw.call(t,n)&&Qw(e,n,t[n]);if(Yw)for(var n of Yw(t))Zw.call(t,n)&&Qw(e,n,t[n]);return e};function eT(e,t){return Di.reduce((n,r)=>(e[r]!==void 0&&(n[`@media (min-width: ${t.breakpoints[r]})`]={margin:`calc(-${J({size:e[r],sizes:t.spacing})} / 2)`}),n),{})}var tT=Ur((e,{justify:t,align:n,gutter:r,gutterXs:i,gutterSm:a,gutterMd:o,gutterLg:s,gutterXl:c})=>({root:$w({margin:`calc(-${J({size:r,sizes:e.spacing})} / 2)`,display:`flex`,flexWrap:`wrap`,justifyContent:t,alignItems:n},eT({xs:i,sm:a,md:o,lg:s,xl:c},e))})),nT=Object.defineProperty,rT=Object.getOwnPropertySymbols,iT=Object.prototype.hasOwnProperty,aT=Object.prototype.propertyIsEnumerable,oT=(e,t,n)=>t in e?nT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sT=(e,t)=>{for(var n in t||={})iT.call(t,n)&&oT(e,n,t[n]);if(rT)for(var n of rT(t))aT.call(t,n)&&oT(e,n,t[n]);return e},cT=(e,t)=>{var n={};for(var r in e)iT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rT)for(var r of rT(e))t.indexOf(r)<0&&aT.call(e,r)&&(n[r]=e[r]);return n},lT={gutter:`md`,justify:`flex-start`,align:`stretch`,columns:12},uT=(0,Z.forwardRef)((e,t)=>{let n=X(`Grid`,lT,e),{gutter:r,gutterXs:i,gutterSm:a,gutterMd:o,gutterLg:s,gutterXl:c,children:l,grow:u,justify:d,align:f,columns:p,className:m,unstyled:h,variant:g}=n,_=cT(n,[`gutter`,`gutterXs`,`gutterSm`,`gutterMd`,`gutterLg`,`gutterXl`,`children`,`grow`,`justify`,`align`,`columns`,`className`,`unstyled`,`variant`]),{classes:v,cx:y}=tT({gutter:r,justify:d,align:f,gutterXs:i,gutterSm:a,gutterMd:o,gutterLg:s,gutterXl:c},{unstyled:h,name:`Grid`,variant:g});return Z.createElement(Cw,{value:{gutter:r,gutterXs:i,gutterSm:a,gutterMd:o,gutterLg:s,gutterXl:c,grow:u,columns:p}},Z.createElement(Br,sT({className:y(v.root,m),ref:t},_),l))});uT.Col=qw,uT.displayName=`@mantine/core/Grid`;function dT(e){return Z.Children.toArray(e).filter(Boolean)}var fT={left:`flex-start`,center:`center`,right:`flex-end`,apart:`space-between`},pT=Ur((e,{spacing:t,position:n,noWrap:r,grow:i,align:a,count:o})=>({root:{boxSizing:`border-box`,display:`flex`,flexDirection:`row`,alignItems:a||`center`,flexWrap:r?`nowrap`:`wrap`,justifyContent:fT[n],gap:J({size:t,sizes:e.spacing}),"& > *":{boxSizing:`border-box`,maxWidth:i?`calc(${100/o}% - (${Y(J({size:t,sizes:e.spacing}))} - ${J({size:t,sizes:e.spacing})} / ${o}))`:void 0,flexGrow:+!!i}}})),mT=Object.defineProperty,hT=Object.getOwnPropertySymbols,gT=Object.prototype.hasOwnProperty,_T=Object.prototype.propertyIsEnumerable,vT=(e,t,n)=>t in e?mT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yT=(e,t)=>{for(var n in t||={})gT.call(t,n)&&vT(e,n,t[n]);if(hT)for(var n of hT(t))_T.call(t,n)&&vT(e,n,t[n]);return e},bT=(e,t)=>{var n={};for(var r in e)gT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hT)for(var r of hT(e))t.indexOf(r)<0&&_T.call(e,r)&&(n[r]=e[r]);return n},xT={position:`left`,spacing:`md`},ST=(0,Z.forwardRef)((e,t)=>{let n=X(`Group`,xT,e),{className:r,position:i,align:a,children:o,noWrap:s,grow:c,spacing:l,unstyled:u,variant:d}=n,f=bT(n,[`className`,`position`,`align`,`children`,`noWrap`,`grow`,`spacing`,`unstyled`,`variant`]),p=dT(o),{classes:m,cx:h}=pT({align:a,grow:c,noWrap:s,spacing:l,position:i,count:p.length},{unstyled:u,name:`Group`,variant:d});return Z.createElement(Br,yT({className:h(m.root,r),ref:t},f),p)});ST.displayName=`@mantine/core/Group`;var CT=Object.defineProperty,wT=Object.defineProperties,TT=Object.getOwnPropertyDescriptors,ET=Object.getOwnPropertySymbols,DT=Object.prototype.hasOwnProperty,OT=Object.prototype.propertyIsEnumerable,kT=(e,t,n)=>t in e?CT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,AT=(e,t)=>{for(var n in t||={})DT.call(t,n)&&kT(e,n,t[n]);if(ET)for(var n of ET(t))OT.call(t,n)&&kT(e,n,t[n]);return e},jT=(e,t)=>wT(e,TT(t)),MT=e=>si({from:{boxShadow:`0 0 ${Y(.5)} 0 ${e}`,opacity:.6},to:{boxShadow:`0 0 ${Y(.5)} ${Y(4.4)} ${e}`,opacity:0}});function NT(e,t=0){let n={},[r,i]=e.split(`-`),a=``,o=``;return r===`top`&&(n.top=t,o=`-50%`),r===`middle`&&(n.top=`50%`,o=`-50%`),r===`bottom`&&(n.bottom=t,o=`50%`),i===`start`&&(n.left=t,a=`-50%`),i===`center`&&(n.left=`50%`,a=`-50%`),i===`end`&&(n.right=t,a=`50%`),n.transform=`translate(${a}, ${o})`,n}var PT=Ur((e,{radius:t,color:n,position:r,offset:i,inline:a,withBorder:o,withLabel:s,zIndex:c},{size:l})=>{let{background:u}=e.fn.variant({variant:`filled`,primaryFallback:!1,color:n||e.primaryColor}),d=Y(l);return{root:{position:`relative`,display:a?`inline-block`:`block`},indicator:jT(AT({},NT(r,i)),{zIndex:c,position:`absolute`,[s?`minWidth`:`width`]:d,height:d,display:`flex`,justifyContent:`center`,alignItems:`center`,fontSize:e.fontSizes.xs,paddingLeft:s?`calc(${e.spacing.xs} / 2)`:0,paddingRight:s?`calc(${e.spacing.xs} / 2)`:0,borderRadius:e.fn.radius(t),backgroundColor:e.fn.variant({variant:`filled`,primaryFallback:!1,color:n||e.primaryColor}).background,border:o?`${Y(2)} solid ${e.colorScheme===`dark`?e.colors.dark[7]:e.white}`:void 0,color:e.white,whiteSpace:`nowrap`}),processing:{animation:`${MT(u)} 1000ms linear infinite`},common:jT(AT({},NT(r,i)),{position:`absolute`,[s?`minWidth`:`width`]:d,height:d,borderRadius:e.fn.radius(t)})}}),FT=Object.defineProperty,IT=Object.getOwnPropertySymbols,LT=Object.prototype.hasOwnProperty,RT=Object.prototype.propertyIsEnumerable,zT=(e,t,n)=>t in e?FT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,BT=(e,t)=>{for(var n in t||={})LT.call(t,n)&&zT(e,n,t[n]);if(IT)for(var n of IT(t))RT.call(t,n)&&zT(e,n,t[n]);return e},VT=(e,t)=>{var n={};for(var r in e)LT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&IT)for(var r of IT(e))t.indexOf(r)<0&&RT.call(e,r)&&(n[r]=e[r]);return n},HT={position:`top-end`,offset:0,inline:!1,withBorder:!1,disabled:!1,processing:!1,size:10,radius:1e3,zIndex:Hu(`app`)},UT=(0,Z.forwardRef)((e,t)=>{let n=X(`Indicator`,HT,e),{children:r,position:i,offset:a,size:o,radius:s,inline:c,withBorder:l,className:u,color:d,styles:f,label:p,classNames:m,disabled:h,zIndex:g,unstyled:_,processing:v,variant:y}=n,b=VT(n,[`children`,`position`,`offset`,`size`,`radius`,`inline`,`withBorder`,`className`,`color`,`styles`,`label`,`classNames`,`disabled`,`zIndex`,`unstyled`,`processing`,`variant`]),{classes:x,cx:S}=PT({position:i,offset:a,radius:s,inline:c,color:d,withBorder:l,zIndex:g,withLabel:!!p},{name:`Indicator`,classNames:m,styles:f,unstyled:_,variant:y,size:o});return Z.createElement(Br,BT({ref:t,className:S(x.root,u)},b),!h&&Z.createElement(Z.Fragment,null,Z.createElement(`div`,{className:S(x.indicator,x.common)},p),v&&Z.createElement(`div`,{className:S(x.processing,x.common)})),r)});UT.displayName=`@mantine/core/Indicator`;var[WT,GT]=Fu(`List component was not found in tree`),KT=Ur((e,{spacing:t,center:n})=>({itemWrapper:{ref:Uu(`itemWrapper`),display:`inline-flex`,flexDirection:`column`,whiteSpace:`normal`},item:{whiteSpace:`nowrap`,lineHeight:n?1:e.lineHeight,"&:not(:first-of-type)":{marginTop:J({size:t,sizes:e.spacing})},"&[data-with-icon]":{listStyle:`none`,[`& .${Uu(`itemWrapper`)}`]:{display:`inline-flex`,alignItems:n?`center`:`flex-start`,flexDirection:`row`}}},itemIcon:{display:`inline-block`,verticalAlign:`middle`,marginRight:e.spacing.sm}})),qT=Object.defineProperty,JT=Object.getOwnPropertySymbols,YT=Object.prototype.hasOwnProperty,XT=Object.prototype.propertyIsEnumerable,ZT=(e,t,n)=>t in e?qT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,QT=(e,t)=>{for(var n in t||={})YT.call(t,n)&&ZT(e,n,t[n]);if(JT)for(var n of JT(t))XT.call(t,n)&&ZT(e,n,t[n]);return e},$T=(e,t)=>{var n={};for(var r in e)YT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&JT)for(var r of JT(e))t.indexOf(r)<0&&XT.call(e,r)&&(n[r]=e[r]);return n},eE={},tE=(0,Z.forwardRef)((e,t)=>{let n=X(`ListItem`,eE,e),{className:r,children:i,icon:a}=n,o=$T(n,[`className`,`children`,`icon`]),{icon:s,spacing:c,center:l,listStyleType:u,size:d,withPadding:f,classNames:p,styles:m,unstyled:h,variant:g}=GT(),_=a||s,{classes:v,cx:y}=KT({withPadding:f,listStyleType:u,center:l,spacing:c},{classNames:p,styles:m,unstyled:h,name:`List`,variant:g,size:d});return Z.createElement(Br,QT({component:`li`,className:y(v.item,r),"data-with-icon":!!_||void 0,ref:t},o),Z.createElement(`div`,{className:v.itemWrapper},_&&Z.createElement(`span`,{className:v.itemIcon},_),Z.createElement(`span`,null,i)))});tE.displayName=`@mantine/core/ListItem`;var nE=Object.defineProperty,rE=Object.defineProperties,iE=Object.getOwnPropertyDescriptors,aE=Object.getOwnPropertySymbols,oE=Object.prototype.hasOwnProperty,sE=Object.prototype.propertyIsEnumerable,cE=(e,t,n)=>t in e?nE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lE=(e,t)=>{for(var n in t||={})oE.call(t,n)&&cE(e,n,t[n]);if(aE)for(var n of aE(t))sE.call(t,n)&&cE(e,n,t[n]);return e},uE=(e,t)=>rE(e,iE(t)),dE=Ur((e,{withPadding:t,listStyleType:n},{size:r})=>({root:uE(lE({},e.fn.fontStyles()),{listStyleType:n,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,fontSize:J({size:r,sizes:e.fontSizes}),lineHeight:e.lineHeight,margin:0,paddingLeft:t?e.spacing.xl:0,listStylePosition:`inside`})})),fE=Object.defineProperty,pE=Object.getOwnPropertySymbols,mE=Object.prototype.hasOwnProperty,hE=Object.prototype.propertyIsEnumerable,gE=(e,t,n)=>t in e?fE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_E=(e,t)=>{for(var n in t||={})mE.call(t,n)&&gE(e,n,t[n]);if(pE)for(var n of pE(t))hE.call(t,n)&&gE(e,n,t[n]);return e},vE=(e,t)=>{var n={};for(var r in e)mE.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&pE)for(var r of pE(e))t.indexOf(r)<0&&hE.call(e,r)&&(n[r]=e[r]);return n},yE={type:`unordered`,size:`md`,spacing:0},bE=(0,Z.forwardRef)((e,t)=>{let n=X(`List`,yE,e),{children:r,type:i,size:a,listStyleType:o,withPadding:s,center:c,spacing:l,icon:u,className:d,styles:f,classNames:p,unstyled:m,variant:h}=n,g=vE(n,[`children`,`type`,`size`,`listStyleType`,`withPadding`,`center`,`spacing`,`icon`,`className`,`styles`,`classNames`,`unstyled`,`variant`]),{classes:_,cx:v}=dE({withPadding:s,listStyleType:o,center:c,spacing:l},{classNames:p,styles:f,name:`List`,unstyled:m,size:a,variant:h});return Z.createElement(WT,{value:{spacing:l,center:c,icon:u,listStyleType:o,size:a,withPadding:s,classNames:p,styles:f,unstyled:m,variant:h}},Z.createElement(Br,_E({component:i===`unordered`?`ul`:`ol`,className:v(_.root,d),ref:t},g),r))});bE.Item=tE,bE.displayName=`@mantine/core/List`;var xE=Object.defineProperty,SE=Object.defineProperties,CE=Object.getOwnPropertyDescriptors,wE=Object.getOwnPropertySymbols,TE=Object.prototype.hasOwnProperty,EE=Object.prototype.propertyIsEnumerable,DE=(e,t,n)=>t in e?xE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,OE=(e,t)=>{for(var n in t||={})TE.call(t,n)&&DE(e,n,t[n]);if(wE)for(var n of wE(t))EE.call(t,n)&&DE(e,n,t[n]);return e},kE=(e,t)=>SE(e,CE(t)),AE=Ur(e=>({root:kE(OE({},e.fn.cover()),{display:`flex`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`})})),jE=Object.defineProperty,ME=Object.defineProperties,NE=Object.getOwnPropertyDescriptors,PE=Object.getOwnPropertySymbols,FE=Object.prototype.hasOwnProperty,IE=Object.prototype.propertyIsEnumerable,LE=(e,t,n)=>t in e?jE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,RE=(e,t)=>{for(var n in t||={})FE.call(t,n)&&LE(e,n,t[n]);if(PE)for(var n of PE(t))IE.call(t,n)&&LE(e,n,t[n]);return e},zE=(e,t)=>ME(e,NE(t)),BE=(e,t)=>{var n={};for(var r in e)FE.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&PE)for(var r of PE(e))t.indexOf(r)<0&&IE.call(e,r)&&(n[r]=e[r]);return n},VE={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:Hu(`overlay`)},HE=(0,Z.forwardRef)((e,t)=>{let n=X(`LoadingOverlay`,VE,e),{className:r,visible:i,loaderProps:a,overlayOpacity:o,overlayColor:s,transitionDuration:c,exitTransitionDuration:l,zIndex:u,style:d,loader:f,radius:p,overlayBlur:m,unstyled:h,variant:g,keepMounted:_}=n,v=BE(n,[`className`,`visible`,`loaderProps`,`overlayOpacity`,`overlayColor`,`transitionDuration`,`exitTransitionDuration`,`zIndex`,`style`,`loader`,`radius`,`overlayBlur`,`unstyled`,`variant`,`keepMounted`]),{classes:y,cx:b,theme:x}=AE(null,{name:`LoadingOverlay`,unstyled:h,variant:g}),S=`calc(${u} + 1)`;return Z.createElement(f_,{keepMounted:_,duration:c,exitDuration:l,mounted:i,transition:`fade`},e=>Z.createElement(Br,RE({className:b(y.root,r),style:zE(RE(RE({},e),d),{zIndex:u}),ref:t},v),f?Z.createElement(`div`,{style:{zIndex:S}},f):Z.createElement(ti,RE({style:{zIndex:S}},a)),Z.createElement(aS,{opacity:o,zIndex:u,radius:p,blur:m,unstyled:h,color:s||(x.colorScheme===`dark`?x.colors.dark[5]:x.white)})))});HE.displayName=`@mantine/core/LoadingOverlay`;var[UE,WE]=Fu(`Modal component was not found in tree`),GE={xs:Y(320),sm:Y(380),md:Y(440),lg:Y(620),xl:Y(780)},KE=Ur((e,{yOffset:t,xOffset:n,centered:r,fullScreen:i},{size:a})=>({content:{flex:i?`0 0 100%`:`0 0 ${J({size:a,sizes:GE})}`,maxWidth:`100%`,maxHeight:i?void 0:`calc(100dvh - (${Y(t)} * 2))`,height:i?`100vh`:void 0,borderRadius:i?0:void 0,overflowY:`auto`},inner:{paddingTop:i?0:t,paddingBottom:i?0:t,paddingLeft:i?0:n,paddingRight:i?0:n,display:`flex`,justifyContent:`center`,alignItems:r?`center`:`flex-start`}})),qE=Object.defineProperty,JE=Object.defineProperties,YE=Object.getOwnPropertyDescriptors,XE=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,$E=(e,t,n)=>t in e?qE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eD=(e,t)=>{for(var n in t||={})ZE.call(t,n)&&$E(e,n,t[n]);if(XE)for(var n of XE(t))QE.call(t,n)&&$E(e,n,t[n]);return e},tD=(e,t)=>JE(e,YE(t)),nD=(e,t)=>{var n={};for(var r in e)ZE.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&XE)for(var r of XE(e))t.indexOf(r)<0&&QE.call(e,r)&&(n[r]=e[r]);return n},rD=tD(eD({},_C),{yOffset:`5dvh`,xOffset:`5vw`});function iD(e){let t=X(`ModalRoot`,rD,e),{classNames:n,variant:r,size:i,yOffset:a,xOffset:o,scrollAreaComponent:s,radius:c,centered:l,fullScreen:u}=t,d=nD(t,[`classNames`,`variant`,`size`,`yOffset`,`xOffset`,`scrollAreaComponent`,`radius`,`centered`,`fullScreen`]),{classes:f,cx:p}=KE({yOffset:a,xOffset:o,centered:l,fullScreen:u},{name:`Modal`,variant:r,size:i});return Z.createElement(UE,{value:{yOffset:a,scrollAreaComponent:s,radius:c}},Z.createElement(vC,eD({__staticSelector:`Modal`,size:i,variant:r,classNames:tD(eD({},n),{content:p(f.content,n?.content),inner:p(f.inner,n?.inner)})},d)))}var aD=Object.defineProperty,oD=Object.getOwnPropertySymbols,sD=Object.prototype.hasOwnProperty,cD=Object.prototype.propertyIsEnumerable,lD=(e,t,n)=>t in e?aD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uD=(e,t)=>{for(var n in t||={})sD.call(t,n)&&lD(e,n,t[n]);if(oD)for(var n of oD(t))cD.call(t,n)&&lD(e,n,t[n]);return e},dD=(e,t)=>{var n={};for(var r in e)sD.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oD)for(var r of oD(e))t.indexOf(r)<0&&cD.call(e,r)&&(n[r]=e[r]);return n},fD={shadow:`xl`},pD=(0,Z.forwardRef)((e,t)=>{let n=X(`ModalContent`,fD,e),{children:r,scrollAreaComponent:i}=n,a=dD(n,[`children`,`scrollAreaComponent`]),o=WE(),s=i||o.scrollAreaComponent||vC.NativeScrollArea;return Z.createElement(vC.Content,uD({ref:t,radius:o.radius},a),Z.createElement(s,{style:{maxHeight:`calc(100dvh - (${Y(o.yOffset)} * 2))`}},r))}),mD=Object.defineProperty,hD=Object.defineProperties,gD=Object.getOwnPropertyDescriptors,_D=Object.getOwnPropertySymbols,vD=Object.prototype.hasOwnProperty,yD=Object.prototype.propertyIsEnumerable,bD=(e,t,n)=>t in e?mD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xD=(e,t)=>{for(var n in t||={})vD.call(t,n)&&bD(e,n,t[n]);if(_D)for(var n of _D(t))yD.call(t,n)&&bD(e,n,t[n]);return e},SD=(e,t)=>hD(e,gD(t)),CD=(e,t)=>{var n={};for(var r in e)vD.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_D)for(var r of _D(e))t.indexOf(r)<0&&yD.call(e,r)&&(n[r]=e[r]);return n},wD=SD(xD({},_C),{transitionProps:{duration:200,transition:`pop`},withOverlay:!0,withCloseButton:!0});function TD(e){let t=X(`Modal`,wD,e),{title:n,withOverlay:r,overlayProps:i,withCloseButton:a,closeButtonProps:o,children:s}=t,c=CD(t,[`title`,`withOverlay`,`overlayProps`,`withCloseButton`,`closeButtonProps`,`children`]),l=!!n||a;return Z.createElement(iD,xD({},c),r&&Z.createElement(vC.Overlay,xD({},i)),Z.createElement(pD,null,l&&Z.createElement(vC.Header,null,n&&Z.createElement(vC.Title,null,n),a&&Z.createElement(vC.CloseButton,xD({},o))),Z.createElement(vC.Body,null,s)))}TD.Root=iD,TD.CloseButton=vC.CloseButton,TD.Overlay=vC.Overlay,TD.Content=pD,TD.Header=vC.Header,TD.Title=vC.Title,TD.Body=vC.Body,TD.NativeScrollArea=vC.NativeScrollArea;var ED=Object.defineProperty,DD=Object.getOwnPropertySymbols,OD=Object.prototype.hasOwnProperty,kD=Object.prototype.propertyIsEnumerable,AD=(e,t,n)=>t in e?ED(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jD=(e,t)=>{for(var n in t||={})OD.call(t,n)&&AD(e,n,t[n]);if(DD)for(var n of DD(t))kD.call(t,n)&&AD(e,n,t[n]);return e},MD=(e,t)=>{var n={};for(var r in e)OD.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&DD)for(var r of DD(e))t.indexOf(r)<0&&kD.call(e,r)&&(n[r]=e[r]);return n},ND={xs:Y(14),sm:Y(18),md:Y(20),lg:Y(24),xl:Y(28)};function PD(e){var t=e,{size:n,error:r,style:i}=t,a=MD(t,[`size`,`error`,`style`]);let o=Kr(),s=J({size:n,sizes:ND});return Z.createElement(`svg`,jD({viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:jD({color:r?o.colors.red[6]:o.colors.gray[6],width:s,height:s},i),"data-chevron":!0},a),Z.createElement(`path`,{d:`M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`}))}var FD=Object.defineProperty,ID=Object.defineProperties,LD=Object.getOwnPropertyDescriptors,RD=Object.getOwnPropertySymbols,zD=Object.prototype.hasOwnProperty,BD=Object.prototype.propertyIsEnumerable,VD=(e,t,n)=>t in e?FD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,HD=(e,t)=>{for(var n in t||={})zD.call(t,n)&&VD(e,n,t[n]);if(RD)for(var n of RD(t))BD.call(t,n)&&VD(e,n,t[n]);return e},UD=(e,t)=>ID(e,LD(t));function WD({shouldClear:e,clearButtonProps:t,onClear:n,size:r,error:i}){return e?Z.createElement(bp,UD(HD({},t),{variant:`transparent`,onClick:n,size:r,onMouseDown:e=>e.preventDefault()})):Z.createElement(PD,{error:i,size:r})}WD.displayName=`@mantine/core/SelectRightSection`;var GD=Object.defineProperty,KD=Object.defineProperties,qD=Object.getOwnPropertyDescriptors,JD=Object.getOwnPropertySymbols,YD=Object.prototype.hasOwnProperty,XD=Object.prototype.propertyIsEnumerable,ZD=(e,t,n)=>t in e?GD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,QD=(e,t)=>{for(var n in t||={})YD.call(t,n)&&ZD(e,n,t[n]);if(JD)for(var n of JD(t))XD.call(t,n)&&ZD(e,n,t[n]);return e},$D=(e,t)=>KD(e,qD(t)),eO=(e,t)=>{var n={};for(var r in e)YD.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&JD)for(var r of JD(e))t.indexOf(r)<0&&XD.call(e,r)&&(n[r]=e[r]);return n};function tO(e){var t=e,{styles:n,rightSection:r,rightSectionWidth:i,theme:a}=t,o=eO(t,[`styles`,`rightSection`,`rightSectionWidth`,`theme`]);if(r)return{rightSection:r,rightSectionWidth:i,styles:n};let s=typeof n==`function`?n(a):n;return{rightSection:!o.readOnly&&!(o.disabled&&o.shouldClear)&&Z.createElement(WD,QD({},o)),styles:$D(QD({},s),{rightSection:$D(QD({},s?.rightSection),{pointerEvents:o.shouldClear?void 0:`none`})})}}var nO=(e,t,n)=>Number.isInteger(e)&&e>=0&&t===0?`numeric`:!Number.isInteger(e)&&e>=0&&t!==0?`decimal`:Number.isInteger(e)&&e<0&&t===0||!Number.isInteger(e)&&e<0&&t!==0?n===`ios`?`text`:`decimal`:`numeric`;function rO({direction:e,size:t}){return Z.createElement(`svg`,{style:{width:Y(t),height:Y(t),transform:e===`up`?`rotate(180deg)`:void 0},viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},Z.createElement(`path`,{d:`M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`}))}var iO={xs:Y(20),sm:Y(24),md:Y(30),lg:Y(34),xl:Y(36)},aO=Ur((e,{radius:t},{size:n})=>({rightSection:{display:`flex`,flexDirection:`column`,height:`calc(100% - ${Y(2)})`,margin:Y(1),overflow:`hidden`,borderTopRightRadius:e.fn.radius(t),borderBottomRightRadius:e.fn.radius(t)},control:{margin:0,position:`relative`,flex:`0 0 50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxSizing:`border-box`,width:J({size:n,sizes:iO}),padding:0,WebkitTapHighlightColor:`transparent`,borderBottom:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[4]}`,borderLeft:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[4]}`,borderTop:0,borderRight:0,backgroundColor:`transparent`,marginRight:Y(1),color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,"&:not(:disabled):hover":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[0]},"&:disabled":{color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[4]}},controlUp:{},controlDown:{borderBottom:0}})),oO=Object.defineProperty,sO=Object.defineProperties,cO=Object.getOwnPropertyDescriptors,lO=Object.getOwnPropertySymbols,uO=Object.prototype.hasOwnProperty,dO=Object.prototype.propertyIsEnumerable,fO=(e,t,n)=>t in e?oO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pO=(e,t)=>{for(var n in t||={})uO.call(t,n)&&fO(e,n,t[n]);if(lO)for(var n of lO(t))dO.call(t,n)&&fO(e,n,t[n]);return e},mO=(e,t)=>sO(e,cO(t)),hO=(e,t)=>{var n={};for(var r in e)uO.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&lO)for(var r of lO(e))t.indexOf(r)<0&&dO.call(e,r)&&(n[r]=e[r]);return n},gO={type:`text`,size:`sm`,__staticSelector:`TextInput`},_O=(0,Z.forwardRef)((e,t)=>{let n=Sv(`TextInput`,gO,e),{inputProps:r,wrapperProps:i}=n,a=hO(n,[`inputProps`,`wrapperProps`]);return Z.createElement(ab.Wrapper,pO({},i),Z.createElement(ab,mO(pO(pO({},r),a),{ref:t})))});_O.displayName=`@mantine/core/TextInput`;var vO=Object.defineProperty,yO=Object.defineProperties,bO=Object.getOwnPropertyDescriptors,xO=Object.getOwnPropertySymbols,SO=Object.prototype.hasOwnProperty,CO=Object.prototype.propertyIsEnumerable,wO=(e,t,n)=>t in e?vO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,TO=(e,t)=>{for(var n in t||={})SO.call(t,n)&&wO(e,n,t[n]);if(xO)for(var n of xO(t))CO.call(t,n)&&wO(e,n,t[n]);return e},EO=(e,t)=>yO(e,bO(t)),DO=(e,t)=>{var n={};for(var r in e)SO.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&xO)for(var r of xO(e))t.indexOf(r)<0&&CO.call(e,r)&&(n[r]=e[r]);return n},OO=e=>e||``,kO=e=>{if(e===`-`)return e;let t=e;t[0]===`.`&&(t=`0${e}`);let n=parseFloat(t);return Number.isNaN(n)?``:e},AO={xs:Y(10),sm:Y(14),md:Y(16),lg:Y(18),xl:Y(20)},jO={step:1,hideControls:!1,size:`sm`,precision:0,noClampOnBlur:!1,removeTrailingZeros:!1,decimalSeparator:`.`,formatter:OO,parser:kO,type:`text`},MO=(0,Z.forwardRef)((e,t)=>{let n=X(`NumberInput`,jO,e),{readOnly:r,disabled:i,value:a,onChange:o,decimalSeparator:s,thousandsSeparator:c,min:l,max:u,startValue:d,step:f,stepHoldInterval:p,stepHoldDelay:m,onFocus:h,onBlur:g,onKeyDown:_,onKeyUp:v,hideControls:y,radius:b,variant:x,precision:S,removeTrailingZeros:C,defaultValue:w,noClampOnBlur:T,handlersRef:E,classNames:D,styles:O,size:k,rightSection:A,rightSectionWidth:j,formatter:M,parser:N,inputMode:P,unstyled:F,type:I}=n,L=DO(n,`readOnly.disabled.value.onChange.decimalSeparator.thousandsSeparator.min.max.startValue.step.stepHoldInterval.stepHoldDelay.onFocus.onBlur.onKeyDown.onKeyUp.hideControls.radius.variant.precision.removeTrailingZeros.defaultValue.noClampOnBlur.handlersRef.classNames.styles.size.rightSection.rightSectionWidth.formatter.parser.inputMode.unstyled.type`.split(`.`)),{classes:R,cx:z}=aO({radius:b},{classNames:D,styles:O,unstyled:F,name:`NumberInput`,variant:x,size:k}),B=e=>{if(e===``)return``;let t=e.toFixed(S);return C&&S>0&&(t=t.replace(RegExp(`[0]{0,${S}}$`),``),t.endsWith(`.`)&&(t=t.slice(0,-1))),t},V=e=>{let t=e;return s&&(t=t.replace(`.`,s)),M(t)},ee=e=>{let t=e;return s&&(t=t.replaceAll(c,``).replace(s,`.`)),N(t)},te=e=>V(B(e)),[ne,re]=(0,Z.useState)(typeof a==`number`?a:typeof w==`number`?w:``),[H,ie]=(0,Z.useState)(()=>te(ne)),U=(0,Z.useRef)(),[W,ae]=(0,Z.useState)(!1),G=(e,t)=>{if(!W||t){let t=te(e);t!==H&&ie(t)}e!==ne&&re(e)},oe=typeof l==`number`?l:-1/0,se=typeof u==`number`?u:1/0,ce=(0,Z.useRef)();ce.current=()=>{let e;e=ne===``?d??l??0:parseFloat(B(od(ne+f,oe,se))),G(e,!0),o?.(e)};let le=(0,Z.useRef)();le.current=()=>{let e;e=ne===``?d??l??0:parseFloat(B(od(ne-f,oe,se))),G(e,!0),o?.(e)},Td(E,{increment:ce.current,decrement:le.current}),(0,Z.useEffect)(()=>{W||G(a===void 0?ne:a,!0)},[a,W]);let ue=m!==void 0&&p!==void 0,de=(0,Z.useRef)(null),fe=(0,Z.useRef)(0),pe=()=>{de.current&&window.clearTimeout(de.current),de.current=null,fe.current=0},me=e=>{e?ce.current():le.current(),fe.current+=1},he=e=>{if(me(e),ue){let t=typeof p==`number`?p:p(fe.current);de.current=window.setTimeout(()=>he(e),t)}},ge=(e,t)=>{e.preventDefault(),U.current.focus(),me(t),ue&&(de.current=window.setTimeout(()=>he(t),m))};(0,Z.useEffect)(()=>(pe(),pe),[]);let _e=Z.createElement(`div`,{className:R.rightSection},Z.createElement(`button`,{type:`button`,tabIndex:-1,"aria-hidden":!0,disabled:ne>=u,className:z(R.control,R.controlUp),onPointerDown:e=>{ge(e,!0)},onPointerUp:pe,onPointerLeave:pe},Z.createElement(rO,{size:J({size:k,sizes:AO}),direction:`up`})),Z.createElement(`button`,{type:`button`,tabIndex:-1,"aria-hidden":!0,disabled:ne<=l,className:z(R.control,R.controlDown),onPointerDown:e=>{ge(e,!1)},onPointerUp:pe,onPointerLeave:pe},Z.createElement(rO,{size:J({size:k,sizes:AO}),direction:`down`}))),ve=e=>{let t=e;(t[0]===`${s}`||t[0]===`.`)&&(t=`0${t}`);let n=parseFloat(B(parseFloat(ee(t)))),r=T?n:od(n,oe,se),i=Number.isNaN(r)?``:r,a=ne!==i;ie(e),G(i),a&&o?.(i)};return Z.createElement(_O,EO(TO({},L),{type:I,variant:x,value:H,disabled:i,readOnly:r,ref:Dd(U,t),onChange:e=>{e.nativeEvent.isComposing||ve(e.target.value)},onFocus:e=>{ae(!0),h?.(e)},onBlur:e=>{ae(!1),g?.(e)},onKeyDown:e=>{if(typeof _==`function`&&_(e),e.repeat&&ue&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();return}r||(e.key===`ArrowUp`?ge(e,!0):e.key===`ArrowDown`&&ge(e,!1))},onKeyUp:e=>{typeof v==`function`&&v(e),(e.key===`ArrowUp`||e.key===`ArrowDown`)&&pe()},rightSection:A||(i||r||y||x===`unstyled`?null:_e),rightSectionWidth:j??`calc(${J({size:k,sizes:iO})} + ${Y(1)})`,radius:b,max:u,min:l,step:f,size:k,styles:O,classNames:D,inputMode:P||nO(f,S,Id()),__staticSelector:`NumberInput`,unstyled:F}))});MO.displayName=`@mantine/core/NumberInput`;function NO({data:e,searchable:t,limit:n,searchValue:r,filter:i,value:a,filterDataOnExactSearchMatch:o}){if(!t)return e;let s=a==null?null:e.find(e=>e.value===a)||null;if(s&&!o&&s?.label===r){if(n){if(n>=e.length)return e;let t=e.indexOf(s),r=t+n,i=r-e.length;return i>0?e.slice(t-i):e.slice(t,r)}return e}let c=[];for(let t=0;t<e.length&&(i(r,e[t])&&c.push(e[t]),!(c.length>=n));t+=1);return c}var PO=Ur(()=>({input:{"&:not(:disabled)":{cursor:`pointer`,"&::selection":{backgroundColor:`transparent`}}}})),FO=Object.defineProperty,IO=Object.defineProperties,LO=Object.getOwnPropertyDescriptors,RO=Object.getOwnPropertySymbols,zO=Object.prototype.hasOwnProperty,BO=Object.prototype.propertyIsEnumerable,VO=(e,t,n)=>t in e?FO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,HO=(e,t)=>{for(var n in t||={})zO.call(t,n)&&VO(e,n,t[n]);if(RO)for(var n of RO(t))BO.call(t,n)&&VO(e,n,t[n]);return e},UO=(e,t)=>IO(e,LO(t)),WO=(e,t)=>{var n={};for(var r in e)zO.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&RO)for(var r of RO(e))t.indexOf(r)<0&&BO.call(e,r)&&(n[r]=e[r]);return n};function GO(e,t){return t.label.toLowerCase().trim().includes(e.toLowerCase().trim())}function KO(e,t){return!!e&&!t.some(t=>t.label.toLowerCase()===e.toLowerCase())}var qO={required:!1,size:`sm`,shadow:`sm`,itemComponent:om,transitionProps:{transition:`fade`,duration:0},initiallyOpened:!1,filter:GO,maxDropdownHeight:220,searchable:!1,clearable:!1,limit:1/0,disabled:!1,creatable:!1,shouldCreate:KO,selectOnBlur:!1,switchDirectionOnFlip:!1,filterDataOnExactSearchMatch:!1,zIndex:Hu(`popover`),positionDependencies:[],dropdownPosition:`flip`},JO=(0,Z.forwardRef)((e,t)=>{let n=Sv(`Select`,qO,e),{inputProps:r,wrapperProps:i,shadow:a,data:o,value:s,defaultValue:c,onChange:l,itemComponent:u,onKeyDown:d,onBlur:f,onFocus:p,transitionProps:m,initiallyOpened:h,unstyled:g,classNames:_,styles:v,filter:y,maxDropdownHeight:b,searchable:x,clearable:S,nothingFound:C,limit:w,disabled:T,onSearchChange:E,searchValue:D,rightSection:O,rightSectionWidth:k,creatable:A,getCreateLabel:j,shouldCreate:M,selectOnBlur:N,onCreate:P,dropdownComponent:F,onDropdownClose:I,onDropdownOpen:L,withinPortal:R,portalProps:z,switchDirectionOnFlip:B,zIndex:V,name:ee,dropdownPosition:te,allowDeselect:ne,placeholder:re,filterDataOnExactSearchMatch:H,form:ie,positionDependencies:U,readOnly:W,clearButtonProps:ae,hoverOnSearchChange:G}=n,oe=WO(n,`inputProps.wrapperProps.shadow.data.value.defaultValue.onChange.itemComponent.onKeyDown.onBlur.onFocus.transitionProps.initiallyOpened.unstyled.classNames.styles.filter.maxDropdownHeight.searchable.clearable.nothingFound.limit.disabled.onSearchChange.searchValue.rightSection.rightSectionWidth.creatable.getCreateLabel.shouldCreate.selectOnBlur.onCreate.dropdownComponent.onDropdownClose.onDropdownOpen.withinPortal.portalProps.switchDirectionOnFlip.zIndex.name.dropdownPosition.allowDeselect.placeholder.filterDataOnExactSearchMatch.form.positionDependencies.readOnly.clearButtonProps.hoverOnSearchChange`.split(`.`)),{classes:se,cx:ce,theme:le}=PO(),[ue,de]=(0,Z.useState)(h),[fe,pe]=(0,Z.useState)(-1),me=(0,Z.useRef)(),he=(0,Z.useRef)({}),[ge,_e]=(0,Z.useState)(`column`),ve=ge===`column`,{scrollIntoView:ye,targetRef:be,scrollableRef:xe}=Pd({duration:0,offset:5,cancelable:!1,isList:!0}),Se=ne===void 0?S:ne,Ce=e=>{if(ue!==e){de(e);let t=e?L:I;typeof t==`function`&&t()}},we=A&&typeof j==`function`,Te=null,Ee=zu({data:o.map(e=>typeof e==`string`?{label:e,value:e}:e)}),[De,Oe,ke]=Od({value:s,defaultValue:c,finalValue:null,onChange:l}),Ae=Ee.find(e=>e.value===De),[je,Me]=Od({value:D,defaultValue:Ae?.label||``,finalValue:void 0,onChange:E}),Ne=e=>{Me(e),x&&typeof E==`function`&&E(e)},Pe=()=>{var e;W||(Oe(null),ke||Ne(``),(e=me.current)==null||e.focus())};(0,Z.useEffect)(()=>{let e=Ee.find(e=>e.value===De);e?Ne(e.label):(!we||!De)&&Ne(``)},[De]),(0,Z.useEffect)(()=>{Ae&&(!x||!ue)&&Ne(Ae.label)},[Ae?.label]);let Fe=e=>{if(!W){if(Se&&Ae?.value===e.value)Oe(null),Ce(!1);else{if(e.creatable&&typeof P==`function`){let t=P(e.value);t!=null&&Oe(typeof t==`string`?t:t.value)}else Oe(e.value);ke||Ne(e.label),pe(-1),Ce(!1),me.current.focus()}}},Ie=NO({data:Ee,searchable:x,limit:w,searchValue:je,filter:y,filterDataOnExactSearchMatch:H,value:De});we&&M(je,Ie)&&(Te=j(je),Ie.push({label:je,value:je,creatable:!0}));let Le=(e,t,n)=>{let r=e;for(;n(r);)if(r=t(r),!Ie[r].disabled)return r;return e};bi(()=>{pe(G&&je?0:-1)},[je,G]);let Re=De?Ie.findIndex(e=>e.value===De):0,ze=!W&&(Ie.length>0?ue:ue&&!!C),Be=()=>{pe(e=>{let t=Le(e,e=>e-1,e=>e>0);return be.current=he.current[Ie[t]?.value],ze&&ye({alignment:ve?`start`:`end`}),t})},K=()=>{pe(e=>{let t=Le(e,e=>e+1,e=>e<Ie.length-1);return be.current=he.current[Ie[t]?.value],ze&&ye({alignment:ve?`end`:`start`}),t})},Ve=()=>window.setTimeout(()=>{be.current=he.current[Ie[Re]?.value],ye({alignment:ve?`end`:`start`})},50);bi(()=>{ze&&Ve()},[ze]);let He=e=>{switch(typeof d==`function`&&d(e),e.key){case`ArrowUp`:e.preventDefault(),ue?ve?Be():K():(pe(Re),Ce(!0),Ve());break;case`ArrowDown`:e.preventDefault(),ue?ve?K():Be():(pe(Re),Ce(!0),Ve());break;case`Home`:if(!x){e.preventDefault(),ue||Ce(!0);let t=Ie.findIndex(e=>!e.disabled);pe(t),ze&&ye({alignment:ve?`end`:`start`})}break;case`End`:if(!x){e.preventDefault(),ue||Ce(!0);let t=Ie.map(e=>!!e.disabled).lastIndexOf(!1);pe(t),ze&&ye({alignment:ve?`end`:`start`})}break;case`Escape`:e.preventDefault(),Ce(!1),pe(-1);break;case` `:x||(e.preventDefault(),Ie[fe]&&ue?Fe(Ie[fe]):(Ce(!0),pe(Re),Ve()));break;case`Enter`:x||e.preventDefault(),Ie[fe]&&ue&&(e.preventDefault(),Fe(Ie[fe]))}},Ue=e=>{typeof f==`function`&&f(e);let t=Ee.find(e=>e.value===De);N&&Ie[fe]&&ue&&Fe(Ie[fe]),Ne(t?.label||``),Ce(!1)},We=e=>{typeof p==`function`&&p(e),x&&Ce(!0)},Ge=e=>{W||(Ne(e.currentTarget.value),S&&e.currentTarget.value===``&&Oe(null),pe(-1),Ce(!0))},Ke=()=>{W||(Ce(!ue),De&&!ue&&pe(Re))};return Z.createElement(ab.Wrapper,UO(HO({},i),{__staticSelector:`Select`}),Z.createElement(dv,{opened:ze,transitionProps:m,shadow:a,withinPortal:R,portalProps:z,__staticSelector:`Select`,onDirectionChange:_e,switchDirectionOnFlip:B,zIndex:V,dropdownPosition:te,positionDependencies:[...U,je],classNames:_,styles:v,unstyled:g,variant:r.variant},Z.createElement(dv.Target,null,Z.createElement(`div`,{role:`combobox`,"aria-haspopup":`listbox`,"aria-owns":ze?`${r.id}-items`:null,"aria-controls":r.id,"aria-expanded":ze,onMouseLeave:()=>pe(-1),tabIndex:-1},Z.createElement(`input`,{type:`hidden`,name:ee,value:De||``,form:ie,disabled:T}),Z.createElement(ab,HO(UO(HO(HO({autoComplete:`off`,type:`search`},r),oe),{ref:Dd(t,me),onKeyDown:He,__staticSelector:`Select`,value:je,placeholder:re,onChange:Ge,"aria-autocomplete":`list`,"aria-controls":ze?`${r.id}-items`:null,"aria-activedescendant":fe>=0?`${r.id}-${fe}`:null,onMouseDown:Ke,onBlur:Ue,onFocus:We,readOnly:!x||W,disabled:T,"data-mantine-stop-propagation":ze,name:null,classNames:UO(HO({},_),{input:ce({[se.input]:!x},_?.input)})}),tO({theme:le,rightSection:O,rightSectionWidth:k,styles:v,size:r.size,shouldClear:S&&!!Ae,onClear:Pe,error:i.error,clearButtonProps:ae,disabled:T,readOnly:W}))))),Z.createElement(dv.Dropdown,{component:F||Bh,maxHeight:b,direction:ge,id:r.id,innerRef:xe,__staticSelector:`Select`,classNames:_,styles:v},Z.createElement(Qp,{data:Ie,hovered:fe,classNames:_,styles:v,isItemSelected:e=>e===De,uuid:r.id,__staticSelector:`Select`,onItemHover:pe,onItemSelect:Fe,itemsRefs:he,itemComponent:u,size:r.size,nothingFound:C,creatable:we&&!!Te,createLabel:Te,"aria-label":i.label,unstyled:g,variant:r.variant}))))});JO.displayName=`@mantine/core/Select`;function YO(e,t){if(t.length===0)return t;let n=`maxWidth`in t[0]?`maxWidth`:`minWidth`,r=[...t].sort((t,r)=>Er(J({size:r[n],sizes:e.breakpoints}))-Er(J({size:t[n],sizes:e.breakpoints})));return n===`minWidth`?r.reverse():r}var XO=Object.defineProperty,ZO=Object.getOwnPropertySymbols,QO=Object.prototype.hasOwnProperty,$O=Object.prototype.propertyIsEnumerable,ek=(e,t,n)=>t in e?XO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,tk=(e,t)=>{for(var n in t||={})QO.call(t,n)&&ek(e,n,t[n]);if(ZO)for(var n of ZO(t))$O.call(t,n)&&ek(e,n,t[n]);return e},nk=Ur((e,{spacing:t,breakpoints:n,cols:r,verticalSpacing:i})=>{let a=i!=null,o=YO(e,n).reduce((n,r)=>{let o=`maxWidth`in r?`max-width`:`min-width`,s=J({size:o===`max-width`?r.maxWidth:r.minWidth,sizes:e.breakpoints,units:`em`}),c=Er(s)-+(o===`max-width`);return n[`@media (${o}: ${sr(c)})`]={gridTemplateColumns:`repeat(${r.cols}, minmax(0, 1fr))`,gap:`${J({size:r.verticalSpacing??(a?i:t),sizes:e.spacing})} ${J({size:r.spacing??t,sizes:e.spacing})}`},n},{});return{root:tk({boxSizing:`border-box`,display:`grid`,gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`,gap:`${J({size:a?i:t,sizes:e.spacing})} ${J({size:t,sizes:e.spacing})}`},o)}}),rk=Object.defineProperty,ik=Object.getOwnPropertySymbols,ak=Object.prototype.hasOwnProperty,ok=Object.prototype.propertyIsEnumerable,sk=(e,t,n)=>t in e?rk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ck=(e,t)=>{for(var n in t||={})ak.call(t,n)&&sk(e,n,t[n]);if(ik)for(var n of ik(t))ok.call(t,n)&&sk(e,n,t[n]);return e},lk=(e,t)=>{var n={};for(var r in e)ak.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ik)for(var r of ik(e))t.indexOf(r)<0&&ok.call(e,r)&&(n[r]=e[r]);return n},uk={breakpoints:[],cols:1,spacing:`md`},dk=(0,Z.forwardRef)((e,t)=>{let n=X(`SimpleGrid`,uk,e),{className:r,breakpoints:i,cols:a,spacing:o,verticalSpacing:s,children:c,unstyled:l,variant:u}=n,d=lk(n,[`className`,`breakpoints`,`cols`,`spacing`,`verticalSpacing`,`children`,`unstyled`,`variant`]),{classes:f,cx:p}=nk({breakpoints:i,cols:a,spacing:o,verticalSpacing:s},{name:`SimpleGrid`,unstyled:l,variant:u});return Z.createElement(Br,ck({className:p(f.root,r),ref:t},d),c)});dk.displayName=`@mantine/core/SimpleGrid`;var fk=Object.defineProperty,pk=Object.defineProperties,mk=Object.getOwnPropertyDescriptors,hk=Object.getOwnPropertySymbols,gk=Object.prototype.hasOwnProperty,_k=Object.prototype.propertyIsEnumerable,vk=(e,t,n)=>t in e?fk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yk=(e,t)=>{for(var n in t||={})gk.call(t,n)&&vk(e,n,t[n]);if(hk)for(var n of hk(t))_k.call(t,n)&&vk(e,n,t[n]);return e},bk=(e,t)=>pk(e,mk(t)),xk=Ur((e,{captionSide:t,horizontalSpacing:n,verticalSpacing:r,fontSize:i,withBorder:a,withColumnBorders:o})=>{let s=`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[3]}`;return{root:bk(yk({},e.fn.fontStyles()),{width:`100%`,borderCollapse:`collapse`,captionSide:t,color:e.colorScheme===`dark`?e.colors.dark[0]:e.black,lineHeight:e.lineHeight,border:a?s:void 0,"& > caption":{marginTop:t===`top`?0:e.spacing.xs,marginBottom:t===`bottom`?0:e.spacing.xs,fontSize:e.fontSizes.sm,color:e.colorScheme===`dark`?e.colors.dark[2]:e.colors.gray[6]},"& > thead > tr > th, & > tfoot > tr > th, & > tbody > tr > th":{textAlign:`left`,fontWeight:`bold`,color:e.colorScheme===`dark`?e.colors.dark[0]:e.colors.gray[7],fontSize:J({size:i,sizes:e.fontSizes}),padding:`${J({size:r,sizes:e.spacing})} ${J({size:n,sizes:e.spacing})}`},"& > thead > tr > th":{borderBottom:s},"& > tfoot > tr > th, & > tbody > tr > th":{borderTop:s},"& > tbody > tr > td":{padding:`${J({size:r,sizes:e.spacing})} ${J({size:n,sizes:e.spacing})}`,borderTop:s,fontSize:J({size:i,sizes:e.fontSizes})},"& > tbody > tr:first-of-type > td, & > tbody > tr:first-of-type > th":{borderTop:`none`},"& > thead > tr > th, & > tbody > tr > td":{borderRight:o?s:`none`,"&:last-of-type":{borderRight:`none`,borderLeft:o?s:`none`}},"& > tbody > tr > th":{borderRight:o?s:`none`},"&[data-striped] > tbody > tr:nth-of-type(odd)":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.colors.gray[0]},"&[data-hover] > tbody > tr":e.fn.hover({backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[1]})})}}),Sk=Object.defineProperty,Ck=Object.defineProperties,wk=Object.getOwnPropertyDescriptors,Tk=Object.getOwnPropertySymbols,Ek=Object.prototype.hasOwnProperty,Dk=Object.prototype.propertyIsEnumerable,Ok=(e,t,n)=>t in e?Sk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kk=(e,t)=>{for(var n in t||={})Ek.call(t,n)&&Ok(e,n,t[n]);if(Tk)for(var n of Tk(t))Dk.call(t,n)&&Ok(e,n,t[n]);return e},Ak=(e,t)=>Ck(e,wk(t)),jk=(e,t)=>{var n={};for(var r in e)Ek.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Tk)for(var r of Tk(e))t.indexOf(r)<0&&Dk.call(e,r)&&(n[r]=e[r]);return n},Mk={striped:!1,highlightOnHover:!1,captionSide:`top`,horizontalSpacing:`xs`,fontSize:`sm`,verticalSpacing:7,withBorder:!1,withColumnBorders:!1},Nk=(0,Z.forwardRef)((e,t)=>{let n=X(`Table`,Mk,e),{className:r,children:i,striped:a,highlightOnHover:o,captionSide:s,horizontalSpacing:c,verticalSpacing:l,fontSize:u,unstyled:d,withBorder:f,withColumnBorders:p,variant:m}=n,h=jk(n,[`className`,`children`,`striped`,`highlightOnHover`,`captionSide`,`horizontalSpacing`,`verticalSpacing`,`fontSize`,`unstyled`,`withBorder`,`withColumnBorders`,`variant`]),{classes:g,cx:_}=xk({captionSide:s,verticalSpacing:l,horizontalSpacing:c,fontSize:u,withBorder:f,withColumnBorders:p},{unstyled:d,name:`Table`,variant:m});return Z.createElement(Br,Ak(kk({},h),{component:`table`,ref:t,className:_(g.root,r),"data-striped":a||void 0,"data-hover":o||void 0}),i)});Nk.displayName=`@mantine/core/Table`;var Pk=(0,Z.createContext)(null);function Fk(){return(0,Z.useContext)(Pk)}function Ik(e){let[t,n]=(0,Z.useState)(!1),r=e.moreInfo?e.moreInfo(e.item):null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`tr`,{children:[e.columns.map((t,n)=>t.disabled?null:(0,Q.jsx)(`td`,{style:t.style,children:t.value(e.item,e.rowContext?e.rowContext(e.item):void 0)},String(n))),e.moreInfo&&(0,Q.jsx)(`td`,{children:r===null?(0,Q.jsx)(`p`,{children:`No Data Related`}):(0,Q.jsx)(q,{onClick:()=>n(!t),className:`ml-auto`,children:`More Info`})})]}),(e.isShowAll||t)&&r!==null&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:12,children:(0,Q.jsx)(gb,{style:{width:`100%`},withBorder:!0,shadow:`lg`,children:r})})})]})}function Lk(e){let[t,n]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex flex-row justify-end w-full`,children:e.showButton===!0?(0,Q.jsx)(q,{type:`button`,onClick:()=>{n(e=>!e)},children:t?`Hide All`:`Show All`}):null}),(0,Q.jsxs)(Nk,{striped:e.striped,highlightOnHover:e.highlightOnHover,children:[(0,Q.jsx)(`thead`,{style:e.stickyHeader?{position:`sticky`,top:0,zIndex:20}:{},children:(0,Q.jsxs)(`tr`,{className:`px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl`,children:[e.columns.map((e,t)=>e.disabled?null:(0,Q.jsx)(`th`,{children:e.title},String(t))),e.moreInfo&&(0,Q.jsx)(`th`,{children:`More Info`})]})}),(0,Q.jsx)(`tbody`,{children:e.items.map((n,r)=>(0,Q.jsx)(Ik,{columns:e.columns,item:n,moreInfo:e.moreInfo,isShowAll:t,rowContext:e.rowContext},r))})]})]})}function Rk({data:e,onChange:t}){let n=Lr(fe,e),[r,i]=(0,Z.useState)(n.accountantApproval);return(0,Z.useEffect)(()=>{r==null&&n.accountantApproval!=null&&i(n.accountantApproval)},[r,n.accountantApproval]),(0,Q.jsx)(b0,{value:r,businessTripId:n.id,onChange:t})}var zk=`creditShareholdersBusinessTripTravelAndSubsistence`,Bk=()=>{let[{fetching:e},t]=H(x);return{fetching:e,creditShareholders:(0,Z.useCallback)(async e=>{let n=`Error crediting shareholders for trip ID ${e.businessTripId}`,r=`${zk}-${e.businessTripId}`;K.loading(`Crediting Shareholders`,{id:r});try{let i=await t(e),a=Ke(i,n,r);a&&K.success(`Shareholders Credited`,{id:r,description:`${a.creditShareholdersBusinessTripTravelAndSubsistence.length} Corresponding charges were successfully generated`})}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function Vk({businessTripId:e}){let[t,n]=(0,Z.useState)(!1),{creditShareholders:r}=Bk();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Vn,{children:[(0,Q.jsx)(zn,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`Business trip actions`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Yi,{className:`size-4`})})}),(0,Q.jsxs)(In,{align:`start`,className:`w-50`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(Gn,{variant:`section`,children:`Summarize Trip`}),(0,Q.jsxs)(Ln,{onSelect:()=>n(!0),children:[(0,Q.jsx)(ia,{className:`size-4`}),`Credit surplus T&S`]})]})]}),(0,Q.jsx)(j0,{open:t,setOpen:n,onConfirm:()=>{r({businessTripId:e})},title:`Credit shareholders with travel and subsistence surplus?`})]})}var Hk=({data:e,onChange:t})=>{let n=Lr(F,e),{name:r,dates:i,purpose:a,destination:o}=n;return(0,Q.jsxs)(uT,{children:[(0,Q.jsxs)(uT.Col,{span:12,className:`flex flex-row justify-between items-center`,children:[(0,Q.jsx)(_i,{fz:`xl`,children:r}),(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[(0,Q.jsx)(Rk,{data:n,onChange:t}),(0,Q.jsx)($k,{isLink:!0,content:`${window.location.origin}${yt.BUSINESS_TRIPS.DETAIL(n.id)}`}),(0,Q.jsx)(Vk,{businessTripId:n.id})]})]}),(0,Q.jsxs)(uT.Col,{xl:2,lg:3,md:6,children:[`From Date:`,(0,Q.jsx)(_i,{fz:`lg`,children:i?.start?Or(new Date(i.start),`dd/MM/yy`):`Missing`})]}),(0,Q.jsxs)(uT.Col,{xl:2,lg:3,md:6,children:[`To Date:`,(0,Q.jsx)(_i,{fz:`lg`,children:i?.end?Or(new Date(i.end),`dd/MM/yy`):`Missing`})]}),(0,Q.jsxs)(uT.Col,{xl:2,lg:3,md:6,children:[`Destination:`,(0,Q.jsx)(_i,{fz:`lg`,children:o?.name})]}),(0,Q.jsxs)(uT.Col,{xl:4,lg:6,md:12,orderMd:6,children:[`Description:`,(0,Q.jsx)(_i,{fz:`lg`,children:a})]}),(0,Q.jsxs)(uT.Col,{xl:2,lg:3,md:6,children:[`Total Days:`,(0,Q.jsx)(_i,{fz:`lg`,children:i?Uk(i.start,i.end):`Missing`})]})]})};function Uk(e,t){return oc(Il(new Date(t),22),Il(new Date(e),6))+1}function Wk(e){return e.split(`_`).map(Gk).join(` `)}function Gk(e){return e.slice(0,1).toUpperCase()+e.slice(1,e.length).toLowerCase()}var Kk=({data:e})=>{let{summary:t}=Lr(j,e);return t?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 mt-5`,children:[t.errors?.length&&(0,Q.jsxs)(gb,{shadow:`xs`,p:`md`,children:[(0,Q.jsx)(_i,{c:`red`,children:`Errors:`}),(0,Q.jsx)(bE,{size:`sm`,withPadding:!0,children:t.errors.map((e,t)=>(0,Q.jsx)(bE.Item,{children:(0,Q.jsx)(_i,{c:`red`,children:e})},t))})]}),(0,Q.jsxs)(Nk,{highlightOnHover:!0,withBorder:!0,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Expense Type`}),(0,Q.jsxs)(`th`,{children:[`Total `,ru(k.Usd)]}),(0,Q.jsxs)(`th`,{children:[`Total `,ru(k.Ils)]}),(0,Q.jsxs)(`th`,{children:[`Max Taxable `,ru(k.Usd)]}),(0,Q.jsxs)(`th`,{children:[`Taxable `,ru(k.Usd)]}),(0,Q.jsxs)(`th`,{children:[`Taxable `,ru(k.Ils)]}),(0,Q.jsx)(`th`,{children:`Excess Expenditure`})]})}),(0,Q.jsx)(`tbody`,{children:t.rows.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:Wk(e.type)}),(0,Q.jsx)(`td`,{children:e.totalForeignCurrency?.formatted}),(0,Q.jsx)(`td`,{children:e.totalLocalCurrency?.formatted}),(0,Q.jsx)(`td`,{children:e.maxTaxableForeignCurrency?.formatted}),(0,Q.jsx)(`td`,{children:e.taxableForeignCurrency?.formatted}),(0,Q.jsx)(`td`,{children:e.taxableLocalCurrency?.formatted}),(0,Q.jsx)(`td`,{children:e.excessExpenditure?.formatted})]},e.type))})]}),(0,Q.jsxs)(uT,{justify:`flex-end`,children:[(0,Q.jsxs)(uT.Col,{lg:2,md:4,children:[`Excess Expenditure Tax:`,(0,Q.jsxs)(_i,{fz:`lg`,children:[t.excessTax??`0`,`%`]})]}),(0,Q.jsx)(uT.Col,{lg:2,md:3,className:`flex flex-col justify-end`,children:(0,Q.jsx)(_i,{fz:`lg`,children:t.excessExpenditure?.formatted??`0.00`})})]})]}):(0,Q.jsx)(_i,{children:`Loading...`})},qk=({data:e})=>{let t=Lr(d,e);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Hk,{data:t,onChange:()=>{}}),(0,Q.jsx)(Kk,{data:t})]})};function Jk(e){return(0,Q.jsx)(SK,{content:`To Charge`,children:(0,Q.jsx)(vt,{to:yt.CHARGES.DETAIL(e.chargeId),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-block`,children:(0,Q.jsx)(q,{...e,className:s(`size-7.5`,e.className),variant:`ghost`,children:(0,Q.jsx)(Xi,{className:`size-5`})})})})}var Yk=`closeDocument`,Xk=()=>{let[{fetching:e},t]=H(at);return{fetching:e,closeDocument:(0,Z.useCallback)(async e=>{let n=`Error closing document ID [${e.documentId}]`,r=`${Yk}-${e.documentId}`;K.loading(`Closing Document...`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`closeDocument`);if(a)return K.success(`Success`,{id:r,description:`Document closed`}),a.closeDocument}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return!1},[t])}};function Zk({documentId:e,couldIssueCreditInvoice:t,...n}){let{closeDocument:r}=Xk(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useCallback)(()=>{r({documentId:e})},[r,e]);return t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{children:(0,Q.jsx)(q,{className:`size-7.5 text-red-600`,variant:`ghost`,...n,onClick:()=>a(!0),children:(0,Q.jsx)(Ui,{className:`size-5`})})}),(0,Q.jsx)(yr,{children:(0,Q.jsx)(`p`,{children:`Close Document`})})]}),(0,Q.jsx)(Xt,{open:i,onOpenChange:a,children:(0,Q.jsxs)(un,{className:`sm:max-w-[425px]`,children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Should Issue Credit Invoice?`})}),(0,Q.jsxs)(Zt,{children:[(0,Q.jsx)(q,{onClick:()=>{a(!1),c()},variant:`secondary`,children:`Just Close`}),(0,Q.jsx)(q,{onClick:()=>{a(!1),s(!0)},variant:`default`,children:`Issue Credit Invoice`})]})]})}),(0,Q.jsx)(h9,{documentId:e,documentType:Ve.CreditInvoice,open:o,setOpen:s})]}):(0,Q.jsx)(j0,{onConfirm:c,title:`Are you sure you want to close this document?`,children:(0,Q.jsx)(q,{className:`size-7.5 text-red-600`,variant:`ghost`,...n,children:(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{children:(0,Q.jsx)(Ui,{className:`size-5`})}),(0,Q.jsx)(yr,{children:(0,Q.jsx)(`p`,{children:`Close Document`})})]})})})}function Qk(e){return(0,Q.jsx)(q,{...e,variant:`ghost`,className:s(`size-7.5 text-green-500`,e.className),children:(0,Q.jsx)(on,{className:`size-5`})})}var $k=({content:e,isLink:t})=>(0,Q.jsx)(q,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:()=>Zl(e),children:t?(0,Q.jsx)(oa,{className:`size-5`}):(0,Q.jsx)(qi,{className:`size-5`})}),eA=`deleteCharge`,tA=()=>{let[{fetching:e},t]=H(C);return{fetching:e,deleteCharge:(0,Z.useCallback)(async e=>{let n=`Error deleting charge ID [${e.chargeId}]`,r=`${eA}-${e.chargeId}`;K.loading(`Deleting charge`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a){if(a.deleteCharge===!1)throw Error(`Unsuccessful deletion`);return K.success(`Success`,{id:r,description:`Charge was deleted`}),a.deleteCharge}}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return!1},[t])}},nA=`deleteDocument`,rA=()=>{let[{fetching:e},t]=H(S);return{fetching:e,deleteDocument:(0,Z.useCallback)(async e=>{let n=`Error deleting document ID [${e.documentId}]`,r=`${nA}-${e.documentId}`;K.loading(`Deleting Document`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a)return K.success(`Success`,{id:r,description:`Document was deleted`}),a.deleteDocument}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return!1},[t])}};function iA({documentId:e,onChange:t}){let{deleteDocument:n}=rA();function r(){n({documentId:e}).then(t)}return(0,Q.jsx)(j0,{onConfirm:r,title:`Are you sure you want to delete this document?`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5 text-red-500`,children:(0,Q.jsx)(Ea,{className:`size-5`})})})}function aA(e,t){let n=new Uint8Array([239,187,191]),r=new Blob([n,e],{type:`text/csv;charset=UTF-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${t}.csv`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}var oA=({createFileVariables:e,buttonProps:t,buttonContent:n,label:r})=>{let[i,a]=(0,Z.useState)(!1),o=(0,Z.useCallback)(async()=>{a(!0);try{let{fileContent:t,fileName:n}=await e();aA(t,n)}catch(e){console.error(`Failed to prepare CSV download`,e)}finally{a(!1)}},[e]),{className:c,disabled:l,...u}=t??{};return(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{children:(0,Q.jsxs)(q,{variant:`outline`,className:s(`relative p-2`,c),disabled:i||l,"aria-busy":i,...u,onClick:o,children:[(0,Q.jsx)(`span`,{className:i?`invisible`:`contents`,children:n||(0,Q.jsx)($i,{size:20})}),i&&(0,Q.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(Qt,{className:`h-5 w-5 animate-spin`})})]})}),(0,Q.jsx)(yr,{children:(0,Q.jsx)(`p`,{children:i?`Preparing download…`:r||`Download CSV`})})]})};function sA(e){return(0,Q.jsx)(SK,{disabled:!e.tooltip,content:e.tooltip,children:(0,Q.jsx)(q,{className:`size-7.5`,variant:`ghost`,...e,children:(0,Q.jsx)(wa,{className:`size-5`})})})}function cA(e){return(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,...e,children:(0,Q.jsx)(Dn,{className:`size-5`})})}function lA(){let{logout:e}=bt();return async()=>{sessionStorage.clear(),await e({logoutParams:{returnTo:`${window.location.origin}${yt.LOGIN}`}})}}function uA(){let e=lA();return(0,Q.jsx)(q,{variant:`ghost`,onClick:e,children:`Log out`})}var dA=Uint8Array,fA=Uint16Array,pA=Int32Array,mA=new dA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),hA=new dA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),gA=new dA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_A=function(e,t){for(var n=new fA(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new pA(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},vA=_A(mA,2),yA=vA.b,bA=vA.r;yA[28]=258,bA[258]=28;var xA=_A(hA,0);xA.b;for(var SA=xA.r,CA=new fA(32768),wA=0;wA<32768;++wA){var TA=(wA&43690)>>1|(wA&21845)<<1;TA=(TA&52428)>>2|(TA&13107)<<2,TA=(TA&61680)>>4|(TA&3855)<<4,CA[wA]=((TA&65280)>>8|(TA&255)<<8)>>1}for(var EA=(function(e,t,n){for(var r=e.length,i=0,a=new fA(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new fA(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new fA(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[CA[d]>>c]=l}else for(s=new fA(r),i=0;i<r;++i)e[i]&&(s[i]=CA[o[e[i]-1]++]>>15-e[i]);return s}),DA=new dA(288),wA=0;wA<144;++wA)DA[wA]=8;for(var wA=144;wA<256;++wA)DA[wA]=9;for(var wA=256;wA<280;++wA)DA[wA]=7;for(var wA=280;wA<288;++wA)DA[wA]=8;for(var OA=new dA(32),wA=0;wA<32;++wA)OA[wA]=5;var kA=EA(DA,9,0),AA=EA(OA,5,0),jA=function(e){return(e+7)/8|0},MA=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new dA(e.subarray(t,n))},NA=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},PA=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},FA=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:HA,l:0};if(i==1){var o=new dA(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new fA(f+1),m=IA(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new dA(p),l:m}},IA=function(e,t,n){return e.s==-1?Math.max(IA(e.l,t,n+1),IA(e.r,t,n+1)):t[e.s]=n},LA=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new fA(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},RA=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},zA=function(e,t,n){var r=n.length,i=jA(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},BA=function(e,t,n,r,i,a,o,s,c,l,u){NA(t,u++,n),++i[256];for(var d=FA(i,15),f=d.t,p=d.l,m=FA(a,15),h=m.t,g=m.l,_=LA(f),v=_.c,y=_.n,b=LA(h),x=b.c,S=b.n,C=new fA(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=FA(C,7),E=T.t,D=T.l,O=19;O>4&&!E[gA[O-1]];--O);var k=l+5<<3,A=RA(i,DA)+RA(a,OA)+o,j=RA(i,f)+RA(a,h)+o+14+3*O+RA(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&k<=A&&k<=j)return zA(t,u,e.subarray(c,c+l));var M,N,P,F;if(NA(t,u,1+(j<A)),u+=2,j<A){M=EA(f,p,0),N=f,P=EA(h,g,0),F=h;var I=EA(E,D,0);NA(t,u,y-257),NA(t,u+5,S-1),NA(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)NA(t,u+3*w,E[gA[w]]);u+=3*O;for(var L=[v,x],R=0;R<2;++R)for(var z=L[R],w=0;w<z.length;++w){var B=z[w]&31;NA(t,u,I[B]),u+=E[B],B>15&&(NA(t,u,z[w]>>5&127),u+=z[w]>>12)}}else M=kA,N=DA,P=AA,F=OA;for(var w=0;w<s;++w){var V=r[w];if(V>255){var B=V>>18&31;PA(t,u,M[B+257]),u+=N[B+257],B>7&&(NA(t,u,V>>23&31),u+=mA[B]);var ee=V&31;PA(t,u,P[ee]),u+=F[ee],ee>3&&(PA(t,u,V>>5&8191),u+=hA[ee])}else PA(t,u,M[V]),u+=N[V]}return PA(t,u,M[256]),u+N[256]},VA=new pA([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),HA=new dA(0),UA=function(e,t,n,r,i,a){var o=a.z||e.length,s=new dA(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=VA[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new fA(32768),g=a.h||new fA(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new pA(25e3),x=new fA(288),S=new fA(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var k=y(T),A=T&32767,j=g[k];if(h[A]=j,g[k]=A,D<=T){var M=o-T;if((C>7e3||E>24576)&&(M>423||!l)){u=BA(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)S[N]=0}var P=2,F=0,I=p,L=A-j&32767;if(M>2&&k==y(T-L))for(var R=Math.min(f,M)-1,z=Math.min(32767,T),B=Math.min(258,M);L<=z&&--I&&A!=j;){if(e[T+P]==e[T+P-L]){for(var V=0;V<B&&e[T+V]==e[T+V-L];++V);if(V>P){if(P=V,F=L,V>R)break;for(var ee=Math.min(L,V-2),te=0,N=0;N<ee;++N){var ne=T-L+N&32767,re=ne-h[ne]&32767;re>te&&(te=re,j=ne)}}}A=j,j=h[A],L+=A-j&32767}if(F){b[E++]=268435456|bA[P]<<18|SA[F];var H=bA[P]&31,ie=SA[F]&31;w+=mA[H]+hA[ie],++x[257+H],++S[ie],D=T+P,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=BA(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var U=T+65535;U>=o&&(c[u/8|0]=l,U=o),u=zA(c,u+1,e.subarray(T,U))}a.i=o}return MA(s,0,r+jA(u)+i)},WA=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},GA=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new dA(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return UA(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},KA=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},qA=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=WA();i.p(t.dictionary),KA(e,2,i.d())}};function JA(e,t){t||={};var n=WA();n.p(e);var r=GA(e,t,t.dictionary?6:2,4);return qA(r,t),KA(r,r.length-4,n.d()),r}var YA=typeof TextDecoder<`u`&&new TextDecoder;try{YA.decode(HA,{stream:!0})}catch{}function XA(e){if(Array.isArray(e))return e}function ZA(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function QA(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $A(e,t){if(e){if(typeof e==`string`)return QA(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?QA(e,t):void 0}}function ej(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tj(e,t){return XA(e)||ZA(e,t)||$A(e,t)||ej()}function nj(e,t=`utf8`){return new TextDecoder(t).decode(e)}var rj=new TextEncoder;function ij(e){return rj.encode(e)}var aj=8192,oj=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),sj={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},cj=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=aj,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=sj[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===oj&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new sj[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new sj[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return nj(this.readBytes(e))}decodeText(e=1,t=`utf8`){return nj(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(ij(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},lj=4,uj=0,dj=1,fj=2;function pj(e){let t=e.length;for(;--t>=0;)e[t]=0}var mj=29,hj=256,gj=286,_j=30,vj=19,yj=573,bj=15,xj=16,Sj=7,Cj=256,wj=16,Tj=17,Ej=18,Dj=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Oj=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),kj=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Aj=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jj=512,Mj=Array(576);pj(Mj);var Nj=Array(60);pj(Nj);var Pj=Array(jj);pj(Pj);var Fj=Array(256);pj(Fj);var Ij=Array(mj);pj(Ij);var Lj=Array(_j);pj(Lj);function Rj(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var zj,Bj,Vj;function Hj(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var Uj=e=>e<256?Pj[e]:Pj[256+(e>>>7)],Wj=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Gj=(e,t,n)=>{e.bi_valid>xj-n?(e.bi_buf|=t<<e.bi_valid&65535,Wj(e,e.bi_buf),e.bi_buf=t>>xj-e.bi_valid,e.bi_valid+=n-xj):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},Kj=(e,t,n)=>{Gj(e,n[t*2],n[t*2+1])},qj=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},Jj=e=>{e.bi_valid===16?(Wj(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},Yj=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=bj;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<yj;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},Xj=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=bj;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=qj(r[t]++,t))}},Zj=()=>{let e,t,n,r,i,a=Array(16);for(n=0,r=0;r<28;r++)for(Ij[r]=n,e=0;e<1<<Dj[r];e++)Fj[n++]=r;for(Fj[n-1]=r,i=0,r=0;r<16;r++)for(Lj[r]=i,e=0;e<1<<Oj[r];e++)Pj[i++]=r;for(i>>=7;r<_j;r++)for(Lj[r]=i<<7,e=0;e<1<<Oj[r]-7;e++)Pj[256+i++]=r;for(t=0;t<=bj;t++)a[t]=0;for(e=0;e<=143;)Mj[e*2+1]=8,e++,a[8]++;for(;e<=255;)Mj[e*2+1]=9,e++,a[9]++;for(;e<=279;)Mj[e*2+1]=7,e++,a[7]++;for(;e<=287;)Mj[e*2+1]=8,e++,a[8]++;for(Xj(Mj,287,a),e=0;e<_j;e++)Nj[e*2+1]=5,Nj[e*2]=qj(e,5);zj=new Rj(Mj,Dj,257,gj,bj),Bj=new Rj(Nj,Oj,0,_j,bj),Vj=new Rj([],kj,0,vj,Sj)},Qj=e=>{let t;for(t=0;t<gj;t++)e.dyn_ltree[t*2]=0;for(t=0;t<_j;t++)e.dyn_dtree[t*2]=0;for(t=0;t<vj;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Cj*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},$j=e=>{e.bi_valid>8?Wj(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},eM=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},tM=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&eM(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!eM(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},nM=(e,t,n)=>{let r,i,a=0,o,s;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+a++]&255,r+=(e.pending_buf[e.sym_buf+a++]&255)<<8,i=e.pending_buf[e.sym_buf+a++],r===0?Kj(e,i,t):(o=Fj[i],Kj(e,o+hj+1,t),s=Dj[o],s!==0&&(i-=Ij[o],Gj(e,i,s)),r--,o=Uj(r),Kj(e,o,n),s=Oj[o],s!==0&&(r-=Lj[o],Gj(e,r,s)));while(a<e.sym_next);Kj(e,Cj,t)},rM=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=yj,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)tM(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],tM(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,tM(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Yj(e,t),Xj(n,c,e.bl_count)},iM=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[34]++:e.bl_tree[36]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[32]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},aM=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do Kj(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(Kj(e,Tj,e.bl_tree),Gj(e,s-3,3)):(Kj(e,Ej,e.bl_tree),Gj(e,s-11,7)):(a!==i&&(Kj(e,a,e.bl_tree),s--),Kj(e,wj,e.bl_tree),Gj(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},oM=e=>{let t;for(iM(e,e.dyn_ltree,e.l_desc.max_code),iM(e,e.dyn_dtree,e.d_desc.max_code),rM(e,e.bl_desc),t=18;t>=3&&e.bl_tree[Aj[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},sM=(e,t,n,r)=>{let i;for(Gj(e,t-257,5),Gj(e,n-1,5),Gj(e,r-4,4),i=0;i<r;i++)Gj(e,e.bl_tree[Aj[i]*2+1],3);aM(e,e.dyn_ltree,t-1),aM(e,e.dyn_dtree,n-1)},cM=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return uj;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return dj;for(n=32;n<hj;n++)if(e.dyn_ltree[n*2]!==0)return dj;return uj},lM=!1,uM=e=>{lM||=(Zj(),!0),e.l_desc=new Hj(e.dyn_ltree,zj),e.d_desc=new Hj(e.dyn_dtree,Bj),e.bl_desc=new Hj(e.bl_tree,Vj),e.bi_buf=0,e.bi_valid=0,Qj(e)},dM=(e,t,n,r)=>{Gj(e,0+ +!!r,3),$j(e),Wj(e,n),Wj(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},fM={_tr_init:uM,_tr_stored_block:dM,_tr_flush_block:(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===fj&&(e.strm.data_type=cM(e)),rM(e,e.l_desc),rM(e,e.d_desc),o=oM(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?dM(e,t,n,r):e.strategy===lj||a===i?(Gj(e,2+ +!!r,3),nM(e,Mj,Nj)):(Gj(e,4+ +!!r,3),sM(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),nM(e,e.dyn_ltree,e.dyn_dtree)),Qj(e),r&&$j(e)},_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(Fj[n]+hj+1)*2]++,e.dyn_dtree[Uj(t)*2]++),e.sym_next===e.sym_end),_tr_align:e=>{Gj(e,2,3),Kj(e,Cj,Mj),Jj(e)}},pM=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},mM=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),hM=(e,t,n,r)=>{let i=mM,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},gM={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`},_M={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:vM,_tr_stored_block:yM,_tr_flush_block:bM,_tr_tally:xM,_tr_align:SM}=fM,{Z_NO_FLUSH:CM,Z_PARTIAL_FLUSH:wM,Z_FULL_FLUSH:TM,Z_FINISH:EM,Z_BLOCK:DM,Z_OK:OM,Z_STREAM_END:kM,Z_STREAM_ERROR:AM,Z_DATA_ERROR:jM,Z_BUF_ERROR:MM,Z_DEFAULT_COMPRESSION:NM,Z_FILTERED:PM,Z_HUFFMAN_ONLY:FM,Z_RLE:IM,Z_FIXED:LM,Z_DEFAULT_STRATEGY:RM,Z_UNKNOWN:zM,Z_DEFLATED:BM}=_M,VM=9,HM=15,UM=8,WM=573,GM=3,KM=258,qM=262,JM=32,YM=42,XM=57,ZM=69,QM=73,$M=91,eN=103,tN=113,nN=666,rN=1,iN=2,aN=3,oN=4,sN=3,cN=(e,t)=>(e.msg=gM[t],t),lN=e=>e*2-(e>4?9:0),uN=e=>{let t=e.length;for(;--t>=0;)e[t]=0},dN=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)},fN=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,pN=(e,t)=>{let n;if(e.legacy_hash)n=e.ins_h=fN(e,e.ins_h,e.window[t+GM-1]);else{let r=e.window,i=r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24;n=e.ins_h=Math.imul(i,66521)+66521>>>16&e.hash_mask}let r=e.prev[t&e.w_mask]=e.head[n];return e.head[n]=t,r},mN=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},hN=(e,t)=>{bM(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,mN(e.strm)},gN=(e,t)=>{e.pending_buf[e.pending++]=t},_N=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},vN=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=pM(e.adler,t,i,n):e.state.wrap===2&&(e.adler=hM(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},yN=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-qM?e.strstart-(e.w_size-qM):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+KM,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,l[i+o]===m&&l[i+o-1]===p&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=KM-(f-r),r=f-KM,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},bN=e=>{let t=e.w_size,n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-qM)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),dN(e),r+=t),e.strm.avail_in===0)break;if(n=vN(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,!e.legacy_hash){if(e.lookahead+e.insert>GM)for(i=e.strstart-e.insert;e.insert&&(pN(e,i),i++,e.insert--,!(e.lookahead+e.insert<=GM)););}else if(e.lookahead+e.insert>=GM)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=fN(e,e.ins_h,e.window[i+1]);e.insert&&(pN(e,i),i++,e.insert--,!(e.lookahead+e.insert<GM)););}while(e.lookahead<qM&&e.strm.avail_in!==0)},xN=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,a,o=0,s=e.strm.avail_in;do{if(r=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&t!==EM||t===CM||r!==i+e.strm.avail_in)))break;o=+(t===EM&&r===i+e.strm.avail_in),yM(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,mN(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(vN(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(o===0);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?oN:t!==CM&&t!==EM&&e.strm.avail_in===0&&e.strstart===e.block_start?iN:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(vN(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,n=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=n||(i||t===EM)&&t!==CM&&e.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=+(t===EM&&e.strm.avail_in===0&&r===i),yM(e,e.block_start,r,o),e.block_start+=r,mN(e.strm)),o?aN:rN)},SN=(e,t)=>{let n,r;for(;;){if(e.lookahead<qM){if(bN(e),e.lookahead<qM&&t===CM)return rN;if(e.lookahead===0)break}if(n=0,e.lookahead>=GM&&(n=pN(e,e.strstart)),n!==0&&e.strstart-n<=e.w_size-qM&&(e.match_length=yN(e,n)),e.match_length>=GM){if(r=xM(e,e.strstart-e.match_start,e.match_length-GM),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=GM){e.match_length--;do e.strstart++,n=pN(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=fN(e,e.ins_h,e.window[e.strstart+1]))}else r=xM(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(hN(e,!1),e.strm.avail_out===0))return rN}return e.insert=e.strstart<2?e.strstart:2,t===EM?(hN(e,!0),e.strm.avail_out===0?aN:oN):e.sym_next&&(hN(e,!1),e.strm.avail_out===0)?rN:iN},CN=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<qM){if(bN(e),e.lookahead<qM&&t===CM)return rN;if(e.lookahead===0)break}if(n=0,e.lookahead>=GM&&(n=pN(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-qM&&(e.match_length=yN(e,n),e.match_length<=5&&(e.strategy===PM||e.match_length===GM&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=GM&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-GM,r=xM(e,e.strstart-1-e.prev_match,e.prev_length-GM),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(n=pN(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(hN(e,!1),e.strm.avail_out===0))return rN}else if(e.match_available){if(r=xM(e,0,e.window[e.strstart-1]),r&&hN(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return rN}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=xM(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<2?e.strstart:2,t===EM?(hN(e,!0),e.strm.avail_out===0?aN:oN):e.sym_next&&(hN(e,!1),e.strm.avail_out===0)?rN:iN},wN=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=KM){if(bN(e),e.lookahead<=KM&&t===CM)return rN;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=GM&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+KM;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=KM-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=GM?(n=xM(e,1,e.match_length-GM),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=xM(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(hN(e,!1),e.strm.avail_out===0))return rN}return e.insert=0,t===EM?(hN(e,!0),e.strm.avail_out===0?aN:oN):e.sym_next&&(hN(e,!1),e.strm.avail_out===0)?rN:iN},TN=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(bN(e),e.lookahead===0)){if(t===CM)return rN;break}if(e.match_length=0,n=xM(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(hN(e,!1),e.strm.avail_out===0))return rN}return e.insert=0,t===EM?(hN(e,!0),e.strm.avail_out===0?aN:oN):e.sym_next&&(hN(e,!1),e.strm.avail_out===0)?rN:iN};function EN(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var DN=[new EN(0,0,0,0,xN),new EN(4,4,8,4,SN),new EN(4,5,16,8,SN),new EN(4,6,32,32,SN),new EN(4,4,16,16,CN),new EN(8,16,32,32,CN),new EN(8,16,128,128,CN),new EN(8,32,128,256,CN),new EN(32,128,258,1024,CN),new EN(32,258,258,4096,CN)],ON=e=>{e.window_size=2*e.w_size,uN(e.head),e.max_lazy_match=DN[e.level].max_lazy,e.good_match=DN[e.level].good_length,e.nice_match=DN[e.level].nice_length,e.max_chain_length=DN[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0};function kN(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=BM,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(WM*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),uN(this.dyn_ltree),uN(this.dyn_dtree),uN(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),uN(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),uN(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var AN=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.status!==YM&&t.status!==XM&&t.status!==ZM&&t.status!==QM&&t.status!==$M&&t.status!==eN&&t.status!==tN&&t.status!==nN)},jN=e=>{if(AN(e))return cN(e,AM);e.total_in=e.total_out=0,e.data_type=zM;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?XM:t.wrap?YM:tN,e.adler=t.wrap===2?0:1,t.last_flush=-2,vM(t),OM},MN=e=>{let t=jN(e);return t===OM&&ON(e.state),t},NN=(e,t)=>AN(e)||e.state.wrap!==2?AM:(e.state.gzhead=t,OM),PN=(e,t,n,r,i,a,o)=>{if(!e)return AM;let s=1;if(t===NM&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>VM||n!==BM||r<8||r>15||t<0||t>9||a<0||a>LM||r===8&&s!==1)return cN(e,AM);r===8&&(r=9);let c=new kN;return e.state=c,c.strm=e,c.status=YM,c.wrap=s,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.legacy_hash=+!!o,c.hash_bits=i+7,!c.legacy_hash&&c.hash_bits<15&&(c.hash_bits=15),c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+GM-1)/GM),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=t,c.strategy=a,c.method=n,MN(e)},FN={deflateInit:(e,t)=>PN(e,t,BM,HM,UM,RM),deflateInit2:PN,deflateReset:MN,deflateResetKeep:jN,deflateSetHeader:NN,deflate:(e,t)=>{if(AN(e)||t>DM||t<0)return e?cN(e,AM):AM;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===nN&&t!==EM)return cN(e,e.avail_out===0?MM:AM);let r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(mN(e),e.avail_out===0)return n.last_flush=-1,OM}else if(e.avail_in===0&&lN(t)<=lN(r)&&t!==EM)return cN(e,MM);if(n.status===nN&&e.avail_in!==0)return cN(e,MM);if(n.status===YM&&n.wrap===0&&(n.status=tN),n.status===YM){let t=BM+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=FM||n.level<2?0:n.level<6?1:n.level===6?2:3,t|=r<<6,n.strstart!==0&&(t|=JM),t+=31-t%31,_N(n,t),n.strstart!==0&&(_N(n,e.adler>>>16),_N(n,e.adler&65535)),e.adler=1,n.status=tN,mN(e),n.pending!==0)return n.last_flush=-1,OM}if(n.status===XM){if(e.adler=0,gN(n,31),gN(n,139),gN(n,8),n.gzhead)gN(n,+!!n.gzhead.text+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),gN(n,n.gzhead.time&255),gN(n,n.gzhead.time>>8&255),gN(n,n.gzhead.time>>16&255),gN(n,n.gzhead.time>>24&255),gN(n,n.level===9?2:n.strategy>=FM||n.level<2?4:0),gN(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(gN(n,n.gzhead.extra.length&255),gN(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=hM(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=ZM;else if(gN(n,0),gN(n,0),gN(n,0),gN(n,0),gN(n,0),gN(n,n.level===9?2:n.strategy>=FM||n.level<2?4:0),gN(n,sN),n.status=tN,mN(e),n.pending!==0)return n.last_flush=-1,OM}if(n.status===ZM){if(n.gzhead.extra){let t=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=hM(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,mN(e),n.pending!==0)return n.last_flush=-1,OM;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=hM(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=QM}if(n.status===QM){if(n.gzhead.name){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=hM(e.adler,n.pending_buf,n.pending-t,t)),mN(e),n.pending!==0)return n.last_flush=-1,OM;t=0}r=n.gzindex<n.gzhead.name.length?n.gzhead.name.charCodeAt(n.gzindex++)&255:0,gN(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=hM(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=$M}if(n.status===$M){if(n.gzhead.comment){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=hM(e.adler,n.pending_buf,n.pending-t,t)),mN(e),n.pending!==0)return n.last_flush=-1,OM;t=0}r=n.gzindex<n.gzhead.comment.length?n.gzhead.comment.charCodeAt(n.gzindex++)&255:0,gN(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=hM(e.adler,n.pending_buf,n.pending-t,t))}n.status=eN}if(n.status===eN){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(mN(e),n.pending!==0))return n.last_flush=-1,OM;gN(n,e.adler&255),gN(n,e.adler>>8&255),e.adler=0}if(n.status=tN,mN(e),n.pending!==0)return n.last_flush=-1,OM}if(e.avail_in!==0||n.lookahead!==0||t!==CM&&n.status!==nN){let r=n.level===0?xN(n,t):n.strategy===FM?TN(n,t):n.strategy===IM?wN(n,t):DN[n.level].func(n,t);if((r===aN||r===oN)&&(n.status=nN),r===rN||r===aN)return e.avail_out===0&&(n.last_flush=-1),OM;if(r===iN&&(t===wM?SM(n):t!==DM&&(yM(n,0,0,!1),t===TM&&(uN(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),mN(e),e.avail_out===0))return n.last_flush=-1,OM}return t===EM?n.wrap<=0?kM:(n.wrap===2?(gN(n,e.adler&255),gN(n,e.adler>>8&255),gN(n,e.adler>>16&255),gN(n,e.adler>>24&255),gN(n,e.total_in&255),gN(n,e.total_in>>8&255),gN(n,e.total_in>>16&255),gN(n,e.total_in>>24&255)):(_N(n,e.adler>>>16),_N(n,e.adler&65535)),mN(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending===0?kM:OM):OM},deflateEnd:e=>{if(AN(e))return AM;let t=e.state.status;return e.state=null,t===tN?cN(e,jM):OM},deflateSetDictionary:(e,t)=>{let n=t.length;if(AN(e))return AM;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==YM||r.lookahead)return AM;if(i===1&&(e.adler=pM(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(uN(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,bN(r);r.lookahead>=GM;){let e=r.strstart,t=r.lookahead-2;do pN(r,e),e++;while(--t);r.strstart=e,r.lookahead=2,bN(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,OM},deflateInfo:`pako deflate (from Nodeca project)`},IN=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),LN={assign:function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!=`object`)throw TypeError(n+`must be non-object`);for(let t in n)IN(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n}},RN=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{RN=!1}var zN=new Uint8Array(256);for(let e=0;e<256;e++)zN[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;zN[254]=zN[255]=1;var BN=e=>{if(typeof TextEncoder==`function`&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t},VN=(e,t)=>{if(t<65534&&e.subarray&&RN)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n=``;for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n},HN={string2buf:BN,buf2string:(e,t)=>{let n=t||e.length;if(typeof TextDecoder==`function`&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i,a=Array(n*2);for(i=0,r=0;r<n;){let t=e[r++];if(t<128){a[i++]=t;continue}let o=zN[t];if(o>4){a[i++]=65533,r+=o-1;continue}for(t&=o===2?31:o===3?15:7;o>1&&r<n;)t=t<<6|e[r++]&63,o--;if(o>1){a[i++]=65533;continue}t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|t&1023)}return VN(a,i)},utf8border:(e,t)=>{t||=e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)==128;)n--;return n<0||n===0?t:n+zN[e[n]]>t?n:t}};function UN(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}var WN=UN,GN=Object.prototype.toString,{Z_NO_FLUSH:KN,Z_SYNC_FLUSH:qN,Z_FULL_FLUSH:JN,Z_FINISH:YN,Z_OK:XN,Z_STREAM_END:ZN,Z_DEFAULT_COMPRESSION:QN,Z_DEFAULT_STRATEGY:$N,Z_DEFLATED:eP}=_M,tP={level:QN,method:eP,chunkSize:16384,windowBits:15,memLevel:8,strategy:$N,legacyHash:!0};function nP(e){this.options=LN.assign({},tP,e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new WN,this.strm.avail_out=0;let n=FN.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(n!==XN)throw Error(gM[n]);if(t.header&&FN.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=typeof t.dictionary==`string`?HN.string2buf(t.dictionary):GN.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary,n=FN.deflateSetDictionary(this.strm,e),n!==XN)throw Error(gM[n]);this._dict_set=!0}}nP.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=t===~~t?t:t===!0?YN:KN,n.input=typeof e==`string`?HN.string2buf(e):GN.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===qN||a===JN)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=FN.deflate(n,a),i===ZN)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=FN.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===XN;if(n.avail_out===0){this.onData(n.output);continue}if(a>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0},nP.prototype.onData=function(e){this.chunks.push(e)},nP.prototype.onEnd=function(e){e===XN&&(this.result=LN.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function rP(e,t){let n=new nP(t);if(n.push(e,!0),n.err)throw n.msg||gM[n.err];return n.result}function iP(e,t){return t||={},t.raw=!0,rP(e,t)}function aP(e,t){return t||={},t.gzip=!0,rP(e,t)}var oP={Deflate:nP,deflate:rP,deflateRaw:iP,gzip:aP,constants:_M},sP=16209,cP=16191,lP=function(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,l=E.whave,u=E.wnext,d=E.window,f=E.hold,p=E.bits,m=E.lencode,h=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;top:do{p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=m[f&g];dolen:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y===0)T[i++]=v&65535;else if(y&16){b=v&65535,y&=15,y&&(p<y&&(f+=w[n++]<<p,p+=8),b+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=h[f&_];dodist:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y&16){if(x=v&65535,y&=15,p<y&&(f+=w[n++]<<p,p+=8,p<y&&(f+=w[n++]<<p,p+=8)),x+=f&(1<<y)-1,x>s){e.msg=`invalid distance too far back`,E.mode=sP;break top}if(f>>>=y,p-=y,y=i-a,x>y){if(y=x-y,y>l&&E.sane){e.msg=`invalid distance too far back`,E.mode=sP;break top}if(S=0,C=d,u===0){if(S+=c-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}else if(u<y){if(S+=c+u-y,y-=u,y<b){b-=y;do T[i++]=d[S++];while(--y);if(S=0,u<b){y=u,b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}}else if(S+=u-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}for(;b>2;)T[i++]=C[S++],T[i++]=C[S++],T[i++]=C[S++],b-=3;b&&(T[i++]=C[S++],b>1&&(T[i++]=C[S++]))}else{S=i-x;do T[i++]=T[S++],T[i++]=T[S++],T[i++]=T[S++],b-=3;while(b>2);b&&(T[i++]=T[S++],b>1&&(T[i++]=T[S++]))}}else if(y&64){e.msg=`invalid distance code`,E.mode=sP;break top}else{v=h[(v&65535)+(f&(1<<y)-1)];continue dodist}break}}else if(!(y&64)){v=m[(v&65535)+(f&(1<<y)-1)];continue dolen}else if(y&32){E.mode=cP;break top}else{e.msg=`invalid literal/length code`,E.mode=sP;break top}break}}while(n<r&&i<o);b=p>>3,n-=b,p-=b<<3,f&=(1<<p)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?5+(r-n):5-(n-r),e.avail_out=i<o?257+(o-i):257-(i-o),E.hold=f,E.bits=p},uP=15,dP=852,fP=592,pP=0,mP=1,hP=2,gP=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),_P=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),vP=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),yP=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),bP=(e,t,n,r,i,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y,b,x,S,C,w=null,T,E=new Uint16Array(16),D=new Uint16Array(16),O=null,k,A,j;for(l=0;l<=uP;l++)E[l]=0;for(u=0;u<r;u++)E[t[n+u]]++;for(p=c,f=uP;f>=1&&E[f]===0;f--);if(p>f&&(p=f),f===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<f&&E[d]===0;d++);for(p<d&&(p=d),g=1,l=1;l<=uP;l++)if(g<<=1,g-=E[l],g<0)return-1;if(g>0&&(e===pP||f!==1))return-1;for(D[1]=0,l=1;l<uP;l++)D[l+1]=D[l]+E[l];for(u=0;u<r;u++)t[n+u]!==0&&(o[D[t[n+u]]++]=u);if(e===pP?(w=O=o,T=20):e===mP?(w=gP,O=_P,T=257):(w=vP,O=yP,T=0),v=0,u=0,l=d,C=a,m=p,h=0,x=-1,_=1<<p,S=_-1,e===mP&&_>dP||e===hP&&_>fP)return 1;for(;;){k=l-h,o[u]+1<T?(A=0,j=o[u]):o[u]>=T?(A=O[o[u]-T],j=w[o[u]-T]):(A=96,j=0),y=1<<l-h,b=1<<m,d=b;do b-=y,i[C+(v>>h)+b]=k<<24|A<<16|j|0;while(b!==0);for(y=1<<l-1;v&y;)y>>=1;if(y===0?v=0:(v&=y-1,v+=y),u++,--E[l]===0){if(l===f)break;l=t[n+o[u]]}if(l>p&&(v&S)!==x){for(h===0&&(h=p),C+=d,m=l-h,g=1<<m;m+h<f&&(g-=E[m+h],!(g<=0));)m++,g<<=1;if(_+=1<<m,e===mP&&_>dP||e===hP&&_>fP)return 1;x=v&S,i[x]=p<<24|m<<16|C-a|0}}return v!==0&&(i[C+v]=l-h<<24|4194304),s.bits=p,0},xP=0,SP=1,CP=2,{Z_FINISH:wP,Z_BLOCK:TP,Z_TREES:EP,Z_OK:DP,Z_STREAM_END:OP,Z_NEED_DICT:kP,Z_STREAM_ERROR:AP,Z_DATA_ERROR:jP,Z_MEM_ERROR:MP,Z_BUF_ERROR:NP,Z_DEFLATED:PP}=_M,FP=16180,IP=16181,LP=16182,RP=16183,zP=16184,BP=16185,VP=16186,HP=16187,UP=16188,WP=16189,GP=16190,KP=16191,qP=16192,JP=16193,YP=16194,XP=16195,ZP=16196,QP=16197,$P=16198,eF=16199,tF=16200,nF=16201,rF=16202,iF=16203,aF=16204,oF=16205,sF=16206,cF=16207,lF=16208,uF=16209,dF=16210,fF=16211,pF=852,mF=592,hF=15,gF=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function _F(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var vF=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.mode<FP||t.mode>fF)},yF=e=>{if(vF(e))return AP;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=t.wrap&1),t.mode=FP,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(pF),t.distcode=t.distdyn=new Int32Array(mF),t.sane=1,t.back=-1,DP},bF=e=>{if(vF(e))return AP;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,yF(e)},xF=(e,t)=>{let n;if(vF(e))return AP;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?AP:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,bF(e))},SF=(e,t)=>{if(!e)return AP;let n=new _F;e.state=n,n.strm=e,n.window=null,n.mode=FP;let r=xF(e,t);return r!==DP&&(e.state=null),r},CF=e=>SF(e,hF),wF=!0,TF,EF,DF=e=>{if(wF){TF=new Int32Array(512),EF=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(bP(SP,e.lens,0,288,TF,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bP(CP,e.lens,0,32,EF,0,e.work,{bits:5}),wF=!1}e.lencode=TF,e.lenbits=9,e.distcode=EF,e.distbits=5},OF=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.window=new Uint8Array(1<<a.wbits)),a.wsize===0&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},kF={inflateReset:bF,inflateReset2:xF,inflateResetKeep:yF,inflateInit:CF,inflateInit2:SF,inflate:(e,t)=>{let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=0,_,v,y,b,x,S,C,w,T=new Uint8Array(4),E,D,O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(vF(e)||!e.output||!e.input&&e.avail_in!==0)return AP;n=e.state,n.mode===KP&&(n.mode=qP),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,d=s,f=c,w=DP;inf_leave:for(;;)switch(n.mode){case FP:if(n.wrap===0){n.mode=qP;break}for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&2&&l===35615){n.wbits===0&&(n.wbits=15),n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=hM(n.check,T,2,0),l=0,u=0,n.mode=IP;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg=`incorrect header check`,n.mode=uF;break}if((l&15)!==PP){e.msg=`unknown compression method`,n.mode=uF;break}if(l>>>=4,u-=4,C=(l&15)+8,n.wbits===0&&(n.wbits=C),C>15||C>n.wbits){e.msg=`invalid window size`,n.mode=uF;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=l&512?WP:KP,l=0,u=0;break;case IP:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==PP){e.msg=`unknown compression method`,n.mode=uF;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=uF;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=hM(n.check,T,2,0)),l=0,u=0,n.mode=LP;case LP:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=hM(n.check,T,4,0)),l=0,u=0,n.mode=RP;case RP:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=hM(n.check,T,2,0)),l=0,u=0,n.mode=zP;case zP:if(n.flags&1024){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=hM(n.check,T,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=BP;case BP:if(n.flags&1024&&(p=n.length,p>s&&(p=s),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+p),C)),n.flags&512&&n.wrap&4&&(n.check=hM(n.check,r,p,a)),s-=p,a+=p,n.length-=p),n.length))break inf_leave;n.length=0,n.mode=VP;case VP:if(n.flags&2048){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=hM(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=HP;case HP:if(n.flags&4096){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=hM(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.comment=null);n.mode=UP;case UP:if(n.flags&512){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=uF;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=KP;break;case WP:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}e.adler=n.check=gF(l),l=0,u=0,n.mode=GP;case GP:if(n.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,kP;e.adler=n.check=1,n.mode=KP;case KP:if(t===TP||t===EP)break inf_leave;case qP:if(n.last){l>>>=u&7,u-=u&7,n.mode=sF;break}for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}switch(n.last=l&1,l>>>=1,--u,l&3){case 0:n.mode=JP;break;case 1:if(DF(n),n.mode=eF,t===EP){l>>>=2,u-=2;break inf_leave}break;case 2:n.mode=ZP;break;case 3:e.msg=`invalid block type`,n.mode=uF}l>>>=2,u-=2;break;case JP:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if((l&65535)!=(l>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=uF;break}if(n.length=l&65535,l=0,u=0,n.mode=YP,t===EP)break inf_leave;case YP:n.mode=XP;case XP:if(p=n.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break inf_leave;i.set(r.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,n.length-=p;break}n.mode=KP;break;case ZP:for(;u<14;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=uF;break}n.have=0,n.mode=QP;case QP:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.lens[O[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[O[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},w=bP(xP,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid code lengths set`,n.mode=uF;break}n.have=0,n.mode=$P;case $P:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(y<16)l>>>=_,u-=_,n.lens[n.have++]=y;else{if(y===16){for(D=_+2;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l>>>=_,u-=_,n.have===0){e.msg=`invalid bit length repeat`,n.mode=uF;break}C=n.lens[n.have-1],p=3+(l&3),l>>>=2,u-=2}else if(y===17){for(D=_+3;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=3+(l&7),l>>>=3,u-=3}else{for(D=_+7;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=11+(l&127),l>>>=7,u-=7}if(n.have+p>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=uF;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===uF)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=uF;break}if(n.lenbits=9,E={bits:n.lenbits},w=bP(SP,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid literal/lengths set`,n.mode=uF;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},w=bP(CP,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,w){e.msg=`invalid distances set`,n.mode=uF;break}if(n.mode=eF,t===EP)break inf_leave;case eF:n.mode=tF;case tF:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,lP(e,f),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===KP&&(n.back=-1);break}for(n.back=0;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(v&&!(v&240)){for(b=_,x=v,S=y;g=n.lencode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,n.length=y,v===0){n.mode=oF;break}if(v&32){n.back=-1,n.mode=KP;break}if(v&64){e.msg=`invalid literal/length code`,n.mode=uF;break}n.extra=v&15,n.mode=nF;case nF:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=rF;case rF:for(;g=n.distcode[l&(1<<n.distbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(!(v&240)){for(b=_,x=v,S=y;g=n.distcode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,v&64){e.msg=`invalid distance code`,n.mode=uF;break}n.offset=y,n.extra=v&15,n.mode=iF;case iF:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=uF;break}n.mode=aF;case aF:if(c===0)break inf_leave;if(p=f-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=uF;break}p>n.wnext?(p-=n.wnext,m=n.wsize-p):m=n.wnext-p,p>n.length&&(p=n.length),h=n.window}else h=i,m=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do i[o++]=h[m++];while(--p);n.length===0&&(n.mode=tF);break;case oF:if(c===0)break inf_leave;i[o++]=n.length,c--,n.mode=tF;break;case sF:if(n.wrap){for(;u<32;){if(s===0)break inf_leave;s--,l|=r[a++]<<u,u+=8}if(f-=c,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?hM(n.check,i,f,o-f):pM(n.check,i,f,o-f)),f=c,n.wrap&4&&(n.flags?l:gF(l))!==n.check){e.msg=`incorrect data check`,n.mode=uF;break}l=0,u=0}n.mode=cF;case cF:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=uF;break}l=0,u=0}n.mode=lF;case lF:w=OP;break inf_leave;case uF:w=jP;break inf_leave;case dF:return MP;case fF:default:return AP}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||f!==e.avail_out&&n.mode<uF&&(n.mode<sF||t!==wP))&&OF(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?hM(n.check,i,f,e.next_out-f):pM(n.check,i,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===KP?128:0)+(n.mode===eF||n.mode===YP?256:0),(d===0&&f===0||t===wP)&&w===DP&&(w=NP),w},inflateEnd:e=>{if(vF(e))return AP;let t=e.state;return t.window&&=null,e.state=null,DP},inflateGetHeader:(e,t)=>{if(vF(e))return AP;let n=e.state;return n.wrap&2?(n.head=t,t.done=!1,DP):AP},inflateSetDictionary:(e,t)=>{let n=t.length,r,i,a;return vF(e)||(r=e.state,r.wrap!==0&&r.mode!==GP)?AP:r.mode===GP&&(i=1,i=pM(i,t,n,0),i!==r.check)?jP:(a=OF(e,t,n,n),a?(r.mode=dF,MP):(r.havedict=1,DP))},inflateInfo:`pako inflate (from Nodeca project)`};function AF(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}var jF=AF,MF=Object.prototype.toString,{Z_NO_FLUSH:NF,Z_FINISH:PF,Z_OK:FF,Z_STREAM_END:IF,Z_NEED_DICT:LF,Z_STREAM_ERROR:RF,Z_DATA_ERROR:zF,Z_MEM_ERROR:BF,Z_BUF_ERROR:VF}=_M,HF={chunkSize:65536,windowBits:15,to:``};function UF(e){this.options=LN.assign({},HF,e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new WN,this.strm.avail_out=0;let n=kF.inflateInit2(this.strm,t.windowBits);if(n!==FF||(this.header=new jF,kF.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary==`string`?t.dictionary=HN.string2buf(t.dictionary):MF.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=kF.inflateSetDictionary(this.strm,t.dictionary),n!==FF))))throw Error(gM[n])}UF.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,a,o,s;if(this.ended)return!1;for(o=t===~~t?t:t===!0?PF:NF,n.input=MF.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),a=kF.inflate(n,o),a===LF&&i&&(a=kF.inflateSetDictionary(n,i),a===FF?a=kF.inflate(n,o):a===zF&&(a=LF));n.avail_in>0&&a===IF&&n.state.wrap&2&&n.state.flags!==0&&n.input[n.next_in]!==0;)kF.inflateReset(n),a=kF.inflate(n,o);switch(a){case RF:case zF:case LF:case BF:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||a===IF||o>0)){if(this.options.to===`string`){let e=HN.utf8border(n.output,n.next_out),t=n.next_out-e,i=HN.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out)),n.avail_out=0,n.next_out=0}if(a!==FF&&a!==VF||s!==0){if(a===IF)return a=kF.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(n.avail_in===0){if(o===PF)return a=kF.inflateEnd(this.strm),this.onEnd(a===FF?VF:a),this.ended=!0,!1;break}}}return!0},UF.prototype.onData=function(e){this.chunks.push(e)},UF.prototype.onEnd=function(e){e===FF&&(this.result=this.options.to===`string`?this.chunks.join(``):LN.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function WF(e,t){let n=new UF(t);if(n.push(e,!0),n.err)throw n.msg||gM[n.err];return n.result}function GF(e,t){return t||={},t.raw=!0,WF(e,t)}var KF={Inflate:UF,inflate:WF,inflateRaw:GF,ungzip:WF,constants:_M},{Deflate:eee,deflate:tee,deflateRaw:qF,gzip:nee}=oP,{Inflate:JF,inflate:YF,inflateRaw:XF,ungzip:ZF}=KF,QF=JF,$F=YF,eI=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;eI[e]=t}var tI=4294967295;function nI(e,t,n){let r=e;for(let e=0;e<n;e++)r=eI[(r^t[e])&255]^r>>>8;return r}function rI(e,t){return(nI(tI,e,t)^tI)>>>0}function iI(e,t,n){let r=e.readUint32(),i=rI(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function aI(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function oI(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function sI(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function cI(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function lI(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+uI(t[a-i],n[a],n[a-i])&255}}function uI(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function dI(e,t,n,r,i,a){switch(e){case 0:aI(t,n,i);break;case 1:oI(t,n,i,a);break;case 2:sI(t,n,r,i);break;case 3:cI(t,n,r,i,a);break;case 4:lI(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var fI=new Uint16Array([255]),pI=new Uint8Array(fI.buffer)[0]===255;function mI(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);dI(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(pI)for(let t=0;t<e.length;t++)e[t]=hI(e[t]);return e}return c}function hI(e){return(e&255)<<8|e>>8&255}var gI=new Uint16Array([255]),_I=new Uint8Array(gI.buffer)[0]===255,vI=new Uint8Array;function yI(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=vI,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:aI(d,f,s);break;case 1:oI(d,f,s,o);break;case 2:sI(d,f,l,s);break;case 3:cI(d,f,l,s,o);break;case 4:lI(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(_I)for(let t=0;t<e.length;t++)e[t]=bI(e[t]);return e}return c}function bI(e){return(e&255)<<8|e>>8&255}var xI=Uint8Array.of(137,80,78,71,13,10,26,10);function SI(e){if(!CI(e.readBytes(xI.length)))throw Error(`wrong PNG signature`)}function CI(e){if(e.length<xI.length)return!1;for(let t=0;t<xI.length;t++)if(e[t]!==xI[t])return!1;return!0}var wI=`tEXt`,TI=0,EI=new TextDecoder(`latin1`);function DI(e){if(kI(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var OI=/^[\u0000-\u00FF]*$/;function kI(e){if(!OI.test(e))throw Error(`invalid latin1 text`)}function AI(e,t,n){let r=jI(t);e[r]=MI(t,n-r.length-1)}function jI(e){for(e.mark();e.readByte()!==TI;);let t=e.offset;e.reset();let n=EI.decode(e.readBytes(t-e.offset-1));return e.skip(1),DI(n),n}function MI(e,t){return EI.decode(e.readBytes(t))}var NI={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},PI={UNKNOWN:-1,DEFLATE:0},FI={UNKNOWN:-1,ADAPTIVE:0},II={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},LI={NONE:0,BACKGROUND:1,PREVIOUS:2},RI={SOURCE:0,OVER:1},zI=class extends cj{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new QF,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=PI.UNKNOWN,this._filterMethod=FI.UNKNOWN,this._interlaceMethod=II.UNKNOWN,this._colorType=NI.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(SI(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this.decodeImage(),this._png}decodeApng(){for(SI(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case wI:AI(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e)}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?iI(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?iI(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=BI(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case NI.GREYSCALE:n=1;break;case NI.TRUECOLOUR:n=3;break;case NI.INDEXED_COLOUR:n=1;break;case NI.GREYSCALE_ALPHA:n=2;break;case NI.TRUECOLOUR_ALPHA:n=4;break;case NI.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==PI.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(n+=4,t-=4,this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case NI.GREYSCALE:case NI.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case NI.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case NI.UNKNOWN:case NI.GREYSCALE_ALPHA:case NI.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=jI(this),n=this.readUint8();if(n!==PI.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:$F(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=yI({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case LI.NONE:break;case LI.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case LI.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case RI.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case RI.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){if(this._inflator.err)throw Error(`Error while decompressing the data: ${this._inflator.err}`);let e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==FI.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===II.NO_INTERLACE)this._png.data=yI({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===II.ADAM7)this._png.data=mI({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){let e=this._inflator.result,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:LI.NONE,blendOp:RI.SOURCE,data:e}),this._inflator=new QF,this._writingDataChunks=!1}};function BI(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}var VI;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.METRE=1]=`METRE`})(VI||={});function HI(e,t){return new zI(e,t).decode()}pt();var UI=function(){return typeof window<`u`?window:mt===void 0?typeof self<`u`?self:this:mt}();function WI(){UI.console&&typeof UI.console.log==`function`&&UI.console.log.apply(UI.console,arguments)}var GI={log:WI,warn:function(e){UI.console&&(typeof UI.console.warn==`function`?UI.console.warn.apply(UI.console,arguments):WI.call(null,arguments))},error:function(e){UI.console&&(typeof UI.console.error==`function`?UI.console.error.apply(UI.console,arguments):WI(e))}};function KI(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e),r.responseType=`blob`,r.onload=function(){YI(r.response,t,n)},r.onerror=function(){GI.error(`could not download file`)},r.send()}function qI(e){var t=new XMLHttpRequest;t.open(`HEAD`,e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function JI(e){try{e.dispatchEvent(new MouseEvent(`click`))}catch{var t=document.createEvent(`MouseEvents`);t.initMouseEvent(`click`,!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var YI=UI.saveAs||((typeof window>`u`?`undefined`:Pi(window))!==`object`||window!==UI?function(){}:typeof HTMLAnchorElement<`u`&&`download`in HTMLAnchorElement.prototype?function(e,t,n){var r=UI.URL||UI.webkitURL,i=document.createElement(`a`);t=t||e.name||`download`,i.download=t,i.rel=`noopener`,typeof e==`string`?(i.href=e,i.origin===location.origin?JI(i):qI(i.href)?KI(e,t,n):JI(i,i.target=`_blank`)):(i.href=r.createObjectURL(e),setTimeout(function(){r.revokeObjectURL(i.href)},4e4),setTimeout(function(){JI(i)},0))}:`msSaveOrOpenBlob`in navigator?function(e,t,n){if(t=t||e.name||`download`,typeof e==`string`){if(qI(e))KI(e,t,n);else{var r=document.createElement(`a`);r.href=e,r.target=`_blank`,setTimeout(function(){JI(r)})}}else navigator.msSaveOrOpenBlob(function(e,t){return t===void 0?t={autoBom:!1}:Pi(t)!==`object`&&(GI.warn(`Deprecated: Expected third argument to be a object`),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([``,e],{type:e.type}):e}(e,n),t)}:function(e,t,n,r){if((r||=open(``,`_blank`))&&(r.document.title=r.document.body.innerText=`downloading...`),typeof e==`string`)return KI(e,t,n);var i=e.type===`application/octet-stream`,a=/constructor/i.test(UI.HTMLElement)||UI.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||i&&a)&&(typeof FileReader>`u`?`undefined`:Pi(FileReader))===`object`){var s=new FileReader;s.onloadend=function(){var e=s.result;e=o?e:e.replace(/^data:[^;]*;/,`data:attachment/file;`),r?r.location.href=e:location=e,r=null},s.readAsDataURL(e)}else{var c=UI.URL||UI.webkitURL,l=c.createObjectURL(e);r?r.location=l:location.href=l,r=null,setTimeout(function(){c.revokeObjectURL(l)},4e4)}});function XI(e){var t;e||=``,this.ok=!1,e.charAt(0)==`#`&&(e=e.substr(1,6)),e={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dodgerblue:`1e90ff`,feldspar:`d19275`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgrey:`d3d3d3`,lightgreen:`90ee90`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslateblue:`8470ff`,lightslategray:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370d8`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`d87093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,violetred:`d02090`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`}[e=(e=e.replace(/ /g,``)).toLowerCase()]||e;for(var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:[`rgb(123, 234, 45)`,`rgb(255,234,245)`],process:function(e){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:[`#00ff00`,`336699`],process:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:[`#fb0`,`f0f`],process:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}}],r=0;r<n.length;r++){var i=n[r].re,a=n[r].process,o=i.exec(e);o&&(t=a(o),this.r=t[0],this.g=t[1],this.b=t[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return`rgb(`+this.r+`, `+this.g+`, `+this.b+`)`},this.toHex=function(){var e=this.r.toString(16),t=this.g.toString(16),n=this.b.toString(16);return e.length==1&&(e=`0`+e),t.length==1&&(t=`0`+t),n.length==1&&(n=`0`+n),`#`+e+t+n}}var ZI=UI.atob.bind(UI),QI=UI.btoa.bind(UI);function $I(e,t){var n=e[0],r=e[1],i=e[2],a=e[3];n=tL(n,r,i,a,t[0],7,-680876936),a=tL(a,n,r,i,t[1],12,-389564586),i=tL(i,a,n,r,t[2],17,606105819),r=tL(r,i,a,n,t[3],22,-1044525330),n=tL(n,r,i,a,t[4],7,-176418897),a=tL(a,n,r,i,t[5],12,1200080426),i=tL(i,a,n,r,t[6],17,-1473231341),r=tL(r,i,a,n,t[7],22,-45705983),n=tL(n,r,i,a,t[8],7,1770035416),a=tL(a,n,r,i,t[9],12,-1958414417),i=tL(i,a,n,r,t[10],17,-42063),r=tL(r,i,a,n,t[11],22,-1990404162),n=tL(n,r,i,a,t[12],7,1804603682),a=tL(a,n,r,i,t[13],12,-40341101),i=tL(i,a,n,r,t[14],17,-1502002290),n=nL(n,r=tL(r,i,a,n,t[15],22,1236535329),i,a,t[1],5,-165796510),a=nL(a,n,r,i,t[6],9,-1069501632),i=nL(i,a,n,r,t[11],14,643717713),r=nL(r,i,a,n,t[0],20,-373897302),n=nL(n,r,i,a,t[5],5,-701558691),a=nL(a,n,r,i,t[10],9,38016083),i=nL(i,a,n,r,t[15],14,-660478335),r=nL(r,i,a,n,t[4],20,-405537848),n=nL(n,r,i,a,t[9],5,568446438),a=nL(a,n,r,i,t[14],9,-1019803690),i=nL(i,a,n,r,t[3],14,-187363961),r=nL(r,i,a,n,t[8],20,1163531501),n=nL(n,r,i,a,t[13],5,-1444681467),a=nL(a,n,r,i,t[2],9,-51403784),i=nL(i,a,n,r,t[7],14,1735328473),n=rL(n,r=nL(r,i,a,n,t[12],20,-1926607734),i,a,t[5],4,-378558),a=rL(a,n,r,i,t[8],11,-2022574463),i=rL(i,a,n,r,t[11],16,1839030562),r=rL(r,i,a,n,t[14],23,-35309556),n=rL(n,r,i,a,t[1],4,-1530992060),a=rL(a,n,r,i,t[4],11,1272893353),i=rL(i,a,n,r,t[7],16,-155497632),r=rL(r,i,a,n,t[10],23,-1094730640),n=rL(n,r,i,a,t[13],4,681279174),a=rL(a,n,r,i,t[0],11,-358537222),i=rL(i,a,n,r,t[3],16,-722521979),r=rL(r,i,a,n,t[6],23,76029189),n=rL(n,r,i,a,t[9],4,-640364487),a=rL(a,n,r,i,t[12],11,-421815835),i=rL(i,a,n,r,t[15],16,530742520),n=iL(n,r=rL(r,i,a,n,t[2],23,-995338651),i,a,t[0],6,-198630844),a=iL(a,n,r,i,t[7],10,1126891415),i=iL(i,a,n,r,t[14],15,-1416354905),r=iL(r,i,a,n,t[5],21,-57434055),n=iL(n,r,i,a,t[12],6,1700485571),a=iL(a,n,r,i,t[3],10,-1894986606),i=iL(i,a,n,r,t[10],15,-1051523),r=iL(r,i,a,n,t[1],21,-2054922799),n=iL(n,r,i,a,t[8],6,1873313359),a=iL(a,n,r,i,t[15],10,-30611744),i=iL(i,a,n,r,t[6],15,-1560198380),r=iL(r,i,a,n,t[13],21,1309151649),n=iL(n,r,i,a,t[4],6,-145523070),a=iL(a,n,r,i,t[11],10,-1120210379),i=iL(i,a,n,r,t[2],15,718787259),r=iL(r,i,a,n,t[9],21,-343485551),e[0]=fL(n,e[0]),e[1]=fL(r,e[1]),e[2]=fL(i,e[2]),e[3]=fL(a,e[3])}function eL(e,t,n,r,i,a){return t=fL(fL(t,e),fL(r,a)),fL(t<<i|t>>>32-i,n)}function tL(e,t,n,r,i,a,o){return eL(t&n|~t&r,e,t,i,a,o)}function nL(e,t,n,r,i,a,o){return eL(t&r|n&~r,e,t,i,a,o)}function rL(e,t,n,r,i,a,o){return eL(t^n^r,e,t,i,a,o)}function iL(e,t,n,r,i,a,o){return eL(n^(t|~r),e,t,i,a,o)}function aL(e){var t,n=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)$I(r,oL(e.substring(t-64,t)));e=e.substring(t-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for($I(r,i),t=0;t<16;t++)i[t]=0;return i[14]=8*n,$I(r,i),r}function oL(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}var sL=`0123456789abcdef`.split(``);function cL(e){for(var t=``,n=0;n<4;n++)t+=sL[e>>8*n+4&15]+sL[e>>8*n&15];return t}function lL(e){return String.fromCharCode(255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24)}function uL(e){return aL(e).map(lL).join(``)}var dL=function(e){for(var t=0;t<e.length;t++)e[t]=cL(e[t]);return e.join(``)}(aL(`hello`))!=`5d41402abc4b2a76b9719d911017c592`;function fL(e,t){if(dL){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}return e+t&4294967295}function pL(e,t){var n,r,i,a;if(e!==n){for(var o=(i=e,a=1+(256/e.length|0),Array(a+1).join(i)),s=[],c=0;c<256;c++)s[c]=c;var l=0;for(c=0;c<256;c++){var u=s[c];l=(l+u+o.charCodeAt(c))%256,s[c]=s[l],s[l]=u}n=e,r=s}else s=r;var d=t.length,f=0,p=0,m=``;for(c=0;c<d;c++)p=(p+(u=s[f=(f+1)%256]))%256,s[f]=s[p],s[p]=u,o=s[(s[f]+s[p])%256],m+=String.fromCharCode(t.charCodeAt(c)^o);return m}var mL={print:4,modify:8,copy:16,"annot-forms":32};function hL(e,t,n,r){this.v=1,this.r=2;var i=192;e.forEach(function(e){if(mL.perm!==void 0)throw Error(`Invalid permission: `+e);i+=mL[e]}),this.padding=`(¿N^NuAd\0NVÿú\b..\0¶Ðh>/\f©þdSiz`;var a=(t+this.padding).substr(0,32),o=(n+this.padding).substr(0,32);this.O=this.processOwnerPassword(a,o),this.P=-(1+(255^i)),this.encryptionKey=uL(a+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(r)).substr(0,5),this.U=pL(this.encryptionKey,this.padding)}function gL(e){if(/[^\u0000-\u00ff]/.test(e))throw Error(`Invalid PDF Name Object: `+e+`, Only accept ASCII characters.`);for(var t=``,n=e.length,r=0;r<n;r++){var i=e.charCodeAt(r);t+=i<33||i===35||i===37||i===40||i===41||i===47||i===60||i===62||i===91||i===93||i===123||i===125||i>126?`#`+(`0`+i.toString(16)).slice(-2):e[r]}return t}function _L(e){if(Pi(e)!==`object`)throw Error(`Invalid Context passed to initialize PubSub (jsPDF-module)`);var t={};this.subscribe=function(e,n,r){if(r||=!1,typeof e!=`string`||typeof n!=`function`||typeof r!=`boolean`)throw Error(`Invalid arguments passed to PubSub.subscribe (jsPDF-module)`);t.hasOwnProperty(e)||(t[e]={});var i=Math.random().toString(35);return t[e][i]=[n,!!r],i},this.unsubscribe=function(e){for(var n in t)if(t[n][e])return delete t[n][e],Object.keys(t[n]).length===0&&delete t[n],!0;return!1},this.publish=function(n){if(t.hasOwnProperty(n)){var r=Array.prototype.slice.call(arguments,1),i=[];for(var a in t[n]){var o=t[n][a];try{o[0].apply(e,r)}catch(e){UI.console&&GI.error(`jsPDF PubSub Error`,e.message,e)}o[1]&&i.push(a)}i.length&&i.forEach(this.unsubscribe)}},this.getTopics=function(){return t}}function vL(e){if(!(this instanceof vL))return new vL(e);var t=`opacity,stroke-opacity`.split(`,`);for(var n in e)e.hasOwnProperty(n)&&t.indexOf(n)>=0&&(this[n]=e[n]);this.id=``,this.objectNumber=-1}function yL(e,t){this.gState=e,this.matrix=t,this.id=``,this.objectNumber=-1}function bL(e,t,n,r,i){if(!(this instanceof bL))return new bL(e,t,n,r,i);this.type=e===`axial`?2:3,this.coords=t,this.colors=n,yL.call(this,r,i)}function xL(e,t,n,r,i){if(!(this instanceof xL))return new xL(e,t,n,r,i);this.boundingBox=e,this.xStep=t,this.yStep=n,this.stream=``,this.cloneIndex=0,yL.call(this,r,i)}function SL(e){var t,n=typeof arguments[0]==`string`?arguments[0]:`p`,r=arguments[1],i=arguments[2],a=arguments[3],o=[],s=1,c=16,l=`S`,u=null;Pi(e||={})===`object`&&(n=e.orientation,r=e.unit||r,i=e.format||i,a=e.compress||e.compressPdf||a,(u=e.encryption||null)!==null&&(u.userPassword=u.userPassword||``,u.ownerPassword=u.ownerPassword||``,u.userPermissions=u.userPermissions||[]),s=typeof e.userUnit==`number`?Math.abs(e.userUnit):1,e.precision!==void 0&&(t=e.precision),e.floatPrecision!==void 0&&(c=e.floatPrecision),l=e.defaultPathOperation||`S`),o=e.filters||(!0===a?[`FlateEncode`]:o),r||=`mm`,n=(``+(n||`P`)).toLowerCase();var d=e.putOnlyUsedFonts||!1,f={},p={internal:{},__private__:{}};p.__private__.PubSub=_L;var m=`1.3`,h=p.__private__.getPdfVersion=function(){return m};p.__private__.setPdfVersion=function(e){m=e};var g={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};p.__private__.getPageFormats=function(){return g};var _=p.__private__.getPageFormat=function(e){return g[e]};i||=`a4`;var v=`compat`,y=`advanced`,b=v;function x(){this.saveGraphicsState(),G(new ze(be,0,0,-be,0,Sn()*be).toString()+` cm`),this.setFontSize(this.getFontSize()/be),l=`n`,b=y}function S(){this.restoreGraphicsState(),l=`S`,b=v}var C=p.__private__.combineFontStyleAndFontWeight=function(e,t){if(e==`bold`&&t==`normal`||e==`bold`&&t==400||e==`normal`&&t==`italic`||e==`bold`&&t==`italic`)throw Error(`Invalid Combination of fontweight and fontstyle`);return t&&(e=t==400||t===`normal`?e===`italic`?`italic`:`normal`:t!=700&&t!==`bold`||e!==`normal`?(t==700?`bold`:t)+``+e:`bold`),e};p.advancedAPI=function(e){var t=b===v;return t&&x.call(this),typeof e!=`function`||(e(this),t&&S.call(this)),this},p.compatAPI=function(e){var t=b===y;return t&&S.call(this),typeof e!=`function`||(e(this),t&&x.call(this)),this},p.isAdvancedAPI=function(){return b===y};var w,T=function(e){if(b!==y)throw Error(e+` is only available in 'advanced' API mode. You need to call advancedAPI() first.`)},E=p.roundToPrecision=p.__private__.roundToPrecision=function(e,n){var r=t||n;if(isNaN(e)||isNaN(r))throw Error(`Invalid argument passed to jsPDF.roundToPrecision`);return e.toFixed(r).replace(/0+$/,``)};w=p.hpf=p.__private__.hpf=typeof c==`number`?function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return E(e,c)}:c===`smart`?function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return E(e,e>-1&&e<1?16:5)}:function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.hpf`);return E(e,16)};var D=p.f2=p.__private__.f2=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.f2`);return E(e,2)},O=p.__private__.f3=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.f3`);return E(e,3)},k=p.scale=p.__private__.scale=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.scale`);return b===v?e*be:b===y?e:void 0},A=function(e){return k(function(e){return b===v?Sn()-e:b===y?e:void 0}(e))};p.__private__.setPrecision=p.setPrecision=function(e){typeof parseInt(e,10)==`number`&&(t=parseInt(e,10))};var j,M=`00000000000000000000000000000000`,N=p.__private__.getFileId=function(){return M},P=p.__private__.setFileId=function(e){return M=e!==void 0&&/^[a-fA-F0-9]{32}$/.test(e)?e.toUpperCase():M.split(``).map(function(){return`ABCDEF0123456789`.charAt(Math.floor(16*Math.random()))}).join(``),u!==null&&(Dt=new hL(u.userPermissions,u.userPassword,u.ownerPassword,M)),M};p.setFileId=function(e){return P(e),this},p.getFileId=function(){return N()};var F=p.__private__.convertDateToPDFDate=function(e){var t=e.getTimezoneOffset(),n=t<0?`+`:`-`,r=Math.floor(Math.abs(t/60)),i=Math.abs(t%60),a=[n,B(r),`'`,B(i),`'`].join(``);return[`D:`,e.getFullYear(),B(e.getMonth()+1),B(e.getDate()),B(e.getHours()),B(e.getMinutes()),B(e.getSeconds()),a].join(``)},I=p.__private__.convertPDFDateToDate=function(e){var t=parseInt(e.substr(2,4),10),n=parseInt(e.substr(6,2),10)-1,r=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),o=parseInt(e.substr(14,2),10);return new Date(t,n,r,i,a,o,0)},L=p.__private__.setCreationDate=function(e){var t;if(e===void 0&&(e=new Date),e instanceof Date)t=F(e);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(e))throw Error(`Invalid argument passed to jsPDF.setCreationDate`);t=e}return j=t},R=p.__private__.getCreationDate=function(e){var t=j;return e===`jsDate`&&(t=I(j)),t};p.setCreationDate=function(e){return L(e),this},p.getCreationDate=function(e){return R(e)};var z,B=p.__private__.padd2=function(e){return(`0`+parseInt(e)).slice(-2)},V=p.__private__.padd2Hex=function(e){return(`00`+(e=e.toString())).substr(e.length)},ee=0,te=[],ne=[],re=0,H=[],ie=[],U=!1,W=ne;p.__private__.setCustomOutputDestination=function(e){U=!0,W=e};var ae=function(e){U||(W=e)};p.__private__.resetCustomOutputDestination=function(){U=!1,W=ne};var G=p.__private__.out=function(e){return e=e.toString(),re+=e.length+1,W.push(e),W},oe=p.__private__.write=function(e){return G(arguments.length===1?e.toString():Array.prototype.join.call(arguments,` `))},se=p.__private__.getArrayBuffer=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);t--;)r[t]=e.charCodeAt(t);return n},ce=[[`Helvetica`,`helvetica`,`normal`,`WinAnsiEncoding`],[`Helvetica-Bold`,`helvetica`,`bold`,`WinAnsiEncoding`],[`Helvetica-Oblique`,`helvetica`,`italic`,`WinAnsiEncoding`],[`Helvetica-BoldOblique`,`helvetica`,`bolditalic`,`WinAnsiEncoding`],[`Courier`,`courier`,`normal`,`WinAnsiEncoding`],[`Courier-Bold`,`courier`,`bold`,`WinAnsiEncoding`],[`Courier-Oblique`,`courier`,`italic`,`WinAnsiEncoding`],[`Courier-BoldOblique`,`courier`,`bolditalic`,`WinAnsiEncoding`],[`Times-Roman`,`times`,`normal`,`WinAnsiEncoding`],[`Times-Bold`,`times`,`bold`,`WinAnsiEncoding`],[`Times-Italic`,`times`,`italic`,`WinAnsiEncoding`],[`Times-BoldItalic`,`times`,`bolditalic`,`WinAnsiEncoding`],[`ZapfDingbats`,`zapfdingbats`,`normal`,null],[`Symbol`,`symbol`,`normal`,null]];p.__private__.getStandardFonts=function(){return ce};var le=e.fontSize||16;p.__private__.setFontSize=p.setFontSize=function(e){return le=b===y?e/be:e,this};var ue,de=p.__private__.getFontSize=p.getFontSize=function(){return b===v?le:le*be},fe=e.R2L||!1;p.__private__.setR2L=p.setR2L=function(e){return fe=e,this},p.__private__.getR2L=p.getR2L=function(){return fe};var pe,me=p.__private__.setZoomMode=function(e){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(e))ue=e;else if(isNaN(e)){if([void 0,null,`fullwidth`,`fullheight`,`fullpage`,`original`].indexOf(e)===-1)throw Error(`zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "`+e+`" is not recognized.`);ue=e}else ue=parseInt(e,10)};p.__private__.getZoomMode=function(){return ue};var he,ge=p.__private__.setPageMode=function(e){if([void 0,null,`UseNone`,`UseOutlines`,`UseThumbs`,`FullScreen`].indexOf(e)==-1)throw Error(`Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "`+e+`" is not recognized.`);pe=e};p.__private__.getPageMode=function(){return pe};var _e=p.__private__.setLayoutMode=function(e){if([void 0,null,`continuous`,`single`,`twoleft`,`tworight`,`two`].indexOf(e)==-1)throw Error(`Layout mode must be one of continuous, single, twoleft, tworight. "`+e+`" is not recognized.`);he=e};p.__private__.getLayoutMode=function(){return he},p.__private__.setDisplayMode=p.setDisplayMode=function(e,t,n){return me(e),_e(t),ge(n),this};var ve={title:``,subject:``,author:``,keywords:``,creator:``};p.__private__.getDocumentProperty=function(e){if(Object.keys(ve).indexOf(e)===-1)throw Error(`Invalid argument passed to jsPDF.getDocumentProperty`);return ve[e]},p.__private__.getDocumentProperties=function(){return ve},p.__private__.setDocumentProperties=p.setProperties=p.setDocumentProperties=function(e){for(var t in ve)ve.hasOwnProperty(t)&&e[t]&&(ve[t]=e[t]);return this},p.__private__.setDocumentProperty=function(e,t){if(Object.keys(ve).indexOf(e)===-1)throw Error(`Invalid arguments passed to jsPDF.setDocumentProperty`);return ve[e]=t};var ye,be,xe,Se,Ce,we={},Te={},Ee=[],De={},Oe={},ke={},Ae={},je=null,Me=0,Ne=[],Pe=new _L(p),Fe=e.hotfixes||[],Ie={},Le={},Re=[],ze=function e(t,n,r,i,a,o){if(!(this instanceof e))return new e(t,n,r,i,a,o);isNaN(t)&&(t=1),isNaN(n)&&(n=0),isNaN(r)&&(r=0),isNaN(i)&&(i=1),isNaN(a)&&(a=0),isNaN(o)&&(o=0),this._matrix=[t,n,r,i,a,o]};Object.defineProperty(ze.prototype,"sx",{get:function(){return this._matrix[0]},set:function(e){this._matrix[0]=e}}),Object.defineProperty(ze.prototype,"shy",{get:function(){return this._matrix[1]},set:function(e){this._matrix[1]=e}}),Object.defineProperty(ze.prototype,"shx",{get:function(){return this._matrix[2]},set:function(e){this._matrix[2]=e}}),Object.defineProperty(ze.prototype,"sy",{get:function(){return this._matrix[3]},set:function(e){this._matrix[3]=e}}),Object.defineProperty(ze.prototype,"tx",{get:function(){return this._matrix[4]},set:function(e){this._matrix[4]=e}}),Object.defineProperty(ze.prototype,"ty",{get:function(){return this._matrix[5]},set:function(e){this._matrix[5]=e}}),Object.defineProperty(ze.prototype,"a",{get:function(){return this._matrix[0]},set:function(e){this._matrix[0]=e}}),Object.defineProperty(ze.prototype,"b",{get:function(){return this._matrix[1]},set:function(e){this._matrix[1]=e}}),Object.defineProperty(ze.prototype,"c",{get:function(){return this._matrix[2]},set:function(e){this._matrix[2]=e}}),Object.defineProperty(ze.prototype,"d",{get:function(){return this._matrix[3]},set:function(e){this._matrix[3]=e}}),Object.defineProperty(ze.prototype,"e",{get:function(){return this._matrix[4]},set:function(e){this._matrix[4]=e}}),Object.defineProperty(ze.prototype,"f",{get:function(){return this._matrix[5]},set:function(e){this._matrix[5]=e}}),Object.defineProperty(ze.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(ze.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(ze.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(ze.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),ze.prototype.join=function(e){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(w).join(e)},ze.prototype.multiply=function(e){return new ze(e.sx*this.sx+e.shy*this.shx,e.sx*this.shy+e.shy*this.sy,e.shx*this.sx+e.sy*this.shx,e.shx*this.shy+e.sy*this.sy,e.tx*this.sx+e.ty*this.shx+this.tx,e.tx*this.shy+e.ty*this.sy+this.ty)},ze.prototype.decompose=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=Math.sqrt(e*e+t*t),s=(e/=o)*n+(t/=o)*r;n-=e*s,r-=t*s;var c=Math.sqrt(n*n+r*r);return s/=c,e*(r/=c)<t*(n/=c)&&(e=-e,t=-t,s=-s,o=-o),{scale:new ze(o,0,0,c,0,0),translate:new ze(1,0,0,1,i,a),rotate:new ze(e,t,-t,e,0,0),skew:new ze(1,0,s,1,0,0)}},ze.prototype.toString=function(e){return this.join(` `)},ze.prototype.inversed=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty,o=1/(e*r-t*n),s=r*o,c=-t*o,l=-n*o,u=e*o;return new ze(s,c,l,u,-s*i-l*a,-c*i-u*a)},ze.prototype.applyToPoint=function(e){return new dn(e.x*this.sx+e.y*this.shx+this.tx,e.x*this.shy+e.y*this.sy+this.ty)},ze.prototype.applyToRectangle=function(e){var t=this.applyToPoint(e),n=this.applyToPoint(new dn(e.x+e.w,e.y+e.h));return new fn(t.x,t.y,n.x-t.x,n.y-t.y)},ze.prototype.clone=function(){var e=this.sx,t=this.shy,n=this.shx,r=this.sy,i=this.tx,a=this.ty;return new ze(e,t,n,r,i,a)},p.Matrix=ze;var Be=p.matrixMult=function(e,t){return t.multiply(e)},K=new ze(1,0,0,1,0,0);p.unitMatrix=p.identityMatrix=K;var Ve=function(e,t){if(!Oe[e]){var n=(t instanceof bL?`Sh`:`P`)+(Object.keys(De).length+1).toString(10);t.id=n,Oe[e]=n,De[n]=t,Pe.publish(`addPattern`,t)}};p.ShadingPattern=bL,p.TilingPattern=xL,p.addShadingPattern=function(e,t){return T(`addShadingPattern()`),Ve(e,t),this},p.beginTilingPattern=function(e){T(`beginTilingPattern()`),mn(e.boundingBox[0],e.boundingBox[1],e.boundingBox[2]-e.boundingBox[0],e.boundingBox[3]-e.boundingBox[1],e.matrix)},p.endTilingPattern=function(e,t){T(`endTilingPattern()`),t.stream=ie[z].join(`
`),Ve(e,t),Pe.publish(`endTilingPattern`,t),Re.pop().restore()};var He,Ue=p.__private__.newObject=function(){var e=We();return Ge(e,!0),e},We=p.__private__.newObjectDeferred=function(){return ee++,te[ee]=function(){return re},ee},Ge=function(e,t){return t=typeof t==`boolean`&&t,te[e]=re,t&&G(e+` 0 obj`),e},Ke=p.__private__.newAdditionalObject=function(){var e={objId:We(),content:``};return H.push(e),e},qe=We(),Je=We(),Ye=p.__private__.decodeColorString=function(e){var t=e.split(` `);if(t.length!==2||t[1]!==`g`&&t[1]!==`G`)t.length!==5||t[4]!==`k`&&t[4]!==`K`||(t=[(1-t[0])*(1-t[3]),(1-t[1])*(1-t[3]),(1-t[2])*(1-t[3]),`r`]);else{var n=parseFloat(t[0]);t=[n,n,n,`r`]}for(var r=`#`,i=0;i<3;i++)r+=(`0`+Math.floor(255*parseFloat(t[i])).toString(16)).slice(-2);return r},Xe=p.__private__.encodeColorString=function(e){var t;typeof e==`string`&&(e={ch1:e});var n=e.ch1,r=e.ch2,i=e.ch3,a=e.ch4,o=e.pdfColorType===`draw`?[`G`,`RG`,`K`]:[`g`,`rg`,`k`];if(typeof n==`string`&&n.charAt(0)!==`#`){var s=new XI(n);if(s.ok)n=s.toHex();else if(!/^\d*\.?\d*$/.test(n))throw Error(`Invalid color "`+n+`" passed to jsPDF.encodeColorString.`)}if(typeof n==`string`&&/^#[0-9A-Fa-f]{3}$/.test(n)&&(n=`#`+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]),typeof n==`string`&&/^#[0-9A-Fa-f]{6}$/.test(n)){var c=parseInt(n.substr(1),16);n=c>>16&255,r=c>>8&255,i=255&c}if(r===void 0||a===void 0&&n===r&&r===i)t=typeof n==`string`?n+` `+o[0]:e.precision===2?D(n/255)+` `+o[0]:O(n/255)+` `+o[0];else if(a===void 0||Pi(a)===`object`){if(a&&!isNaN(a.a)&&a.a===0)return[`1.`,`1.`,`1.`,o[1]].join(` `);t=typeof n==`string`?[n,r,i,o[1]].join(` `):e.precision===2?[D(n/255),D(r/255),D(i/255),o[1]].join(` `):[O(n/255),O(r/255),O(i/255),o[1]].join(` `)}else t=typeof n==`string`?[n,r,i,a,o[2]].join(` `):e.precision===2?[D(n),D(r),D(i),D(a),o[2]].join(` `):[O(n),O(r),O(i),O(a),o[2]].join(` `);return t},Ze=p.__private__.getFilters=function(){return o},Qe=p.__private__.putStream=function(e){var t=(e||={}).data||``,n=e.filters||Ze(),r=e.alreadyAppliedFilters||[],i=e.addLength1||!1,a=t.length,o=e.objectId,s=function(e){return e};if(u!==null&&o===void 0)throw Error(`ObjectId must be passed to putStream for file encryption`);u!==null&&(s=Dt.encryptor(o,0));var c={};!0===n&&(n=[`FlateEncode`]);var l=e.additionalKeyValues||[],d=(c=SL.API.processDataByFilters===void 0?{data:t,reverseChain:[]}:SL.API.processDataByFilters(t,n)).reverseChain+(Array.isArray(r)?r.join(` `):r.toString());if(c.data.length!==0&&(l.push({key:`Length`,value:c.data.length}),!0===i&&l.push({key:`Length1`,value:a})),d.length!=0){if(d.split(`/`).length-1==1)l.push({key:`Filter`,value:d});else{l.push({key:`Filter`,value:`[`+d+`]`});for(var f=0;f<l.length;f+=1)if(l[f].key===`DecodeParms`){for(var p=[],m=0;m<c.reverseChain.split(`/`).length-1;m+=1)p.push(`null`);p.push(l[f].value),l[f].value=`[`+p.join(` `)+`]`}}}G(`<<`);for(var h=0;h<l.length;h++)G(`/`+l[h].key+` `+l[h].value);G(`>>`),c.data.length!==0&&(G(`stream`),G(s(c.data)),G(`endstream`))},$e=p.__private__.putPage=function(e){var t=e.number,n=e.data,r=e.objId,i=e.contentsObjId;Ge(r,!0),G(`<</Type /Page`),G(`/Parent `+e.rootDictionaryObjId+` 0 R`),G(`/Resources `+e.resourceDictionaryObjId+` 0 R`),G(`/MediaBox [`+parseFloat(w(e.mediaBox.bottomLeftX))+` `+parseFloat(w(e.mediaBox.bottomLeftY))+` `+w(e.mediaBox.topRightX)+` `+w(e.mediaBox.topRightY)+`]`),e.cropBox!==null&&G(`/CropBox [`+w(e.cropBox.bottomLeftX)+` `+w(e.cropBox.bottomLeftY)+` `+w(e.cropBox.topRightX)+` `+w(e.cropBox.topRightY)+`]`),e.bleedBox!==null&&G(`/BleedBox [`+w(e.bleedBox.bottomLeftX)+` `+w(e.bleedBox.bottomLeftY)+` `+w(e.bleedBox.topRightX)+` `+w(e.bleedBox.topRightY)+`]`),e.trimBox!==null&&G(`/TrimBox [`+w(e.trimBox.bottomLeftX)+` `+w(e.trimBox.bottomLeftY)+` `+w(e.trimBox.topRightX)+` `+w(e.trimBox.topRightY)+`]`),e.artBox!==null&&G(`/ArtBox [`+w(e.artBox.bottomLeftX)+` `+w(e.artBox.bottomLeftY)+` `+w(e.artBox.topRightX)+` `+w(e.artBox.topRightY)+`]`),typeof e.userUnit==`number`&&e.userUnit!==1&&G(`/UserUnit `+e.userUnit),Pe.publish(`putPage`,{objId:r,pageContext:Ne[t],pageNumber:t,page:n}),G(`/Contents `+i+` 0 R`),G(`>>`),G(`endobj`);var a=n.join(`
`);return b===y&&(a+=`
Q`),Ge(i,!0),Qe({data:a,filters:Ze(),objectId:i}),G(`endobj`),r},et=p.__private__.putPages=function(){var e,t,n=[];for(e=1;e<=Me;e++)Ne[e].objId=We(),Ne[e].contentsObjId=We();for(e=1;e<=Me;e++)n.push($e({number:e,data:ie[e],objId:Ne[e].objId,contentsObjId:Ne[e].contentsObjId,mediaBox:Ne[e].mediaBox,cropBox:Ne[e].cropBox,bleedBox:Ne[e].bleedBox,trimBox:Ne[e].trimBox,artBox:Ne[e].artBox,userUnit:Ne[e].userUnit,rootDictionaryObjId:qe,resourceDictionaryObjId:Je}));Ge(qe,!0),G(`<</Type /Pages`);var r=`/Kids [`;for(t=0;t<Me;t++)r+=n[t]+` 0 R `;G(r+`]`),G(`/Count `+Me),G(`>>`),G(`endobj`),Pe.publish(`postPutPages`)},tt=function(e){Pe.publish(`putFont`,{font:e,out:G,newObject:Ue,putStream:Qe}),!0!==e.isAlreadyPutted&&(e.objectNumber=Ue(),G(`<<`),G(`/Type /Font`),G(`/BaseFont /`+gL(e.postScriptName)),G(`/Subtype /Type1`),typeof e.encoding==`string`&&G(`/Encoding /`+e.encoding),G(`/FirstChar 32`),G(`/LastChar 255`),G(`>>`),G(`endobj`))},nt=function(e){e.objectNumber=Ue();var t=[];t.push({key:`Type`,value:`/XObject`}),t.push({key:`Subtype`,value:`/Form`}),t.push({key:`BBox`,value:`[`+[w(e.x),w(e.y),w(e.x+e.width),w(e.y+e.height)].join(` `)+`]`}),t.push({key:`Matrix`,value:`[`+e.matrix.toString()+`]`}),Qe({data:e.pages[1].join(`
`),additionalKeyValues:t,objectId:e.objectNumber}),G(`endobj`)},rt=function(e,t){t||=21;var n=Ue(),r=function(e,t){var n,r=[],i=1/(t-1);for(n=0;n<1;n+=i)r.push(n);if(r.push(1),e[0].offset!=0){var a={offset:0,color:e[0].color};e.unshift(a)}if(e[e.length-1].offset!=1){var o={offset:1,color:e[e.length-1].color};e.push(o)}for(var s=``,c=0,l=0;l<r.length;l++){for(n=r[l];n>e[c+1].offset;)c++;var u=e[c].offset,d=(n-u)/(e[c+1].offset-u),f=e[c].color,p=e[c+1].color;s+=V(Math.round((1-d)*f[0]+d*p[0]).toString(16))+V(Math.round((1-d)*f[1]+d*p[1]).toString(16))+V(Math.round((1-d)*f[2]+d*p[2]).toString(16))}return s.trim()}(e.colors,t),i=[];i.push({key:`FunctionType`,value:`0`}),i.push({key:`Domain`,value:`[0.0 1.0]`}),i.push({key:`Size`,value:`[`+t+`]`}),i.push({key:`BitsPerSample`,value:`8`}),i.push({key:`Range`,value:`[0.0 1.0 0.0 1.0 0.0 1.0]`}),i.push({key:`Decode`,value:`[0.0 1.0 0.0 1.0 0.0 1.0]`}),Qe({data:r,additionalKeyValues:i,alreadyAppliedFilters:[`/ASCIIHexDecode`],objectId:n}),G(`endobj`),e.objectNumber=Ue(),G(`<< /ShadingType `+e.type),G(`/ColorSpace /DeviceRGB`);var a=`/Coords [`+w(parseFloat(e.coords[0]))+` `+w(parseFloat(e.coords[1]))+` `;e.type===2?a+=w(parseFloat(e.coords[2]))+` `+w(parseFloat(e.coords[3])):a+=w(parseFloat(e.coords[2]))+` `+w(parseFloat(e.coords[3]))+` `+w(parseFloat(e.coords[4]))+` `+w(parseFloat(e.coords[5])),G(a+=`]`),e.matrix&&G(`/Matrix [`+e.matrix.toString()+`]`),G(`/Function `+n+` 0 R`),G(`/Extend [true true]`),G(`>>`),G(`endobj`)},it=function(e,t){var n=We(),r=Ue();t.push({resourcesOid:n,objectOid:r}),e.objectNumber=r;var i=[];i.push({key:`Type`,value:`/Pattern`}),i.push({key:`PatternType`,value:`1`}),i.push({key:`PaintType`,value:`1`}),i.push({key:`TilingType`,value:`1`}),i.push({key:`BBox`,value:`[`+e.boundingBox.map(w).join(` `)+`]`}),i.push({key:`XStep`,value:w(e.xStep)}),i.push({key:`YStep`,value:w(e.yStep)}),i.push({key:`Resources`,value:n+` 0 R`}),e.matrix&&i.push({key:`Matrix`,value:`[`+e.matrix.toString()+`]`}),Qe({data:e.stream,additionalKeyValues:i,objectId:e.objectNumber}),G(`endobj`)},at=function(e){for(var t in e.objectNumber=Ue(),G(`<<`),e)switch(t){case`opacity`:G(`/ca `+D(e[t]));break;case`stroke-opacity`:G(`/CA `+D(e[t]))}G(`>>`),G(`endobj`)},ot=function(e){Ge(e.resourcesOid,!0),G(`<<`),G(`/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]`),function(){for(var e in G(`/Font <<`),we)we.hasOwnProperty(e)&&(!1===d||!0===d&&f.hasOwnProperty(e))&&G(`/`+e+` `+we[e].objectNumber+` 0 R`);G(`>>`)}(),function(){if(Object.keys(De).length>0){for(var e in G(`/Shading <<`),De)De.hasOwnProperty(e)&&De[e]instanceof bL&&De[e].objectNumber>=0&&G(`/`+e+` `+De[e].objectNumber+` 0 R`);Pe.publish(`putShadingPatternDict`),G(`>>`)}}(),function(e){if(Object.keys(De).length>0){for(var t in G(`/Pattern <<`),De)De.hasOwnProperty(t)&&De[t]instanceof p.TilingPattern&&De[t].objectNumber>=0&&De[t].objectNumber<e&&G(`/`+t+` `+De[t].objectNumber+` 0 R`);Pe.publish(`putTilingPatternDict`),G(`>>`)}}(e.objectOid),function(){if(Object.keys(ke).length>0){for(var e in G(`/ExtGState <<`),ke)ke.hasOwnProperty(e)&&ke[e].objectNumber>=0&&G(`/`+e+` `+ke[e].objectNumber+` 0 R`);Pe.publish(`putGStateDict`),G(`>>`)}}(),function(){for(var e in G(`/XObject <<`),Ie)Ie.hasOwnProperty(e)&&Ie[e].objectNumber>=0&&G(`/`+e+` `+Ie[e].objectNumber+` 0 R`);Pe.publish(`putXobjectDict`),G(`>>`)}(),G(`>>`),G(`endobj`)},st=function(e){Te[e.fontName]=Te[e.fontName]||{},Te[e.fontName][e.fontStyle]=e.id},ct=function(e,t,n,r,i){var a={id:`F`+(Object.keys(we).length+1).toString(10),postScriptName:e,fontName:t,fontStyle:n,encoding:r,isStandardFont:i||!1,metadata:{}};return Pe.publish(`addFont`,{font:a,instance:this}),we[a.id]=a,st(a),a.id},lt=p.__private__.pdfEscape=p.pdfEscape=function(e,t){return function(e,t){var n,r,i,a,o,s,c,l,u;if(i=(t||={}).sourceEncoding||`Unicode`,o=t.outputEncoding,(t.autoencode||o)&&we[ye].metadata&&we[ye].metadata[i]&&we[ye].metadata[i].encoding&&(a=we[ye].metadata[i].encoding,!o&&we[ye].encoding&&(o=we[ye].encoding),!o&&a.codePages&&(o=a.codePages[0]),typeof o==`string`&&(o=a[o]),o)){for(c=!1,s=[],n=0,r=e.length;n<r;n++)(l=o[e.charCodeAt(n)])?s.push(String.fromCharCode(l)):s.push(e[n]),s[n].charCodeAt(0)>>8&&(c=!0);e=s.join(``)}for(n=e.length;c===void 0&&n!==0;)e.charCodeAt(n-1)>>8&&(c=!0),n--;if(!c)return e;for(s=t.noBOM?[]:[254,255],n=0,r=e.length;n<r;n++){if((u=(l=e.charCodeAt(n))>>8)>>8)throw Error(`Character at position `+n+` of string '`+e+`' exceeds 16bits. Cannot be encoded into UCS-2 BE`);s.push(u),s.push(l-(u<<8))}return String.fromCharCode.apply(void 0,s)}(e,t).replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`)},ut=p.__private__.beginPage=function(e){ie[++Me]=[],Ne[Me]={objId:0,contentsObjId:0,userUnit:Number(s),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(e[0]),topRightY:Number(e[1])}},pt(Me),ae(ie[z])},dt=function(e,t){var r,a,o;switch(n=t||n,typeof e==`string`&&(r=_(e.toLowerCase()),Array.isArray(r)&&(a=r[0],o=r[1])),Array.isArray(e)&&(a=e[0]*be,o=e[1]*be),isNaN(a)&&(a=i[0],o=i[1]),(a>14400||o>14400)&&(GI.warn(`A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400`),a=Math.min(14400,a),o=Math.min(14400,o)),i=[a,o],n.substr(0,1)){case`l`:o>a&&(i=[o,a]);break;case`p`:a>o&&(i=[o,a])}ut(i),qt(Gt),G(tn),cn!==0&&G(cn+` J`),ln!==0&&G(ln+` j`),Pe.publish(`addPage`,{pageNumber:Me})},ft=function(e){e>0&&e<=Me&&(ie.splice(e,1),Ne.splice(e,1),Me--,z>Me&&(z=Me),this.setPage(z))},pt=function(e){e>0&&e<=Me&&(z=e)},mt=p.__private__.getNumberOfPages=p.getNumberOfPages=function(){return ie.length-1},ht=function(e,t,n){var r,i=void 0;return n||={},e=e===void 0?we[ye].fontName:e,t=t===void 0?we[ye].fontStyle:t,r=e.toLowerCase(),Te[r]!==void 0&&Te[r][t]!==void 0?i=Te[r][t]:Te[e]!==void 0&&Te[e][t]!==void 0?i=Te[e][t]:!1===n.disableWarning&&GI.warn(`Unable to look up font label for font '`+e+`', '`+t+`'. Refer to getFontList() for available fonts.`),i||n.noFallback||((i=Te.times[t])??(i=Te.times.normal)),i},gt=p.__private__.putInfo=function(){var e=Ue(),t=function(e){return e};for(var n in u!==null&&(t=Dt.encryptor(e,0)),G(`<<`),G(`/Producer (`+lt(t(`jsPDF `+SL.version))+`)`),ve)ve.hasOwnProperty(n)&&ve[n]&&G(`/`+n.substr(0,1).toUpperCase()+n.substr(1)+` (`+lt(t(ve[n]))+`)`);G(`/CreationDate (`+lt(t(j))+`)`),G(`>>`),G(`endobj`)},_t=p.__private__.putCatalog=function(e){var t=(e||={}).rootDictionaryObjId||qe;switch(Ue(),G(`<<`),G(`/Type /Catalog`),G(`/Pages `+t+` 0 R`),ue||=`fullwidth`,ue){case`fullwidth`:G(`/OpenAction [3 0 R /FitH null]`);break;case`fullheight`:G(`/OpenAction [3 0 R /FitV null]`);break;case`fullpage`:G(`/OpenAction [3 0 R /Fit]`);break;case`original`:G(`/OpenAction [3 0 R /XYZ null null 1]`);break;default:var n=``+ue;n.substr(n.length-1)===`%`&&(ue=parseInt(ue)/100),typeof ue==`number`&&G(`/OpenAction [3 0 R /XYZ null null `+D(ue)+`]`)}switch(he||=`continuous`,he){case`continuous`:G(`/PageLayout /OneColumn`);break;case`single`:G(`/PageLayout /SinglePage`);break;case`two`:case`twoleft`:G(`/PageLayout /TwoColumnLeft`);break;case`tworight`:G(`/PageLayout /TwoColumnRight`)}pe&&G(`/PageMode /`+pe),Pe.publish(`putCatalog`),G(`>>`),G(`endobj`)},vt=p.__private__.putTrailer=function(){G(`trailer`),G(`<<`),G(`/Size `+(ee+1)),G(`/Root `+ee+` 0 R`),G(`/Info `+(ee-1)+` 0 R`),u!==null&&G(`/Encrypt `+Dt.oid+` 0 R`),G(`/ID [ <`+M+`> <`+M+`> ]`),G(`>>`)},yt=p.__private__.putHeader=function(){G(`%PDF-`+m),G(`%ºß¬à`)},bt=p.__private__.putXRef=function(){var e=`0000000000`;G(`xref`),G(`0 `+(ee+1)),G(`0000000000 65535 f `);for(var t=1;t<=ee;t++)typeof te[t]==`function`?G((e+te[t]()).slice(-10)+` 00000 n `):te[t]===void 0?G(`0000000000 00000 n `):G((e+te[t]).slice(-10)+` 00000 n `)},xt=p.__private__.buildDocument=function(){var e;ee=0,re=0,ne=[],te=[],H=[],qe=We(),Je=We(),ae(ne),Pe.publish(`buildDocument`),yt(),et(),function(){Pe.publish(`putAdditionalObjects`);for(var e=0;e<H.length;e++){var t=H[e];Ge(t.objId,!0),G(t.content),G(`endobj`)}Pe.publish(`postPutAdditionalObjects`)}(),e=[],function(){for(var e in we)we.hasOwnProperty(e)&&(!1===d||!0===d&&f.hasOwnProperty(e))&&tt(we[e])}(),function(){for(var e in ke)ke.hasOwnProperty(e)&&at(ke[e])}(),function(){for(var e in Ie)Ie.hasOwnProperty(e)&&nt(Ie[e])}(),function(e){for(var t in De)De.hasOwnProperty(t)&&(De[t]instanceof bL?rt(De[t]):De[t]instanceof xL&&it(De[t],e))}(e),Pe.publish(`putResources`),e.forEach(ot),ot({resourcesOid:Je,objectOid:2**53-1}),Pe.publish(`postPutResources`),u!==null&&(Dt.oid=Ue(),G(`<<`),G(`/Filter /Standard`),G(`/V `+Dt.v),G(`/R `+Dt.r),G(`/U <`+Dt.toHexString(Dt.U)+`>`),G(`/O <`+Dt.toHexString(Dt.O)+`>`),G(`/P `+Dt.P),G(`>>`),G(`endobj`)),gt(),_t();var t=re;return bt(),vt(),G(`startxref`),G(``+t),G(`%%EOF`),ae(ie[z]),ne.join(`
`)},St=p.__private__.getBlob=function(e){return new Blob([se(e)],{type:`application/pdf`})},Ct=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},wt=function(e){var t,n=e.document,r=n.documentElement,i=n.head,a=n.body;return i||(i=n.createElement(`head`),r.appendChild(i)),a||(a=n.createElement(`body`),r.appendChild(a)),Ct(i),Ct(a),(t=n.createElement(`style`)).appendChild(n.createTextNode(`html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}`)),i.appendChild(t),{document:n,body:a}},Tt=p.output=p.__private__.output=(He=function(e,t){switch(typeof(t||={})==`string`?t={filename:t}:t.filename=t.filename||`generated.pdf`,e){case void 0:return xt();case`save`:p.save(t.filename);break;case`arraybuffer`:return se(xt());case`blob`:return St(xt());case`bloburi`:case`bloburl`:if(UI.URL!==void 0&&typeof UI.URL.createObjectURL==`function`)return UI.URL&&UI.URL.createObjectURL(St(xt()))||void 0;GI.warn(`bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.`);break;case`datauristring`:case`dataurlstring`:var n=``,r=xt();try{n=QI(r)}catch{n=QI(unescape(encodeURIComponent(r)))}return`data:application/pdf;filename=`+encodeURIComponent(t.filename)+`;base64,`+n;case`pdfobjectnewwindow`:if(Object.prototype.toString.call(UI)===`[object Window]`){var i=`https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js`,a=!t.pdfObjectUrl;a||(i=t.pdfObjectUrl);var o=UI.open();if(o!==null){var s=wt(o),c=s.document.createElement(`script`),l=this;c.src=i,a&&(c.integrity=`sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==`,c.crossOrigin=`anonymous`),c.onload=function(){o.PDFObject.embed(l.output(`dataurlstring`),t)},s.body.appendChild(c)}return o}throw Error(`The option pdfobjectnewwindow just works in a browser-environment.`);case`pdfjsnewwindow`:if(Object.prototype.toString.call(UI)===`[object Window]`){var u=t.pdfJsUrl||`examples/PDF.js/web/viewer.html`,d=UI.open();if(d!==null){var f=wt(d),m=f.document.createElement(`iframe`),h=u.indexOf(`?`)===-1?`?`:`&`;l=this,m.id=`pdfViewer`,m.width=`500px`,m.height=`400px`,m.src=u+h+`file=&downloadName=`+encodeURIComponent(t.filename),m.onload=function(){d.document.title=t.filename,m.contentWindow.PDFViewerApplication.open(l.output(`bloburl`))},f.body.appendChild(m)}return d}throw Error(`The option pdfjsnewwindow just works in a browser-environment.`);case`dataurlnewwindow`:if(Object.prototype.toString.call(UI)!==`[object Window]`)throw Error(`The option dataurlnewwindow just works in a browser-environment.`);var g=UI.open();if(g!==null){var _=wt(g),v=_.document.createElement(`iframe`);v.src=this.output(`datauristring`,t),_.body.appendChild(v),g.document.title=t.filename}if(g||typeof safari>`u`)return g;break;case`datauri`:case`dataurl`:return UI.document.location.href=this.output(`datauristring`,t);default:return null}},He.foo=function(){try{return He.apply(this,arguments)}catch(n){var e=n.stack||``;~e.indexOf(` at `)&&(e=e.split(` at `)[1]);var t=`Error in function `+e.split(`
`)[0].split(`<`)[0]+`: `+n.message;if(!UI.console)throw Error(t);UI.console.error(t,n),UI.alert&&alert(t)}},He.foo.bar=He,He.foo),Et=function(e){return!0===Array.isArray(Fe)&&Fe.indexOf(e)>-1};switch(r){case`pt`:be=1;break;case`mm`:be=72/25.4;break;case`cm`:be=72/2.54;break;case`in`:be=72;break;case`px`:be=Et(`px_scaling`)==1?.75:96/72;break;case`pc`:case`em`:be=12;break;case`ex`:be=6;break;default:if(typeof r!=`number`)throw Error(`Invalid unit: `+r);be=r}var Dt=null;L(),P();var Ot=p.__private__.getPageInfo=p.getPageInfo=function(e){if(isNaN(e)||e%1!=0)throw Error(`Invalid argument passed to jsPDF.getPageInfo`);return{objId:Ne[e].objId,pageNumber:e,pageContext:Ne[e]}},kt=p.__private__.getPageInfoByObjId=function(e){if(isNaN(e)||e%1!=0)throw Error(`Invalid argument passed to jsPDF.getPageInfoByObjId`);for(var t in Ne)if(Ne[t].objId===e)break;return Ot(t)},At=p.__private__.getCurrentPageInfo=p.getCurrentPageInfo=function(){return{objId:Ne[z].objId,pageNumber:z,pageContext:Ne[z]}};p.addPage=function(){return dt.apply(this,arguments),this},p.setPage=function(){return pt.apply(this,arguments),ae.call(this,ie[z]),this},p.insertPage=function(e){return this.addPage(),this.movePage(z,e),this},p.movePage=function(e,t){var n,r;if(e>t){n=ie[e],r=Ne[e];for(var i=e;i>t;i--)ie[i]=ie[i-1],Ne[i]=Ne[i-1];ie[t]=n,Ne[t]=r,this.setPage(t)}else if(e<t){n=ie[e],r=Ne[e];for(var a=e;a<t;a++)ie[a]=ie[a+1],Ne[a]=Ne[a+1];ie[t]=n,Ne[t]=r,this.setPage(t)}return this},p.deletePage=function(){return ft.apply(this,arguments),this},p.__private__.text=p.text=function(e,t,n,r,i){var a,o,s,c,l,u,d,p,m,h=(r||={}).scope||this;if(typeof e==`number`&&typeof t==`number`&&(typeof n==`string`||Array.isArray(n))){var g=n;n=t,t=e,e=g}if(arguments[3]instanceof ze==0?(s=arguments[4],c=arguments[5],Pi(d=arguments[3])===`object`&&d!==null||(typeof s==`string`&&(c=s,s=null),typeof d==`string`&&(c=d,d=null),typeof d==`number`&&(s=d,d=null),r={flags:d,angle:s,align:c})):(T(`The transform parameter of text() with a Matrix value`),m=i),isNaN(t)||isNaN(n)||e==null)throw Error(`Invalid arguments passed to jsPDF.text`);if(e.length===0)return h;var _,v=``,x=typeof r.lineHeightFactor==`number`?r.lineHeightFactor:Wt,S=h.internal.scaleFactor;function C(e){return e=e.split(` `).join(Array(r.TabLen||9).join(` `)),lt(e,d)}function E(e){for(var t,n=e.concat(),r=[],i=n.length;i--;)typeof(t=n.shift())==`string`?r.push(t):Array.isArray(e)&&(t.length===1||t[1]===void 0&&t[2]===void 0)?r.push(t[0]):r.push([t[0],t[1],t[2]]);return r}function D(e,t){var n;if(typeof e==`string`)n=t(e)[0];else if(Array.isArray(e)){for(var r,i,a=e.concat(),o=[],s=a.length;s--;)typeof(r=a.shift())==`string`?o.push(t(r)[0]):Array.isArray(r)&&typeof r[0]==`string`&&(i=t(r[0],r[1],r[2]),o.push([i[0],i[1],i[2]]));n=o}return n}var O=!1,A=!0;if(typeof e==`string`)O=!0;else if(Array.isArray(e)){var j=e.concat();o=[];for(var M,N=j.length;N--;)(typeof(M=j.shift())!=`string`||Array.isArray(M)&&typeof M[0]!=`string`)&&(A=!1);O=A}if(!1===O)throw Error(`Type of text must be string or Array. "`+e+`" is not recognized.`);typeof e==`string`&&(e=e.match(/[\r?\n]/)?e.split(/\r\n|\r|\n/g):[e]);var P=le/h.internal.scaleFactor,F=P*(x-1);switch(r.baseline){case`bottom`:n-=F;break;case`top`:n+=P-F;break;case`hanging`:n+=P-2*F;break;case`middle`:n+=P/2-F}if((u=r.maxWidth||0)>0&&(typeof e==`string`?e=h.splitTextToSize(e,u):Object.prototype.toString.call(e)===`[object Array]`&&(e=e.reduce(function(e,t){return e.concat(h.splitTextToSize(t,u))},[]))),a={text:e,x:t,y:n,options:r,mutex:{pdfEscape:lt,activeFontKey:ye,fonts:we,activeFontSize:le}},Pe.publish(`preProcessText`,a),e=a.text,s=(r=a.options).angle,m instanceof ze==0&&s&&typeof s==`number`){s*=Math.PI/180,r.rotationDirection===0&&(s=-s),b===y&&(s=-s);var I=Math.cos(s),L=Math.sin(s);m=new ze(I,L,-L,I,0,0)}else s&&s instanceof ze&&(m=s);b!==y||m||(m=K),(l=r.charSpace||on)!==void 0&&(v+=w(k(l))+` Tc
`,this.setCharSpace(this.getCharSpace()||0)),(p=r.horizontalScale)!==void 0&&(v+=w(100*p)+` Tz
`),r.lang;var R=-1,z=r.renderingMode===void 0?r.stroke:r.renderingMode,B=h.internal.getCurrentPageInfo().pageContext;switch(z){case 0:case!1:case`fill`:R=0;break;case 1:case!0:case`stroke`:R=1;break;case 2:case`fillThenStroke`:R=2;break;case 3:case`invisible`:R=3;break;case 4:case`fillAndAddForClipping`:R=4;break;case 5:case`strokeAndAddPathForClipping`:R=5;break;case 6:case`fillThenStrokeAndAddToPathForClipping`:R=6;break;case 7:case`addToPathForClipping`:R=7}var V=B.usedRenderingMode===void 0?-1:B.usedRenderingMode;R===-1?V!==-1&&(v+=`0 Tr
`):v+=R+` Tr
`,R!==-1&&(B.usedRenderingMode=R),c=r.align||`left`;var ee,te=le*x,ne=h.internal.pageSize.getWidth(),re=we[ye];l=r.charSpace||on,u=r.maxWidth||0,d=Object.assign({autoencode:!0,noBOM:!0},r.flags);var H=[],ie=function(e){return h.getStringUnitWidth(e,{font:re,charSpace:l,fontSize:le,doKerning:!1})*le/S};if(Object.prototype.toString.call(e)===`[object Array]`){var U;o=E(e),c!==`left`&&(ee=o.map(ie));var W,ae=0;if(c===`right`){t-=ee[0],e=[],N=o.length;for(var oe=0;oe<N;oe++)oe===0?(W=Zt(t),U=Qt(n)):(W=k(ae-ee[oe]),U=-te),e.push([o[oe],W,U]),ae=ee[oe]}else if(c===`center`){t-=ee[0]/2,e=[],N=o.length;for(var se=0;se<N;se++)se===0?(W=Zt(t),U=Qt(n)):(W=k((ae-ee[se])/2),U=-te),e.push([o[se],W,U]),ae=ee[se]}else if(c===`left`){e=[],N=o.length;for(var ce=0;ce<N;ce++)e.push(o[ce])}else if(c===`justify`&&re.encoding===`Identity-H`){e=[],N=o.length,u=u===0?ne:u;for(var ue=0,de=0;de<N;de++)if(U=de===0?Qt(n):-te,W=de===0?Zt(t):ue,de<N-1){var pe=k((u-ee[de])/(o[de].split(` `).length-1)),me=o[de].split(` `);e.push([me[0]+` `,W,U]),ue=0;for(var he=1;he<me.length;he++){var ge=(ie(me[he-1]+` `+me[he])-ie(me[he]))*S+pe;he==me.length-1?e.push([me[he],ge,0]):e.push([me[he]+` `,ge,0]),ue-=ge}}else e.push([o[de],W,U]);e.push([``,ue,0])}else{if(c!==`justify`)throw Error(`Unrecognized alignment option, use "left", "center", "right" or "justify".`);for(e=[],N=o.length,u=u===0?ne:u,de=0;de<N;de++){U=de===0?Qt(n):-te,W=de===0?Zt(t):0;var _e=o[de].split(` `).length-1,ve=_e>0?(u-ee[de])/_e:0;de<N-1?H.push(w(k(ve))):H.push(0),e.push([o[de],W,U])}}}!0===(typeof r.R2L==`boolean`?r.R2L:fe)&&(e=D(e,function(e,t,n){return[e.split(``).reverse().join(``),t,n]})),a={text:e,x:t,y:n,options:r,mutex:{pdfEscape:lt,activeFontKey:ye,fonts:we,activeFontSize:le}},Pe.publish(`postProcessText`,a),e=a.text,_=a.mutex.isHex||!1;var be=we[ye].encoding;be!==`WinAnsiEncoding`&&be!==`StandardEncoding`||(e=D(e,function(e,t,n){return[C(e),t,n]})),o=E(e),e=[];for(var xe,Se,Ce,Te=+!!Array.isArray(o[0]),Ee=``,De=function(e,t,n){var i=``;return n instanceof ze?(n=typeof r.angle==`number`?Be(n,new ze(1,0,0,1,e,t)):Be(new ze(1,0,0,1,e,t),n),b===y&&(n=Be(new ze(1,0,0,-1,0,0),n)),i=n.join(` `)+` Tm
`):i=w(e)+` `+w(t)+` Td
`,i},Oe=0;Oe<o.length;Oe++){switch(Ee=``,Te){case 1:Ce=(_?`<`:`(`)+o[Oe][0]+(_?`>`:`)`),xe=parseFloat(o[Oe][1]),Se=parseFloat(o[Oe][2]);break;case 0:Ce=(_?`<`:`(`)+o[Oe]+(_?`>`:`)`),xe=Zt(t),Se=Qt(n)}H!==void 0&&H[Oe]!==void 0&&(Ee=H[Oe]+` Tw
`),Oe===0?e.push(Ee+De(xe,Se,m)+Ce):Te===0?e.push(Ee+Ce):Te===1&&e.push(Ee+De(xe,Se,m)+Ce)}e=Te===0?e.join(` Tj
T* `):e.join(` Tj
`),e+=` Tj
`;var ke=`BT
/`;return ke+=ye+` `+le+` Tf
`,ke+=w(le*x)+` TL
`,ke+=rn+`
`,ke+=v,ke+=e,G(ke+=`ET`),f[ye]=!0,h};var jt=p.__private__.clip=p.clip=function(e){return G(e===`evenodd`?`W*`:`W`),this};p.clipEvenOdd=function(){return jt(`evenodd`)},p.__private__.discardPath=p.discardPath=function(){return G(`n`),this};var Mt=p.__private__.isValidStyle=function(e){var t=!1;return[void 0,null,`S`,`D`,`F`,`DF`,`FD`,`f`,`f*`,`B`,`B*`,`n`].indexOf(e)!==-1&&(t=!0),t};p.__private__.setDefaultPathOperation=p.setDefaultPathOperation=function(e){return Mt(e)&&(l=e),this};var Nt=p.__private__.getStyle=p.getStyle=function(e){var t=l;switch(e){case`D`:case`S`:t=`S`;break;case`F`:t=`f`;break;case`FD`:case`DF`:t=`B`;break;case`f`:case`f*`:case`B`:case`B*`:t=e}return t},Pt=p.close=function(){return G(`h`),this};p.stroke=function(){return G(`S`),this},p.fill=function(e){return Ft(`f`,e),this},p.fillEvenOdd=function(e){return Ft(`f*`,e),this},p.fillStroke=function(e){return Ft(`B`,e),this},p.fillStrokeEvenOdd=function(e){return Ft(`B*`,e),this};var Ft=function(e,t){Pi(t)===`object`?Rt(t,e):G(e)},It=function(e){e===null||b===y&&e===void 0||(e=Nt(e),G(e))};function Lt(e,t,n,r,i){var a=new xL(t||this.boundingBox,n||this.xStep,r||this.yStep,this.gState,i||this.matrix);return a.stream=this.stream,Ve(e+`$$`+this.cloneIndex+++`$$`,a),a}var Rt=function(e,t){var n=Oe[e.key],r=De[n];if(r instanceof bL)G(`q`),G(zt(t)),r.gState&&p.setGState(r.gState),G(e.matrix.toString()+` cm`),G(`/`+n+` sh`),G(`Q`);else if(r instanceof xL){var i=new ze(1,0,0,-1,0,Sn());e.matrix&&(i=i.multiply(e.matrix||K),n=Lt.call(r,e.key,e.boundingBox,e.xStep,e.yStep,i).id),G(`q`),G(`/Pattern cs`),G(`/`+n+` scn`),r.gState&&p.setGState(r.gState),G(t),G(`Q`)}},zt=function(e){switch(e){case`f`:case`F`:case`n`:return`W n`;case`f*`:return`W* n`;case`B`:case`S`:return`W S`;case`B*`:return`W* S`}},Bt=p.moveTo=function(e,t){return G(w(k(e))+` `+w(A(t))+` m`),this},Vt=p.lineTo=function(e,t){return G(w(k(e))+` `+w(A(t))+` l`),this},Ht=p.curveTo=function(e,t,n,r,i,a){return G([w(k(e)),w(A(t)),w(k(n)),w(A(r)),w(k(i)),w(A(a)),`c`].join(` `)),this};p.__private__.line=p.line=function(e,t,n,r,i){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||!Mt(i))throw Error(`Invalid arguments passed to jsPDF.line`);return b===v?this.lines([[n-e,r-t]],e,t,[1,1],i||`S`):this.lines([[n-e,r-t]],e,t,[1,1]).stroke()},p.__private__.lines=p.lines=function(e,t,n,r,i,a){var o,s,c,l,u,d,f,p,m,h,g,_;if(typeof e==`number`&&(_=n,n=t,t=e,e=_),r||=[1,1],a||=!1,isNaN(t)||isNaN(n)||!Array.isArray(e)||!Array.isArray(r)||!Mt(i)||typeof a!=`boolean`)throw Error(`Invalid arguments passed to jsPDF.lines`);for(Bt(t,n),o=r[0],s=r[1],l=e.length,h=t,g=n,c=0;c<l;c++)(u=e[c]).length===2?(h=u[0]*o+h,g=u[1]*s+g,Vt(h,g)):(d=u[0]*o+h,f=u[1]*s+g,p=u[2]*o+h,m=u[3]*s+g,h=u[4]*o+h,g=u[5]*s+g,Ht(d,f,p,m,h,g));return a&&Pt(),It(i),this},p.path=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n.c;switch(n.op){case`m`:Bt(r[0],r[1]);break;case`l`:Vt(r[0],r[1]);break;case`c`:Ht.apply(this,r);break;case`h`:Pt()}}return this},p.__private__.rect=p.rect=function(e,t,n,r,i){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||!Mt(i))throw Error(`Invalid arguments passed to jsPDF.rect`);return b===v&&(r=-r),G([w(k(e)),w(A(t)),w(k(n)),w(k(r)),`re`].join(` `)),It(i),this},p.__private__.triangle=p.triangle=function(e,t,n,r,i,a,o){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a)||!Mt(o))throw Error(`Invalid arguments passed to jsPDF.triangle`);return this.lines([[n-e,r-t],[i-n,a-r],[e-i,t-a]],e,t,[1,1],o,!0),this},p.__private__.roundedRect=p.roundedRect=function(e,t,n,r,i,a,o){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a)||!Mt(o))throw Error(`Invalid arguments passed to jsPDF.roundedRect`);var s=4/3*(Math.SQRT2-1);return i=Math.min(i,.5*n),a=Math.min(a,.5*r),this.lines([[n-2*i,0],[i*s,0,i,a-a*s,i,a],[0,r-2*a],[0,a*s,-i*s,a,-i,a],[2*i-n,0],[-i*s,0,-i,-a*s,-i,-a],[0,2*a-r],[0,-a*s,i*s,-a,i,-a]],e+i,t,[1,1],o,!0),this},p.__private__.ellipse=p.ellipse=function(e,t,n,r,i){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||!Mt(i))throw Error(`Invalid arguments passed to jsPDF.ellipse`);var a=4/3*(Math.SQRT2-1)*n,o=4/3*(Math.SQRT2-1)*r;return Bt(e+n,t),Ht(e+n,t-o,e+a,t-r,e,t-r),Ht(e-a,t-r,e-n,t-o,e-n,t),Ht(e-n,t+o,e-a,t+r,e,t+r),Ht(e+a,t+r,e+n,t+o,e+n,t),It(i),this},p.__private__.circle=p.circle=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||!Mt(r))throw Error(`Invalid arguments passed to jsPDF.circle`);return this.ellipse(e,t,n,n,r)},p.setFont=function(e,t,n){return n&&(t=C(t,n)),ye=ht(e,t,{disableWarning:!1}),this};var Ut=p.__private__.getFont=p.getFont=function(){return we[ht.apply(p,arguments)]};p.__private__.getFontList=p.getFontList=function(){var e,t,n={};for(e in Te)if(Te.hasOwnProperty(e))for(t in n[e]=[],Te[e])Te[e].hasOwnProperty(t)&&n[e].push(t);return n},p.addFont=function(e,t,n,r,i){var a=[`StandardEncoding`,`MacRomanEncoding`,`Identity-H`,`WinAnsiEncoding`];return arguments[3]&&a.indexOf(arguments[3])!==-1?i=arguments[3]:arguments[3]&&a.indexOf(arguments[3])==-1&&(n=C(n,r)),ct.call(this,e,t,n,i||=`Identity-H`)};var Wt,Gt=e.lineWidth||.200025,Kt=p.__private__.getLineWidth=p.getLineWidth=function(){return Gt},qt=p.__private__.setLineWidth=p.setLineWidth=function(e){return Gt=e,G(w(k(e))+` w`),this};p.__private__.setLineDash=SL.API.setLineDash=SL.API.setLineDashPattern=function(e,t){if(e||=[],t||=0,isNaN(t)||!Array.isArray(e))throw Error(`Invalid arguments passed to jsPDF.setLineDash`);return e=e.map(function(e){return w(k(e))}).join(` `),t=w(k(t)),G(`[`+e+`] `+t+` d`),this};var Jt=p.__private__.getLineHeight=p.getLineHeight=function(){return le*Wt};p.__private__.getLineHeight=p.getLineHeight=function(){return le*Wt};var Yt=p.__private__.setLineHeightFactor=p.setLineHeightFactor=function(e){return typeof(e||=1.15)==`number`&&(Wt=e),this},Xt=p.__private__.getLineHeightFactor=p.getLineHeightFactor=function(){return Wt};Yt(e.lineHeight);var Zt=p.__private__.getHorizontalCoordinate=function(e){return k(e)},Qt=p.__private__.getVerticalCoordinate=function(e){return b===y?e:Ne[z].mediaBox.topRightY-Ne[z].mediaBox.bottomLeftY-k(e)},$t=p.__private__.getHorizontalCoordinateString=p.getHorizontalCoordinateString=function(e){return w(Zt(e))},en=p.__private__.getVerticalCoordinateString=p.getVerticalCoordinateString=function(e){return w(Qt(e))},tn=e.strokeColor||`0 G`;p.__private__.getStrokeColor=p.getDrawColor=function(){return Ye(tn)},p.__private__.setStrokeColor=p.setDrawColor=function(e,t,n,r){return tn=Xe({ch1:e,ch2:t,ch3:n,ch4:r,pdfColorType:`draw`,precision:2}),G(tn),this};var nn=e.fillColor||`0 g`;p.__private__.getFillColor=p.getFillColor=function(){return Ye(nn)},p.__private__.setFillColor=p.setFillColor=function(e,t,n,r){return nn=Xe({ch1:e,ch2:t,ch3:n,ch4:r,pdfColorType:`fill`,precision:2}),G(nn),this};var rn=e.textColor||`0 g`,an=p.__private__.getTextColor=p.getTextColor=function(){return Ye(rn)};p.__private__.setTextColor=p.setTextColor=function(e,t,n,r){return rn=Xe({ch1:e,ch2:t,ch3:n,ch4:r,pdfColorType:`text`,precision:3}),this};var on=e.charSpace,sn=p.__private__.getCharSpace=p.getCharSpace=function(){return parseFloat(on||0)};p.__private__.setCharSpace=p.setCharSpace=function(e){if(isNaN(e))throw Error(`Invalid argument passed to jsPDF.setCharSpace`);return on=e,this};var cn=0;p.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},p.__private__.setLineCap=p.setLineCap=function(e){var t=p.CapJoinStyles[e];if(t===void 0)throw Error(`Line cap style of '`+e+`' is not recognized. See or extend .CapJoinStyles property for valid styles`);return cn=t,G(t+` J`),this};var ln=0;p.__private__.setLineJoin=p.setLineJoin=function(e){var t=p.CapJoinStyles[e];if(t===void 0)throw Error(`Line join style of '`+e+`' is not recognized. See or extend .CapJoinStyles property for valid styles`);return ln=t,G(t+` j`),this},p.__private__.setLineMiterLimit=p.__private__.setMiterLimit=p.setLineMiterLimit=p.setMiterLimit=function(e){if(e||=0,isNaN(e))throw Error(`Invalid argument passed to jsPDF.setLineMiterLimit`);return G(w(k(e))+` M`),this},p.GState=vL,p.setGState=function(e){(e=typeof e==`string`?ke[Ae[e]]:un(null,e)).equals(je)||(G(`/`+e.id+` gs`),je=e)};var un=function(e,t){if(!e||!Ae[e]){var n=!1;for(var r in ke)if(ke.hasOwnProperty(r)&&ke[r].equals(t)){n=!0;break}if(n)t=ke[r];else{var i=`GS`+(Object.keys(ke).length+1).toString(10);ke[i]=t,t.id=i}return e&&(Ae[e]=t.id),Pe.publish(`addGState`,t),t}};p.addGState=function(e,t){return un(e,t),this},p.saveGraphicsState=function(){return G(`q`),Ee.push({key:ye,size:le,color:rn}),this},p.restoreGraphicsState=function(){G(`Q`);var e=Ee.pop();return ye=e.key,le=e.size,rn=e.color,je=null,this},p.setCurrentTransformationMatrix=function(e){return G(e.toString()+` cm`),this},p.comment=function(e){return G(`#`+e),this};var dn=function(e,t){var n=e||0;Object.defineProperty(this,"x",{enumerable:!0,get:function(){return n},set:function(e){isNaN(e)||(n=parseFloat(e))}});var r=t||0;Object.defineProperty(this,"y",{enumerable:!0,get:function(){return r},set:function(e){isNaN(e)||(r=parseFloat(e))}});var i=`pt`;return Object.defineProperty(this,"type",{enumerable:!0,get:function(){return i},set:function(e){i=e.toString()}}),this},fn=function(e,t,n,r){dn.call(this,e,t),this.type=`rect`;var i=n||0;Object.defineProperty(this,"w",{enumerable:!0,get:function(){return i},set:function(e){isNaN(e)||(i=parseFloat(e))}});var a=r||0;return Object.defineProperty(this,"h",{enumerable:!0,get:function(){return a},set:function(e){isNaN(e)||(a=parseFloat(e))}}),this},pn=function(){this.page=Me,this.currentPage=z,this.pages=ie.slice(0),this.pagesContext=Ne.slice(0),this.x=xe,this.y=Se,this.matrix=Ce,this.width=gn(z),this.height=vn(z),this.outputDestination=W,this.id=``,this.objectNumber=-1};pn.prototype.restore=function(){Me=this.page,z=this.currentPage,Ne=this.pagesContext,ie=this.pages,xe=this.x,Se=this.y,Ce=this.matrix,_n(z,this.width),yn(z,this.height),W=this.outputDestination};var mn=function(e,t,n,r,i){Re.push(new pn),Me=z=0,ie=[],xe=e,Se=t,Ce=i,ut([n,r])};for(var hn in p.beginFormObject=function(e,t,n,r,i){return mn(e,t,n,r,i),this},p.endFormObject=function(e){return function(e){if(Le[e])Re.pop().restore();else{var t=new pn,n=`Xo`+(Object.keys(Ie).length+1).toString(10);t.id=n,Le[e]=n,Ie[n]=t,Pe.publish(`addFormObject`,t),Re.pop().restore()}}(e),this},p.doFormObject=function(e,t){var n=Ie[Le[e]];return G(`q`),G(t.toString()+` cm`),G(`/`+n.id+` Do`),G(`Q`),this},p.getFormObject=function(e){var t=Ie[Le[e]];return{x:t.x,y:t.y,width:t.width,height:t.height,matrix:t.matrix}},p.save=function(e,t){return e||=`generated.pdf`,(t||={}).returnPromise=t.returnPromise||!1,!1===t.returnPromise?(YI(St(xt()),e),typeof YI.unload==`function`&&UI.setTimeout&&setTimeout(YI.unload,911),this):new Promise(function(t,n){try{var r=YI(St(xt()),e);typeof YI.unload==`function`&&UI.setTimeout&&setTimeout(YI.unload,911),t(r)}catch(e){n(e.message)}})},SL.API)SL.API.hasOwnProperty(hn)&&(hn===`events`&&SL.API.events.length?function(e,t){var n,r,i;for(i=t.length-1;i!==-1;i--)n=t[i][0],r=t[i][1],e.subscribe.apply(e,[n].concat(typeof r==`function`?[r]:r))}(Pe,SL.API.events):p[hn]=SL.API[hn]);function gn(e){return Ne[e].mediaBox.topRightX-Ne[e].mediaBox.bottomLeftX}function _n(e,t){Ne[e].mediaBox.topRightX=t+Ne[e].mediaBox.bottomLeftX}function vn(e){return Ne[e].mediaBox.topRightY-Ne[e].mediaBox.bottomLeftY}function yn(e,t){Ne[e].mediaBox.topRightY=t+Ne[e].mediaBox.bottomLeftY}var bn=p.getPageWidth=function(e){return gn(e||=z)/be},xn=p.setPageWidth=function(e,t){_n(e,t*be)},Sn=p.getPageHeight=function(e){return vn(e||=z)/be},Cn=p.setPageHeight=function(e,t){yn(e,t*be)};return p.internal={pdfEscape:lt,getStyle:Nt,getFont:Ut,getFontSize:de,getCharSpace:sn,getTextColor:an,getLineHeight:Jt,getLineHeightFactor:Xt,getLineWidth:Kt,write:oe,getHorizontalCoordinate:Zt,getVerticalCoordinate:Qt,getCoordinateString:$t,getVerticalCoordinateString:en,collections:{},newObject:Ue,newAdditionalObject:Ke,newObjectDeferred:We,newObjectDeferredBegin:Ge,getFilters:Ze,putStream:Qe,events:Pe,scaleFactor:be,pageSize:{getWidth:function(){return bn(z)},setWidth:function(e){xn(z,e)},getHeight:function(){return Sn(z)},setHeight:function(e){Cn(z,e)}},encryptionOptions:u,encryption:Dt,getEncryptor:function(e){return u===null?function(e){return e}:Dt.encryptor(e,0)},output:Tt,getNumberOfPages:mt,get pages(){return ie},out:G,f2:D,f3:O,getPageInfo:Ot,getPageInfoByObjId:kt,getCurrentPageInfo:At,getPDFVersion:h,Point:dn,Rectangle:fn,Matrix:ze,hasHotfix:Et},Object.defineProperty(p.internal.pageSize,"width",{get:function(){return bn(z)},set:function(e){xn(z,e)},enumerable:!0,configurable:!0}),Object.defineProperty(p.internal.pageSize,"height",{get:function(){return Sn(z)},set:function(e){Cn(z,e)},enumerable:!0,configurable:!0}),function(e){for(var t=0,n=ce.length;t<n;t++){var r=ct.call(this,e[t][0],e[t][1],e[t][2],ce[t][3],!0);!1===d&&(f[r]=!0);var i=e[t][0].split(`-`);st({id:r,fontName:i[0],fontStyle:i[1]||``})}Pe.publish(`addFonts`,{fonts:we,dictionary:Te})}.call(p,ce),ye=`F1`,dt(i,n),Pe.publish(`initialized`),p}hL.prototype.lsbFirstWord=function(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)},hL.prototype.toHexString=function(e){return e.split(``).map(function(e){return(`0`+(255&e.charCodeAt(0)).toString(16)).slice(-2)}).join(``)},hL.prototype.hexToBytes=function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(String.fromCharCode(parseInt(e.substr(n,2),16)));return t.join(``)},hL.prototype.processOwnerPassword=function(e,t){return pL(uL(t).substr(0,5),e)},hL.prototype.encryptor=function(e,t){var n=uL(this.encryptionKey+String.fromCharCode(255&e,e>>8&255,e>>16&255,255&t,t>>8&255)).substr(0,10);return function(e){return pL(n,e)}},vL.prototype.equals=function(e){var t,n=`id,objectNumber,equals`;if(!e||Pi(e)!==Pi(this))return!1;var r=0;for(t in this)if(!(n.indexOf(t)>=0)){if(this.hasOwnProperty(t)&&!e.hasOwnProperty(t)||this[t]!==e[t])return!1;r++}for(t in e)e.hasOwnProperty(t)&&n.indexOf(t)<0&&r--;return r===0},SL.API={events:[]},SL.version=`4.2.1`;var CL=SL.API,wL=1,TL=function(e){return e.replace(/\\/g,`\\\\`).replace(/\(/g,`\\(`).replace(/\)/g,`\\)`)},EL=function(e){return e.replace(/\\\\/g,`\\`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)},DL=function(e){return e.toString().replace(/#/g,`#23`).replace(/[\s\n\r()<>[\]{}\/%]/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return`#`+(t.length===1?`0`+t:t)})},OL=function(e){return e.toFixed(2)},kL=function(e){return e.toFixed(5)};CL.__acroform__={};var AL=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e},jL=function(e){return e*wL},ML=function(e){var t=new YL,n=lR.internal.getHeight(e)||0,r=lR.internal.getWidth(e)||0;return t.BBox=[0,0,Number(OL(r)),Number(OL(n))],t},NL=CL.__acroform__.setBit=function(e,t){if(e||=0,t||=0,isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.setBit`);return e|1<<t},PL=CL.__acroform__.clearBit=function(e,t){if(e||=0,t||=0,isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.clearBit`);return e&~(1<<t)},FL=CL.__acroform__.getBit=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.getBit`);return e&1<<t?1:0},IL=CL.__acroform__.getBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf`);return FL(e,t-1)},LL=CL.__acroform__.setBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf`);return NL(e,t-1)},RL=CL.__acroform__.clearBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf`);return PL(e,t-1)},zL=CL.__acroform__.calculateCoordinates=function(e,t){var n=t.internal.getHorizontalCoordinate,r=t.internal.getVerticalCoordinate,i=e[0],a=e[1],o=e[2],s=e[3],c={};return c.lowerLeft_X=n(i)||0,c.lowerLeft_Y=r(a+s)||0,c.upperRight_X=n(i+o)||0,c.upperRight_Y=r(a)||0,[Number(OL(c.lowerLeft_X)),Number(OL(c.lowerLeft_Y)),Number(OL(c.upperRight_X)),Number(OL(c.upperRight_Y))]},BL=function(e){if(e.appearanceStreamContent)return e.appearanceStreamContent;if(e.V||e.DV){var t=[],n=VL(e,e._V||e.DV),r=e.scope.internal.getFont(e.fontName,e.fontStyle).id;t.push(`/Tx BMC`),t.push(`q`),t.push(`BT`),t.push(e.scope.__private__.encodeColorString(e.color)),t.push(`/`+r+` `+OL(n.fontSize)+` Tf`),t.push(`1 0 0 1 0 0 Tm`),t.push(n.text),t.push(`ET`),t.push(`Q`),t.push(`EMC`);var i=ML(e);return i.scope=e.scope,i.stream=t.join(`
`),i}},VL=function(e,t){var n=e.fontSize===0?e.maxFontSize:e.fontSize,r={text:``,fontSize:``},i=(t=(t=t.substr(0,1)==`(`?t.substr(1):t).substr(t.length-1)==`)`?t.substr(0,t.length-1):t).split(` `);i=e.multiline?i.map(function(e){return e.split(`
`)}):i.map(function(e){return[e]});var a=n,o=lR.internal.getHeight(e)||0;o=o<0?-o:o;var s=lR.internal.getWidth(e)||0;s=s<0?-s:s;var c=function(t,n,r){return t+1<i.length&&HL(n+` `+i[t+1][0],e,r).width<=s-4};a++;t:for(;a>0;){t=``,a--;var l,u,d=HL(`3`,e,a).height,f=e.multiline?o-a:(o-d)/2,p=f+=2,m=0,h=0,g=0;if(a<=0){t=`(...) Tj
`,t+=`% Width of Text: `+HL(t,e,a=12).width+`, FieldWidth:`+s+`
`;break}for(var _=``,v=0,y=0;y<i.length;y++)if(i.hasOwnProperty(y)){var b=!1;if(i[y].length!==1&&g!==i[y].length-1){if((d+2)*(v+2)+2>o)continue t;_+=i[y][g],b=!0,h=y,y--}else{_=(_+=i[y][g]+` `).substr(_.length-1)==` `?_.substr(0,_.length-1):_;var x=parseInt(y),S=c(x,_,a),C=y>=i.length-1;if(S&&!C){_+=` `,g=0;continue}if(S||C){if(C)h=x;else if(e.multiline&&(d+2)*(v+2)+2>o)continue t}else{if(!e.multiline||(d+2)*(v+2)+2>o)continue t;h=x}}for(var w=``,T=m;T<=h;T++){var E=i[T];if(e.multiline){if(T===h){w+=E[g]+` `,g=(g+1)%E.length;continue}if(T===m){w+=E[E.length-1]+` `;continue}}w+=E[0]+` `}switch(w=w.substr(w.length-1)==` `?w.substr(0,w.length-1):w,u=HL(w,e,a).width,e.textAlign){case`right`:l=s-u-2;break;case`center`:l=(s-u)/2;break;default:l=2}t+=OL(l)+` `+OL(p)+` Td
`,t+=`(`+TL(w)+`) Tj
`,t+=-OL(l)+` 0 Td
`,p=-(a+2),u=0,m=b?h:h+1,v++,_=``}break}return r.text=t,r.fontSize=a,r},HL=function(e,t,n){var r=t.scope.internal.getFont(t.fontName,t.fontStyle),i=t.scope.getStringUnitWidth(e,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n);return{height:t.scope.getStringUnitWidth(`3`,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n)*1.5,width:i}},UL={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},WL=function(e,t){var n={type:`reference`,object:e};t.internal.getPageInfo(e.page).pageContext.annotations.find(function(e){return e.type===n.type&&e.object===n.object})===void 0&&t.internal.getPageInfo(e.page).pageContext.annotations.push(n)},GL=function(e,t){if(t.scope=e,e.internal!==void 0&&(e.internal.acroformPlugin===void 0||!1===e.internal.acroformPlugin.isInitialized)){if(ZL.FieldNum=0,e.internal.acroformPlugin=JSON.parse(JSON.stringify(UL)),e.internal.acroformPlugin.acroFormDictionaryRoot)throw Error(`Exception while creating AcroformDictionary`);wL=e.internal.scaleFactor,e.internal.acroformPlugin.acroFormDictionaryRoot=new XL,e.internal.acroformPlugin.acroFormDictionaryRoot.scope=e,e.internal.acroformPlugin.acroFormDictionaryRoot._eventID=e.internal.events.subscribe(`postPutResources`,function(){(function(e){e.internal.events.unsubscribe(e.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete e.internal.acroformPlugin.acroFormDictionaryRoot._eventID,e.internal.acroformPlugin.printedOut=!0})(e)}),e.internal.events.subscribe(`buildDocument`,function(){(function(e){e.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var t=e.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];r.objId=void 0,r.hasAnnotation&&WL(r,e)}})(e)}),e.internal.events.subscribe(`putCatalog`,function(){(function(e){if(e.internal.acroformPlugin.acroFormDictionaryRoot===void 0)throw Error(`putCatalogCallback: Root missing.`);e.internal.write(`/AcroForm `+e.internal.acroformPlugin.acroFormDictionaryRoot.objId+` 0 R`)})(e)}),e.internal.events.subscribe(`postPutPages`,function(t){(function(e,t){var n=!e;for(var r in e||(t.internal.newObjectDeferredBegin(t.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),t.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),e||=t.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(e.hasOwnProperty(r)){var i=e[r],a=[],o=i.Rect;if(i.Rect&&=zL(i.Rect,t),t.internal.newObjectDeferredBegin(i.objId,!0),i.DA=lR.createDefaultAppearanceStream(i),Pi(i)===`object`&&typeof i.getKeyValueListForStream==`function`&&(a=i.getKeyValueListForStream()),i.Rect=o,i.hasAppearanceStream&&!i.appearanceStreamContent){var s=BL(i);a.push({key:`AP`,value:`<</N `+s+`>>`}),t.internal.acroformPlugin.xForms.push(s)}if(i.appearanceStreamContent){var c=``;for(var l in i.appearanceStreamContent)if(i.appearanceStreamContent.hasOwnProperty(l)){var u=i.appearanceStreamContent[l];if(c+=`/`+l+` `,c+=`<<`,Object.keys(u).length>=1||Array.isArray(u)){for(var r in u)if(u.hasOwnProperty(r)){var d=u[r];typeof d==`function`&&(d=d.call(t,i)),c+=`/`+r+` `+d+` `,t.internal.acroformPlugin.xForms.indexOf(d)>=0||t.internal.acroformPlugin.xForms.push(d)}}else typeof(d=u)==`function`&&(d=d.call(t,i)),c+=`/`+r+` `+d,t.internal.acroformPlugin.xForms.indexOf(d)>=0||t.internal.acroformPlugin.xForms.push(d);c+=`>>`}a.push({key:`AP`,value:`<<
`+c+`>>`})}t.internal.putStream({additionalKeyValues:a,objectId:i.objId}),t.internal.out(`endobj`)}n&&function(e,t){for(var n in e)if(e.hasOwnProperty(n)){var r=n,i=e[n];t.internal.newObjectDeferredBegin(i.objId,!0),Pi(i)===`object`&&typeof i.putStream==`function`&&i.putStream(),delete e[r]}}(t.internal.acroformPlugin.xForms,t)})(t,e)}),e.internal.acroformPlugin.isInitialized=!0}},KL=CL.__acroform__.arrayToPdfArray=function(e,t,n){var r=function(e){return e};if(Array.isArray(e)){for(var i=`[`,a=0;a<e.length;a++)switch(a!==0&&(i+=` `),Pi(e[a])){case`boolean`:case`number`:case`object`:i+=e[a].toString();break;case`string`:e[a].substr(0,1)===`/`?i+=`/`+DL(e[a].substr(1)):(t!==void 0&&n&&(r=n.internal.getEncryptor(t)),i+=`(`+TL(r(e[a].toString()))+`)`)}return i+`]`}throw Error(`Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray`)},qL=function(e,t,n){var r=function(e){return e};return t!==void 0&&n&&(r=n.internal.getEncryptor(t)),(e||=``).toString(),`(`+TL(r(e))+`)`},JL=function(){this._objId=void 0,this._scope=void 0,Object.defineProperty(this,"objId",{get:function(){if(this._objId===void 0){if(this.scope===void 0)return;this._objId=this.scope.internal.newObjectDeferred()}return this._objId},set:function(e){this._objId=e}}),Object.defineProperty(this,"scope",{value:this._scope,writable:!0})};JL.prototype.toString=function(){return this.objId+` 0 R`},JL.prototype.putStream=function(){var e=this.getKeyValueListForStream();this.scope.internal.putStream({data:this.stream,additionalKeyValues:e,objectId:this.objId}),this.scope.internal.out(`endobj`)},JL.prototype.getKeyValueListForStream=function(){var e=[],t=Object.getOwnPropertyNames(this).filter(function(e){return e!=`content`&&e!=`appearanceStreamContent`&&e!=`scope`&&e!=`objId`&&e.substring(0,1)!=`_`});for(var n in t)if(!1===Object.getOwnPropertyDescriptor(this,t[n]).configurable){var r=t[n],i=this[r];i&&(Array.isArray(i)?e.push({key:r,value:KL(i,this.objId,this.scope)}):i instanceof JL?(i.scope=this.scope,e.push({key:r,value:i.objId+` 0 R`})):typeof i!=`function`&&e.push({key:r,value:i}))}return e};var YL=function(){JL.call(this),Object.defineProperty(this,"Type",{value:`/XObject`,configurable:!1,writable:!0}),Object.defineProperty(this,"Subtype",{value:`/Form`,configurable:!1,writable:!0}),Object.defineProperty(this,"FormType",{value:1,configurable:!1,writable:!0});var e,t=[];Object.defineProperty(this,"BBox",{configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"Resources",{value:`2 0 R`,configurable:!1,writable:!0}),Object.defineProperty(this,"stream",{enumerable:!1,configurable:!0,set:function(t){e=t.trim()},get:function(){return e||null}})};AL(YL,JL);var XL=function(){JL.call(this);var e,t=[];Object.defineProperty(this,"Kids",{enumerable:!1,configurable:!0,get:function(){return t.length>0?t:void 0}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return t}}),Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(e){var t=function(e){return e};return this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),`(`+TL(t(e))+`)`}},set:function(t){e=t}})};AL(XL,JL);var ZL=function e(){JL.call(this);var t=4;Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){if(isNaN(e))throw Error(`Invalid value "`+e+`" for attribute F supplied.`);t=e}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!IL(t,3)},set:function(e){this.F=!!e==1?LL(t,3):RL(t,3)}});var n=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return n},set:function(e){if(isNaN(e))throw Error(`Invalid value "`+e+`" for attribute Ff supplied.`);n=e}});var r=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(r.length!==0)return r},set:function(e){r=e===void 0?[]:e}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[0])?0:r[0]},set:function(e){r[0]=e}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[1])?0:r[1]},set:function(e){r[1]=e}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[2])?0:r[2]},set:function(e){r[2]=e}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[3])?0:r[3]},set:function(e){r[3]=e}});var i=``;Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return i},set:function(e){switch(e){case`/Btn`:case`/Tx`:case`/Ch`:case`/Sig`:i=e;break;default:throw Error(`Invalid value "`+e+`" for attribute FT supplied.`)}}});var a=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!a||a.length<1){if(this instanceof aR)return;a=`FieldObject`+e.FieldNum++}var t=function(e){return e};return this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),`(`+TL(t(a))+`)`},set:function(e){a=e.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return a},set:function(e){a=e}});var o=`helvetica`;Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return o},set:function(e){o=e}});var s=`normal`;Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return s},set:function(e){s=e}});var c=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return c},set:function(e){c=e}});var l=void 0;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return l===void 0?50/wL:l},set:function(e){l=e}});var u=`black`;Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return u},set:function(e){u=e}});var d=`/F1 0 Tf 0 g`;Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!d||this instanceof aR||this instanceof sR))return qL(d,this.objId,this.scope)},set:function(e){e=e.toString(),d=e}});var f=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(f)return this instanceof nR==0?qL(f,this.objId,this.scope):f},set:function(e){e=e.toString(),f=this instanceof nR==0?e.substr(0,1)===`(`?EL(e.substr(1,e.length-2)):EL(e):e}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof nR==1?EL(f.substr(1,f.length-1)):f},set:function(e){e=e.toString(),f=this instanceof nR==1?`/`+DL(e):e}});var p=null;Object.defineProperty(this,"_V",{enumerable:!1,configurable:!1,get:function(){if(p)return p},set:function(e){this.V=e}}),Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(p)return this instanceof nR==0?qL(p,this.objId,this.scope):p},set:function(e){e=e.toString(),p=this instanceof nR==0?e.substr(0,1)===`(`?EL(e.substr(1,e.length-2)):EL(e):e}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this instanceof nR==1?EL(p.substr(1,p.length-1)):p},set:function(e){e=e.toString(),p=this instanceof nR==1?`/`+DL(e):e}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?`/Annot`:null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?`/Widget`:null}});var m,h=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return h},set:function(e){e=!!e,h=e}}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,get:function(){if(m)return m},set:function(e){m=e}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,1)},set:function(e){this.Ff=!!e==1?LL(this.Ff,1):RL(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,2)},set:function(e){this.Ff=!!e==1?LL(this.Ff,2):RL(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,3)},set:function(e){this.Ff=!!e==1?LL(this.Ff,3):RL(this.Ff,3)}});var g=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(g!==null)return g},set:function(e){if([0,1,2].indexOf(e)===-1)throw Error(`Invalid value "`+e+`" for attribute Q supplied.`);g=e}}),Object.defineProperty(this,"textAlign",{get:function(){var e;switch(g){case 0:default:e=`left`;break;case 1:e=`center`;break;case 2:e=`right`}return e},configurable:!0,enumerable:!0,set:function(e){switch(e){case`right`:case 2:g=2;break;case`center`:case 1:g=1;break;default:g=0}}})};AL(ZL,JL);var QL=function(){ZL.call(this),this.FT=`/Ch`,this.V=`()`,this.fontName=`zapfdingbats`;var e=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return e},set:function(t){e=t}});var t=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return KL(t,this.objId,this.scope)},set:function(e){var n,r=[];typeof(n=e)==`string`&&(r=function(e,t,n){n||=1;for(var r,i=[];r=t.exec(e);)i.push(r[n]);return i}(n,/\((.*?)\)/g)),t=r}}),this.getOptions=function(){return t},this.setOptions=function(e){t=e,this.sort&&t.sort()},this.addOption=function(e){e=(e||=``).toString(),t.push(e),this.sort&&t.sort()},this.removeOption=function(e,n){for(n||=!1,e=(e||=``).toString();t.indexOf(e)!==-1&&(t.splice(t.indexOf(e),1),!1!==n););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,18)},set:function(e){this.Ff=!!e==1?LL(this.Ff,18):RL(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,19)},set:function(e){!0===this.combo&&(this.Ff=!!e==1?LL(this.Ff,19):RL(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,20)},set:function(e){!!e==1?(this.Ff=LL(this.Ff,20),t.sort()):this.Ff=RL(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,22)},set:function(e){this.Ff=!!e==1?LL(this.Ff,22):RL(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,23)},set:function(e){this.Ff=!!e==1?LL(this.Ff,23):RL(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,27)},set:function(e){this.Ff=!!e==1?LL(this.Ff,27):RL(this.Ff,27)}}),this.hasAppearanceStream=!1};AL(QL,ZL);var $L=function(){QL.call(this),this.fontName=`helvetica`,this.combo=!1};AL($L,QL);var eR=function(){$L.call(this),this.combo=!0};AL(eR,$L);var tR=function(){eR.call(this),this.edit=!0};AL(tR,eR);var nR=function(){ZL.call(this),this.FT=`/Btn`,Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,15)},set:function(e){this.Ff=!!e==1?LL(this.Ff,15):RL(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,16)},set:function(e){this.Ff=!!e==1?LL(this.Ff,16):RL(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,17)},set:function(e){this.Ff=!!e==1?LL(this.Ff,17):RL(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,26)},set:function(e){this.Ff=!!e==1?LL(this.Ff,26):RL(this.Ff,26)}});var e,t={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var e=function(e){return e};if(this.scope&&(e=this.scope.internal.getEncryptor(this.objId)),Object.keys(t).length!==0){var n,r=[];for(n in r.push(`<<`),t)r.push(`/`+n+` (`+TL(e(t[n]))+`)`);return r.push(`>>`),r.join(`
`)}},set:function(e){Pi(e)===`object`&&(t=e)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return t.CA||``},set:function(e){typeof e==`string`&&(t.CA=e)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){var n=t==null?``:t.toString();n.substr(0,1)===`/`&&(n=n.substr(1)),e=`/`+DL(n)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return e.substr(1,e.length-1)},set:function(t){e=`/`+DL(t)}})};AL(nR,ZL);var rR=function(){nR.call(this),this.pushButton=!0};AL(rR,nR);var iR=function(){nR.call(this),this.radio=!0,this.pushButton=!1;var e=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t===void 0?[]:t}})};AL(iR,nR);var aR=function(){var e,t;ZL.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return t},set:function(e){t=e}});var n,r={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var e=function(e){return e};this.scope&&(e=this.scope.internal.getEncryptor(this.objId));var t,n=[];for(t in n.push(`<<`),r)n.push(`/`+t+` (`+TL(e(r[t]))+`)`);return n.push(`>>`),n.join(`
`)},set:function(e){Pi(e)===`object`&&(r=e)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return r.CA||``},set:function(e){typeof e==`string`&&(r.CA=e)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return n},set:function(e){var t=e==null?``:e.toString();t.substr(0,1)===`/`&&(t=t.substr(1)),n=`/`+DL(t)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return n.substr(1,n.length-1)},set:function(e){var t=e==null?``:e.toString();t.substr(0,1)===`/`&&(t=t.substr(1)),n=`/`+DL(t)}}),this.caption=`l`,this.appearanceState=`Off`,this._AppearanceType=lR.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};AL(aR,ZL),iR.prototype.setAppearance=function(e){if(!(`createAppearanceStream`in e)||!(`getCA`in e))throw Error(`Couldn't assign Appearance to RadioButton. Appearance was Invalid!`);for(var t in this.Kids)if(this.Kids.hasOwnProperty(t)){var n=this.Kids[t];n.appearanceStreamContent=e.createAppearanceStream(n.optionName),n.caption=e.getCA()}},iR.prototype.createOption=function(e){var t=new aR;return t.Parent=this,t.optionName=e,this.Kids.push(t),uR.call(this.scope,t),t};var oR=function(){nR.call(this),this.fontName=`zapfdingbats`,this.caption=`3`,this.appearanceState=`On`,this.value=`On`,this.textAlign=`center`,this.appearanceStreamContent=lR.CheckBox.createAppearanceStream()};AL(oR,nR);var sR=function(){ZL.call(this),this.FT=`/Tx`,Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,13)},set:function(e){this.Ff=!!e==1?LL(this.Ff,13):RL(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,21)},set:function(e){this.Ff=!!e==1?LL(this.Ff,21):RL(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,23)},set:function(e){this.Ff=!!e==1?LL(this.Ff,23):RL(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,24)},set:function(e){this.Ff=!!e==1?LL(this.Ff,24):RL(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,25)},set:function(e){this.Ff=!!e==1?LL(this.Ff,25):RL(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,26)},set:function(e){this.Ff=!!e==1?LL(this.Ff,26):RL(this.Ff,26)}});var e=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return e},set:function(t){Number.isInteger(t)&&(e=t)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};AL(sR,ZL);var cR=function(){sR.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!IL(this.Ff,14)},set:function(e){this.Ff=!!e==1?LL(this.Ff,14):RL(this.Ff,14)}}),this.password=!0};AL(cR,sR);var lR={CheckBox:{createAppearanceStream:function(){return{N:{On:lR.CheckBox.YesNormal},D:{On:lR.CheckBox.YesPushDown,Off:lR.CheckBox.OffPushDown}}},YesPushDown:function(e){var t=ML(e);t.scope=e.scope;var n=[],r=e.scope.internal.getFont(e.fontName,e.fontStyle).id,i=e.scope.__private__.encodeColorString(e.color),a=VL(e,e.caption);return n.push(`0.749023 g`),n.push(`0 0 `+OL(lR.internal.getWidth(e))+` `+OL(lR.internal.getHeight(e))+` re`),n.push(`f`),n.push(`BMC`),n.push(`q`),n.push(`0 0 1 rg`),n.push(`/`+r+` `+OL(a.fontSize)+` Tf `+i),n.push(`BT`),n.push(a.text),n.push(`ET`),n.push(`Q`),n.push(`EMC`),t.stream=n.join(`
`),t},YesNormal:function(e){var t=ML(e);t.scope=e.scope;var n=e.scope.internal.getFont(e.fontName,e.fontStyle).id,r=e.scope.__private__.encodeColorString(e.color),i=[],a=lR.internal.getHeight(e),o=lR.internal.getWidth(e),s=VL(e,e.caption);return i.push(`1 g`),i.push(`0 0 `+OL(o)+` `+OL(a)+` re`),i.push(`f`),i.push(`q`),i.push(`0 0 1 rg`),i.push(`0 0 `+OL(o-1)+` `+OL(a-1)+` re`),i.push(`W`),i.push(`n`),i.push(`0 g`),i.push(`BT`),i.push(`/`+n+` `+OL(s.fontSize)+` Tf `+r),i.push(s.text),i.push(`ET`),i.push(`Q`),t.stream=i.join(`
`),t},OffPushDown:function(e){var t=ML(e);t.scope=e.scope;var n=[];return n.push(`0.749023 g`),n.push(`0 0 `+OL(lR.internal.getWidth(e))+` `+OL(lR.internal.getHeight(e))+` re`),n.push(`f`),t.stream=n.join(`
`),t}},RadioButton:{Circle:{createAppearanceStream:function(e){var t={D:{Off:lR.RadioButton.Circle.OffPushDown},N:{}};return t.N[e]=lR.RadioButton.Circle.YesNormal,t.D[e]=lR.RadioButton.Circle.YesPushDown,t},getCA:function(){return`l`},YesNormal:function(e){var t=ML(e);t.scope=e.scope;var n=[],r=lR.internal.getWidth(e)<=lR.internal.getHeight(e)?lR.internal.getWidth(e)/4:lR.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var i=lR.internal.Bezier_C,a=Number((r*i).toFixed(5));return n.push(`q`),n.push(`1 0 0 1 `+kL(lR.internal.getWidth(e)/2)+` `+kL(lR.internal.getHeight(e)/2)+` cm`),n.push(r+` 0 m`),n.push(r+` `+a+` `+a+` `+r+` 0 `+r+` c`),n.push(`-`+a+` `+r+` -`+r+` `+a+` -`+r+` 0 c`),n.push(`-`+r+` -`+a+` -`+a+` -`+r+` 0 -`+r+` c`),n.push(a+` -`+r+` `+r+` -`+a+` `+r+` 0 c`),n.push(`f`),n.push(`Q`),t.stream=n.join(`
`),t},YesPushDown:function(e){var t=ML(e);t.scope=e.scope;var n=[],r=lR.internal.getWidth(e)<=lR.internal.getHeight(e)?lR.internal.getWidth(e)/4:lR.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),a=Number((i*lR.internal.Bezier_C).toFixed(5)),o=Number((r*lR.internal.Bezier_C).toFixed(5));return n.push(`0.749023 g`),n.push(`q`),n.push(`1 0 0 1 `+kL(lR.internal.getWidth(e)/2)+` `+kL(lR.internal.getHeight(e)/2)+` cm`),n.push(i+` 0 m`),n.push(i+` `+a+` `+a+` `+i+` 0 `+i+` c`),n.push(`-`+a+` `+i+` -`+i+` `+a+` -`+i+` 0 c`),n.push(`-`+i+` -`+a+` -`+a+` -`+i+` 0 -`+i+` c`),n.push(a+` -`+i+` `+i+` -`+a+` `+i+` 0 c`),n.push(`f`),n.push(`Q`),n.push(`0 g`),n.push(`q`),n.push(`1 0 0 1 `+kL(lR.internal.getWidth(e)/2)+` `+kL(lR.internal.getHeight(e)/2)+` cm`),n.push(r+` 0 m`),n.push(r+` `+o+` `+o+` `+r+` 0 `+r+` c`),n.push(`-`+o+` `+r+` -`+r+` `+o+` -`+r+` 0 c`),n.push(`-`+r+` -`+o+` -`+o+` -`+r+` 0 -`+r+` c`),n.push(o+` -`+r+` `+r+` -`+o+` `+r+` 0 c`),n.push(`f`),n.push(`Q`),t.stream=n.join(`
`),t},OffPushDown:function(e){var t=ML(e);t.scope=e.scope;var n=[],r=lR.internal.getWidth(e)<=lR.internal.getHeight(e)?lR.internal.getWidth(e)/4:lR.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),a=Number((i*lR.internal.Bezier_C).toFixed(5));return n.push(`0.749023 g`),n.push(`q`),n.push(`1 0 0 1 `+kL(lR.internal.getWidth(e)/2)+` `+kL(lR.internal.getHeight(e)/2)+` cm`),n.push(i+` 0 m`),n.push(i+` `+a+` `+a+` `+i+` 0 `+i+` c`),n.push(`-`+a+` `+i+` -`+i+` `+a+` -`+i+` 0 c`),n.push(`-`+i+` -`+a+` -`+a+` -`+i+` 0 -`+i+` c`),n.push(a+` -`+i+` `+i+` -`+a+` `+i+` 0 c`),n.push(`f`),n.push(`Q`),t.stream=n.join(`
`),t}},Cross:{createAppearanceStream:function(e){var t={D:{Off:lR.RadioButton.Cross.OffPushDown},N:{}};return t.N[e]=lR.RadioButton.Cross.YesNormal,t.D[e]=lR.RadioButton.Cross.YesPushDown,t},getCA:function(){return`8`},YesNormal:function(e){var t=ML(e);t.scope=e.scope;var n=[],r=lR.internal.calculateCross(e);return n.push(`q`),n.push(`1 1 `+OL(lR.internal.getWidth(e)-2)+` `+OL(lR.internal.getHeight(e)-2)+` re`),n.push(`W`),n.push(`n`),n.push(OL(r.x1.x)+` `+OL(r.x1.y)+` m`),n.push(OL(r.x2.x)+` `+OL(r.x2.y)+` l`),n.push(OL(r.x4.x)+` `+OL(r.x4.y)+` m`),n.push(OL(r.x3.x)+` `+OL(r.x3.y)+` l`),n.push(`s`),n.push(`Q`),t.stream=n.join(`
`),t},YesPushDown:function(e){var t=ML(e);t.scope=e.scope;var n=lR.internal.calculateCross(e),r=[];return r.push(`0.749023 g`),r.push(`0 0 `+OL(lR.internal.getWidth(e))+` `+OL(lR.internal.getHeight(e))+` re`),r.push(`f`),r.push(`q`),r.push(`1 1 `+OL(lR.internal.getWidth(e)-2)+` `+OL(lR.internal.getHeight(e)-2)+` re`),r.push(`W`),r.push(`n`),r.push(OL(n.x1.x)+` `+OL(n.x1.y)+` m`),r.push(OL(n.x2.x)+` `+OL(n.x2.y)+` l`),r.push(OL(n.x4.x)+` `+OL(n.x4.y)+` m`),r.push(OL(n.x3.x)+` `+OL(n.x3.y)+` l`),r.push(`s`),r.push(`Q`),t.stream=r.join(`
`),t},OffPushDown:function(e){var t=ML(e);t.scope=e.scope;var n=[];return n.push(`0.749023 g`),n.push(`0 0 `+OL(lR.internal.getWidth(e))+` `+OL(lR.internal.getHeight(e))+` re`),n.push(`f`),t.stream=n.join(`
`),t}}},createDefaultAppearanceStream:function(e){var t=e.scope.internal.getFont(e.fontName,e.fontStyle).id,n=e.scope.__private__.encodeColorString(e.color);return`/`+t+` `+e.fontSize+` Tf `+n}};lR.internal={Bezier_C:.551915024494,calculateCross:function(e){var t=lR.internal.getWidth(e),n=lR.internal.getHeight(e),r=Math.min(t,n);return{x1:{x:(t-r)/2,y:(n-r)/2+r},x2:{x:(t-r)/2+r,y:(n-r)/2},x3:{x:(t-r)/2,y:(n-r)/2},x4:{x:(t-r)/2+r,y:(n-r)/2+r}}}},lR.internal.getWidth=function(e){var t=0;return Pi(e)===`object`&&(t=jL(e.Rect[2])),t},lR.internal.getHeight=function(e){var t=0;return Pi(e)===`object`&&(t=jL(e.Rect[3])),t};var uR=CL.addField=function(e){if(GL(this,e),!(e instanceof ZL))throw Error(`Invalid argument passed to jsPDF.addField.`);var t;return(t=e).scope.internal.acroformPlugin.printedOut&&(t.scope.internal.acroformPlugin.printedOut=!1,t.scope.internal.acroformPlugin.acroFormDictionaryRoot=null),t.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(t),e.page=e.scope.internal.getCurrentPageInfo().pageNumber,this};CL.AcroFormChoiceField=QL,CL.AcroFormListBox=$L,CL.AcroFormComboBox=eR,CL.AcroFormEditBox=tR,CL.AcroFormButton=nR,CL.AcroFormPushButton=rR,CL.AcroFormRadioButton=iR,CL.AcroFormCheckBox=oR,CL.AcroFormTextField=sR,CL.AcroFormPasswordField=cR,CL.AcroFormAppearance=lR,CL.AcroForm={ChoiceField:QL,ListBox:$L,ComboBox:eR,EditBox:tR,Button:nR,PushButton:rR,RadioButton:iR,CheckBox:oR,TextField:sR,PasswordField:cR,Appearance:lR},SL.AcroForm={ChoiceField:QL,ListBox:$L,ComboBox:eR,EditBox:tR,Button:nR,PushButton:rR,RadioButton:iR,CheckBox:oR,TextField:sR,PasswordField:cR,Appearance:lR},SL.AcroForm;function dR(e){return e.reduce(function(e,t,n){return e[t]=n,e},{})}(function(e){e.__addimage__={};var t=`UNKNOWN`,n={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},r=e.__addimage__.getImageFileTypeByImageData=function(e,r){var i,a,o,s,c,l=t;if((r||=t)===`RGBA`||e.data!==void 0&&e.data instanceof Uint8ClampedArray&&`height`in e&&`width`in e)return`RGBA`;if(x(e))for(c in n)for(o=n[c],i=0;i<o.length;i+=1){for(s=!0,a=0;a<o[i].length;a+=1)if(o[i][a]!==void 0&&o[i][a]!==e[a]){s=!1;break}if(!0===s){l=c;break}}else for(c in n)for(o=n[c],i=0;i<o.length;i+=1){for(s=!0,a=0;a<o[i].length;a+=1)if(o[i][a]!==void 0&&o[i][a]!==e.charCodeAt(a)){s=!1;break}if(!0===s){l=c;break}}return l===t&&r!==t&&(l=r),l},i=function e(t){for(var n=this.internal.write,r=this.internal.putStream,i=(0,this.internal.getFilters)();i.indexOf(`FlateEncode`)!==-1;)i.splice(i.indexOf(`FlateEncode`),1);t.objectId=this.internal.newObject();var a=[];if(a.push({key:`Type`,value:`/XObject`}),a.push({key:`Subtype`,value:`/Image`}),a.push({key:`Width`,value:t.width}),a.push({key:`Height`,value:t.height}),t.colorSpace===g.INDEXED?a.push({key:`ColorSpace`,value:`[/Indexed /DeviceRGB `+(t.palette.length/3-1)+` `+(`sMask`in t&&t.sMask!==void 0?t.objectId+2:t.objectId+1)+` 0 R]`}):(a.push({key:`ColorSpace`,value:`/`+t.colorSpace}),t.colorSpace===g.DEVICE_CMYK&&a.push({key:`Decode`,value:`[1 0 1 0 1 0 1 0]`})),a.push({key:`BitsPerComponent`,value:t.bitsPerComponent}),`decodeParameters`in t&&t.decodeParameters!==void 0&&a.push({key:`DecodeParms`,value:`<<`+t.decodeParameters+`>>`}),`transparency`in t&&Array.isArray(t.transparency)&&t.transparency.length>0){for(var o=``,s=0,c=t.transparency.length;s<c;s++)o+=t.transparency[s]+` `+t.transparency[s]+` `;a.push({key:`Mask`,value:`[`+o+`]`})}t.sMask!==void 0&&a.push({key:`SMask`,value:t.objectId+1+` 0 R`});var l=t.filter===void 0?void 0:[`/`+t.filter];if(r({data:t.data,additionalKeyValues:a,alreadyAppliedFilters:l,objectId:t.objectId}),n(`endobj`),`sMask`in t&&t.sMask!==void 0){var u=t.sMaskBitsPerComponent??t.bitsPerComponent,d={width:t.width,height:t.height,colorSpace:`DeviceGray`,bitsPerComponent:u,data:t.sMask};`filter`in t&&(d.decodeParameters=`/Predictor ${t.predictor} /Colors 1 /BitsPerComponent ${u} /Columns ${t.width}`,d.filter=t.filter),e.call(this,d)}if(t.colorSpace===g.INDEXED){var f=this.internal.newObject();r({data:C(new Uint8Array(t.palette)),objectId:f}),n(`endobj`)}},a=function(){var e=this.internal.collections.addImage_images;for(var t in e)i.call(this,e[t])},o=function(){var e,t=this.internal.collections.addImage_images,n=this.internal.write;for(var r in t)n(`/I`+(e=t[r]).index,e.objectId,`0`,`R`)},s=function(){this.internal.collections.addImage_images||(this.internal.collections.addImage_images={},this.internal.events.subscribe(`putResources`,a),this.internal.events.subscribe(`putXobjectDict`,o))},c=function(){var e=this.internal.collections.addImage_images;return s.call(this),e},l=function(){return Object.keys(this.internal.collections.addImage_images).length},u=function(t){return typeof e[`process`+t.toUpperCase()]==`function`},d=function(e){return Pi(e)===`object`&&e.nodeType===1},f=function(t,n){if(t.nodeName===`IMG`&&t.hasAttribute(`src`)){var r=``+t.getAttribute(`src`);if(r.indexOf(`data:image/`)===0)return ZI(unescape(r).split(`base64,`).pop());var i=e.loadFile(r,!0);if(i!==void 0)return i}if(t.nodeName===`CANVAS`){if(t.width===0||t.height===0)throw Error(`Given canvas must have data. Canvas width: `+t.width+`, height: `+t.height);var a;switch(n){case`PNG`:a=`image/png`;break;case`WEBP`:a=`image/webp`;break;default:a=`image/jpeg`}return ZI(t.toDataURL(a,1).split(`base64,`).pop())}},p=function(e){var t=this.internal.collections.addImage_images;if(t){for(var n in t)if(e===t[n].alias)return t[n]}},m=function(e,t,n){return e||t||(e=-96,t=-96),e<0&&(e=-1*n.width*72/e/this.internal.scaleFactor),t<0&&(t=-1*n.height*72/t/this.internal.scaleFactor),e===0&&(e=t*n.width/n.height),t===0&&(t=e*n.height/n.width),[e,t]},h=function(e,t,n,r,i,a){var o=m.call(this,n,r,i),s=this.internal.getCoordinateString,l=this.internal.getVerticalCoordinateString,u=c.call(this);if(n=o[0],r=o[1],u[i.index]=i,a){a*=Math.PI/180;var d=Math.cos(a),f=Math.sin(a),p=function(e){return e.toFixed(4)},h=[p(d),p(f),p(-1*f),p(d),0,0,`cm`]}this.internal.write(`q`),a?(this.internal.write([1,`0`,`0`,1,s(e),l(t+r),`cm`].join(` `)),this.internal.write(h.join(` `)),this.internal.write([s(n),`0`,`0`,s(r),`0`,`0`,`cm`].join(` `))):this.internal.write([s(n),`0`,`0`,s(r),s(e),l(t+r),`cm`].join(` `)),this.isAdvancedAPI()&&this.internal.write([1,0,0,-1,0,0,`cm`].join(` `)),this.internal.write(`/I`+i.index+` Do`),this.internal.write(`Q`)},g=e.color_spaces={DEVICE_RGB:`DeviceRGB`,DEVICE_GRAY:`DeviceGray`,DEVICE_CMYK:`DeviceCMYK`,CAL_GREY:`CalGray`,CAL_RGB:`CalRGB`,LAB:`Lab`,ICC_BASED:`ICCBased`,INDEXED:`Indexed`,PATTERN:`Pattern`,SEPARATION:`Separation`,DEVICE_N:`DeviceN`};e.decode={DCT_DECODE:`DCTDecode`,FLATE_DECODE:`FlateDecode`,LZW_DECODE:`LZWDecode`,JPX_DECODE:`JPXDecode`,JBIG2_DECODE:`JBIG2Decode`,ASCII85_DECODE:`ASCII85Decode`,ASCII_HEX_DECODE:`ASCIIHexDecode`,RUN_LENGTH_DECODE:`RunLengthDecode`,CCITT_FAX_DECODE:`CCITTFaxDecode`};var _=e.image_compression={NONE:`NONE`,FAST:`FAST`,MEDIUM:`MEDIUM`,SLOW:`SLOW`},v=e.__addimage__.sHashCode=function(e){var t,n,r=0;if(typeof e==`string`)for(n=e.length,t=0;t<n;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;else if(x(e))for(n=e.byteLength/2,t=0;t<n;t++)r=(r<<5)-r+e[t],r|=0;return r},y=e.__addimage__.validateStringAsBase64=function(e){(e||=``).toString().trim();var t=!0;return e.length===0&&(t=!1),e.length%4!=0&&(t=!1),!1===/^[A-Za-z0-9+/]+$/.test(e.substr(0,e.length-2))&&(t=!1),!1===/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(e.substr(-2))&&(t=!1),t},b=e.__addimage__.extractImageFromDataUrl=function(e){if(e==null||!(e=e.trim()).startsWith(`data:`))return null;var t=e.indexOf(`,`);return t<0?null:e.substring(0,t).trim().endsWith(`base64`)?e.substring(t+1):null};e.__addimage__.isArrayBuffer=function(e){return e instanceof ArrayBuffer};var x=e.__addimage__.isArrayBufferView=function(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array},S=e.__addimage__.binaryStringToUint8Array=function(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n},C=e.__addimage__.arrayBufferToBinaryString=function(e){for(var t=``,n=x(e)?e:new Uint8Array(e),r=0;r<n.length;r+=8192)t+=String.fromCharCode.apply(null,n.subarray(r,r+8192));return t};e.addImage=function(){var e,n,r,i,a,o,c,l,u;if(typeof arguments[1]==`number`?(n=t,r=arguments[1],i=arguments[2],a=arguments[3],o=arguments[4],c=arguments[5],l=arguments[6],u=arguments[7]):(n=arguments[1],r=arguments[2],i=arguments[3],a=arguments[4],o=arguments[5],c=arguments[6],l=arguments[7],u=arguments[8]),Pi(e=arguments[0])===`object`&&!d(e)&&`imageData`in e){var f=e;e=f.imageData,n=f.format||n||t,r=f.x||r||0,i=f.y||i||0,a=f.w||f.width||a,o=f.h||f.height||o,c=f.alias||c,l=f.compression||l,u=f.rotation||f.angle||u}var p=this.internal.getFilters();if(l===void 0&&p.indexOf(`FlateEncode`)!==-1&&(l=`SLOW`),isNaN(r)||isNaN(i))throw Error(`Invalid coordinates passed to jsPDF.addImage`);s.call(this);var m=w.call(this,e,n,c,l);return h.call(this,r,i,a,o,m,u),this};var w=function(n,i,a,o){var s,c,m;if(typeof n==`string`&&r(n)===t){n=unescape(n);var h=T(n,!1);(h!==``||(h=e.loadFile(n,!0))!==void 0)&&(n=h)}if(d(n)&&(n=f(n,i)),i=r(n,i),!u(i))throw Error(`addImage does not support files of type '`+i+`', please ensure that a plugin for '`+i+`' support is added.`);if(((m=a)==null||m.length===0)&&(a=function(e){return typeof e==`string`||x(e)?v(e):x(e.data)?v(e.data):null}(n)),(s=p.call(this,a))||(n instanceof Uint8Array||i===`RGBA`||(c=n,n=S(n)),s=this[`process`+i.toUpperCase()](n,l.call(this),a,function(t){return t&&typeof t==`string`&&(t=t.toUpperCase()),t in e.image_compression?t:_.NONE}(o),c)),!s)throw Error(`An unknown error occurred whilst processing the image.`);return s},T=e.__addimage__.convertBase64ToBinaryString=function(e,t){t=typeof t!=`boolean`||t;var n,r=``;if(typeof e==`string`){n=b(e)??e;try{r=ZI(n)}catch(e){if(t)throw y(n)?Error(`atob-Error in jsPDF.convertBase64ToBinaryString `+e.message):Error(`Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString `)}}return r};e.getImageProperties=function(n){var i,a,o=``;if(d(n)&&(n=f(n)),typeof n==`string`&&r(n)===t&&((o=T(n,!1))===``&&(o=e.loadFile(n)||``),n=o),a=r(n),!u(a))throw Error(`addImage does not support files of type '`+a+`', please ensure that a plugin for '`+a+`' support is added.`);if(n instanceof Uint8Array||(n=S(n)),!(i=this[`process`+a.toUpperCase()](n)))throw Error(`An unknown error occurred whilst processing the image`);return i.fileType=a,i}})(SL.API),function(e){var t=function(e){if(e!==void 0&&e!=``)return!0};SL.API.events.push([`addPage`,function(e){this.internal.getPageInfo(e.pageNumber).pageContext.annotations=[]}]),e.events.push([`putPage`,function(e){for(var n,r,i,a=this.internal.getCoordinateString,o=this.internal.getVerticalCoordinateString,s=this.internal.getPageInfoByObjId(e.objId),c=e.pageContext.annotations,l=!1,u=0;u<c.length&&!l;u++)switch((n=c[u]).type){case`link`:(t(n.options.url)||t(n.options.pageNumber))&&(l=!0);break;case`reference`:case`text`:case`freetext`:l=!0}if(l!=0){this.internal.write(`/Annots [`);for(var d=0;d<c.length;d++){n=c[d];var f=this.internal.pdfEscape,p=this.internal.getEncryptor(e.objId);switch(n.type){case`reference`:this.internal.write(` `+n.object.objId+` 0 R `);break;case`text`:var m=this.internal.newAdditionalObject(),h=this.internal.newAdditionalObject(),g=this.internal.getEncryptor(m.objId),_=n.title||`Note`;i=`<</Type /Annot /Subtype /Text `+(r=`/Rect [`+a(n.bounds.x)+` `+o(n.bounds.y+n.bounds.h)+` `+a(n.bounds.x+n.bounds.w)+` `+o(n.bounds.y)+`] `)+`/Contents (`+f(g(n.contents))+`)`,i+=` /Popup `+h.objId+` 0 R`,i+=` /P `+s.objId+` 0 R`,i+=` /T (`+f(g(_))+`) >>`,m.content=i;var v=m.objId+` 0 R`;i=`<</Type /Annot /Subtype /Popup `+(r=`/Rect [`+a(n.bounds.x+30)+` `+o(n.bounds.y+n.bounds.h)+` `+a(n.bounds.x+n.bounds.w+30)+` `+o(n.bounds.y)+`] `)+` /Parent `+v,n.open&&(i+=` /Open true`),i+=` >>`,h.content=i,this.internal.write(m.objId,`0 R`,h.objId,`0 R`);break;case`freetext`:r=`/Rect [`+a(n.bounds.x)+` `+o(n.bounds.y)+` `+a(n.bounds.x+n.bounds.w)+` `+o(n.bounds.y+n.bounds.h)+`] `;var y=`font: Helvetica,sans-serif 12.0pt; text-align:left; color:#`+(n.color||`#000000`);i=`<</Type /Annot /Subtype /FreeText `+r+`/Contents (`+f(p(n.contents))+`)`,i+=` /DS(`+f(p(y))+`)`,i+=` /Border [0 0 0]`,i+=` >>`,this.internal.write(i);break;case`link`:if(n.options.name){var b=this.annotations._nameMap[n.options.name];n.options.pageNumber=b.page,n.options.top=b.y}else n.options.top||(n.options.top=0);if(r=`/Rect [`+n.finalBounds.x+` `+n.finalBounds.y+` `+n.finalBounds.w+` `+n.finalBounds.h+`] `,i=``,n.options.url)i=`<</Type /Annot /Subtype /Link `+r+`/Border [0 0 0] /A <</S /URI /URI (`+f(p(n.options.url))+`) >>`;else if(n.options.pageNumber)switch(i=`<</Type /Annot /Subtype /Link `+r+`/Border [0 0 0] /Dest [`+this.internal.getPageInfo(n.options.pageNumber).objId+` 0 R`,n.options.magFactor=n.options.magFactor||`XYZ`,n.options.magFactor){case`Fit`:i+=` /Fit]`;break;case`FitH`:i+=` /FitH `+n.options.top+`]`;break;case`FitV`:n.options.left=n.options.left||0,i+=` /FitV `+n.options.left+`]`;break;default:var x=o(n.options.top);n.options.left=n.options.left||0,n.options.zoom===void 0&&(n.options.zoom=0),i+=` /XYZ `+n.options.left+` `+x+` `+n.options.zoom+`]`}i!=``&&(i+=` >>`,this.internal.write(i))}}this.internal.write(`]`)}}]),e.createAnnotation=function(e){var t=this.internal.getCurrentPageInfo();switch(e.type){case`link`:this.link(e.bounds.x,e.bounds.y,e.bounds.w,e.bounds.h,e);break;case`text`:case`freetext`:t.pageContext.annotations.push(e)}},e.link=function(e,t,n,r,i){var a=this.internal.getCurrentPageInfo(),o=this.internal.getCoordinateString,s=this.internal.getVerticalCoordinateString;a.pageContext.annotations.push({finalBounds:{x:o(e),y:s(t),w:o(e+n),h:s(t+r)},options:i,type:`link`})},e.textWithLink=function(e,t,n,r){var i,a,o=this.getTextWidth(e),s=this.internal.getLineHeight()/this.internal.scaleFactor;if(r.maxWidth!==void 0){a=r.maxWidth;var c=this.splitTextToSize(e,a).length;i=Math.ceil(s*c)}else a=o,i=s;return this.text(e,t,n,r),n+=.2*s,r.align===`center`&&(t-=o/2),r.align===`right`&&(t-=o),this.link(t,n-s,a,i,r),o},e.getTextWidth=function(e){var t=this.internal.getFontSize();return this.getStringUnitWidth(e)*t/this.internal.scaleFactor}}(SL.API),function(e){var t={1569:[65152],1570:[65153,65154],1571:[65155,65156],1572:[65157,65158],1573:[65159,65160],1574:[65161,65162,65163,65164],1575:[65165,65166],1576:[65167,65168,65169,65170],1577:[65171,65172],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194],1584:[65195,65196],1585:[65197,65198],1586:[65199,65200],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1649:[64336,64337],1655:[64477],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393],1676:[64388,64389],1677:[64386,64387],1678:[64390,64391],1681:[64396,64397],1688:[64394,64395],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421],1729:[64422,64423,64424,64425],1733:[64480,64481],1734:[64473,64474],1735:[64471,64472],1736:[64475,64476],1737:[64482,64483],1739:[64478,64479],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431],1747:[64432,64433]},n={65247:{65154:65269,65156:65271,65160:65273,65166:65275},65248:{65154:65270,65156:65272,65160:65274,65166:65276},65165:{65247:{65248:{65258:65010}}},1617:{1612:64606,1613:64607,1614:64608,1615:64609,1616:64610}},r={1612:64606,1613:64607,1614:64608,1615:64609,1616:64610},i=[1570,1571,1573,1575];e.__arabicParser__={};var a=e.__arabicParser__.isInArabicSubstitutionA=function(e){return t[e.charCodeAt(0)]!==void 0},o=e.__arabicParser__.isArabicLetter=function(e){return typeof e==`string`&&/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(e)},s=e.__arabicParser__.isArabicEndLetter=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length<=2},c=e.__arabicParser__.isArabicAlfLetter=function(e){return o(e)&&i.indexOf(e.charCodeAt(0))>=0};e.__arabicParser__.arabicLetterHasIsolatedForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length>=1};var l=e.__arabicParser__.arabicLetterHasFinalForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length>=2};e.__arabicParser__.arabicLetterHasInitialForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length>=3};var u=e.__arabicParser__.arabicLetterHasMedialForm=function(e){return o(e)&&a(e)&&t[e.charCodeAt(0)].length==4},d=e.__arabicParser__.resolveLigatures=function(e){var t=0,r=n,i=``,a=0;for(t=0;t<e.length;t+=1)r[e.charCodeAt(t)]===void 0?(r=n,i+=e.charAt(t-a),t-=a,a=0):(a++,typeof(r=r[e.charCodeAt(t)])==`number`&&(i+=String.fromCharCode(r),r=n,a=0),t===e.length-1&&(r=n,i+=e.charAt(t-(a-1)),t-=a-1,a=0));return i};e.__arabicParser__.isArabicDiacritic=function(e){return e!==void 0&&r[e.charCodeAt(0)]!==void 0};var f=e.__arabicParser__.getCorrectForm=function(e,t,n){return o(e)?!1===a(e)?-1:!l(e)||!o(t)&&!o(n)||!o(n)&&s(t)||s(e)&&!o(t)||s(e)&&c(t)||s(e)&&s(t)?0:u(e)&&o(t)&&!s(t)&&o(n)&&l(n)?3:s(e)||!o(n)?1:2:-1},p=function(e){var n=0,r=0,i=0,a=``,s=``,c=``,l=(e||=``).split(`\\s+`),u=[];for(n=0;n<l.length;n+=1){for(u.push(``),r=0;r<l[n].length;r+=1)a=l[n][r],s=l[n][r-1],c=l[n][r+1],o(a)?(i=f(a,s,c),u[n]+=i===-1?a:String.fromCharCode(t[a.charCodeAt(0)][i])):u[n]+=a;u[n]=d(u[n])}return u.join(` `)},m=e.__arabicParser__.processArabic=e.processArabic=function(){var e,t=typeof arguments[0]==`string`?arguments[0]:arguments[0].text,n=[];if(Array.isArray(t)){var r=0;for(n=[],r=0;r<t.length;r+=1)Array.isArray(t[r])?n.push([p(t[r][0]),t[r][1],t[r][2]]):n.push([p(t[r])]);e=n}else e=p(t);return typeof arguments[0]==`string`?e:(arguments[0].text=e,arguments[0])};e.events.push([`preProcessText`,m])}(SL.API),SL.API.autoPrint=function(e){var t;return(e||={}).variant=e.variant||`non-conform`,e.variant===`javascript`?this.addJS(`print({});`):(this.internal.events.subscribe(`postPutResources`,function(){t=this.internal.newObject(),this.internal.out(`<<`),this.internal.out(`/S /Named`),this.internal.out(`/Type /Action`),this.internal.out(`/N /Print`),this.internal.out(`>>`),this.internal.out(`endobj`)}),this.internal.events.subscribe(`putCatalog`,function(){this.internal.out(`/OpenAction `+t+` 0 R`)})),this},function(e){var t=function(){var e=void 0;Object.defineProperty(this,"pdf",{get:function(){return e},set:function(t){e=t}});var t=150;Object.defineProperty(this,"width",{get:function(){return t},set:function(e){t=isNaN(e)||!1===Number.isInteger(e)||e<0?150:e,this.getContext(`2d`).pageWrapXEnabled&&(this.getContext(`2d`).pageWrapX=t+1)}});var n=300;Object.defineProperty(this,"height",{get:function(){return n},set:function(e){n=isNaN(e)||!1===Number.isInteger(e)||e<0?300:e,this.getContext(`2d`).pageWrapYEnabled&&(this.getContext(`2d`).pageWrapY=n+1)}});var r=[];Object.defineProperty(this,"childNodes",{get:function(){return r},set:function(e){r=e}});var i={};Object.defineProperty(this,"style",{get:function(){return i},set:function(e){i=e}}),Object.defineProperty(this,"parentNode",{})};t.prototype.getContext=function(e,t){var n;if((e||=`2d`)!==`2d`)return null;for(n in t)this.pdf.context2d.hasOwnProperty(n)&&(this.pdf.context2d[n]=t[n]);return this.pdf.context2d._canvas=this,this.pdf.context2d},t.prototype.toDataURL=function(){throw Error(`toDataURL is not implemented.`)},e.events.push([`initialized`,function(){this.canvas=new t,this.canvas.pdf=this}])}(SL.API),function(e){var t={left:0,top:0,bottom:0,right:0},n=!1,r=function(){this.internal.__cell__===void 0&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},t),this.internal.__cell__.margins.width=this.getPageWidth(),i.call(this))},i=function(){this.internal.__cell__.lastCell=new a,this.internal.__cell__.pages=1},a=function(){var e=arguments[0];Object.defineProperty(this,"x",{enumerable:!0,get:function(){return e},set:function(t){e=t}});var t=arguments[1];Object.defineProperty(this,"y",{enumerable:!0,get:function(){return t},set:function(e){t=e}});var n=arguments[2];Object.defineProperty(this,"width",{enumerable:!0,get:function(){return n},set:function(e){n=e}});var r=arguments[3];Object.defineProperty(this,"height",{enumerable:!0,get:function(){return r},set:function(e){r=e}});var i=arguments[4];Object.defineProperty(this,"text",{enumerable:!0,get:function(){return i},set:function(e){i=e}});var a=arguments[5];Object.defineProperty(this,"lineNumber",{enumerable:!0,get:function(){return a},set:function(e){a=e}});var o=arguments[6];return Object.defineProperty(this,"align",{enumerable:!0,get:function(){return o},set:function(e){o=e}}),this};a.prototype.clone=function(){return new a(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},a.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},e.setHeaderFunction=function(e){return r.call(this),this.internal.__cell__.headerFunction=typeof e==`function`?e:void 0,this},e.getTextDimensions=function(e,t){r.call(this);var n=(t||={}).fontSize||this.getFontSize(),i=t.font||this.getFont(),a=t.scaleFactor||this.internal.scaleFactor,o=0,s=0,c=0,l=this;if(!Array.isArray(e)&&typeof e!=`string`){if(typeof e!=`number`)throw Error(`getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.`);e=String(e)}var u=t.maxWidth;u>0?typeof e==`string`?e=this.splitTextToSize(e,u):Object.prototype.toString.call(e)===`[object Array]`&&(e=e.reduce(function(e,t){return e.concat(l.splitTextToSize(t,u))},[])):e=Array.isArray(e)?e:[e];for(var d=0;d<e.length;d++)o<(c=this.getStringUnitWidth(e[d],{font:i})*n)&&(o=c);return o!==0&&(s=e.length),{w:o/=a,h:Math.max((s*n*this.getLineHeightFactor()-n*(this.getLineHeightFactor()-1))/a,0)}},e.cellAddPage=function(){r.call(this),this.addPage();var e=this.internal.__cell__.margins||t;return this.internal.__cell__.lastCell=new a(e.left,e.top,void 0,void 0),this.internal.__cell__.pages+=1,this};var o=e.cell=function(){var e=arguments[0]instanceof a?arguments[0]:new a(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]);r.call(this);var i=this.internal.__cell__.lastCell,o=this.internal.__cell__.padding,s=this.internal.__cell__.margins||t,c=this.internal.__cell__.tableHeaderRow,l=this.internal.__cell__.printHeaders;return i.lineNumber!==void 0&&(i.lineNumber===e.lineNumber?(e.x=(i.x||0)+(i.width||0),e.y=i.y||0):i.y+i.height+e.height+s.bottom>this.getPageHeight()?(this.cellAddPage(),e.y=s.top,l&&c&&(this.printHeaderRow(e.lineNumber,!0),e.y+=c[0].height)):e.y=i.y+i.height||e.y),e.text[0]!==void 0&&(this.rect(e.x,e.y,e.width,e.height,!0===n?`FD`:void 0),e.align===`right`?this.text(e.text,e.x+e.width-o,e.y+o,{align:`right`,baseline:`top`}):e.align===`center`?this.text(e.text,e.x+e.width/2,e.y+o,{align:`center`,baseline:`top`,maxWidth:e.width-o-o}):this.text(e.text,e.x+o,e.y+o,{align:`left`,baseline:`top`,maxWidth:e.width-o-o})),this.internal.__cell__.lastCell=e,this};e.table=function(e,n,c,l,u){if(r.call(this),!c)throw Error(`No data for PDF table.`);var d,f,p,m,h=[],g=[],_=[],v={},y={},b=[],x=[],S=(u||={}).autoSize||!1,C=!1!==u.printHeaders,w=u.css&&u.css[`font-size`]!==void 0?16*u.css[`font-size`]:u.fontSize||12,T=u.margins||Object.assign({width:this.getPageWidth()},t),E=typeof u.padding==`number`?u.padding:3,D=u.headerBackgroundColor||`#c8c8c8`,O=u.headerTextColor||`#000`;if(i.call(this),this.internal.__cell__.printHeaders=C,this.internal.__cell__.margins=T,this.internal.__cell__.table_font_size=w,this.internal.__cell__.padding=E,this.internal.__cell__.headerBackgroundColor=D,this.internal.__cell__.headerTextColor=O,this.setFontSize(w),l==null)g=h=Object.keys(c[0]),_=h.map(function(){return`left`});else if(Array.isArray(l)&&Pi(l[0])===`object`)for(h=l.map(function(e){return e.name}),g=l.map(function(e){return e.prompt||e.name||``}),_=l.map(function(e){return e.align||`left`}),d=0;d<l.length;d+=1)y[l[d].name]=.7499990551181103*l[d].width;else Array.isArray(l)&&typeof l[0]==`string`&&(g=h=l,_=h.map(function(){return`left`}));if(S||Array.isArray(l)&&typeof l[0]==`string`)for(d=0;d<h.length;d+=1){for(v[m=h[d]]=c.map(function(e){return e[m]}),this.setFont(void 0,`bold`),b.push(this.getTextDimensions(g[d],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w),f=v[m],this.setFont(void 0,`normal`),p=0;p<f.length;p+=1)b.push(this.getTextDimensions(f[p],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w);y[m]=Math.max.apply(null,b)+E+E,b=[]}if(C){var k={};for(d=0;d<h.length;d+=1)k[h[d]]={},k[h[d]].text=g[d],k[h[d]].align=_[d];var A=s.call(this,k,y);x=h.map(function(t){return new a(e,n,y[t],A,k[t].text,void 0,k[t].align)}),this.setTableHeaderRow(x),this.printHeaderRow(1,!1)}var j=l.reduce(function(e,t){return e[t.name]=t.align,e},{});for(d=0;d<c.length;d+=1){`rowStart`in u&&u.rowStart instanceof Function&&u.rowStart({row:d,data:c[d]},this);var M=s.call(this,c[d],y);for(p=0;p<h.length;p+=1){var N=c[d][h[p]];`cellStart`in u&&u.cellStart instanceof Function&&u.cellStart({row:d,col:p,data:N},this),o.call(this,new a(e,n,y[h[p]],M,N,d+2,j[h[p]]))}}return this.internal.__cell__.table_x=e,this.internal.__cell__.table_y=n,this};var s=function(e,t){var n=this.internal.__cell__.padding,r=this.internal.__cell__.table_font_size,i=this.internal.scaleFactor;return Object.keys(e).map(function(r){var i=e[r];return this.splitTextToSize(i.hasOwnProperty(`text`)?i.text:i,t[r]-n-n)},this).map(function(e){return this.getLineHeightFactor()*e.length*r/i+n+n},this).reduce(function(e,t){return Math.max(e,t)},0)};e.setTableHeaderRow=function(e){r.call(this),this.internal.__cell__.tableHeaderRow=e},e.printHeaderRow=function(e,t){if(r.call(this),!this.internal.__cell__.tableHeaderRow)throw Error(`Property tableHeaderRow does not exist.`);var i;if(n=!0,typeof this.internal.__cell__.headerFunction==`function`){var s=this.internal.__cell__.headerFunction(this,this.internal.__cell__.pages);this.internal.__cell__.lastCell=new a(s[0],s[1],s[2],s[3],void 0,-1)}this.setFont(void 0,`bold`);for(var c=[],l=0;l<this.internal.__cell__.tableHeaderRow.length;l+=1){i=this.internal.__cell__.tableHeaderRow[l].clone(),t&&(i.y=this.internal.__cell__.margins.top||0,c.push(i)),i.lineNumber=e;var u=this.getTextColor();this.setTextColor(this.internal.__cell__.headerTextColor),this.setFillColor(this.internal.__cell__.headerBackgroundColor),o.call(this,i),this.setTextColor(u)}c.length>0&&this.setTableHeaderRow(c),this.setFont(void 0,`normal`),n=!1}}(SL.API);var fR={italic:[`italic`,`oblique`,`normal`],oblique:[`oblique`,`italic`,`normal`],normal:[`normal`,`oblique`,`italic`]},pR=[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`],mR=dR(pR),hR=[100,200,300,400,500,600,700,800,900],gR=dR(hR);function _R(e){var t=e.family.replace(/"|'/g,``).toLowerCase(),n=function(e){return fR[e||=`normal`]?e:`normal`}(e.style),r=function(e){return e?typeof e==`number`?e>=100&&e<=900&&e%100==0?e:400:/^\d00$/.test(e)?parseInt(e):e===`bold`?700:400:400}(e.weight),i=function(e){return typeof mR[e||=`normal`]==`number`?e:`normal`}(e.stretch);return{family:t,style:n,weight:r,stretch:i,src:e.src||[],ref:e.ref||{name:t,style:[i,n,r].join(` `)}}}function vR(e,t,n,r){var i;for(i=n;i>=0&&i<t.length;i+=r)if(e[t[i]])return e[t[i]];for(i=n;i>=0&&i<t.length;i-=r)if(e[t[i]])return e[t[i]]}var yR={"sans-serif":`helvetica`,fixed:`courier`,monospace:`courier`,terminal:`courier`,cursive:`times`,fantasy:`times`,serif:`times`},bR={caption:`times`,icon:`times`,menu:`times`,"message-box":`times`,"small-caption":`times`,"status-bar":`times`};function xR(e){return[e.stretch,e.style,e.weight,e.family].join(` `)}function SR(e){return e.trimLeft()}function CR(e,t){for(var n=0;n<e.length;){if(e.charAt(n)===t)return[e.substring(0,n),e.substring(n+1)];n+=1}return null}function wR(e){var t=e.match(/^(-[a-z_]|[a-z_])[a-z0-9_-]*/i);return t===null?null:[t[0],e.substring(t[0].length)]}var TR,ER,DR,OR,kR,AR=[`times`];function jR(e,t,n,r,i){var a=4,o=PR;switch(i){case SL.API.image_compression.FAST:a=1,o=NR;break;case SL.API.image_compression.MEDIUM:a=6,o=FR;break;case SL.API.image_compression.SLOW:a=9,o=IR}e=function(e,t,n,r){for(var i,a=e.length/t,o=new Uint8Array(e.length+a),s=[MR,NR,PR,FR,IR],c=0;c<a;c+=1){var l=c*t,u=e.subarray(l,l+t);if(r)o.set(r(u,n,i),l+c);else{for(var d=s.length,f=[],p=0;p<d;p+=1)f[p]=s[p](u,n,i);var m=RR(f.concat());o.set(f[m],l+c)}i=u}return o}(e,t,Math.ceil(n*r/8),o);var s=JA(e,{level:a});return SL.API.__addimage__.arrayBufferToBinaryString(s)}function MR(e){var t=Array.apply([],e);return t.unshift(0),t}function NR(e,t){var n=e.length,r=[];r[0]=1;for(var i=0;i<n;i+=1){var a=e[i-t]||0;r[i+1]=e[i]-a+256&255}return r}function PR(e,t,n){var r=e.length,i=[];i[0]=2;for(var a=0;a<r;a+=1){var o=n&&n[a]||0;i[a+1]=e[a]-o+256&255}return i}function FR(e,t,n){var r=e.length,i=[];i[0]=3;for(var a=0;a<r;a+=1){var o=e[a-t]||0,s=n&&n[a]||0;i[a+1]=e[a]+256-(o+s>>>1)&255}return i}function IR(e,t,n){var r=e.length,i=[];i[0]=4;for(var a=0;a<r;a+=1){var o=LR(e[a-t]||0,n&&n[a]||0,n&&n[a-t]||0);i[a+1]=e[a]-o+256&255}return i}function LR(e,t,n){if(e===t&&t===n)return e;var r=Math.abs(t-n),i=Math.abs(e-n),a=Math.abs(e+t-n-n);return r<=i&&r<=a?e:i<=a?t:n}function RR(e){var t=e.map(function(e){return e.reduce(function(e,t){return e+Math.abs(t)},0)});return t.indexOf(Math.min.apply(null,t))}function zR(e,t,n){var r=t*n,i=Math.floor(r/8),a=16-(r-8*i+n),o=(1<<n)-1;return VR(e,i)>>a&o}function BR(e,t,n,r){var i=n*r,a=Math.floor(i/8),o=16-(i-8*a+r),s=(1<<r)-1,c=(t&s)<<o;(function(e,t,n){if(t+1<e.byteLength)e.setUint16(t,n,!1);else{var r=n>>8&255;e.setUint8(t,r)}})(e,a,VR(e,a)&~(s<<o)&65535|c)}function VR(e,t){return t+1<e.byteLength?e.getUint16(t,!1):e.getUint8(t)<<8}function HR(e){var t=0;if(e[t++]!==71||e[t++]!==73||e[t++]!==70||e[t++]!==56||(e[t++]+1&253)!=56||e[t++]!==97)throw Error(`Invalid GIF 87a/89a header.`);var n=e[t++]|e[t++]<<8,r=e[t++]|e[t++]<<8,i=e[t++],a=i>>7,o=1<<1+(7&i);e[t++],e[t++];var s=null,c=null;a&&(s=t,c=o,t+=3*o);var l=!0,u=[],d=0,f=null,p=0,m=null;for(this.width=n,this.height=r;l&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(e[t]!==11||e[t+1]==78&&e[t+2]==69&&e[t+3]==84&&e[t+4]==83&&e[t+5]==67&&e[t+6]==65&&e[t+7]==80&&e[t+8]==69&&e[t+9]==50&&e[t+10]==46&&e[t+11]==48&&e[t+12]==3&&e[t+13]==1&&e[t+16]==0)t+=14,m=e[t++]|e[t++]<<8,t++;else for(t+=12;;){if(!((D=e[t++])>=0))throw Error(`Invalid block size`);if(D===0)break;t+=D}break;case 249:if(e[t++]!==4||e[t+4]!==0)throw Error(`Invalid graphics extension block.`);var h=e[t++];d=e[t++]|e[t++]<<8,f=e[t++],1&h||(f=null),p=h>>2&7,t++;break;case 254:for(;;){if(!((D=e[t++])>=0))throw Error(`Invalid block size`);if(D===0)break;t+=D}break;default:throw Error(`Unknown graphic control label: 0x`+e[t-1].toString(16))}break;case 44:var g=e[t++]|e[t++]<<8,_=e[t++]|e[t++]<<8,v=e[t++]|e[t++]<<8,y=e[t++]|e[t++]<<8,b=e[t++],x=b>>6&1,S=1<<1+(7&b),C=s,w=c,T=!1;b>>7&&(T=!0,C=t,w=S,t+=3*S);var E=t;for(t++;;){var D;if(!((D=e[t++])>=0))throw Error(`Invalid block size`);if(D===0)break;t+=D}u.push({x:g,y:_,width:v,height:y,has_local_palette:T,palette_offset:C,palette_size:w,data_offset:E,data_length:t-E,transparent_index:f,interlaced:!!x,delay:d,disposal:p});break;case 59:l=!1;break;default:throw Error(`Unknown gif block: 0x`+e[t-1].toString(16))}this.numFrames=function(){return u.length},this.loopCount=function(){return m},this.frameInfo=function(e){if(e<0||e>=u.length)throw Error(`Frame index out of range.`);return u[e]},this.decodeAndBlitFrameBGRA=function(t,r){var i=this.frameInfo(t),a=i.width*i.height;if(a>536870912)throw Error(`Image dimensions exceed 512MB, which is too large.`);var o=new Uint8Array(a);UR(e,i.data_offset,o,a);var s=i.palette_offset,c=i.transparent_index;c===null&&(c=256);var l=i.width,u=n-l,d=l,f=4*(i.y*n+i.x),p=4*((i.y+i.height)*n+i.x),m=f,h=4*u;!0===i.interlaced&&(h+=4*n*7);for(var g=8,_=0,v=o.length;_<v;++_){var y=o[_];if(d===0&&(d=l,(m+=h)>=p&&(h=4*u+4*n*(g-1),m=f+(l+u)*(g<<1),g>>=1)),y===c)m+=4;else{var b=e[s+3*y],x=e[s+3*y+1],S=e[s+3*y+2];r[m++]=S,r[m++]=x,r[m++]=b,r[m++]=255}--d}},this.decodeAndBlitFrameRGBA=function(t,r){var i=this.frameInfo(t),a=i.width*i.height;if(a>536870912)throw Error(`Image dimensions exceed 512MB, which is too large.`);var o=new Uint8Array(a);UR(e,i.data_offset,o,a);var s=i.palette_offset,c=i.transparent_index;c===null&&(c=256);var l=i.width,u=n-l,d=l,f=4*(i.y*n+i.x),p=4*((i.y+i.height)*n+i.x),m=f,h=4*u;!0===i.interlaced&&(h+=4*n*7);for(var g=8,_=0,v=o.length;_<v;++_){var y=o[_];if(d===0&&(d=l,(m+=h)>=p&&(h=4*u+4*n*(g-1),m=f+(l+u)*(g<<1),g>>=1)),y===c)m+=4;else{var b=e[s+3*y],x=e[s+3*y+1],S=e[s+3*y+2];r[m++]=b,r[m++]=x,r[m++]=S,r[m++]=255}--d}}}function UR(e,t,n,r){for(var i=e[t++],a=1<<i,o=a+1,s=o+1,c=i+1,l=(1<<c)-1,u=0,d=0,f=0,p=e[t++],m=new Int32Array(4096),h=null;;){for(;u<16&&p!==0;)d|=e[t++]<<u,u+=8,p===1?p=e[t++]:--p;if(u<c)break;var g=d&l;if(d>>=c,u-=c,g!==a){if(g===o)break;for(var _=g<s?g:h,v=0,y=_;y>a;)y=m[y]>>8,++v;var b=y;if(f+v+(_===g?0:1)>r)return void GI.log(`Warning, gif stream longer than expected.`);n[f++]=b;var x=f+=v;for(_!==g&&(n[f++]=b),y=_;v--;)y=m[y],n[--x]=255&y,y>>=8;h!==null&&s<4096&&(m[s++]=h<<8|b,s>=l+1&&c<12&&(++c,l=l<<1|1)),h=g}else s=o+1,l=(1<<(c=i+1))-1,h=null}return f!==r&&GI.log(`Warning, gif stream shorter than expected.`),n}function WR(e){var t,n,r,i,a,o=Math.floor,s=Array(64),c=Array(64),l=Array(64),u=Array(64),d=Array(65535),f=Array(65535),p=Array(64),m=Array(64),h=[],g=0,_=7,v=Array(64),y=Array(64),b=Array(64),x=Array(256),S=Array(2048),C=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],w=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],T=[0,1,2,3,4,5,6,7,8,9,10,11],E=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],D=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],O=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],k=[0,1,2,3,4,5,6,7,8,9,10,11],A=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],j=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function M(e,t){for(var n=0,r=0,i=[],a=1;a<=16;a++){for(var o=1;o<=e[a];o++)i[t[r]]=[],i[t[r]][0]=n,i[t[r]][1]=a,r++,n++;n*=2}return i}function N(e){for(var t=e[0],n=e[1]-1;n>=0;)t&1<<n&&(g|=1<<_),n--,--_<0&&(g==255?(P(255),P(0)):P(g),_=7,g=0)}function P(e){h.push(e)}function F(e){P(e>>8&255),P(255&e)}function I(e,t,n,r,i){for(var a,o=i[0],s=i[240],c=function(e,t){var n,r,i,a,o,s,c,l,u,d,f=0;for(u=0;u<8;++u){n=e[f],r=e[f+1],i=e[f+2],a=e[f+3],o=e[f+4],s=e[f+5],c=e[f+6];var m=n+(l=e[f+7]),h=n-l,g=r+c,_=r-c,v=i+s,y=i-s,b=a+o,x=a-o,S=m+b,C=m-b,w=g+v,T=g-v;e[f]=S+w,e[f+4]=S-w;var E=.707106781*(T+C);e[f+2]=C+E,e[f+6]=C-E;var D=.382683433*((S=x+y)-(T=_+h)),O=.5411961*S+D,k=1.306562965*T+D,A=.707106781*(w=y+_),j=h+A,M=h-A;e[f+5]=M+O,e[f+3]=M-O,e[f+1]=j+k,e[f+7]=j-k,f+=8}for(f=0,u=0;u<8;++u){n=e[f],r=e[f+8],i=e[f+16],a=e[f+24],o=e[f+32],s=e[f+40],c=e[f+48];var N=n+(l=e[f+56]),P=n-l,F=r+c,I=r-c,L=i+s,R=i-s,z=a+o,B=a-o,V=N+z,ee=N-z,te=F+L,ne=F-L;e[f]=V+te,e[f+32]=V-te;var re=.707106781*(ne+ee);e[f+16]=ee+re,e[f+48]=ee-re;var H=.382683433*((V=B+R)-(ne=I+P)),ie=.5411961*V+H,U=1.306562965*ne+H,W=.707106781*(te=R+I),ae=P+W,G=P-W;e[f+40]=G+ie,e[f+24]=G-ie,e[f+8]=ae+U,e[f+56]=ae-U,f++}for(u=0;u<64;++u)d=e[u]*t[u],p[u]=d>0?d+.5|0:d-.5|0;return p}(e,t),l=0;l<64;++l)m[C[l]]=c[l];var u=m[0]-n;n=m[0],u==0?N(r[0]):(N(r[f[a=32767+u]]),N(d[a]));for(var h=63;h>0&&m[h]==0;)h--;if(h==0)return N(o),n;for(var g,_=1;_<=h;){for(var v=_;m[_]==0&&_<=h;)++_;var y=_-v;if(y>=16){g=y>>4;for(var b=1;b<=g;++b)N(s);y&=15}a=32767+m[_],N(i[(y<<4)+f[a]]),N(d[a]),_++}return h!=63&&N(o),n}function L(e){e=Math.min(Math.max(e,1),100),a!=e&&(function(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],n=0;n<64;n++){var r=o((t[n]*e+50)/100);r=Math.min(Math.max(r,1),255),s[C[n]]=r}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var d=o((i[a]*e+50)/100);d=Math.min(Math.max(d,1),255),c[C[a]]=d}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],p=0,m=0;m<8;m++)for(var h=0;h<8;h++)l[p]=1/(s[C[p]]*f[m]*f[h]*8),u[p]=1/(c[C[p]]*f[m]*f[h]*8),p++}(Math.floor(e<50?5e3/e:200-2*e)),a=e)}this.encode=function(e,a){a&&L(a),h=[],g=0,_=7,F(65496),F(65504),F(16),P(74),P(70),P(73),P(70),P(0),P(1),P(1),P(0),F(1),F(1),P(0),P(0),function(){F(65499),F(132),P(0);for(var e=0;e<64;e++)P(s[e]);P(1);for(var t=0;t<64;t++)P(c[t])}(),function(e,t){F(65472),F(17),P(8),F(t),F(e),P(3),P(1),P(17),P(0),P(2),P(17),P(1),P(3),P(17),P(1)}(e.width,e.height),function(){F(65476),F(418),P(0);for(var e=0;e<16;e++)P(w[e+1]);for(var t=0;t<=11;t++)P(T[t]);P(16);for(var n=0;n<16;n++)P(E[n+1]);for(var r=0;r<=161;r++)P(D[r]);P(1);for(var i=0;i<16;i++)P(O[i+1]);for(var a=0;a<=11;a++)P(k[a]);P(17);for(var o=0;o<16;o++)P(A[o+1]);for(var s=0;s<=161;s++)P(j[s])}(),F(65498),F(12),P(3),P(1),P(0),P(2),P(17),P(3),P(17),P(0),P(63),P(0);var o=0,d=0,f=0;g=0,_=7,this.encode.displayName=`_encode_`;for(var p,m,x,C,M,R,z,B,V,ee=e.data,te=e.width,ne=e.height,re=4*te,H=0;H<ne;){for(p=0;p<re;){for(M=re*H+p,z=-1,B=0,V=0;V<64;V++)R=M+(B=V>>3)*re+(z=4*(7&V)),H+B>=ne&&(R-=re*(H+1+B-ne)),p+z>=re&&(R-=p+z-re+4),m=ee[R++],x=ee[R++],C=ee[R++],v[V]=(S[m]+S[x+256|0]+S[C+512|0]>>16)-128,y[V]=(S[m+768|0]+S[x+1024|0]+S[C+1280|0]>>16)-128,b[V]=(S[m+1280|0]+S[x+1536|0]+S[C+1792|0]>>16)-128;o=I(v,l,o,t,r),d=I(y,u,d,n,i),f=I(b,u,f,n,i),p+=32}H+=8}if(_>=0){var ie=[];ie[1]=_+1,ie[0]=(1<<_+1)-1,N(ie)}return F(65497),new Uint8Array(h)},e||=50,function(){for(var e=String.fromCharCode,t=0;t<256;t++)x[t]=e(t)}(),t=M(w,T),n=M(O,k),r=M(E,D),i=M(A,j),function(){for(var e=1,t=2,n=1;n<=15;n++){for(var r=e;r<t;r++)f[32767+r]=n,d[32767+r]=[],d[32767+r][1]=n,d[32767+r][0]=r;for(var i=-(t-1);i<=-e;i++)f[32767+i]=n,d[32767+i]=[],d[32767+i][1]=n,d[32767+i][0]=t-1+i;e<<=1,t<<=1}}(),function(){for(var e=0;e<256;e++)S[e]=19595*e,S[e+256|0]=38470*e,S[e+512|0]=7471*e+32768,S[e+768|0]=-11059*e,S[e+1024|0]=-21709*e,S[e+1280|0]=32768*e+8421375,S[e+1536|0]=-27439*e,S[e+1792|0]=-5329*e}(),L(e)}function GR(e,t){if(this.pos=0,this.buffer=e,this.datav=new DataView(e.buffer),this.is_with_alpha=!!t,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,[`BM`,`BA`,`CI`,`CP`,`IC`,`PT`].indexOf(this.flag)===-1)throw Error(`Invalid BMP File`);this.parseHeader(),this.parseBGR()}function KR(e){function t(e){if(!e)throw Error(`assert :P`)}function n(e,t,n){for(var r=0;4>r;r++)if(e[t+r]!=n.charCodeAt(r))return!0;return!1}function r(e,t,n,r,i){for(var a=0;a<i;a++)e[t+a]=n[r+a]}function i(e,t,n,r){for(var i=0;i<r;i++)e[t+i]=n}function a(e){return new Int32Array(e)}function o(e,t){for(var n=[],r=0;r<e;r++)n.push(new t);return n}function s(e,t){var n=[];return function e(n,r,i){for(var a=i[r],o=0;o<a&&(n.push(i.length>r+1?[]:new t),!(i.length<r+1));o++)e(n[o],r+1,i)}(n,0,e),n}var c=function(){var e=this;function c(e,t){for(var n=1<<t-1>>>0;e&n;)n>>>=1;return n?(e&n-1)+n:e}function l(e,n,r,i,a){t(!(i%r));do e[n+(i-=r)]=a;while(0<i)}function u(e,n,r,i,o){if(t(2328>=o),512>=o)var s=a(512);else if((s=a(o))==null)return 0;return function(e,n,r,i,o,s){var u,f,p=n,m=1<<r,h=a(16),g=a(16);for(t(o!=0),t(i!=null),t(e!=null),t(0<r),f=0;f<o;++f){if(15<i[f])return 0;++h[i[f]]}if(h[0]==o)return 0;for(g[1]=0,u=1;15>u;++u){if(h[u]>1<<u)return 0;g[u+1]=g[u]+h[u]}for(f=0;f<o;++f)u=i[f],0<i[f]&&(s[g[u]++]=f);if(g[15]==1)return(i=new d).g=0,i.value=s[0],l(e,p,1,m,i),m;var _,v=-1,y=m-1,b=0,x=1,S=1,C=1<<r;for(f=0,u=1,o=2;u<=r;++u,o<<=1){if(x+=S<<=1,0>(S-=h[u]))return 0;for(;0<h[u];--h[u])(i=new d).g=u,i.value=s[f++],l(e,p+b,o,C,i),b=c(b,u)}for(u=r+1,o=2;15>=u;++u,o<<=1){if(x+=S<<=1,0>(S-=h[u]))return 0;for(;0<h[u];--h[u]){if(i=new d,(b&y)!=v){for(p+=C,_=1<<(v=u)-r;15>v&&!(0>=(_-=h[v]));)++v,_<<=1;m+=C=1<<(_=v-r),e[n+(v=b&y)].g=_+r,e[n+v].value=p-n-v}i.g=u-r,i.value=s[f++],l(e,p+(b>>r),o,C,i),b=c(b,u)}}return x==2*g[15]-1?m:0}(e,n,r,i,o,s)}function d(){this.value=this.g=0}function f(){this.value=this.g=0}function p(){this.G=o(5,d),this.H=a(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=o(Gn,f)}function m(e,n,r,i){t(e!=null),t(n!=null),t(2147483648>i),e.Ca=254,e.I=0,e.b=-8,e.Ka=0,e.oa=n,e.pa=r,e.Jd=n,e.Yc=r+i,e.Zc=4<=i?r+i-4+1:r,E(e)}function h(e,t){for(var n=0;0<t--;)n|=O(e,128)<<t;return n}function g(e,t){var n=h(e,t);return D(e)?-n:n}function _(e,n,r,i){var a,o=0;for(t(e!=null),t(n!=null),t(4294967288>i),e.Sb=i,e.Ra=0,e.u=0,e.h=0,4<i&&(i=4),a=0;a<i;++a)o+=n[r+a]<<8*a;e.Ra=o,e.bb=i,e.oa=n,e.pa=r}function v(e){for(;8<=e.u&&e.bb<e.Sb;)e.Ra>>>=8,e.Ra+=e.oa[e.pa+e.bb]<<Jn-8>>>0,++e.bb,e.u-=8;C(e)&&(e.h=1,e.u=0)}function y(e,n){if(t(0<=n),!e.h&&n<=qn){var r=S(e)&Kn[n];return e.u+=n,v(e),r}return e.h=1,e.u=0}function b(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function x(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function S(e){return e.Ra>>>(e.u&Jn-1)>>>0}function C(e){return t(e.bb<=e.Sb),e.h||e.bb==e.Sb&&e.u>Jn}function w(e,t){e.u=t,e.h=C(e)}function T(e){e.u>=Yn&&(t(e.u>=Yn),v(e))}function E(e){t(e!=null&&e.oa!=null),e.pa<e.Zc?(e.I=(e.oa[e.pa++]|e.I<<8)>>>0,e.b+=8):(t(e!=null&&e.oa!=null),e.pa<e.Yc?(e.b+=8,e.I=e.oa[e.pa++]|e.I<<8):e.Ka?e.b=0:(e.I<<=8,e.b+=8,e.Ka=1))}function D(e){return h(e,1)}function O(e,t){var n=e.Ca;0>e.b&&E(e);var r=e.b,i=n*t>>>8,a=(e.I>>>r>i)+0;for(a?(n-=i,e.I-=i+1<<r>>>0):n=i+1,r=n,i=0;256<=r;)i+=8,r>>=8;return r=7^i+Xn[r],e.b-=r,e.Ca=(n<<r)-1,a}function k(e,t,n){e[t+0]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n}function A(e,t){return e[t+0]|e[t+1]<<8}function j(e,t){return A(e,t)|e[t+2]<<16}function M(e,t){return A(e,t)|A(e,t+2)<<16}function N(e,n){var r=1<<n;return t(e!=null),t(0<n),e.X=a(r),e.X==null?0:(e.Mb=32-n,e.Xa=n,1)}function P(e,n){t(e!=null),t(n!=null),t(e.Xa==n.Xa),r(n.X,0,e.X,0,1<<n.Xa)}function F(){this.X=[],this.Xa=this.Mb=0}function I(e,n,r,i){t(r!=null),t(i!=null);var a=r[0],o=i[0];return a==0&&(a=(e*o+n/2)/n),o==0&&(o=(n*a+e/2)/e),0>=a||0>=o?0:(r[0]=a,i[0]=o,1)}function L(e,t){return e+(1<<t)-1>>>t}function R(e,t){return((4278255360&e)+(4278255360&t)>>>0&4278255360)+((16711935&e)+(16711935&t)>>>0&16711935)>>>0}function z(t,n){e[n]=function(n,r,i,a,o,s,c){var l;for(l=0;l<o;++l){var u=e[t](s[c+l-1],i,a+l);s[c+l]=R(n[r+l],u)}}}function B(){this.ud=this.hd=this.jd=0}function V(e,t){return((4278124286&(e^t))>>>1)+(e&t)>>>0}function ee(e){return 0<=e&&256>e?e:0>e?0:255<e?255:void 0}function te(e,t){return ee(e+(e-t+.5>>1))}function ne(e,t,n){return Math.abs(t-n)-Math.abs(e-n)}function re(e,t,n,r,i,a,o){for(r=a[o-1],n=0;n<i;++n)a[o+n]=r=R(e[t+n],r)}function H(e,t,n,r,i){var a;for(a=0;a<n;++a){var o=e[t+a],s=o>>8&255,c=16711935&(c=(c=16711935&o)+((s<<16)+s));r[i+a]=(4278255360&o)+c>>>0}}function ie(e,t){t.jd=255&e,t.hd=e>>8&255,t.ud=e>>16&255}function U(e,t,n,r,i,a){var o;for(o=0;o<r;++o){var s=t[n+o],c=s>>>8,l=s,u=255&(u=(u=s>>>16)+((e.jd<<24>>24)*(c<<24>>24)>>>5));l=255&(l=(l+=(e.hd<<24>>24)*(c<<24>>24)>>>5)+((e.ud<<24>>24)*(u<<24>>24)>>>5)),i[a+o]=(4278255360&s)+(u<<16)+l}}function W(t,n,r,i,a){e[n]=function(e,t,n,r,o,s,c,l,u){for(r=c;r<l;++r)for(c=0;c<u;++c)o[s++]=a(n[i(e[t++])])},e[t]=function(t,n,o,s,c,l,u){var d=8>>t.b,f=t.Ea,p=t.K[0],m=t.w;if(8>d)for(t=(1<<t.b)-1,m=(1<<d)-1;n<o;++n){var h,g=0;for(h=0;h<f;++h)h&t||(g=i(s[c++])),l[u++]=a(p[g&m]),g>>=d}else e[`VP8LMapColor`+r](s,c,p,m,l,u,n,o,f)}}function ae(e,t,n,r,i){for(n=t+n;t<n;){var a=e[t++];r[i++]=a>>16&255,r[i++]=a>>8&255,r[i++]=255&a}}function G(e,t,n,r,i){for(n=t+n;t<n;){var a=e[t++];r[i++]=a>>16&255,r[i++]=a>>8&255,r[i++]=255&a,r[i++]=a>>24&255}}function oe(e,t,n,r,i){for(n=t+n;t<n;){var a=(o=e[t++])>>16&240|o>>12&15,o=240&o|o>>28&15;r[i++]=a,r[i++]=o}}function se(e,t,n,r,i){for(n=t+n;t<n;){var a=(o=e[t++])>>16&248|o>>13&7,o=o>>5&224|o>>3&31;r[i++]=a,r[i++]=o}}function ce(e,t,n,r,i){for(n=t+n;t<n;){var a=e[t++];r[i++]=255&a,r[i++]=a>>8&255,r[i++]=a>>16&255}}function le(e,t,n,i,a,o){if(o==0)for(n=t+n;t<n;)k(i,((o=e[t++])[0]>>24|o[1]>>8&65280|o[2]<<8&16711680|o[3]<<24)>>>0),a+=32;else r(i,a,e,t,n)}function ue(t,n){e[n][0]=e[t+`0`],e[n][1]=e[t+`1`],e[n][2]=e[t+`2`],e[n][3]=e[t+`3`],e[n][4]=e[t+`4`],e[n][5]=e[t+`5`],e[n][6]=e[t+`6`],e[n][7]=e[t+`7`],e[n][8]=e[t+`8`],e[n][9]=e[t+`9`],e[n][10]=e[t+`10`],e[n][11]=e[t+`11`],e[n][12]=e[t+`12`],e[n][13]=e[t+`13`],e[n][14]=e[t+`0`],e[n][15]=e[t+`0`]}function de(e){return e==Kr||e==qr||e==Jr||e==Yr}function fe(){this.eb=[],this.size=this.A=this.fb=0}function pe(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function me(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new fe,this.f.kb=new pe,this.sd=null}function he(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function ge(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function _e(e){return alert(`todo:WebPSamplerProcessPlane`),e.T}function ve(e,t){var n=e.T,i=t.ba.f.RGBA,a=i.eb,o=i.fb+e.ka*i.A,s=bi[t.ba.S],c=e.y,l=e.O,u=e.f,d=e.N,f=e.ea,p=e.W,m=t.cc,h=t.dc,g=t.Mc,_=t.Nc,v=e.ka,y=e.ka+e.T,b=e.U,x=b+1>>1;for(v==0?s(c,l,null,null,u,d,f,p,u,d,f,p,a,o,null,null,b):(s(t.ec,t.fc,c,l,m,h,g,_,u,d,f,p,a,o-i.A,a,o,b),++n);v+2<y;v+=2)m=u,h=d,g=f,_=p,d+=e.Rc,p+=e.Rc,o+=2*i.A,s(c,(l+=2*e.fa)-e.fa,c,l,m,h,g,_,u,d,f,p,a,o-i.A,a,o,b);return l+=e.fa,e.j+y<e.o?(r(t.ec,t.fc,c,l,b),r(t.cc,t.dc,u,d,x),r(t.Mc,t.Nc,f,p,x),n--):1&y||s(c,l,null,null,u,d,f,p,u,d,f,p,a,o+i.A,null,null,b),n}function ye(e,n,r){var i=e.F,a=[e.J];if(i!=null){var o=e.U,s=n.ba.S,c=s==Ur||s==Jr;n=n.ba.f.RGBA;var l=[0],u=e.ka;l[0]=e.T,e.Kb&&(u==0?--l[0]:(--u,a[0]-=e.width),e.j+e.ka+e.T==e.o&&(l[0]=e.o-e.j-u));var d=n.eb;u=n.fb+u*n.A,e=Or(i,a[0],e.width,o,l,d,u+(c?0:3),n.A),t(r==l),e&&de(s)&&Er(d,u,c,o,l,n.A)}return 0}function be(e){var t=e.ma,n=t.ba.S,r=11>n,i=n==Br||n==Hr||n==Ur||n==Wr||n==12||de(n);if(t.memory=null,t.Ib=null,t.Jb=null,t.Nd=null,!Hn(t.Oa,e,i?11:12))return 0;if(i&&de(n)&&Tn(),e.da)alert(`todo:use_scaling`);else{if(r){if(t.Ib=_e,e.Kb){if(n=e.U+1>>1,t.memory=a(e.U+2*n),t.memory==null)return 0;t.ec=t.memory,t.fc=0,t.cc=t.ec,t.dc=t.fc+e.U,t.Mc=t.cc,t.Nc=t.dc+n,t.Ib=ve,Tn()}}else alert(`todo:EmitYUV`);i&&(t.Jb=ye,r&&Cn())}if(r&&!Ni){for(e=0;256>e;++e)Pi[e]=89858*(e-128)+Oi>>Di,Li[e]=-22014*(e-128)+Oi,Ii[e]=-45773*(e-128),Fi[e]=113618*(e-128)+Oi>>Di;for(e=ki;e<Ai;++e)t=76283*(e-16)+Oi>>Di,Ri[e-ki]=Qe(t,255),zi[e-ki]=Qe(t+8>>4,15);Ni=1}return 1}function xe(e){var n=e.ma,r=e.U,i=e.T;return t(!(1&e.ka)),0>=r||0>=i?0:(r=n.Ib(e,n),n.Jb!=null&&n.Jb(e,n,r),n.Dc+=r,1)}function Se(e){e.ma.memory=null}function Ce(e,t,n,r){return y(e,8)==47?(t[0]=y(e,14)+1,n[0]=y(e,14)+1,r[0]=y(e,1),y(e,3)==0?!e.h:0):0}function we(e,t){if(4>e)return e+1;var n=e-2>>1;return(2+(1&e)<<n)+y(t,n)+1}function Te(e,t){return 120<t?t-120:1<=(n=((n=ti[t-1])>>4)*e+(8-(15&n)))?n:1;var n}function Ee(e,t,n){var r=S(n),i=e[t+=255&r].g-8;return 0<i&&(w(n,n.u+8),r=S(n),t+=e[t].value,t+=r&(1<<i)-1),w(n,n.u+e[t].g),e[t].value}function De(e,n,r){return r.g+=e.g,r.value+=e.value<<n>>>0,t(8>=r.g),e.g}function Oe(e,n,r){var i=e.xc;return t((n=i==0?0:e.vc[e.md*(r>>i)+(n>>i)])<e.Wb),e.Ya[n]}function ke(e,n,i,a){var o=e.ab,s=e.c*n,c=e.C;n=c+n;var l=i,u=a;for(a=e.Ta,i=e.Ua;0<o--;){var d=e.gc[o],f=c,p=n,m=l,h=u,g=(u=a,l=i,d.Ea);switch(t(f<p),t(p<=d.nc),d.hc){case 2:$n(m,h,(p-f)*g,u,l);break;case 0:var _=f,v=p,y=u,b=l,x=(E=d).Ea;_==0&&(Zn(m,h,null,null,1,y,b),re(m,h+1,0,0,x-1,y,b+1),h+=x,b+=x,++_);for(var S=1<<E.b,C=S-1,w=L(x,E.b),T=E.K,E=E.w+(_>>E.b)*w;_<v;){var D=T,O=E,k=1;for(Qn(m,h,y,b-x,1,y,b);k<x;){var A=(k&~C)+S;A>x&&(A=x),(0,rr[D[O++]>>8&15])(m,h+ +k,y,b+k-x,A-k,y,b+k),k=A}h+=x,b+=x,++_&C||(E+=w)}p!=d.nc&&r(u,l-g,u,l+(p-f-1)*g,g);break;case 1:for(g=m,v=h,x=(m=d.Ea)-(b=m&~(y=(h=1<<d.b)-1)),_=L(m,d.b),S=d.K,d=d.w+(f>>d.b)*_;f<p;){for(C=S,w=d,T=new B,E=v+b,D=v+m;v<E;)ie(C[w++],T),ir(T,g,v,h,u,l),v+=h,l+=h;v<D&&(ie(C[w++],T),ir(T,g,v,x,u,l),v+=x,l+=x),++f&y||(d+=_)}break;case 3:if(m==u&&h==l&&0<d.b){for(v=u,m=g=l+(p-f)*g-(b=(p-f)*L(d.Ea,d.b)),h=u,y=l,_=[],b=(x=b)-1;0<=b;--b)_[b]=h[y+b];for(b=x-1;0<=b;--b)v[m+b]=_[b];er(d,f,p,u,g,u,l)}else er(d,f,p,m,h,u,l)}l=a,u=i}u!=i&&r(a,i,l,u,s)}function Ae(e,n){var r=e.V,i=e.Ba+e.c*e.C,a=n-e.C;if(t(n<=e.l.o),t(16>=a),0<a){var o=e.l,s=e.Ta,c=e.Ua,l=o.width;if(ke(e,a,r,i),a=c=[c],t((r=e.C)<(i=n)),t(o.v<o.va),i>o.o&&(i=o.o),r<o.j){var u=o.j-r;r=o.j,a[0]+=u*l}if(r>=i?r=0:(a[0]+=4*o.v,o.ka=r-o.j,o.U=o.va-o.v,o.T=i-r,r=1),r){if(c=c[0],11>(r=e.ca).S){var d=r.f.RGBA,f=(i=r.S,a=o.U,o=o.T,u=d.eb,d.A),p=o;for(d=d.fb+e.Ma*d.A;0<p--;){var m=s,h=c,g=a,_=u,v=d;switch(i){case zr:ar(m,h,g,_,v);break;case Br:or(m,h,g,_,v);break;case Kr:or(m,h,g,_,v),Er(_,v,0,g,1,0);break;case Vr:cr(m,h,g,_,v);break;case Hr:le(m,h,g,_,v,1);break;case qr:le(m,h,g,_,v,1),Er(_,v,0,g,1,0);break;case Ur:le(m,h,g,_,v,0);break;case Jr:le(m,h,g,_,v,0),Er(_,v,1,g,1,0);break;case Wr:sr(m,h,g,_,v);break;case Yr:sr(m,h,g,_,v),Dr(_,v,g,1,0);break;case Gr:J(m,h,g,_,v);break;default:t(0)}c+=l,d+=f}e.Ma+=o}else alert(`todo:EmitRescaledRowsYUVA`);t(e.Ma<=r.height)}}e.C=n,t(e.C<=e.i)}function je(e){var t;if(0<e.ua)return 0;for(t=0;t<e.Wb;++t){var n=e.Ya[t].G,r=e.Ya[t].H;if(0<n[1][r[1]+0].g||0<n[2][r[2]+0].g||0<n[3][r[3]+0].g)return 0}return 1}function Me(e,n,r,i,a,o){if(e.Z!=0){var s=e.qd,c=e.rd;for(t(yi[e.Z]!=null);n<r;++n)yi[e.Z](s,c,i,a,i,a,o),s=i,c=a,a+=o;e.qd=s,e.rd=c}}function Ne(e,n){var r=e.l.ma,i=r.Z==0||r.Z==1?e.l.j:e.C;if(i=e.C<i?i:e.C,t(n<=e.l.o),n>i){var a=e.l.width,o=r.ca,s=r.tb+a*i,c=e.V,l=e.Ba+e.c*i,u=e.gc;t(e.ab==1),t(u[0].hc==3),q(u[0],i,n,c,l,o,s),Me(r,i,n,o,s,a)}e.C=e.Ma=n}function Pe(e,n,r,i,a,o,s){var c=e.$/i,l=e.$%i,u=e.m,d=e.s,f=r+e.$,p=f;a=r+i*a;var m=r+i*o,h=280+d.ua,g=e.Pb?c:16777216,_=0<d.ua?d.Wa:null,v=d.wc,y=f<m?Oe(d,l,c):null;t(e.C<o),t(m<=a);var b=!1;t:for(;;){for(;b||f<m;){var x=0;if(c>=g){var E=f-r;t((g=e).Pb),g.wd=g.m,g.xd=E,0<g.s.ua&&P(g.s.Wa,g.s.vb),g=c+ri}if(l&v||(y=Oe(d,l,c)),t(y!=null),y.Qb&&(n[f]=y.qb,b=!0),!b){if(T(u),y.jc){x=u,E=n;var D=f,O=y.pd[S(x)&Gn-1];t(y.jc),256>O.g?(w(x,x.u+O.g),E[D]=O.value,x=0):(w(x,x.u+O.g-256),t(256<=O.value),x=O.value),x==0&&(b=!0)}else x=Ee(y.G[0],y.H[0],u)}if(u.h)break;if(b||256>x){if(!b){if(y.nd)n[f]=(y.qb|x<<8)>>>0;else{if(T(u),b=Ee(y.G[1],y.H[1],u),T(u),E=Ee(y.G[2],y.H[2],u),D=Ee(y.G[3],y.H[3],u),u.h)break;n[f]=(D<<24|b<<16|x<<8|E)>>>0}}if(b=!1,++f,++l>=i&&(l=0,++c,s!=null&&c<=o&&!(c%16)&&s(e,c),_!=null))for(;p<f;)x=n[p++],_.X[(506832829*x&4294967295)>>>_.Mb]=x}else if(280>x){if(x=we(x-256,u),E=Ee(y.G[4],y.H[4],u),T(u),E=Te(i,E=we(E,u)),u.h)break;if(f-r<E||a-f<x)break t;for(D=0;D<x;++D)n[f+D]=n[f+D-E];for(f+=x,l+=x;l>=i;)l-=i,++c,s!=null&&c<=o&&!(c%16)&&s(e,c);if(t(f<=a),l&v&&(y=Oe(d,l,c)),_!=null)for(;p<f;)x=n[p++],_.X[(506832829*x&4294967295)>>>_.Mb]=x}else{if(!(x<h))break t;for(b=x-280,t(_!=null);p<f;)x=n[p++],_.X[(506832829*x&4294967295)>>>_.Mb]=x;x=f,t(!(b>>>(E=_).Xa)),n[x]=E.X[b],b=!0}b||t(u.h==C(u))}if(e.Pb&&u.h&&f<a)t(e.m.h),e.a=5,e.m=e.wd,e.$=e.xd,0<e.s.ua&&P(e.s.vb,e.s.Wa);else{if(u.h)break t;s?.(e,c>o?o:c),e.a=0,e.$=f-r}return 1}return e.a=3,0}function Fe(e){t(e!=null),e.vc=null,e.yc=null,e.Ya=null;var n=e.Wa;n!=null&&(n.X=null),e.vb=null,t(e!=null)}function Ie(){var t=new pn;return t==null?null:(t.a=0,t.xb=vi,ue(`Predictor`,`VP8LPredictors`),ue(`Predictor`,`VP8LPredictors_C`),ue(`PredictorAdd`,`VP8LPredictorsAdd`),ue(`PredictorAdd`,`VP8LPredictorsAdd_C`),$n=H,ir=U,ar=ae,or=G,sr=oe,J=se,cr=ce,e.VP8LMapColor32b=tr,e.VP8LMapColor8b=nr,t)}function Le(e,n,r,s,c){var l=1,f=[e],m=[n],h=s.m,g=s.s,_=null,v=0;t:for(;;){if(r)for(;l&&y(h,1);){var b=f,x=m,C=s,E=1,D=C.m,O=C.gc[C.ab],k=y(D,2);if(C.Oc&1<<k)l=0;else{switch(C.Oc|=1<<k,O.hc=k,O.Ea=b[0],O.nc=x[0],O.K=[null],++C.ab,t(4>=C.ab),k){case 0:case 1:O.b=y(D,3)+2,E=Le(L(O.Ea,O.b),L(O.nc,O.b),0,C,O.K),O.K=O.K[0];break;case 3:var A,j=y(D,8)+1,M=16<j?0:4<j?1:2<j?2:3;if(b[0]=L(O.Ea,M),O.b=M,A=E=Le(j,1,0,C,O.K)){var P,F=j,I=O,z=1<<(8>>I.b),B=a(z);if(B==null)A=0;else{var V=I.K[0],ee=I.w;for(B[0]=I.K[0][0],P=1;P<1*F;++P)B[P]=R(V[ee+P],B[P-1]);for(;P<4*z;++P)B[P]=0;I.K[0]=null,I.K[0]=B,A=1}}E=A;break;case 2:break;default:t(0)}l=E}}if(f=f[0],m=m[0],l&&y(h,1)&&!(l=1<=(v=y(h,4))&&11>=v)){s.a=3;break t}var te;if(te=l)e:{var ne,re,H,ie=s,U=f,W=m,ae=v,G=r,oe=ie.m,se=ie.s,ce=[null],le=1,ue=0,de=ni[ae];r:for(;;){if(G&&y(oe,1)){var fe=y(oe,3)+2,pe=L(U,fe),me=L(W,fe),he=pe*me;if(!Le(pe,me,0,ie,ce))break r;for(ce=ce[0],se.xc=fe,ne=0;ne<he;++ne){var ge=ce[ne]>>8&65535;ce[ne]=ge,ge>=le&&(le=ge+1)}}if(oe.h)break r;for(re=0;5>re;++re){var _e=Qr[re];!re&&0<ae&&(_e+=1<<ae),ue<_e&&(ue=_e)}var ve=o(le*de,d),ye=le,be=o(ye,p);if(be==null)var xe=null;else t(65536>=ye),xe=be;var Se=a(ue);if(xe==null||Se==null||ve==null){ie.a=1;break r}var Ce=ve;for(ne=H=0;ne<le;++ne){var we=xe[ne],Te=we.G,Ee=we.H,Oe=0,ke=1,Ae=0;for(re=0;5>re;++re){_e=Qr[re],Te[re]=Ce,Ee[re]=H,!re&&0<ae&&(_e+=1<<ae);n:{var je,Me=_e,Ne=ie,Ie=Se,Re=Ce,ze=H,Be=0,K=Ne.m,Ve=y(K,1);if(i(Ie,0,0,Me),Ve){var He=y(K,1)+1,Ue=y(K,y(K,1)==0?1:8);Ie[Ue]=1,He==2&&(Ie[Ue=y(K,8)]=1);var We=1}else{var Ge=a(19),Ke=y(K,4)+4;if(19<Ke){Ne.a=3;var qe=0;break n}for(je=0;je<Ke;++je)Ge[ei[je]]=y(K,3);var Je=void 0,Ye=void 0,Xe=Ne,Ze=Ge,Qe=Me,$e=Ie,et=0,tt=Xe.m,nt=8,rt=o(128,d);i:for(;u(rt,0,7,Ze,19);){if(y(tt,1)){if((Je=2+y(tt,2+2*y(tt,3)))>Qe)break i}else Je=Qe;for(Ye=0;Ye<Qe&&Je--;){T(tt);var it=rt[0+(127&S(tt))];w(tt,tt.u+it.g);var at=it.value;if(16>at)$e[Ye++]=at,at!=0&&(nt=at);else{var ot=at==16,st=at-16,ct=Zr[st],lt=y(tt,Xr[st])+ct;if(Ye+lt>Qe)break i;for(var ut=ot?nt:0;0<lt--;)$e[Ye++]=ut}}et=1;break i}et||(Xe.a=3),We=et}(We&&=!K.h)&&(Be=u(Re,ze,8,Ie,Me)),We&&Be!=0?qe=Be:(Ne.a=3,qe=0)}if(qe==0)break r;if(ke&&$r[re]==1&&(ke=Ce[H].g==0),Oe+=Ce[H].g,H+=qe,3>=re){var dt,ft=Se[0];for(dt=1;dt<_e;++dt)Se[dt]>ft&&(ft=Se[dt]);Ae+=ft}}if(we.nd=ke,we.Qb=0,ke&&(we.qb=(Te[3][Ee[3]+0].value<<24|Te[1][Ee[1]+0].value<<16|Te[2][Ee[2]+0].value)>>>0,Oe==0&&256>Te[0][Ee[0]+0].value&&(we.Qb=1,we.qb+=Te[0][Ee[0]+0].value<<8)),we.jc=!we.Qb&&6>Ae,we.jc){var pt,mt=we;for(pt=0;pt<Gn;++pt){var ht=pt,gt=mt.pd[ht],_t=mt.G[0][mt.H[0]+ht];256<=_t.value?(gt.g=_t.g+256,gt.value=_t.value):(gt.g=0,gt.value=0,ht>>=De(_t,8,gt),ht>>=De(mt.G[1][mt.H[1]+ht],16,gt),ht>>=De(mt.G[2][mt.H[2]+ht],0,gt),De(mt.G[3][mt.H[3]+ht],24,gt))}}}se.vc=ce,se.Wb=le,se.Ya=xe,se.yc=ve,te=1;break e}te=0}if(!(l=te)){s.a=3;break t}if(0<v){if(g.ua=1<<v,!N(g.Wa,v)){s.a=1,l=0;break t}}else g.ua=0;var vt=s,yt=f,bt=m,xt=vt.s,St=xt.xc;if(vt.c=yt,vt.i=bt,xt.md=L(yt,St),xt.wc=St==0?-1:(1<<St)-1,r){s.xb=_i;break t}if((_=a(f*m))==null){s.a=1,l=0;break t}l=(l=Pe(s,_,0,f,m,m,null))&&!h.h;break t}return l?(c==null?(t(_==null),t(r)):c[0]=_,s.$=0,r||Fe(g)):Fe(g),l}function Re(e,n){var r=e.c*e.i,i=r+n+16*n;return t(e.c<=n),e.V=a(i),e.V==null?(e.Ta=null,e.Ua=0,e.a=1,0):(e.Ta=e.V,e.Ua=e.Ba+r+n,1)}function ze(e,n){var r=e.C,i=n-r,a=e.V,o=e.Ba+e.c*r;for(t(n<=e.l.o);0<i;){var s=16<i?16:i,c=e.l.ma,l=e.l.width,u=l*s,d=c.ca,f=c.tb+l*r,p=e.Ta,m=e.Ua;ke(e,s,a,o),kr(p,m,d,f,u),Me(c,r,r+s,d,f,l),i-=s,a+=s*e.c,r+=s}t(r==n),e.C=e.Ma=n}function Be(){this.ub=this.yd=this.td=this.Rb=0}function K(){this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0}function Ve(){this.Fb=this.Bb=this.Cb=0,this.Zb=a(4),this.Lb=a(4)}function He(){this.Yb=function(){var e=[];return function e(t,n,r){for(var i=r[n],a=0;a<i&&(t.push(r.length>n+1?[]:0),!(r.length<n+1));a++)e(t[a],n+1,r)}(e,0,[3,11]),e}()}function Ue(){this.jb=a(3),this.Wc=s([4,8],He),this.Xc=s([4,17],He)}function We(){this.Pc=this.wb=this.Tb=this.zd=0,this.vd=new a(4),this.od=new a(4)}function Ge(){this.ld=this.La=this.dd=this.tc=0}function Ke(){this.Na=this.la=0}function qe(){this.Sc=[0,0],this.Eb=[0,0],this.Qc=[0,0],this.ia=this.lc=0}function Je(){this.ad=a(384),this.Za=0,this.Ob=a(16),this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0}function Ye(){this.uc=this.M=this.Nb=0,this.wa=Array(new Ge),this.Y=0,this.ya=Array(new Je),this.aa=0,this.l=new $e}function Xe(){this.y=a(16),this.f=a(8),this.ea=a(8)}function Ze(){this.cb=this.a=0,this.sc=``,this.m=new b,this.Od=new Be,this.Kc=new K,this.ed=new We,this.Qa=new Ve,this.Ic=this.$c=this.Aa=0,this.D=new Ye,this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0,this.Jc=o(8,b),this.ia=0,this.pb=o(4,qe),this.Pa=new Ue,this.Bd=this.kc=0,this.Ac=[],this.Bc=0,this.zc=[0,0,0,0],this.Gd=Array(new Xe),this.Hd=0,this.rb=Array(new Ke),this.sb=0,this.wa=Array(new Ge),this.Y=0,this.oc=[],this.pc=0,this.sa=[],this.ta=0,this.qa=[],this.ra=0,this.Ha=[],this.B=this.R=this.Ia=0,this.Ec=[],this.M=this.ja=this.Vb=this.Fc=0,this.ya=Array(new Je),this.L=this.aa=0,this.gd=s([4,2],Ge),this.ga=null,this.Fa=[],this.Cc=this.qc=this.P=0,this.Gb=[],this.Uc=0,this.mb=[],this.nb=0,this.rc=[],this.Ga=this.Vc=0}function Qe(e,t){return 0>e?0:e>t?t:e}function $e(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma=`void`,this.put=`VP8IoPutHook`,this.ac=`VP8IoSetupHook`,this.bc=`VP8IoTeardownHook`,this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function et(){var e=new Ze;return e!=null&&(e.a=0,e.sc=`OK`,e.cb=0,e.Xb=0,oi||=it),e}function tt(e,t,n){return e.a==0&&(e.a=t,e.sc=n,e.cb=0),0}function nt(e,t,n){return 3<=n&&e[t+0]==157&&e[t+1]==1&&e[t+2]==42}function rt(e,n){if(e==null)return 0;if(e.a=0,e.sc=`OK`,n==null)return tt(e,2,`null VP8Io passed to VP8GetHeaders()`);var r=n.data,a=n.w,o=n.ha;if(4>o)return tt(e,7,`Truncated header.`);var s=r[a+0]|r[a+1]<<8|r[a+2]<<16,c=e.Od;if(c.Rb=!(1&s),c.td=s>>1&7,c.yd=s>>4&1,c.ub=s>>5,3<c.td)return tt(e,3,`Incorrect keyframe parameters.`);if(!c.yd)return tt(e,4,`Frame not displayable.`);a+=3,o-=3;var l=e.Kc;if(c.Rb){if(7>o)return tt(e,7,`cannot parse picture header`);if(!nt(r,a,o))return tt(e,3,`Bad code word`);l.c=16383&(r[a+4]<<8|r[a+3]),l.Td=r[a+4]>>6,l.i=16383&(r[a+6]<<8|r[a+5]),l.Ud=r[a+6]>>6,a+=7,o-=7,e.za=l.c+15>>4,e.Ub=l.i+15>>4,n.width=l.c,n.height=l.i,n.Da=0,n.j=0,n.v=0,n.va=n.width,n.o=n.height,n.da=0,n.ib=n.width,n.hb=n.height,n.U=n.width,n.T=n.height,i((s=e.Pa).jb,0,255,s.jb.length),t((s=e.Qa)!=null),s.Cb=0,s.Bb=0,s.Fb=1,i(s.Zb,0,0,s.Zb.length),i(s.Lb,0,0,s.Lb)}if(c.ub>o)return tt(e,7,`bad partition length`);m(s=e.m,r,a,c.ub),a+=c.ub,o-=c.ub,c.Rb&&(l.Ld=D(s),l.Kd=D(s)),l=e.Qa;var u,d=e.Pa;if(t(s!=null),t(l!=null),l.Cb=D(s),l.Cb){if(l.Bb=D(s),D(s)){for(l.Fb=D(s),u=0;4>u;++u)l.Zb[u]=D(s)?g(s,7):0;for(u=0;4>u;++u)l.Lb[u]=D(s)?g(s,6):0}if(l.Bb)for(u=0;3>u;++u)d.jb[u]=D(s)?h(s,8):255}else l.Bb=0;if(s.Ka)return tt(e,3,`cannot parse segment header`);if((l=e.ed).zd=D(s),l.Tb=h(s,6),l.wb=h(s,3),l.Pc=D(s),l.Pc&&D(s)){for(d=0;4>d;++d)D(s)&&(l.vd[d]=g(s,6));for(d=0;4>d;++d)D(s)&&(l.od[d]=g(s,6))}if(e.L=l.Tb==0?0:l.zd?1:2,s.Ka)return tt(e,3,`cannot parse filter header`);var f=o;if(o=u=a,a=u+f,l=f,e.Xb=(1<<h(e.m,2))-1,f<3*(d=e.Xb))r=7;else{for(u+=3*d,l-=3*d,f=0;f<d;++f){var p=r[o+0]|r[o+1]<<8|r[o+2]<<16;p>l&&(p=l),m(e.Jc[+f],r,u,p),u+=p,l-=p,o+=3}m(e.Jc[+d],r,u,l),r=u<a?0:5}if(r!=0)return tt(e,r,`cannot parse partitions`);for(r=h(u=e.m,7),o=D(u)?g(u,4):0,a=D(u)?g(u,4):0,l=D(u)?g(u,4):0,d=D(u)?g(u,4):0,u=D(u)?g(u,4):0,f=e.Qa,p=0;4>p;++p){if(f.Cb){var _=f.Zb[p];f.Fb||(_+=r)}else{if(0<p){e.pb[p]=e.pb[0];continue}_=r}var v=e.pb[p];v.Sc[0]=ii[Qe(_+o,127)],v.Sc[1]=ai[Qe(_+0,127)],v.Eb[0]=2*ii[Qe(_+a,127)],v.Eb[1]=101581*ai[Qe(_+l,127)]>>16,8>v.Eb[1]&&(v.Eb[1]=8),v.Qc[0]=ii[Qe(_+d,117)],v.Qc[1]=ai[Qe(_+u,127)],v.lc=_+u}if(!c.Rb)return tt(e,4,`Not a key frame.`);for(D(s),c=e.Pa,r=0;4>r;++r){for(o=0;8>o;++o)for(a=0;3>a;++a)for(l=0;11>l;++l)d=O(s,fi[r][o][a][l])?h(s,8):ui[r][o][a][l],c.Wc[r][o].Yb[a][l]=d;for(o=0;17>o;++o)c.Xc[r][o]=c.Wc[r][pi[o]]}return e.kc=D(s),e.kc&&(e.Bd=h(s,8)),e.cb=1}function it(e,t,n,r,i,a,o){var s=t[i].Yb[n];for(n=0;16>i;++i){if(!O(e,s[n+0]))return i;for(;!O(e,s[n+1]);)if(s=t[++i].Yb[0],n=0,i==16)return 16;var c=t[i+1].Yb;if(O(e,s[n+2])){var l=e,u=0;if(O(l,(f=s)[(d=n)+3])){if(O(l,f[d+6])){for(s=0,d=2*(u=O(l,f[d+8]))+(f=O(l,f[d+9+u])),u=0,f=si[d];f[s];++s)u+=u+O(l,f[s]);u+=3+(8<<d)}else O(l,f[d+7])?(u=7+2*O(l,165),u+=O(l,145)):u=5+O(l,159)}else u=O(l,f[d+4])?3+O(l,f[d+5]):2;s=c[2]}else u=1,s=c[1];c=o+ci[i],0>(l=e).b&&E(l);var d,f=l.b,p=(d=l.Ca>>1)-(l.I>>f)>>31;--l.b,l.Ca+=p,l.Ca|=1,l.I-=(d+1&p)<<f,a[c]=((u^p)-p)*r[(0<i)+0]}return 16}function at(e){var t=e.rb[e.sb-1];t.la=0,t.Na=0,i(e.zc,0,0,e.zc.length),e.ja=0}function ot(e,t,n,r,i){i=e[t+n+32*r]+(i>>3),e[t+n+32*r]=-256&i?0>i?0:255:i}function st(e,t,n,r,i,a){ot(e,t,0,n,r+i),ot(e,t,1,n,r+a),ot(e,t,2,n,r-a),ot(e,t,3,n,r-i)}function ct(e){return(20091*e>>16)+e}function lt(e,t,n,r){var i,o=0,s=a(16);for(i=0;4>i;++i){var c=e[t+0]+e[t+8],l=e[t+0]-e[t+8],u=(35468*e[t+4]>>16)-ct(e[t+12]),d=ct(e[t+4])+(35468*e[t+12]>>16);s[o+0]=c+d,s[o+1]=l+u,s[o+2]=l-u,s[o+3]=c-d,o+=4,t++}for(i=o=0;4>i;++i)c=(e=s[o+0]+4)+s[o+8],l=e-s[o+8],u=(35468*s[o+4]>>16)-ct(s[o+12]),ot(n,r,0,0,c+(d=ct(s[o+4])+(35468*s[o+12]>>16))),ot(n,r,1,0,l+u),ot(n,r,2,0,l-u),ot(n,r,3,0,c-d),o++,r+=32}function ut(e,t,n,r){var i=e[t+0]+4,a=35468*e[t+4]>>16,o=ct(e[t+4]),s=35468*e[t+1]>>16;st(n,r,0,i+o,e=ct(e[t+1]),s),st(n,r,1,i+a,e,s),st(n,r,2,i-a,e,s),st(n,r,3,i-o,e,s)}function dt(e,t,n,r,i){lt(e,t,n,r),i&<(e,t+16,n,r+4)}function ft(e,t,n,r){ur(e,t+0,n,r,1),ur(e,t+32,n,r+128,1)}function pt(e,t,n,r){var i;for(e=e[t+0]+4,i=0;4>i;++i)for(t=0;4>t;++t)ot(n,r,t,i,e)}function mt(e,t,n,r){e[t+0]&&pr(e,t+0,n,r),e[t+16]&&pr(e,t+16,n,r+4),e[t+32]&&pr(e,t+32,n,r+128),e[t+48]&&pr(e,t+48,n,r+128+4)}function ht(e,t,n,r){var i,o=a(16);for(i=0;4>i;++i){var s=e[t+0+i]+e[t+12+i],c=e[t+4+i]+e[t+8+i],l=e[t+4+i]-e[t+8+i],u=e[t+0+i]-e[t+12+i];o[0+i]=s+c,o[8+i]=s-c,o[4+i]=u+l,o[12+i]=u-l}for(i=0;4>i;++i)s=(e=o[0+4*i]+3)+o[3+4*i],c=o[1+4*i]+o[2+4*i],l=o[1+4*i]-o[2+4*i],u=e-o[3+4*i],n[r+0]=s+c>>3,n[r+16]=u+l>>3,n[r+32]=s-c>>3,n[r+48]=u-l>>3,r+=64}function gt(e,t,n){var r,i=t-32,a=Lr,o=255-e[i-1];for(r=0;r<n;++r){var s,c=a,l=o+e[t-1];for(s=0;s<n;++s)e[t+s]=c[l+e[i+s]];t+=32}}function _t(e,t){gt(e,t,4)}function vt(e,t){gt(e,t,8)}function yt(e,t){gt(e,t,16)}function bt(e,t){var n;for(n=0;16>n;++n)r(e,t+32*n,e,t-32,16)}function xt(e,t){var n;for(n=16;0<n;--n)i(e,t,e[t-1],16),t+=32}function St(e,t,n){var r;for(r=0;16>r;++r)i(t,n+32*r,e,16)}function Ct(e,t){var n,r=16;for(n=0;16>n;++n)r+=e[t-1+32*n]+e[t+n-32];St(r>>5,e,t)}function wt(e,t){var n,r=8;for(n=0;16>n;++n)r+=e[t-1+32*n];St(r>>4,e,t)}function Tt(e,t){var n,r=8;for(n=0;16>n;++n)r+=e[t+n-32];St(r>>4,e,t)}function Et(e,t){St(128,e,t)}function Dt(e,t,n){return e+2*t+n+2>>2}function Ot(e,t){var n,i=t-32;for(i=new Uint8Array([Dt(e[i-1],e[i+0],e[i+1]),Dt(e[i+0],e[i+1],e[i+2]),Dt(e[i+1],e[i+2],e[i+3]),Dt(e[i+2],e[i+3],e[i+4])]),n=0;4>n;++n)r(e,t+32*n,i,0,i.length)}function kt(e,t){var n=e[t-1],r=e[t-1+32],i=e[t-1+64],a=e[t-1+96];k(e,t+0,16843009*Dt(e[t-1-32],n,r)),k(e,t+32,16843009*Dt(n,r,i)),k(e,t+64,16843009*Dt(r,i,a)),k(e,t+96,16843009*Dt(i,a,a))}function At(e,t){var n,r=4;for(n=0;4>n;++n)r+=e[t+n-32]+e[t-1+32*n];for(r>>=3,n=0;4>n;++n)i(e,t+32*n,r,4)}function jt(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1-32],o=e[t+0-32],s=e[t+1-32],c=e[t+2-32],l=e[t+3-32];e[t+0+96]=Dt(r,i,e[t-1+96]),e[t+1+96]=e[t+0+64]=Dt(n,r,i),e[t+2+96]=e[t+1+64]=e[t+0+32]=Dt(a,n,r),e[t+3+96]=e[t+2+64]=e[t+1+32]=e[t+0+0]=Dt(o,a,n),e[t+3+64]=e[t+2+32]=e[t+1+0]=Dt(s,o,a),e[t+3+32]=e[t+2+0]=Dt(c,s,o),e[t+3+0]=Dt(l,c,s)}function Mt(e,t){var n=e[t+1-32],r=e[t+2-32],i=e[t+3-32],a=e[t+4-32],o=e[t+5-32],s=e[t+6-32],c=e[t+7-32];e[t+0+0]=Dt(e[t+0-32],n,r),e[t+1+0]=e[t+0+32]=Dt(n,r,i),e[t+2+0]=e[t+1+32]=e[t+0+64]=Dt(r,i,a),e[t+3+0]=e[t+2+32]=e[t+1+64]=e[t+0+96]=Dt(i,a,o),e[t+3+32]=e[t+2+64]=e[t+1+96]=Dt(a,o,s),e[t+3+64]=e[t+2+96]=Dt(o,s,c),e[t+3+96]=Dt(s,c,c)}function Nt(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1-32],o=e[t+0-32],s=e[t+1-32],c=e[t+2-32],l=e[t+3-32];e[t+0+0]=e[t+1+64]=a+o+1>>1,e[t+1+0]=e[t+2+64]=o+s+1>>1,e[t+2+0]=e[t+3+64]=s+c+1>>1,e[t+3+0]=c+l+1>>1,e[t+0+96]=Dt(i,r,n),e[t+0+64]=Dt(r,n,a),e[t+0+32]=e[t+1+96]=Dt(n,a,o),e[t+1+32]=e[t+2+96]=Dt(a,o,s),e[t+2+32]=e[t+3+96]=Dt(o,s,c),e[t+3+32]=Dt(s,c,l)}function Pt(e,t){var n=e[t+0-32],r=e[t+1-32],i=e[t+2-32],a=e[t+3-32],o=e[t+4-32],s=e[t+5-32],c=e[t+6-32],l=e[t+7-32];e[t+0+0]=n+r+1>>1,e[t+1+0]=e[t+0+64]=r+i+1>>1,e[t+2+0]=e[t+1+64]=i+a+1>>1,e[t+3+0]=e[t+2+64]=a+o+1>>1,e[t+0+32]=Dt(n,r,i),e[t+1+32]=e[t+0+96]=Dt(r,i,a),e[t+2+32]=e[t+1+96]=Dt(i,a,o),e[t+3+32]=e[t+2+96]=Dt(a,o,s),e[t+3+64]=Dt(o,s,c),e[t+3+96]=Dt(s,c,l)}function Ft(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1+96];e[t+0+0]=n+r+1>>1,e[t+2+0]=e[t+0+32]=r+i+1>>1,e[t+2+32]=e[t+0+64]=i+a+1>>1,e[t+1+0]=Dt(n,r,i),e[t+3+0]=e[t+1+32]=Dt(r,i,a),e[t+3+32]=e[t+1+64]=Dt(i,a,a),e[t+3+64]=e[t+2+64]=e[t+0+96]=e[t+1+96]=e[t+2+96]=e[t+3+96]=a}function It(e,t){var n=e[t-1+0],r=e[t-1+32],i=e[t-1+64],a=e[t-1+96],o=e[t-1-32],s=e[t+0-32],c=e[t+1-32],l=e[t+2-32];e[t+0+0]=e[t+2+32]=n+o+1>>1,e[t+0+32]=e[t+2+64]=r+n+1>>1,e[t+0+64]=e[t+2+96]=i+r+1>>1,e[t+0+96]=a+i+1>>1,e[t+3+0]=Dt(s,c,l),e[t+2+0]=Dt(o,s,c),e[t+1+0]=e[t+3+32]=Dt(n,o,s),e[t+1+32]=e[t+3+64]=Dt(r,n,o),e[t+1+64]=e[t+3+96]=Dt(i,r,n),e[t+1+96]=Dt(a,i,r)}function Lt(e,t){var n;for(n=0;8>n;++n)r(e,t+32*n,e,t-32,8)}function Rt(e,t){var n;for(n=0;8>n;++n)i(e,t,e[t-1],8),t+=32}function zt(e,t,n){var r;for(r=0;8>r;++r)i(t,n+32*r,e,8)}function Bt(e,t){var n,r=8;for(n=0;8>n;++n)r+=e[t+n-32]+e[t-1+32*n];zt(r>>4,e,t)}function Vt(e,t){var n,r=4;for(n=0;8>n;++n)r+=e[t+n-32];zt(r>>3,e,t)}function Ht(e,t){var n,r=4;for(n=0;8>n;++n)r+=e[t-1+32*n];zt(r>>3,e,t)}function Ut(e,t){zt(128,e,t)}function Wt(e,t,n){var r=e[t-n],i=e[t+0],a=3*(i-r)+Fr[1020+e[t-2*n]-e[t+n]],o=Ir[112+(a+4>>3)];e[t-n]=Lr[255+r+Ir[112+(a+3>>3)]],e[t+0]=Lr[255+i-o]}function Gt(e,t,n,r){var i=e[t+0],a=e[t+n];return Rr[255+e[t-2*n]-e[t-n]]>r||Rr[255+a-i]>r}function Kt(e,t,n,r){return 4*Rr[255+e[t-n]-e[t+0]]+Rr[255+e[t-2*n]-e[t+n]]<=r}function qt(e,t,n,r,i){var a=e[t-3*n],o=e[t-2*n],s=e[t-n],c=e[t+0],l=e[t+n],u=e[t+2*n],d=e[t+3*n];return 4*Rr[255+s-c]+Rr[255+o-l]>r?0:Rr[255+e[t-4*n]-a]<=i&&Rr[255+a-o]<=i&&Rr[255+o-s]<=i&&Rr[255+d-u]<=i&&Rr[255+u-l]<=i&&Rr[255+l-c]<=i}function Jt(e,t,n,r){var i=2*r+1;for(r=0;16>r;++r)Kt(e,t+r,n,i)&&Wt(e,t+r,n)}function Yt(e,t,n,r){var i=2*r+1;for(r=0;16>r;++r)Kt(e,t+r*n,1,i)&&Wt(e,t+r*n,1)}function Xt(e,t,n,r){var i;for(i=3;0<i;--i)Jt(e,t+=4*n,n,r)}function Zt(e,t,n,r){var i;for(i=3;0<i;--i)Yt(e,t+=4,n,r)}function Qt(e,t,n,r,i,a,o,s){for(a=2*a+1;0<i--;){if(qt(e,t,n,a,o)){if(Gt(e,t,n,s))Wt(e,t,n);else{var c=e,l=t,u=n,d=c[l-2*u],f=c[l-u],p=c[l+0],m=c[l+u],h=c[l+2*u],g=27*(v=Fr[1020+3*(p-f)+Fr[1020+d-m]])+63>>7,_=18*v+63>>7,v=9*v+63>>7;c[l-3*u]=Lr[255+c[l-3*u]+v],c[l-2*u]=Lr[255+d+_],c[l-u]=Lr[255+f+g],c[l+0]=Lr[255+p-g],c[l+u]=Lr[255+m-_],c[l+2*u]=Lr[255+h-v]}}t+=r}}function $t(e,t,n,r,i,a,o,s){for(a=2*a+1;0<i--;){if(qt(e,t,n,a,o)){if(Gt(e,t,n,s))Wt(e,t,n);else{var c=e,l=t,u=n,d=c[l-u],f=c[l+0],p=c[l+u],m=Ir[112+(4+(h=3*(f-d))>>3)],h=Ir[112+(h+3>>3)],g=m+1>>1;c[l-2*u]=Lr[255+c[l-2*u]+g],c[l-u]=Lr[255+d+h],c[l+0]=Lr[255+f-m],c[l+u]=Lr[255+p-g]}}t+=r}}function en(e,t,n,r,i,a){Qt(e,t,n,1,16,r,i,a)}function tn(e,t,n,r,i,a){Qt(e,t,1,n,16,r,i,a)}function nn(e,t,n,r,i,a){var o;for(o=3;0<o;--o)$t(e,t+=4*n,n,1,16,r,i,a)}function rn(e,t,n,r,i,a){var o;for(o=3;0<o;--o)$t(e,t+=4,1,n,16,r,i,a)}function an(e,t,n,r,i,a,o,s){Qt(e,t,i,1,8,a,o,s),Qt(n,r,i,1,8,a,o,s)}function on(e,t,n,r,i,a,o,s){Qt(e,t,1,i,8,a,o,s),Qt(n,r,1,i,8,a,o,s)}function sn(e,t,n,r,i,a,o,s){$t(e,t+4*i,i,1,8,a,o,s),$t(n,r+4*i,i,1,8,a,o,s)}function cn(e,t,n,r,i,a,o,s){$t(e,t+4,1,i,8,a,o,s),$t(n,r+4,1,i,8,a,o,s)}function ln(){this.ba=new me,this.ec=[],this.cc=[],this.Mc=[],this.Dc=this.Nc=this.dc=this.fc=0,this.Oa=new ge,this.memory=0,this.Ib=`OutputFunc`,this.Jb=`OutputAlphaFunc`,this.Nd=`OutputRowFunc`}function un(){this.data=[],this.offset=this.kd=this.ha=this.w=0,this.na=[],this.xa=this.gb=this.Ja=this.Sa=this.P=0}function dn(){this.nc=this.Ea=this.b=this.hc=0,this.K=[],this.w=0}function fn(){this.ua=0,this.Wa=new F,this.vb=new F,this.md=this.xc=this.wc=0,this.vc=[],this.Wb=0,this.Ya=new p,this.yc=new d}function pn(){this.xb=this.a=0,this.l=new $e,this.ca=new me,this.V=[],this.Ba=0,this.Ta=[],this.Ua=0,this.m=new x,this.Pb=0,this.wd=new x,this.Ma=this.$=this.C=this.i=this.c=this.xd=0,this.s=new fn,this.ab=0,this.gc=o(4,dn),this.Oc=0}function mn(){this.Lc=this.Z=this.$a=this.i=this.c=0,this.l=new $e,this.ic=0,this.ca=[],this.tb=0,this.qd=null,this.rd=0}function hn(e,t,n,r,i,a,o){for(e=e==null?0:e[t+0],t=0;t<o;++t)i[a+t]=e+n[r+t]&255,e=i[a+t]}function gn(e,t,n,r,i,a,o){var s;if(e==null)hn(null,null,n,r,i,a,o);else for(s=0;s<o;++s)i[a+s]=e[t+s]+n[r+s]&255}function _n(e,t,n,r,i,a,o){if(e==null)hn(null,null,n,r,i,a,o);else{var s,c=e[t+0],l=c,u=c;for(s=0;s<o;++s)l=u+(c=e[t+s])-l,u=n[r+s]+(-256&l?0>l?0:255:l)&255,l=c,i[a+s]=u}}function vn(e,n,i,o){var s=n.width,c=n.o;if(t(e!=null&&n!=null),0>i||0>=o||i+o>c)return null;if(!e.Cc){if(e.ga==null){var l;if(e.ga=new mn,(l=e.ga==null)||(l=n.width*n.o,t(e.Gb.length==0),e.Gb=a(l),e.Uc=0,e.Gb==null?l=0:(e.mb=e.Gb,e.nb=e.Uc,e.rc=null,l=1),l=!l),!l){l=e.ga;var u=e.Fa,d=e.P,f=e.qc,p=e.mb,m=e.nb,h=d+1,g=f-1,v=l.l;if(t(u!=null&&p!=null&&n!=null),yi[0]=null,yi[1]=hn,yi[2]=gn,yi[3]=_n,l.ca=p,l.tb=m,l.c=n.width,l.i=n.height,t(0<l.c&&0<l.i),1>=f)n=0;else if(l.$a=3&u[d+0],l.Z=u[d+0]>>2&3,l.Lc=u[d+0]>>4&3,d=u[d+0]>>6&3,0>l.$a||1<l.$a||4<=l.Z||1<l.Lc||d)n=0;else if(v.put=xe,v.ac=be,v.bc=Se,v.ma=l,v.width=n.width,v.height=n.height,v.Da=n.Da,v.v=n.v,v.va=n.va,v.j=n.j,v.o=n.o,l.$a)t:{t(l.$a==1),n=Ie();e:for(;;){if(n==null){n=0;break t}if(t(l!=null),l.mc=n,n.c=l.c,n.i=l.i,n.l=l.l,n.l.ma=l,n.l.width=l.c,n.l.height=l.i,n.a=0,_(n.m,u,h,g),!Le(l.c,l.i,1,n,null)||(n.ab==1&&n.gc[0].hc==3&&je(n.s)?(l.ic=1,u=n.c*n.i,n.Ta=null,n.Ua=0,n.V=a(u),n.Ba=0,n.V==null?(n.a=1,n=0):n=1):(l.ic=0,n=Re(n,l.c)),!n))break e;n=1;break t}l.mc=null,n=0}else n=g>=l.c*l.i;l=!n}if(l)return null;e.ga.Lc==1?o=c-i:e.Ga=0}t(e.ga!=null),t(i+o<=c);t:{if(n=(u=e.ga).c,c=u.l.o,u.$a==0){if(h=e.rc,g=e.Vc,v=e.Fa,d=e.P+1+i*n,f=e.mb,p=e.nb+i*n,t(d<=e.P+e.qc),u.Z!=0)for(t(yi[u.Z]!=null),l=0;l<o;++l)yi[u.Z](h,g,v,d,f,p,n),h=f,g=p,p+=n,d+=n;else for(l=0;l<o;++l)r(f,p,v,d,n),h=f,g=p,p+=n,d+=n;e.rc=h,e.Vc=g}else{if(t(u.mc!=null),n=i+o,t((l=u.mc)!=null),t(n<=l.i),l.C>=n)n=1;else if(u.ic||Cn(),u.ic){u=l.V,h=l.Ba,g=l.c;var y=l.i,b=(v=1,d=l.$/g,f=l.$%g,p=l.m,m=l.s,l.$),x=g*y,S=g*n,w=m.wc,E=b<S?Oe(m,f,d):null;t(b<=x),t(n<=y),t(je(m));e:for(;;){for(;!p.h&&b<S;){if(f&w||(E=Oe(m,f,d)),t(E!=null),T(p),256>(y=Ee(E.G[0],E.H[0],p)))u[h+b]=y,++b,++f>=g&&(f=0,++d<=n&&!(d%16)&&Ne(l,d));else{if(!(280>y)){v=0;break e}y=we(y-256,p);var D,O=Ee(E.G[4],E.H[4],p);if(T(p),!(b>=(O=Te(g,O=we(O,p)))&&x-b>=y)){v=0;break e}for(D=0;D<y;++D)u[h+b+D]=u[h+b+D-O];for(b+=y,f+=y;f>=g;)f-=g,++d<=n&&!(d%16)&&Ne(l,d);b<S&&f&w&&(E=Oe(m,f,d))}t(p.h==C(p))}Ne(l,d>n?n:d);break e}!v||p.h&&b<x?(v=0,l.a=p.h?5:3):l.$=b,n=v}else n=Pe(l,l.V,l.Ba,l.c,l.i,n,ze);if(!n){o=0;break t}}i+o>=c&&(e.Cc=1),o=1}if(!o)return null;if(e.Cc&&((o=e.ga)!=null&&(o.mc=null),e.ga=null,0<e.Ga))return alert(`todo:WebPDequantizeLevels`),null}return e.nb+i*s}function yn(e,t,n,r,i,a){for(;0<i--;){var o,s=e,c=t+ +!!n,l=e,u=t+(n?0:3);for(o=0;o<r;++o){var d=l[u+4*o];d!=255&&(d*=32897,s[c+4*o+0]=s[c+4*o+0]*d>>23,s[c+4*o+1]=s[c+4*o+1]*d>>23,s[c+4*o+2]=s[c+4*o+2]*d>>23)}t+=a}}function bn(e,t,n,r,i){for(;0<r--;){var a;for(a=0;a<n;++a){var o=e[t+2*a+0],s=15&(l=e[t+2*a+1]),c=4369*s,l=(240&l|l>>4)*c>>16;e[t+2*a+0]=(240&o|o>>4)*c>>16&240|(15&o|o<<4)*c>>16>>4&15,e[t+2*a+1]=240&l|s}t+=i}}function xn(e,t,n,r,i,a,o,s){var c,l,u=255;for(l=0;l<i;++l){for(c=0;c<r;++c){var d=e[t+c];a[o+4*c]=d,u&=d}t+=n,o+=s}return u!=255}function Sn(e,t,n,r,i){var a;for(a=0;a<i;++a)n[r+a]=e[t+a]>>8}function Cn(){Er=yn,Dr=bn,Or=xn,kr=Sn}function wn(n,r,i){e[n]=function(e,n,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y){var b,x=y-1>>1,S=s[c+0]|l[u+0]<<16,C=d[f+0]|p[m+0]<<16;t(e!=null);var w=3*S+C+131074>>2;for(r(e[n+0],255&w,w>>16,h,g),a!=null&&(w=3*C+S+131074>>2,r(a[o+0],255&w,w>>16,_,v)),b=1;b<=x;++b){var T=s[c+b]|l[u+b]<<16,E=d[f+b]|p[m+b]<<16,D=S+T+C+E+524296,O=D+2*(T+C)>>3;w=O+S>>1,S=(D=D+2*(S+E)>>3)+T>>1,r(e[n+2*b-1],255&w,w>>16,h,g+(2*b-1)*i),r(e[n+2*b-0],255&S,S>>16,h,g+(2*b-0)*i),a!=null&&(w=D+C>>1,S=O+E>>1,r(a[o+2*b-1],255&w,w>>16,_,v+(2*b-1)*i),r(a[o+2*b+0],255&S,S>>16,_,v+(2*b+0)*i)),S=T,C=E}1&y||(w=3*S+C+131074>>2,r(e[n+y-1],255&w,w>>16,h,g+(y-1)*i),a!=null&&(w=3*C+S+131074>>2,r(a[o+y-1],255&w,w>>16,_,v+(y-1)*i)))}}function Tn(){bi[zr]=xi,bi[Br]=Ci,bi[Vr]=Si,bi[Hr]=wi,bi[Ur]=X,bi[Wr]=Ti,bi[Gr]=Ei,bi[Kr]=Ci,bi[qr]=wi,bi[Jr]=X,bi[Yr]=Ti}function En(e){return e&~Mi?0>e?0:255:e>>ji}function Dn(e,t){return En((19077*e>>8)+(26149*t>>8)-14234)}function On(e,t,n){return En((19077*e>>8)-(6419*t>>8)-(13320*n>>8)+8708)}function kn(e,t){return En((19077*e>>8)+(33050*t>>8)-17685)}function An(e,t,n,r,i){r[i+0]=Dn(e,n),r[i+1]=On(e,t,n),r[i+2]=kn(e,t)}function jn(e,t,n,r,i){r[i+0]=kn(e,t),r[i+1]=On(e,t,n),r[i+2]=Dn(e,n)}function Mn(e,t,n,r,i){var a=On(e,t,n);t=a<<3&224|kn(e,t)>>3,r[i+0]=248&Dn(e,n)|a>>5,r[i+1]=t}function Nn(e,t,n,r,i){var a=240&kn(e,t)|15;r[i+0]=240&Dn(e,n)|On(e,t,n)>>4,r[i+1]=a}function Pn(e,t,n,r,i){r[i+0]=255,An(e,t,n,r,i+1)}function Fn(e,t,n,r,i){jn(e,t,n,r,i),r[i+3]=255}function In(e,t,n,r,i){An(e,t,n,r,i),r[i+3]=255}function Ln(t,n,r){e[t]=function(e,t,i,a,o,s,c,l,u){for(var d=l+(-2&u)*r;l!=d;)n(e[t+0],i[a+0],o[s+0],c,l),n(e[t+1],i[a+0],o[s+0],c,l+r),t+=2,++a,++s,l+=2*r;1&u&&n(e[t+0],i[a+0],o[s+0],c,l)}}function Rn(e,t,n){return n==0?e==0?t==0?6:5:t==0?4:0:n}function zn(e,t,n,r,i){switch(e>>>30){case 3:ur(t,n,r,i,0);break;case 2:dr(t,n,r,i);break;case 1:pr(t,n,r,i)}}function Bn(e,t){var n,a,o=t.M,s=t.Nb,c=e.oc,l=e.pc+40,u=e.oc,d=e.pc+584,f=e.oc,p=e.pc+600;for(n=0;16>n;++n)c[l+32*n-1]=129;for(n=0;8>n;++n)u[d+32*n-1]=129,f[p+32*n-1]=129;for(0<o?c[l-1-32]=u[d-1-32]=f[p-1-32]=129:(i(c,l-32-1,127,21),i(u,d-32-1,127,9),i(f,p-32-1,127,9)),a=0;a<e.za;++a){var m=t.ya[t.aa+a];if(0<a){for(n=-1;16>n;++n)r(c,l+32*n-4,c,l+32*n+12,4);for(n=-1;8>n;++n)r(u,d+32*n-4,u,d+32*n+4,4),r(f,p+32*n-4,f,p+32*n+4,4)}var h=e.Gd,g=e.Hd+a,_=m.ad,v=m.Hc;if(0<o&&(r(c,l-32,h[g].y,0,16),r(u,d-32,h[g].f,0,8),r(f,p-32,h[g].ea,0,8)),m.Za){var y=c,b=l-32+16;for(0<o&&(a>=e.za-1?i(y,b,h[g].y[15],4):r(y,b,h[g+1].y,0,4)),n=0;4>n;n++)y[b+128+n]=y[b+256+n]=y[b+384+n]=y[b+0+n];for(n=0;16>n;++n,v<<=2)y=c,b=l+Bi[n],hi[m.Ob[n]](y,b),zn(v,_,16*n,y,b)}else if(y=Rn(a,o,m.Ob[0]),mi[y](c,l),v!=0)for(n=0;16>n;++n,v<<=2)zn(v,_,16*n,c,l+Bi[n]);for(n=m.Gc,y=Rn(a,o,m.Dd),gi[y](u,d),gi[y](f,p),v=_,y=u,b=d,255&(m=0|n)&&(170&m?fr(v,256,y,b):mr(v,256,y,b)),m=f,v=p,255&(n>>=8)&&(170&n?fr(_,320,m,v):mr(_,320,m,v)),o<e.Ub-1&&(r(h[g].y,0,c,l+480,16),r(h[g].f,0,u,d+224,8),r(h[g].ea,0,f,p+224,8)),n=8*s*e.B,h=e.sa,g=e.ta+16*a+16*s*e.R,_=e.qa,m=e.ra+8*a+n,v=e.Ha,y=e.Ia+8*a+n,n=0;16>n;++n)r(h,g+n*e.R,c,l+32*n,16);for(n=0;8>n;++n)r(_,m+n*e.B,u,d+32*n,8),r(v,y+n*e.B,f,p+32*n,8)}}function Vn(e,r,i,a,o,s,c,l,u){var d=[0],f=[0],p=0,m=u==null?0:u.kd,h=u??new un;if(e==null||12>i)return 7;h.data=e,h.w=r,h.ha=i,r=[r],i=[i],h.gb=[h.gb];t:{var g=r,v=i,y=h.gb;if(t(e!=null),t(v!=null),t(y!=null),y[0]=0,12<=v[0]&&!n(e,g[0],`RIFF`)){if(n(e,g[0]+8,`WEBP`)){y=3;break t}var b=M(e,g[0]+4);if(12>b||4294967286<b){y=3;break t}if(m&&b>v[0]-8){y=7;break t}y[0]=b,g[0]+=12,v[0]-=12}y=0}if(y!=0)return y;for(b=0<h.gb[0],i=i[0];;){t:{var S=e;v=r,y=i;var C=d,w=f,T=g=[0];if((O=p=[p])[0]=0,8>y[0])y=7;else{if(!n(S,v[0],`VP8X`)){if(M(S,v[0]+4)!=10){y=3;break t}if(18>y[0]){y=7;break t}var E=M(S,v[0]+8),D=1+j(S,v[0]+12);if(2147483648<=D*(S=1+j(S,v[0]+15))){y=3;break t}T!=null&&(T[0]=E),C!=null&&(C[0]=D),w!=null&&(w[0]=S),v[0]+=18,y[0]-=18,O[0]=1}y=0}}if(p=p[0],g=g[0],y!=0)return y;if(v=!!(2&g),!b&&p)return 3;if(s!=null&&(s[0]=!!(16&g)),c!=null&&(c[0]=v),l!=null&&(l[0]=0),c=d[0],g=f[0],p&&v&&u==null){y=0;break}if(4>i){y=7;break}if(b&&p||!b&&!p&&!n(e,r[0],`ALPH`)){i=[i],h.na=[h.na],h.P=[h.P],h.Sa=[h.Sa];t:{E=e,y=r,b=i;var O=h.gb;C=h.na,w=h.P,T=h.Sa,D=22,t(E!=null),t(b!=null),S=y[0];var k=b[0];for(t(C!=null),t(T!=null),C[0]=null,w[0]=null,T[0]=0;;){if(y[0]=S,b[0]=k,8>k){y=7;break t}var A=M(E,S+4);if(4294967286<A){y=3;break t}var N=8+A+1&-2;if(D+=N,0<O&&D>O){y=3;break t}if(!n(E,S,`VP8 `)||!n(E,S,`VP8L`)){y=0;break t}if(k[0]<N){y=7;break t}n(E,S,`ALPH`)||(C[0]=E,w[0]=S+8,T[0]=A),S+=N,k-=N}}if(i=i[0],h.na=h.na[0],h.P=h.P[0],h.Sa=h.Sa[0],y!=0)break}i=[i],h.Ja=[h.Ja],h.xa=[h.xa];t:if(O=e,y=r,b=i,C=h.gb[0],w=h.Ja,T=h.xa,E=y[0],S=!n(O,E,`VP8 `),D=!n(O,E,`VP8L`),t(O!=null),t(b!=null),t(w!=null),t(T!=null),8>b[0])y=7;else{if(S||D){if(O=M(O,E+4),12<=C&&O>C-12){y=3;break t}if(m&&O>b[0]-8){y=7;break t}w[0]=O,y[0]+=8,b[0]-=8,T[0]=D}else T[0]=5<=b[0]&&O[E+0]==47&&!(O[E+4]>>5),w[0]=b[0];y=0}if(i=i[0],h.Ja=h.Ja[0],h.xa=h.xa[0],r=r[0],y!=0)break;if(4294967286<h.Ja)return 3;if(l==null||v||(l[0]=h.xa?2:1),c=[c],g=[g],h.xa){if(5>i){y=7;break}l=c,m=g,v=s,e==null||5>i?e=0:5<=i&&e[r+0]==47&&!(e[r+4]>>5)?(b=[0],O=[0],C=[0],_(w=new x,e,r,i),Ce(w,b,O,C)?(l!=null&&(l[0]=b[0]),m!=null&&(m[0]=O[0]),v!=null&&(v[0]=C[0]),e=1):e=0):e=0}else{if(10>i){y=7;break}l=g,e==null||10>i||!nt(e,r+3,i-3)?e=0:(m=e[r+0]|e[r+1]<<8|e[r+2]<<16,v=16383&(e[r+7]<<8|e[r+6]),e=16383&(e[r+9]<<8|e[r+8]),1&m||3<(m>>1&7)||!(m>>4&1)||m>>5>=h.Ja||!v||!e?e=0:(c&&(c[0]=v),l&&(l[0]=e),e=1))}if(!e||(c=c[0],g=g[0],p&&(d[0]!=c||f[0]!=g)))return 3;u!=null&&(u[0]=h,u.offset=r-u.w,t(4294967286>r-u.w),t(u.offset==u.ha-i));break}return y==0||y==7&&p&&u==null?(s!=null&&(s[0]|=h.na!=null&&0<h.na.length),a!=null&&(a[0]=c),o!=null&&(o[0]=g),0):y}function Hn(e,t,n){var r=t.width,i=t.height,a=0,o=0,s=r,c=i;if(t.Da=e!=null&&0<e.Da,t.Da&&(s=e.cd,c=e.bd,a=e.v,o=e.j,11>n||(a&=-2,o&=-2),0>a||0>o||0>=s||0>=c||a+s>r||o+c>i))return 0;if(t.v=a,t.j=o,t.va=a+s,t.o=o+c,t.U=s,t.T=c,t.da=e!=null&&0<e.da,t.da){if(!I(s,c,n=[e.ib],a=[e.hb]))return 0;t.ib=n[0],t.hb=a[0]}return t.ob=e!=null&&e.ob,t.Kb=e==null||!e.Sd,t.da&&(t.ob=t.ib<3*r/4&&t.hb<3*i/4,t.Kb=0),1}function Un(e){if(e==null)return 2;if(11>e.S){var t=e.f.RGBA;t.fb+=(e.height-1)*t.A,t.A=-t.A}else t=e.f.kb,e=e.height,t.O+=(e-1)*t.fa,t.fa=-t.fa,t.N+=(e-1>>1)*t.Ab,t.Ab=-t.Ab,t.W+=(e-1>>1)*t.Db,t.Db=-t.Db,t.F!=null&&(t.J+=(e-1)*t.lb,t.lb=-t.lb);return 0}function Wn(e,t,n,r){if(r==null||0>=e||0>=t)return 2;if(n!=null){if(n.Da){var i=n.cd,o=n.bd,s=-2&n.v,c=-2&n.j;if(0>s||0>c||0>=i||0>=o||s+i>e||c+o>t)return 2;e=i,t=o}if(n.da){if(!I(e,t,i=[n.ib],o=[n.hb]))return 2;e=i[0],t=o[0]}}r.width=e,r.height=t;t:{var l=r.width,u=r.height;if(e=r.S,0>=l||0>=u||!(e>=zr&&13>e))e=2;else{if(0>=r.Rd&&r.sd==null){s=o=i=t=0;var d=(c=l*Wi[e])*u;if(11>e||(o=(u+1)/2*(t=(l+1)/2),e==12&&(s=(i=l)*u)),(u=a(d+2*o+s))==null){e=1;break t}r.sd=u,11>e?((l=r.f.RGBA).eb=u,l.fb=0,l.A=c,l.size=d):((l=r.f.kb).y=u,l.O=0,l.fa=c,l.Fd=d,l.f=u,l.N=0+d,l.Ab=t,l.Cd=o,l.ea=u,l.W=0+d+o,l.Db=t,l.Ed=o,e==12&&(l.F=u,l.J=0+d+2*o),l.Tc=s,l.lb=i)}if(t=1,i=r.S,o=r.width,s=r.height,i>=zr&&13>i){if(11>i)e=r.f.RGBA,t&=(c=Math.abs(e.A))*(s-1)+o<=e.size,t&=c>=o*Wi[i],t&=e.eb!=null;else{e=r.f.kb,c=(o+1)/2,d=(s+1)/2,l=Math.abs(e.fa),u=Math.abs(e.Ab);var f=Math.abs(e.Db),p=Math.abs(e.lb),m=p*(s-1)+o;t&=l*(s-1)+o<=e.Fd,t&=u*(d-1)+c<=e.Cd,t=(t&=f*(d-1)+c<=e.Ed)&l>=o&u>=c&f>=c,t&=e.y!=null,t&=e.f!=null,t&=e.ea!=null,i==12&&(t&=p>=o,t&=m<=e.Tc,t&=e.F!=null)}}else t=0;e=t?0:2}}return e!=0||n!=null&&n.fd&&(e=Un(r)),e}var Gn=64,Kn=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],qn=24,Jn=32,Yn=8,Xn=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];z(`Predictor0`,`PredictorAdd0`),e.Predictor0=function(){return 4278190080},e.Predictor1=function(e){return e},e.Predictor2=function(e,t,n){return t[n+0]},e.Predictor3=function(e,t,n){return t[n+1]},e.Predictor4=function(e,t,n){return t[n-1]},e.Predictor5=function(e,t,n){return V(V(e,t[n+1]),t[n+0])},e.Predictor6=function(e,t,n){return V(e,t[n-1])},e.Predictor7=function(e,t,n){return V(e,t[n+0])},e.Predictor8=function(e,t,n){return V(t[n-1],t[n+0])},e.Predictor9=function(e,t,n){return V(t[n+0],t[n+1])},e.Predictor10=function(e,t,n){return V(V(e,t[n-1]),V(t[n+0],t[n+1]))},e.Predictor11=function(e,t,n){var r=t[n+0];return 0>=ne(r>>24&255,e>>24&255,(t=t[n-1])>>24&255)+ne(r>>16&255,e>>16&255,t>>16&255)+ne(r>>8&255,e>>8&255,t>>8&255)+ne(255&r,255&e,255&t)?r:e},e.Predictor12=function(e,t,n){var r=t[n+0];return(ee((e>>24&255)+(r>>24&255)-((t=t[n-1])>>24&255))<<24|ee((e>>16&255)+(r>>16&255)-(t>>16&255))<<16|ee((e>>8&255)+(r>>8&255)-(t>>8&255))<<8|ee((255&e)+(255&r)-(255&t)))>>>0},e.Predictor13=function(e,t,n){var r=t[n-1];return(te((e=V(e,t[n+0]))>>24&255,r>>24&255)<<24|te(e>>16&255,r>>16&255)<<16|te(e>>8&255,r>>8&255)<<8|te(255&e,255&r))>>>0};var Zn=e.PredictorAdd0;e.PredictorAdd1=re,z(`Predictor2`,`PredictorAdd2`),z(`Predictor3`,`PredictorAdd3`),z(`Predictor4`,`PredictorAdd4`),z(`Predictor5`,`PredictorAdd5`),z(`Predictor6`,`PredictorAdd6`),z(`Predictor7`,`PredictorAdd7`),z(`Predictor8`,`PredictorAdd8`),z(`Predictor9`,`PredictorAdd9`),z(`Predictor10`,`PredictorAdd10`),z(`Predictor11`,`PredictorAdd11`),z(`Predictor12`,`PredictorAdd12`),z(`Predictor13`,`PredictorAdd13`);var Qn=e.PredictorAdd2;W(`ColorIndexInverseTransform`,`MapARGB`,`32b`,function(e){return e>>8&255},function(e){return e}),W(`VP8LColorIndexInverseTransformAlpha`,`MapAlpha`,`8b`,function(e){return e},function(e){return e>>8&255});var $n,er=e.ColorIndexInverseTransform,tr=e.MapARGB,q=e.VP8LColorIndexInverseTransformAlpha,nr=e.MapAlpha,rr=e.VP8LPredictorsAdd=[];rr.length=16,(e.VP8LPredictors=[]).length=16,(e.VP8LPredictorsAdd_C=[]).length=16,(e.VP8LPredictors_C=[]).length=16;var ir,ar,or,sr,J,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,Y,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar=a(511),jr=a(2041),Mr=a(225),Nr=a(767),Pr=0,Fr=jr,Ir=Mr,Lr=Nr,Rr=Ar,zr=0,Br=1,Vr=2,Hr=3,Ur=4,Wr=5,Gr=6,Kr=7,qr=8,Jr=9,Yr=10,Xr=[2,3,7],Zr=[3,3,11],Qr=[280,256,256,256,40],$r=[0,1,1,1,0],ei=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],ti=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],ni=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],ri=8,ii=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],ai=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],oi=null,si=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],ci=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],li=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],ui=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],di=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],fi=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],pi=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],mi=[],hi=[],gi=[],_i=1,vi=2,yi=[],bi=[];wn(`UpsampleRgbLinePair`,An,3),wn(`UpsampleBgrLinePair`,jn,3),wn(`UpsampleRgbaLinePair`,In,4),wn(`UpsampleBgraLinePair`,Fn,4),wn(`UpsampleArgbLinePair`,Pn,4),wn(`UpsampleRgba4444LinePair`,Nn,2),wn(`UpsampleRgb565LinePair`,Mn,2);var xi=e.UpsampleRgbLinePair,Si=e.UpsampleBgrLinePair,Ci=e.UpsampleRgbaLinePair,wi=e.UpsampleBgraLinePair,X=e.UpsampleArgbLinePair,Ti=e.UpsampleRgba4444LinePair,Ei=e.UpsampleRgb565LinePair,Di=16,Oi=1<<Di-1,ki=-227,Ai=482,ji=6,Mi=(256<<ji)-1,Ni=0,Pi=a(256),Fi=a(256),Ii=a(256),Li=a(256),Ri=a(Ai-ki),zi=a(Ai-ki);Ln(`YuvToRgbRow`,An,3),Ln(`YuvToBgrRow`,jn,3),Ln(`YuvToRgbaRow`,In,4),Ln(`YuvToBgraRow`,Fn,4),Ln(`YuvToArgbRow`,Pn,4),Ln(`YuvToRgba4444Row`,Nn,2),Ln(`YuvToRgb565Row`,Mn,2);var Bi=[0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396],Vi=[0,2,8],Hi=[8,7,6,4,4,2,2,2,1,1,1,1],Ui=1;this.WebPDecodeRGBA=function(e,n,s,c,l){var u=Br,d=new ln,f=new me;d.ba=f,f.S=u,f.width=[f.width],f.height=[f.height];var p=f.width,m=f.height,h=new he;if(h==null||e==null)var g=2;else t(h!=null),g=Vn(e,n,s,h.width,h.height,h.Pd,h.Qd,h.format,null);if(g==0?(p!=null&&(p[0]=h.width[0]),m!=null&&(m[0]=h.height[0]),p=1):p=0,p){f.width=f.width[0],f.height=f.height[0],c!=null&&(c[0]=f.width),l!=null&&(l[0]=f.height);t:{if(c=new $e,(l=new un).data=e,l.w=n,l.ha=s,l.kd=1,n=[0],t(l!=null),((e=Vn(l.data,l.w,l.ha,null,null,null,n,null,l))==0||e==7)&&n[0]&&(e=4),(n=e)==0){if(t(d!=null),c.data=l.data,c.w=l.w+l.offset,c.ha=l.ha-l.offset,c.put=xe,c.ac=be,c.bc=Se,c.ma=d,l.xa){if((e=Ie())==null){d=1;break t}if(function(e,n){var r=[0],i=[0],a=[0];e:for(;;){if(e==null)return 0;if(n==null)return e.a=2,0;if(e.l=n,e.a=0,_(e.m,n.data,n.w,n.ha),!Ce(e.m,r,i,a)){e.a=3;break e}if(e.xb=vi,n.width=r[0],n.height=i[0],!Le(r[0],i[0],1,e,null))break e;return 1}return t(e.a!=0),0}(e,c)){if(c=(n=Wn(c.width,c.height,d.Oa,d.ba))==0){e:{c=e;r:for(;;){if(c==null){c=0;break e}if(t(c.s.yc!=null),t(c.s.Ya!=null),t(0<c.s.Wb),t((s=c.l)!=null),t((l=s.ma)!=null),c.xb!=0){if(c.ca=l.ba,c.tb=l.tb,t(c.ca!=null),!Hn(l.Oa,s,Hr)){c.a=2;break r}if(!Re(c,s.width)||s.da)break r;if((s.da||de(c.ca.S))&&Cn(),11>c.ca.S||(alert(`todo:WebPInitConvertARGBToYUV`),c.ca.f.kb.F!=null&&Cn()),c.Pb&&0<c.s.ua&&c.s.vb.X==null&&!N(c.s.vb,c.s.Wa.Xa)){c.a=1;break r}c.xb=0}if(!Pe(c,c.V,c.Ba,c.c,c.i,s.o,Ae))break r;l.Dc=c.Ma,c=1;break e}t(c.a!=0),c=0}c=!c}c&&(n=e.a)}else n=e.a}else{if((e=new et)==null){d=1;break t}if(e.Fa=l.na,e.P=l.P,e.qc=l.Sa,rt(e,c)){if((n=Wn(c.width,c.height,d.Oa,d.ba))==0){if(e.Aa=0,s=d.Oa,t((l=e)!=null),s!=null){if(0<(p=0>(p=s.Md)?0:100<p?255:255*p/100)){for(m=h=0;4>m;++m)12>(g=l.pb[m]).lc&&(g.ia=p*Hi[0>g.lc?0:g.lc]>>3),h|=g.ia;h&&(alert(`todo:VP8InitRandom`),l.ia=1)}l.Ga=s.Id,100<l.Ga?l.Ga=100:0>l.Ga&&(l.Ga=0)}(function(e,n){if(e==null)return 0;if(n==null)return tt(e,2,`NULL VP8Io parameter in VP8Decode().`);if(!e.cb&&!rt(e,n))return 0;if(t(e.cb),n.ac==null||n.ac(n)){n.ob&&(e.L=0);var s=Vi[e.L];if(e.L==2?(e.yb=0,e.zb=0):(e.yb=n.v-s>>4,e.zb=n.j-s>>4,0>e.yb&&(e.yb=0),0>e.zb&&(e.zb=0)),e.Va=n.o+15+s>>4,e.Hb=n.va+15+s>>4,e.Hb>e.za&&(e.Hb=e.za),e.Va>e.Ub&&(e.Va=e.Ub),0<e.L){var c=e.ed;for(s=0;4>s;++s){var l;if(e.Qa.Cb){var u=e.Qa.Lb[s];e.Qa.Fb||(u+=c.Tb)}else u=c.Tb;for(l=0;1>=l;++l){var d=e.gd[s][l],f=u;if(c.Pc&&(f+=c.vd[0],l&&(f+=c.od[0])),0<(f=0>f?0:63<f?63:f)){var p=f;0<c.wb&&(p=4<c.wb?p>>2:p>>1)>9-c.wb&&(p=9-c.wb),1>p&&(p=1),d.dd=p,d.tc=2*f+p,d.ld=40<=f?2:+(15<=f)}else d.tc=0;d.La=l}}}s=0}else tt(e,6,`Frame setup failed`),s=e.a;if(s=s==0){if(s){e.$c=0,0<e.Aa||(e.Ic=Ui);e:{s=e.Ic,c=4*(p=e.za);var m=32*p,h=p+1,g=0<e.L?p*(0<e.Aa?2:1):0,_=(e.Aa==2?2:1)*p;if((d=c+832+(l=3*(16*s+Vi[e.L])/2*m)+(u=e.Fa!=null&&0<e.Fa.length?e.Kc.c*e.Kc.i:0))!=d)s=0;else{if(d>e.Vb){if(e.Vb=0,e.Ec=a(d),e.Fc=0,e.Ec==null){s=tt(e,1,`no memory during frame initialization.`);break e}e.Vb=d}d=e.Ec,f=e.Fc,e.Ac=d,e.Bc=f,f+=c,e.Gd=o(m,Xe),e.Hd=0,e.rb=o(h+1,Ke),e.sb=1,e.wa=g?o(g,Ge):null,e.Y=0,e.D.Nb=0,e.D.wa=e.wa,e.D.Y=e.Y,0<e.Aa&&(e.D.Y+=p),t(!0),e.oc=d,e.pc=f,f+=832,e.ya=o(_,Je),e.aa=0,e.D.ya=e.ya,e.D.aa=e.aa,e.Aa==2&&(e.D.aa+=p),e.R=16*p,e.B=8*p,p=(m=Vi[e.L])*e.R,m=m/2*e.B,e.sa=d,e.ta=f+p,e.qa=e.sa,e.ra=e.ta+16*s*e.R+m,e.Ha=e.qa,e.Ia=e.ra+8*s*e.B+m,e.$c=0,f+=l,e.mb=u?d:null,e.nb=u?f:null,t(f+u<=e.Fc+e.Vb),at(e),i(e.Ac,e.Bc,0,c),s=1}}if(s){if(n.ka=0,n.y=e.sa,n.O=e.ta,n.f=e.qa,n.N=e.ra,n.ea=e.Ha,n.Vd=e.Ia,n.fa=e.R,n.Rc=e.B,n.F=null,n.J=0,!Pr){for(s=-255;255>=s;++s)Ar[255+s]=0>s?-s:s;for(s=-1020;1020>=s;++s)jr[1020+s]=-128>s?-128:127<s?127:s;for(s=-112;112>=s;++s)Mr[112+s]=-16>s?-16:15<s?15:s;for(s=-255;510>=s;++s)Nr[255+s]=0>s?0:255<s?255:s;Pr=1}lr=ht,ur=dt,fr=ft,pr=pt,mr=mt,dr=ut,hr=en,gr=tn,_r=an,vr=on,yr=nn,br=rn,Y=sn,xr=cn,Sr=Jt,Cr=Yt,wr=Xt,Tr=Zt,hi[0]=At,hi[1]=_t,hi[2]=Ot,hi[3]=kt,hi[4]=jt,hi[5]=Nt,hi[6]=Mt,hi[7]=Pt,hi[8]=It,hi[9]=Ft,mi[0]=Ct,mi[1]=yt,mi[2]=bt,mi[3]=xt,mi[4]=wt,mi[5]=Tt,mi[6]=Et,gi[0]=Bt,gi[1]=vt,gi[2]=Lt,gi[3]=Rt,gi[4]=Ht,gi[5]=Vt,gi[6]=Ut,s=1}else s=0}s&&=function(e,n){for(e.M=0;e.M<e.Va;++e.M){var o,s=e.Jc[e.M&e.Xb],c=e.m,l=e;for(o=0;o<l.za;++o){var u=c,d=l,f=d.Ac,p=d.Bc+4*o,m=d.zc,h=d.ya[d.aa+o];if(d.Qa.Bb?h.$b=O(u,d.Pa.jb[0])?2+O(u,d.Pa.jb[2]):O(u,d.Pa.jb[1]):h.$b=0,d.kc&&(h.Ad=O(u,d.Bd)),h.Za=!O(u,145)+0,h.Za){var g=h.Ob,_=0;for(d=0;4>d;++d){var v,y=m[0+d];for(v=0;4>v;++v){y=di[f[p+v]][y];for(var b=li[O(u,y[0])];0<b;)b=li[2*b+O(u,y[b])];y=-b,f[p+v]=y}r(g,_,f,p,4),_+=4,m[0+d]=y}}else y=O(u,156)?O(u,128)?1:3:O(u,163)?2:0,h.Ob[0]=y,i(f,p,y,4),i(m,0,y,4);h.Dd=O(u,142)?O(u,114)?O(u,183)?1:3:2:0}if(l.m.Ka)return tt(e,7,`Premature end-of-partition0 encountered.`);for(;e.ja<e.za;++e.ja){if(l=s,u=(c=e).rb[c.sb-1],f=c.rb[c.sb+c.ja],o=c.ya[c.aa+c.ja],p=c.kc?o.Ad:0)u.la=f.la=0,o.Za||(u.Na=f.Na=0),o.Hc=0,o.Gc=0,o.ia=0;else{var x,S;if(u=f,f=l,p=c.Pa.Xc,m=c.ya[c.aa+c.ja],h=c.pb[m.$b],d=m.ad,g=0,_=c.rb[c.sb-1],y=v=0,i(d,g,0,384),m.Za)var C=0,w=p[3];else{b=a(16);var T=u.Na+_.Na;if(T=oi(f,p[1],T,h.Eb,0,b,0),u.Na=_.Na=(0<T)+0,1<T)lr(b,0,d,g);else{var E=b[0]+3>>3;for(b=0;256>b;b+=16)d[g+b]=E}C=1,w=p[0]}var D=15&u.la,k=15&_.la;for(b=0;4>b;++b){var A=1&k;for(E=S=0;4>E;++E)D=D>>1|(A=(T=oi(f,w,T=A+(1&D),h.Sc,C,d,g))>C)<<7,S=S<<2|(3<T?3:1<T?2:d[g+0]!=0),g+=16;D>>=4,k=k>>1|A<<7,v=(v<<8|S)>>>0}for(w=D,C=k>>4,x=0;4>x;x+=2){for(S=0,D=u.la>>4+x,k=_.la>>4+x,b=0;2>b;++b){for(A=1&k,E=0;2>E;++E)T=A+(1&D),D=D>>1|(A=0<(T=oi(f,p[2],T,h.Qc,0,d,g)))<<3,S=S<<2|(3<T?3:1<T?2:d[g+0]!=0),g+=16;D>>=2,k=k>>1|A<<5}y|=S<<4*x,w|=D<<4<<x,C|=(240&k)<<x}u.la=w,_.la=C,m.Hc=v,m.Gc=y,m.ia=43690&y?0:h.ia,p=!(v|y)}if(0<c.L&&(c.wa[c.Y+c.ja]=c.gd[o.$b][o.Za],c.wa[c.Y+c.ja].La|=!p),l.Ka)return tt(e,7,`Premature end-of-file encountered.`)}if(at(e),c=n,l=1,o=(s=e).D,u=0<s.L&&s.M>=s.zb&&s.M<=s.Va,s.Aa==0)e:{if(o.M=s.M,o.uc=u,Bn(s,o),l=1,o=(S=s.D).Nb,u=(y=Vi[s.L])*s.R,f=y/2*s.B,b=16*o*s.R,E=8*o*s.B,p=s.sa,m=s.ta-u+b,h=s.qa,d=s.ra-f+E,g=s.Ha,_=s.Ia-f+E,k=(D=S.M)==0,v=D>=s.Va-1,s.Aa==2&&Bn(s,S),S.uc)for(A=(T=s).D.M,t(T.D.uc),S=T.yb;S<T.Hb;++S){C=S,w=A;var j=(M=(V=T).D).Nb;x=V.R;var M=M.wa[M.Y+C],N=V.sa,P=V.ta+16*j*x+16*C,F=M.dd,I=M.tc;if(I!=0){if(t(3<=I),V.L==1)0<C&&Cr(N,P,x,I+4),M.La&&Tr(N,P,x,I),0<w&&Sr(N,P,x,I+4),M.La&&wr(N,P,x,I);else{var L=V.B,R=V.qa,z=V.ra+8*j*L+8*C,B=V.Ha,V=V.Ia+8*j*L+8*C;j=M.ld,0<C&&(gr(N,P,x,I+4,F,j),vr(R,z,B,V,L,I+4,F,j)),M.La&&(br(N,P,x,I,F,j),xr(R,z,B,V,L,I,F,j)),0<w&&(hr(N,P,x,I+4,F,j),_r(R,z,B,V,L,I+4,F,j)),M.La&&(yr(N,P,x,I,F,j),Y(R,z,B,V,L,I,F,j))}}}if(s.ia&&alert(`todo:DitherRow`),c.put!=null){if(S=16*D,D=16*(D+1),k?(c.y=s.sa,c.O=s.ta+b,c.f=s.qa,c.N=s.ra+E,c.ea=s.Ha,c.W=s.Ia+E):(S-=y,c.y=p,c.O=m,c.f=h,c.N=d,c.ea=g,c.W=_),v||(D-=y),D>c.o&&(D=c.o),c.F=null,c.J=null,s.Fa!=null&&0<s.Fa.length&&S<D&&(c.J=vn(s,c,S,D-S),c.F=s.mb,c.F==null&&c.F.length==0)){l=tt(s,3,`Could not decode alpha data.`);break e}S<c.j&&(y=c.j-S,S=c.j,t(!(1&y)),c.O+=s.R*y,c.N+=s.B*(y>>1),c.W+=s.B*(y>>1),c.F!=null&&(c.J+=c.width*y)),S<D&&(c.O+=c.v,c.N+=c.v>>1,c.W+=c.v>>1,c.F!=null&&(c.J+=c.v),c.ka=S-c.j,c.U=c.va-c.v,c.T=D-S,l=c.put(c))}o+1!=s.Ic||v||(r(s.sa,s.ta-u,p,m+16*s.R,u),r(s.qa,s.ra-f,h,d+8*s.B,f),r(s.Ha,s.Ia-f,g,_+8*s.B,f))}if(!l)return tt(e,6,`Output aborted.`)}return 1}(e,n),n.bc!=null&&n.bc(n),s&=1}return s?(e.cb=0,s):0})(e,c)||(n=e.a)}}else n=e.a}n==0&&d.Oa!=null&&d.Oa.fd&&(n=Un(d.ba))}d=n}u=d==0?11>u?f.f.RGBA.eb:f.f.kb.y:null}else u=null;return u};var Wi=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function l(e,t){for(var n=``,r=0;r<4;r++)n+=String.fromCharCode(e[t++]);return n}function u(e,t){return e[t+0]|e[t+1]<<8}function d(e,t){return(e[t+0]|e[t+1]<<8|e[t+2]<<16)>>>0}function f(e,t){return(e[t+0]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}new c;var p=[0],m=[0],h=[],g=new c,_=e,v=function(e,t){var n={},r=0,i=!1,a=0,o=0;if(n.frames=[],!function(e,t){for(var n=0;n<4;n++)if(e[t+n]!=`RIFF`.charCodeAt(n))return!0;return!1}(e,t)){for(f(e,t+=4),t+=8;t<e.length;){var s=l(e,t),c=f(e,t+=4);t+=4;var p=c+(1&c);switch(s){case`VP8 `:case`VP8L`:n.frames[r]===void 0&&(n.frames[r]={}),(g=n.frames[r]).src_off=i?o:t-8,g.src_size=a+c+8,r++,i&&(i=!1,a=0,o=0);break;case`VP8X`:(g=n.header={}).feature_flags=e[t];var m=t+4;g.canvas_width=1+d(e,m),m+=3,g.canvas_height=1+d(e,m),m+=3;break;case`ALPH`:i=!0,a=p+8,o=t-8;break;case`ANIM`:(g=n.header).bgcolor=f(e,t),m=t+4,g.loop_count=u(e,m),m+=2;break;case`ANMF`:var h,g;(g=n.frames[r]={}).offset_x=2*d(e,t),t+=3,g.offset_y=2*d(e,t),t+=3,g.width=1+d(e,t),t+=3,g.height=1+d(e,t),t+=3,g.duration=d(e,t),t+=3,h=e[t++],g.dispose=1&h,g.blend=h>>1&1}s!=`ANMF`&&(t+=p)}return n}}(_,0);v.response=_,v.rgbaoutput=!0,v.dataurl=!1;var y=v.header?v.header:null,b=v.frames?v.frames:null;if(y){y.loop_counter=y.loop_count,p=[y.canvas_height],m=[y.canvas_width];for(var x=0;x<b.length&&b[x].blend!=0;x++);}var S=b[0],C=g.WebPDecodeRGBA(_,S.src_off,S.src_size,m,p);S.rgba=C,S.imgwidth=m[0],S.imgheight=p[0];for(var w=0;w<m[0]*p[0]*4;w++)h[w]=C[w];return this.width=m,this.height=p,this.data=h,this}function qR(){var e,t=this.internal.__metadata__.metadata,n=unescape(encodeURIComponent(t));e=this.internal.__metadata__.rawXml?n:`<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="`+this.internal.__metadata__.namespaceUri+`"><jspdf:metadata>`+n.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)+`</jspdf:metadata></rdf:Description></rdf:RDF></x:xmpmeta>`,this.internal.__metadata__.metadataObjectNumber=this.internal.newObject(),this.internal.write(`<< /Type /Metadata /Subtype /XML /Length `+e.length+` >>`),this.internal.write(`stream`),this.internal.write(e),this.internal.write(`endstream`),this.internal.write(`endobj`)}function JR(){this.internal.__metadata__.metadataObjectNumber&&this.internal.write(`/Metadata `+this.internal.__metadata__.metadataObjectNumber+` 0 R`)}(function(e){var t,n,r,i,a,o,s,c,l,u=function(e){return e||={},this.isStrokeTransparent=e.isStrokeTransparent||!1,this.strokeOpacity=e.strokeOpacity||1,this.strokeStyle=e.strokeStyle||`#000000`,this.fillStyle=e.fillStyle||`#000000`,this.isFillTransparent=e.isFillTransparent||!1,this.fillOpacity=e.fillOpacity||1,this.font=e.font||`10px sans-serif`,this.textBaseline=e.textBaseline||`alphabetic`,this.textAlign=e.textAlign||`left`,this.lineWidth=e.lineWidth||1,this.lineJoin=e.lineJoin||`miter`,this.lineCap=e.lineCap||`butt`,this.path=e.path||[],this.transform=e.transform===void 0?new c:e.transform.clone(),this.globalCompositeOperation=e.globalCompositeOperation||`normal`,this.globalAlpha=e.globalAlpha||1,this.clip_path=e.clip_path||[],this.currentPoint=e.currentPoint||new o,this.miterLimit=e.miterLimit||10,this.lastPoint=e.lastPoint||new o,this.lineDashOffset=e.lineDashOffset||0,this.lineDash=e.lineDash||[],this.margin=e.margin||[0,0,0,0],this.prevPageLastElemOffset=e.prevPageLastElemOffset||0,this.ignoreClearRect=typeof e.ignoreClearRect!=`boolean`||e.ignoreClearRect,this};e.events.push([`initialized`,function(){this.context2d=new d(this),t=this.internal.f2,n=this.internal.getCoordinateString,r=this.internal.getVerticalCoordinateString,i=this.internal.getHorizontalCoordinate,a=this.internal.getVerticalCoordinate,o=this.internal.Point,s=this.internal.Rectangle,c=this.internal.Matrix,l=new u}]);var d=function(e){Object.defineProperty(this,"canvas",{get:function(){return{parentNode:!1,style:!1}}});var t=e;Object.defineProperty(this,"pdf",{get:function(){return t}});var n=!1;Object.defineProperty(this,"pageWrapXEnabled",{get:function(){return n},set:function(e){n=!!e}});var r=!1;Object.defineProperty(this,"pageWrapYEnabled",{get:function(){return r},set:function(e){r=!!e}});var i=0;Object.defineProperty(this,"posX",{get:function(){return i},set:function(e){isNaN(e)||(i=e)}});var a=0;Object.defineProperty(this,"posY",{get:function(){return a},set:function(e){isNaN(e)||(a=e)}}),Object.defineProperty(this,"margin",{get:function(){return l.margin},set:function(e){var t;typeof e==`number`?t=[e,e,e,e]:((t=[,,,,])[0]=e[0],t[1]=e.length>=2?e[1]:t[0],t[2]=e.length>=3?e[2]:t[0],t[3]=e.length>=4?e[3]:t[1]),l.margin=t}});var o=!1;Object.defineProperty(this,"autoPaging",{get:function(){return o},set:function(e){o=e}});var s=0;Object.defineProperty(this,"lastBreak",{get:function(){return s},set:function(e){s=e}});var c=[];Object.defineProperty(this,"pageBreaks",{get:function(){return c},set:function(e){c=e}}),Object.defineProperty(this,"ctx",{get:function(){return l},set:function(e){e instanceof u&&(l=e)}}),Object.defineProperty(this,"path",{get:function(){return l.path},set:function(e){l.path=e}});var d=[];Object.defineProperty(this,"ctxStack",{get:function(){return d},set:function(e){d=e}}),Object.defineProperty(this,"fillStyle",{get:function(){return this.ctx.fillStyle},set:function(e){var t=f(e);this.ctx.fillStyle=t.style,this.ctx.isFillTransparent=t.a===0,this.ctx.fillOpacity=t.a,this.pdf.setFillColor(t.r,t.g,t.b,{a:t.a}),this.pdf.setTextColor(t.r,t.g,t.b,{a:t.a})}}),Object.defineProperty(this,"strokeStyle",{get:function(){return this.ctx.strokeStyle},set:function(e){var t=f(e);this.ctx.strokeStyle=t.style,this.ctx.isStrokeTransparent=t.a===0,this.ctx.strokeOpacity=t.a,t.a===0?this.pdf.setDrawColor(255,255,255):(t.a,this.pdf.setDrawColor(t.r,t.g,t.b))}}),Object.defineProperty(this,"lineCap",{get:function(){return this.ctx.lineCap},set:function(e){[`butt`,`round`,`square`].indexOf(e)!==-1&&(this.ctx.lineCap=e,this.pdf.setLineCap(e))}}),Object.defineProperty(this,"lineWidth",{get:function(){return this.ctx.lineWidth},set:function(e){isNaN(e)||(this.ctx.lineWidth=e,this.pdf.setLineWidth(e))}}),Object.defineProperty(this,"lineJoin",{get:function(){return this.ctx.lineJoin},set:function(e){[`bevel`,`round`,`miter`].indexOf(e)!==-1&&(this.ctx.lineJoin=e,this.pdf.setLineJoin(e))}}),Object.defineProperty(this,"miterLimit",{get:function(){return this.ctx.miterLimit},set:function(e){isNaN(e)||(this.ctx.miterLimit=e,this.pdf.setMiterLimit(e))}}),Object.defineProperty(this,"textBaseline",{get:function(){return this.ctx.textBaseline},set:function(e){this.ctx.textBaseline=e}}),Object.defineProperty(this,"textAlign",{get:function(){return this.ctx.textAlign},set:function(e){[`right`,`end`,`center`,`left`,`start`].indexOf(e)!==-1&&(this.ctx.textAlign=e)}});var p=null,m=null,h=null;Object.defineProperty(this,"fontFaces",{get:function(){return h},set:function(e){p=null,m=null,h=e}}),Object.defineProperty(this,"font",{get:function(){return this.ctx.font},set:function(e){var t;if(this.ctx.font=e,(t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i.exec(e))!==null){var n=t[1];t[2];var r=t[3],i=t[4];t[5];var a=t[6],o=/^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(i)[2];i=Math.floor(o===`px`?parseFloat(i)*this.pdf.internal.scaleFactor:o===`em`?parseFloat(i)*this.pdf.getFontSize():parseFloat(i)*this.pdf.internal.scaleFactor),this.pdf.setFontSize(i);var s=function(e){var t,n,r=[],i=e.trim();if(i===``)return AR;if(i in bR)return[bR[i]];for(;i!==``;){switch(n=null,t=(i=SR(i)).charAt(0)){case`"`:case`'`:n=CR(i.substring(1),t);break;default:n=wR(i)}if(n===null||(r.push(n[0]),(i=SR(n[1]))!==``&&i.charAt(0)!==`,`))return AR;i=i.replace(/^,/,``)}return r}(a);if(this.fontFaces){var c=function(e,t,n){for(var r=(n||={}).defaultFontFamily||`times`,i=Object.assign({},yR,n.genericFontFamilies||{}),a=null,o=null,s=0;s<t.length;++s)if(i[(a=_R(t[s])).family]&&(a.family=i[a.family]),e.hasOwnProperty(a.family)){o=e[a.family];break}if(!(o||=e[r]))throw Error(`Could not find a font-family for the rule '`+xR(a)+`' and default family '`+r+`'.`);if(o=function(e,t){if(t[e])return t[e];var n=mR[e],r=vR(t,pR,n,n<=mR.normal?-1:1);if(!r)throw Error(`Could not find a matching font-stretch value for `+e);return r}(a.stretch,o),o=function(e,t){if(t[e])return t[e];for(var n=fR[e],r=0;r<n.length;++r)if(t[n[r]])return t[n[r]];throw Error(`Could not find a matching font-style for `+e)}(a.style,o),!(o=function(e,t){if(t[e])return t[e];if(e===400&&t[500])return t[500];if(e===500&&t[400])return t[400];var n=gR[e],r=vR(t,hR,n,e<400?-1:1);if(!r)throw Error(`Could not find a matching font-weight for value `+e);return r}(a.weight,o)))throw Error(`Failed to resolve a font for the rule '`+xR(a)+`'.`);return o}(function(e,t){var n=e.getFontList(),r=JSON.stringify(n);return(p===null||m!==r)&&(p=function(e){for(var t={},n=0;n<e.length;++n){var r=_R(e[n]),i=r.family,a=r.stretch,o=r.style,s=r.weight;t[i]=t[i]||{},t[i][a]=t[i][a]||{},t[i][a][o]=t[i][a][o]||{},t[i][a][o][s]=r}return t}(function(e){var t=[];return Object.keys(e).forEach(function(n){e[n].forEach(function(e){var r=null;switch(e){case`bold`:r={family:n,weight:`bold`};break;case`italic`:r={family:n,style:`italic`};break;case`bolditalic`:r={family:n,weight:`bold`,style:`italic`};break;case``:case`normal`:r={family:n}}r!==null&&(r.ref={name:n,style:e},t.push(r))})}),t}(n).concat(t)),m=r),p}(this.pdf,this.fontFaces),s.map(function(e){return{family:e,stretch:`normal`,weight:r,style:n}}));this.pdf.setFont(c.ref.name,c.ref.style)}else{var l=``;(r===`bold`||parseInt(r,10)>=700||n===`bold`)&&(l=`bold`),n===`italic`&&(l+=`italic`),l.length===0&&(l=`normal`);for(var u=``,d={arial:`Helvetica`,Arial:`Helvetica`,verdana:`Helvetica`,Verdana:`Helvetica`,helvetica:`Helvetica`,Helvetica:`Helvetica`,"sans-serif":`Helvetica`,fixed:`Courier`,monospace:`Courier`,terminal:`Courier`,cursive:`Times`,fantasy:`Times`,serif:`Times`},f=0;f<s.length;f++){if(this.pdf.internal.getFont(s[f],l,{noFallback:!0,disableWarning:!0})!==void 0){u=s[f];break}if(l===`bolditalic`&&this.pdf.internal.getFont(s[f],`bold`,{noFallback:!0,disableWarning:!0})!==void 0)u=s[f],l=`bold`;else if(this.pdf.internal.getFont(s[f],`normal`,{noFallback:!0,disableWarning:!0})!==void 0){u=s[f],l=`normal`;break}}if(u===``){for(var h=0;h<s.length;h++)if(d[s[h]]){u=d[s[h]];break}}u=u===``?`Times`:u,this.pdf.setFont(u,l)}}}}),Object.defineProperty(this,"globalCompositeOperation",{get:function(){return this.ctx.globalCompositeOperation},set:function(e){this.ctx.globalCompositeOperation=e}}),Object.defineProperty(this,"globalAlpha",{get:function(){return this.ctx.globalAlpha},set:function(e){this.ctx.globalAlpha=e}}),Object.defineProperty(this,"lineDashOffset",{get:function(){return this.ctx.lineDashOffset},set:function(e){this.ctx.lineDashOffset=e,L.call(this)}}),Object.defineProperty(this,"lineDash",{get:function(){return this.ctx.lineDash},set:function(e){this.ctx.lineDash=e,L.call(this)}}),Object.defineProperty(this,"ignoreClearRect",{get:function(){return this.ctx.ignoreClearRect},set:function(e){this.ctx.ignoreClearRect=!!e}})};d.prototype.setLineDash=function(e){this.lineDash=e},d.prototype.getLineDash=function(){return this.lineDash.length%2?this.lineDash.concat(this.lineDash):this.lineDash.slice()},d.prototype.fill=function(){b.call(this,`fill`,!1)},d.prototype.stroke=function(){b.call(this,`stroke`,!1)},d.prototype.beginPath=function(){this.path=[{type:`begin`}]},d.prototype.moveTo=function(e,t){if(isNaN(e)||isNaN(t))throw GI.error(`jsPDF.context2d.moveTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.moveTo`);var n=this.ctx.transform.applyToPoint(new o(e,t));this.path.push({type:`mt`,x:n.x,y:n.y}),this.ctx.lastPoint=new o(e,t)},d.prototype.closePath=function(){var e=new o(0,0),t=0;for(t=this.path.length-1;t!==-1;t--)if(this.path[t].type===`begin`&&Pi(this.path[t+1])===`object`&&typeof this.path[t+1].x==`number`){e=new o(this.path[t+1].x,this.path[t+1].y);break}this.path.push({type:`close`}),this.ctx.lastPoint=new o(e.x,e.y)},d.prototype.lineTo=function(e,t){if(isNaN(e)||isNaN(t))throw GI.error(`jsPDF.context2d.lineTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.lineTo`);var n=this.ctx.transform.applyToPoint(new o(e,t));this.path.push({type:`lt`,x:n.x,y:n.y}),this.ctx.lastPoint=new o(n.x,n.y)},d.prototype.clip=function(){this.ctx.clip_path=JSON.parse(JSON.stringify(this.path)),b.call(this,null,!0)},d.prototype.quadraticCurveTo=function(e,t,n,r){if(isNaN(n)||isNaN(r)||isNaN(e)||isNaN(t))throw GI.error(`jsPDF.context2d.quadraticCurveTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.quadraticCurveTo`);var i=this.ctx.transform.applyToPoint(new o(n,r)),a=this.ctx.transform.applyToPoint(new o(e,t));this.path.push({type:`qct`,x1:a.x,y1:a.y,x:i.x,y:i.y}),this.ctx.lastPoint=new o(i.x,i.y)},d.prototype.bezierCurveTo=function(e,t,n,r,i,a){if(isNaN(i)||isNaN(a)||isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw GI.error(`jsPDF.context2d.bezierCurveTo: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.bezierCurveTo`);var s=this.ctx.transform.applyToPoint(new o(i,a)),c=this.ctx.transform.applyToPoint(new o(e,t)),l=this.ctx.transform.applyToPoint(new o(n,r));this.path.push({type:`bct`,x1:c.x,y1:c.y,x2:l.x,y2:l.y,x:s.x,y:s.y}),this.ctx.lastPoint=new o(s.x,s.y)},d.prototype.arc=function(e,t,n,r,i,a){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i))throw GI.error(`jsPDF.context2d.arc: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.arc`);if(a=!!a,!this.ctx.transform.isIdentity){var s=this.ctx.transform.applyToPoint(new o(e,t));e=s.x,t=s.y;var c=this.ctx.transform.applyToPoint(new o(0,n)),l=this.ctx.transform.applyToPoint(new o(0,0));n=Math.sqrt((c.x-l.x)**2+(c.y-l.y)**2)}Math.abs(i-r)>=2*Math.PI&&(r=0,i=2*Math.PI),this.path.push({type:`arc`,x:e,y:t,radius:n,startAngle:r,endAngle:i,counterclockwise:a})},d.prototype.arcTo=function(e,t,n,r,i){throw Error(`arcTo not implemented.`)},d.prototype.rect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw GI.error(`jsPDF.context2d.rect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.rect`);this.moveTo(e,t),this.lineTo(e+n,t),this.lineTo(e+n,t+r),this.lineTo(e,t+r),this.lineTo(e,t),this.lineTo(e+n,t),this.lineTo(e,t)},d.prototype.fillRect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw GI.error(`jsPDF.context2d.fillRect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.fillRect`);if(!p.call(this)){var i={};this.lineCap!==`butt`&&(i.lineCap=this.lineCap,this.lineCap=`butt`),this.lineJoin!==`miter`&&(i.lineJoin=this.lineJoin,this.lineJoin=`miter`),this.beginPath(),this.rect(e,t,n,r),this.fill(),i.hasOwnProperty(`lineCap`)&&(this.lineCap=i.lineCap),i.hasOwnProperty(`lineJoin`)&&(this.lineJoin=i.lineJoin)}},d.prototype.strokeRect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw GI.error(`jsPDF.context2d.strokeRect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.strokeRect`);m.call(this)||(this.beginPath(),this.rect(e,t,n,r),this.stroke())},d.prototype.clearRect=function(e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r))throw GI.error(`jsPDF.context2d.clearRect: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.clearRect`);this.ignoreClearRect||(this.fillStyle=`#ffffff`,this.fillRect(e,t,n,r))},d.prototype.save=function(e){e=typeof e!=`boolean`||e;for(var t=this.pdf.internal.getCurrentPageInfo().pageNumber,n=0;n<this.pdf.internal.getNumberOfPages();n++)this.pdf.setPage(n+1),this.pdf.internal.out(`q`);if(this.pdf.setPage(t),e){this.ctx.fontSize=this.pdf.internal.getFontSize();var r=new u(this.ctx);this.ctxStack.push(this.ctx),this.ctx=r}},d.prototype.restore=function(e){e=typeof e!=`boolean`||e;for(var t=this.pdf.internal.getCurrentPageInfo().pageNumber,n=0;n<this.pdf.internal.getNumberOfPages();n++)this.pdf.setPage(n+1),this.pdf.internal.out(`Q`);this.pdf.setPage(t),e&&this.ctxStack.length!==0&&(this.ctx=this.ctxStack.pop(),this.fillStyle=this.ctx.fillStyle,this.strokeStyle=this.ctx.strokeStyle,this.font=this.ctx.font,this.lineCap=this.ctx.lineCap,this.lineWidth=this.ctx.lineWidth,this.lineJoin=this.ctx.lineJoin,this.lineDash=this.ctx.lineDash,this.lineDashOffset=this.ctx.lineDashOffset)},d.prototype.toDataURL=function(){throw Error(`toDataUrl not implemented.`)};var f=function(e){var t,n,r,i;if(!0===e.isCanvasGradient&&(e=e.getColor()),!e)return{r:0,g:0,b:0,a:0,style:e};if(/transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/.test(e))t=0,n=0,r=0,i=0;else{var a=/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e);if(a!==null)t=parseInt(a[1]),n=parseInt(a[2]),r=parseInt(a[3]),i=1;else if((a=/rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/.exec(e))!==null)t=parseInt(a[1]),n=parseInt(a[2]),r=parseInt(a[3]),i=parseFloat(a[4]);else{if(i=1,typeof e==`string`&&e.charAt(0)!==`#`){var o=new XI(e);e=o.ok?o.toHex():`#000000`}e.length===4?(t=e.substring(1,2),t+=t,n=e.substring(2,3),n+=n,r=e.substring(3,4),r+=r):(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7)),t=parseInt(t,16),n=parseInt(n,16),r=parseInt(r,16)}}return{r:t,g:n,b:r,a:i,style:e}},p=function(){return this.ctx.isFillTransparent||this.globalAlpha==0},m=function(){return!!(this.ctx.isStrokeTransparent||this.globalAlpha==0)};d.prototype.fillText=function(e,t,n,r){if(isNaN(t)||isNaN(n)||typeof e!=`string`)throw GI.error(`jsPDF.context2d.fillText: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.fillText`);if(r=isNaN(r)?void 0:r,!p.call(this)){var i=P(this.ctx.transform.rotation),a=this.ctx.transform.scaleX;O.call(this,{text:e,x:t,y:n,scale:a,angle:i,align:this.textAlign,maxWidth:r})}},d.prototype.strokeText=function(e,t,n,r){if(isNaN(t)||isNaN(n)||typeof e!=`string`)throw GI.error(`jsPDF.context2d.strokeText: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.strokeText`);if(!m.call(this)){r=isNaN(r)?void 0:r;var i=P(this.ctx.transform.rotation),a=this.ctx.transform.scaleX;O.call(this,{text:e,x:t,y:n,scale:a,renderingMode:`stroke`,angle:i,align:this.textAlign,maxWidth:r})}},d.prototype.measureText=function(e){if(typeof e!=`string`)throw GI.error(`jsPDF.context2d.measureText: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.measureText`);var t=this.pdf,n=this.pdf.internal.scaleFactor,r=t.internal.getFontSize(),i=t.getStringUnitWidth(e)*r/t.internal.scaleFactor;return new function(e){var t=(e||={}).width||0;return Object.defineProperty(this,"width",{get:function(){return t}}),this}({width:i*=Math.round(96*n/72*1e4)/1e4})},d.prototype.scale=function(e,t){if(isNaN(e)||isNaN(t))throw GI.error(`jsPDF.context2d.scale: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.scale`);var n=new c(e,0,0,t,0,0);this.ctx.transform=this.ctx.transform.multiply(n)},d.prototype.rotate=function(e){if(isNaN(e))throw GI.error(`jsPDF.context2d.rotate: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.rotate`);var t=new c(Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0);this.ctx.transform=this.ctx.transform.multiply(t)},d.prototype.translate=function(e,t){if(isNaN(e)||isNaN(t))throw GI.error(`jsPDF.context2d.translate: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.translate`);var n=new c(1,0,0,1,e,t);this.ctx.transform=this.ctx.transform.multiply(n)},d.prototype.transform=function(e,t,n,r,i,a){if(isNaN(e)||isNaN(t)||isNaN(n)||isNaN(r)||isNaN(i)||isNaN(a))throw GI.error(`jsPDF.context2d.transform: Invalid arguments`,arguments),Error(`Invalid arguments passed to jsPDF.context2d.transform`);var o=new c(e,t,n,r,i,a);this.ctx.transform=this.ctx.transform.multiply(o)},d.prototype.setTransform=function(e,t,n,r,i,a){e=isNaN(e)?1:e,t=isNaN(t)?0:t,n=isNaN(n)?0:n,r=isNaN(r)?1:r,i=isNaN(i)?0:i,a=isNaN(a)?0:a,this.ctx.transform=new c(e,t,n,r,i,a)};var h=function(){return this.margin[0]>0||this.margin[1]>0||this.margin[2]>0||this.margin[3]>0};d.prototype.drawImage=function(e,t,n,r,i,a,o,l,u){var d=this.pdf.getImageProperties(e),f=1,p=1,m=1,_=1;r!==void 0&&l!==void 0&&(m=l/r,_=u/i,f=d.width/r*l/r,p=d.height/i*u/i),a===void 0&&(a=t,o=n,t=0,n=0),r!==void 0&&l===void 0&&(l=r,u=i),r===void 0&&l===void 0&&(l=d.width,u=d.height);var b=this.ctx.transform.decompose(),S=P(b.rotate.shx),C=new c,w=(C=(C=(C=C.multiply(b.translate)).multiply(b.skew)).multiply(b.scale)).applyToRectangle(new s(a-t*m,o-n*_,r*f,i*p));if(this.autoPaging){for(var T,E=g.call(this,w),D=[],O=0;O<E.length;O+=1)D.indexOf(E[O])===-1&&D.push(E[O]);y(D);for(var k=D[0],A=D[D.length-1],j=k;j<A+1;j++){this.pdf.setPage(j);var M=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],N=j===1?this.posY+this.margin[0]:this.margin[0],F=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],I=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],L=j===1?0:F+(j-2)*I;if(this.ctx.clip_path.length!==0){var R=this.path;T=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=v(T,this.posX+this.margin[3],-L+N+this.ctx.prevPageLastElemOffset),x.call(this,`fill`,!0),this.path=R}var z=JSON.parse(JSON.stringify(w));z=v([z],this.posX+this.margin[3],-L+N+this.ctx.prevPageLastElemOffset)[0];var B=(j>k||j<A)&&h.call(this);B&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],M,I,null).clip().discardPath()),this.pdf.addImage(e,`JPEG`,z.x,z.y,z.w,z.h,null,null,S),B&&this.pdf.restoreGraphicsState()}}else this.pdf.addImage(e,`JPEG`,w.x,w.y,w.w,w.h,null,null,S)};var g=function(e,t,n){var r=[];t||=this.pdf.internal.pageSize.width,n||=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2];var i=this.posY+this.ctx.prevPageLastElemOffset;switch(e.type){default:case`mt`:case`lt`:r.push(Math.floor((e.y+i)/n)+1);break;case`arc`:r.push(Math.floor((e.y+i-e.radius)/n)+1),r.push(Math.floor((e.y+i+e.radius)/n)+1);break;case`qct`:var a=F(this.ctx.lastPoint.x,this.ctx.lastPoint.y,e.x1,e.y1,e.x,e.y);r.push(Math.floor((a.y+i)/n)+1),r.push(Math.floor((a.y+a.h+i)/n)+1);break;case`bct`:var o=I(this.ctx.lastPoint.x,this.ctx.lastPoint.y,e.x1,e.y1,e.x2,e.y2,e.x,e.y);r.push(Math.floor((o.y+i)/n)+1),r.push(Math.floor((o.y+o.h+i)/n)+1);break;case`rect`:r.push(Math.floor((e.y+i)/n)+1),r.push(Math.floor((e.y+e.h+i)/n)+1)}for(var s=0;s<r.length;s+=1)for(;this.pdf.internal.getNumberOfPages()<r[s];)_.call(this);return r},_=function(){var e=this.fillStyle,t=this.strokeStyle,n=this.font,r=this.lineCap,i=this.lineWidth,a=this.lineJoin;this.pdf.addPage(),this.fillStyle=e,this.strokeStyle=t,this.font=n,this.lineCap=r,this.lineWidth=i,this.lineJoin=a},v=function(e,t,n){for(var r=0;r<e.length;r++)switch(e[r].type){case`bct`:e[r].x2+=t,e[r].y2+=n;case`qct`:e[r].x1+=t,e[r].y1+=n;default:e[r].x+=t,e[r].y+=n}return e},y=function(e){return e.sort(function(e,t){return e-t})},b=function(e,t){var n=this.fillStyle,r=this.strokeStyle,i=this.lineCap,a=this.lineWidth,o=Math.abs(a*this.ctx.transform.scaleX),s=this.lineJoin;if(this.autoPaging){for(var c,l,u=JSON.parse(JSON.stringify(this.path)),d=JSON.parse(JSON.stringify(this.path)),f=[],p=0;p<d.length;p++)if(d[p].x!==void 0)for(var m=g.call(this,d[p]),b=0;b<m.length;b+=1)f.indexOf(m[b])===-1&&f.push(m[b]);for(var S=0;S<f.length;S++)for(;this.pdf.internal.getNumberOfPages()<f[S];)_.call(this);y(f);for(var C=f[0],w=f[f.length-1],T=C;T<w+1;T++){this.pdf.setPage(T),this.fillStyle=n,this.strokeStyle=r,this.lineCap=i,this.lineWidth=o,this.lineJoin=s;var E=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],D=T===1?this.posY+this.margin[0]:this.margin[0],O=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],k=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],A=T===1?0:O+(T-2)*k;if(this.ctx.clip_path.length!==0){var j=this.path;c=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=v(c,this.posX+this.margin[3],-A+D+this.ctx.prevPageLastElemOffset),x.call(this,e,!0),this.path=j}if(l=JSON.parse(JSON.stringify(u)),this.path=v(l,this.posX+this.margin[3],-A+D+this.ctx.prevPageLastElemOffset),!1===t||T===0){var M=(T>C||T<w)&&h.call(this);M&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],E,k,null).clip().discardPath()),x.call(this,e,t),M&&this.pdf.restoreGraphicsState()}this.lineWidth=a}this.path=u}else this.lineWidth=o,x.call(this,e,t),this.lineWidth=a},x=function(e,t){if((e!==`stroke`||t||!m.call(this))&&(e===`stroke`||t||!p.call(this))){for(var n,r,i=[],a=this.path,o=0;o<a.length;o++){var s=a[o];switch(s.type){case`begin`:i.push({begin:!0});break;case`close`:i.push({close:!0});break;case`mt`:i.push({start:s,deltas:[],abs:[]});break;case`lt`:var c=i.length;if(a[o-1]&&!isNaN(a[o-1].x)&&(n=[s.x-a[o-1].x,s.y-a[o-1].y],c>0)){for(;c>=0;c--)if(!0!==i[c-1].close&&!0!==i[c-1].begin){i[c-1].deltas.push(n),i[c-1].abs.push(s);break}}break;case`bct`:n=[s.x1-a[o-1].x,s.y1-a[o-1].y,s.x2-a[o-1].x,s.y2-a[o-1].y,s.x-a[o-1].x,s.y-a[o-1].y],i[i.length-1].deltas.push(n);break;case`qct`:var l=a[o-1].x+2/3*(s.x1-a[o-1].x),u=a[o-1].y+2/3*(s.y1-a[o-1].y),d=s.x+2/3*(s.x1-s.x),f=s.y+2/3*(s.y1-s.y),h=s.x,g=s.y;n=[l-a[o-1].x,u-a[o-1].y,d-a[o-1].x,f-a[o-1].y,h-a[o-1].x,g-a[o-1].y],i[i.length-1].deltas.push(n);break;case`arc`:i.push({deltas:[],abs:[],arc:!0}),Array.isArray(i[i.length-1].abs)&&i[i.length-1].abs.push(s)}}r=t?null:e===`stroke`?`stroke`:`fill`;for(var _=!1,v=0;v<i.length;v++)if(i[v].arc)for(var y=i[v].abs,b=0;b<y.length;b++){var x=y[b];x.type===`arc`?w.call(this,x.x,x.y,x.radius,x.startAngle,x.endAngle,x.counterclockwise,void 0,t,!_):k.call(this,x.x,x.y),_=!0}else if(!0===i[v].close)this.pdf.internal.out(`h`),_=!1;else if(!0!==i[v].begin){var S=i[v].start.x,C=i[v].start.y;A.call(this,i[v].deltas,S,C),_=!0}r&&T.call(this,r),t&&E.call(this)}},S=function(e){var t=this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor,n=t*(this.pdf.internal.getLineHeightFactor()-1);switch(this.ctx.textBaseline){case`bottom`:return e-n;case`top`:return e+t-n;case`hanging`:return e+t-2*n;case`middle`:return e+t/2-n;default:return e}},C=function(e){return e+this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor*(this.pdf.internal.getLineHeightFactor()-1)};d.prototype.createLinearGradient=function(){var e=function(){};return e.colorStops=[],e.addColorStop=function(e,t){this.colorStops.push([e,t])},e.getColor=function(){return this.colorStops.length===0?`#000000`:this.colorStops[0][1]},e.isCanvasGradient=!0,e},d.prototype.createPattern=function(){return this.createLinearGradient()},d.prototype.createRadialGradient=function(){return this.createLinearGradient()};var w=function(e,t,n,r,i,a,o,s,c){for(var l=M.call(this,n,r,i,a),u=0;u<l.length;u++){var d=l[u];u===0&&(c?D.call(this,d.x1+e,d.y1+t):k.call(this,d.x1+e,d.y1+t)),j.call(this,e,t,d.x2,d.y2,d.x3,d.y3,d.x4,d.y4)}s?E.call(this):T.call(this,o)},T=function(e){switch(e){case`stroke`:this.pdf.internal.out(`S`);break;case`fill`:this.pdf.internal.out(`f`)}},E=function(){this.pdf.clip(),this.pdf.discardPath()},D=function(e,t){this.pdf.internal.out(n(e)+` `+r(t)+` m`)},O=function(e){var t;switch(e.align){case`right`:case`end`:t=`right`;break;case`center`:t=`center`;break;default:t=`left`}var n,r,i,a=this.pdf.getTextDimensions(e.text),l=S.call(this,e.y),u=C.call(this,l)-a.h,d=this.ctx.transform.applyToPoint(new o(e.x,l));if(this.autoPaging){var f=this.ctx.transform.decompose(),p=new c;p=(p=(p=p.multiply(f.translate)).multiply(f.skew)).multiply(f.scale);for(var m=this.ctx.transform.applyToRectangle(new s(e.x,l,a.w,a.h)),_=p.applyToRectangle(new s(e.x,u,a.w,a.h)),b=g.call(this,_),w=[],T=0;T<b.length;T+=1)w.indexOf(b[T])===-1&&w.push(b[T]);y(w);for(var E=w[0],D=w[w.length-1],O=E;O<D+1;O++){this.pdf.setPage(O);var k=O===1?this.posY+this.margin[0]:this.margin[0],A=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],j=this.pdf.internal.pageSize.height-this.margin[2],M=j-this.margin[0],N=this.pdf.internal.pageSize.width-this.margin[1],P=N-this.margin[3],F=O===1?0:A+(O-2)*M;if(this.ctx.clip_path.length!==0){var I=this.path;n=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=v(n,this.posX+this.margin[3],-1*F+k),x.call(this,`fill`,!0),this.path=I}var L=v([JSON.parse(JSON.stringify(_))],this.posX+this.margin[3],-F+k+this.ctx.prevPageLastElemOffset)[0];e.scale>=.01&&(r=this.pdf.internal.getFontSize(),this.pdf.setFontSize(r*e.scale),i=this.lineWidth,this.lineWidth=i*e.scale);var R=this.autoPaging!==`text`;if(R||L.y+L.h<=j){if(R||L.y>=k&&L.x<=N){var z=R?e.text:this.pdf.splitTextToSize(e.text,e.maxWidth||N-L.x)[0],B=v([JSON.parse(JSON.stringify(m))],this.posX+this.margin[3],-F+k+this.ctx.prevPageLastElemOffset)[0],V=R&&(O>E||O<D)&&h.call(this);V&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],P,M,null).clip().discardPath()),this.pdf.text(z,B.x,B.y,{angle:e.angle,align:t,renderingMode:e.renderingMode}),V&&this.pdf.restoreGraphicsState()}}else L.y<j&&(this.ctx.prevPageLastElemOffset+=j-L.y);e.scale>=.01&&(this.pdf.setFontSize(r),this.lineWidth=i)}}else e.scale>=.01&&(r=this.pdf.internal.getFontSize(),this.pdf.setFontSize(r*e.scale),i=this.lineWidth,this.lineWidth=i*e.scale),this.pdf.text(e.text,d.x+this.posX,d.y+this.posY,{angle:e.angle,align:t,renderingMode:e.renderingMode,maxWidth:e.maxWidth}),e.scale>=.01&&(this.pdf.setFontSize(r),this.lineWidth=i)},k=function(e,t,i,a){i||=0,a||=0,this.pdf.internal.out(n(e+i)+` `+r(t+a)+` l`)},A=function(e,t,n){return this.pdf.lines(e,t,n,null,null)},j=function(e,n,r,o,s,c,l,u){this.pdf.internal.out([t(i(r+e)),t(a(o+n)),t(i(s+e)),t(a(c+n)),t(i(l+e)),t(a(u+n)),`c`].join(` `))},M=function(e,t,n,r){for(var i=2*Math.PI,a=Math.PI/2;t>n;)t-=i;var o=Math.abs(n-t);o<i&&r&&(o=i-o);for(var s=[],c=r?-1:1,l=t;o>1e-5;){var u=l+c*Math.min(o,a);s.push(N.call(this,e,l,u)),o-=Math.abs(u-l),l=u}return s},N=function(e,t,n){var r=(n-t)/2,i=e*Math.cos(r),a=e*Math.sin(r),o=i,s=-a,c=o*o+s*s,l=c+o*i+s*a,u=4/3*(Math.sqrt(2*c*l)-l)/(o*a-s*i),d=o-u*s,f=s+u*o,p=d,m=-f,h=r+t,g=Math.cos(h),_=Math.sin(h);return{x1:e*Math.cos(t),y1:e*Math.sin(t),x2:d*g-f*_,y2:d*_+f*g,x3:p*g-m*_,y3:p*_+m*g,x4:e*Math.cos(n),y4:e*Math.sin(n)}},P=function(e){return 180*e/Math.PI},F=function(e,t,n,r,i,a){var o=e+.5*(n-e),c=t+.5*(r-t),l=i+.5*(n-i),u=a+.5*(r-a),d=Math.min(e,i,o,l),f=Math.max(e,i,o,l),p=Math.min(t,a,c,u),m=Math.max(t,a,c,u);return new s(d,p,f-d,m-p)},I=function(e,t,n,r,i,a,o,c){var l,u,d,f,p,m,h,g,_,v,y,b,x,S,C=n-e,w=r-t,T=i-n,E=a-r,D=o-i,O=c-a;for(u=0;u<41;u++)_=(h=(d=e+(l=u/40)*C)+l*((p=n+l*T)-d))+l*(p+l*(i+l*D-p)-h),v=(g=(f=t+l*w)+l*((m=r+l*E)-f))+l*(m+l*(a+l*O-m)-g),u==0?(y=_,b=v,x=_,S=v):(y=Math.min(y,_),b=Math.min(b,v),x=Math.max(x,_),S=Math.max(S,v));return new s(Math.round(y),Math.round(b),Math.round(x-y),Math.round(S-b))},L=function(){if(this.prevLineDash||this.ctx.lineDash.length||this.ctx.lineDashOffset){var e,t,n=(e=this.ctx.lineDash,t=this.ctx.lineDashOffset,JSON.stringify({lineDash:e,lineDashOffset:t}));this.prevLineDash!==n&&(this.pdf.setLineDash(this.ctx.lineDash,this.ctx.lineDashOffset),this.prevLineDash=n)}}})(SL.API),function(e){var t=function(e){var t,n,r,i,a,o,s,c,l,u;for(/[^\x00-\xFF]/.test(e),n=[],r=0,i=(e+=t=`\0\0\0\0`.slice(e.length%4||4)).length;i>r;r+=4)(a=(e.charCodeAt(r)<<24)+(e.charCodeAt(r+1)<<16)+(e.charCodeAt(r+2)<<8)+e.charCodeAt(r+3))===0?n.push(122):(o=(a=((a=((a=((a=(a-(u=a%85))/85)-(l=a%85))/85)-(c=a%85))/85)-(s=a%85))/85)%85,n.push(o+33,s+33,c+33,l+33,u+33));return function(e,t){for(var n=t;n>0;n--)e.pop()}(n,t.length),String.fromCharCode.apply(String,n)+`~>`},n=function(e){var t,n,r,i,a,o=String,s=`length`,c=255,l=`charCodeAt`,u=`slice`,d=`replace`;for(e[u](-2),e=e[u](0,-2)[d](/\s/g,``)[d](`z`,`!!!!!`),r=[],i=0,a=(e+=t=`uuuuu`[u](e[s]%5||5))[s];a>i;i+=5)n=52200625*(e[l](i)-33)+614125*(e[l](i+1)-33)+7225*(e[l](i+2)-33)+85*(e[l](i+3)-33)+(e[l](i+4)-33),r.push(c&n>>24,c&n>>16,c&n>>8,c&n);return function(e,t){for(var n=t;n>0;n--)e.pop()}(r,t[s]),o.fromCharCode.apply(o,r)},r=function(e){return e.split(``).map(function(e){return(`0`+e.charCodeAt().toString(16)).slice(-2)}).join(``)+`>`},i=function(e){var t=new RegExp(/^([0-9A-Fa-f]{2})+$/);if((e=e.replace(/\s/g,``)).indexOf(`>`)!==-1&&(e=e.substr(0,e.indexOf(`>`))),e.length%2&&(e+=`0`),!1===t.test(e))return``;for(var n=``,r=0;r<e.length;r+=2)n+=String.fromCharCode(`0x`+(e[r]+e[r+1]));return n},a=function(e){for(var t=new Uint8Array(e.length),n=e.length;n--;)t[n]=e.charCodeAt(n);return(t=JA(t)).reduce(function(e,t){return e+String.fromCharCode(t)},``)};e.processDataByFilters=function(e,o){var s=0,c=e||``,l=[];for(typeof(o||=[])==`string`&&(o=[o]),s=0;s<o.length;s+=1)switch(o[s]){case`ASCII85Decode`:case`/ASCII85Decode`:c=n(c),l.push(`/ASCII85Encode`);break;case`ASCII85Encode`:case`/ASCII85Encode`:c=t(c),l.push(`/ASCII85Decode`);break;case`ASCIIHexDecode`:case`/ASCIIHexDecode`:c=i(c),l.push(`/ASCIIHexEncode`);break;case`ASCIIHexEncode`:case`/ASCIIHexEncode`:c=r(c),l.push(`/ASCIIHexDecode`);break;case`FlateEncode`:case`/FlateEncode`:c=a(c),l.push(`/FlateDecode`);break;default:throw Error(`The filter: "`+o[s]+`" is not implemented`)}return{data:c,reverseChain:l.reverse().join(` `)}}}(SL.API),function(e){e.loadFile=function(e,t,n){return function(e,t,n){t=!1!==t,n=typeof n==`function`?n:function(){};var r=void 0;try{r=function(e,t,n){var r=new XMLHttpRequest,i=0,a=function(e){var t=e.length,n=[],r=String.fromCharCode;for(i=0;i<t;i+=1)n.push(r(255&e.charCodeAt(i)));return n.join(``)};if(r.open(`GET`,e,!t),r.overrideMimeType(`text/plain; charset=x-user-defined`),!1===t&&(r.onload=function(){r.status===200?n(a(this.responseText)):n(void 0)}),r.send(null),t&&r.status===200)return a(r.responseText)}(e,t,n)}catch{}return r}(e,t,n)},e.allowFsRead=void 0,e.loadImageFile=e.loadFile}(SL.API),function(e){function t(){return(UI.html2canvas?Promise.resolve(UI.html2canvas):ht(()=>import(`./html2canvas-pro.esm-Byf5I_tX.js`).then(e=>e.n),__vite__mapDeps([0,1]))).catch(function(e){return Promise.reject(Error(`Could not load html2canvas: `+e))}).then(function(e){return e.default?e.default:e})}function n(){return(UI.DOMPurify?Promise.resolve(UI.DOMPurify):ht(()=>import(`./purify.es-JEAr64Sr.js`),[])).catch(function(e){return Promise.reject(Error(`Could not load dompurify: `+e))}).then(function(e){return e.default?e.default:e})}var r=function(e){var t=Pi(e);return t===`undefined`?`undefined`:t===`string`||e instanceof String?`string`:t===`number`||e instanceof Number?`number`:t===`function`||e instanceof Function?`function`:e&&e.constructor===Array?`array`:e&&e.nodeType===1?`element`:t===`object`?`object`:`unknown`},i=function(e,t){var n=document.createElement(e);for(var r in t.className&&(n.className=t.className),t.innerHTML&&t.dompurify&&(n.innerHTML=t.dompurify.sanitize(t.innerHTML)),t.style)n.style[r]=t.style[r];return n},a=function e(t,n){for(var r=t.nodeType===3?document.createTextNode(t.nodeValue):t.cloneNode(!1),i=t.firstChild;i;i=i.nextSibling)!0!==n&&i.nodeType===1&&i.nodeName===`SCRIPT`||r.appendChild(e(i,n));return t.nodeType===1&&(t.nodeName===`CANVAS`?(r.width=t.width,r.height=t.height,r.getContext(`2d`).drawImage(t,0,0)):t.nodeName!==`TEXTAREA`&&t.nodeName!==`SELECT`||(r.value=t.value),r.addEventListener(`load`,function(){r.scrollTop=t.scrollTop,r.scrollLeft=t.scrollLeft},!0)),r},o=function e(t){var n=Object.assign(e.convert(Promise.resolve()),JSON.parse(JSON.stringify(e.template))),r=e.convert(Promise.resolve(),n);return(r=r.setProgress(1,e,1,[e])).set(t)};(o.prototype=Object.create(Promise.prototype)).constructor=o,o.convert=function(e,t){return e.__proto__=t||o.prototype,e},o.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:`file.pdf`,margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:`transparent`}},o.prototype.from=function(e,t){return this.then(function(){switch(t||=function(e){switch(r(e)){case`string`:return`string`;case`element`:return e.nodeName.toLowerCase()===`canvas`?`canvas`:`element`;default:return`unknown`}}(e),t){case`string`:return this.then(n).then(function(t){return this.set({src:i(`div`,{innerHTML:e,dompurify:t})})});case`element`:return this.set({src:e});case`canvas`:return this.set({canvas:e});case`img`:return this.set({img:e});default:return this.error(`Unknown source type.`)}})},o.prototype.to=function(e){switch(e){case`container`:return this.toContainer();case`canvas`:return this.toCanvas();case`img`:return this.toImg();case`pdf`:return this.toPdf();default:return this.error(`Invalid target.`)}},o.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error(`Cannot duplicate - no source HTML.`)},function(){return this.prop.pageSize||this.setPageSize()}]).then(function(){var e={position:`relative`,display:`inline-block`,width:(typeof this.opt.width!=`number`||isNaN(this.opt.width)||typeof this.opt.windowWidth!=`number`||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+`px`,left:0,right:0,top:0,margin:`auto`,backgroundColor:this.opt.backgroundColor},t=a(this.prop.src,this.opt.html2canvas.javascriptEnabled);t.tagName===`BODY`&&(e.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+`px`),this.prop.overlay=i(`div`,{className:`html2pdf__overlay`,style:{position:`fixed`,overflow:`hidden`,zIndex:1e3,left:`-100000px`,right:0,bottom:0,top:0}}),this.prop.container=i(`div`,{className:`html2pdf__container`,style:e}),this.prop.container.appendChild(t),this.prop.container.firstChild.appendChild(i(`div`,{style:{clear:`both`,border:`0 none transparent`,margin:0,padding:0,height:0}})),this.prop.container.style.float=`none`,this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position=`relative`,this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+`px`})},o.prototype.toCanvas=function(){return this.thenList([function(){return document.body.contains(this.prop.container)||this.toContainer()}]).then(t).then(function(e){var t=Object.assign({},this.opt.html2canvas);return delete t.onrendered,e(this.prop.container,t)}).then(function(e){(this.opt.html2canvas.onrendered||function(){})(e),this.prop.canvas=e,document.body.removeChild(this.prop.overlay)})},o.prototype.toContext2d=function(){return this.thenList([function(){return document.body.contains(this.prop.container)||this.toContainer()}]).then(t).then(function(e){var t=this.opt.jsPDF,n=this.opt.fontFaces,r=typeof this.opt.width!=`number`||isNaN(this.opt.width)||typeof this.opt.windowWidth!=`number`||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,i=Object.assign({async:!0,allowTaint:!0,scale:r,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:`#ffffff`,imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete i.onrendered,t.context2d.autoPaging=this.opt.autoPaging===void 0||this.opt.autoPaging,t.context2d.posX=this.opt.x,t.context2d.posY=this.opt.y,t.context2d.margin=this.opt.margin,t.context2d.fontFaces=n,n)for(var a=0;a<n.length;++a){var o=n[a],s=o.src.find(function(e){return e.format===`truetype`});s&&t.addFont(s.url,o.ref.name,o.ref.style)}return i.windowHeight=i.windowHeight||0,i.windowHeight=i.windowHeight==0?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):i.windowHeight,t.context2d.save(!0),e(this.prop.container,i)}).then(function(e){this.opt.jsPDF.context2d.restore(!0),(this.opt.html2canvas.onrendered||function(){})(e),this.prop.canvas=e,document.body.removeChild(this.prop.overlay)})},o.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then(function(){var e=this.prop.canvas.toDataURL(`image/`+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement(`img`),this.prop.img.src=e})},o.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then(function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF})},o.prototype.output=function(e,t,n){return(n||=`pdf`).toLowerCase()===`img`||n.toLowerCase()===`image`?this.outputImg(e,t):this.outputPdf(e,t)},o.prototype.outputPdf=function(e,t){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){return this.prop.pdf.output(e,t)})},o.prototype.outputImg=function(e){return this.thenList([function(){return this.prop.img||this.toImg()}]).then(function(){switch(e){case void 0:case`img`:return this.prop.img;case`datauristring`:case`dataurlstring`:return this.prop.img.src;case`datauri`:case`dataurl`:return document.location.href=this.prop.img.src;default:throw`Image output type "`+e+`" is not supported.`}})},o.prototype.save=function(e){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(e?{filename:e}:null).then(function(){this.prop.pdf.save(this.opt.filename)})},o.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){this.prop.callback(this.prop.pdf)})},o.prototype.set=function(e){if(r(e)!==`object`)return this;var t=Object.keys(e||{}).map(function(t){if(t in o.template.prop)return function(){this.prop[t]=e[t]};switch(t){case`margin`:return this.setMargin.bind(this,e.margin);case`jsPDF`:return function(){return this.opt.jsPDF=e.jsPDF,this.setPageSize()};case`pageSize`:return this.setPageSize.bind(this,e.pageSize);default:return function(){this.opt[t]=e[t]}}},this);return this.then(function(){return this.thenList(t)})},o.prototype.get=function(e,t){return this.then(function(){var n=e in o.template.prop?this.prop[e]:this.opt[e];return t?t(n):n})},o.prototype.setMargin=function(e){return this.then(function(){switch(r(e)){case`number`:e=[e,e,e,e];case`array`:if(e.length===2&&(e=[e[0],e[1],e[0],e[1]]),e.length===4)break;default:return this.error(`Invalid margin array.`)}this.opt.margin=e}).then(this.setPageSize)},o.prototype.setPageSize=function(e){function t(e,t){return Math.floor(e*t/72*96)}return this.then(function(){(e||=SL.getPageSize(this.opt.jsPDF)).hasOwnProperty(`inner`)||(e.inner={width:e.width-this.opt.margin[1]-this.opt.margin[3],height:e.height-this.opt.margin[0]-this.opt.margin[2]},e.inner.px={width:t(e.inner.width,e.k),height:t(e.inner.height,e.k)},e.inner.ratio=e.inner.height/e.inner.width),this.prop.pageSize=e})},o.prototype.setProgress=function(e,t,n,r){return e!=null&&(this.progress.val=e),t!=null&&(this.progress.state=t),n!=null&&(this.progress.n=n),r!=null&&(this.progress.stack=r),this.progress.ratio=this.progress.val/this.progress.state,this},o.prototype.updateProgress=function(e,t,n,r){return this.setProgress(e?this.progress.val+e:null,t||null,n?this.progress.n+n:null,r?this.progress.stack.concat(r):null)},o.prototype.then=function(e,t){var n=this;return this.thenCore(e,t,function(e,t){return n.updateProgress(null,null,1,[e]),Promise.prototype.then.call(this,function(t){return n.updateProgress(null,e),t}).then(e,t).then(function(e){return n.updateProgress(1),e})})},o.prototype.thenCore=function(e,t,n){n||=Promise.prototype.then;var r=this;e&&=e.bind(r),t&&=t.bind(r);var i=Promise.toString().indexOf(`[native code]`)!==-1&&Promise.name===`Promise`?r:o.convert(Object.assign({},r),Promise.prototype),a=n.call(i,e,t);return o.convert(a,r.__proto__)},o.prototype.thenExternal=function(e,t){return Promise.prototype.then.call(this,e,t)},o.prototype.thenList=function(e){var t=this;return e.forEach(function(e){t=t.thenCore(e)}),t},o.prototype.catch=function(e){e&&=e.bind(this);var t=Promise.prototype.catch.call(this,e);return o.convert(t,this)},o.prototype.catchExternal=function(e){return Promise.prototype.catch.call(this,e)},o.prototype.error=function(e){return this.then(function(){throw Error(e)})},o.prototype.using=o.prototype.set,o.prototype.saveAs=o.prototype.save,o.prototype.export=o.prototype.output,o.prototype.run=o.prototype.then,SL.getPageSize=function(e,t,n){if(Pi(e)===`object`){var r=e;e=r.orientation,t=r.unit||t,n=r.format||n}t||=`mm`,n||=`a4`,e=(``+(e||`P`)).toLowerCase();var i,a=(``+n).toLowerCase(),o={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};switch(t){case`pt`:i=1;break;case`mm`:i=72/25.4;break;case`cm`:i=72/2.54;break;case`in`:i=72;break;case`px`:i=.75;break;case`pc`:case`em`:i=12;break;case`ex`:i=6;break;default:throw`Invalid unit: `+t}var s,c=0,l=0;if(o.hasOwnProperty(a))c=o[a][1]/i,l=o[a][0]/i;else try{c=n[1],l=n[0]}catch{throw Error(`Invalid format: `+n)}if(e===`p`||e===`portrait`)e=`p`,l>c&&(s=l,l=c,c=s);else{if(e!==`l`&&e!==`landscape`)throw`Invalid orientation: `+e;e=`l`,c>l&&(s=l,l=c,c=s)}return{width:l,height:c,unit:t,k:i,orientation:e}},e.html=function(e,t){(t||={}).callback=t.callback||function(){},t.html2canvas=t.html2canvas||{},t.html2canvas.canvas=t.html2canvas.canvas||this.canvas,t.jsPDF=t.jsPDF||this,t.fontFaces=t.fontFaces?t.fontFaces.map(_R):null;var n=new o(t);return t.worker?n:n.from(e).doCallback()}}(SL.API),SL.API.addJS=function(e){var t,n,r=function(e){for(var t=``,n=0;n<e.length;n++){var r=e[n];if(r===`(`||r===`)`){for(var i=0,a=n-1;a>=0&&e[a]===`\\`;a--)i++;t+=i%2==0?`\\`+r:r}else t+=r}return t}(e);return this.internal.events.subscribe(`postPutResources`,function(){t=this.internal.newObject(),this.internal.out(`<<`),this.internal.out(`/Names [(EmbeddedJS) `+(t+1)+` 0 R]`),this.internal.out(`>>`),this.internal.out(`endobj`),n=this.internal.newObject(),this.internal.out(`<<`),this.internal.out(`/S /JavaScript`),this.internal.out(`/JS (`+r+`)`),this.internal.out(`>>`),this.internal.out(`endobj`)}),this.internal.events.subscribe(`putCatalog`,function(){t!==void 0&&n!==void 0&&this.internal.out(`/Names <</JavaScript `+t+` 0 R>>`)}),this},function(e){var t;e.events.push([`postPutResources`,function(){var e=this,n=/^(\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var r=e.outline.render().split(/\r\n/),i=0;i<r.length;i++){var a=r[i],o=n.exec(a);if(o!=null){var s=o[1];e.internal.newObjectDeferredBegin(s,!1)}e.internal.write(a)}if(this.outline.createNamedDestinations){var c=this.internal.pages.length,l=[];for(i=0;i<c;i++){var u=e.internal.newObject();l.push(u);var d=e.internal.getPageInfo(i+1);e.internal.write(`<< /D[`+d.objId+` 0 R /XYZ null null null]>> endobj`)}var f=e.internal.newObject();for(e.internal.write(`<< /Names [ `),i=0;i<l.length;i++)e.internal.write(`(page_`+(i+1)+`)`+l[i]+` 0 R`);e.internal.write(` ] >>`,`endobj`),t=e.internal.newObject(),e.internal.write(`<< /Dests `+f+` 0 R`),e.internal.write(`>>`,`endobj`)}}]),e.events.push([`putCatalog`,function(){var e=this;e.outline.root.children.length>0&&(e.internal.write(`/Outlines`,this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&e.internal.write(`/Names `+t+` 0 R`))}]),e.events.push([`initialized`,function(){var e=this;e.outline={createNamedDestinations:!1,root:{children:[]}},e.outline.add=function(e,t,n){var r={title:t,options:n,children:[]};return e??=this.root,e.children.push(r),r},e.outline.render=function(){return this.ctx={},this.ctx.val=``,this.ctx.pdf=e,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},e.outline.genIds_r=function(t){t.id=e.internal.newObjectDeferred();for(var n=0;n<t.children.length;n++)this.genIds_r(t.children[n])},e.outline.renderRoot=function(e){this.objStart(e),this.line(`/Type /Outlines`),e.children.length>0&&(this.line(`/First `+this.makeRef(e.children[0])),this.line(`/Last `+this.makeRef(e.children[e.children.length-1]))),this.line(`/Count `+this.count_r({count:0},e)),this.objEnd()},e.outline.renderItems=function(t){for(var n=this.ctx.pdf.internal.getVerticalCoordinateString,r=0;r<t.children.length;r++){var i=t.children[r];this.objStart(i),this.line(`/Title `+this.makeString(i.title)),this.line(`/Parent `+this.makeRef(t)),r>0&&this.line(`/Prev `+this.makeRef(t.children[r-1])),r<t.children.length-1&&this.line(`/Next `+this.makeRef(t.children[r+1])),i.children.length>0&&(this.line(`/First `+this.makeRef(i.children[0])),this.line(`/Last `+this.makeRef(i.children[i.children.length-1])));var a=this.count=this.count_r({count:0},i);if(a>0&&this.line(`/Count `+a),i.options&&i.options.pageNumber){var o=e.internal.getPageInfo(i.options.pageNumber);this.line(`/Dest [`+o.objId+` 0 R /XYZ 0 `+n(0)+` 0]`)}this.objEnd()}for(var s=0;s<t.children.length;s++)this.renderItems(t.children[s])},e.outline.line=function(e){this.ctx.val+=e+`\r
`},e.outline.makeRef=function(e){return e.id+` 0 R`},e.outline.makeString=function(t){return`(`+e.internal.pdfEscape(t)+`)`},e.outline.objStart=function(e){this.ctx.val+=`\r
`+e.id+` 0 obj\r
<<\r
`},e.outline.objEnd=function(){this.ctx.val+=`>> \r
endobj\r
`},e.outline.count_r=function(e,t){for(var n=0;n<t.children.length;n++)e.count++,this.count_r(e,t.children[n]);return e.count}}])}(SL.API),function(e){var t=[192,193,194,195,196,197,198,199];e.processJPEG=function(e,n,r,i,a,o){var s,c=this.decode.DCT_DECODE,l=null;if(typeof e==`string`||this.__addimage__.isArrayBuffer(e)||this.__addimage__.isArrayBufferView(e)){switch(e=a||e,e=this.__addimage__.isArrayBuffer(e)?new Uint8Array(e):e,s=function(e){for(var n,r=256*e.charCodeAt(4)+e.charCodeAt(5),i=e.length,a={width:0,height:0,numcomponents:1},o=4;o<i;o+=2){if(o+=r,t.indexOf(e.charCodeAt(o+1))!==-1){n=256*e.charCodeAt(o+5)+e.charCodeAt(o+6),a={width:256*e.charCodeAt(o+7)+e.charCodeAt(o+8),height:n,numcomponents:e.charCodeAt(o+9)};break}r=256*e.charCodeAt(o+2)+e.charCodeAt(o+3)}return a}(e=this.__addimage__.isArrayBufferView(e)?this.__addimage__.arrayBufferToBinaryString(e):e),s.numcomponents){case 1:o=this.color_spaces.DEVICE_GRAY;break;case 4:o=this.color_spaces.DEVICE_CMYK;break;case 3:o=this.color_spaces.DEVICE_RGB}l={data:e,width:s.width,height:s.height,colorSpace:o,bitsPerComponent:8,filter:c,index:n,alias:r}}return l}}(SL.API),SL.API.processPNG=function(e,t,n,r){if(this.__addimage__.isArrayBuffer(e)&&(e=new Uint8Array(e)),this.__addimage__.isArrayBufferView(e)){var i,a=HI(e,{checkCrc:!0}),o=a.width,s=a.height,c=a.channels,l=a.palette,u=a.depth;i=l&&c===1?function(e){for(var t=e.width,n=e.height,r=e.data,i=e.palette,a=e.depth,o=!1,s=[],c=[],l=void 0,u=!1,d=0,f=0;f<i.length;f++){var p=tj(i[f],4),m=p[0],h=p[1],g=p[2],_=p[3];s.push(m,h,g),_!=null&&(_===0?(d++,c.length<1&&c.push(f)):_<255&&(u=!0))}if(u||d>1){o=!0,c=void 0;var v=t*n;l=new Uint8Array(v);for(var y=new DataView(r.buffer),b=0;b<v;b++){var x=tj(i[zR(y,b,a)],4)[3];l[b]=x}}else d===0&&(c=void 0);return{colorSpace:`Indexed`,colorsPerPixel:1,sMaskBitsPerComponent:o?8:void 0,colorBytes:r,alphaBytes:l,needSMask:o,palette:s,mask:c}}(a):c===2||c===4?function(e){for(var t=e.data,n=e.width,r=e.height,i=e.channels,a=e.depth,o=i===2?`DeviceGray`:`DeviceRGB`,s=i-1,c=n*r,l=s,u=c*l,d=1*c,f=Math.ceil(u*a/8),p=Math.ceil(d*a/8),m=new Uint8Array(f),h=new Uint8Array(p),g=new DataView(t.buffer),_=new DataView(m.buffer),v=new DataView(h.buffer),y=!1,b=0;b<c;b++){for(var x=b*i,S=0;S<l;S++)BR(_,zR(g,x+S,a),b*l+S,a);var C=zR(g,x+l,a);C<(1<<a)-1&&(y=!0),BR(v,C,1*b,a)}return{colorSpace:o,colorsPerPixel:s,sMaskBitsPerComponent:y?a:void 0,colorBytes:m,alphaBytes:h,needSMask:y}}(a):function(e){var t=e.data,n=e.channels===1?`DeviceGray`:`DeviceRGB`;return{colorSpace:n,colorsPerPixel:n===`DeviceGray`?1:3,colorBytes:t instanceof Uint16Array?function(e){for(var t=e.length,n=new Uint8Array(2*t),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=0;i<t;i++)r.setUint16(2*i,e[i],!1);return n}(t):t,needSMask:!1}}(a);var d,f,p,m=i,h=m.colorSpace,g=m.colorsPerPixel,_=m.sMaskBitsPerComponent,v=m.colorBytes,y=m.alphaBytes,b=m.needSMask,x=m.palette,S=m.mask,C=null;return r!==SL.API.image_compression.NONE&&typeof JA==`function`?(C=function(e){var t;switch(e){case SL.API.image_compression.FAST:t=11;break;case SL.API.image_compression.MEDIUM:t=13;break;case SL.API.image_compression.SLOW:t=14;break;default:t=12}return t}(r),d=this.decode.FLATE_DECODE,f=`/Predictor ${C} /Colors ${g} /BitsPerComponent ${u} /Columns ${o}`,e=jR(v,Math.ceil(o*g*u/8),g,u,r),b&&(p=jR(y,Math.ceil(o*_/8),1,_,r))):(d=void 0,f=void 0,e=v,b&&(p=y)),(this.__addimage__.isArrayBuffer(e)||this.__addimage__.isArrayBufferView(e))&&(e=this.__addimage__.arrayBufferToBinaryString(e)),(p&&this.__addimage__.isArrayBuffer(p)||this.__addimage__.isArrayBufferView(p))&&(p=this.__addimage__.arrayBufferToBinaryString(p)),{alias:n,data:e,index:t,filter:d,decodeParameters:f,transparency:S,palette:x,sMask:p,predictor:C,width:o,height:s,bitsPerComponent:u,sMaskBitsPerComponent:_,colorSpace:h}}},function(e){e.processGIF89A=function(t,n,r,i){var a=new HR(t),o=a.width,s=a.height,c=[];a.decodeAndBlitFrameRGBA(0,c);var l={data:c,width:o,height:s},u=new WR(100).encode(l,100);return e.processJPEG.call(this,u,n,r,i)},e.processGIF87A=e.processGIF89A}(SL.API),GR.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.bitPP===16&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var e=this.colors===0?1<<this.bitPP:this.colors;this.palette=Array(e);for(var t=0;t<e;t++){var n=this.datav.getUint8(this.pos++,!0),r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0);this.palette[t]={red:i,green:r,blue:n,quad:a}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},GR.prototype.parseBGR=function(){this.pos=this.offset;var e=`bit`+this.bitPP,t=this.width*this.height*4;if(t>536870912)throw Error(`Image dimensions exceed 512MB, which is too large.`);this.data=new Uint8Array(t);try{this[e]()}catch(e){GI.log(`bit decode error:`+e)}},GR.prototype.bit1=function(){var e,t=Math.ceil(this.width/8),n=t%4;for(e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,i=0;i<t;i++)for(var a=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+8*i*4,s=0;s<8&&8*i+s<this.width;s++){var c=this.palette[a>>7-s&1];this.data[o+4*s]=c.blue,this.data[o+4*s+1]=c.green,this.data[o+4*s+2]=c.red,this.data[o+4*s+3]=255}n!==0&&(this.pos+=4-n)}},GR.prototype.bit4=function(){for(var e=Math.ceil(this.width/2),t=e%4,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i<e;i++){var a=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+2*i*4,s=a>>4,c=15&a,l=this.palette[s];if(this.data[o]=l.blue,this.data[o+1]=l.green,this.data[o+2]=l.red,this.data[o+3]=255,2*i+1>=this.width)break;l=this.palette[c],this.data[o+4]=l.blue,this.data[o+4+1]=l.green,this.data[o+4+2]=l.red,this.data[o+4+3]=255}t!==0&&(this.pos+=4-t)}},GR.prototype.bit8=function(){for(var e=this.width%4,t=this.height-1;t>=0;t--){for(var n=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var i=this.datav.getUint8(this.pos++,!0),a=n*this.width*4+4*r;if(i<this.palette.length){var o=this.palette[i];this.data[a]=o.red,this.data[a+1]=o.green,this.data[a+2]=o.blue,this.data[a+3]=255}else this.data[a]=255,this.data[a+1]=255,this.data[a+2]=255,this.data[a+3]=255}e!==0&&(this.pos+=4-e)}},GR.prototype.bit15=function(){for(var e=this.width%3,t=31,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i<this.width;i++){var a=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(a&t)/t*255|0,s=(a>>5&t)/t*255|0,c=(a>>10&t)/t*255|0,l=a>>15?255:0,u=r*this.width*4+4*i;this.data[u]=c,this.data[u+1]=s,this.data[u+2]=o,this.data[u+3]=l}this.pos+=e}},GR.prototype.bit16=function(){for(var e=this.width%3,t=31,n=63,r=this.height-1;r>=0;r--){for(var i=this.bottom_up?r:this.height-1-r,a=0;a<this.width;a++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var s=(o&t)/t*255|0,c=(o>>5&n)/n*255|0,l=(o>>11)/t*255|0,u=i*this.width*4+4*a;this.data[u]=l,this.data[u+1]=c,this.data[u+2]=s,this.data[u+3]=255}this.pos+=e}},GR.prototype.bit24=function(){for(var e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=t*this.width*4+4*n;this.data[o]=a,this.data[o+1]=i,this.data[o+2]=r,this.data[o+3]=255}this.pos+=this.width%4}},GR.prototype.bit32=function(){for(var e=this.height-1;e>=0;e--)for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),s=t*this.width*4+4*n;this.data[s]=a,this.data[s+1]=i,this.data[s+2]=r,this.data[s+3]=o}},GR.prototype.getData=function(){return this.data},function(e){e.processBMP=function(t,n,r,i){var a=new GR(t,!1),o=a.width,s=a.height,c={data:a.getData(),width:o,height:s},l=new WR(100).encode(c,100);return e.processJPEG.call(this,l,n,r,i)}}(SL.API),KR.prototype.getData=function(){return this.data},function(e){e.processWEBP=function(t,n,r,i){var a=new KR(t),o=a.width,s=a.height,c={data:a.getData(),width:o,height:s},l=new WR(100).encode(c,100);return e.processJPEG.call(this,l,n,r,i)}}(SL.API),SL.API.processRGBA=function(e,t,n){for(var r=e.data,i=r.length,a=new Uint8Array(i/4*3),o=new Uint8Array(i/4),s=0,c=0,l=0;l<i;l+=4){var u=r[l],d=r[l+1],f=r[l+2],p=r[l+3];a[s++]=u,a[s++]=d,a[s++]=f,o[c++]=p}var m=this.__addimage__.arrayBufferToBinaryString(a);return{alpha:this.__addimage__.arrayBufferToBinaryString(o),data:m,index:t,alias:n,colorSpace:`DeviceRGB`,bitsPerComponent:8,width:e.width,height:e.height}},SL.API.setLanguage=function(e){return this.internal.languageSettings===void 0&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),{af:`Afrikaans`,sq:`Albanian`,ar:`Arabic (Standard)`,"ar-DZ":`Arabic (Algeria)`,"ar-BH":`Arabic (Bahrain)`,"ar-EG":`Arabic (Egypt)`,"ar-IQ":`Arabic (Iraq)`,"ar-JO":`Arabic (Jordan)`,"ar-KW":`Arabic (Kuwait)`,"ar-LB":`Arabic (Lebanon)`,"ar-LY":`Arabic (Libya)`,"ar-MA":`Arabic (Morocco)`,"ar-OM":`Arabic (Oman)`,"ar-QA":`Arabic (Qatar)`,"ar-SA":`Arabic (Saudi Arabia)`,"ar-SY":`Arabic (Syria)`,"ar-TN":`Arabic (Tunisia)`,"ar-AE":`Arabic (U.A.E.)`,"ar-YE":`Arabic (Yemen)`,an:`Aragonese`,hy:`Armenian`,as:`Assamese`,ast:`Asturian`,az:`Azerbaijani`,eu:`Basque`,be:`Belarusian`,bn:`Bengali`,bs:`Bosnian`,br:`Breton`,bg:`Bulgarian`,my:`Burmese`,ca:`Catalan`,ch:`Chamorro`,ce:`Chechen`,zh:`Chinese`,"zh-HK":`Chinese (Hong Kong)`,"zh-CN":`Chinese (PRC)`,"zh-SG":`Chinese (Singapore)`,"zh-TW":`Chinese (Taiwan)`,cv:`Chuvash`,co:`Corsican`,cr:`Cree`,hr:`Croatian`,cs:`Czech`,da:`Danish`,nl:`Dutch (Standard)`,"nl-BE":`Dutch (Belgian)`,en:`English`,"en-AU":`English (Australia)`,"en-BZ":`English (Belize)`,"en-CA":`English (Canada)`,"en-IE":`English (Ireland)`,"en-JM":`English (Jamaica)`,"en-NZ":`English (New Zealand)`,"en-PH":`English (Philippines)`,"en-ZA":`English (South Africa)`,"en-TT":`English (Trinidad & Tobago)`,"en-GB":`English (United Kingdom)`,"en-US":`English (United States)`,"en-ZW":`English (Zimbabwe)`,eo:`Esperanto`,et:`Estonian`,fo:`Faeroese`,fj:`Fijian`,fi:`Finnish`,fr:`French (Standard)`,"fr-BE":`French (Belgium)`,"fr-CA":`French (Canada)`,"fr-FR":`French (France)`,"fr-LU":`French (Luxembourg)`,"fr-MC":`French (Monaco)`,"fr-CH":`French (Switzerland)`,fy:`Frisian`,fur:`Friulian`,gd:`Gaelic (Scots)`,"gd-IE":`Gaelic (Irish)`,gl:`Galacian`,ka:`Georgian`,de:`German (Standard)`,"de-AT":`German (Austria)`,"de-DE":`German (Germany)`,"de-LI":`German (Liechtenstein)`,"de-LU":`German (Luxembourg)`,"de-CH":`German (Switzerland)`,el:`Greek`,gu:`Gujurati`,ht:`Haitian`,he:`Hebrew`,hi:`Hindi`,hu:`Hungarian`,is:`Icelandic`,id:`Indonesian`,iu:`Inuktitut`,ga:`Irish`,it:`Italian (Standard)`,"it-CH":`Italian (Switzerland)`,ja:`Japanese`,kn:`Kannada`,ks:`Kashmiri`,kk:`Kazakh`,km:`Khmer`,ky:`Kirghiz`,tlh:`Klingon`,ko:`Korean`,"ko-KP":`Korean (North Korea)`,"ko-KR":`Korean (South Korea)`,la:`Latin`,lv:`Latvian`,lt:`Lithuanian`,lb:`Luxembourgish`,mk:`North Macedonia`,ms:`Malay`,ml:`Malayalam`,mt:`Maltese`,mi:`Maori`,mr:`Marathi`,mo:`Moldavian`,nv:`Navajo`,ng:`Ndonga`,ne:`Nepali`,no:`Norwegian`,nb:`Norwegian (Bokmal)`,nn:`Norwegian (Nynorsk)`,oc:`Occitan`,or:`Oriya`,om:`Oromo`,fa:`Persian`,"fa-IR":`Persian/Iran`,pl:`Polish`,pt:`Portuguese`,"pt-BR":`Portuguese (Brazil)`,pa:`Punjabi`,"pa-IN":`Punjabi (India)`,"pa-PK":`Punjabi (Pakistan)`,qu:`Quechua`,rm:`Rhaeto-Romanic`,ro:`Romanian`,"ro-MO":`Romanian (Moldavia)`,ru:`Russian`,"ru-MO":`Russian (Moldavia)`,sz:`Sami (Lappish)`,sg:`Sango`,sa:`Sanskrit`,sc:`Sardinian`,sd:`Sindhi`,si:`Singhalese`,sr:`Serbian`,sk:`Slovak`,sl:`Slovenian`,so:`Somani`,sb:`Sorbian`,es:`Spanish`,"es-AR":`Spanish (Argentina)`,"es-BO":`Spanish (Bolivia)`,"es-CL":`Spanish (Chile)`,"es-CO":`Spanish (Colombia)`,"es-CR":`Spanish (Costa Rica)`,"es-DO":`Spanish (Dominican Republic)`,"es-EC":`Spanish (Ecuador)`,"es-SV":`Spanish (El Salvador)`,"es-GT":`Spanish (Guatemala)`,"es-HN":`Spanish (Honduras)`,"es-MX":`Spanish (Mexico)`,"es-NI":`Spanish (Nicaragua)`,"es-PA":`Spanish (Panama)`,"es-PY":`Spanish (Paraguay)`,"es-PE":`Spanish (Peru)`,"es-PR":`Spanish (Puerto Rico)`,"es-ES":`Spanish (Spain)`,"es-UY":`Spanish (Uruguay)`,"es-VE":`Spanish (Venezuela)`,sx:`Sutu`,sw:`Swahili`,sv:`Swedish`,"sv-FI":`Swedish (Finland)`,"sv-SV":`Swedish (Sweden)`,ta:`Tamil`,tt:`Tatar`,te:`Teluga`,th:`Thai`,tig:`Tigre`,ts:`Tsonga`,tn:`Tswana`,tr:`Turkish`,tk:`Turkmen`,uk:`Ukrainian`,hsb:`Upper Sorbian`,ur:`Urdu`,ve:`Venda`,vi:`Vietnamese`,vo:`Volapuk`,wa:`Walloon`,cy:`Welsh`,xh:`Xhosa`,ji:`Yiddish`,zu:`Zulu`}[e]!==void 0&&(this.internal.languageSettings.languageCode=e,!1===this.internal.languageSettings.isSubscribed&&(this.internal.events.subscribe(`putCatalog`,function(){this.internal.write(`/Lang (`+this.internal.languageSettings.languageCode+`)`)}),this.internal.languageSettings.isSubscribed=!0)),this},TR=SL.API,ER=TR.getCharWidthsArray=function(e,t){var n,r,i=(t||={}).font||this.internal.getFont(),a=t.fontSize||this.internal.getFontSize(),o=t.charSpace||this.internal.getCharSpace(),s=t.widths?t.widths:i.metadata.Unicode.widths,c=s.fof?s.fof:1,l=t.kerning?t.kerning:i.metadata.Unicode.kerning,u=l.fof?l.fof:1,d=!1!==t.doKerning,f=0,p=e.length,m=0,h=s[0]||c,g=[];for(n=0;n<p;n++)r=e.charCodeAt(n),typeof i.metadata.widthOfString==`function`?g.push((i.metadata.widthOfGlyph(i.metadata.characterToGlyph(r))+1e3/a*o||0)/1e3):(f=d&&Pi(l[r])===`object`&&!isNaN(parseInt(l[r][m],10))?l[r][m]/u:0,g.push((s[r]||h)/c+f)),m=r;return g},DR=TR.getStringUnitWidth=function(e,t){var n=(t||={}).fontSize||this.internal.getFontSize(),r=t.font||this.internal.getFont(),i=t.charSpace||this.internal.getCharSpace();return TR.processArabic&&(e=TR.processArabic(e)),typeof r.metadata.widthOfString==`function`?r.metadata.widthOfString(e,n,i)/n:ER.apply(this,arguments).reduce(function(e,t){return e+t},0)},OR=function(e,t,n,r){for(var i=[],a=0,o=e.length,s=0;a!==o&&s+t[a]<n;)s+=t[a],a++;i.push(e.slice(0,a));var c=a;for(s=0;a!==o;)s+t[a]>r&&(i.push(e.slice(c,a)),s=0,c=a),s+=t[a],a++;return c!==a&&i.push(e.slice(c,a)),i},kR=function(e,t,n){n||={};var r,i,a,o,s,c,l,u=[],d=[u],f=n.textIndent||0,p=0,m=0,h=e.split(` `),g=ER.apply(this,[` `,n])[0];if(c=n.lineIndent===-1?h[0].length+2:n.lineIndent||0){var _=Array(c).join(` `),v=[];h.map(function(e){(e=e.split(/\s*\n/)).length>1?v=v.concat(e.map(function(e,t){return(t&&e.length?`
`:``)+e})):v.push(e[0])}),h=v,c=DR.apply(this,[_,n])}for(a=0,o=h.length;a<o;a++){var y=0;if(r=h[a],c&&r[0]==`
`&&(r=r.substr(1),y=1),f+p+(m=(i=ER.apply(this,[r,n])).reduce(function(e,t){return e+t},0))>t||y){if(m>t){for(s=OR.apply(this,[r,i,t-(f+p),t]),u.push(s.shift()),u=[s.pop()];s.length;)d.push([s.shift()]);m=i.slice(r.length-(u[0]?u[0].length:0)).reduce(function(e,t){return e+t},0)}else u=[r];d.push(u),f=m+c,p=g}else u.push(r),f+=p+m,p=g}return l=c?function(e,t){return(t?_:``)+e.join(` `)}:function(e){return e.join(` `)},d.map(l)},TR.splitTextToSize=function(e,t,n){var r,i=(n||={}).fontSize||this.internal.getFontSize(),a=function(e){if(e.widths&&e.kerning)return{widths:e.widths,kerning:e.kerning};var t=this.internal.getFont(e.fontName,e.fontStyle),n=`Unicode`;return t.metadata[n]?{widths:t.metadata[n].widths||{0:1},kerning:t.metadata[n].kerning||{}}:{font:t.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,n);r=Array.isArray(e)?e:String(e).split(/\r?\n/);var o=1*this.internal.scaleFactor*t/i;a.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/i:0,a.lineIndent=n.lineIndent;var s,c,l=[];for(s=0,c=r.length;s<c;s++)l=l.concat(kR.apply(this,[r[s],o,a]));return l},function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t=`0123456789abcdef`,n=`klmnopqrstuvwxyz`,r={},i={},a=0;a<16;a++)r[n[a]]=t[a],i[t[a]]=n[a];var o=function(e){return`0x`+parseInt(e,10).toString(16)},s=e.__fontmetrics__.compress=function(e){var t,n,r,a,c=[`{`];for(var l in e){if(t=e[l],isNaN(parseInt(l,10))?n=`'`+l+`'`:(l=parseInt(l,10),n=(n=o(l).slice(2)).slice(0,-1)+i[n.slice(-1)]),typeof t==`number`)t<0?(r=o(t).slice(3),a=`-`):(r=o(t).slice(2),a=``),r=a+r.slice(0,-1)+i[r.slice(-1)];else{if(Pi(t)!==`object`)throw Error(`Don't know what to do with value type `+Pi(t)+`.`);r=s(t)}c.push(n+r)}return c.push(`}`),c.join(``)},c=e.__fontmetrics__.uncompress=function(e){if(typeof e!=`string`)throw Error(`Invalid argument passed to uncompress.`);for(var t,n,i,a,o={},s=1,c=o,l=[],u=``,d=``,f=e.length-1,p=1;p<f;p+=1)(a=e[p])==`'`?t?(i=t.join(``),t=void 0):t=[]:t?t.push(a):a==`{`?(l.push([c,i]),c={},i=void 0):a==`}`?((n=l.pop())[0][n[1]]=c,i=void 0,c=n[0]):a==`-`?s=-1:i===void 0?r.hasOwnProperty(a)?(u+=r[a],i=parseInt(u,16)*s,s=1,u=``):u+=a:r.hasOwnProperty(a)?(d+=r[a],c[i]=parseInt(d,16)*s,s=1,i=void 0,d=``):d+=a;return o},l={codePages:[`WinAnsiEncoding`],WinAnsiEncoding:c(`{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}`)},u={Unicode:{Courier:l,"Courier-Bold":l,"Courier-BoldOblique":l,"Courier-Oblique":l,Helvetica:l,"Helvetica-Bold":l,"Helvetica-BoldOblique":l,"Helvetica-Oblique":l,"Times-Roman":l,"Times-Bold":l,"Times-BoldItalic":l,"Times-Italic":l}},d={Unicode:{"Courier-Oblique":c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Times-BoldItalic":c(`{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}`),"Helvetica-Bold":c(`{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}`),Courier:c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Courier-BoldOblique":c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Times-Bold":c(`{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}`),Symbol:c(`{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}`),Helvetica:c(`{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}`),"Helvetica-BoldOblique":c(`{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}`),ZapfDingbats:c(`{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}`),"Courier-Bold":c(`{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}`),"Times-Italic":c(`{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}`),"Times-Roman":c(`{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}`),"Helvetica-Oblique":c(`{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}`)}};e.events.push([`addFont`,function(e){var t=e.font,n=d.Unicode[t.postScriptName];n&&(t.metadata.Unicode={},t.metadata.Unicode.widths=n.widths,t.metadata.Unicode.kerning=n.kerning);var r=u.Unicode[t.postScriptName];r&&(t.metadata.Unicode.encoding=r,t.encoding=r.codePages[0])}])}(SL.API),function(e){var t=function(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n};e.API.events.push([`addFont`,function(n){var r=void 0,i=n.font,a=n.instance;if(!i.isStandardFont){if(a===void 0)throw Error(`Font does not exist in vFS, import fonts or remove declaration doc.addFont('`+i.postScriptName+`').`);if(typeof(r=!1===a.existsFileInVFS(i.postScriptName)?a.loadFile(i.postScriptName):a.getFileFromVFS(i.postScriptName))!=`string`)throw Error(`Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('`+i.postScriptName+`').`);(function(n,r){r=/^\x00\x01\x00\x00/.test(r)?t(r):t(ZI(r)),n.metadata=e.API.TTFFont.open(r),n.metadata.Unicode=n.metadata.Unicode||{encoding:{},kerning:{},widths:[]},n.metadata.glyIdsUsed=[0]})(i,r)}}])}(SL),SL.API.addSvgAsImage=function(e,t,n,r,i,a,o,s){if(isNaN(t)||isNaN(n))throw GI.error(`jsPDF.addSvgAsImage: Invalid coordinates`,arguments),Error(`Invalid coordinates passed to jsPDF.addSvgAsImage`);if(isNaN(r)||isNaN(i))throw GI.error(`jsPDF.addSvgAsImage: Invalid measurements`,arguments),Error(`Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage`);var c=document.createElement(`canvas`);c.width=r,c.height=i;var l=c.getContext(`2d`);l.fillStyle=`#fff`,l.fillRect(0,0,c.width,c.height);var u={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},d=this;return(UI.canvg?Promise.resolve(UI.canvg):ht(()=>import(`./index.es-Ckt5H9Kz.js`),__vite__mapDeps([2,1,3,4,5]))).catch(function(e){return Promise.reject(Error(`Could not load canvg: `+e))}).then(function(e){return e.default?e.default:e}).then(function(t){return t.fromString(l,e,u)},function(){return Promise.reject(Error(`Could not load canvg.`))}).then(function(e){return e.render(u)}).then(function(){d.addImage(c.toDataURL(`image/jpeg`,1),t,n,r,i,o,s)})},SL.API.putTotalPages=function(e){var t,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,`g`),n=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),`g`),n=this.pdfEscape16(this.internal.getNumberOfPages()+``,this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var i=0;i<this.internal.pages[r].length;i++)this.internal.pages[r][i]=this.internal.pages[r][i].replace(t,n);return this},SL.API.viewerPreferences=function(e,t){var n;e||={},t||=!1;var r,i,a,o={HideToolbar:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:`UseNone`,value:`UseNone`,type:`name`,explicitSet:!1,valueSet:[`UseNone`,`UseOutlines`,`UseThumbs`,`UseOC`],pdfVersion:1.3},Direction:{defaultValue:`L2R`,value:`L2R`,type:`name`,explicitSet:!1,valueSet:[`L2R`,`R2L`],pdfVersion:1.3},ViewArea:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},ViewClip:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},PrintArea:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},PrintClip:{defaultValue:`CropBox`,value:`CropBox`,type:`name`,explicitSet:!1,valueSet:[`MediaBox`,`CropBox`,`TrimBox`,`BleedBox`,`ArtBox`],pdfVersion:1.4},PrintScaling:{defaultValue:`AppDefault`,value:`AppDefault`,type:`name`,explicitSet:!1,valueSet:[`AppDefault`,`None`],pdfVersion:1.6},Duplex:{defaultValue:``,value:`none`,type:`name`,explicitSet:!1,valueSet:[`Simplex`,`DuplexFlipShortEdge`,`DuplexFlipLongEdge`,`none`],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:`boolean`,explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:``,value:``,type:`array`,explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:`integer`,explicitSet:!1,valueSet:null,pdfVersion:1.7}},s=Object.keys(o),c=[],l=0,u=0,d=0;function f(e,t){var n,r=!1;for(n=0;n<e.length;n+=1)e[n]===t&&(r=!0);return r}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,e===`reset`||!0===t){var p=s.length;for(d=0;d<p;d+=1)n[s[d]].value=n[s[d]].defaultValue,n[s[d]].explicitSet=!1}if(Pi(e)===`object`){for(i in e)if(a=e[i],f(s,i)&&a!==void 0){if(n[i].type===`boolean`&&typeof a==`boolean`)n[i].value=a;else if(n[i].type===`name`&&f(n[i].valueSet,a))n[i].value=a;else if(n[i].type===`integer`&&Number.isInteger(a))n[i].value=a;else if(n[i].type===`array`){for(l=0;l<a.length;l+=1)if(r=!0,a[l].length===1&&typeof a[l][0]==`number`)c.push(String(a[l]-1));else if(a[l].length>1){for(u=0;u<a[l].length;u+=1)typeof a[l][u]!=`number`&&(r=!1);!0===r&&c.push([a[l][0]-1,a[l][1]-1].join(` `))}n[i].value=`[`+c.join(` `)+`]`}else n[i].value=n[i].defaultValue;n[i].explicitSet=!0}}return!1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe(`putCatalog`,function(){var e,t=[];for(e in n)!0===n[e].explicitSet&&(n[e].type===`name`?t.push(`/`+e+` /`+n[e].value):t.push(`/`+e+` `+n[e].value));t.length!==0&&this.internal.write(`/ViewerPreferences
<<
`+t.join(`
`)+`
>>`)}),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},SL.API.addMetadata=function(e,t){return this.internal.__metadata__===void 0&&(this.internal.__metadata__={metadata:e,namespaceUri:t??`http://jspdf.default.namespaceuri/`,rawXml:typeof t==`boolean`&&t},this.internal.events.subscribe(`putCatalog`,JR),this.internal.events.subscribe(`postPutResources`,qR)),this},function(e){var t=e.API,n=t.pdfEscape16=function(e,t){for(var n,r=t.metadata.Unicode.widths,i=[``,`0`,`00`,`000`,`0000`],a=[``],o=0,s=e.length;o<s;++o){if(n=t.metadata.characterToGlyph(e.charCodeAt(o)),t.metadata.glyIdsUsed.push(n),t.metadata.toUnicode[n]=e.charCodeAt(o),r.indexOf(n)==-1&&(r.push(n),r.push([parseInt(t.metadata.widthOfGlyph(n),10)])),n==`0`)return a.join(``);n=n.toString(16),a.push(i[4-n.length],n)}return a.join(``)},r=function(e){var t,n,r,i,a,o,s;for(a=`/CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (UCS)
/Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000><ffff>
endcodespacerange`,r=[],o=0,s=(n=Object.keys(e).sort(function(e,t){return e-t})).length;o<s;o++)t=n[o],r.length>=100&&(a+=`
`+r.length+` beginbfchar
`+r.join(`
`)+`
endbfchar`,r=[]),e[t]!==void 0&&e[t]!==null&&typeof e[t].toString==`function`&&(i=(`0000`+e[t].toString(16)).slice(-4),t=(`0000`+(+t).toString(16)).slice(-4),r.push(`<`+t+`><`+i+`>`));return r.length&&(a+=`
`+r.length+` beginbfchar
`+r.join(`
`)+`
endbfchar
`),a+`endcmap
CMapName currentdict /CMap defineresource pop
end
end`};t.events.push([`putFont`,function(t){(function(t){var n=t.font,i=t.out,a=t.newObject,o=t.putStream;if(n.metadata instanceof e.API.TTFFont&&n.encoding===`Identity-H`){for(var s=n.metadata.Unicode.widths,c=n.metadata.subset.encode(n.metadata.glyIdsUsed,1),l=``,u=0;u<c.length;u++)l+=String.fromCharCode(c[u]);var d=a();o({data:l,addLength1:!0,objectId:d}),i(`endobj`);var f=a();o({data:r(n.metadata.toUnicode),addLength1:!0,objectId:f}),i(`endobj`);var p=a();i(`<<`),i(`/Type /FontDescriptor`),i(`/FontName /`+gL(n.fontName)),i(`/FontFile2 `+d+` 0 R`),i(`/FontBBox `+e.API.PDFObject.convert(n.metadata.bbox)),i(`/Flags `+n.metadata.flags),i(`/StemV `+n.metadata.stemV),i(`/ItalicAngle `+n.metadata.italicAngle),i(`/Ascent `+n.metadata.ascender),i(`/Descent `+n.metadata.decender),i(`/CapHeight `+n.metadata.capHeight),i(`>>`),i(`endobj`);var m=a();i(`<<`),i(`/Type /Font`),i(`/BaseFont /`+gL(n.fontName)),i(`/FontDescriptor `+p+` 0 R`),i(`/W `+e.API.PDFObject.convert(s)),i(`/CIDToGIDMap /Identity`),i(`/DW 1000`),i(`/Subtype /CIDFontType2`),i(`/CIDSystemInfo`),i(`<<`),i(`/Supplement 0`),i(`/Registry (Adobe)`),i(`/Ordering (`+n.encoding+`)`),i(`>>`),i(`>>`),i(`endobj`),n.objectNumber=a(),i(`<<`),i(`/Type /Font`),i(`/Subtype /Type0`),i(`/ToUnicode `+f+` 0 R`),i(`/BaseFont /`+gL(n.fontName)),i(`/Encoding /`+n.encoding),i(`/DescendantFonts [`+m+` 0 R]`),i(`>>`),i(`endobj`),n.isAlreadyPutted=!0}})(t)}]),t.events.push([`putFont`,function(t){(function(t){var n=t.font,i=t.out,a=t.newObject,o=t.putStream;if(n.metadata instanceof e.API.TTFFont&&n.encoding===`WinAnsiEncoding`){for(var s=n.metadata.rawData,c=``,l=0;l<s.length;l++)c+=String.fromCharCode(s[l]);var u=a();o({data:c,addLength1:!0,objectId:u}),i(`endobj`);var d=a();o({data:r(n.metadata.toUnicode),addLength1:!0,objectId:d}),i(`endobj`);var f=a();i(`<<`),i(`/Descent `+n.metadata.decender),i(`/CapHeight `+n.metadata.capHeight),i(`/StemV `+n.metadata.stemV),i(`/Type /FontDescriptor`),i(`/FontFile2 `+u+` 0 R`),i(`/Flags 96`),i(`/FontBBox `+e.API.PDFObject.convert(n.metadata.bbox)),i(`/FontName /`+gL(n.fontName)),i(`/ItalicAngle `+n.metadata.italicAngle),i(`/Ascent `+n.metadata.ascender),i(`>>`),i(`endobj`),n.objectNumber=a();for(var p=0;p<n.metadata.hmtx.widths.length;p++)n.metadata.hmtx.widths[p]=parseInt(n.metadata.hmtx.widths[p]*(1e3/n.metadata.head.unitsPerEm));i(`<</Subtype/TrueType/Type/Font/ToUnicode `+d+` 0 R/BaseFont/`+gL(n.fontName)+`/FontDescriptor `+f+` 0 R/Encoding/`+n.encoding+` /FirstChar 29 /LastChar 255 /Widths `+e.API.PDFObject.convert(n.metadata.hmtx.widths)+`>>`),i(`endobj`),n.isAlreadyPutted=!0}})(t)}]);var i=function(e){var t,r=e.text||``,i=e.x,a=e.y,o=e.options||{},s=e.mutex||{},c=s.pdfEscape,l=s.activeFontKey,u=s.fonts,d=l,f=``,p=0,m=``,h=u[d].encoding;if(u[d].encoding!==`Identity-H`)return{text:r,x:i,y:a,options:o,mutex:s};for(m=r,d=l,Array.isArray(r)&&(m=r[0]),p=0;p<m.length;p+=1)u[d].metadata.hasOwnProperty(`cmap`)&&(t=u[d].metadata.cmap.unicode.codeMap[m[p].charCodeAt(0)]),t||m[p].charCodeAt(0)<256&&u[d].metadata.hasOwnProperty(`Unicode`)?f+=m[p]:f+=``;var g=``;return parseInt(d.slice(1))<14||h===`WinAnsiEncoding`?g=c(f,d).split(``).map(function(e){return e.charCodeAt(0).toString(16)}).join(``):h===`Identity-H`&&(g=n(f,u[d])),s.isHex=!0,{text:g,x:i,y:a,options:o,mutex:s}};t.events.push([`postProcessText`,function(e){var t=e.text||``,n=[],r={text:t,x:e.x,y:e.y,options:e.options,mutex:e.mutex};if(Array.isArray(t)){var a=0;for(a=0;a<t.length;a+=1)Array.isArray(t[a])&&t[a].length===3?n.push([i(Object.assign({},r,{text:t[a][0]})).text,t[a][1],t[a][2]]):n.push(i(Object.assign({},r,{text:t[a]})).text);e.text=n}else e.text=i(Object.assign({},r,{text:t})).text}])}(SL),function(e){var t=function(){return this.internal.vFS===void 0&&(this.internal.vFS={}),!0};e.existsFileInVFS=function(e){return t.call(this),this.internal.vFS[e]!==void 0},e.addFileToVFS=function(e,n){return t.call(this),this.internal.vFS[e]=n,this},e.getFileFromVFS=function(e){return t.call(this),this.internal.vFS[e]===void 0?null:this.internal.vFS[e]}}(SL.API),function(e){e.__bidiEngine__=e.prototype.__bidiEngine__=function(e){var n,r,i,a,o,s,c,l=t,u=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],d=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],f={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},p={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},m=`(.).(.<.>.<.[.].[.{.}.{.«.».«.‹.›.‹.⁅.⁆.⁅.⁽.⁾.⁽.₍.₎.₍.≤.≥.≤.〈.〉.〈.﹙.﹚.﹙.﹛.﹜.﹛.﹝.﹞.﹝.﹤.﹥.﹤`.split(`.`),h=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),g=!1,_=0;this.__bidiEngine__={};var v=function(e){var t=e.charCodeAt(),n=t>>8,r=p[n];return r===void 0?n===252||n===253?`AL`:h.test(n)?`L`:n===8?`R`:`N`:l[256*r+(255&t)]},y=function(e){for(var t,n=0;n<e.length;n++){if((t=v(e.charAt(n)))===`L`)return!1;if(t===`R`)return!0}return!1},b=function(e,t,o,s){var c,l,u,d,f=t[s];switch(f){case`L`:case`R`:case`LRE`:case`RLE`:case`LRO`:case`RLO`:case`PDF`:g=!1;break;case`N`:case`AN`:break;case`EN`:g&&(f=`AN`);break;case`AL`:g=!0,f=`R`;break;case`WS`:case`BN`:f=`N`;break;case`CS`:s<1||s+1>=t.length||(c=o[s-1])!==`EN`&&c!==`AN`||(l=t[s+1])!==`EN`&&l!==`AN`?f=`N`:g&&(l=`AN`),f=l===c?l:`N`;break;case`ES`:f=(c=s>0?o[s-1]:`B`)===`EN`&&s+1<t.length&&t[s+1]===`EN`?`EN`:`N`;break;case`ET`:if(s>0&&o[s-1]===`EN`){f=`EN`;break}if(g){f=`N`;break}for(u=s+1,d=t.length;u<d&&t[u]===`ET`;)u++;f=u<d&&t[u]===`EN`?`EN`:`N`;break;case`NSM`:if(i&&!a){for(d=t.length,u=s+1;u<d&&t[u]===`NSM`;)u++;if(u<d){var p=e[s],m=p>=1425&&p<=2303||p===64286;if(c=t[u],m&&(c===`R`||c===`AL`)){f=`R`;break}}}f=s<1||(c=t[s-1])===`B`?`N`:o[s-1];break;case`B`:g=!1,n=!0,f=_;break;case`S`:r=!0,f=`N`}return f},x=function(e,t,n){var r=e.split(``);return n&&S(r,n,{hiLevel:_}),r.reverse(),t&&t.reverse(),r.join(``)},S=function(e,t,i){var a,o,s,c,l,p=-1,m=e.length,h=0,y=[],x=_?d:u,S=[];for(g=!1,n=!1,r=!1,o=0;o<m;o++)S[o]=v(e[o]);for(s=0;s<m;s++){if(l=h,y[s]=b(e,S,y,s),a=240&(h=x[l][f[y[s]]]),h&=15,t[s]=c=x[h][5],a>0){if(a===16){for(o=p;o<s;o++)t[o]=1;p=-1}else p=-1}if(x[h][6])p===-1&&(p=s);else if(p>-1){for(o=p;o<s;o++)t[o]=c;p=-1}S[s]===`B`&&(t[s]=0),i.hiLevel|=c}r&&function(e,t,n){for(var r=0;r<n;r++)if(e[r]===`S`){t[r]=_;for(var i=r-1;i>=0&&e[i]===`WS`;i--)t[i]=_}}(S,t,m)},C=function(e,t,r,i,a){if(!(a.hiLevel<e)){if(e===1&&_===1&&!n)return t.reverse(),void(r&&r.reverse());for(var o,s,c,l,u=t.length,d=0;d<u;){if(i[d]>=e){for(c=d+1;c<u&&i[c]>=e;)c++;for(l=d,s=c-1;l<s;l++,s--)o=t[l],t[l]=t[s],t[s]=o,r&&(o=r[l],r[l]=r[s],r[s]=o);d=c}d++}}},w=function(e,t,n){var r=e.split(``),i={hiLevel:_};return n||=[],S(r,n,i),function(e,t,n){if(n.hiLevel!==0&&c)for(var r,i=0;i<e.length;i++)t[i]===1&&(r=m.indexOf(e[i]))>=0&&(e[i]=m[r+1])}(r,n,i),C(2,r,t,n,i),C(1,r,t,n,i),r.join(``)};return this.__bidiEngine__.doBidiReorder=function(e,t,n){if(function(e,t){if(t)for(var n=0;n<e.length;n++)t[n]=n;a===void 0&&(a=y(e)),s===void 0&&(s=y(e))}(e,t),i||!o||s){if(i&&o&&a^s)_=+!!a,e=x(e,t,n);else if(!i&&o&&s)_=+!!a,e=w(e,t,n),e=x(e,t);else if(!i||a||o||s){if(i&&!o&&a^s)e=x(e,t),a?(_=0,e=w(e,t,n)):(_=1,e=w(e,t,n),e=x(e,t));else if(i&&a&&!o&&s)_=1,e=w(e,t,n),e=x(e,t);else if(!i&&!o&&a^s){var r=c;a?(_=1,e=w(e,t,n),_=0,c=!1,e=w(e,t,n),c=r):(_=0,e=w(e,t,n),e=x(e,t),_=1,c=!1,e=w(e,t,n),c=r,e=x(e,t))}}else _=0,e=w(e,t,n)}else _=+!!a,e=w(e,t,n);return e},this.__bidiEngine__.setOptions=function(e){e&&(i=e.isInputVisual,o=e.isOutputVisual,a=e.isInputRtl,s=e.isOutputRtl,c=e.isSymmetricSwapping)},this.__bidiEngine__.setOptions(e),this.__bidiEngine__};var t=`BN.BN.BN.BN.BN.BN.BN.BN.BN.S.B.S.WS.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.B.B.B.S.WS.N.N.ET.ET.ET.N.N.N.N.N.ES.CS.ES.CS.CS.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.CS.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.BN.BN.BN.BN.BN.BN.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.CS.N.ET.ET.ET.ET.N.N.N.N.L.N.N.BN.N.N.ET.ET.EN.EN.N.L.N.N.N.EN.L.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.L.L.L.L.L.L.L.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.L.N.N.N.N.N.ET.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.R.NSM.R.NSM.NSM.R.NSM.NSM.R.NSM.N.N.N.N.N.N.N.N.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.N.N.N.N.N.R.R.R.R.R.N.N.N.N.N.N.N.N.N.N.N.AN.AN.AN.AN.AN.AN.N.N.AL.ET.ET.AL.CS.AL.N.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AN.AN.AN.AN.AN.AN.AN.AN.AN.AN.ET.AN.AN.AL.AL.AL.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AN.N.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.NSM.NSM.N.NSM.NSM.NSM.NSM.AL.AL.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.N.AL.AL.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AL.N.N.N.N.N.N.N.N.N.N.N.N.N.N.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.R.R.N.N.N.N.R.N.N.N.N.N.WS.WS.WS.WS.WS.WS.WS.WS.WS.WS.WS.BN.BN.BN.L.R.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.WS.B.LRE.RLE.PDF.LRO.RLO.CS.ET.ET.ET.ET.ET.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.CS.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.WS.BN.BN.BN.BN.BN.N.LRI.RLI.FSI.PDI.BN.BN.BN.BN.BN.BN.EN.L.N.N.EN.EN.EN.EN.EN.EN.ES.ES.N.N.N.L.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.ES.ES.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.ET.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.L.L.L.L.L.L.L.N.N.N.N.N.N.N.N.N.N.N.N.L.L.L.L.L.N.N.N.N.N.R.NSM.R.R.R.R.R.R.R.R.R.R.ES.R.R.R.R.R.R.R.R.R.R.R.R.R.N.R.R.R.R.R.N.R.N.R.R.N.R.R.N.R.R.R.R.R.R.R.R.R.R.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.CS.N.CS.N.N.CS.N.N.N.N.N.N.N.N.N.ET.N.N.ES.ES.N.N.N.N.N.ET.ET.N.N.N.N.N.AL.AL.AL.AL.AL.N.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.N.N.BN.N.N.N.ET.ET.ET.N.N.N.N.N.ES.CS.ES.CS.CS.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.CS.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.N.N.N.N.N.N.N.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.N.N.L.L.L.L.L.L.N.N.L.L.L.L.L.L.N.N.L.L.L.L.L.L.N.N.L.L.L.N.N.N.ET.ET.N.N.N.ET.ET.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N`.split(`.`),n=new e.__bidiEngine__({isInputVisual:!0});e.API.events.push([`postProcessText`,function(e){var t=e.text;e.x,e.y;var r=e.options||{};e.mutex,r.lang;var i=[];if(r.isInputVisual=typeof r.isInputVisual!=`boolean`||r.isInputVisual,n.setOptions(r),Object.prototype.toString.call(t)===`[object Array]`){var a=0;for(i=[],a=0;a<t.length;a+=1)Object.prototype.toString.call(t[a])===`[object Array]`?i.push([n.doBidiReorder(t[a][0]),t[a][1],t[a][2]]):i.push([n.doBidiReorder(t[a])]);e.text=i}else e.text=n.doBidiReorder(t);n.setOptions({isInputVisual:!0})}])}(SL),SL.API.TTFFont=function(){function e(e){var t;if(this.rawData=e,t=this.contents=new XR(e),this.contents.pos=4,t.readString(4)===`ttcf`)throw Error(`TTCF not supported.`);t.pos=0,this.parse(),this.subset=new hz(this),this.registerTTF()}return e.open=function(t){return new e(t)},e.prototype.parse=function(){return this.directory=new ZR(this.contents),this.head=new ez(this),this.name=new sz(this),this.cmap=new nz(this),this.toUnicode={},this.hhea=new rz(this),this.maxp=new cz(this),this.hmtx=new lz(this),this.post=new az(this),this.os2=new iz(this),this.loca=new mz(this),this.glyf=new dz(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},e.prototype.registerTTF=function(){var e,t,n,r,i;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=function(){var t,n,r,i;for(i=[],t=0,n=(r=this.bbox).length;t<n;t++)e=r[t],i.push(Math.round(e*this.scaleFactor));return i}.call(this),this.stemV=0,this.post.exists?(n=255&(r=this.post.italic_angle),32768&(t=r>>16)&&(t=-(1+(65535^t))),this.italicAngle=+(t+`.`+n)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=(i=this.familyClass)===1||i===2||i===3||i===4||i===5||i===7,this.isScript=this.familyClass===10,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),this.italicAngle!==0&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw Error(`No unicode cmap for font`)},e.prototype.characterToGlyph=function(e){return this.cmap.unicode?.codeMap[e]||0},e.prototype.widthOfGlyph=function(e){var t;return t=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(e).advance*t},e.prototype.widthOfString=function(e,t,n){var r,i,a,o;for(a=0,i=0,o=(e=``+e).length;0<=o?i<o:i>o;i=0<=o?++i:--i)r=e.charCodeAt(i),a+=this.widthOfGlyph(this.characterToGlyph(r))+1e3/t*n||0;return t/1e3*a},e.prototype.lineHeight=function(e,t){var n;return t??=!1,n=t?this.lineGap:0,(this.ascender+n-this.decender)/1e3*e},e}();var YR,XR=function(){function e(e){this.data=e??[],this.pos=0,this.length=this.data.length}return e.prototype.readByte=function(){return this.data[this.pos++]},e.prototype.writeByte=function(e){return this.data[this.pos++]=e},e.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},e.prototype.writeUInt32=function(e){return this.writeByte(e>>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e)},e.prototype.readInt32=function(){var e;return(e=this.readUInt32())>=2147483648?e-4294967296:e},e.prototype.writeInt32=function(e){return e<0&&(e+=4294967296),this.writeUInt32(e)},e.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},e.prototype.writeUInt16=function(e){return this.writeByte(e>>8&255),this.writeByte(255&e)},e.prototype.readInt16=function(){var e;return(e=this.readUInt16())>=32768?e-65536:e},e.prototype.writeInt16=function(e){return e<0&&(e+=65536),this.writeUInt16(e)},e.prototype.readString=function(e){var t,n;for(n=[],t=0;0<=e?t<e:t>e;t=0<=e?++t:--t)n[t]=String.fromCharCode(this.readByte());return n.join(``)},e.prototype.writeString=function(e){var t,n,r;for(r=[],t=0,n=e.length;0<=n?t<n:t>n;t=0<=n?++t:--t)r.push(this.writeByte(e.charCodeAt(t)));return r},e.prototype.readShort=function(){return this.readInt16()},e.prototype.writeShort=function(e){return this.writeInt16(e)},e.prototype.readLongLong=function(){var e,t,n,r,i,a,o,s;return e=this.readByte(),t=this.readByte(),n=this.readByte(),r=this.readByte(),i=this.readByte(),a=this.readByte(),o=this.readByte(),s=this.readByte(),128&e?-1*(72057594037927940*(255^e)+281474976710656*(255^t)+1099511627776*(255^n)+4294967296*(255^r)+16777216*(255^i)+65536*(255^a)+256*(255^o)+(255^s)+1):72057594037927940*e+281474976710656*t+1099511627776*n+4294967296*r+16777216*i+65536*a+256*o+s},e.prototype.writeLongLong=function(e){var t,n;return t=Math.floor(e/4294967296),n=4294967295&e,this.writeByte(t>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t),this.writeByte(n>>24&255),this.writeByte(n>>16&255),this.writeByte(n>>8&255),this.writeByte(255&n)},e.prototype.readInt=function(){return this.readInt32()},e.prototype.writeInt=function(e){return this.writeInt32(e)},e.prototype.read=function(e){var t,n;for(t=[],n=0;0<=e?n<e:n>e;n=0<=e?++n:--n)t.push(this.readByte());return t},e.prototype.write=function(e){var t,n,r,i;for(i=[],n=0,r=e.length;n<r;n++)t=e[n],i.push(this.writeByte(t));return i},e}(),ZR=function(){var e;function t(e){var t,n,r;for(this.scalarType=e.readInt(),this.tableCount=e.readShort(),this.searchRange=e.readShort(),this.entrySelector=e.readShort(),this.rangeShift=e.readShort(),this.tables={},n=0,r=this.tableCount;0<=r?n<r:n>r;n=0<=r?++n:--n)t={tag:e.readString(4),checksum:e.readInt(),offset:e.readInt(),length:e.readInt()},this.tables[t.tag]=t}return t.prototype.encode=function(t){var n,r,i,a,o,s,c,l,u,d,f,p,m;for(m in f=Object.keys(t).length,s=Math.log(2),u=16*Math.floor(Math.log(f)/s),a=Math.floor(u/s),l=16*f-u,(r=new XR).writeInt(this.scalarType),r.writeShort(f),r.writeShort(u),r.writeShort(a),r.writeShort(l),i=16*f,c=r.pos+i,o=null,p=[],t)for(d=t[m],r.writeString(m),r.writeInt(e(d)),r.writeInt(c),r.writeInt(d.length),p=p.concat(d),m===`head`&&(o=c),c+=d.length;c%4;)p.push(0),c++;return r.write(p),n=2981146554-e(r.data),r.pos=o+8,r.writeUInt32(n),r.data},e=function(e){var t,n,r,i;for(e=uz.call(e);e.length%4;)e.push(0);for(r=new XR(e),n=0,t=0,i=e.length;t<i;t=t+=4)n+=r.readUInt32();return 4294967295&n},t}(),QR={}.hasOwnProperty,$R=function(e,t){for(var n in t)QR.call(t,n)&&(e[n]=t[n]);function r(){this.constructor=e}return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};YR=function(){function e(e){var t;this.file=e,t=this.file.directory.tables[this.tag],this.exists=!!t,t&&(this.offset=t.offset,this.length=t.length,this.parse(this.file.contents))}return e.prototype.parse=function(){},e.prototype.encode=function(){},e.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},e}();var ez=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`head`,e.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.revision=e.readInt(),this.checkSumAdjustment=e.readInt(),this.magicNumber=e.readInt(),this.flags=e.readShort(),this.unitsPerEm=e.readShort(),this.created=e.readLongLong(),this.modified=e.readLongLong(),this.xMin=e.readShort(),this.yMin=e.readShort(),this.xMax=e.readShort(),this.yMax=e.readShort(),this.macStyle=e.readShort(),this.lowestRecPPEM=e.readShort(),this.fontDirectionHint=e.readShort(),this.indexToLocFormat=e.readShort(),this.glyphDataFormat=e.readShort()},e.prototype.encode=function(e){var t;return(t=new XR).writeInt(this.version),t.writeInt(this.revision),t.writeInt(this.checkSumAdjustment),t.writeInt(this.magicNumber),t.writeShort(this.flags),t.writeShort(this.unitsPerEm),t.writeLongLong(this.created),t.writeLongLong(this.modified),t.writeShort(this.xMin),t.writeShort(this.yMin),t.writeShort(this.xMax),t.writeShort(this.yMax),t.writeShort(this.macStyle),t.writeShort(this.lowestRecPPEM),t.writeShort(this.fontDirectionHint),t.writeShort(e),t.writeShort(this.glyphDataFormat),t.data},e}(),tz=function(){function e(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v;switch(this.platformID=e.readUInt16(),this.encodingID=e.readShort(),this.offset=t+e.readInt(),u=e.pos,e.pos=this.offset,this.format=e.readUInt16(),this.length=e.readUInt16(),this.language=e.readUInt16(),this.isUnicode=this.platformID===3&&this.encodingID===1&&this.format===4||this.platformID===0&&this.format===4,this.codeMap={},this.format){case 0:for(s=0;s<256;++s)this.codeMap[s]=e.readByte();break;case 4:for(f=e.readUInt16(),d=f/2,e.pos+=6,i=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),e.pos+=2,m=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),c=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),l=function(){var t,n;for(n=[],s=t=0;0<=d?t<d:t>d;s=0<=d?++t:--t)n.push(e.readUInt16());return n}(),r=(this.length-e.pos+this.offset)/2,o=function(){var t,n;for(n=[],s=t=0;0<=r?t<r:t>r;s=0<=r?++t:--t)n.push(e.readUInt16());return n}(),s=g=0,v=i.length;g<v;s=++g)for(h=i[s],n=_=p=m[s];p<=h?_<=h:_>=h;n=p<=h?++_:--_)l[s]===0?a=n+c[s]:(a=o[l[s]/2+(n-p)-(d-s)]||0)!==0&&(a+=c[s]),this.codeMap[n]=65535&a}e.pos=u}return e.encode=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z,B,V,ee,te,ne,re,H,ie;switch(k=new XR,a=Object.keys(e).sort(function(e,t){return e-t}),t){case`macroman`:for(m=0,h=function(){var e=[];for(p=0;p<256;++p)e.push(0);return e}(),_={0:0},i={},A=0,P=a.length;A<P;A++)_[ne=e[r=a[A]]]??(_[ne]=++m),i[r]={old:e[r],new:_[e[r]]},h[r]=_[e[r]];return k.writeUInt16(1),k.writeUInt16(0),k.writeUInt32(12),k.writeUInt16(0),k.writeUInt16(262),k.writeUInt16(0),k.write(h),{charMap:i,subtable:k.data,maxGlyphID:m+1};case`unicode`:for(D=[],u=[],v=0,_={},n={},g=c=null,j=0,F=a.length;j<F;j++)_[b=e[r=a[j]]]??(_[b]=++v),n[r]={old:b,new:_[b]},o=_[b]-r,g!=null&&o===c||(g&&u.push(g),D.push(r),c=o),g=r;for(g&&u.push(g),u.push(65535),D.push(65535),T=2*(w=D.length),C=2*(Math.log(w)/Math.LN2)**2,d=Math.log(C/2)/Math.LN2,S=2*w-C,s=[],x=[],f=[],p=M=0,I=D.length;M<I;p=++M){if(E=D[p],l=u[p],E===65535){s.push(0),x.push(0);break}if(E-(O=n[E].new)>=32768)for(s.push(0),x.push(2*(f.length+w-p)),r=N=E;E<=l?N<=l:N>=l;r=E<=l?++N:--N)f.push(n[r].new);else s.push(O-E),x.push(0)}for(k.writeUInt16(3),k.writeUInt16(1),k.writeUInt32(12),k.writeUInt16(4),k.writeUInt16(16+8*w+2*f.length),k.writeUInt16(0),k.writeUInt16(T),k.writeUInt16(C),k.writeUInt16(d),k.writeUInt16(S),ee=0,L=u.length;ee<L;ee++)r=u[ee],k.writeUInt16(r);for(k.writeUInt16(0),te=0,R=D.length;te<R;te++)r=D[te],k.writeUInt16(r);for(re=0,z=s.length;re<z;re++)o=s[re],k.writeUInt16(o);for(H=0,B=x.length;H<B;H++)y=x[H],k.writeUInt16(y);for(ie=0,V=f.length;ie<V;ie++)m=f[ie],k.writeUInt16(m);return{charMap:n,subtable:k.data,maxGlyphID:v+1}}},e}(),nz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`cmap`,e.prototype.parse=function(e){var t,n,r;for(e.pos=this.offset,this.version=e.readUInt16(),r=e.readUInt16(),this.tables=[],this.unicode=null,n=0;0<=r?n<r:n>r;n=0<=r?++n:--n)t=new tz(e,this.offset),this.tables.push(t),t.isUnicode&&this.unicode==null&&(this.unicode=t);return!0},e.encode=function(e,t){var n,r;return t??=`macroman`,n=tz.encode(e,t),(r=new XR).writeUInt16(0),r.writeUInt16(1),n.table=r.data.concat(n.subtable),n},e}(),rz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`hhea`,e.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.ascender=e.readShort(),this.decender=e.readShort(),this.lineGap=e.readShort(),this.advanceWidthMax=e.readShort(),this.minLeftSideBearing=e.readShort(),this.minRightSideBearing=e.readShort(),this.xMaxExtent=e.readShort(),this.caretSlopeRise=e.readShort(),this.caretSlopeRun=e.readShort(),this.caretOffset=e.readShort(),e.pos+=8,this.metricDataFormat=e.readShort(),this.numberOfMetrics=e.readUInt16()},e}(),iz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`OS/2`,e.prototype.parse=function(e){if(e.pos=this.offset,this.version=e.readUInt16(),this.averageCharWidth=e.readShort(),this.weightClass=e.readUInt16(),this.widthClass=e.readUInt16(),this.type=e.readShort(),this.ySubscriptXSize=e.readShort(),this.ySubscriptYSize=e.readShort(),this.ySubscriptXOffset=e.readShort(),this.ySubscriptYOffset=e.readShort(),this.ySuperscriptXSize=e.readShort(),this.ySuperscriptYSize=e.readShort(),this.ySuperscriptXOffset=e.readShort(),this.ySuperscriptYOffset=e.readShort(),this.yStrikeoutSize=e.readShort(),this.yStrikeoutPosition=e.readShort(),this.familyClass=e.readShort(),this.panose=function(){var t,n;for(n=[],t=0;t<10;++t)n.push(e.readByte());return n}(),this.charRange=function(){var t,n;for(n=[],t=0;t<4;++t)n.push(e.readInt());return n}(),this.vendorID=e.readString(4),this.selection=e.readShort(),this.firstCharIndex=e.readShort(),this.lastCharIndex=e.readShort(),this.version>0&&(this.ascent=e.readShort(),this.descent=e.readShort(),this.lineGap=e.readShort(),this.winAscent=e.readShort(),this.winDescent=e.readShort(),this.codePageRange=function(){var t,n;for(n=[],t=0;t<2;t=++t)n.push(e.readInt());return n}(),this.version>1))return this.xHeight=e.readShort(),this.capHeight=e.readShort(),this.defaultChar=e.readShort(),this.breakChar=e.readShort(),this.maxContext=e.readShort()},e}(),az=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`post`,e.prototype.parse=function(e){var t,n,r;switch(e.pos=this.offset,this.format=e.readInt(),this.italicAngle=e.readInt(),this.underlinePosition=e.readShort(),this.underlineThickness=e.readShort(),this.isFixedPitch=e.readInt(),this.minMemType42=e.readInt(),this.maxMemType42=e.readInt(),this.minMemType1=e.readInt(),this.maxMemType1=e.readInt(),this.format){case 65536:case 196608:break;case 131072:var i;for(n=e.readUInt16(),this.glyphNameIndex=[],i=0;0<=n?i<n:i>n;i=0<=n?++i:--i)this.glyphNameIndex.push(e.readUInt16());for(this.names=[],r=[];e.pos<this.offset+this.length;)t=e.readByte(),r.push(this.names.push(e.readString(t)));return r;case 151552:return n=e.readUInt16(),this.offsets=e.read(n);case 262144:return this.map=function(){var t,n,r;for(r=[],i=t=0,n=this.file.maxp.numGlyphs;0<=n?t<n:t>n;i=0<=n?++t:--t)r.push(e.readUInt32());return r}.call(this)}},e}(),oz=function(e,t){this.raw=e,this.length=e.length,this.platformID=t.platformID,this.encodingID=t.encodingID,this.languageID=t.languageID},sz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`name`,e.prototype.parse=function(e){var t,n,r,i,a,o,s,c,l,u,d;for(e.pos=this.offset,e.readShort(),t=e.readShort(),o=e.readShort(),n=[],i=0;0<=t?i<t:i>t;i=0<=t?++i:--i)n.push({platformID:e.readShort(),encodingID:e.readShort(),languageID:e.readShort(),nameID:e.readShort(),length:e.readShort(),offset:this.offset+o+e.readShort()});for(s={},i=l=0,u=n.length;l<u;i=++l)r=n[i],e.pos=r.offset,c=e.readString(r.length),a=new oz(c,r),s[d=r.nameID]??(s[d]=[]),s[r.nameID].push(a);this.strings=s,this.copyright=s[0],this.fontFamily=s[1],this.fontSubfamily=s[2],this.uniqueSubfamily=s[3],this.fontName=s[4],this.version=s[5];try{this.postscriptName=s[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,``)}catch{this.postscriptName=s[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,``)}return this.trademark=s[7],this.manufacturer=s[8],this.designer=s[9],this.description=s[10],this.vendorUrl=s[11],this.designerUrl=s[12],this.license=s[13],this.licenseUrl=s[14],this.preferredFamily=s[15],this.preferredSubfamily=s[17],this.compatibleFull=s[18],this.sampleText=s[19]},e}(),cz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`maxp`,e.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.numGlyphs=e.readUInt16(),this.maxPoints=e.readUInt16(),this.maxContours=e.readUInt16(),this.maxCompositePoints=e.readUInt16(),this.maxComponentContours=e.readUInt16(),this.maxZones=e.readUInt16(),this.maxTwilightPoints=e.readUInt16(),this.maxStorage=e.readUInt16(),this.maxFunctionDefs=e.readUInt16(),this.maxInstructionDefs=e.readUInt16(),this.maxStackElements=e.readUInt16(),this.maxSizeOfInstructions=e.readUInt16(),this.maxComponentElements=e.readUInt16(),this.maxComponentDepth=e.readUInt16()},e}(),lz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`hmtx`,e.prototype.parse=function(e){var t,n,r,i,a,o,s;for(e.pos=this.offset,this.metrics=[],t=0,o=this.file.hhea.numberOfMetrics;0<=o?t<o:t>o;t=0<=o?++t:--t)this.metrics.push({advance:e.readUInt16(),lsb:e.readInt16()});for(r=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var n,i;for(i=[],t=n=0;0<=r?n<r:n>r;t=0<=r?++n:--n)i.push(e.readInt16());return i}(),this.widths=function(){var e,t,n,r;for(r=[],e=0,t=(n=this.metrics).length;e<t;e++)i=n[e],r.push(i.advance);return r}.call(this),n=this.widths[this.widths.length-1],s=[],t=a=0;0<=r?a<r:a>r;t=0<=r?++a:--a)s.push(this.widths.push(n));return s},e.prototype.forGlyph=function(e){return e in this.metrics?this.metrics[e]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[e-this.metrics.length]}},e}(),uz=[].slice,dz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`glyf`,e.prototype.parse=function(){return this.cache={}},e.prototype.glyphFor=function(e){var t,n,r,i,a,o,s,c,l,u;return e in this.cache?this.cache[e]:(i=this.file.loca,t=this.file.contents,n=i.indexOf(e),(r=i.lengthOf(e))===0?this.cache[e]=null:(t.pos=this.offset+n,a=(o=new XR(t.read(r))).readShort(),c=o.readShort(),u=o.readShort(),s=o.readShort(),l=o.readShort(),this.cache[e]=a===-1?new pz(o,c,u,s,l):new fz(o,a,c,u,s,l),this.cache[e]))},e.prototype.encode=function(e,t,n){var r,i,a,o,s;for(a=[],i=[],o=0,s=t.length;o<s;o++)r=e[t[o]],i.push(a.length),r&&(a=a.concat(r.encode(n)));return i.push(a.length),{table:a,offsets:i}},e}(),fz=function(){function e(e,t,n,r,i,a){this.raw=e,this.numberOfContours=t,this.xMin=n,this.yMin=r,this.xMax=i,this.yMax=a,this.compound=!1}return e.prototype.encode=function(){return this.raw.data},e}(),pz=function(){function e(e,t,n,r,i){var a,o;for(this.raw=e,this.xMin=t,this.yMin=n,this.xMax=r,this.yMax=i,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],a=this.raw;o=a.readShort(),this.glyphOffsets.push(a.pos),this.glyphIDs.push(a.readUInt16()),32&o;)a.pos+=1&o?4:2,128&o?a.pos+=8:64&o?a.pos+=4:8&o&&(a.pos+=2)}return e.prototype.encode=function(){var e,t,n;for(t=new XR(uz.call(this.raw.data)),e=0,n=this.glyphIDs.length;e<n;++e)t.pos=this.glyphOffsets[e];return t.data},e}(),mz=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return $R(e,YR),e.prototype.tag=`loca`,e.prototype.parse=function(e){var t,n;return e.pos=this.offset,t=this.file.head.indexToLocFormat,this.offsets=t===0?function(){var t,r;for(r=[],n=0,t=this.length;n<t;n+=2)r.push(2*e.readUInt16());return r}.call(this):function(){var t,r;for(r=[],n=0,t=this.length;n<t;n+=4)r.push(e.readUInt32());return r}.call(this)},e.prototype.indexOf=function(e){return this.offsets[e]},e.prototype.lengthOf=function(e){return this.offsets[e+1]-this.offsets[e]},e.prototype.encode=function(e,t){for(var n=new Uint32Array(this.offsets.length),r=0,i=0,a=0;a<n.length;++a)if(n[a]=r,i<t.length&&t[i]==a){++i,n[a]=r;var o=this.offsets[a],s=this.offsets[a+1]-o;s>0&&(r+=s)}for(var c=Array(4*n.length),l=0;l<n.length;++l)c[4*l+3]=255&n[l],c[4*l+2]=(65280&n[l])>>8,c[4*l+1]=(16711680&n[l])>>16,c[4*l]=(4278190080&n[l])>>24;return c},e}(),hz=function(){function e(e){this.font=e,this.subset={},this.unicodes={},this.next=33}return e.prototype.generateCmap=function(){var e,t,n,r,i;for(t in r=this.font.cmap.tables[0].codeMap,e={},i=this.subset)n=i[t],e[t]=r[n];return e},e.prototype.glyphsFor=function(e){var t,n,r,i,a,o,s;for(r={},a=0,o=e.length;a<o;a++)r[i=e[a]]=this.font.glyf.glyphFor(i);for(i in t=[],r)(n=r[i])!=null&&n.compound&&t.push.apply(t,n.glyphIDs);if(t.length>0)for(i in s=this.glyphsFor(t))n=s[i],r[i]=n;return r},e.prototype.encode=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;for(r in n=nz.encode(this.generateCmap(),`unicode`),a=this.glyphsFor(e),f={0:0},g=n.charMap)f[(s=g[r]).old]=s.new;for(p in d=n.maxGlyphID,a)p in f||(f[p]=d++);return l=function(e){var t,n;for(t in n={},e)n[e[t]]=t;return n}(f),u=Object.keys(l).sort(function(e,t){return e-t}),m=function(){var e,t,n;for(n=[],e=0,t=u.length;e<t;e++)o=u[e],n.push(l[o]);return n}(),i=this.font.glyf.encode(a,m,f),c=this.font.loca.encode(i.offsets,m),h={cmap:this.font.cmap.raw(),glyf:i.table,loca:c,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(t)},this.font.os2.exists&&(h[`OS/2`]=this.font.os2.raw()),this.font.directory.encode(h)},e}();SL.API.PDFObject=function(){var e;function t(){}return e=function(e,t){return(Array(t+1).join(`0`)+e).slice(-t)},t.convert=function(n){var r,i,a,o;if(Array.isArray(n))return`[`+function(){var e,i,a;for(a=[],e=0,i=n.length;e<i;e++)r=n[e],a.push(t.convert(r));return a}().join(` `)+`]`;if(typeof n==`string`)return`/`+n;if(n?.isString)return`(`+n+`)`;if(n instanceof Date)return`(D:`+e(n.getUTCFullYear(),4)+e(n.getUTCMonth(),2)+e(n.getUTCDate(),2)+e(n.getUTCHours(),2)+e(n.getUTCMinutes(),2)+e(n.getUTCSeconds(),2)+`Z)`;if({}.toString.call(n)===`[object Object]`){for(i in a=[`<<`],n)o=n[i],a.push(`/`+i+` `+t.convert(o));return a.push(`>>`),a.join(`
`)}return``+n},t}();var gz=3.77952755906,_z={method:`save`,resolution:3,page:{margin:0,format:`A4`,orientation:`portrait`},canvas:{mimeType:`image/jpeg`,qualityRatio:1,useCORS:!0,logging:!1},overrides:{}},vz=class{pdf;canvas;options;constructor(e,t){this.canvas=e,this.options=t,this.pdf=new SL({format:this.options.page.format,orientation:this.options.page.orientation,...this.options.overrides?.pdf,unit:`mm`})}getMarginTopMM(){let e=typeof this.options.page.margin==`object`?this.options.page.margin.top:this.options.page.margin;return Number(e)}getMarginLeftMM(){let e=typeof this.options.page.margin==`object`?this.options.page.margin.left:this.options.page.margin;return Number(e)}getMarginRightMM(){let e=typeof this.options.page.margin==`object`?this.options.page.margin.right:this.options.page.margin;return Number(e)}getMarginBottomMM(){let e=typeof this.options.page.margin==`object`?this.options.page.margin.bottom:this.options.page.margin;return Number(e)}getMarginTop(){return this.getMarginTopMM()*gz}getMarginBottom(){return this.getMarginBottomMM()*gz}getMarginLeft(){return this.getMarginLeftMM()*gz}getMarginRight(){return this.getMarginRightMM()*gz}getScale(){return this.options.resolution}getPageHeight(){return this.getPageHeightMM()*gz}getPageHeightMM(){return this.pdf.internal.pageSize.height}getPageWidthMM(){return this.pdf.internal.pageSize.width}getPageWidth(){return this.getPageWidthMM()*gz}getOriginalCanvasWidth(){return this.canvas.width/this.getScale()}getOriginalCanvasHeight(){return this.canvas.height/this.getScale()}getCanvasPageAvailableHeight(){return this.getPageAvailableHeight()*this.getScale()*this.getHorizontalFitFactor()}getPageAvailableWidth(){return this.getPageWidth()-(this.getMarginLeft()+this.getMarginRight())}getPageAvailableHeight(){return this.getPageHeight()-(this.getMarginTop()+this.getMarginBottom())}getPageAvailableWidthMM(){return this.getPageAvailableWidth()/gz}getPageAvailableHeightMM(){return this.getPageAvailableHeight()/gz}getNumberPages(){return Math.ceil(this.canvas.height/this.getCanvasPageAvailableHeight())}getHorizontalFitFactor(){return this.getPageAvailableWidth()<this.getOriginalCanvasWidth()?this.getOriginalCanvasWidth()/this.getPageAvailableWidth():1}getCanvasOffsetY(e){return this.getCanvasPageAvailableHeight()*(e-1)}getCanvasHeightLeft(e){return this.canvas.height-this.getCanvasOffsetY(e)}getCanvasPageHeight(e){if(this.canvas.height<this.getCanvasPageAvailableHeight())return this.canvas.height;let t=this.getCanvasHeightLeft(e);return t<this.getCanvasPageAvailableHeight()?t:this.getCanvasPageAvailableHeight()}getCanvasPageWidth(){return this.canvas.width}createCanvasPage(e){let t=this.getCanvasPageWidth(),n=this.getCanvasPageHeight(e),r=document.createElement(`canvas`);return r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(n)),r.getContext(`2d`).drawImage(this.canvas,0,this.getCanvasOffsetY(e),this.canvas.width,n,0,0,this.canvas.width,n),r}convert(){let e=1,t=this.getNumberPages();for(;e<=t;){e>1&&this.pdf.addPage(this.options.page.format,this.options.page.orientation);let t=this.createCanvasPage(e),n=t.toDataURL(this.options.canvas.mimeType,this.options.canvas.qualityRatio);this.pdf.setPage(e),this.pdf.addImage({imageData:n,width:t.width/(this.getScale()*gz*this.getHorizontalFitFactor()),height:t.height/(this.getScale()*gz*this.getHorizontalFitFactor()),x:this.getMarginLeftMM(),y:this.getMarginTopMM()}),e+=1}return this.pdf}},yz=e=>e?{..._z,...e,canvas:{..._z.canvas,...e.canvas},page:{..._z.page,...e.page}}:_z,bz=e=>typeof e==`function`?e():e?.current,xz=async(e,t)=>{let n=yz(t),r=bz(e);if(!r){console.error(`Unable to get the target element.`);return}let i=new vz(await Ni(r,{useCORS:n.canvas.useCORS,logging:n.canvas.logging,scale:n.resolution,...n.overrides?.canvas}),n).convert();switch(n.method){case`build`:return i;case`open`:return window.open(i.output(`bloburl`),`_blank`),i;default:{let e=n.filename??`${new Date().getTime()}.pdf`;return await i.save(e,{returnPromise:!0}),i}}},Sz={method:`open`,overrides:{pdf:{compress:!0}}},Cz=()=>document.getElementById(`main-page`),wz=({filename:e})=>{let[t,n]=(0,Z.useState)(!1);return(0,Q.jsx)(q,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:async()=>{n(!0),await xz(Cz,{...Sz,filename:e}),n(!1)},disabled:t,children:t?(0,Q.jsx)(Qt,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,Q.jsx)(_a,{className:`size-5`})})},Tz=`regenerateLedgerRecords`,Ez=()=>{let[{fetching:e},t]=H(f);return{fetching:e,regenerateLedgerRecords:(0,Z.useCallback)(async e=>{let n=`Error regenerating ledger`,r=e.length>1,i=r?`${Tz}-batch`:`${Tz}-${e[0]}`;K.loading(r?`Regenerating Ledger for ${e.length} charges`:`Regenerating Ledger`,{id:i});try{let a=await t({chargeIds:e}),o=Ke(a,n,i);if(o){let e=o.regenerateLedgerRecords,t=e.filter(e=>e.__typename===`CommonError`);if(t.length>0&&t.length===e.length)throw Error(t.map(e=>e.message).join(`
`));return t.length>0?K.warning(`Partial success`,{id:i,description:`${e.length-t.length}/${e.length} charges regenerated. ${t.length} failed.`,duration:1e5,closeButton:!0}):K.success(`Success`,{id:i,description:r?`Ledger records were regenerated for ${e.length} charges`:`Ledger records were regenerated`}),e}}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:i,description:e instanceof Error?e.message:n,duration:1e5,closeButton:!0})}},[t])}};function Dz({chargeId:e,onChange:t,...n}){let{regenerateLedgerRecords:r}=Ez();function i(){r([e]).then(t)}return(0,Q.jsx)(SK,{content:`Regenerate Ledger`,children:(0,Q.jsx)(j0,{onConfirm:i,title:`Are you sure you want to regenerate ledger records?`,children:(0,Q.jsx)(q,{variant:`outline`,size:`icon`,...n,className:s(`size-7.5`,n.className),children:(0,Q.jsx)(ya,{className:`size-5`})})})})}function Oz(e){let{toggleExpansion:t,isExpanded:n,onClickAction:r}=e;return(0,Q.jsx)(SK,{content:`Expand info`,children:(0,Q.jsx)(q,{variant:n?`default`:`outline`,onClick:e=>{e.stopPropagation(),t(e=>(r?.(e),!e))},className:`size-7.5`,children:n?(0,Q.jsx)(fa,{className:`size-5`}):(0,Q.jsx)(pa,{className:`size-5`})})})}function kz(e){let{mergeSelected:t,toggleMergeSelected:n}=e,[r,i]=(0,Z.useState)(t?`default`:`ghost`);return(0,Z.useEffect)(()=>{i(t?`default`:`ghost`)},[t]),(0,Q.jsx)(SK,{content:`Select for merge`,children:(0,Q.jsx)(q,{onClick:e=>{e.stopPropagation(),n()},variant:r,className:s(`size-7.5`,t?`bg-blue-500 hover:bg-blue-500/90`:``),children:(0,Q.jsx)(Ki,{className:`size-5`})})})}var Az=`updateDocument`,jz=()=>{let[{fetching:e},t]=H(We);return{fetching:e,updateDocument:(0,Z.useCallback)(async e=>{let n=`Error updating document ID [${e.documentId}]`,r=`${Az}-${e.documentId}`;K.loading(`Updating document`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateDocument`);if(a)return K.success(`Success`,{id:r,description:`Document updated`}),a.updateDocument}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function Mz({documentId:e,onChange:t}){let{updateDocument:n}=jz();function r(){n({documentId:e,fields:{chargeId:eu}}).then(t)}return(0,Q.jsx)(j0,{onConfirm:r,title:`Are you sure you want to unlink this document from the charge?`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,children:(0,Q.jsx)(Oa,{className:`size-5`})})})}var Nz=`updateTransaction`,Pz=()=>{let[{fetching:e},t]=H(G);return{fetching:e,updateTransaction:(0,Z.useCallback)(async e=>{let n=`Error updating transaction ID [${e.transactionId}]`,r=`${Nz}-${e.transactionId}`;K.loading(`Updating Transaction`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateTransaction`);if(a)return K.success(`Success`,{id:r,description:`Transaction updated`}),a.updateTransaction}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function Fz({transactionId:e}){let{updateTransaction:t}=Pz();function n(){t({transactionId:e,fields:{chargeId:eu}})}return(0,Q.jsx)(j0,{onConfirm:n,title:`Are you sure you want to unlink this transaction from the charge?`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,children:(0,Q.jsx)(Oa,{className:`size-5`})})})}function Iz({column:e,title:t,className:n}){return e.getCanSort()?(0,Q.jsx)(`div`,{className:s(`flex items-center gap-2`,n),children:(0,Q.jsxs)(Vn,{children:[(0,Q.jsx)(zn,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`data-[state=open]:bg-accent -ml-3 h-8`,children:[(0,Q.jsx)(`span`,{children:t}),e.getIsSorted()===`desc`?(0,Q.jsx)(Fi,{}):e.getIsSorted()===`asc`?(0,Q.jsx)(Li,{}):(0,Q.jsx)(Hi,{})]})}),(0,Q.jsxs)(In,{align:`start`,children:[(0,Q.jsxs)(Ln,{onClick:()=>e.toggleSorting(!1),children:[(0,Q.jsx)(Li,{}),`Asc`]}),(0,Q.jsxs)(Ln,{onClick:()=>e.toggleSorting(!0),children:[(0,Q.jsx)(Fi,{}),`Desc`]}),(0,Q.jsx)(Hn,{}),(0,Q.jsxs)(Ln,{onClick:()=>e.toggleVisibility(!1),children:[(0,Q.jsx)(Zi,{}),`Hide`]})]})]})}):(0,Q.jsx)(`div`,{className:s(n),children:t})}function Lz({table:e}){return(0,Q.jsxs)(`div`,{className:`flex items-center space-x-6 lg:space-x-8`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`Rows per page`}),(0,Q.jsxs)(wn,{value:String(e.store.state.pagination.pageSize),onValueChange:t=>{e.setPageSize(Number(t))},children:[(0,Q.jsx)(sn,{className:`h-8 w-[70px]`,children:(0,Q.jsx)(qt,{placeholder:e.store.state.pagination.pageSize})}),(0,Q.jsx)(mn,{side:`top`,children:[10,20,30,40,50,100].map(e=>(0,Q.jsx)(bn,{value:String(e),children:e},e))})]})]}),(0,Q.jsxs)(`div`,{className:`flex w-[100px] items-center justify-center text-sm font-medium`,children:[`Page `,e.store.state.pagination.pageIndex+1,` of `,e.getPageCount()]}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsxs)(q,{variant:`outline`,className:`hidden h-8 w-8 p-0 lg:flex`,onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:`Go to first page`}),(0,Q.jsx)(Bi,{})]}),(0,Q.jsxs)(q,{variant:`outline`,className:`h-8 w-8 p-0`,onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:`Go to previous page`}),(0,Q.jsx)(zi,{})]}),(0,Q.jsxs)(q,{variant:`outline`,className:`h-8 w-8 p-0`,onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:`Go to next page`}),(0,Q.jsx)(vn,{})]}),(0,Q.jsxs)(q,{variant:`outline`,className:`hidden h-8 w-8 p-0 lg:flex`,onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:`Go to last page`}),(0,Q.jsx)(Vi,{})]})]})]})}var Rz=()=>{let[{data:e,fetching:t,error:n},r]=W({query:D});n&&(console.error(`Error fetching tags: ${n}`),K.error(`Error`,{description:`Unable to fetch tags`}));let i=(0,Z.useMemo)(()=>cu(e?.allTags??[]),[e]);return{fetching:t,refresh:()=>r(),tags:i,selectableTags:(0,Z.useMemo)(()=>i.map(e=>({value:e.id,label:e.name,description:e.namePath?e.namePath.join(` > `):void 0})),[i])}},zz=()=>{let[{data:e,fetching:t,error:n},r]=W({query:dt});n&&(console.error(`Error fetching tax categories: ${n}`),K.error(`Error`,{description:`Unable to fetch tax categories`}));let i=(0,Z.useMemo)(()=>e?.taxCategories?.sort((e,t)=>e.name>t.name?1:-1)??[],[e]);return{fetching:t,refresh:()=>r(),taxCategories:i,selectableTaxCategories:(0,Z.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i])}},Bz=`updateCharge`,Vz=()=>{let[{fetching:e},t]=H(Pe);return{fetching:e,updateCharge:(0,Z.useCallback)(async e=>{let n=`Error updating charge ID [${e.chargeId}]`,r=`${Bz}-${e.chargeId}`;K.loading(`Updating charge`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateCharge`);if(a)return K.success(`Success`,{id:r,description:`Charge updated`}),a.updateCharge.charge}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function Hz({className:e,...t}){return(0,Q.jsx)(Cs,{"data-slot":`switch`,className:s(`peer data-[state=checked]:bg-gray-900 data-[state=unchecked]:bg-gray-200 focus-visible:border-gray-950 focus-visible:ring-gray-950/50 dark:data-[state=unchecked]:bg-gray-200/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-gray-200 border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:data-[state=checked]:bg-gray-50 dark:data-[state=unchecked]:bg-gray-800 dark:focus-visible:border-gray-300 dark:focus-visible:ring-gray-300/50 dark:dark:data-[state=unchecked]:bg-gray-800/80 dark:border-gray-800`,e),...t,children:(0,Q.jsx)(Ts,{"data-slot":`switch-thumb`,className:s(`bg-white dark:data-[state=unchecked]:bg-gray-950 dark:data-[state=checked]:bg-gray-50 pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:bg-gray-950 dark:dark:data-[state=unchecked]:bg-gray-50 dark:dark:data-[state=checked]:bg-gray-900`)})})}var Uz=Object.entries(Kl).map(([e,t])=>({value:Xl(e),label:t})),Wz=({charge:e,close:t,onChange:n})=>{let{updateCharge:r,fetching:i}=Vz(),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(void 0),d=(0,Z.useMemo)(()=>({tags:e.tags?.map(e=>({id:e.id})),counterpartyId:e.counterparty?.id,businessTripID:`businessTrip`in e?e.businessTrip?.id:void 0,defaultTaxCategoryID:e.taxCategory?.id,isDecreasedVAT:e.decreasedVAT,isInvoicePaymentDifferentCurrency:e.isInvoicePaymentDifferentCurrency,optionalDocuments:e.optionalDocuments,optionalVAT:e.optionalVAT,ownerId:e.owner?.id,type:Xl(e.__typename),userDescription:e.userDescription,yearsOfRelevance:e.yearsOfRelevance?.map(e=>({year:e.year,amount:e.amount})).sort((e,t)=>e.year>t.year?1:-1)}),[e]),f=Mr({defaultValues:d}),{control:p,handleSubmit:m,formState:{dirtyFields:h}}=f,g=async i=>{let a=gt(i,h);if(a&&Object.keys(a).length>0){if(await r({chargeId:e.id,fields:{...a,yearsOfRelevance:i.yearsOfRelevance?Object.values(i.yearsOfRelevance):void 0}}),a.tags?.length||a.userDescription){let t={};if(a.tags){let n=e?.missingInfoSuggestions?.tags??[],r=new Set(n.map(e=>e.id)),i=new Set(a.tags.map(e=>e.id));(r.size!==i.size||[...r].some(e=>!i.has(e)))&&(t.tagIds=a.tags.map(e=>({id:e.id})))}u(t),c(!0)}else t(),n?.()}},{selectableTaxCategories:_,fetching:v}=zz(),{selectableTags:y,fetching:b}=Rz(),[{data:x,fetching:S,error:C},w]=W({query:rt}),T=(0,Z.useCallback)(()=>{w()},[w]);return(0,Z.useEffect)(()=>{C&&K.error(`Error`,{description:`An error occurred while fetching business trips.`})},[C]),(0,Z.useEffect)(()=>{x?.allBusinessTrips.length&&o([...x.allBusinessTrips.map(e=>({value:e.id,label:e.name})).sort((e,t)=>e.label>t.label?1:-1),{value:eu,label:`None`}])},[x,o]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(kr,{...f,children:(0,Q.jsxs)(`form`,{onSubmit:m(g),children:[(0,Q.jsx)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:(0,Q.jsxs)(X9,{cols:3,children:[(0,Q.jsx)(Ar,{name:`userDescription`,control:p,defaultValue:d.userDescription,rules:{required:`Required`,minLength:{value:2,message:`Must be at least 2 characters`}},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Description`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??void 0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`defaultTaxCategoryID`,control:p,defaultValue:d.defaultTaxCategoryID,render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Tax Category Override`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(JO,{...e,data:_,value:e.value,disabled:v,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:!!t.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`businessTripID`,control:p,defaultValue:d.businessTripID,render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Business Trip`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(JO,{...e,data:a,value:e.value,disabled:S,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:!!t.error,rightSection:(0,Q.jsx)(c2,{onDone:T})})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`tags`,control:p,defaultValue:d.tags,render:({field:e,fieldState:t})=>{let n=e.value?.map(e=>e.id)??[];return(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Tags`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(y1,{asChild:!0,options:Object.values(y),onValueChange:t=>e.onChange(t.map(e=>({id:e}))),defaultValue:n,value:n,placeholder:`Select Tags`,variant:`default`,disabled:b,className:t.error?`border-red-500`:void 0})}),(0,Q.jsx)(mi,{})]})}}),(0,Q.jsx)(Ar,{name:`type`,control:p,defaultValue:d.type,render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Charge Type`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(JO,{...e,data:Uz,value:e.value,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:!!t.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`isInvoicePaymentDifferentCurrency`,control:p,defaultValue:d.isInvoicePaymentDifferentCurrency,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row h-fit items-center justify-between rounded-lg border p-3 shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(hr,{children:`Is Invoice-Payment currency difference`})}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{checked:e.value===!0,onCheckedChange:e.onChange})})]})}),(0,Q.jsx)(Ar,{name:`isDecreasedVAT`,control:p,defaultValue:d.isDecreasedVAT,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row h-fit items-center justify-between rounded-lg border p-3 shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(hr,{children:`Is Decreased VAT`})}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{checked:e.value===!0,onCheckedChange:e.onChange})})]})}),(0,Q.jsx)(Ar,{name:`optionalVAT`,control:p,defaultValue:d.optionalVAT??!1,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row h-fit items-center justify-between rounded-lg border p-3 shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(hr,{children:`Optional VAT`})}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{checked:e.value===!0,onCheckedChange:e.onChange})})]})}),(0,Q.jsx)(Ar,{name:`optionalDocuments`,control:p,defaultValue:d.optionalDocuments??!1,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row h-fit items-center justify-between rounded-lg border p-3 shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(hr,{children:`Optional Documents`})}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{checked:e.value===!0,onCheckedChange:e.onChange})})]})}),(0,Q.jsx)(TK,{formManager:f,chargeSpreadPath:`yearsOfRelevance`})]})}),(0,Q.jsxs)(`div`,{className:`mt-10 mb-5 flex justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:`mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:i||Object.keys(h).length===0,children:`Accept`}),(0,Q.jsx)(`button`,{type:`button`,className:`mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg`,onClick:t,children:`Cancel`})]})]})}),(0,Q.jsx)(k9,{chargeId:e.id,tagIds:l?.tagIds,description:l?.description,open:s,onOpenChange:c,onClose:()=>{t(),n?.()},showChargesWithExistingSuggestions:!0})]})},Gz=Object.defineProperty,Kz=Object.defineProperties,qz=Object.getOwnPropertyDescriptors,Jz=Object.getOwnPropertySymbols,Yz=Object.prototype.hasOwnProperty,Xz=Object.prototype.propertyIsEnumerable,Zz=(e,t,n)=>t in e?Gz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qz=(e,t)=>{for(var n in t||={})Yz.call(t,n)&&Zz(e,n,t[n]);if(Jz)for(var n of Jz(t))Xz.call(t,n)&&Zz(e,n,t[n]);return e},$z=(e,t)=>Kz(e,qz(t)),eB=(e,t)=>{var n={};for(var r in e)Yz.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Jz)for(var r of Jz(e))t.indexOf(r)<0&&Xz.call(e,r)&&(n[r]=e[r]);return n};function tB(e){var t=e,{direction:n,style:r}=t,i=eB(t,[`direction`,`style`]);let a=Kr();return Z.createElement(ff,$z(Qz({},i),{style:$z(Qz({},r),{transform:n===`next`&&a.dir===`ltr`||n===`previous`&&a.dir===`rtl`?`rotate(270deg)`:`rotate(90deg)`})}))}tB.displayName=`@mantine/dates/Chevron`;var nB=Object.defineProperty,rB=Object.defineProperties,iB=Object.getOwnPropertyDescriptors,aB=Object.getOwnPropertySymbols,oB=Object.prototype.hasOwnProperty,sB=Object.prototype.propertyIsEnumerable,cB=(e,t,n)=>t in e?nB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lB=(e,t)=>{for(var n in t||={})oB.call(t,n)&&cB(e,n,t[n]);if(aB)for(var n of aB(t))sB.call(t,n)&&cB(e,n,t[n]);return e},uB=(e,t)=>rB(e,iB(t)),dB={xs:Y(30),sm:Y(36),md:Y(42),lg:Y(48),xl:Y(54)},fB=Ur((e,{radius:t,isStatic:n},{size:r})=>{let i=e.fn.variant({variant:`filled`}),a=e.fn.variant({variant:`light`});return{day:uB(lB({width:J({size:r,sizes:dB}),height:J({size:r,sizes:dB}),fontSize:J({size:r,sizes:e.fontSizes}),display:`inline-flex`,justifyContent:`center`,alignItems:`center`,userSelect:n?void 0:`none`,cursor:n?`default`:`pointer`,borderRadius:e.fn.radius(t)},n?null:e.fn.hover({backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[0]})),{"&:active":n?void 0:e.activeStyles,"&[data-disabled]":uB(lB({color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[4],cursor:`not-allowed`},e.fn.hover({backgroundColor:`transparent`})),{"&:active":{transform:`none`}}),"&[data-weekend]":{color:e.colors.red[e.fn.primaryShade()]},"&[data-outside]":{color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[4]},"&[data-in-range]":lB({backgroundColor:a.background,borderRadius:0},n?null:e.fn.hover({backgroundColor:a.hover})),"&[data-first-in-range]":{borderTopLeftRadius:e.radius.sm,borderBottomLeftRadius:e.radius.sm},"&[data-last-in-range]":{borderTopRightRadius:e.radius.sm,borderBottomRightRadius:e.radius.sm},"&[data-selected]":lB({color:i.color,backgroundColor:i.background},n?null:e.fn.hover({backgroundColor:i.hover})),"&[data-hidden]":{display:`none`}})}}),pB=Object.defineProperty,mB=Object.defineProperties,hB=Object.getOwnPropertyDescriptors,gB=Object.getOwnPropertySymbols,_B=Object.prototype.hasOwnProperty,vB=Object.prototype.propertyIsEnumerable,yB=(e,t,n)=>t in e?pB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bB=(e,t)=>{for(var n in t||={})_B.call(t,n)&&yB(e,n,t[n]);if(gB)for(var n of gB(t))vB.call(t,n)&&yB(e,n,t[n]);return e},xB=(e,t)=>mB(e,hB(t)),SB=Ur((e,t,{size:n})=>{let r=J({size:n,sizes:dB});return{calendarHeaderControlIcon:{},calendarHeader:{display:`flex`,maxWidth:`calc(${r} * 7 + ${Y(7)})`},calendarHeaderControl:xB(bB({width:r,height:r,borderRadius:e.fn.radius(),display:`flex`,justifyContent:`center`,alignItems:`center`,userSelect:`none`},e.fn.hover({backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[0]})),{"&:active":e.activeStyles,"&[data-disabled]":xB(bB({opacity:.2,cursor:`not-allowed`},e.fn.hover({backgroundColor:`transparent`})),{"&:active":{transform:`none`}})}),calendarHeaderLevel:xB(bB({height:r,borderRadius:e.fn.radius(),display:`flex`,justifyContent:`center`,alignItems:`center`,userSelect:`none`,flex:1,fontSize:J({size:n,sizes:e.fontSizes}),fontWeight:500,textTransform:`capitalize`},e.fn.hover({backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[0]})),{"&:active":e.activeStyles,"&[data-static]":xB(bB({cursor:`default`,userSelect:`unset`},e.fn.hover({backgroundColor:`transparent`})),{"&:active":{transform:`none`}})})}}),CB=Object.defineProperty,wB=Object.getOwnPropertySymbols,TB=Object.prototype.hasOwnProperty,EB=Object.prototype.propertyIsEnumerable,DB=(e,t,n)=>t in e?CB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,OB=(e,t)=>{for(var n in t||={})TB.call(t,n)&&DB(e,n,t[n]);if(wB)for(var n of wB(t))EB.call(t,n)&&DB(e,n,t[n]);return e},kB=(e,t)=>{var n={};for(var r in e)TB.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&wB)for(var r of wB(e))t.indexOf(r)<0&&EB.call(e,r)&&(n[r]=e[r]);return n},AB={nextDisabled:!1,previousDisabled:!1,hasNextLevel:!0,withNext:!0,withPrevious:!0,size:`sm`},jB=(0,Z.forwardRef)((e,t)=>{let n=X(`CalendarHeader`,AB,e),{className:r,nextIcon:i,previousIcon:a,nextLabel:o,previousLabel:s,onNext:c,onPrevious:l,onLevelClick:u,label:d,classNames:f,styles:p,unstyled:m,nextDisabled:h,previousDisabled:g,hasNextLevel:_,levelControlAriaLabel:v,withNext:y,withPrevious:b,__staticSelector:x,__preventFocus:S,__stopPropagation:C,size:w,variant:T}=n,E=kB(n,[`className`,`nextIcon`,`previousIcon`,`nextLabel`,`previousLabel`,`onNext`,`onPrevious`,`onLevelClick`,`label`,`classNames`,`styles`,`unstyled`,`nextDisabled`,`previousDisabled`,`hasNextLevel`,`levelControlAriaLabel`,`withNext`,`withPrevious`,`__staticSelector`,`__preventFocus`,`__stopPropagation`,`size`,`variant`]),{classes:D,cx:O}=SB(null,{name:[`CalendarHeader`,x],classNames:f,styles:p,unstyled:m,size:w,variant:T}),k=S?e=>e.preventDefault():void 0;return Z.createElement(Br,OB({className:O(D.calendarHeader,r),ref:t},E),b&&Z.createElement(rf,{className:D.calendarHeaderControl,"data-previous":!0,"aria-label":s,onClick:l,unstyled:m,onMouseDown:k,disabled:g,"data-disabled":g||void 0,tabIndex:S?-1:0,"data-mantine-stop-propagation":C||void 0},a||Z.createElement(tB,{className:D.calendarHeaderControlIcon,direction:`previous`,"data-previous":!0})),Z.createElement(rf,{component:_?`button`:`div`,className:D.calendarHeaderLevel,onClick:_?u:void 0,unstyled:m,onMouseDown:_?k:void 0,disabled:!_,"data-static":!_||void 0,"aria-label":v,tabIndex:S||!_?-1:0,"data-mantine-stop-propagation":C||void 0},d),y&&Z.createElement(rf,{className:D.calendarHeaderControl,"data-next":!0,"aria-label":o,onClick:c,unstyled:m,onMouseDown:k,disabled:h,"data-disabled":h||void 0,tabIndex:S?-1:0,"data-mantine-stop-propagation":C||void 0},i||Z.createElement(tB,{className:D.calendarHeaderControlIcon,direction:`next`,"data-next":!0})))});jB.displayName=`@mantine/dates/CalendarHeader`;var MB=r(n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))());function NB(e,t){return e?e===`month`?0:e===`year`?1:2:t}function PB(e){return e===0?`month`:e===1?`year`:`decade`}function FB(e,t,n){return PB(od(NB(e,0),NB(t,0),NB(n,2)))}var IB=Ur(()=>({calendar:{}})),LB=Ur((e,t,{size:n})=>({monthLevelGroup:{display:`flex`,"& [data-month-level]:not(:last-of-type)":{marginRight:J({size:n,sizes:e.spacing})}}})),RB=Ur(e=>({monthLevel:{},calendarHeader:{marginBottom:e.spacing.xs}})),zB=(0,Z.createContext)({locale:`en`,firstDayOfWeek:1,weekendDays:[0,6],labelSeparator:`–`}),BB=Object.defineProperty,VB=Object.defineProperties,HB=Object.getOwnPropertyDescriptors,UB=Object.getOwnPropertySymbols,WB=Object.prototype.hasOwnProperty,GB=Object.prototype.propertyIsEnumerable,KB=(e,t,n)=>t in e?BB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qB=(e,t)=>{for(var n in t||={})WB.call(t,n)&&KB(e,n,t[n]);if(UB)for(var n of UB(t))GB.call(t,n)&&KB(e,n,t[n]);return e},JB=(e,t)=>VB(e,HB(t));function YB(){let e=(0,Z.useContext)(zB),t=(0,Z.useCallback)(t=>t||e.locale,[e.locale]),n=(0,Z.useCallback)(t=>typeof t==`number`?t:e.firstDayOfWeek,[e.firstDayOfWeek]),r=(0,Z.useCallback)(t=>Array.isArray(t)?t:e.weekendDays,[e.weekendDays]),i=(0,Z.useCallback)(t=>typeof t==`string`?t:e.labelSeparator,[e.labelSeparator]);return JB(qB({},e),{getLocale:t,getFirstDayOfWeek:n,getWeekendDays:r,getLabelSeparator:i})}function XB(e,t=1){let n=new Date(e);for(;n.getDay()!==t;)n.setDate(n.getDate()-1);return n}function ZB(e,t=1){let n=new Date(e),r=t===0?6:t-1;for(;n.getDay()!==r;)n.setDate(n.getDate()+1);return n}function QB(e,t=1){let n=e.getMonth(),r=new Date(e.getFullYear(),n,1),i=ZB(new Date(e.getFullYear(),e.getMonth()+1,0),t),a=XB(r,t),o=[];for(;a<=i;){let e=[];for(let t=0;t<7;t+=1)e.push(new Date(a)),a.setDate(a.getDate()+1);o.push(e)}return o}function $B(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function eV(e,t){return t instanceof Date?(0,MB.default)(e).isBefore((0,MB.default)(t).add(1,`day`),`day`):!0}function tV(e,t){return t instanceof Date?(0,MB.default)(e).isAfter((0,MB.default)(t).subtract(1,`day`),`day`):!0}var nV=Object.defineProperty,rV=Object.defineProperties,iV=Object.getOwnPropertyDescriptors,aV=Object.getOwnPropertySymbols,oV=Object.prototype.hasOwnProperty,sV=Object.prototype.propertyIsEnumerable,cV=(e,t,n)=>t in e?nV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lV=(e,t)=>{for(var n in t||={})oV.call(t,n)&&cV(e,n,t[n]);if(aV)for(var n of aV(t))sV.call(t,n)&&cV(e,n,t[n]);return e},uV=(e,t)=>rV(e,iV(t)),dV=Ur(e=>({monthThead:{},monthRow:{},monthTbody:{},monthCell:{padding:0,"&[data-with-spacing]":{padding:Y(.5)}},month:uV(lV({},e.fn.fontStyles()),{borderCollapse:`collapse`,tableLayout:`fixed`,"& *":{boxSizing:`border-box`}})}));function fV(e,t,n,r,i,a,o){let s=e.flat().filter(e=>eV(e,n)&&tV(e,t)&&!i?.(e)&&!r?.(e)?.disabled&&(!a||$B(e,o)));return s.find(e=>r?.(e)?.selected)||s.find(e=>(0,MB.default)().isSame(e,`date`))||s[0]}var pV=Object.defineProperty,mV=Object.getOwnPropertySymbols,hV=Object.prototype.hasOwnProperty,gV=Object.prototype.propertyIsEnumerable,_V=(e,t,n)=>t in e?pV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vV=(e,t)=>{for(var n in t||={})hV.call(t,n)&&_V(e,n,t[n]);if(mV)for(var n of mV(t))gV.call(t,n)&&_V(e,n,t[n]);return e},yV=(e,t)=>{var n={};for(var r in e)hV.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&mV)for(var r of mV(e))t.indexOf(r)<0&&gV.call(e,r)&&(n[r]=e[r]);return n},bV={tabIndex:0,size:`sm`},xV=(0,Z.forwardRef)((e,t)=>{let n=X(`Day`,bV,e),{className:r,date:i,radius:a,disabled:o,styles:s,classNames:c,unstyled:l,__staticSelector:u,weekend:d,outside:f,selected:p,renderDay:m,inRange:h,firstInRange:g,lastInRange:_,hidden:v,static:y,variant:b,size:x}=n,S=yV(n,[`className`,`date`,`radius`,`disabled`,`styles`,`classNames`,`unstyled`,`__staticSelector`,`weekend`,`outside`,`selected`,`renderDay`,`inRange`,`firstInRange`,`lastInRange`,`hidden`,`static`,`variant`,`size`]),{classes:C,cx:w}=fB({radius:a,isStatic:y},{name:[`Day`,u],classNames:c,styles:s,unstyled:l,variant:b,size:x});return Z.createElement(rf,vV({component:y?`div`:`button`,ref:t,className:w(C.day,r),disabled:o,"data-today":(0,MB.default)(i).isSame(new Date,`day`)||void 0,"data-hidden":v||void 0,"data-disabled":o||void 0,"data-weekend":!o&&!f&&d||void 0,"data-outside":!o&&f||void 0,"data-selected":!o&&p||void 0,"data-in-range":h&&!o||void 0,"data-first-in-range":g&&!o||void 0,"data-last-in-range":_&&!o||void 0,unstyled:l},S),m?.(i)||i.getDate())});xV.displayName=`@mantine/dates/Day`;function SV({locale:e,format:t=`dd`,firstDayOfWeek:n=1}){let r=(0,MB.default)().day(n),i=[];for(let n=0;n<7;n+=1)typeof t==`string`?i.push((0,MB.default)(r).add(n,`days`).locale(e).format(t)):i.push(t((0,MB.default)(r).add(n,`days`).toDate()));return i}var CV=Ur((e,t,{size:n})=>({weekdaysRow:{},weekday:{color:e.colorScheme===`dark`?e.colors.dark[1]:e.colors.gray[5],fontWeight:400,fontSize:J({size:n,sizes:e.fontSizes}),textTransform:`capitalize`,paddingBottom:`calc(${J({size:n,sizes:e.spacing})} / 2)`}})),wV=Object.defineProperty,TV=Object.getOwnPropertySymbols,EV=Object.prototype.hasOwnProperty,DV=Object.prototype.propertyIsEnumerable,OV=(e,t,n)=>t in e?wV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kV=(e,t)=>{for(var n in t||={})EV.call(t,n)&&OV(e,n,t[n]);if(TV)for(var n of TV(t))DV.call(t,n)&&OV(e,n,t[n]);return e},AV=(e,t)=>{var n={};for(var r in e)EV.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&TV)for(var r of TV(e))t.indexOf(r)<0&&DV.call(e,r)&&(n[r]=e[r]);return n},jV={weekdayFormat:`dd`,cellComponent:`th`,size:`sm`},MV=(0,Z.forwardRef)((e,t)=>{let n=X(`WeekdaysRow`,jV,e),{className:r,locale:i,firstDayOfWeek:a,weekdayFormat:o,cellComponent:s,__staticSelector:c,classNames:l,styles:u,unstyled:d,variant:f,size:p}=n,m=AV(n,[`className`,`locale`,`firstDayOfWeek`,`weekdayFormat`,`cellComponent`,`__staticSelector`,`classNames`,`styles`,`unstyled`,`variant`,`size`]),h=YB(),{classes:g,cx:_}=CV(null,{name:[`WeekdaysRow`,c],classNames:l,styles:u,unstyled:d,variant:f,size:p}),v=SV({locale:h.getLocale(i),format:o,firstDayOfWeek:h.getFirstDayOfWeek(a)}).map((e,t)=>Z.createElement(s,{key:t,className:g.weekday},e));return Z.createElement(Br,kV({component:`tr`,ref:t,className:_(g.weekdaysRow,r)},m),v)});MV.displayName=`@mantine/dates/WeekdaysRow`;var NV=Object.defineProperty,PV=Object.defineProperties,FV=Object.getOwnPropertyDescriptors,IV=Object.getOwnPropertySymbols,LV=Object.prototype.hasOwnProperty,RV=Object.prototype.propertyIsEnumerable,zV=(e,t,n)=>t in e?NV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,BV=(e,t)=>{for(var n in t||={})LV.call(t,n)&&zV(e,n,t[n]);if(IV)for(var n of IV(t))RV.call(t,n)&&zV(e,n,t[n]);return e},VV=(e,t)=>PV(e,FV(t)),HV=(e,t)=>{var n={};for(var r in e)LV.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&IV)for(var r of IV(e))t.indexOf(r)<0&&RV.call(e,r)&&(n[r]=e[r]);return n},UV={size:`sm`,withCellSpacing:!0},WV=(0,Z.forwardRef)((e,t)=>{let n=X(`Month`,UV,e),{className:r,classNames:i,styles:a,unstyled:o,__staticSelector:s,locale:c,firstDayOfWeek:l,weekdayFormat:u,month:d,weekendDays:f,getDayProps:p,excludeDate:m,minDate:h,maxDate:g,renderDay:_,hideOutsideDates:v,hideWeekdays:y,getDayAriaLabel:b,static:x,__getDayRef:S,__onDayKeyDown:C,__onDayClick:w,__onDayMouseEnter:T,__preventFocus:E,__stopPropagation:D,withCellSpacing:O,size:k,variant:A}=n,j=HV(n,`className.classNames.styles.unstyled.__staticSelector.locale.firstDayOfWeek.weekdayFormat.month.weekendDays.getDayProps.excludeDate.minDate.maxDate.renderDay.hideOutsideDates.hideWeekdays.getDayAriaLabel.static.__getDayRef.__onDayKeyDown.__onDayClick.__onDayMouseEnter.__preventFocus.__stopPropagation.withCellSpacing.size.variant`.split(`.`)),M=YB(),{classes:N,cx:P}=dV(null,{name:[`Month`,s],classNames:i,styles:a,unstyled:o,variant:A,size:k}),F={__staticSelector:s||`Month`,classNames:i,styles:a,unstyled:o,variant:A,size:k},I=QB(d,M.getFirstDayOfWeek(l)),L=fV(I,h,g,p,m,v,d),R=I.map((e,t)=>{let n=e.map((e,n)=>{let r=!$B(e,d),i=b?.(e)||(0,MB.default)(e).locale(c||M.locale).format(`D MMMM YYYY`),a=p?.(e),o=(0,MB.default)(e).isSame(L,`date`);return Z.createElement(`td`,{key:e.toString(),className:N.monthCell,"data-with-spacing":O||void 0},Z.createElement(xV,VV(BV(VV(BV({},F),{"data-mantine-stop-propagation":D||void 0,renderDay:_,date:e,weekend:M.getWeekendDays(f).includes(e.getDay()),outside:r,hidden:v?r:!1,"aria-label":i,static:x,disabled:m?.(e)||!eV(e,g)||!tV(e,h),ref:e=>S?.(t,n,e)}),a),{onKeyDown:r=>{var i;(i=a?.onKeyDown)==null||i.call(a,r),C?.(r,{rowIndex:t,cellIndex:n,date:e})},onMouseEnter:t=>{var n;(n=a?.onMouseEnter)==null||n.call(a,t),T?.(t,e)},onClick:t=>{var n;(n=a?.onClick)==null||n.call(a,t),w?.(t,e)},onMouseDown:e=>{var t;(t=a?.onMouseDown)==null||t.call(a,e),E&&e.preventDefault()},tabIndex:E||!o?-1:0})))});return Z.createElement(`tr`,{key:t,className:N.monthRow},n)});return Z.createElement(Br,BV({component:`table`,className:P(N.month,r),ref:t},j),!y&&Z.createElement(`thead`,{className:N.monthThead},Z.createElement(MV,VV(BV({},F),{locale:c,firstDayOfWeek:l,weekdayFormat:u}))),Z.createElement(`tbody`,{className:N.monthTbody},R))});WV.displayName=`@mantine/dates/Month`;var GV=Object.defineProperty,KV=Object.getOwnPropertySymbols,qV=Object.prototype.hasOwnProperty,JV=Object.prototype.propertyIsEnumerable,YV=(e,t,n)=>t in e?GV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,XV=(e,t)=>{for(var n in t||={})qV.call(t,n)&&YV(e,n,t[n]);if(KV)for(var n of KV(t))JV.call(t,n)&&YV(e,n,t[n]);return e},ZV=(e,t)=>{var n={};for(var r in e)qV.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&KV)for(var r of KV(e))t.indexOf(r)<0&&JV.call(e,r)&&(n[r]=e[r]);return n},QV={monthLabelFormat:`MMMM YYYY`},$V=(0,Z.forwardRef)((e,t)=>{let n=X(`MonthLevel`,QV,e),{month:r,locale:i,firstDayOfWeek:a,weekdayFormat:o,weekendDays:s,getDayProps:c,excludeDate:l,minDate:u,maxDate:d,renderDay:f,hideOutsideDates:p,hideWeekdays:m,getDayAriaLabel:h,__getDayRef:g,__onDayKeyDown:_,__onDayClick:v,__onDayMouseEnter:y,withCellSpacing:b,__preventFocus:x,__stopPropagation:S,nextIcon:C,previousIcon:w,nextLabel:T,previousLabel:E,onNext:D,onPrevious:O,onLevelClick:k,nextDisabled:A,previousDisabled:j,hasNextLevel:M,levelControlAriaLabel:N,withNext:P,withPrevious:F,className:I,monthLabelFormat:L,classNames:R,styles:z,unstyled:B,__staticSelector:V,size:ee,variant:te,static:ne}=n,re=ZV(n,`month.locale.firstDayOfWeek.weekdayFormat.weekendDays.getDayProps.excludeDate.minDate.maxDate.renderDay.hideOutsideDates.hideWeekdays.getDayAriaLabel.__getDayRef.__onDayKeyDown.__onDayClick.__onDayMouseEnter.withCellSpacing.__preventFocus.__stopPropagation.nextIcon.previousIcon.nextLabel.previousLabel.onNext.onPrevious.onLevelClick.nextDisabled.previousDisabled.hasNextLevel.levelControlAriaLabel.withNext.withPrevious.className.monthLabelFormat.classNames.styles.unstyled.__staticSelector.size.variant.static`.split(`.`)),{classes:H,cx:ie}=RB(null,{name:[`MonthLevel`,V],classNames:R,styles:z,unstyled:B,variant:te,size:ee}),U=YB(),W={__staticSelector:V||`MonthLevel`,classNames:R,styles:z,unstyled:B,variant:te,size:ee},ae=typeof A==`boolean`?A:d?!(0,MB.default)(r).endOf(`month`).isBefore(d):!1,G=typeof j==`boolean`?j:u?!(0,MB.default)(r).startOf(`month`).isAfter(u):!1;return Z.createElement(Br,XV({className:ie(H.monthLevel,I),"data-month-level":!0,ref:t},re),Z.createElement(jB,XV({label:typeof L==`function`?L(r):(0,MB.default)(r).locale(i||U.locale).format(L),className:H.calendarHeader,__preventFocus:x,__stopPropagation:S,nextIcon:C,previousIcon:w,nextLabel:T,previousLabel:E,onNext:D,onPrevious:O,onLevelClick:k,nextDisabled:ae,previousDisabled:G,hasNextLevel:M,levelControlAriaLabel:N,withNext:P,withPrevious:F},W)),Z.createElement(WV,XV({month:r,locale:i,firstDayOfWeek:a,weekdayFormat:o,weekendDays:s,getDayProps:c,excludeDate:l,minDate:u,maxDate:d,renderDay:f,hideOutsideDates:p,hideWeekdays:m,getDayAriaLabel:h,__getDayRef:g,__onDayKeyDown:_,__onDayClick:v,__onDayMouseEnter:y,__preventFocus:x,__stopPropagation:S,static:ne,withCellSpacing:b},W)))});$V.displayName=`@mantine/dates/MonthLevel`;function eH({direction:e,levelIndex:t,rowIndex:n,cellIndex:r,size:i}){switch(e){case`up`:return t===0&&n===0?null:n===0?{levelIndex:t-1,rowIndex:r<=i[t-1][i[t-1].length-1]-1?i[t-1].length-1:i[t-1].length-2,cellIndex:r}:{levelIndex:t,rowIndex:n-1,cellIndex:r};case`down`:return n===i[t].length-1||n===i[t].length-2&&r>=i[t][i[t].length-1]?{levelIndex:t+1,rowIndex:0,cellIndex:r}:{levelIndex:t,rowIndex:n+1,cellIndex:r};case`left`:return t===0&&n===0&&r===0?null:n===0&&r===0?{levelIndex:t-1,rowIndex:i[t-1].length-1,cellIndex:i[t-1][i[t-1].length-1]-1}:r===0?{levelIndex:t,rowIndex:n-1,cellIndex:i[t][n-1]-1}:{levelIndex:t,rowIndex:n,cellIndex:r-1};case`right`:return n===i[t].length-1&&r===i[t][n]-1?{levelIndex:t+1,rowIndex:0,cellIndex:0}:r===i[t][n]-1?{levelIndex:t,rowIndex:n+1,cellIndex:0}:{levelIndex:t,rowIndex:n,cellIndex:r+1};default:return{levelIndex:t,rowIndex:n,cellIndex:r}}}function tH({controlsRef:e,direction:t,levelIndex:n,rowIndex:r,cellIndex:i,size:a}){let o=eH({direction:t,size:a,rowIndex:r,cellIndex:i,levelIndex:n});if(!o)return;let s=e.current[o.levelIndex]?.[o.rowIndex]?.[o.cellIndex];s&&(s.disabled||s.getAttribute(`data-hidden`)||s.getAttribute(`data-outside`)?tH({controlsRef:e,direction:t,levelIndex:o.levelIndex,cellIndex:o.cellIndex,rowIndex:o.rowIndex,size:a}):s.focus())}function nH(e){switch(e){case`ArrowDown`:return`down`;case`ArrowUp`:return`up`;case`ArrowRight`:return`right`;case`ArrowLeft`:return`left`;default:return null}}function rH(e){return e.current.map(e=>e.map(e=>e.length))}function iH({controlsRef:e,levelIndex:t,rowIndex:n,cellIndex:r,event:i}){let a=nH(i.key);a&&(i.preventDefault(),tH({controlsRef:e,direction:a,levelIndex:t,rowIndex:n,cellIndex:r,size:rH(e)}))}var aH=Object.defineProperty,oH=Object.getOwnPropertySymbols,sH=Object.prototype.hasOwnProperty,cH=Object.prototype.propertyIsEnumerable,lH=(e,t,n)=>t in e?aH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uH=(e,t)=>{for(var n in t||={})sH.call(t,n)&&lH(e,n,t[n]);if(oH)for(var n of oH(t))cH.call(t,n)&&lH(e,n,t[n]);return e},dH=(e,t)=>{var n={};for(var r in e)sH.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oH)for(var r of oH(e))t.indexOf(r)<0&&cH.call(e,r)&&(n[r]=e[r]);return n},fH={numberOfColumns:1},pH=(0,Z.forwardRef)((e,t)=>{let n=X(`MonthLevelGroup`,fH,e),{month:r,locale:i,firstDayOfWeek:a,weekdayFormat:o,weekendDays:s,getDayProps:c,excludeDate:l,minDate:u,maxDate:d,renderDay:f,hideOutsideDates:p,hideWeekdays:m,getDayAriaLabel:h,__onDayClick:g,__onDayMouseEnter:_,withCellSpacing:v,__preventFocus:y,nextIcon:b,previousIcon:x,nextLabel:S,previousLabel:C,onNext:w,onPrevious:T,onLevelClick:E,nextDisabled:D,previousDisabled:O,hasNextLevel:k,className:A,classNames:j,styles:M,unstyled:N,numberOfColumns:P,levelControlAriaLabel:F,monthLabelFormat:I,__staticSelector:L,__stopPropagation:R,size:z,variant:B,static:V}=n,ee=dH(n,`month.locale.firstDayOfWeek.weekdayFormat.weekendDays.getDayProps.excludeDate.minDate.maxDate.renderDay.hideOutsideDates.hideWeekdays.getDayAriaLabel.__onDayClick.__onDayMouseEnter.withCellSpacing.__preventFocus.nextIcon.previousIcon.nextLabel.previousLabel.onNext.onPrevious.onLevelClick.nextDisabled.previousDisabled.hasNextLevel.className.classNames.styles.unstyled.numberOfColumns.levelControlAriaLabel.monthLabelFormat.__staticSelector.__stopPropagation.size.variant.static`.split(`.`)),{classes:te,cx:ne}=LB(null,{name:[`MonthLevelGroup`,L],classNames:j,styles:M,unstyled:N,variant:B,size:z}),re=(0,Z.useRef)([]),H=Array(P).fill(0).map((e,t)=>{let n=(0,MB.default)(r).add(t,`months`).toDate();return Z.createElement($V,{key:t,month:n,withNext:t===P-1,withPrevious:t===0,monthLabelFormat:I,__stopPropagation:R,__onDayClick:g,__onDayMouseEnter:_,__onDayKeyDown:(e,n)=>iH({levelIndex:t,rowIndex:n.rowIndex,cellIndex:n.cellIndex,event:e,controlsRef:re}),__getDayRef:(e,n,r)=>{Array.isArray(re.current[t])||(re.current[t]=[]),Array.isArray(re.current[t][e])||(re.current[t][e]=[]),re.current[t][e][n]=r},levelControlAriaLabel:typeof F==`function`?F(n):F,locale:i,firstDayOfWeek:a,weekdayFormat:o,weekendDays:s,getDayProps:c,excludeDate:l,minDate:u,maxDate:d,renderDay:f,hideOutsideDates:p,hideWeekdays:m,getDayAriaLabel:h,__preventFocus:y,nextIcon:b,previousIcon:x,nextLabel:S,previousLabel:C,onNext:w,onPrevious:T,onLevelClick:E,nextDisabled:D,previousDisabled:O,hasNextLevel:k,classNames:j,styles:M,unstyled:N,__staticSelector:L||`MonthLevelGroup`,size:z,variant:B,static:V,withCellSpacing:v})});return Z.createElement(Br,uH({className:ne(te.monthLevelGroup,A),ref:t},ee),H)});pH.displayName=`@mantine/dates/MonthLevelGroup`;var mH=Ur((e,t,{size:n})=>({yearLevelGroup:{display:`flex`,"& [data-year-level]:not(:last-of-type)":{marginRight:J({size:n,sizes:e.spacing})}}})),hH=Ur(e=>({yearLevel:{},calendarHeader:{marginBottom:e.spacing.xs}}));function gH(e){let t=(0,MB.default)(e).startOf(`year`).toDate(),n=[[],[],[],[]],r=0;for(let e=0;e<4;e+=1)for(let i=0;i<3;i+=1)n[e].push((0,MB.default)(t).add(r,`months`).toDate()),r+=1;return n}function _H(e,t,n){return!t&&!n?!1:!!(t&&(0,MB.default)(e).isBefore(t,`month`)||n&&(0,MB.default)(e).isAfter(n,`month`))}var vH=Ur(()=>({monthsList:{borderCollapse:`collapse`,borderWidth:0,cursor:`pointer`},monthsListCell:{padding:0,"&[data-with-spacing]":{padding:Y(.5)}},monthsListRow:{}}));function yH(e,t,n,r){let i=e.flat().filter(e=>!_H(e,t,n)&&!r?.(e)?.disabled);return i.find(e=>r?.(e)?.selected)||i.find(e=>(0,MB.default)().isSame(e,`month`))||i[0]}var bH=Object.defineProperty,xH=Object.defineProperties,SH=Object.getOwnPropertyDescriptors,CH=Object.getOwnPropertySymbols,wH=Object.prototype.hasOwnProperty,TH=Object.prototype.propertyIsEnumerable,EH=(e,t,n)=>t in e?bH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,DH=(e,t)=>{for(var n in t||={})wH.call(t,n)&&EH(e,n,t[n]);if(CH)for(var n of CH(t))TH.call(t,n)&&EH(e,n,t[n]);return e},OH=(e,t)=>xH(e,SH(t)),kH=Ur((e,t,{size:n})=>{let r=e.fn.variant({variant:`filled`}),i=e.fn.variant({variant:`light`});return{pickerControl:OH(DH({fontSize:J({size:n,sizes:e.fontSizes}),height:J({size:n,sizes:dB}),width:`calc((${J({size:n,sizes:dB})} * 7) / 3 + ${Y(1.5)})`,display:`flex`,justifyContent:`center`,alignItems:`center`,userSelect:`none`,borderRadius:e.fn.radius()},e.fn.hover({backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[0]})),{"&:active":e.activeStyles,"&[data-in-range]":DH({backgroundColor:i.background,borderRadius:0},e.fn.hover({backgroundColor:i.hover})),"&[data-first-in-range]":{borderRadius:0,borderTopLeftRadius:e.radius.sm,borderBottomLeftRadius:e.radius.sm},"&[data-last-in-range]":{borderRadius:0,borderTopRightRadius:e.radius.sm,borderBottomRightRadius:e.radius.sm},"&[data-last-in-range][data-first-in-range]":{borderRadius:e.radius.sm},"&[data-selected]":DH({color:r.color,backgroundColor:r.background},e.fn.hover({backgroundColor:r.hover})),"&[data-disabled]":OH(DH({color:e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[4],cursor:`not-allowed`},e.fn.hover({backgroundColor:`transparent`})),{"&:active":{transform:`none`}})})}}),AH=Object.defineProperty,jH=Object.getOwnPropertySymbols,MH=Object.prototype.hasOwnProperty,NH=Object.prototype.propertyIsEnumerable,PH=(e,t,n)=>t in e?AH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,FH=(e,t)=>{for(var n in t||={})MH.call(t,n)&&PH(e,n,t[n]);if(jH)for(var n of jH(t))NH.call(t,n)&&PH(e,n,t[n]);return e},IH=(e,t)=>{var n={};for(var r in e)MH.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&jH)for(var r of jH(e))t.indexOf(r)<0&&NH.call(e,r)&&(n[r]=e[r]);return n},LH={size:`sm`},RH=(0,Z.forwardRef)((e,t)=>{let n=X(`PickerControl`,LH,e),{className:r,children:i,disabled:a,selected:o,classNames:s,styles:c,unstyled:l,firstInRange:u,lastInRange:d,inRange:f,__staticSelector:p,size:m,variant:h}=n,g=IH(n,[`className`,`children`,`disabled`,`selected`,`classNames`,`styles`,`unstyled`,`firstInRange`,`lastInRange`,`inRange`,`__staticSelector`,`size`,`variant`]),{classes:_,cx:v}=kH(null,{name:[`PickerControl`,p],classNames:s,styles:c,unstyled:l,variant:h,size:m});return Z.createElement(rf,FH({className:v(_.pickerControl,r),ref:t,unstyled:l,"data-picker-control":!0,"data-selected":o&&!a||void 0,"data-disabled":a||void 0,"data-in-range":f&&!a&&!o||void 0,"data-first-in-range":u&&!a||void 0,"data-last-in-range":d&&!a||void 0,disabled:a},g),i)});RH.displayName=`@mantine/dates/PickerControl`;var zH=Object.defineProperty,BH=Object.defineProperties,VH=Object.getOwnPropertyDescriptors,HH=Object.getOwnPropertySymbols,UH=Object.prototype.hasOwnProperty,WH=Object.prototype.propertyIsEnumerable,GH=(e,t,n)=>t in e?zH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,KH=(e,t)=>{for(var n in t||={})UH.call(t,n)&&GH(e,n,t[n]);if(HH)for(var n of HH(t))WH.call(t,n)&&GH(e,n,t[n]);return e},qH=(e,t)=>BH(e,VH(t)),JH=(e,t)=>{var n={};for(var r in e)UH.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&HH)for(var r of HH(e))t.indexOf(r)<0&&WH.call(e,r)&&(n[r]=e[r]);return n},YH={monthsListFormat:`MMM`,size:`sm`,withCellSpacing:!0},XH=(0,Z.forwardRef)((e,t)=>{let n=X(`MonthsList`,YH,e),{year:r,className:i,monthsListFormat:a,locale:o,minDate:s,maxDate:c,getMonthControlProps:l,classNames:u,styles:d,unstyled:f,__staticSelector:p,__getControlRef:m,__onControlKeyDown:h,__onControlClick:g,__onControlMouseEnter:_,__preventFocus:v,size:y,variant:b,__stopPropagation:x,withCellSpacing:S}=n,C=JH(n,[`year`,`className`,`monthsListFormat`,`locale`,`minDate`,`maxDate`,`getMonthControlProps`,`classNames`,`styles`,`unstyled`,`__staticSelector`,`__getControlRef`,`__onControlKeyDown`,`__onControlClick`,`__onControlMouseEnter`,`__preventFocus`,`size`,`variant`,`__stopPropagation`,`withCellSpacing`]),{classes:w,cx:T}=vH(null,{name:[`MonthsList`,p],classNames:u,styles:d,unstyled:f,variant:b,size:y}),E=YB(),D=gH(r),O=yH(D,s,c,l),k=D.map((e,t)=>{let n=e.map((e,n)=>{let r=l?.(e),i=(0,MB.default)(e).isSame(O,`month`);return Z.createElement(`td`,{key:n,className:w.monthsListCell,"data-with-spacing":S||void 0},Z.createElement(RH,qH(KH({variant:b,size:y,classNames:u,styles:d,unstyled:f,__staticSelector:p||`MonthsList`,"data-mantine-stop-propagation":x||void 0,disabled:_H(e,s,c),ref:e=>m?.(t,n,e)},r),{onKeyDown:i=>{var a;(a=r?.onKeyDown)==null||a.call(r,i),h?.(i,{rowIndex:t,cellIndex:n,date:e})},onClick:t=>{var n;(n=r?.onClick)==null||n.call(r,t),g?.(t,e)},onMouseEnter:t=>{var n;(n=r?.onMouseEnter)==null||n.call(r,t),_?.(t,e)},onMouseDown:e=>{var t;(t=r?.onMouseDown)==null||t.call(r,e),v&&e.preventDefault()},tabIndex:v||!i?-1:0}),(0,MB.default)(e).locale(E.getLocale(o)).format(a)))});return Z.createElement(`tr`,{key:t,className:w.monthsListRow},n)});return Z.createElement(Br,KH({component:`table`,ref:t,className:T(w.monthsList,i)},C),Z.createElement(`tbody`,null,k))});XH.displayName=`@mantine/dates/MonthsList`;var ZH=Object.defineProperty,QH=Object.getOwnPropertySymbols,$H=Object.prototype.hasOwnProperty,eU=Object.prototype.propertyIsEnumerable,tU=(e,t,n)=>t in e?ZH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nU=(e,t)=>{for(var n in t||={})$H.call(t,n)&&tU(e,n,t[n]);if(QH)for(var n of QH(t))eU.call(t,n)&&tU(e,n,t[n]);return e},rU=(e,t)=>{var n={};for(var r in e)$H.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&QH)for(var r of QH(e))t.indexOf(r)<0&&eU.call(e,r)&&(n[r]=e[r]);return n},iU={yearLabelFormat:`YYYY`,size:`sm`},aU=(0,Z.forwardRef)((e,t)=>{let n=X(`YearLevel`,iU,e),{year:r,locale:i,minDate:a,maxDate:o,monthsListFormat:s,getMonthControlProps:c,__getControlRef:l,__onControlKeyDown:u,__onControlClick:d,__onControlMouseEnter:f,withCellSpacing:p,__preventFocus:m,nextIcon:h,previousIcon:g,nextLabel:_,previousLabel:v,onNext:y,onPrevious:b,onLevelClick:x,nextDisabled:S,previousDisabled:C,hasNextLevel:w,levelControlAriaLabel:T,withNext:E,withPrevious:D,className:O,yearLabelFormat:k,classNames:A,styles:j,unstyled:M,__staticSelector:N,__stopPropagation:P,size:F,variant:I}=n,L=rU(n,`year.locale.minDate.maxDate.monthsListFormat.getMonthControlProps.__getControlRef.__onControlKeyDown.__onControlClick.__onControlMouseEnter.withCellSpacing.__preventFocus.nextIcon.previousIcon.nextLabel.previousLabel.onNext.onPrevious.onLevelClick.nextDisabled.previousDisabled.hasNextLevel.levelControlAriaLabel.withNext.withPrevious.className.yearLabelFormat.classNames.styles.unstyled.__staticSelector.__stopPropagation.size.variant`.split(`.`)),{classes:R,cx:z}=hH(null,{name:[`YearLevel`,N],classNames:A,styles:j,unstyled:M,size:F,variant:I}),B=YB(),V={__staticSelector:N||`YearLevel`,classNames:A,styles:j,unstyled:M,size:F,variant:I},ee=typeof S==`boolean`?S:o?!(0,MB.default)(r).endOf(`year`).isBefore(o):!1,te=typeof C==`boolean`?C:a?!(0,MB.default)(r).startOf(`year`).isAfter(a):!1;return Z.createElement(Br,nU({className:z(R.yearLevel,O),"data-year-level":!0,ref:t},L),Z.createElement(jB,nU({label:typeof k==`function`?k(r):(0,MB.default)(r).locale(i||B.locale).format(k),className:R.calendarHeader,__preventFocus:m,__stopPropagation:P,nextIcon:h,previousIcon:g,nextLabel:_,previousLabel:v,onNext:y,onPrevious:b,onLevelClick:x,nextDisabled:ee,previousDisabled:te,hasNextLevel:w,levelControlAriaLabel:T,withNext:E,withPrevious:D},V)),Z.createElement(XH,nU({year:r,locale:i,minDate:a,maxDate:o,monthsListFormat:s,getMonthControlProps:c,__getControlRef:l,__onControlKeyDown:u,__onControlClick:d,__onControlMouseEnter:f,__preventFocus:m,__stopPropagation:P,withCellSpacing:p},V)))});aU.displayName=`@mantine/dates/YearLevel`;var oU=Object.defineProperty,sU=Object.getOwnPropertySymbols,cU=Object.prototype.hasOwnProperty,lU=Object.prototype.propertyIsEnumerable,uU=(e,t,n)=>t in e?oU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dU=(e,t)=>{for(var n in t||={})cU.call(t,n)&&uU(e,n,t[n]);if(sU)for(var n of sU(t))lU.call(t,n)&&uU(e,n,t[n]);return e},fU=(e,t)=>{var n={};for(var r in e)cU.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&sU)for(var r of sU(e))t.indexOf(r)<0&&lU.call(e,r)&&(n[r]=e[r]);return n},pU={numberOfColumns:1,size:`sm`},mU=(0,Z.forwardRef)((e,t)=>{let n=X(`YearLevelGroup`,pU,e),{year:r,locale:i,minDate:a,maxDate:o,monthsListFormat:s,getMonthControlProps:c,__onControlClick:l,__onControlMouseEnter:u,withCellSpacing:d,__preventFocus:f,nextIcon:p,previousIcon:m,nextLabel:h,previousLabel:g,onNext:_,onPrevious:v,onLevelClick:y,nextDisabled:b,previousDisabled:x,hasNextLevel:S,className:C,classNames:w,styles:T,unstyled:E,__staticSelector:D,__stopPropagation:O,numberOfColumns:k,levelControlAriaLabel:A,yearLabelFormat:j,variant:M,size:N}=n,P=fU(n,`year.locale.minDate.maxDate.monthsListFormat.getMonthControlProps.__onControlClick.__onControlMouseEnter.withCellSpacing.__preventFocus.nextIcon.previousIcon.nextLabel.previousLabel.onNext.onPrevious.onLevelClick.nextDisabled.previousDisabled.hasNextLevel.className.classNames.styles.unstyled.__staticSelector.__stopPropagation.numberOfColumns.levelControlAriaLabel.yearLabelFormat.variant.size`.split(`.`)),{classes:F,cx:I}=mH(null,{name:[`YearLevelGroup`,D],styles:T,classNames:w,unstyled:E,variant:M,size:N}),L=(0,Z.useRef)([]),R=Array(k).fill(0).map((e,t)=>{let n=(0,MB.default)(r).add(t,`years`).toDate();return Z.createElement(aU,{key:t,variant:M,size:N,monthsListFormat:s,year:n,withNext:t===k-1,withPrevious:t===0,yearLabelFormat:j,__stopPropagation:O,__onControlClick:l,__onControlMouseEnter:u,__onControlKeyDown:(e,n)=>iH({levelIndex:t,rowIndex:n.rowIndex,cellIndex:n.cellIndex,event:e,controlsRef:L}),__getControlRef:(e,n,r)=>{Array.isArray(L.current[t])||(L.current[t]=[]),Array.isArray(L.current[t][e])||(L.current[t][e]=[]),L.current[t][e][n]=r},levelControlAriaLabel:typeof A==`function`?A(n):A,locale:i,minDate:a,maxDate:o,__preventFocus:f,nextIcon:p,previousIcon:m,nextLabel:h,previousLabel:g,onNext:_,onPrevious:v,onLevelClick:y,nextDisabled:b,previousDisabled:x,hasNextLevel:S,getMonthControlProps:c,classNames:w,styles:T,unstyled:E,__staticSelector:D||`YearLevelGroup`,withCellSpacing:d})});return Z.createElement(Br,dU({className:I(F.yearLevelGroup,C),ref:t},P),R)});mU.displayName=`@mantine/dates/YearLevelGroup`;var hU=Ur(e=>({decadeLevelGroup:{display:`flex`,gap:e.spacing.md}}));function gU(e){let t=e.getFullYear(),n=t-t%10,r=0,i=[[],[],[],[]];for(let e=0;e<4;e+=1){let t=e===3?1:3;for(let a=0;a<t;a+=1)i[e].push(new Date(n+r,0)),r+=1}return i}function _U(e){let t=gU(e);return[t[0][0],t[3][0]]}var vU=Ur(e=>({decadeLevel:{},calendarHeader:{marginBottom:e.spacing.xs}}));function yU(e,t,n){return!t&&!n?!1:!!(t&&(0,MB.default)(e).isBefore(t,`year`)||n&&(0,MB.default)(e).isAfter(n,`year`))}var bU=Ur(()=>({yearsList:{borderCollapse:`collapse`,borderWidth:0},yearsListCell:{padding:0,"&[data-with-spacing]":{padding:Y(.5)}},yearsListRow:{}}));function xU(e,t,n,r){let i=e.flat().filter(e=>!yU(e,t,n)&&!r?.(e)?.disabled);return i.find(e=>r?.(e)?.selected)||i.find(e=>(0,MB.default)().isSame(e,`year`))||i[0]}var SU=Object.defineProperty,CU=Object.defineProperties,wU=Object.getOwnPropertyDescriptors,TU=Object.getOwnPropertySymbols,EU=Object.prototype.hasOwnProperty,DU=Object.prototype.propertyIsEnumerable,OU=(e,t,n)=>t in e?SU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kU=(e,t)=>{for(var n in t||={})EU.call(t,n)&&OU(e,n,t[n]);if(TU)for(var n of TU(t))DU.call(t,n)&&OU(e,n,t[n]);return e},AU=(e,t)=>CU(e,wU(t)),jU=(e,t)=>{var n={};for(var r in e)EU.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&TU)for(var r of TU(e))t.indexOf(r)<0&&DU.call(e,r)&&(n[r]=e[r]);return n},MU={yearsListFormat:`YYYY`,size:`sm`,withCellSpacing:!0},NU=(0,Z.forwardRef)((e,t)=>{let n=X(`YearsList`,MU,e),{decade:r,className:i,yearsListFormat:a,locale:o,minDate:s,maxDate:c,getYearControlProps:l,classNames:u,styles:d,unstyled:f,__staticSelector:p,__getControlRef:m,__onControlKeyDown:h,__onControlClick:g,__onControlMouseEnter:_,__preventFocus:v,__stopPropagation:y,size:b,variant:x,withCellSpacing:S}=n,C=jU(n,[`decade`,`className`,`yearsListFormat`,`locale`,`minDate`,`maxDate`,`getYearControlProps`,`classNames`,`styles`,`unstyled`,`__staticSelector`,`__getControlRef`,`__onControlKeyDown`,`__onControlClick`,`__onControlMouseEnter`,`__preventFocus`,`__stopPropagation`,`size`,`variant`,`withCellSpacing`]),{classes:w,cx:T}=bU(null,{name:[`YearsList`,p],classNames:u,styles:d,unstyled:f,variant:x,size:b}),E=YB(),D=gU(r),O=xU(D,s,c,l),k=D.map((e,t)=>{let n=e.map((e,n)=>{let r=l?.(e),i=(0,MB.default)(e).isSame(O,`year`);return Z.createElement(`td`,{key:n,className:w.yearsListCell,"data-with-spacing":S||void 0},Z.createElement(RH,AU(kU({size:b,variant:x,classNames:u,styles:d,unstyled:f,__staticSelector:p||`YearsList`,"data-mantine-stop-propagation":y||void 0,disabled:yU(e,s,c),ref:e=>m?.(t,n,e)},r),{onKeyDown:i=>{var a;(a=r?.onKeyDown)==null||a.call(r,i),h?.(i,{rowIndex:t,cellIndex:n,date:e})},onClick:t=>{var n;(n=r?.onClick)==null||n.call(r,t),g?.(t,e)},onMouseEnter:t=>{var n;(n=r?.onMouseEnter)==null||n.call(r,t),_?.(t,e)},onMouseDown:e=>{var t;(t=r?.onMouseDown)==null||t.call(r,e),v&&e.preventDefault()},tabIndex:v||!i?-1:0}),(0,MB.default)(e).locale(E.getLocale(o)).format(a)))});return Z.createElement(`tr`,{key:t,className:w.yearsListRow},n)});return Z.createElement(Br,kU({component:`table`,ref:t,className:T(w.yearsList,i)},C),Z.createElement(`tbody`,null,k))});NU.displayName=`@mantine/dates/YearsList`;var PU=Object.defineProperty,FU=Object.getOwnPropertySymbols,IU=Object.prototype.hasOwnProperty,LU=Object.prototype.propertyIsEnumerable,RU=(e,t,n)=>t in e?PU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zU=(e,t)=>{for(var n in t||={})IU.call(t,n)&&RU(e,n,t[n]);if(FU)for(var n of FU(t))LU.call(t,n)&&RU(e,n,t[n]);return e},BU=(e,t)=>{var n={};for(var r in e)IU.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&FU)for(var r of FU(e))t.indexOf(r)<0&&LU.call(e,r)&&(n[r]=e[r]);return n},VU={decadeLabelFormat:`YYYY`},HU=(0,Z.forwardRef)((e,t)=>{let n=X(`DecadeLevel`,VU,e),{decade:r,locale:i,minDate:a,maxDate:o,yearsListFormat:s,getYearControlProps:c,__getControlRef:l,__onControlKeyDown:u,__onControlClick:d,__onControlMouseEnter:f,withCellSpacing:p,__preventFocus:m,nextIcon:h,previousIcon:g,nextLabel:_,previousLabel:v,onNext:y,onPrevious:b,nextDisabled:x,previousDisabled:S,levelControlAriaLabel:C,withNext:w,withPrevious:T,className:E,decadeLabelFormat:D,classNames:O,styles:k,unstyled:A,__staticSelector:j,__stopPropagation:M,variant:N,size:P}=n,F=BU(n,`decade.locale.minDate.maxDate.yearsListFormat.getYearControlProps.__getControlRef.__onControlKeyDown.__onControlClick.__onControlMouseEnter.withCellSpacing.__preventFocus.nextIcon.previousIcon.nextLabel.previousLabel.onNext.onPrevious.nextDisabled.previousDisabled.levelControlAriaLabel.withNext.withPrevious.className.decadeLabelFormat.classNames.styles.unstyled.__staticSelector.__stopPropagation.variant.size`.split(`.`)),{classes:I,cx:L}=vU(null,{name:[`DecadeLevel`,j],classNames:O,styles:k,unstyled:A,variant:N,size:P}),R=YB(),[z,B]=_U(r),V={__staticSelector:j||`DecadeLevel`,classNames:O,styles:k,unstyled:A,variant:N,size:P},ee=typeof x==`boolean`?x:o?!(0,MB.default)(B).endOf(`year`).isBefore(o):!1,te=typeof S==`boolean`?S:a?!(0,MB.default)(z).startOf(`year`).isAfter(a):!1,ne=(e,t)=>(0,MB.default)(e).locale(i||R.locale).format(t);return Z.createElement(Br,zU({className:L(I.decadeLevel,E),"data-decade-level":!0,ref:t},F),Z.createElement(jB,zU({label:typeof D==`function`?D(z,B):`${ne(z,D)} \u2013 ${ne(B,D)}`,className:I.calendarHeader,__preventFocus:m,__stopPropagation:M,nextIcon:h,previousIcon:g,nextLabel:_,previousLabel:v,onNext:y,onPrevious:b,nextDisabled:ee,previousDisabled:te,hasNextLevel:!1,levelControlAriaLabel:C,withNext:w,withPrevious:T},V)),Z.createElement(NU,zU({decade:r,locale:i,minDate:a,maxDate:o,yearsListFormat:s,getYearControlProps:c,__getControlRef:l,__onControlKeyDown:u,__onControlClick:d,__onControlMouseEnter:f,__preventFocus:m,__stopPropagation:M,withCellSpacing:p},V)))});HU.displayName=`@mantine/dates/DecadeLevel`;var UU=Object.defineProperty,WU=Object.getOwnPropertySymbols,GU=Object.prototype.hasOwnProperty,KU=Object.prototype.propertyIsEnumerable,qU=(e,t,n)=>t in e?UU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,JU=(e,t)=>{for(var n in t||={})GU.call(t,n)&&qU(e,n,t[n]);if(WU)for(var n of WU(t))KU.call(t,n)&&qU(e,n,t[n]);return e},YU=(e,t)=>{var n={};for(var r in e)GU.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&WU)for(var r of WU(e))t.indexOf(r)<0&&KU.call(e,r)&&(n[r]=e[r]);return n},XU={numberOfColumns:1},ZU=(0,Z.forwardRef)((e,t)=>{let n=X(`DecadeLevelGroup`,XU,e),{decade:r,locale:i,minDate:a,maxDate:o,yearsListFormat:s,getYearControlProps:c,__onControlClick:l,__onControlMouseEnter:u,withCellSpacing:d,__preventFocus:f,nextIcon:p,previousIcon:m,nextLabel:h,previousLabel:g,onNext:_,onPrevious:v,nextDisabled:y,previousDisabled:b,className:x,classNames:S,styles:C,unstyled:w,__staticSelector:T,__stopPropagation:E,numberOfColumns:D,levelControlAriaLabel:O,decadeLabelFormat:k,variant:A,size:j}=n,M=YU(n,`decade.locale.minDate.maxDate.yearsListFormat.getYearControlProps.__onControlClick.__onControlMouseEnter.withCellSpacing.__preventFocus.nextIcon.previousIcon.nextLabel.previousLabel.onNext.onPrevious.nextDisabled.previousDisabled.className.classNames.styles.unstyled.__staticSelector.__stopPropagation.numberOfColumns.levelControlAriaLabel.decadeLabelFormat.variant.size`.split(`.`)),{classes:N,cx:P}=hU(null,{name:[`DecadeLevelGroup`,T],styles:C,classNames:S,unstyled:w,variant:A,size:j}),F=(0,Z.useRef)([]),I=Array(D).fill(0).map((e,t)=>{let n=(0,MB.default)(r).add(t*10,`years`).toDate();return Z.createElement(HU,{key:t,variant:A,size:j,yearsListFormat:s,decade:n,withNext:t===D-1,withPrevious:t===0,decadeLabelFormat:k,__onControlClick:l,__onControlMouseEnter:u,__onControlKeyDown:(e,n)=>iH({levelIndex:t,rowIndex:n.rowIndex,cellIndex:n.cellIndex,event:e,controlsRef:F}),__getControlRef:(e,n,r)=>{Array.isArray(F.current[t])||(F.current[t]=[]),Array.isArray(F.current[t][e])||(F.current[t][e]=[]),F.current[t][e][n]=r},levelControlAriaLabel:typeof O==`function`?O(n):O,locale:i,minDate:a,maxDate:o,__preventFocus:f,__stopPropagation:E,nextIcon:p,previousIcon:m,nextLabel:h,previousLabel:g,onNext:_,onPrevious:v,nextDisabled:y,previousDisabled:b,getYearControlProps:c,__staticSelector:T||`DecadeLevelGroup`,classNames:S,styles:C,unstyled:w,withCellSpacing:d})});return Z.createElement(Br,JU({className:P(N.decadeLevelGroup,x),ref:t},M),I)});ZU.displayName=`@mantine/dates/DecadeLevelGroup`;var QU=Object.defineProperty,$U=Object.getOwnPropertySymbols,eW=Object.prototype.hasOwnProperty,tW=Object.prototype.propertyIsEnumerable,nW=(e,t,n)=>t in e?QU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rW=(e,t)=>{for(var n in t||={})eW.call(t,n)&&nW(e,n,t[n]);if($U)for(var n of $U(t))tW.call(t,n)&&nW(e,n,t[n]);return e},iW=(e,t)=>{var n={};for(var r in e)eW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&$U)for(var r of $U(e))t.indexOf(r)<0&&tW.call(e,r)&&(n[r]=e[r]);return n},aW={maxLevel:`decade`,minLevel:`month`,__updateDateOnYearSelect:!0,__updateDateOnMonthSelect:!0},oW=(0,Z.forwardRef)((e,t)=>{let n=X(`Calendar`,aW,e),{maxLevel:r,minLevel:i,defaultLevel:a,level:o,onLevelChange:s,date:c,defaultDate:l,onDateChange:u,numberOfColumns:d,columnsToScroll:f,ariaLabels:p,onYearSelect:m,onMonthSelect:h,onYearMouseEnter:g,onMonthMouseEnter:_,__updateDateOnYearSelect:v,__updateDateOnMonthSelect:y,firstDayOfWeek:b,weekdayFormat:x,weekendDays:S,getDayProps:C,excludeDate:w,renderDay:T,hideOutsideDates:E,hideWeekdays:D,getDayAriaLabel:O,monthLabelFormat:k,nextIcon:A,previousIcon:j,__onDayClick:M,__onDayMouseEnter:N,withCellSpacing:P,monthsListFormat:F,getMonthControlProps:I,yearLabelFormat:L,yearsListFormat:R,getYearControlProps:z,decadeLabelFormat:B,minDate:V,maxDate:ee,locale:te,className:ne,classNames:re,styles:H,__staticSelector:ie,unstyled:U,variant:W,size:ae,__preventFocus:G,__stopPropagation:oe,onNextDecade:se,onPreviousDecade:ce,onNextYear:le,onPreviousYear:ue,onNextMonth:de,onPreviousMonth:fe,static:pe}=n,me=iW(n,`maxLevel.minLevel.defaultLevel.level.onLevelChange.date.defaultDate.onDateChange.numberOfColumns.columnsToScroll.ariaLabels.onYearSelect.onMonthSelect.onYearMouseEnter.onMonthMouseEnter.__updateDateOnYearSelect.__updateDateOnMonthSelect.firstDayOfWeek.weekdayFormat.weekendDays.getDayProps.excludeDate.renderDay.hideOutsideDates.hideWeekdays.getDayAriaLabel.monthLabelFormat.nextIcon.previousIcon.__onDayClick.__onDayMouseEnter.withCellSpacing.monthsListFormat.getMonthControlProps.yearLabelFormat.yearsListFormat.getYearControlProps.decadeLabelFormat.minDate.maxDate.locale.className.classNames.styles.__staticSelector.unstyled.variant.size.__preventFocus.__stopPropagation.onNextDecade.onPreviousDecade.onNextYear.onPreviousYear.onNextMonth.onPreviousMonth.static`.split(`.`)),{classes:he,cx:ge}=IB(null,{name:[`Calendar`,ie],classNames:re,styles:H,unstyled:U,variant:W,size:ae}),[_e,ve]=Od({value:o?FB(o,i,r):void 0,defaultValue:a?FB(a,i,r):void 0,finalValue:FB(void 0,i,r),onChange:s}),[ye,be]=Od({value:c,defaultValue:l,finalValue:null,onChange:u}),xe={__staticSelector:ie||`Calendar`,styles:H,classNames:re,unstyled:U,variant:W,size:ae},Se=f||d||1,Ce=ye||new Date;return Z.createElement(Br,rW({className:ge(he.calendar,ne),ref:t},me),_e===`month`&&Z.createElement(pH,rW({month:Ce,minDate:V,maxDate:ee,firstDayOfWeek:b,weekdayFormat:x,weekendDays:S,getDayProps:C,excludeDate:w,renderDay:T,hideOutsideDates:E,hideWeekdays:D,getDayAriaLabel:O,onNext:()=>{let e=(0,MB.default)(Ce).add(Se,`month`).toDate();de?.(e),be(e)},onPrevious:()=>{let e=(0,MB.default)(Ce).subtract(Se,`month`).toDate();fe?.(e),be(e)},hasNextLevel:r!==`month`,onLevelClick:()=>ve(`year`),numberOfColumns:d,locale:te,levelControlAriaLabel:p?.monthLevelControl,nextLabel:p?.nextMonth,nextIcon:A,previousLabel:p?.previousMonth,previousIcon:j,monthLabelFormat:k,__onDayClick:M,__onDayMouseEnter:N,__preventFocus:G,__stopPropagation:oe,static:pe,withCellSpacing:P},xe)),_e===`year`&&Z.createElement(mU,rW({year:Ce,numberOfColumns:d,minDate:V,maxDate:ee,monthsListFormat:F,getMonthControlProps:I,locale:te,onNext:()=>{let e=(0,MB.default)(Ce).add(Se,`year`).toDate();le?.(e),be(e)},onPrevious:()=>{let e=(0,MB.default)(Ce).subtract(Se,`year`).toDate();ue?.(e),be(e)},hasNextLevel:r!==`month`&&r!==`year`,onLevelClick:()=>ve(`decade`),levelControlAriaLabel:p?.yearLevelControl,nextLabel:p?.nextYear,nextIcon:A,previousLabel:p?.previousYear,previousIcon:j,yearLabelFormat:L,__onControlMouseEnter:_,__onControlClick:(e,t)=>{y&&be(t),ve(FB(`month`,i,r)),h?.(t)},__preventFocus:G,__stopPropagation:oe,withCellSpacing:P},xe)),_e===`decade`&&Z.createElement(ZU,rW({decade:Ce,minDate:V,maxDate:ee,yearsListFormat:R,getYearControlProps:z,locale:te,onNext:()=>{let e=(0,MB.default)(Ce).add(10*Se,`year`).toDate();se?.(e),be(e)},onPrevious:()=>{let e=(0,MB.default)(Ce).subtract(10*Se,`year`).toDate();ce?.(e),be(e)},numberOfColumns:d,nextLabel:p?.nextDecade,nextIcon:A,previousLabel:p?.previousDecade,previousIcon:j,decadeLabelFormat:B,__onControlMouseEnter:g,__onControlClick:(e,t)=>{v&&be(t),ve(FB(`year`,i,r)),m?.(t)},__preventFocus:G,__stopPropagation:oe,withCellSpacing:P},xe)))});oW.displayName=`@mantine/dates/Calendar`;var sW=Object.getOwnPropertySymbols,cW=Object.prototype.hasOwnProperty,lW=Object.prototype.propertyIsEnumerable,uW=(e,t)=>{var n={};for(var r in e)cW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&sW)for(var r of sW(e))t.indexOf(r)<0&&lW.call(e,r)&&(n[r]=e[r]);return n};function dW(e){let t=e,{maxLevel:n,minLevel:r,defaultLevel:i,level:a,onLevelChange:o,nextIcon:s,previousIcon:c,date:l,defaultDate:u,onDateChange:d,numberOfColumns:f,columnsToScroll:p,ariaLabels:m,onYearSelect:h,onMonthSelect:g,onYearMouseEnter:_,onMonthMouseEnter:v,onNextMonth:y,onPreviousMonth:b,onNextYear:x,onPreviousYear:S,onNextDecade:C,onPreviousDecade:w,withCellSpacing:T,__updateDateOnYearSelect:E,__updateDateOnMonthSelect:D,firstDayOfWeek:O,weekdayFormat:k,weekendDays:A,getDayProps:j,excludeDate:M,renderDay:N,hideOutsideDates:P,hideWeekdays:F,getDayAriaLabel:I,monthLabelFormat:L,monthsListFormat:R,getMonthControlProps:z,yearLabelFormat:B,yearsListFormat:V,getYearControlProps:ee,decadeLabelFormat:te,allowSingleDateInRange:ne,allowDeselect:re,minDate:H,maxDate:ie,locale:U}=t,W=uW(t,`maxLevel.minLevel.defaultLevel.level.onLevelChange.nextIcon.previousIcon.date.defaultDate.onDateChange.numberOfColumns.columnsToScroll.ariaLabels.onYearSelect.onMonthSelect.onYearMouseEnter.onMonthMouseEnter.onNextMonth.onPreviousMonth.onNextYear.onPreviousYear.onNextDecade.onPreviousDecade.withCellSpacing.__updateDateOnYearSelect.__updateDateOnMonthSelect.firstDayOfWeek.weekdayFormat.weekendDays.getDayProps.excludeDate.renderDay.hideOutsideDates.hideWeekdays.getDayAriaLabel.monthLabelFormat.monthsListFormat.getMonthControlProps.yearLabelFormat.yearsListFormat.getYearControlProps.decadeLabelFormat.allowSingleDateInRange.allowDeselect.minDate.maxDate.locale`.split(`.`));return{calendarProps:{maxLevel:n,minLevel:r,defaultLevel:i,level:a,onLevelChange:o,nextIcon:s,previousIcon:c,date:l,defaultDate:u,onDateChange:d,numberOfColumns:f,columnsToScroll:p,ariaLabels:m,onYearSelect:h,onMonthSelect:g,onYearMouseEnter:_,onMonthMouseEnter:v,onNextMonth:y,onPreviousMonth:b,onNextYear:x,onPreviousYear:S,onNextDecade:C,onPreviousDecade:w,withCellSpacing:T,__updateDateOnYearSelect:E,__updateDateOnMonthSelect:D,firstDayOfWeek:O,weekdayFormat:k,weekendDays:A,getDayProps:j,excludeDate:M,renderDay:N,hideOutsideDates:P,hideWeekdays:F,getDayAriaLabel:I,monthLabelFormat:L,monthsListFormat:R,getMonthControlProps:z,yearLabelFormat:B,yearsListFormat:V,getYearControlProps:ee,decadeLabelFormat:te,allowSingleDateInRange:ne,allowDeselect:re,minDate:H,maxDate:ie,locale:U},others:W}}function fW(e,t){if(t===`range`&&Array.isArray(e)){let[t,n]=e;return t?n?`${t.toISOString()} \u2013 ${n.toISOString()}`:`${t.toISOString()} \u2013`:``}return t===`multiple`&&Array.isArray(e)?e.map(e=>e.toISOString()).join(`, `):!Array.isArray(e)&&e?e.toISOString():``}function pW({value:e,type:t,name:n,form:r}){return Z.createElement(`input`,{type:`hidden`,value:fW(e,t),name:n,form:r})}pW.displayName=`@mantine/dates/HiddenDatesInput`;var mW=e=>e===`range`?[null,null]:e===`multiple`?[]:null;function hW({type:e,value:t,defaultValue:n,onChange:r}){let i=(0,Z.useRef)(e),[a,o]=Od({value:t,defaultValue:n,onChange:r,finalValue:mW(e)}),s=a;return i.current!==e&&(i.current=e,t===void 0&&(s=n===void 0?mW(e):n,o(s))),[s,o]}function gW(e,t){let n=[...t].sort((e,t)=>e.getTime()-t.getTime());return(0,MB.default)(n[0]).startOf(`day`).subtract(1,`ms`).isBefore(e)&&(0,MB.default)(n[1]).endOf(`day`).add(1,`ms`).isAfter(e)}function _W({type:e,level:t,value:n,defaultValue:r,onChange:i,allowSingleDateInRange:a,allowDeselect:o,onMouseLeave:s}){let[c,l]=hW({type:e,value:n,defaultValue:r,onChange:i}),[u,d]=(0,Z.useState)(e===`range`&&c[0]&&!c[1]?c[0]:null),[f,p]=(0,Z.useState)(null),m=n=>{if(e===`range`){if(u instanceof Date&&!c[1]){if((0,MB.default)(n).isSame(u,t)&&!a){d(null),p(null),l([null,null]);return}let e=[n,u];e.sort((e,t)=>e.getTime()-t.getTime()),l(e),p(null),d(null);return}if(c[0]&&!c[1]&&(0,MB.default)(n).isSame(c[0],t)&&!a){d(null),p(null),l([null,null]);return}l([n,null]),p(null),d(n);return}if(e===`multiple`){c.some(e=>(0,MB.default)(e).isSame(n,t))?l(c.filter(e=>!(0,MB.default)(e).isSame(n,t))):l([...c,n]);return}c&&o&&(0,MB.default)(n).isSame(c,t)?l(null):l(n)},h=e=>u instanceof Date&&f instanceof Date?gW(e,[f,u]):c[0]instanceof Date&&c[1]instanceof Date&&gW(e,c),g=e===`range`?e=>{s?.(e),p(null)}:s,_=e=>c[0]instanceof Date&&(0,MB.default)(e).isSame(c[0],t)?!(f&&(0,MB.default)(f).isBefore(c[0])):!1,v=e=>c[1]instanceof Date?(0,MB.default)(e).isSame(c[1],t):!(c[0]instanceof Date)||!f?!1:(0,MB.default)(f).isBefore(c[0])&&(0,MB.default)(e).isSame(c[0],t);return{onDateChange:m,onRootMouseLeave:g,onHoveredDateChange:e===`range`&&u?p:()=>{},getControlProps:n=>{if(e===`range`)return{selected:c.some(e=>e&&(0,MB.default)(e).isSame(n,t)),inRange:h(n),firstInRange:_(n),lastInRange:v(n),"data-autofocus":!!c[0]&&(0,MB.default)(c[0]).isSame(n,t)||void 0};if(e===`multiple`)return{selected:c.some(e=>e&&(0,MB.default)(e).isSame(n,t)),"data-autofocus":!!c[0]&&(0,MB.default)(c[0]).isSame(n,t)||void 0};let r=(0,MB.default)(c).isSame(n,t);return{selected:r,"data-autofocus":r||void 0}},_value:c,setValue:l}}function vW({type:e,date:t,locale:n,format:r,labelSeparator:i}){let a=e=>(0,MB.default)(e).locale(n).format(r);return e==="default"?t===null?``:a(t):e===`multiple`?t.map(a).join(`, `):e===`range`?t[0]&&t[1]?`${a(t[0])} ${i} ${a(t[1])}`:t[0]?`${a(t[0])} ${i} `:``:``}function yW({type:e,value:t,defaultValue:n,onChange:r,locale:i,format:a,closeOnChange:o,sortDates:s,labelSeparator:c}){let l=YB(),[u,d]=Ld(!1),[f,p]=hW({type:e,value:t,defaultValue:n,onChange:r}),m=vW({type:e,date:f,locale:l.getLocale(i),format:a,labelSeparator:l.getLabelSeparator(c)}),h=t=>{o&&(e==="default"&&d.close(),e===`range`&&t[0]&&t[1]&&d.close()),p(s&&e===`multiple`?[...t].sort((e,t)=>e.getTime()-t.getTime()):t)};return{_value:f,setValue:h,onClear:()=>h(e===`range`?[null,null]:e===`multiple`?[]:null),shouldClear:e===`range`?!!f[0]:e===`multiple`?f.length>0:f!==null,formattedValue:m,dropdownOpened:u,dropdownHandlers:d}}function bW({minDate:e,maxDate:t}){let n=new Date;return!e&&!t?n:(0,MB.default)(n).isBefore(e)?e:(0,MB.default)(n).isAfter(t)?t:n}var xW=Ur(()=>({placeholder:{},input:{cursor:`pointer`,lineHeight:`unset`,"&[data-read-only]":{cursor:`default`}}})),SW=Object.defineProperty,CW=Object.defineProperties,wW=Object.getOwnPropertyDescriptors,TW=Object.getOwnPropertySymbols,EW=Object.prototype.hasOwnProperty,DW=Object.prototype.propertyIsEnumerable,OW=(e,t,n)=>t in e?SW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kW=(e,t)=>{for(var n in t||={})EW.call(t,n)&&OW(e,n,t[n]);if(TW)for(var n of TW(t))DW.call(t,n)&&OW(e,n,t[n]);return e},AW=(e,t)=>CW(e,wW(t)),jW=(e,t)=>{var n={};for(var r in e)EW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&TW)for(var r of TW(e))t.indexOf(r)<0&&DW.call(e,r)&&(n[r]=e[r]);return n},MW={},NW=(0,Z.forwardRef)((e,t)=>{let n=Sv(`PickerInputBase`,MW,e),{inputProps:r,wrapperProps:i,placeholder:a,classNames:o,styles:s,unstyled:c,popoverProps:l,modalProps:u,dropdownType:d,children:f,formattedValue:p,dropdownHandlers:m,dropdownOpened:h,onClick:g,clearable:_,onClear:v,clearButtonProps:y,rightSection:b,shouldClear:x,readOnly:S,disabled:C,value:w,name:T,form:E,type:D}=n,O=jW(n,[`inputProps`,`wrapperProps`,`placeholder`,`classNames`,`styles`,`unstyled`,`popoverProps`,`modalProps`,`dropdownType`,`children`,`formattedValue`,`dropdownHandlers`,`dropdownOpened`,`onClick`,`clearable`,`onClear`,`clearButtonProps`,`rightSection`,`shouldClear`,`readOnly`,`disabled`,`value`,`name`,`form`,`type`]),{classes:k,cx:A}=xW(null,{name:r.__staticSelector,classNames:o,styles:s,unstyled:c,variant:r.variant,size:r.size}),j=b||(_&&x&&!S&&!C?Z.createElement(bp,kW({variant:`transparent`,onClick:v,unstyled:c,size:r.size},y)):null),M=()=>{D===`range`&&w[0]&&!w[1]&&v(),m.close()},N=i.label;return Z.createElement(Z.Fragment,null,d===`modal`&&!S&&Z.createElement(TD,kW({opened:h,onClose:M,withCloseButton:!1,size:`auto`,"data-dates-modal":!0,unstyled:c},u),f),Z.createElement(ab.Wrapper,kW({},i),Z.createElement(nv,kW({position:`bottom-start`,opened:h,onClose:M,disabled:d===`modal`||S,trapFocus:!0,returnFocus:!0,unstyled:c},l),Z.createElement(nv.Target,{shouldOverrideDefaultTargetId:!N},Z.createElement(ab,kW(AW(kW({"aria-label":p,"data-dates-input":!0,"data-read-only":S||void 0,disabled:C,component:`button`,type:`button`,multiline:!0,onClick:e=>{g?.(e),m.toggle()},rightSection:j},r),{ref:t,classNames:AW(kW({},o),{input:A(k.input,o?.input)})}),O),p||Z.createElement(ab.Placeholder,{className:k.placeholder,sx:{color:r.error?`inherit`:void 0}},a))),Z.createElement(nv.Dropdown,{"data-dates-dropdown":!0},f))),Z.createElement(pW,{value:w,name:T,form:E,type:D}))});NW.displayName=`@mantine/dates/PickerInputBase`;var PW=Object.defineProperty,FW=Object.getOwnPropertySymbols,IW=Object.prototype.hasOwnProperty,LW=Object.prototype.propertyIsEnumerable,RW=(e,t,n)=>t in e?PW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zW=(e,t)=>{for(var n in t||={})IW.call(t,n)&&RW(e,n,t[n]);if(FW)for(var n of FW(t))LW.call(t,n)&&RW(e,n,t[n]);return e},BW=(e,t)=>{var n={};for(var r in e)IW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&FW)for(var r of FW(e))t.indexOf(r)<0&&LW.call(e,r)&&(n[r]=e[r]);return n},VW={type:`default`},HW=(0,Z.forwardRef)((e,t)=>{let n=X(`MonthPicker`,VW,e),{type:r,defaultValue:i,value:a,onChange:o,__staticSelector:s,getMonthControlProps:c,allowSingleDateInRange:l,allowDeselect:u,onMouseLeave:d,onMonthSelect:f}=n,p=BW(n,[`type`,`defaultValue`,`value`,`onChange`,`__staticSelector`,`getMonthControlProps`,`allowSingleDateInRange`,`allowDeselect`,`onMouseLeave`,`onMonthSelect`]),{onDateChange:m,onRootMouseLeave:h,onHoveredDateChange:g,getControlProps:_}=_W({type:r,level:`month`,allowDeselect:u,allowSingleDateInRange:l,value:a,defaultValue:i,onChange:o,onMouseLeave:d});return Z.createElement(oW,zW({ref:t,minLevel:`year`,__updateDateOnMonthSelect:!1,__staticSelector:s||`MonthPicker`,onMouseLeave:h,onMonthMouseEnter:(e,t)=>g(t),onMonthSelect:e=>{m(e),f?.(e)},getMonthControlProps:e=>zW(zW({},_(e)),c?.(e))},p))});HW.displayName=`@mantine/dates/MonthPicker`;var UW=Object.defineProperty,WW=Object.defineProperties,GW=Object.getOwnPropertyDescriptors,KW=Object.getOwnPropertySymbols,qW=Object.prototype.hasOwnProperty,JW=Object.prototype.propertyIsEnumerable,YW=(e,t,n)=>t in e?UW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,XW=(e,t)=>{for(var n in t||={})qW.call(t,n)&&YW(e,n,t[n]);if(KW)for(var n of KW(t))JW.call(t,n)&&YW(e,n,t[n]);return e},ZW=(e,t)=>WW(e,GW(t)),QW=(e,t)=>{var n={};for(var r in e)qW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&KW)for(var r of KW(e))t.indexOf(r)<0&&JW.call(e,r)&&(n[r]=e[r]);return n},$W={type:`default`,valueFormat:`MMMM YYYY`,closeOnChange:!0,sortDates:!0,dropdownType:`popover`},eG=(0,Z.forwardRef)((e,t)=>{let n=X(`MonthPickerInput`,$W,e),{type:r,value:i,defaultValue:a,onChange:o,valueFormat:s,labelSeparator:c,locale:l,classNames:u,styles:d,unstyled:f,closeOnChange:p,variant:m,size:h,dropdownType:g,sortDates:_,minDate:v,maxDate:y}=n,{calendarProps:b,others:x}=dW(QW(n,[`type`,`value`,`defaultValue`,`onChange`,`valueFormat`,`labelSeparator`,`locale`,`classNames`,`styles`,`unstyled`,`closeOnChange`,`variant`,`size`,`dropdownType`,`sortDates`,`minDate`,`maxDate`])),{_value:S,setValue:C,formattedValue:w,dropdownHandlers:T,dropdownOpened:E,onClear:D,shouldClear:O}=yW({type:r,value:i,defaultValue:a,onChange:o,locale:l,format:s,labelSeparator:c,closeOnChange:p,sortDates:_});return Z.createElement(NW,XW({formattedValue:w,dropdownOpened:E,dropdownHandlers:T,classNames:u,styles:d,unstyled:f,__staticSelector:`MonthPickerInput`,ref:t,onClear:D,shouldClear:O,value:S,type:r,variant:m,size:h,dropdownType:g},x),Z.createElement(HW,ZW(XW({},b),{type:r,value:S,defaultDate:Array.isArray(S)?S[0]||bW({maxDate:y,minDate:v}):S||bW({maxDate:y,minDate:v}),onChange:C,locale:l,classNames:u,styles:d,unstyled:f,__staticSelector:`MonthPickerInput`,__stopPropagation:g===`popover`,variant:m,size:h,minDate:v,maxDate:y})))});eG.displayName=`@mantine/dates/MonthPickerInput`;var tG=Object.defineProperty,nG=Object.getOwnPropertySymbols,rG=Object.prototype.hasOwnProperty,iG=Object.prototype.propertyIsEnumerable,aG=(e,t,n)=>t in e?tG(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oG=(e,t)=>{for(var n in t||={})rG.call(t,n)&&aG(e,n,t[n]);if(nG)for(var n of nG(t))iG.call(t,n)&&aG(e,n,t[n]);return e},sG=(e,t)=>{var n={};for(var r in e)rG.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&nG)for(var r of nG(e))t.indexOf(r)<0&&iG.call(e,r)&&(n[r]=e[r]);return n},cG={type:`default`},lG=(0,Z.forwardRef)((e,t)=>{let n=X(`YearPicker`,cG,e),{type:r,defaultValue:i,value:a,onChange:o,__staticSelector:s,getYearControlProps:c,allowSingleDateInRange:l,allowDeselect:u,onMouseLeave:d,onYearSelect:f}=n,p=sG(n,[`type`,`defaultValue`,`value`,`onChange`,`__staticSelector`,`getYearControlProps`,`allowSingleDateInRange`,`allowDeselect`,`onMouseLeave`,`onYearSelect`]),{onDateChange:m,onRootMouseLeave:h,onHoveredDateChange:g,getControlProps:_}=_W({type:r,level:`year`,allowDeselect:u,allowSingleDateInRange:l,value:a,defaultValue:i,onChange:o,onMouseLeave:d});return Z.createElement(oW,oG({ref:t,minLevel:`decade`,__updateDateOnYearSelect:!1,__staticSelector:s||`YearPicker`,onMouseLeave:h,onYearMouseEnter:(e,t)=>g(t),onYearSelect:e=>{m(e),f?.(e)},getYearControlProps:e=>oG(oG({},_(e)),c?.(e))},p))});lG.displayName=`@mantine/dates/YearPicker`;var uG=Object.defineProperty,dG=Object.defineProperties,fG=Object.getOwnPropertyDescriptors,pG=Object.getOwnPropertySymbols,mG=Object.prototype.hasOwnProperty,hG=Object.prototype.propertyIsEnumerable,gG=(e,t,n)=>t in e?uG(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_G=(e,t)=>{for(var n in t||={})mG.call(t,n)&&gG(e,n,t[n]);if(pG)for(var n of pG(t))hG.call(t,n)&&gG(e,n,t[n]);return e},vG=(e,t)=>dG(e,fG(t)),yG=(e,t)=>{var n={};for(var r in e)mG.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&pG)for(var r of pG(e))t.indexOf(r)<0&&hG.call(e,r)&&(n[r]=e[r]);return n},bG={type:`default`,valueFormat:`YYYY`,closeOnChange:!0,sortDates:!0,dropdownType:`popover`},xG=(0,Z.forwardRef)((e,t)=>{let n=X(`YearPickerInput`,bG,e),{type:r,value:i,defaultValue:a,onChange:o,valueFormat:s,labelSeparator:c,locale:l,classNames:u,styles:d,unstyled:f,closeOnChange:p,size:m,variant:h,dropdownType:g,sortDates:_,minDate:v,maxDate:y}=n,{calendarProps:b,others:x}=dW(yG(n,[`type`,`value`,`defaultValue`,`onChange`,`valueFormat`,`labelSeparator`,`locale`,`classNames`,`styles`,`unstyled`,`closeOnChange`,`size`,`variant`,`dropdownType`,`sortDates`,`minDate`,`maxDate`])),{_value:S,setValue:C,formattedValue:w,dropdownHandlers:T,dropdownOpened:E,onClear:D,shouldClear:O}=yW({type:r,value:i,defaultValue:a,onChange:o,locale:l,format:s,labelSeparator:c,closeOnChange:p,sortDates:_});return Z.createElement(NW,_G({formattedValue:w,dropdownOpened:E,dropdownHandlers:T,classNames:u,styles:d,unstyled:f,__staticSelector:`YearPickerInput`,ref:t,onClear:D,shouldClear:O,value:S,type:r,size:m,variant:h,dropdownType:g},x),Z.createElement(lG,vG(_G({},b),{size:m,variant:h,type:r,value:S,defaultDate:Array.isArray(S)?S[0]||bW({maxDate:y,minDate:v}):S||bW({maxDate:y,minDate:v}),onChange:C,locale:l,classNames:u,styles:d,unstyled:f,__staticSelector:`YearPickerInput`,__stopPropagation:g===`popover`,minDate:v,maxDate:y})))});xG.displayName=`@mantine/dates/YearPickerInput`;var SG=()=>{let[{data:e,fetching:t,error:n},r]=W({query:M});n&&(console.error(`Error fetching financial entities: ${n}`),K.error(`Error`,{description:`Unable to fetch financial entities`}));let i=(0,Z.useMemo)(()=>e?.allFinancialEntities?.nodes.sort((e,t)=>e.name>t.name?1:-1)??[],[e]);return{fetching:t,refresh:()=>r(),financialEntities:i,selectableFinancialEntities:(0,Z.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i])}},CG=({formManager:e,document:t,defaultCurrency:n})=>{let{control:r,watch:i,trigger:a}=e,[o,s]=(0,Z.useState)(!1),c=Fk(),{selectableFinancialEntities:l,fetching:u}=SG(),d=t??void 0,f=i(`documentType`);return(0,Z.useEffect)(()=>{s(!!f&&(f===Ve.Invoice||f===Ve.Receipt||f===Ve.InvoiceReceipt||f===Ve.Proforma||f===Ve.CreditInvoice))},[f]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{name:`documentType`,control:r,rules:{required:`Required`},defaultValue:t?.documentType??Ve.Unprocessed,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Type`}),(0,Q.jsxs)(wn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,Q.jsx)(dr,{children:(0,Q.jsx)(sn,{className:`w-full truncate`,children:(0,Q.jsx)(qt,{placeholder:`Select type`})})}),(0,Q.jsx)(mn,{onClick:e=>e.stopPropagation(),container:c,children:Object.entries(Ve).map(([e,t])=>(0,Q.jsx)(bn,{value:t,children:e},t))})]}),(0,Q.jsx)(mi,{})]})}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{name:`date`,control:r,defaultValue:d?.date,rules:{pattern:{value:Ql,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Date`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(kZ,{value:e.value??void 0,onChange:t=>{t!==e.value&&e.onChange(t)},"aria-invalid":!!t.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`serialNumber`,control:r,defaultValue:d?.serialNumber,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Serial Number`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:!e||e.value===`Missing`?``:e.value})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`allocationNumber`,control:r,defaultValue:d?.allocationNumber,rules:{pattern:{value:/^\d{9}$/,message:`Allocation number must be 9 characters long`}},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Allocation Number`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??void 0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`debtorId`,control:r,defaultValue:d?.debtor?.id,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-col`,children:[(0,Q.jsx)(hr,{children:`Debtor`}),(0,Q.jsx)(WJ,{...e,data:l,value:e.value??void 0,disabled:u,placeholder:`Scroll to see all options`,formPart:!0}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`creditorId`,control:r,defaultValue:d?.creditor?.id,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-col`,children:[(0,Q.jsx)(hr,{children:`Creditor`}),(0,Q.jsx)(WJ,{...e,data:l,value:e.value??void 0,disabled:u,placeholder:`Scroll to see all options`,formPart:!0}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(pr,{name:`vat.raw`,control:r,defaultValue:d?.vat?.raw,render:({field:e,fieldState:t})=>(0,Q.jsx)(pr,{name:`vat.currency`,control:r,defaultValue:d?.amount?.currency??n??k.Ils,render:({field:n,fieldState:r})=>(0,Q.jsx)(YJ,{...e,error:t.error?.message||r.error?.message,label:`VAT`,currencyCodeProps:{...n,label:`Currency`,disabled:!0}})})}),(0,Q.jsx)(pr,{name:`amount.raw`,control:r,defaultValue:d?.amount?.raw,render:({field:e,fieldState:t})=>(0,Q.jsx)(pr,{name:`amount.currency`,control:r,defaultValue:d?.amount?.currency??n??k.Ils,render:({field:n,fieldState:r})=>(0,Q.jsx)(YJ,{...e,error:t.error?.message||r.error?.message,label:`Amount`,currencyCodeProps:{...n,label:`Currency`}})})}),(0,Q.jsx)(pr,{name:`vatReportDateOverride`,control:r,defaultValue:d?.vatReportDateOverride,rules:{pattern:{value:Ql,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsx)(eG,{...e,label:`VAT report date`,value:e.value?new Date(e.value):void 0,onChange:t=>{a(`vatReportDateOverride`),e.onChange(t?`${Or(t,`yyyy-MM`)}-15`:void 0)},error:t.error?.message,popoverProps:{withinPortal:!0}})}),(0,Q.jsx)(pr,{name:`noVatAmount`,control:r,defaultValue:d?.noVatAmount??void 0,render:({field:e,fieldState:t})=>(0,Q.jsx)(pr,{name:`amount.currency`,control:r,defaultValue:d?.amount?.currency??n??k.Ils,render:({field:n})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`no VAT amount`,currencyCodeProps:{...n,label:`Currency`,disabled:!0}})})})]}),(0,Q.jsx)(Ar,{name:`image`,control:r,defaultValue:t?.image,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Image URL`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value?.toString()})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`file`,control:r,defaultValue:t?.file,render:({field:e})=>(0,Q.jsx)(`div`,{className:`flex flex-row`,children:(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`File URL`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{className:`grow`,...e,value:e.value?.toString()})}),(0,Q.jsx)(mi,{})]})})}),(0,Q.jsx)(Ar,{name:`description`,control:r,defaultValue:t?.description,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Description`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??``})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`remarks`,control:r,defaultValue:t?.remarks,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Remarks`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??``})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`exchangeRateOverride`,control:r,defaultValue:d?.exchangeRateOverride,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsxs)(hr,{children:[`Exchange Rate Override`,(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(${d?.amount?.currency??n??k.Ils} => ${k.Ils})`})]}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(l0,{onValueChange:t=>e.onChange(Number(t)),value:e.value??void 0,hideControls:!0,decimalScale:5,thousandSeparator:`,`})}),(0,Q.jsx)(mi,{})]})})]})},wG=({documentId:e,onDone:t,onChange:n})=>{let[{data:r,fetching:i}]=W({query:Xe,variables:{documentId:e}}),a=r?.documentById,o=Mr({defaultValues:{...a}}),{handleSubmit:s,formState:{dirtyFields:c},setValue:l,watch:u}=o,[d,f]=(0,Z.useState)(!1),{updateDocument:p,fetching:m}=jz(),h=r=>{if(!a)return;let i=gt(r,c);t?.(),i&&Object.keys(i).length>0&&p({documentId:e,fields:i}).then(n)},g=u(`amount.currency`);return(0,Z.useEffect)(()=>{l(`vat.currency`,g)},[l,g]),(0,Q.jsxs)(`div`,{className:`flex flex-row`,children:[i&&(0,Q.jsx)(ti,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}),!i&&a&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-5 w-4/5 h-max justify-items-center`,children:(0,Q.jsx)(kr,{...o,children:(0,Q.jsxs)(`form`,{onSubmit:s(h),children:[(0,Q.jsxs)(X9,{cols:4,children:[(0,Q.jsx)(CG,{document:a,formManager:o}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`file`,children:`File`}),(0,Q.jsx)(vt,{to:a?.file?.toString()||``,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center justify-center mt-5`,children:(0,Q.jsx)(q,{variant:`outline`,className:`w-full mb-2`,children:`Open File`})})]})]}),(0,Q.jsx)(`div`,{className:`flex justify-center mt-5`,children:(0,Q.jsx)(q,{type:`submit`,variant:`default`,disabled:m||Object.keys(c).length===0,children:`Save`})})]})})}),(0,Q.jsx)(`div`,{className:` w-1/5 h-max flex flex-col `,children:(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(li,{onClick:()=>f(!!a.image),src:a?.image?.toString(),className:` cursor-pointer bg-gray-300 p-5 mr-5 max-h-fit max-w-fit`})})}),a.image&&(0,Q.jsx)($C,{classNames:{content:`overflow-y-auto drop-shadow-lg`},withCloseButton:!0,withOverlay:!1,position:`right`,opened:d,onClose:()=>f(!1),size:`30%`,children:(0,Q.jsx)(`div`,{className:`m-2`,children:(0,Q.jsx)(CK,{src:a.image.toString(),zoomLevel:3,magnifierHeight:300,magnifierWidth:300})})})]})]})},TG=`updateMiscExpense`,EG=()=>{let[{fetching:e},t]=H(me);return{fetching:e,updateMiscExpense:(0,Z.useCallback)(async e=>{let n=`Error updating misc expense ID [${e.id}]`,r=`${TG}-${e.id}`;K.loading(`Update Misc Expense`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateMiscExpense`);if(a)return K.success(`Success`,{id:r,description:`Misc expense was updated`}),a.updateMiscExpense}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},DG=({onDone:e,data:t})=>{let[n,r]=(0,Z.useState)(!1),i=Lr(he,t),a=Mr({defaultValues:{amount:i.amount.raw,currency:i.amount.currency,description:i.description,valueDate:new Date(i.valueDate),invoiceDate:i.invoiceDate,creditorId:i.creditor.id,debtorId:i.debtor.id}}),{handleSubmit:o,formState:{dirtyFields:s}}=a,{updateMiscExpense:c,fetching:l}=EG(),u=(0,Z.useCallback)(async t=>{r(!0),await c({id:i.id,fields:t}),e(),r(!1)},[c,e,i.id]),d=e=>{e&&Object.keys(e).length>0&&u({...e})};return n?(0,Q.jsx)(ti,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}):(0,Q.jsx)(kr,{...a,children:(0,Q.jsx)(`form`,{onSubmit:o(d),noValidate:!0,children:(0,Q.jsxs)(`div`,{className:`px-5 flex flex-col gap-5`,children:[(0,Q.jsx)(fK,{formManager:a,isInsert:!1}),(0,Q.jsx)(`div`,{className:`flex justify-right gap-5 mt-5`,children:(0,Q.jsx)(`button`,{type:`submit`,className:`text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:l||Object.keys(s).length===0,children:`Accept`})})]})})})},OG=({transactionID:e,onDone:t,onChange:n})=>{let r=Fk(),[{data:i,fetching:a}]=W({query:Me,variables:{transactionIDs:[e]}}),o=i?.transactionsByIDs?.[0],s=Mr({defaultValues:o??{}});(0,Z.useEffect)(()=>{o&&s.reset(o)},[o,s]);let{control:c,handleSubmit:l,formState:{dirtyFields:u}}=s,{updateTransaction:d,fetching:f}=Pz(),p=e=>{if(!o)return;let r=gt(e,u);t?.(),r&&Object.keys(r).length>0&&d({transactionId:o.id,fields:r}).then(n)},{selectableFinancialEntities:m,fetching:h}=SG();return(0,Q.jsxs)(Q.Fragment,{children:[a&&(0,Q.jsx)(ti,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}),!a&&o&&(0,Q.jsx)(kr,{...s,children:(0,Q.jsxs)(`form`,{onSubmit:l(p),children:[(0,Q.jsx)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:(0,Q.jsxs)(X9,{cols:3,children:[(0,Q.jsx)(Ar,{name:`counterpartyId`,control:c,defaultValue:o.counterparty?.id,rules:{minLength:{value:2,message:`Minimum 2 characters`}},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Counterparty`}),(0,Q.jsxs)(wn,{onValueChange:e.onChange,value:e.value??void 0,disabled:h,children:[(0,Q.jsx)(dr,{children:(0,Q.jsx)(sn,{className:`w-full truncate`,children:(0,Q.jsx)(qt,{placeholder:`Scroll to see all options`})})}),(0,Q.jsx)(mn,{onClick:e=>e.stopPropagation(),container:r,children:m.map(({value:e,label:t})=>(0,Q.jsx)(bn,{value:e,children:t},e))})]}),(0,Q.jsx)(mi,{})]})}),o?.account.type===z.CreditCard?(0,Q.jsx)(Ar,{name:`effectiveDate`,control:c,rules:{pattern:{value:Ql,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{htmlFor:`transaction-effective-date`,children:`Effective Date`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(kZ,{id:`transaction-effective-date`,onChange:t=>{t!==e.value&&e.onChange(t)},value:e.value??void 0,"aria-invalid":!!t.error})}),(0,Q.jsx)(mi,{})]})}):(0,Q.jsx)(Q.Fragment,{}),(0,Q.jsx)(Ar,{name:`isFee`,control:c,defaultValue:o.isFee,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(hr,{children:`Fee Transaction`})}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{checked:e.value===!0,onCheckedChange:e.onChange})})]})})]})}),(0,Q.jsxs)(`div`,{className:`mt-10 mb-5 flex justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`submit`,onClick:()=>l(p),className:`mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:f||Object.keys(u).length===0,children:`Accept`}),(0,Q.jsx)(`button`,{type:`button`,className:`mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg`,onClick:t,children:`Cancel`})]})]})})]})},kG=`insertBusinessTrip`,AG=()=>{let[{fetching:e},t]=H(ft);return{fetching:e,insertBusinessTrip:(0,Z.useCallback)(async e=>{let n=`Error inserting business trip`,r=kG;K.loading(`Creating trip`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a)return K.success(`Success`,{id:r,description:`Business trip created`}),a.insertBusinessTrip}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},jG=()=>{let[{data:e,fetching:t,error:n},r]=W({query:v});return n&&(console.error(`Error fetching countries: ${n}`),K.error(`Error`,{description:`Unable to fetch countries`})),{fetching:t,refresh:()=>r(),countries:e?.allCountries??[]}},MG=({control:e})=>{let{countries:t,fetching:n}=jG();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{name:`name`,control:e,rules:{required:`Required`},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Name`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,required:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`fromDate`,control:e,rules:{pattern:{value:Ql,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{htmlFor:`business-trip-from-date`,children:`Start Date`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(kZ,{id:`business-trip-from-date`,onChange:t=>{t!==e.value&&e.onChange(t)},value:e.value??void 0,"aria-invalid":!!t.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`toDate`,control:e,rules:{pattern:{value:Ql,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{htmlFor:`business-trip-to-date`,children:`End Date`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(kZ,{id:`business-trip-to-date`,onChange:t=>{t!==e.value&&e.onChange(t)},value:e.value??void 0,"aria-invalid":!!t.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`destinationCode`,control:e,render:({field:e,fieldState:r})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Destination`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(JO,{...e,data:t.map(e=>({value:e.code,label:e.name})),value:e.value??void 0,disabled:n,maxDropdownHeight:160,searchable:!0,error:r.error?.message})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:e,name:`tripPurpose`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Trip Purpose`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??void 0})}),(0,Q.jsx)(mi,{})]})})]})},NG=({onDone:e})=>{let[t,n]=(0,Z.useState)(!1),r=Mr(),{control:i,handleSubmit:a,formState:{dirtyFields:o}}=r,{insertBusinessTrip:s,fetching:c}=AG(),l=(0,Z.useCallback)(async t=>{n(!0),await s({fields:t}),e(),n(!1)},[s,e]),u=e=>{if(e.fromDate?.trim()===``&&(e.fromDate=void 0),e.toDate?.trim()===``&&(e.fromDate=void 0),e&&Object.keys(e).length>0){if(!e.name){K.error(`Error`,{description:`Business name is required`});return}l(e)}};return t?(0,Q.jsx)(ti,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}):(0,Q.jsx)(kr,{...r,children:(0,Q.jsx)(`form`,{children:(0,Q.jsxs)(`div`,{className:`px-5 flex flex-col gap-5`,children:[(0,Q.jsx)(MG,{control:i}),(0,Q.jsx)(`div`,{className:`flex justify-right gap-5 mt-5`,children:(0,Q.jsx)(`button`,{type:`button`,className:`text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:c||Object.keys(o).length===0,onClick:a(u),children:`Accept`})})]})})})},PG=`insertDocument`,FG=()=>{let[{fetching:e},t]=H(ne);return{fetching:e,insertDocument:(0,Z.useCallback)(async e=>{let n=`Error inserting document to charge ID [${e.record.chargeId}]`,r=PG;K.loading(`Adding document`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`insertDocument`);if(a)return K.success(`Success`,{id:r,description:`Document added`}),a.insertDocument}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},IG=({chargeId:e,onChange:t,closeModal:n})=>{let r=Mr(),{handleSubmit:i,formState:{dirtyFields:a},setValue:o,watch:s}=r,{insertDocument:c,fetching:l}=FG(),u=r=>{if(r&&Object.keys(r).length>0){if(r.vat){if(!r.amount?.currency){K.error(`Error`,{description:`Couldn't figure out the currency of the document`});return}r.vat.currency=r.amount.currency}r.documentType??=Ve.Unprocessed,c({record:{...r,chargeId:e}}).then(()=>t?.()),n?.()}},d=s(`amount.currency`);return(0,Z.useEffect)(()=>{o(`vat.currency`,d)},[o,d]),(0,Q.jsx)(`div`,{className:`px-5 w-max h-max justify-items-center`,children:(0,Q.jsx)(kr,{...r,children:(0,Q.jsxs)(`form`,{onSubmit:i(u),children:[(0,Q.jsx)(X9,{cols:5,children:(0,Q.jsx)(CG,{formManager:r,defaultCurrency:k.Ils})}),(0,Q.jsxs)(`div`,{className:`flex justify-center gap-5 mt-5`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:` text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:l||Object.keys(a).length===0,children:`Accept`}),(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg`,onClick:n,children:`Cancel`})]})]})})})},LG=`insertMiscExpense`,RG=()=>{let[{fetching:e},t]=H(re);return{fetching:e,insertMiscExpense:(0,Z.useCallback)(async e=>{let n=`Error creating misc expense`,r=`${LG}-${e.chargeId}`;K.loading(`Creating misc expense`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a)return K.success(`Success`,{id:r,description:`Misc expense was created`}),a.insertMiscExpense}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},zG=({onDone:e,defaultValues:t={},chargeId:n})=>{let{insertMiscExpense:r,fetching:i}=RG(),a=(0,Z.useCallback)(async t=>{await r({chargeId:n,fields:t}),e()},[r,n,e]);return(0,Q.jsx)(BG,{defaultValues:t,onInsertDone:a,fetching:i})},BG=({onInsertDone:e,defaultValues:t,fetching:n})=>{let r=t=>{t&&Object.keys(t).length>0&&e(t)},i=Mr({defaultValues:{...t}}),{handleSubmit:a,formState:{dirtyFields:o}}=i;return(0,Q.jsx)(kr,{...i,children:(0,Q.jsx)(`form`,{onSubmit:a(r),noValidate:!0,children:(0,Q.jsxs)(`div`,{className:`px-5 flex flex-col gap-5 relative`,children:[n&&(0,Q.jsx)(`div`,{className:`absolute bg-white/60 z-10 h-full w-full flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`flex items-center`,children:(0,Q.jsx)(`span`,{className:`text-3xl mr-4`,children:(0,Q.jsx)(Qt,{className:`h-10 w-10 animate-spin mr-2 self-center`})})})}),(0,Q.jsx)(fK,{formManager:i,isInsert:!0}),(0,Q.jsx)(`div`,{className:`flex justify-right gap-5 mt-5`,children:(0,Q.jsx)(`button`,{type:`submit`,className:`text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:n||Object.keys(o).length===0,children:`Accept`})})]})})})},VG=()=>{let[{data:e,fetching:t,error:n},r]=W({query:V});n&&(console.error(`Error fetching clients: ${n}`),K.error(`Error`,{description:`Unable to fetch clients`}));let i=(0,Z.useMemo)(()=>e?.allClients?.slice().sort((e,t)=>e.originalBusiness.name>t.originalBusiness.name?1:-1)??[],[e]);return{fetching:t,refresh:()=>r(),clients:i,selectableClients:(0,Z.useMemo)(()=>i.map(e=>({value:e.originalBusiness.id,label:e.originalBusiness.name})),[i])}},HG=function(e){return e.Afghanistan=`AFG`,e.Albania=`ALB`,e.Algeria=`DZA`,e[`American Samoa`]=`ASM`,e.Andorra=`AND`,e.Angola=`AGO`,e.Anguilla=`AIA`,e.Antarctica=`ATA`,e[`Antigua and Barbuda`]=`ATG`,e.Argentina=`ARG`,e.Armenia=`ARM`,e.Aruba=`ABW`,e.Australia=`AUS`,e.Austria=`AUT`,e.Azerbaijan=`AZE`,e[`Bahamas (the)`]=`BHS`,e.Bahrain=`BHR`,e.Bangladesh=`BGD`,e.Barbados=`BRB`,e.Belarus=`BLR`,e.Belgium=`BEL`,e.Belize=`BLZ`,e.Benin=`BEN`,e.Bermuda=`BMU`,e.Bhutan=`BTN`,e[`Bolivia (Plurinational State of)`]=`BOL`,e[`Bonaire, Sint Eustatius and Saba`]=`BES`,e[`Bosnia and Herzegovina`]=`BIH`,e.Botswana=`BWA`,e[`Bouvet Island`]=`BVT`,e.Brazil=`BRA`,e[`British Indian Ocean Territory (the)`]=`IOT`,e[`Brunei Darussalam`]=`BRN`,e.Bulgaria=`BGR`,e[`Burkina Faso`]=`BFA`,e.Burundi=`BDI`,e[`Cabo Verde`]=`CPV`,e.Cambodia=`KHM`,e.Cameroon=`CMR`,e.Canada=`CAN`,e[`Cayman Islands (the)`]=`CYM`,e[`Central African Republic (the)`]=`CAF`,e.Chad=`TCD`,e.Chile=`CHL`,e.China=`CHN`,e[`Christmas Island`]=`CXR`,e[`Cocos (Keeling) Islands (the)`]=`CCK`,e.Colombia=`COL`,e[`Comoros (the)`]=`COM`,e[`Congo (the Democratic Republic of the)`]=`COD`,e[`Congo (the)`]=`COG`,e[`Cook Islands (the)`]=`COK`,e[`Costa Rica`]=`CRI`,e.Croatia=`HRV`,e.Cuba=`CUB`,e.Curaçao=`CUW`,e.Cyprus=`CYP`,e.Czechia=`CZE`,e[`Côte d'Ivoire`]=`CIV`,e.Denmark=`DNK`,e.Djibouti=`DJI`,e.Dominica=`DMA`,e[`Dominican Republic (the)`]=`DOM`,e.Ecuador=`ECU`,e.Egypt=`EGY`,e[`El Salvador`]=`SLV`,e[`Equatorial Guinea`]=`GNQ`,e.Eritrea=`ERI`,e.Estonia=`EST`,e.Eswatini=`SWZ`,e.Ethiopia=`ETH`,e[`Falkland Islands (the) [Malvinas]`]=`FLK`,e[`Faroe Islands (the)`]=`FRO`,e.Fiji=`FJI`,e.Finland=`FIN`,e.France=`FRA`,e[`French Guiana`]=`GUF`,e[`French Polynesia`]=`PYF`,e[`French Southern Territories (the)`]=`ATF`,e.Gabon=`GAB`,e[`Gambia (the)`]=`GMB`,e.Georgia=`GEO`,e.Germany=`DEU`,e.Ghana=`GHA`,e.Gibraltar=`GIB`,e.Greece=`GRC`,e.Greenland=`GRL`,e.Grenada=`GRD`,e.Guadeloupe=`GLP`,e.Guam=`GUM`,e.Guatemala=`GTM`,e.Guernsey=`GGY`,e.Guinea=`GIN`,e[`Guinea-Bissau`]=`GNB`,e.Guyana=`GUY`,e.Haiti=`HTI`,e[`Heard Island and McDonald Islands`]=`HMD`,e[`Holy See (the)`]=`VAT`,e.Honduras=`HND`,e[`Hong Kong`]=`HKG`,e.Hungary=`HUN`,e.Iceland=`ISL`,e.India=`IND`,e.Indonesia=`IDN`,e[`Iran (Islamic Republic of)`]=`IRN`,e.Iraq=`IRQ`,e.Ireland=`IRL`,e[`Isle of Man`]=`IMN`,e.Israel=`ISR`,e.Italy=`ITA`,e.Jamaica=`JAM`,e.Japan=`JPN`,e.Jersey=`JEY`,e.Jordan=`JOR`,e.Kazakhstan=`KAZ`,e.Kenya=`KEN`,e.Kiribati=`KIR`,e[`Korea (the Democratic People's Republic of)`]=`PRK`,e[`Korea (the Republic of)`]=`KOR`,e.Kuwait=`KWT`,e.Kyrgyzstan=`KGZ`,e[`Lao People's Democratic Republic (the)`]=`LAO`,e.Latvia=`LVA`,e.Lebanon=`LBN`,e.Lesotho=`LSO`,e.Liberia=`LBR`,e.Libya=`LBY`,e.Liechtenstein=`LIE`,e.Lithuania=`LTU`,e.Luxembourg=`LUX`,e.Macao=`MAC`,e.Madagascar=`MDG`,e.Malawi=`MWI`,e.Malaysia=`MYS`,e.Maldives=`MDV`,e.Mali=`MLI`,e.Malta=`MLT`,e[`Marshall Islands (the)`]=`MHL`,e.Martinique=`MTQ`,e.Mauritania=`MRT`,e.Mauritius=`MUS`,e.Mayotte=`MYT`,e.Mexico=`MEX`,e[`Micronesia (Federated States of)`]=`FSM`,e[`Moldova (the Republic of)`]=`MDA`,e.Monaco=`MCO`,e.Mongolia=`MNG`,e.Montenegro=`MNE`,e.Montserrat=`MSR`,e.Morocco=`MAR`,e.Mozambique=`MOZ`,e.Myanmar=`MMR`,e.Namibia=`NAM`,e.Nauru=`NRU`,e.Nepal=`NPL`,e[`Netherlands (the)`]=`NLD`,e[`New Caledonia`]=`NCL`,e[`New Zealand`]=`NZL`,e.Nicaragua=`NIC`,e[`Niger (the)`]=`NER`,e.Nigeria=`NGA`,e.Niue=`NIU`,e[`Norfolk Island`]=`NFK`,e[`Northern Mariana Islands (the)`]=`MNP`,e.Norway=`NOR`,e.Oman=`OMN`,e.Pakistan=`PAK`,e.Palau=`PLW`,e[`Palestine, State of`]=`PSE`,e.Panama=`PAN`,e[`Papua New Guinea`]=`PNG`,e.Paraguay=`PRY`,e.Peru=`PER`,e[`Philippines (the)`]=`PHL`,e.Pitcairn=`PCN`,e.Poland=`POL`,e.Portugal=`PRT`,e[`Puerto Rico`]=`PRI`,e.Qatar=`QAT`,e[`Republic of North Macedonia`]=`MKD`,e.Romania=`ROU`,e[`Russian Federation (the)`]=`RUS`,e.Rwanda=`RWA`,e.Réunion=`REU`,e[`Saint Barthélemy`]=`BLM`,e[`Saint Helena, Ascension and Tristan da Cunha`]=`SHN`,e[`Saint Kitts and Nevis`]=`KNA`,e[`Saint Lucia`]=`LCA`,e[`Saint Martin (French part)`]=`MAF`,e[`Saint Pierre and Miquelon`]=`SPM`,e[`Saint Vincent and the Grenadines`]=`VCT`,e.Samoa=`WSM`,e[`San Marino`]=`SMR`,e[`Sao Tome and Principe`]=`STP`,e[`Saudi Arabia`]=`SAU`,e.Senegal=`SEN`,e.Serbia=`SRB`,e.Seychelles=`SYC`,e[`Sierra Leone`]=`SLE`,e.Singapore=`SGP`,e[`Sint Maarten (Dutch part)`]=`SXM`,e.Slovakia=`SVK`,e.Slovenia=`SVN`,e[`Solomon Islands`]=`SLB`,e.Somalia=`SOM`,e[`South Africa`]=`ZAF`,e[`South Georgia and the South Sandwich Islands`]=`SGS`,e[`South Sudan`]=`SSD`,e.Spain=`ESP`,e[`Sri Lanka`]=`LKA`,e[`Sudan (the)`]=`SDN`,e.Suriname=`SUR`,e[`Svalbard and Jan Mayen`]=`SJM`,e.Sweden=`SWE`,e.Switzerland=`CHE`,e[`Syrian Arab Republic`]=`SYR`,e[`Taiwan (Province of China)`]=`TWN`,e.Tajikistan=`TJK`,e[`Tanzania, United Republic of`]=`TZA`,e.Thailand=`THA`,e[`Timor-Leste`]=`TLS`,e.Togo=`TGO`,e.Tokelau=`TKL`,e.Tonga=`TON`,e[`Trinidad and Tobago`]=`TTO`,e.Tunisia=`TUN`,e.Turkey=`TUR`,e.Turkmenistan=`TKM`,e[`Turks and Caicos Islands (the)`]=`TCA`,e.Tuvalu=`TUV`,e.Uganda=`UGA`,e.Ukraine=`UKR`,e[`United Arab Emirates (the)`]=`ARE`,e[`United Kingdom of Great Britain and Northern Ireland (the)`]=`GBR`,e[`United States Minor Outlying Islands (the)`]=`UMI`,e[`United States of America (the)`]=`USA`,e.Uruguay=`URY`,e.Uzbekistan=`UZB`,e.Vanuatu=`VUT`,e[`Venezuela (Bolivarian Republic of)`]=`VEN`,e[`Viet Nam`]=`VNM`,e[`Virgin Islands (British)`]=`VGB`,e[`Virgin Islands (U.S.)`]=`VIR`,e[`Wallis and Futuna`]=`WLF`,e[`Western Sahara`]=`ESH`,e.Yemen=`YEM`,e.Zambia=`ZMB`,e.Zimbabwe=`ZWE`,e[`Åland Islands`]=`ALA`,e}({}),UG=Object.fromEntries(Object.entries(HG).map(([e,t])=>[t,e]));function WG(e){return e?UG[e.toUpperCase()]??e:null}var GG=()=>[{value:Je.English,label:`English`},{value:Je.Hebrew,label:`Hebrew`}],KG=()=>[{value:k.Ils,label:`Israeli Shekel (ILS)`},{value:k.Usd,label:`US Dollar (USD)`},{value:k.Eur,label:`Euro (EUR)`},{value:k.Gbp,label:`British Pound (GBP)`},{value:k.Jpy,label:`Japanese Yen (JPY)`},{value:k.Aud,label:`Australian Dollar (AUD)`},{value:k.Cad,label:`Canadian Dollar (CAD)`},{value:k.Sek,label:`Swedish Krona (SEK)`}],qG=()=>[{value:we.Default,label:`Default (Based on business type)`},{value:we.Exempt,label:`Exempt (VAT free)`},{value:we.Mixed,label:`Mixed (Contains exempt and due VAT income rows)`}],JG=()=>[Ve.CreditInvoice,Ve.Invoice,Ve.InvoiceReceipt,Ve.Receipt,Ve.Proforma].map(e=>({value:e,label:au(e)})),YG=()=>Object.entries(HG).map(([e,t])=>({value:t,label:e})),XG=()=>[{value:u.TaxDeduction,label:`Tax deduction (ניכוי במקור)`},{value:u.Cash,label:`Cash (מזומן)`},{value:u.Cheque,label:`Cheque (צ׳ק)`},{value:u.CreditCard,label:`Credit card (כרטיס אשראי)`},{value:u.WireTransfer,label:`Wire-transfer (העברה בנקאית)`},{value:u.Paypal,label:`PayPal (פייפאל)`},{value:u.OtherDeduction,label:`Other deduction (ניכוי אחר)`},{value:u.PaymentApp,label:`Payment app (אפליקציית תשלום)`},{value:u.Other,label:`Other (אחר)`}],ZG=()=>[{value:Fe.Unknown,label:`Unknown (לא ידוע)`},{value:Fe.Isracard,label:`Isracard (ישראכרט)`},{value:Fe.Visa,label:`Visa (ויזה)`},{value:Fe.Mastercard,label:`Mastercard (מאסטרקארד)`},{value:Fe.AmericanExpress,label:`American Express (אמריקן אקספרס)`},{value:Fe.Diners,label:`Diners (דיינרס)`}],QG=YG();function $G({client:e,onChange:t,fetching:n}){let r=(n,r)=>{t({...e,[n]:r})},i=e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);r(`emails`,t)};return(0,Q.jsxs)(Mi,{children:[(0,Q.jsx)(Oi,{children:(0,Q.jsxs)(Ai,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ka,{className:`w-5 h-5`}),`Client Information`]})}),(0,Q.jsx)(ki,{className:`space-y-4`,children:n?(0,Q.jsx)(`div`,{children:`Loading...`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`clientName`,children:`Client Name`}),(0,Q.jsx)(Sn,{id:`clientName`,value:e.name||``,onChange:e=>r(`name`,e.target.value),placeholder:`Enter client name`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`taxId`,children:`Tax ID`}),(0,Q.jsx)(Sn,{id:`taxId`,value:e.taxId||``,onChange:e=>r(`taxId`,e.target.value),placeholder:`Tax identification number`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`emails`,children:`Email Addresses`}),(0,Q.jsx)(Sn,{id:`emails`,value:e.emails?.join(`, `)||``,onChange:e=>i(e.target.value),placeholder:`email1@example.com, email2@example.com`})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`phone`,children:`Phone`}),(0,Q.jsx)(Sn,{id:`phone`,value:e.phone||``,onChange:e=>r(`phone`,e.target.value),placeholder:`Phone number`})]})}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`address`,children:`Address`}),(0,Q.jsx)(Sn,{id:`address`,value:e.address||``,onChange:e=>r(`address`,e.target.value),placeholder:`Street address`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`city`,children:`City`}),(0,Q.jsx)(Sn,{id:`city`,value:e.city||``,onChange:e=>r(`city`,e.target.value),placeholder:`City`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`country`,children:`Country`}),(0,Q.jsx)(WJ,{onChange:e=>r(`country`,e),data:QG,value:e.country,placeholder:`Select country`,triggerProps:{className:`w-full flex justify-between`}})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`zipCode`,children:`Zip Code`}),(0,Q.jsx)(Sn,{id:`zipCode`,value:e.zipCode||``,onChange:e=>r(`zipCode`,e.target.value),placeholder:`Zip Code`})]})]})]})})]})}var eK=qG(),tK=KG();function nK({income:e,currency:t,onChange:n}){let r=()=>{let r={description:``,price:0,quantity:1,currency:t,vatType:we.Exempt};n([...e,r])},i=(t,r,i)=>{let a=[...e];a[t]={...a[t],[r]:i},n(a)},a=t=>{n(e.filter((e,n)=>n!==t))},o=e=>{let t=e.price*e.quantity;return t+t*((e.vatRate||0)/100)};return(0,Q.jsxs)(Mi,{children:[(0,Q.jsx)(Oi,{children:(0,Q.jsxs)(Ai,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(va,{className:`w-5 h-5`}),`Income Items`]})}),(0,Q.jsxs)(ki,{className:`space-y-4`,children:[e.map((e,n)=>(0,Q.jsxs)(`div`,{className:`border rounded-lg p-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Q.jsxs)(`h4`,{className:`font-medium`,children:[`Item `,n+1]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>a(n),className:`text-red-600 hover:text-red-700`,children:(0,Q.jsx)(Xn,{className:`w-4 h-4`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Description`}),(0,Q.jsx)(Wn,{value:e.description,onChange:e=>i(n,`description`,e.target.value),placeholder:`Item description`,className:`min-h-[60px]`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Price`}),(0,Q.jsx)(Sn,{type:`number`,step:`0.01`,value:e.price,onChange:e=>i(n,`price`,Number.parseFloat(e.target.value)||0),placeholder:`0.00`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Currency`}),(0,Q.jsxs)(wn,{value:e.currency,onValueChange:e=>i(n,`currency`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:tK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Quantity`}),(0,Q.jsx)(Sn,{type:`number`,step:`1`,value:e.quantity,onChange:e=>i(n,`quantity`,Number.parseInt(e.target.value)||1),placeholder:`1`})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`VAT Type`}),(0,Q.jsxs)(wn,{value:e.vatType,onValueChange:e=>i(n,`vatType`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:eK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`VAT Rate (%)`}),(0,Q.jsx)(Sn,{type:`number`,step:`0.01`,value:e.vatRate||0,onChange:e=>i(n,`vatRate`,Number.parseFloat(e.target.value)||0),placeholder:`0.00`})]})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Total`}),(0,Q.jsxs)(`div`,{className:`px-3 py-2 bg-gray-50 rounded-md text-sm font-medium`,children:[o(e).toFixed(2),` `,t]})]})})]},n)),(0,Q.jsxs)(q,{onClick:r,variant:`outline`,className:`w-full bg-transparent`,children:[(0,Q.jsx)(Dn,{className:`w-4 h-4 mr-2`}),`Add Income Item`]}),e.length>0&&(0,Q.jsx)(`div`,{className:`border-t pt-4`,children:(0,Q.jsxs)(`div`,{className:`flex justify-between items-center font-medium`,children:[(0,Q.jsx)(`span`,{children:`Total Amount:`}),(0,Q.jsxs)(`span`,{children:[e.reduce((e,t)=>e+o(t),0).toFixed(2),` `,t]})]})})]})]})}var rK=KG(),iK=XG(),aK=ZG();function oK({payments:e,currency:t,onChange:n}){let r=()=>{let r={currency:t,price:0,type:u.Cash,date:new Date().toISOString().split(`T`)[0]};n([...e,r])},i=(0,Z.useCallback)((t,r,i)=>{let a=[...e];a[t]={...a[t],[r]:i},n(a)},[e,n]),a=t=>{n(e.filter((e,n)=>n!==t))},o=e=>iK.find(t=>t.value===e)?.label||e,s=e=>e===u.WireTransfer||e===u.Cheque,c=e=>e===u.Cheque,l=e=>e===u.CreditCard,d=e=>e===u.Paypal,f=(0,Z.useCallback)((e,t)=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Account ID`}),(0,Q.jsx)(Sn,{value:e.accountId||``,onChange:e=>i(t,`accountId`,e.target.value),placeholder:`PayPal account ID`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Transaction ID`}),(0,Q.jsx)(Sn,{value:e.transactionId||``,onChange:e=>i(t,`transactionId`,e.target.value),placeholder:`Transaction ID`})]})]}),[i]);return(0,Q.jsxs)(Mi,{children:[(0,Q.jsx)(Oi,{children:(0,Q.jsxs)(Ai,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ji,{className:`w-5 h-5`}),`Payments`]})}),(0,Q.jsxs)(ki,{className:`space-y-4`,children:[e.map((e,t)=>(0,Q.jsxs)(`div`,{className:`border rounded-lg p-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Q.jsxs)(`h4`,{className:`font-medium`,children:[`Payment `,t+1,` - `,o(e.type)]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>a(t),className:`text-red-600 hover:text-red-700`,children:(0,Q.jsx)(Xn,{className:`w-4 h-4`})})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Payment Type`}),(0,Q.jsxs)(wn,{value:e.type,onValueChange:e=>i(t,`type`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:iK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Amount`}),(0,Q.jsx)(Sn,{type:`number`,step:`0.01`,value:e.price,onChange:e=>i(t,`price`,Number.parseFloat(e.target.value)||0),placeholder:`0.00`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Currency`}),(0,Q.jsxs)(wn,{value:e.currency,onValueChange:e=>i(t,`currency`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:rK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Date`}),(0,Q.jsx)(Sn,{type:`date`,value:e.date||``,onChange:e=>i(t,`date`,e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Currency Rate (relative to ILS)`}),(0,Q.jsx)(Sn,{type:`number`,step:`0.0001`,value:e.currencyRate||``,onChange:e=>i(t,`currencyRate`,Number.parseFloat(e.target.value)||void 0),placeholder:`1.0000`})]})]}),s(e.type)&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h5`,{className:`font-medium text-sm text-gray-700`,children:`Bank Details`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Bank Name`}),(0,Q.jsx)(Sn,{value:e.bankName||``,onChange:e=>i(t,`bankName`,e.target.value),placeholder:`Bank name`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Bank Branch`}),(0,Q.jsx)(Sn,{value:e.bankBranch||``,onChange:e=>i(t,`bankBranch`,e.target.value),placeholder:`Branch number`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Bank Account`}),(0,Q.jsx)(Sn,{value:e.bankAccount||``,onChange:e=>i(t,`bankAccount`,e.target.value),placeholder:`Account number`})]})]})]}),c(e.type)&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Cheque Number`}),(0,Q.jsx)(Sn,{value:e.chequeNum||``,onChange:e=>i(t,`chequeNum`,e.target.value),placeholder:`Cheque number`})]})})}),l(e.type)&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h5`,{className:`font-medium text-sm text-gray-700`,children:`Credit Card Details`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Card Type`}),(0,Q.jsxs)(wn,{value:e.cardType||``,onValueChange:e=>i(t,`cardType`,e||void 0),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{placeholder:`Select card type`})}),(0,Q.jsx)(mn,{children:aK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Last 4 Digits`}),(0,Q.jsx)(Sn,{value:e.cardNum||``,onChange:e=>i(t,`cardNum`,e.target.value),placeholder:`1234`,maxLength:4})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`Number of Payments (1-36)`}),(0,Q.jsx)(Sn,{type:`number`,min:`1`,max:`36`,value:e.numPayments||``,onChange:e=>i(t,`numPayments`,Number.parseInt(e.target.value)||void 0),placeholder:`1`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{children:`First Payment Amount`}),(0,Q.jsx)(Sn,{type:`number`,step:`0.01`,value:e.firstPayment||``,onChange:e=>i(t,`firstPayment`,Number.parseFloat(e.target.value)||void 0),placeholder:`0.00`})]})]})]}),d(e.type)&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h5`,{className:`font-medium text-sm text-gray-700`,children:`PayPal Details`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-4`,children:f(e,t)})]})]},t)),(0,Q.jsxs)(q,{onClick:r,variant:`outline`,className:`w-full bg-transparent`,children:[(0,Q.jsx)(Dn,{className:`w-4 h-4 mr-2`}),`Add Payment`]}),e.length>0&&(0,Q.jsx)(`div`,{className:`border-t pt-4`,children:(0,Q.jsxs)(`div`,{className:`flex justify-between items-center font-medium`,children:[(0,Q.jsx)(`span`,{children:`Total Payments:`}),(0,Q.jsxs)(`span`,{children:[e.reduce((e,t)=>e+t.price,0).toFixed(2),` `,t]})]})})]})]})}var sK=KG(),cK=JG(),lK=GG(),uK=qG();function dK({formData:e,updateFormData:t}){let[n,r]=(0,Z.useState)(e.client?.id||void 0),{selectableClients:i}=VG(),[a,o]=(0,Z.useState)(e.client??null),[{data:s,fetching:c},l]=W({pause:!0,query:et,variables:{businessId:n??``}});(0,Z.useEffect)(()=>{e.client?.id&&r(e.client.id)},[e.client?.id]),(0,Z.useEffect)(()=>{n&&l()},[n,l]);let u=(0,Z.useCallback)(e=>{o(e),t(`client`,e)},[t]);(0,Z.useEffect)(()=>{if(s?.client?.integrations.greenInvoiceInfo){let e=p9(Lr(T,s.client));u(e)}},[s?.client,u,n]);let d=e=>{if(r(e),e===`new`)t(`client`,{id:`temp-${crypto.randomUUID()}`,name:``});else if(e){let n=i.find(t=>t.value===e);n&&t(`client`,{id:n.value,name:n.label})}},f=e.type===Ve.Proforma||e.type===Ve.Invoice,p=f||e.type===Ve.InvoiceReceipt||e.type===Ve.CreditInvoice,m=e.type===Ve.Receipt||e.type===Ve.InvoiceReceipt;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Mi,{children:[(0,Q.jsx)(Oi,{children:(0,Q.jsxs)(Ai,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Sa,{className:`w-5 h-5`}),`Document Settings`]})}),(0,Q.jsxs)(ki,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`documentType`,children:`Document Type`}),(0,Q.jsxs)(wn,{value:e.type,onValueChange:e=>t(`type`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:cK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`language`,children:`Language`}),(0,Q.jsxs)(wn,{value:e.language,onValueChange:e=>t(`language`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:lK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`currency`,children:`Currency`}),(0,Q.jsxs)(wn,{value:e.currency,onValueChange:e=>t(`currency`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:sK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`vatType`,children:`VAT Type`}),(0,Q.jsxs)(wn,{value:e.vatType,onValueChange:e=>t(`vatType`,e),children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})}),(0,Q.jsx)(mn,{children:uK.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`clientSelect`,children:`Select Client`}),(0,Q.jsxs)(wn,{value:n,onValueChange:d,children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{placeholder:`Choose existing client or create new`})}),(0,Q.jsx)(mn,{children:i.map(e=>(0,Q.jsx)(bn,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`date`,children:`Document Date`}),(0,Q.jsx)(Sn,{id:`date`,type:`date`,value:e.date||``,onChange:e=>t(`date`,e.target.value)})]})]}),f&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`maxPayments`,children:`Max Payments`}),(0,Q.jsx)(Sn,{id:`maxPayments`,type:`number`,min:`1`,max:`36`,value:e.maxPayments||``,onChange:e=>t(`maxPayments`,Number.parseInt(e.target.value)||void 0),placeholder:`1`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`dueDate`,children:`Due Date`}),(0,Q.jsx)(Sn,{id:`dueDate`,type:`date`,value:e.dueDate||``,onChange:e=>t(`dueDate`,e.target.value)})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`description`,children:`Description`}),(0,Q.jsx)(Wn,{id:`description`,value:e.description||``,onChange:e=>t(`description`,e.target.value),placeholder:`Main description`,className:`min-h-[60px]`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`remarks`,children:`Remarks`}),(0,Q.jsx)(Wn,{id:`remarks`,value:e.remarks||``,onChange:e=>t(`remarks`,e.target.value),placeholder:`Additional remarks`,className:`min-h-[60px]`})]})]})]}),a&&(0,Q.jsx)($G,{client:a,fetching:c,onChange:e=>u(e)}),p&&(0,Q.jsx)(nK,{income:e.income||[],currency:e.currency,onChange:e=>t(`income`,e)}),m&&(0,Q.jsx)(oK,{payments:e.payment||[],currency:e.currency,onChange:e=>t(`payment`,e)})]})}var fK=({formManager:e,isInsert:t})=>{let{control:n,setValue:r}=e,{selectableFinancialEntities:i,fetching:a}=SG();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{name:`creditorId`,control:n,rules:{required:t?`Required`:void 0},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Creditor`}),(0,Q.jsx)(WJ,{...e,data:i,value:e.value??void 0,disabled:a,placeholder:`Select creditor`,formPart:!0}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`debtorId`,control:n,rules:{required:t?`Required`:void 0},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Debtor`}),(0,Q.jsx)(WJ,{...e,data:i,value:e.value??void 0,disabled:a,placeholder:`Select debtor`,formPart:!0}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(pr,{name:`amount`,control:n,rules:{required:t?`Required`:void 0},render:({field:e,fieldState:r})=>(0,Q.jsx)(pr,{name:`currency`,control:n,rules:{required:t?`Required`:void 0},render:({field:n,fieldState:i})=>(0,Q.jsx)(YJ,{...e,required:t,value:e.value??void 0,error:r.error?.message||i.error?.message,label:`Amount`,currencyCodeProps:{...n,required:t,label:`Currency`}})})}),(0,Q.jsx)(Ar,{name:`invoiceDate`,control:n,rules:{...t?{required:`Required`}:{},pattern:{value:Ql,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:n})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{htmlFor:`misc-expense-invoice-date`,children:`Invoice Date`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(kZ,{id:`misc-expense-invoice-date`,required:t,onChange:t=>{t!==e.value&&e.onChange(t)},value:e.value??void 0,"aria-invalid":!!n.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`valueDate`,control:n,rules:{...t?{required:`Required`}:{},validate:e=>!e||!Number.isNaN(e.getTime())||`Invalid date and time format`},render:({field:e,fieldState:n})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{htmlFor:`misc-expense-value-date`,children:`Value Date`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(NZ,{id:`misc-expense-value-date`,value:e.value??null,onChange:t=>{r(`valueDate`,t),e.onChange(t)},required:t,"aria-invalid":!!n.error})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`description`,control:n,rules:{required:t?`Required`:void 0},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Description`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,required:t,value:e.value??void 0})}),(0,Q.jsx)(mi,{})]})})]})},pK=()=>{let[{data:e,fetching:t,error:n},r]=W({query:R});n&&(console.error(`Error fetching businesses: ${n}`),K.error(`Error`,{description:`Unable to fetch businesses`}));let i=(0,Z.useMemo)(()=>e?.allBusinesses?.nodes.sort((e,t)=>e.name>t.name?1:-1)??[],[e]);return{fetching:t,refresh:()=>r(),businesses:i,selectableBusinesses:(0,Z.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i])}},mK=({isNewInsert:e=!0,defaultValues:t,month:n,onDone:r,isModifying:i})=>{let{selectableBusinesses:a,fetching:o}=pK(),[{data:s,fetching:c,error:u}]=W({query:P}),{userContext:d}=(0,Z.useContext)(nr),[{data:f,fetching:p,error:m}]=W({query:te}),[{data:h,fetching:g,error:_}]=W({query:l,variables:{employerId:d?.context.adminBusinessId??``}}),[v,y]=(0,Z.useState)([]),[b,x]=(0,Z.useState)([]),[S,C]=(0,Z.useState)([]),w=t?.month??n,T=Mr({defaultValues:{...t,month:w}}),{control:E,handleSubmit:D,formState:{dirtyFields:O},setValue:k}=T;(0,Z.useEffect)(()=>{u&&K.error(`Error`,{description:`Oh no!, we have an error fetching pension funds! 🤥`})},[u]),(0,Z.useEffect)(()=>{m&&K.error(`Error`,{description:`Oh no!, we have an error fetching training funds! 🤥`})},[m]),(0,Z.useEffect)(()=>{_&&K.error(`Error`,{description:`Oh no!, we have an error employees! 🤥`})},[_]),(0,Z.useEffect)(()=>{s?.allPensionFunds?.length&&y(s.allPensionFunds.map(e=>({value:e.id,label:e.name})).sort((e,t)=>e.label>t.label?1:-1))},[s,x]),(0,Z.useEffect)(()=>{f?.allTrainingFunds?.length&&x(f.allTrainingFunds.map(e=>({value:e.id,label:e.name})).sort((e,t)=>e.label>t.label?1:-1))},[f,x]),(0,Z.useEffect)(()=>{h?.employeesByEmployerId.length&&C(h.employeesByEmployerId.filter(e=>!e.name.toLocaleLowerCase().includes(`batched`)).map(e=>({value:e.id,label:e.name})).sort((e,t)=>e.label>t.label?1:-1))},[h,x]),(0,Z.useEffect)(()=>{!t?.employer&&d?.context.adminBusinessId&&k(`employer`,d.context.adminBusinessId,{shouldDirty:!0,shouldTouch:!0})},[k,t?.employer,d?.context.adminBusinessId]);let A=n=>{let i=gt(n,O);if(!(e&&(!i?.directPaymentAmount||!i?.employeeId||!i?.employer||!i?.month))){if(i&&Object.keys(i).length>0){if(!e){if(!t)return;i.employeeId??=t.employeeId,i.month??=t.month}r(i)}else r()}};function j(e){k(`month`,Or(e,`yyyy-MM-dd`),{shouldDirty:!0,shouldTouch:!0})}return(0,Q.jsx)(kr,{...T,children:(0,Q.jsxs)(`form`,{onSubmit:D(A),children:[(0,Q.jsx)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:(0,Q.jsxs)(X9,{cols:4,children:[(0,Q.jsxs)(`div`,{className:`flex-column h-max justify-start block`,children:[(0,Q.jsx)(eG,{defaultDate:w?new Date(w):void 0,defaultValue:w?new Date(w):void 0,onChange:j,popoverProps:{withinPortal:!0}}),(0,Q.jsx)(pr,{name:`employer`,control:E,defaultValue:t?.employer,rules:{required:`Required`},render:({field:e,fieldState:t})=>(0,Q.jsx)(JO,{...e,data:a,value:e.value,disabled:o,label:`Employer`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message})}),(0,Q.jsx)(Ar,{name:`chargeId`,control:E,defaultValue:t?.chargeId,rules:{pattern:{value:$l,message:`Invalid UUID`}},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Charge ID`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??void 0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(pr,{name:`employeeId`,control:E,defaultValue:t?.employeeId,rules:{required:`Required`},render:({field:e,fieldState:t})=>(0,Q.jsx)(JO,{...e,data:S,value:e.value,disabled:g,label:`Employee`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`baseSalary`,control:E,defaultValue:t?.baseSalary,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Base Salary`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`globalAdditionalHours`,control:E,defaultValue:t?.globalAdditionalHours,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Global Additional Hours`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`bonus`,control:E,defaultValue:t?.bonus,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Bonus`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`gift`,control:E,defaultValue:t?.gift,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Gift`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`travelAndSubsistence`,control:E,defaultValue:t?.travelAndSubsistence,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Travel and Subsistence`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`recovery`,control:E,defaultValue:t?.recovery,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Recovery`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`}})}),(0,Q.jsx)(pr,{name:`vacationTakeout`,control:E,defaultValue:t?.vacationTakeout,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Vacation Takeout`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`directPaymentAmount`,control:E,defaultValue:t?.directPaymentAmount,rules:{required:`Required`},render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Direct Payment`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`pensionFundId`,control:E,defaultValue:t?.pensionFundId,render:({field:e,fieldState:t})=>(0,Q.jsx)(JO,{...e,data:v,value:e.value,disabled:c,label:`Pension Fund`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message})}),(0,Q.jsx)(pr,{name:`pensionEmployeeAmount`,control:E,defaultValue:t?.pensionEmployeeAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Pension Employee Amount`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`pensionEmployeePercentage`,control:E,defaultValue:t?.pensionEmployeePercentage,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:`%`,value:e??void 0,error:n.error?.message,label:`Pension Employee Percentage`})}),(0,Q.jsx)(pr,{name:`pensionEmployerAmount`,control:E,defaultValue:t?.pensionEmployerAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Pension Employer Amount`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`pensionEmployerPercentage`,control:E,defaultValue:t?.pensionEmployerPercentage,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:`%`,value:e??void 0,error:n.error?.message,label:`Pension Employer Percentage`})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`compensationsEmployerAmount`,control:E,defaultValue:t?.compensationsEmployerAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Compensations Amount`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`compensationsEmployerPercentage`,control:E,defaultValue:t?.compensationsEmployerPercentage,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:`%`,value:e??void 0,error:n.error?.message,label:`Compensations Percentage`})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`trainingFundId`,control:E,defaultValue:t?.trainingFundId,render:({field:e,fieldState:t})=>(0,Q.jsx)(JO,{...e,data:b,value:e.value,disabled:p,label:`Training Fund`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message})}),(0,Q.jsx)(pr,{name:`trainingFundEmployeeAmount`,control:E,defaultValue:t?.trainingFundEmployeeAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Training Employee Amount`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`trainingFundEmployeePercentage`,control:E,defaultValue:t?.trainingFundEmployeePercentage,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:`%`,value:e??void 0,error:n.error?.message,label:`Training Employee Percentage`})}),(0,Q.jsx)(pr,{name:`trainingFundEmployerAmount`,control:E,defaultValue:t?.trainingFundEmployerAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Training Employer Amount`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`trainingFundEmployerPercentage`,control:E,defaultValue:t?.trainingFundEmployerPercentage,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:`%`,value:e??void 0,error:n.error?.message,label:`Training Employer Percentage`})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`socialSecurityAmountEmployee`,control:E,defaultValue:t?.socialSecurityAmountEmployee,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Social Security - Employee`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`socialSecurityAmountEmployer`,control:E,defaultValue:t?.socialSecurityAmountEmployer,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Social Security - Employer`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`healthPaymentAmount`,control:E,defaultValue:t?.healthPaymentAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Health Insurance`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`taxAmount`,control:E,defaultValue:t?.taxAmount,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,label:`Income Tax`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})}),(0,Q.jsx)(pr,{name:`zkufot`,control:E,defaultValue:t?.zkufot,render:({field:e,fieldState:t})=>(0,Q.jsx)(YJ,{...e,value:e.value??void 0,error:t.error?.message,precision:0,label:`Notional Expense`,removeTrailingZeros:!0,currencyCodeProps:{value:`ILS`,label:`Currency`,disabled:!0}})})]}),(0,Q.jsxs)(`div`,{className:`flex-row px-10 h-max justify-start block`,children:[(0,Q.jsx)(pr,{name:`workDays`,control:E,defaultValue:t?.workDays,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,value:e??void 0,error:n.error?.message,label:`Work Days`})}),(0,Q.jsx)(pr,{name:`addedVacationDays`,control:E,defaultValue:t?.addedVacationDays,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,value:e??void 0,error:n.error?.message,label:`Added Vacation Days`})}),(0,Q.jsx)(pr,{name:`vacationDaysBalance`,control:E,defaultValue:t?.vacationDaysBalance,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,value:e??void 0,error:n.error?.message,label:`Vacation Days Balance`})}),(0,Q.jsx)(pr,{name:`sicknessDaysBalance`,control:E,defaultValue:t?.sicknessDaysBalance,render:({field:{value:e,...t},fieldState:n})=>(0,Q.jsx)(MO,{...t,hideControls:!0,precision:2,removeTrailingZeros:!0,value:e??void 0,error:n.error?.message,label:`Sickness Days Balance`})})]})]})}),(0,Q.jsxs)(`div`,{className:`mt-10 mb-5 flex justify-center gap-5`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:`mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:i||Object.keys(O).length===0,children:`Accept`}),(0,Q.jsx)(`button`,{type:`button`,className:`mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg`,onClick:()=>r(),children:`Cancel`})]})]})})};function hK({isInsert:e,formManager:t}){let{control:n}=t;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{name:`key`,control:n,disabled:!e,rules:{required:`Required`,validate:{positive:e=>Number(e)>0||`Key must be a positive number`,integer:e=>Number.isInteger(Number(e))||`Key must be an integer`}},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Key`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(l0,{...e,value:e.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:``,required:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`name`,control:n,rules:{required:`Required`,minLength:{value:2,message:`Must be at least 2 characters`}},render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Name`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??void 0,required:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`defaultIrsCode`,control:n,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Default IRS Code`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(l0,{...e,value:e.value??void 0,hideControls:!0,decimalScale:0})}),(0,Q.jsx)(mi,{})]})})]})}var gK=({data:e})=>{let t=e.map(e=>Lr(Oe,e));return(0,Q.jsx)(`div`,{className:`flex flex-col gap-4 mt-5`,children:t.filter(({charge:e})=>e).map(e=>(0,Q.jsx)(vt,{to:yt.CHARGES.DETAIL(e.charge.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:`${e.charge.counterparty?.name??`Unknown`} - ${e.charge.userDescription}`},e.id))})},_K=`uploadMultipleDocuments`,vK=()=>{let[{fetching:e},t]=H(_);return{uploading:e,uploadMultipleDocuments:(0,Z.useCallback)(async e=>{let n=`Error uploading documents`,r=`${_K}-${e.chargeId}`;K.loading(`Uploading Documents`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`batchUploadDocuments`);if(a){let e=!1,t=a.batchUploadDocuments.filter(t=>`message`in t?(console.error(`Error uploading document: ${t.message}`),e=!0,!1):`document`in t).map(({document:e})=>e);return K.success(`Upload Successful`,{id:r,description:t.length>0?gK({data:t}):`No successful document uploads`,duration:t.length>0?1/0:5e3,closeButton:!0}),e&&K.error(`Some files failed to upload`,{duration:1e5,closeButton:!0}),t}}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},yK=`insertSalaryRecordsFromFile`,bK=()=>{let[{fetching:e},t]=H(De);return{fetching:e,uploadPayrollFile:(0,Z.useCallback)(async e=>{let n=`Error uploading payroll file to charge ID [${e.chargeId}]`,r=`${yK}-${e.chargeId}`;K.loading(`Uploading payroll file`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`insertSalaryRecordsFromFile`);if(a)return K.success(`Success`,{id:r,description:`Payroll file added`}),a.insertSalaryRecordsFromFile}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return!1},[t])}},xK=({chargeId:e,onDone:t})=>{let{fetching:n,uploadPayrollFile:r}=bK(),[i,a]=(0,Z.useState)(null),o=(0,Z.useCallback)(async()=>{i&&r({file:i,chargeId:e}).then(t)},[r,t,i,e]);return(0,Q.jsxs)(`div`,{className:`px-5 w-max h-max justify-items-center`,children:[(0,Q.jsx)(Sw,{icon:n&&(0,Q.jsx)(ti,{}),value:i,onChange:a,clearable:!0,label:`File Upload`}),(0,Q.jsx)(`div`,{className:`flex justify-center gap-5 mt-5`,children:(0,Q.jsx)(`button`,{type:`submit`,className:` text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,disabled:n||!i,onClick:o,children:`Accept`})})]})};function SK({children:e,content:t,disabled:n,asChild:r=!1,...i}){return n?e:(0,Q.jsx)(xr,{children:(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{asChild:r,children:e}),(0,Q.jsx)(yr,{...i,children:t})]})})}function CK({src:e,width:t,height:n,magnifierHeight:r=100,magnifierWidth:i=100,zoomLevel:a=1.5}){let[o,s]=(0,Z.useState)({x:0,y:0}),[c,l]=(0,Z.useState)({height:0,width:0}),[u,d]=(0,Z.useState)(a),[f,p]=(0,Z.useState)({width:i,height:r}),[m,h]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{style:{position:`relative`,height:n,width:t},children:[(0,Q.jsx)(`img`,{src:e,style:{height:n,width:t},onMouseEnter:e=>{let{width:t,height:n}=e.currentTarget.getBoundingClientRect();l({width:t,height:n}),h(!0)},onMouseMove:e=>{let{top:t,left:n}=e.currentTarget.getBoundingClientRect(),r=e.pageX-n-window.pageXOffset,i=e.pageY-t-window.pageYOffset;s({x:r,y:i})},onMouseLeave:()=>{h(!1)},alt:`img`}),(0,Q.jsx)(`div`,{style:{display:m?``:`none`,position:`absolute`,pointerEvents:`none`,height:`${f.height}px`,width:`${f.width}px`,top:`${o.y-f.height/2}px`,left:`${o.x-f.width/2}px`,opacity:`1`,border:`1px solid lightgray`,backgroundColor:`white`,backgroundImage:`url('${e}')`,backgroundRepeat:`no-repeat`,backgroundSize:`${c.width*u}px ${c.height*u}px`,backgroundPositionX:`${-o.x*u+f.width/2}px`,backgroundPositionY:`${-o.y*u+f.height/2}px`}}),(0,Q.jsxs)(`div`,{className:`absolute top-10 right-10 flex flex-row gap-1`,children:[(0,Q.jsx)(SK,{content:`Increase zoom`,asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),d(e=>e*1.2)},children:(0,Q.jsx)(Ma,{className:`size-5`})})}),(0,Q.jsx)(SK,{content:`Decrease zoom`,asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),d(e=>e/1.2)},children:(0,Q.jsx)(Na,{className:`size-5`})})}),(0,Q.jsx)(SK,{content:`Expand zoom area`,asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),p(e=>({width:e.width*1.2,height:e.height*1.2}))},children:(0,Q.jsx)(Ma,{className:`size-5`})})}),(0,Q.jsx)(SK,{content:`Reduce zoom area`,asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),p(e=>({width:e.width/1.2,height:e.height/1.2}))},children:(0,Q.jsx)(Na,{className:`size-5`})})})]})]})}function wK(e,t){let{control:n,watch:r}=e,{fields:i,append:a,remove:o}=Fr({control:n,name:t}),s=r(t)??[];return{controlledFields:i.map((e,t)=>{let n=s[t];return{...e,...typeof n==`object`&&n?n:{}}}),append:a,remove:o,watchFieldArray:s}}function TK({formManager:e,chargeSpreadPath:t}){let{control:n,trigger:r}=e,{controlledFields:i,append:a,remove:o,watchFieldArray:s}=wK(e,t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mantine-InputWrapper-label mantine-Select-label`,children:`Charge Spread`}),(0,Q.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[i?.map((e,i)=>(0,Q.jsxs)(`div`,{className:`flex items-end gap-2 text-gray-600 mb-2`,children:[(0,Q.jsx)(`div`,{className:`w-full mt-1 relative rounded-md shadow-xs`,children:(0,Q.jsx)(pr,{name:`${t}.${i}.year`,control:n,rules:{required:`Required`,validate:e=>s.map(e=>e.year).filter(t=>t===e).length>1?`Years must be unique`:!0},render:({field:{value:e,...n},fieldState:i})=>(0,Q.jsx)(xG,{...n,label:`Year of relevance`,value:e?new Date(e):null,error:i.error?.message,popoverProps:{withinPortal:!0,zIndex:1002},required:!0,onChange:e=>{r(t),n.onChange(e?Or(e,`yyyy-MM-dd`):void 0)}})})}),(0,Q.jsx)(`div`,{className:`w-full mt-1 relative rounded-md shadow-xs`,children:(0,Q.jsx)(pr,{control:n,name:`${t}.${i}.amount`,render:({field:e,fieldState:t})=>(0,Q.jsx)(MO,{className:`w-full`,...e,min:0,label:`Amount`,value:e.value??void 0,hideControls:!0,precision:2,error:t.error?.message,onChange:t=>e.onChange(t&&typeof t==`number`?t:void 0)})})}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5 mb-2`,onClick:()=>{o(i),r(t)},children:(0,Q.jsx)(Xn,{className:`size-5`})})]},e.id)),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7.5`,onClick:()=>{a({year:`${new Date().getFullYear()}-01-01`}),r(t)},children:(0,Q.jsx)(sa,{className:`size-5`})})]})]})}function EK(e){let[t,n]=Z.useState(!1);return Z.useEffect(()=>{function t(e){n(e.matches)}let r=matchMedia(e);return r.addEventListener(`change`,t),n(r.matches),()=>r.removeEventListener(`change`,t)},[e]),t}var DK=1,OK=.9,kK=.8,AK=.17,jK=.1,MK=.999,NK=.9999,PK=.99,FK=/[\\\/_+.#"@\[\(\{&]/,IK=/[\\\/_+.#"@\[\(\{&]/g,LK=/[\s-]/,RK=/[\s-]/g;function zK(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?DK:PK;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=zK(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=DK:FK.test(e.charAt(l-1))?(d*=kK,p=e.slice(i,l-1).match(IK),p&&i>0&&(d*=MK**+p.length)):LK.test(e.charAt(l-1))?(d*=OK,m=e.slice(i,l-1).match(RK),m&&i>0&&(d*=MK**+m.length)):(d*=AK,i>0&&(d*=MK**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=NK)),(d<jK&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=zK(e,t,n,r,l+1,a+2,o),f*jK>d&&(d=f*jK)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function BK(e){return e.toLowerCase().replace(RK,` `)}function VK(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,zK(e,t,BK(e),BK(t),0,0,{})}var HK=`[cmdk-group=""]`,UK=`[cmdk-group-items=""]`,WK=`[cmdk-group-heading=""]`,GK=`[cmdk-item=""]`,KK=`${GK}:not([aria-disabled="true"])`,qK=`cmdk-item-select`,JK=`data-value`,YK=(e,t,n)=>VK(e,t,n),XK=Z.createContext(void 0),ZK=()=>Z.useContext(XK),QK=Z.createContext(void 0),$K=()=>Z.useContext(QK),eq=Z.createContext(void 0),tq=Z.forwardRef((e,t)=>{let n=hq(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=hq(()=>new Set),i=hq(()=>new Map),a=hq(()=>new Map),o=hq(()=>new Set),s=pq(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=xt(),y=xt(),b=xt(),x=Z.useRef(null),S=vq();mq(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),mq(()=>{S(6,k)},[]);let C=Z.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Z.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??YK;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(UK);t?t.appendChild(e.parentElement===t?e:e.closest(`${UK} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${UK} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${HK}[${JK}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(JK);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(HK)?.querySelector(WK))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${GK}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(KK)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(JK))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(JK))}function P(e){let t=A()?.closest(HK),n;for(;t&&!n;)t=e>0?dq(t,HK):fq(t,HK),n=t?.querySelector(KK);n?C.setState(`value`,n.getAttribute(JK)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Z.createElement(Cn.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(qK);t.dispatchEvent(e)}}}}},Z.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:xq},c),bq(e,e=>Z.createElement(QK.Provider,{value:C},Z.createElement(XK.Provider,{value:w},e))))}),nq=Z.forwardRef((e,t)=>{let n=xt(),r=Z.useRef(null),i=Z.useContext(eq),a=ZK(),o=pq(e),s=o.current?.forceMount??i?.forceMount;mq(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=_q(n,r,[e.value,e.children,r],e.keywords),l=$K(),u=gq(e=>e.value&&e.value===c.current),d=gq(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Z.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(qK,f),()=>t.removeEventListener(qK,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Z.createElement(Cn.div,{ref:er(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),rq=Z.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=xt(),s=Z.useRef(null),c=Z.useRef(null),l=xt(),u=ZK(),d=gq(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));mq(()=>u.group(o),[]),_q(o,s,[e.value,e.heading,c]);let f=Z.useMemo(()=>({id:o,forceMount:i}),[i]);return Z.createElement(Cn.div,{ref:er(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Z.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),bq(e,e=>Z.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Z.createElement(eq.Provider,{value:f},e))))}),iq=Z.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Z.useRef(null),a=gq(e=>!e.search);return!n&&!a?null:Z.createElement(Cn.div,{ref:er(i,t),...r,"cmdk-separator":``,role:`separator`})}),aq=Z.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=$K(),o=gq(e=>e.search),s=gq(e=>e.selectedItemId),c=ZK();return Z.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Z.createElement(Cn.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),oq=Z.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Z.useRef(null),o=Z.useRef(null),s=gq(e=>e.selectedItemId),c=ZK();return Z.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Z.createElement(Cn.div,{ref:er(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},bq(e,e=>Z.createElement(`div`,{ref:er(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),sq=Z.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Z.createElement(Nt,{open:n,onOpenChange:r},Z.createElement(Mt,{container:o},Z.createElement(kt,{"cmdk-overlay":``,className:i}),Z.createElement(It,{"aria-label":e.label,"cmdk-dialog":``,className:a},Z.createElement(tq,{ref:t,...s}))))}),cq=Z.forwardRef((e,t)=>gq(e=>e.filtered.count===0)?Z.createElement(Cn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),lq=Z.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Z.createElement(Cn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},bq(e,e=>Z.createElement(`div`,{"aria-hidden":!0},e)))}),uq=Object.assign(tq,{List:oq,Item:nq,Input:aq,Group:rq,Separator:iq,Dialog:sq,Empty:cq,Loading:lq});function dq(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fq(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pq(e){let t=Z.useRef(e);return mq(()=>{t.current=e}),t}var mq=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function hq(e){let t=Z.useRef();return t.current===void 0&&(t.current=e()),t}function gq(e){let t=$K(),n=()=>e(t.snapshot());return Z.useSyncExternalStore(t.subscribe,n,n)}function _q(e,t,n,r=[]){let i=Z.useRef(),a=ZK();return mq(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(JK,s),i.current=s}),i}var vq=()=>{let[e,t]=Z.useState(),n=hq(()=>new Map);return mq(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function yq(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function bq({asChild:e,children:t},n){return e&&Z.isValidElement(t)?Z.cloneElement(yq(t),{ref:t.ref},n(t.props.children)):n(t)}var xq={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Sq({className:e,...t}){return(0,Q.jsx)(uq,{"data-slot":`command`,className:s(`bg-white text-gray-950 flex h-full w-full flex-col overflow-hidden rounded-md dark:bg-gray-950 dark:text-gray-50`,e),...t})}function Cq({className:e,...t}){return(0,Q.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,Q.jsx)(Fn,{className:`size-4 shrink-0 opacity-50`}),(0,Q.jsx)(uq.Input,{"data-slot":`command-input`,className:s(`placeholder:text-gray-500 flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50 dark:placeholder:text-gray-400`,e),...t})]})}function wq({className:e,...t}){return(0,Q.jsx)(uq.List,{"data-slot":`command-list`,className:s(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function Tq({...e}){return(0,Q.jsx)(uq.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function Eq({className:e,...t}){return(0,Q.jsx)(uq.Group,{"data-slot":`command-group`,className:s(`text-gray-950 [&_[cmdk-group-heading]]:text-gray-500 overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium dark:text-gray-50 dark:[&_[cmdk-group-heading]]:text-gray-400`,e),...t})}function Dq({className:e,...t}){return(0,Q.jsx)(uq.Separator,{"data-slot":`command-separator`,className:s(`bg-gray-200 -mx-1 h-px dark:bg-gray-800`,e),...t})}function Oq({className:e,...t}){return(0,Q.jsx)(uq.Item,{"data-slot":`command-item`,className:s(`data-[selected=true]:bg-gray-100 data-[selected=true]:text-gray-900 [&_svg:not([class*='text-'])]:text-gray-500 relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 dark:data-[selected=true]:bg-gray-800 dark:data-[selected=true]:text-gray-50 dark:[&_svg:not([class*='text-'])]:text-gray-400`,e),...t})}function kq(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Aq=Z.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:`bottom`,shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),jq=()=>{let e=Z.useContext(Aq);if(!e)throw Error(`useDrawerContext must be used within a Drawer.Root`);return e};kq(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
[data-state=closed]
){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function Mq(){let e=navigator.userAgent;return typeof window<`u`&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Nq(){return Rq(/^Mac/)}function Pq(){return Rq(/^iPhone/)}function Fq(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Iq(){return Rq(/^iPad/)||Nq()&&navigator.maxTouchPoints>1}function Lq(){return Pq()||Iq()}function Rq(e){return typeof window<`u`&&window.navigator!=null?e.test(window.navigator.platform):void 0}var zq=24,Bq=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function Vq(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}var Hq=typeof document<`u`&&window.visualViewport;function Uq(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Wq(e){for(Uq(e)&&(e=e.parentElement);e&&!Uq(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var Gq=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]),Kq=0,qq;function Jq(e={}){let{isDisabled:t}=e;Bq(()=>{if(!t)return Kq++,Kq===1&&Lq()&&(qq=Yq()),()=>{Kq--,Kq===0&&qq?.()}},[t])}function Yq(){let e,t=0,n=n=>{e=Wq(n.target),(e!==document.documentElement||e!==document.body)&&(t=n.changedTouches[0].pageY)},r=n=>{if(!e||e===document.documentElement||e===document.body){n.preventDefault();return}let r=n.changedTouches[0].pageY,i=e.scrollTop,a=e.scrollHeight-e.clientHeight;a!==0&&((i<=0&&r>t||i>=a&&r<t)&&n.preventDefault(),t=r)},i=e=>{let t=e.target;$q(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform=`translateY(-2000px)`,t.focus(),requestAnimationFrame(()=>{t.style.transform=``}))},a=e=>{let t=e.target;$q(t)&&(t.style.transform=`translateY(-2000px)`,requestAnimationFrame(()=>{t.style.transform=``,Hq&&(Hq.height<window.innerHeight?requestAnimationFrame(()=>{Qq(t)}):Hq.addEventListener(`resize`,()=>Qq(t),{once:!0}))}))},o=()=>{window.scrollTo(0,0)},s=window.pageXOffset,c=window.pageYOffset,l=Vq(Xq(document.documentElement,`paddingRight`,`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let u=Vq(Zq(document,`touchstart`,n,{passive:!1,capture:!0}),Zq(document,`touchmove`,r,{passive:!1,capture:!0}),Zq(document,`touchend`,i,{passive:!1,capture:!0}),Zq(document,`focus`,a,!0),Zq(window,`scroll`,o));return()=>{l(),u(),window.scrollTo(s,c)}}function Xq(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}function Zq(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Qq(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=Wq(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+zq&&(t.scrollTop+=r-n)}e=t.parentElement}}function $q(e){return e instanceof HTMLInputElement&&!Gq.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function eJ(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}function tJ(...e){return t=>e.forEach(e=>eJ(e,t))}function nJ(...e){return Z.useCallback(tJ(...e),e)}var rJ=new WeakMap;function iJ(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([t,n])=>{if(t.startsWith(`--`)){e.style.setProperty(t,n);return}r[t]=e.style[t],e.style[t]=n}),!n&&rJ.set(e,r)}function aJ(e,t){if(!e||!(e instanceof HTMLElement))return;let n=rJ.get(e);n&&(e.style[t]=n[t])}var oJ=e=>{switch(e){case`top`:case`bottom`:return!0;case`left`:case`right`:return!1;default:return e}};function sJ(e,t){if(!e)return null;let n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform,i=r.match(/^matrix3d\((.+)\)$/);return i?parseFloat(i[1].split(`, `)[oJ(t)?13:12]):(i=r.match(/^matrix\((.+)\)$/),i?parseFloat(i[1].split(`, `)[oJ(t)?5:4]):null)}function cJ(e){return 8*(Math.log(e+1)-2)}function lJ(e,t){if(!e)return()=>{};let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}var uJ={DURATION:.5,EASE:[.32,.72,0,1]},dJ=.4,fJ=.25,pJ=100,mJ=8,hJ=16,gJ=26,_J=`vaul-dragging`;function vJ(e){let t=Z.useRef(e);return Z.useEffect(()=>{t.current=e}),Z.useMemo(()=>(...e)=>t.current==null?void 0:t.current.call(t,...e),[])}function yJ({defaultProp:e,onChange:t}){let n=Z.useState(e),[r]=n,i=Z.useRef(r),a=vJ(t);return Z.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}function bJ({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=yJ({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=vJ(n);return[o,Z.useCallback(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function xJ({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:i,fadeFromIndex:a,onSnapPointChange:o,direction:s=`bottom`,container:c,snapToSequentialPoint:l}){let[u,d]=bJ({prop:e,defaultProp:n?.[0],onChange:t}),[f,p]=Z.useState(typeof window<`u`?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);Z.useEffect(()=>{function e(){p({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=Z.useMemo(()=>u===n?.[n.length-1]||null,[n,u]),h=Z.useMemo(()=>n?.findIndex(e=>e===u)??null,[n,u]),g=n&&n.length>0&&(a||a===0)&&!Number.isNaN(a)&&n[a]===u||!n,_=Z.useMemo(()=>{let e=c?{width:c.getBoundingClientRect().width,height:c.getBoundingClientRect().height}:typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};return n?.map(t=>{let n=typeof t==`string`,r=0;if(n&&(r=parseInt(t,10)),oJ(s)){let i=n?r:f?t*e.height:0;return f?s===`bottom`?e.height-i:-e.height+i:i}let i=n?r:f?t*e.width:0;return f?s===`right`?e.width-i:-e.width+i:i})??[]},[n,f,c]),v=Z.useMemo(()=>h===null?null:_?.[h],[_,h]),y=Z.useCallback(e=>{let t=_?.findIndex(t=>t===e)??null;o(t),iJ(r.current,{transition:`transform ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`,transform:oJ(s)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),_&&t!==_.length-1&&a!==void 0&&t!==a&&t<a?iJ(i.current,{transition:`opacity ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`,opacity:`0`}):iJ(i.current,{transition:`opacity ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`,opacity:`1`}),d(n?.[Math.max(t,0)])},[r.current,n,_,a,i,d]);Z.useEffect(()=>{if(u||e){let t=n?.findIndex(t=>t===e||t===u)??-1;_&&t!==-1&&typeof _[t]==`number`&&y(_[t])}},[u,e,n,_,y]);function b({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:o}){if(a===void 0)return;let c=s===`bottom`||s===`right`?(v??0)-e:(v??0)+e,u=h===a-1,d=h===0,f=e>0;if(u&&iJ(i.current,{transition:`opacity ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`}),!l&&r>2&&!f){o?t():y(_[0]);return}if(!l&&r>2&&f&&_&&n){y(_[n.length-1]);return}let p=_?.reduce((e,t)=>typeof e!=`number`||typeof t!=`number`?e:Math.abs(t-c)<Math.abs(e-c)?t:e),g=oJ(s)?window.innerHeight:window.innerWidth;if(r>dJ&&Math.abs(e)<g*.4){let e=f?1:-1;if(e>0&&m&&n){y(_[n.length-1]);return}if(d&&e<0&&o&&t(),h===null)return;y(_[h+e]);return}y(p)}function x({draggedDistance:e}){if(v===null)return;let t=s===`bottom`||s===`right`?v-e:v+e;(s===`bottom`||s===`right`)&&t<_[_.length-1]||(s===`top`||s===`left`)&&t>_[_.length-1]||iJ(r.current,{transform:oJ(s)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})}function S(e,t){if(!n||typeof h!=`number`||!_||a===void 0)return null;let r=h===a-1;if(h>=a&&t)return 0;if(r&&!t)return 1;if(!g&&!r)return null;let i=r?h+1:h-1,o=r?_[i]-_[i-1]:_[i+1]-_[i],s=e/Math.abs(o);return r?1-s:s}return{isLastSnapPoint:m,activeSnapPoint:u,shouldFade:g,getPercentageDragged:S,setActiveSnapPoint:d,activeSnapPointIndex:h,onRelease:b,onDrag:x,snapPointsOffset:_}}function SJ(){let{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:i}=jq(),a=Z.useRef(null),o=(0,Z.useMemo)(()=>document.body.style.backgroundColor,[]);function s(){return(window.innerWidth-gJ)/window.innerWidth}Z.useEffect(()=>{if(t&&n){a.current&&clearTimeout(a.current);let t=document.querySelector(`[data-vaul-drawer-wrapper]`)||document.querySelector(`[vaul-drawer-wrapper]`);if(!t)return;r&&!i&&lJ(document.body,{background:`black`}),lJ(t,{transformOrigin:oJ(e)?`top`:`left`,transitionProperty:`transform, border-radius`,transitionDuration:`${uJ.DURATION}s`,transitionTimingFunction:`cubic-bezier(${uJ.EASE.join(`,`)})`});let n=lJ(t,{borderRadius:`${mJ}px`,overflow:`hidden`,...oJ(e)?{transform:`scale(${s()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${s()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{n(),a.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty(`background`)},uJ.DURATION*1e3)}}},[t,n,o])}var CJ=null;function wJ({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:i,noBodyStyles:a}){let[o,s]=Z.useState(()=>typeof window<`u`?window.location.href:``),c=Z.useRef(0),l=Z.useCallback(()=>{if(Fq()&&CJ===null&&e&&!a){CJ={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:`unset`};let{scrollX:e,innerHeight:t}=window;document.body.style.setProperty(`position`,`fixed`,`important`),Object.assign(document.body.style,{top:`${-c.current}px`,left:`${-e}px`,right:`0px`,height:`auto`}),window.setTimeout(()=>window.requestAnimationFrame(()=>{let e=t-window.innerHeight;e&&c.current>=t&&(document.body.style.top=`${-(c.current+e)}px`)}),300)}},[e]),u=Z.useCallback(()=>{if(Fq()&&CJ!==null&&!a){let e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,CJ),window.requestAnimationFrame(()=>{if(i&&o!==window.location.href){s(window.location.href);return}window.scrollTo(t,e)}),CJ=null}},[o]);return Z.useEffect(()=>{function e(){c.current=window.scrollY}return e(),window.addEventListener(`scroll`,e),()=>{window.removeEventListener(`scroll`,e)}},[]),Z.useEffect(()=>{if(t)return()=>{typeof document>`u`||document.querySelector(`[data-vaul-drawer]`)||u()}},[t,u]),Z.useEffect(()=>{n||!r||(e?(!window.matchMedia(`(display-mode: standalone)`).matches&&l(),t||window.setTimeout(()=>{u()},500)):u())},[e,r,o,t,n,l,u]),{restorePositionSetting:u}}function TJ({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:i,snapPoints:a,shouldScaleBackground:o=!1,setBackgroundColorOnScale:s=!0,closeThreshold:c=fJ,scrollLockTimeout:l=pJ,dismissible:u=!0,handleOnly:d=!1,fadeFromIndex:f=a&&a.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:h,modal:g=!0,onClose:_,nested:v,noBodyStyles:y=!1,direction:b=`bottom`,defaultOpen:x=!1,disablePreventScroll:S=!0,snapToSequentialPoint:C=!1,preventScrollRestoration:w=!1,repositionInputs:T=!0,onAnimationEnd:E,container:D,autoFocus:O=!1}){let[k=!1,A]=bJ({defaultProp:x,prop:e,onChange:e=>{t?.(e),!e&&!v&&me(),setTimeout(()=>{E?.(e)},uJ.DURATION*1e3),e&&!g&&typeof window<`u`&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents=`auto`}),e||(document.body.style.pointerEvents=`auto`)}}),[j,M]=Z.useState(!1),[N,P]=Z.useState(!1),[F,I]=Z.useState(!1),L=Z.useRef(null),R=Z.useRef(null),z=Z.useRef(null),B=Z.useRef(null),V=Z.useRef(null),ee=Z.useRef(!1),te=Z.useRef(null),ne=Z.useRef(0),re=Z.useRef(!1),H=Z.useRef(!x),ie=Z.useRef(0),U=Z.useRef(null),W=Z.useRef(U.current?.getBoundingClientRect().height||0),ae=Z.useRef(U.current?.getBoundingClientRect().width||0),G=Z.useRef(0),{activeSnapPoint:oe,activeSnapPointIndex:se,setActiveSnapPoint:ce,onRelease:le,snapPointsOffset:ue,onDrag:de,shouldFade:fe,getPercentageDragged:pe}=xJ({snapPoints:a,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:U,fadeFromIndex:f,overlayRef:L,onSnapPointChange:Z.useCallback(e=>{a&&e===ue.length-1&&(R.current=new Date)},[]),direction:b,container:D,snapToSequentialPoint:C});Jq({isDisabled:!k||N||!g||F||!j||!T||!S});let{restorePositionSetting:me}=wJ({isOpen:k,modal:g,nested:v??!1,hasBeenOpened:j,preventScrollRestoration:w,noBodyStyles:y});function he(){return(window.innerWidth-gJ)/window.innerWidth}function ge(e){!u&&!a||U.current&&!U.current.contains(e.target)||(W.current=U.current?.getBoundingClientRect().height||0,ae.current=U.current?.getBoundingClientRect().width||0,P(!0),z.current=new Date,Lq()&&window.addEventListener(`touchend`,()=>ee.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),ne.current=oJ(b)?e.pageY:e.pageX)}function _e(e,t){let n=e,r=window.getSelection()?.toString(),i=U.current?sJ(U.current,b):null,a=new Date;if(n.tagName===`SELECT`||n.hasAttribute(`data-vaul-no-drag`)||n.closest(`[data-vaul-no-drag]`))return!1;if(b===`right`||b===`left`)return!0;if(R.current&&a.getTime()-R.current.getTime()<500)return!1;if(i!==null&&(b===`bottom`?i>0:i<0))return!0;if(r&&r.length>0)return!1;if(V.current&&a.getTime()-V.current.getTime()<l&&i===0||t)return V.current=a,!1;for(;n;){if(n.scrollHeight>n.clientHeight){if(n.scrollTop!==0)return V.current=new Date,!1;if(n.getAttribute(`role`)===`dialog`)return!0}n=n.parentNode}return!0}function ve(e){if(U.current&&N){let t=b===`bottom`||b===`right`?1:-1,n=(ne.current-(oJ(b)?e.pageY:e.pageX))*t,i=n>0,s=a&&!u&&!i;if(s&&se===0)return;let c=Math.abs(n),l=document.querySelector(`[data-vaul-drawer-wrapper]`),d=c/(b===`bottom`||b===`top`?W.current:ae.current),p=pe(c,i);if(p!==null&&(d=p),s&&d>=1||!ee.current&&!_e(e.target,i))return;if(U.current.classList.add(_J),ee.current=!0,iJ(U.current,{transition:`none`}),iJ(L.current,{transition:`none`}),a&&de({draggedDistance:n}),i&&!a){let e=cJ(n),r=Math.min(e*-1,0)*t;iJ(U.current,{transform:oJ(b)?`translate3d(0, ${r}px, 0)`:`translate3d(${r}px, 0, 0)`});return}let m=1-d;if((fe||f&&se===f-1)&&(r?.(e,d),iJ(L.current,{opacity:`${m}`,transition:`none`},!0)),l&&L.current&&o){let e=Math.min(he()+d*(1-he()),1),t=8-d*8,n=Math.max(0,14-d*14);iJ(l,{borderRadius:`${t}px`,transform:oJ(b)?`scale(${e}) translate3d(0, ${n}px, 0)`:`scale(${e}) translate3d(${n}px, 0, 0)`,transition:`none`},!0)}if(!a){let e=c*t;iJ(U.current,{transform:oJ(b)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}}Z.useEffect(()=>{window.requestAnimationFrame(()=>{H.current=!0})},[]),Z.useEffect(()=>{var e;function t(){if(!U.current||!T)return;let e=document.activeElement;if($q(e)||re.current){let e=window.visualViewport?.height||0,t=window.innerHeight,n=t-e,r=U.current.getBoundingClientRect().height||0,i=r>t*.8;G.current||=r;let o=U.current.getBoundingClientRect().top;if(Math.abs(ie.current-n)>60&&(re.current=!re.current),a&&a.length>0&&ue&&se){let e=ue[se]||0;n+=e}if(ie.current=n,r>e||re.current){let t=U.current.getBoundingClientRect().height,r=t;t>e&&(r=e-(i?o:gJ)),h?U.current.style.height=`${t-Math.max(n,0)}px`:U.current.style.height=`${Math.max(r,e-o)}px`}else Mq()||(U.current.style.height=`${G.current}px`);a&&a.length>0&&!re.current?U.current.style.bottom=`0px`:U.current.style.bottom=`${Math.max(n,0)}px`}}return(e=window.visualViewport)==null||e.addEventListener(`resize`,t),()=>window.visualViewport?.removeEventListener(`resize`,t)},[se,a,ue]);function ye(e){xe(),_?.(),e||A(!1),setTimeout(()=>{a&&ce(a[0])},uJ.DURATION*1e3)}function be(){if(!U.current)return;let e=document.querySelector(`[data-vaul-drawer-wrapper]`),t=sJ(U.current,b);iJ(U.current,{transform:`translate3d(0, 0, 0)`,transition:`transform ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`}),iJ(L.current,{transition:`opacity ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`,opacity:`1`}),o&&t&&t>0&&k&&iJ(e,{borderRadius:`${mJ}px`,overflow:`hidden`,...oJ(b)?{transform:`scale(${he()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:`top`}:{transform:`scale(${he()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:`left`},transitionProperty:`transform, border-radius`,transitionDuration:`${uJ.DURATION}s`,transitionTimingFunction:`cubic-bezier(${uJ.EASE.join(`,`)})`},!0)}function xe(){!N||!U.current||(U.current.classList.remove(_J),ee.current=!1,P(!1),B.current=new Date)}function Se(e){if(!N||!U.current)return;U.current.classList.remove(_J),ee.current=!1,P(!1),B.current=new Date;let t=sJ(U.current,b);if(!e||!_e(e.target,!1)||!t||Number.isNaN(t)||z.current===null)return;let n=B.current.getTime()-z.current.getTime(),r=ne.current-(oJ(b)?e.pageY:e.pageX),o=Math.abs(r)/n;if(o>.05&&(I(!0),setTimeout(()=>{I(!1)},200)),a){le({draggedDistance:r*(b===`bottom`||b===`right`?1:-1),closeDrawer:ye,velocity:o,dismissible:u}),i?.(e,!0);return}if(b===`bottom`||b===`right`?r>0:r<0){be(),i?.(e,!0);return}if(o>dJ){ye(),i?.(e,!1);return}let s=Math.min(U.current.getBoundingClientRect().height??0,window.innerHeight),l=Math.min(U.current.getBoundingClientRect().width??0,window.innerWidth);if(Math.abs(t)>=(b===`left`||b===`right`?l:s)*c){ye(),i?.(e,!1);return}i?.(e,!0),be()}Z.useEffect(()=>(k&&(iJ(document.documentElement,{scrollBehavior:`auto`}),R.current=new Date),()=>{aJ(document.documentElement,`scrollBehavior`)}),[k]);function Ce(e){let t=e?(window.innerWidth-hJ)/window.innerWidth:1,n=e?-16:0;te.current&&window.clearTimeout(te.current),iJ(U.current,{transition:`transform ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`,transform:oJ(b)?`scale(${t}) translate3d(0, ${n}px, 0)`:`scale(${t}) translate3d(${n}px, 0, 0)`}),!e&&U.current&&(te.current=setTimeout(()=>{let e=sJ(U.current,b);iJ(U.current,{transition:`none`,transform:oJ(b)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))}function we(e,t){if(t<0)return;let n=(window.innerWidth-hJ)/window.innerWidth,r=n+t*(1-n),i=-16+t*hJ;iJ(U.current,{transform:oJ(b)?`scale(${r}) translate3d(0, ${i}px, 0)`:`scale(${r}) translate3d(${i}px, 0, 0)`,transition:`none`})}function Te(e,t){let n=oJ(b)?window.innerHeight:window.innerWidth,r=t?(n-hJ)/n:1,i=t?-16:0;t&&iJ(U.current,{transition:`transform ${uJ.DURATION}s cubic-bezier(${uJ.EASE.join(`,`)})`,transform:oJ(b)?`scale(${r}) translate3d(0, ${i}px, 0)`:`scale(${r}) translate3d(${i}px, 0, 0)`})}return Z.useEffect(()=>{g||window.requestAnimationFrame(()=>{document.body.style.pointerEvents=`auto`})},[g]),Z.createElement(Nt,{defaultOpen:x,onOpenChange:e=>{!u&&!e||(e?M(!0):ye(!0),A(e))},open:k},Z.createElement(Aq.Provider,{value:{activeSnapPoint:oe,snapPoints:a,setActiveSnapPoint:ce,drawerRef:U,overlayRef:L,onOpenChange:t,onPress:ge,onRelease:Se,onDrag:ve,dismissible:u,shouldAnimate:H,handleOnly:d,isOpen:k,isDragging:N,shouldFade:fe,closeDrawer:ye,onNestedDrag:we,onNestedOpenChange:Ce,onNestedRelease:Te,keyboardIsOpen:re,modal:g,snapPointsOffset:ue,activeSnapPointIndex:se,direction:b,shouldScaleBackground:o,setBackgroundColorOnScale:s,noBodyStyles:y,container:D,autoFocus:O}},n))}var EJ=Z.forwardRef(function({...e},t){let{overlayRef:n,snapPoints:r,onRelease:i,shouldFade:a,isOpen:o,modal:s,shouldAnimate:c}=jq(),l=nJ(t,n),u=r&&r.length>0;if(!s)return null;let d=Z.useCallback(e=>i(e),[i]);return Z.createElement(kt,{onMouseUp:d,ref:l,"data-vaul-overlay":``,"data-vaul-snap-points":o&&u?`true`:`false`,"data-vaul-snap-points-overlay":o&&a?`true`:`false`,"data-vaul-animate":c?.current?`true`:`false`,...e})});EJ.displayName=`Drawer.Overlay`;var DJ=Z.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},i){let{drawerRef:a,onPress:o,onRelease:s,onDrag:c,keyboardIsOpen:l,snapPointsOffset:u,activeSnapPointIndex:d,modal:f,isOpen:p,direction:m,snapPoints:h,container:g,handleOnly:_,shouldAnimate:v,autoFocus:y}=jq(),[b,x]=Z.useState(!1),S=nJ(i,a),C=Z.useRef(null),w=Z.useRef(null),T=Z.useRef(!1),E=h&&h.length>0;SJ();let D=(e,t,n=0)=>{if(T.current)return!0;let r=Math.abs(e.y),i=Math.abs(e.x),a=i>r,o=[`bottom`,`right`].includes(t)?1:-1;if(t===`left`||t===`right`){if(!(e.x*o<0)&&i>=0&&i<=n)return a}else if(!(e.y*o<0)&&r>=0&&r<=n)return!a;return T.current=!0,!0};Z.useEffect(()=>{E&&window.requestAnimationFrame(()=>{x(!0)})},[]);function O(e){C.current=null,T.current=!1,s(e)}return Z.createElement(It,{"data-vaul-drawer-direction":m,"data-vaul-drawer":``,"data-vaul-delayed-snap-points":b?`true`:`false`,"data-vaul-snap-points":p&&E?`true`:`false`,"data-vaul-custom-container":g?`true`:`false`,"data-vaul-animate":v?.current?`true`:`false`,...r,ref:S,style:u&&u.length>0?{"--snap-point-height":`${u[d??0]}px`,...t}:t,onPointerDown:e=>{_||(r.onPointerDown==null||r.onPointerDown.call(r,e),C.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{n?.(e),y||e.preventDefault()},onPointerDownOutside:t=>{if(e?.(t),!f||t.defaultPrevented){t.preventDefault();return}l.current&&=!1},onFocusOutside:e=>{if(!f){e.preventDefault();return}},onPointerMove:e=>{if(w.current=e,_||(r.onPointerMove==null||r.onPointerMove.call(r,e),!C.current))return;let t=e.pageY-C.current.y,n=e.pageX-C.current.x,i=e.pointerType===`touch`?10:2;D({x:n,y:t},m,i)?c(e):(Math.abs(n)>i||Math.abs(t)>i)&&(C.current=null)},onPointerUp:e=>{r.onPointerUp==null||r.onPointerUp.call(r,e),C.current=null,T.current=!1,s(e)},onPointerOut:e=>{r.onPointerOut==null||r.onPointerOut.call(r,e),O(w.current)},onContextMenu:e=>{r.onContextMenu==null||r.onContextMenu.call(r,e),w.current&&O(w.current)}})});DJ.displayName=`Drawer.Content`;var OJ=250,kJ=120,AJ=Z.forwardRef(function({preventCycle:e=!1,children:t,...n},r){let{closeDrawer:i,isDragging:a,snapPoints:o,activeSnapPoint:s,setActiveSnapPoint:c,dismissible:l,handleOnly:u,isOpen:d,onPress:f,onDrag:p}=jq(),m=Z.useRef(null),h=Z.useRef(!1);function g(){if(h.current){y();return}window.setTimeout(()=>{_()},kJ)}function _(){if(a||e||h.current){y();return}if(y(),!o||o.length===0){l||i();return}if(s===o[o.length-1]&&l){i();return}let t=o.findIndex(e=>e===s);if(t===-1)return;let n=o[t+1];c(n)}function v(){m.current=window.setTimeout(()=>{h.current=!0},OJ)}function y(){m.current&&window.clearTimeout(m.current),h.current=!1}return Z.createElement(`div`,{onClick:g,onPointerCancel:y,onPointerDown:e=>{u&&f(e),v()},onPointerMove:e=>{u&&p(e)},ref:r,"data-vaul-drawer-visible":d?`true`:`false`,"data-vaul-handle":``,"aria-hidden":`true`,...n},Z.createElement(`span`,{"data-vaul-handle-hitarea":``,"aria-hidden":`true`},t))});AJ.displayName=`Drawer.Handle`;function jJ({onDrag:e,onOpenChange:t,open:n,...r}){let{onNestedDrag:i,onNestedOpenChange:a,onNestedRelease:o}=jq();if(!i)throw Error(`Drawer.NestedRoot must be placed in another drawer`);return Z.createElement(TJ,{nested:!0,open:n,onClose:()=>{a(!1)},onDrag:(t,n)=>{i(t,n),e?.(t,n)},onOpenChange:e=>{e&&a(e),t?.(e)},onRelease:o,...r})}function MJ(e){let t=jq(),{container:n=t.container,...r}=e;return Z.createElement(Mt,{container:n,...r})}var NJ={Root:TJ,NestedRoot:jJ,Content:DJ,Overlay:EJ,Trigger:Mn,Portal:MJ,Handle:AJ,Close:Pt,Title:Rt,Description:Et};function PJ({...e}){return(0,Q.jsx)(NJ.Root,{"data-slot":`drawer`,...e})}function FJ({...e}){return(0,Q.jsx)(NJ.Trigger,{"data-slot":`drawer-trigger`,...e})}function IJ({...e}){return(0,Q.jsx)(NJ.Portal,{"data-slot":`drawer-portal`,...e})}function LJ({className:e,...t}){return(0,Q.jsx)(NJ.Overlay,{"data-slot":`drawer-overlay`,className:s(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-1001 bg-black/50`,e),...t})}function RJ({className:e,children:t,withOverlay:n=!0,...r}){return(0,Q.jsxs)(IJ,{"data-slot":`drawer-portal`,children:[n&&(0,Q.jsx)(LJ,{}),(0,Q.jsx)(NJ.Content,{"data-slot":`drawer-content`,className:s(`group/drawer-content bg-white fixed z-1001 flex h-auto flex-col dark:bg-gray-950`,`data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b`,`data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t`,`data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm`,`data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm`,e),onClick:e=>e.stopPropagation(),...r,children:t})]})}function zJ({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`drawer-header`,className:s(`flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left`,e),...t})}function BJ({className:e,...t}){return(0,Q.jsx)(NJ.Title,{"data-slot":`drawer-title`,className:s(`text-gray-950 font-semibold dark:text-gray-50`,e),...t})}function VJ({...e}){return(0,Q.jsx)(xo,{"data-slot":`popover`,...e})}function HJ({...e}){return(0,Q.jsx)(So,{"data-slot":`popover-trigger`,...e})}function UJ({className:e,align:t=`center`,sideOffset:n=4,container:r,...i}){return(0,Q.jsx)(Co,{container:r,children:(0,Q.jsx)(wo,{"data-slot":`popover-content`,align:t,sideOffset:n,className:s(`bg-white text-gray-950 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-1001 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border border-gray-200 p-4 shadow-md outline-hidden dark:bg-gray-950 dark:text-gray-50 dark:border-gray-800`,e),...i})})}function WJ({data:e,placeholder:t,triggerProps:n,disabled:r,onChange:i,value:a,formPart:o,error:s}){let[c,l]=Z.useState(!1),u=Fk(),d=EK(`(min-width: 768px)`),f=(0,Z.useMemo)(()=>a&&e.find(e=>e.value===a)||null,[a,e]);return d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 w-full`,children:[(0,Q.jsxs)(VJ,{modal:!0,open:c,onOpenChange:l,children:[(0,Q.jsx)(HJ,{asChild:!0,className:`w-full min-w-40`,children:(0,Q.jsx)(GJ,{placeholder:t,selectedOption:f,disabled:r,formPart:o,...n})}),(0,Q.jsx)(UJ,{className:`w-full p-0`,align:`start`,container:u,children:(0,Q.jsx)(KJ,{setOpen:l,onChange:i,data:e,placeholder:t,value:a})})]}),s&&(0,Q.jsx)(`p`,{className:`text-xs text-red-500`,children:s})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 w-full`,children:[(0,Q.jsxs)(PJ,{open:c,onOpenChange:l,children:[(0,Q.jsx)(FJ,{asChild:!0,children:(0,Q.jsx)(GJ,{placeholder:t,selectedOption:f,disabled:r,formPart:o,...n})}),(0,Q.jsx)(RJ,{children:(0,Q.jsx)(`div`,{className:`mt-4 border-t`,children:(0,Q.jsx)(KJ,{setOpen:l,onChange:i,data:e,placeholder:t,value:a})})})]}),s&&(0,Q.jsx)(`p`,{className:`text-xs text-red-500`,children:s})]})}function GJ({formPart:e,placeholder:t,selectedOption:n,...r}){return e?(0,Q.jsx)(dr,{children:(0,Q.jsxs)(q,{variant:`outline`,className:`w-full justify-start`,...r,children:[n?n.label:t,(0,Q.jsx)(pn,{strokeWidth:2,className:`shrink-0 text-gray-500/80 dark:text-gray-400/80 size-4`,"aria-hidden":`true`})]})}):(0,Q.jsxs)(q,{variant:`outline`,className:`w-[150px] justify-start`,...r,children:[n?n.label:t,(0,Q.jsx)(pn,{strokeWidth:2,className:`shrink-0 text-gray-500/80 dark:text-gray-400/80 size-4`,"aria-hidden":`true`})]})}function KJ({setOpen:e,onChange:t,placeholder:n,data:r,value:i}){return(0,Q.jsxs)(Sq,{children:[(0,Q.jsx)(Cq,{placeholder:n??`Filter options...`}),(0,Q.jsxs)(wq,{children:[(0,Q.jsx)(Tq,{children:`No results found.`}),(0,Q.jsx)(Eq,{children:r.map(n=>(0,Q.jsxs)(Oq,{keywords:[n.label,n.description??``],value:n.value,onSelect:n=>{t?.(r.find(e=>e.value.toLowerCase()===n.toLowerCase())?.value??null),e(!1)},children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{children:n.label}),n.description&&(0,Q.jsx)(`span`,{className:`text-xs opacity-65`,children:n.description})]}),(0,Q.jsx)(on,{className:s(`ml-auto`,n.value===i?`opacity-100`:`opacity-0`)})]},n.value))})]})]})}var qJ=Object.values(k);(0,Z.forwardRef)(function({label:e,value:t,onChange:n,disabled:r,name:i,form:a}){let o=Fk();return(0,Q.jsxs)(`div`,{className:`bottom-0 mt-6`,children:[e&&(0,Q.jsx)(gn,{className:`sr-only`,children:e}),(0,Q.jsxs)(wn,{value:t,onValueChange:n,disabled:r,name:i,form:a,children:[(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{placeholder:`Currency`})}),(0,Q.jsx)(mn,{container:o,children:qJ.map(e=>(0,Q.jsx)(bn,{value:e,children:e},e))})]})]})});function JJ({value:e,onChange:t,onBlur:n,label:r,disabled:i,form:a}){let[o,c]=(0,Z.useState)(!1),l=Fk();return(0,Q.jsxs)(`div`,{className:`w-1/2 min-w-[75px] mt-6`,children:[r&&(0,Q.jsx)(gn,{className:`sr-only`,children:r}),(0,Q.jsxs)(VJ,{modal:!0,open:o,onOpenChange:c,children:[(0,Q.jsx)(HJ,{asChild:!0,children:(0,Q.jsxs)(q,{type:`button`,variant:`outline`,className:`w-full justify-between font-normal`,disabled:i,onBlur:n,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{children:e??`Currency`}),(0,Q.jsx)(pn,{strokeWidth:2,className:`shrink-0 text-gray-500/80 dark:text-gray-400/80 size-4`,"aria-hidden":`true`})]})}),(0,Q.jsx)(UJ,{className:`w-40 p-0`,align:`start`,container:l,children:(0,Q.jsxs)(Sq,{children:[(0,Q.jsx)(Cq,{placeholder:`Search currency...`,form:a}),(0,Q.jsxs)(wq,{children:[(0,Q.jsx)(Tq,{children:`No currency found.`}),(0,Q.jsx)(Eq,{children:qJ.map(n=>(0,Q.jsxs)(Oq,{value:n,onSelect:()=>{t?.(n),c(!1)},children:[n,(0,Q.jsx)(on,{className:s(`ml-auto`,e===n?`opacity-100`:`opacity-0`)})]},n))})]})]})})]})]})}var YJ=(0,Z.forwardRef)(function({currencyCodeProps:{error:e,...t},error:n,...r}){let{precision:i}=r,a=Math.abs(typeof r.value==`number`?r.value:0);if(a&&!i){if(a>.1)i=2;else for(let e=1;e<6;e++)if(a>10**-e){i=e+1;break}}return(0,Q.jsxs)(`div`,{className:`w-full flex flex-row min-w-[150px]`,children:[(0,Q.jsx)(MO,{className:`w-full min-w-[75px]`,...r,hideControls:!0,precision:i??2,error:n||e}),(0,Q.jsx)(JJ,{...t})]})});function XJ(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var ZJ={},QJ={};function $J(e,t){try{let n=(ZJ[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in QJ?QJ[n]:tY(n,n.split(`:`))}catch{if(e in QJ)return QJ[e];let t=e?.match(eY);return t?tY(e,t.slice(1)):NaN}}var eY=/([+-]\d\d):?(\d\d)?/;function tY(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return QJ[e]=n*60+r>0?n*60+r+i:n*60-r-i}var nY=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN($J(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),oY(this,e)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-$J(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),iY(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},rY=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!rY.test(e))return;let t=e.replace(rY,`$1UTC`);nY.prototype[t]&&(e.startsWith(`get`)?nY.prototype[e]=function(){return this.internal[t]()}:(nY.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),aY(this),+this},nY.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),iY(this),+this}))});function iY(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-$J(e.timeZone,e)*60))}function aY(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),oY(e)}function oY(e,t){let n=Array.isArray(t)?sY(t):+e.internal,r=$J(e.timeZone,e),i=r>0?Math.floor(r):Math.ceil(r),a=new Date(+e);a.setUTCHours(a.getUTCHours()-1);let o=-new Date(+e).getTimezoneOffset(),s=-new Date(+a).getTimezoneOffset(),c=o-s,l=o;if(c&&o!==i&&Date.prototype.getHours.apply(e)!==(Array.isArray(t)?t[3]||0:e.internal.getUTCHours())){let t=new Date(+e),n=o-i;n&&t.setUTCMinutes(t.getUTCMinutes()+n);let r=$J(e.timeZone,t);(r>0?Math.floor(r):Math.ceil(r))===i&&(l=s)}let u=l-i;u&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+u);let d=new Date(+e);d.setUTCSeconds(0);let f=o>0?d.getSeconds():(d.getSeconds()-60)%60,p=Math.round(-($J(e.timeZone,e)*60))%60;(p||f)&&Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+p+f);let m=$J(e.timeZone,e),h=m>0?Math.floor(m):Math.ceil(m),g=-new Date(+e).getTimezoneOffset()-h,_=h!==i,v=g-u,y=h-i,b=n-h*60*1e3,x=y>0&&cY(e)-n===y*60*1e3&&cY(e,b)!==n;if(_&&v&&!x){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+v);let t=$J(e.timeZone,e),n=h-(t>0?Math.floor(t):Math.ceil(t));n&&v<0&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n)}iY(e);let S=(t?n:n+p*1e3)-+e.internal;S&&Math.abs(S)<18e5&&(Date.prototype.setTime.call(e,+e+S),iY(e))}function sY(e){return Date.UTC(e[0],e.length>1?e[1]:0,e.length>2?e[2]:1,...e.slice(3))}function cY(e,t){let n=new Date(t??+e);return n.setUTCSeconds(n.getUTCSeconds()-Math.round(-$J(e.timeZone,n)*60)),+n}var lY=class e extends nY{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${XJ(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},uY=5,dY=4;function fY(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,34);return t.getMonth(e)===t.getMonth(a)?uY:dY}function pY(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function mY(e,t){let n=pY(e,t),r=fY(e,t);return t.addDays(n,r*7-1)}var hY={...Rr,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>Or(e,t,{locale:Rr,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>Or(e,n,{locale:Rr,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>Or(e,t,{locale:Rr,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>Or(e,n,{locale:Rr,...t}),r(e,`cccc`)}}},gY=class e{constructor(e,t){this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?lY.tz(this.options.timeZone):new(this.options.Date??Date),this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new lY(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):Qs(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):$s(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):ec(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):tc(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):wi(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):ac(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):uc(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):pc(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):mY(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):hc(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):cc(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):mc(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):fc(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):Or(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):Nr(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):yc(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):bc(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):mr(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):xc(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):Sc(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):Zr(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):ic(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):Nl(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):Pl(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):nc(e),this.min=e=>this.overrides?.min?this.overrides.min(e):rc(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):Fl(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):Ll(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):pY(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):ui(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):Vr(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):dc(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):pi(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):Sr(e),this.options={locale:hY,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};gY.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var _Y=new gY,vY=class{constructor(e,t,n=_Y){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},yY=class{constructor(e,t){this.date=e,this.weeks=t}},bY=class{constructor(e,t){this.days=t,this.weekNumber=e}};function xY(e){return Z.createElement(`span`,{...e})}function SY(e){let{size:t=24,orientation:n=`left`,className:r,style:i}=e;return Z.createElement(`svg`,{className:r,style:i,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&Z.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&Z.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&Z.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&Z.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function CY(e){let{day:t,modifiers:n,...r}=e;return Z.createElement(`td`,{...r})}function wY(e){let{day:t,modifiers:n,...r}=e,i=Z.useRef(null);return Z.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),Z.createElement(`button`,{ref:i,...r})}var TY;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})(TY||={});var EY;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(EY||={});var DY;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(DY||={});var OY;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(OY||={});var kY=(0,Z.createContext)(void 0);function AY(){let e=(0,Z.useContext)(kY);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function jY(e){let{options:t,className:n,...r}=e,{classNames:i,components:a,styles:o}=AY(),s=[i[TY.Dropdown],n].join(` `),c=t?.find(({value:e})=>e===r.value);return Z.createElement(`span`,{"data-disabled":r.disabled,className:i[TY.DropdownRoot],style:o?.[TY.DropdownRoot]},Z.createElement(a.Select,{className:s,...r},t?.map(({value:e,label:t,disabled:n})=>Z.createElement(a.Option,{key:e,value:e,disabled:n},t))),Z.createElement(`span`,{className:i[TY.CaptionLabel],style:o?.[TY.CaptionLabel],"aria-hidden":!0},c?.label,Z.createElement(a.Chevron,{orientation:`down`,size:18,className:i[TY.Chevron],style:o?.[TY.Chevron]})))}function MY(e){return Z.createElement(`div`,{...e})}function NY(e){return Z.createElement(`div`,{...e})}function PY(e){let{calendarMonth:t,displayIndex:n,...r}=e;return Z.createElement(`div`,{...r},e.children)}function FY(e){let{calendarMonth:t,displayIndex:n,...r}=e;return Z.createElement(`div`,{...r})}function IY(e){return Z.createElement(`table`,{...e})}function LY(e){return Z.createElement(`div`,{...e})}function RY(e){let{components:t}=AY();return Z.createElement(t.Dropdown,{...e})}function zY(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,styles:c,labels:{labelPrevious:l,labelNext:u}}=AY(),d=(0,Z.useCallback)(e=>{i&&n?.(e)},[i,n]),f=(0,Z.useCallback)(e=>{r&&t?.(e)},[r,t]);return Z.createElement(`nav`,{...a},Z.createElement(o.PreviousMonthButton,{type:`button`,className:s[TY.PreviousMonthButton],style:c?.[TY.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":!r||void 0,"aria-label":l(r),onClick:f},Z.createElement(o.Chevron,{disabled:!r||void 0,className:s[TY.Chevron],style:c?.[TY.Chevron],orientation:`left`})),Z.createElement(o.NextMonthButton,{type:`button`,className:s[TY.NextMonthButton],style:c?.[TY.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":!i||void 0,"aria-label":u(i),onClick:d},Z.createElement(o.Chevron,{disabled:!i||void 0,orientation:`right`,className:s[TY.Chevron],style:c?.[TY.Chevron]})))}function BY(e){return Z.createElement(`button`,{...e})}function VY(e){return Z.createElement(`option`,{...e})}function HY(e){return Z.createElement(`button`,{...e})}function UY(e){let{rootRef:t,...n}=e;return Z.createElement(`div`,{...n,ref:t})}function WY(e){return Z.createElement(`select`,{...e})}function GY(e){let{week:t,...n}=e;return Z.createElement(`tr`,{...n})}function KY(e){return Z.createElement(`th`,{...e})}function qY(e){return Z.createElement(`thead`,{"aria-hidden":!0},Z.createElement(`tr`,{...e}))}function JY(e){let{week:t,...n}=e;return Z.createElement(`th`,{...n})}function YY(e){return Z.createElement(`th`,{...e})}function XY(e){return Z.createElement(`tbody`,{...e})}function ZY(e){let{components:t}=AY();return Z.createElement(t.Dropdown,{...e})}var QY=e({CaptionLabel:()=>xY,Chevron:()=>SY,Day:()=>CY,DayButton:()=>wY,Dropdown:()=>jY,DropdownNav:()=>MY,Footer:()=>NY,Month:()=>PY,MonthCaption:()=>FY,MonthGrid:()=>IY,Months:()=>LY,MonthsDropdown:()=>RY,Nav:()=>zY,NextMonthButton:()=>BY,Option:()=>VY,PreviousMonthButton:()=>HY,Root:()=>UY,Select:()=>WY,Week:()=>GY,WeekNumber:()=>JY,WeekNumberHeader:()=>YY,Weekday:()=>KY,Weekdays:()=>qY,Weeks:()=>XY,YearsDropdown:()=>ZY});function $Y(e,t,n=!1,r=_Y){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function eX(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function tX(e){return!!(e&&typeof e==`object`&&`from`in e)}function nX(e){return!!(e&&typeof e==`object`&&`after`in e)}function rX(e){return!!(e&&typeof e==`object`&&`before`in e)}function iX(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function aX(e,t){return Array.isArray(e)&&e.every(t.isDate)}function oX(e,t,n=_Y){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(aX(t,n))return t.some(t=>i(e,t));if(tX(t))return $Y(t,e,!1,n);if(iX(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(eX(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return nX(t)?a(e,t.after)>0:rX(t)?a(t.before,e)>0:typeof t==`function`&&t(e)})}function sX(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[EY.focused]:[],[EY.outside]:[],[EY.disabled]:[],[EY.hidden]:[],[EY.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!!(n&&!f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&oX(e,a,i)),S=!!(o&&oX(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&oX(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[EY.focused]:!1,[EY.disabled]:!1,[EY.hidden]:!1,[EY.outside]:!1,[EY.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function cX(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[EY[r]]?e.push(t[EY[r]]):t[DY[r]]&&e.push(t[DY[r]]),e),[t[TY.Day]])}function lX(e){return{...QY,...e}}function uX(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function dX(){let e={};for(let t in TY)e[TY[t]]=`rdp-${TY[t]}`;for(let t in EY)e[EY[t]]=`rdp-${EY[t]}`;for(let t in DY)e[DY[t]]=`rdp-${DY[t]}`;for(let t in OY)e[OY[t]]=`rdp-${OY[t]}`;return e}function fX(e,t,n){return(n??new gY(t)).formatMonthYear(e)}function pX(e,t,n){return(n??new gY(t)).format(e,`d`)}function mX(e,t=_Y){return t.format(e,`LLLL`)}function hX(e,t,n){return(n??new gY(t)).format(e,`cccccc`)}function gX(e,t=_Y){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function _X(){return``}function vX(e,t=_Y){return t.format(e,`yyyy`)}var yX=e({formatCaption:()=>fX,formatDay:()=>pX,formatMonthDropdown:()=>mX,formatWeekNumber:()=>gX,formatWeekNumberHeader:()=>_X,formatWeekdayName:()=>hX,formatYearDropdown:()=>vX});function bX(e){return{...yX,...e}}function xX(e,t,n,r){let i=(r??new gY(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}function SX(e,t,n){return(n??new gY(t)).formatMonthYear(e)}function CX(e,t,n,r){let i=(r??new gY(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function wX(e){return`Choose the Month`}function TX(){return``}var EX=`Go to the Next Month`;function DX(e,t){return EX}function OX(e){return`Go to the Previous Month`}function kX(e,t,n){return(n??new gY(t)).format(e,`cccc`)}function AX(e,t){return`Week ${e}`}function jX(e){return`Week Number`}function MX(e){return`Choose the Year`}var NX=e({labelDayButton:()=>xX,labelGrid:()=>SX,labelGridcell:()=>CX,labelMonthDropdown:()=>wX,labelNav:()=>TX,labelNext:()=>DX,labelPrevious:()=>OX,labelWeekNumber:()=>AX,labelWeekNumberHeader:()=>jX,labelWeekday:()=>kX,labelYearDropdown:()=>MX}),PX=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function FX(e,t){let n=t.locale?.labels??{};return{...NX,...e??{},labelDayButton:PX(xX,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:PX(wX,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:PX(DX,e?.labelNext,n.labelNext),labelPrevious:PX(OX,e?.labelPrevious,n.labelPrevious),labelWeekNumber:PX(AX,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:PX(MX,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:PX(SX,e?.labelGrid,n.labelGrid),labelGridcell:PX(CX,e?.labelGridcell,n.labelGridcell),labelNav:PX(TX,e?.labelNav,n.labelNav),labelWeekNumberHeader:PX(jX,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:PX(kX,e?.labelWeekday,n.labelWeekday)}}function IX(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function LX(e,t={},n={}){let r={...t?.[TY.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function RX(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function zX(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function BX(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new lY(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(lY.tz(e)),newDate:(t,n,r)=>new lY(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new lY(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new lY(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new lY(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new lY(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>{let n=o(e);return mr(n,{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:e=>{let t=o(e);return Nr(t)},differenceInCalendarDays:(e,t)=>{let n=o(e),r=o(t);return wi(n,r)},differenceInCalendarMonths:(e,t)=>ac(o(e),o(t))}}var VX=e=>e instanceof HTMLElement?e:null,HX=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],UX=e=>VX(e.querySelector(`[data-animated-month]`)),WX=e=>VX(e.querySelector(`[data-animated-caption]`)),GX=e=>VX(e.querySelector(`[data-animated-weeks]`)),KX=e=>VX(e.querySelector(`[data-animated-nav]`)),qX=e=>VX(e.querySelector(`[data-animated-weekdays]`));function JX(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,Z.useRef)(null),s=(0,Z.useRef)(r),c=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[OY.caption_after_enter]:n[OY.caption_before_enter],p=d?n[OY.weeks_after_enter]:n[OY.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(HX(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=UX(e);t&&e.contains(t)&&e.removeChild(t);let n=WX(e);n&&n.classList.remove(f);let r=GX(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?HX(m):[],_=HX(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g?.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=KX(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=WX(i);s&&s.classList.add(f);let l=GX(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=qX(o);m&&(m.style.opacity=`0`);let h=WX(o);h&&(h.classList.add(d?n[OY.caption_before_exit]:n[OY.caption_after_exit]),h.addEventListener(`animationend`,u));let _=GX(o);_&&_.classList.add(d?n[OY.weeks_before_exit]:n[OY.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function YX(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let E=(c?35:42)*w;if(s&&T.length<E){let e=E-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function XX(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function ZX(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function QX(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function $X(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new yY(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new vY(t,m,r);return a?a.days.push(o):e.push(new bY(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function eZ(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,today:u}=t,d=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):!n&&d&&(n=i(c(e.today??u(),-100))),r?r=s(r):!r&&d&&(r=l(e.today??u())),[n&&a(n),r&&a(r)]}function tZ(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function nZ(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function rZ(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function iZ(e,t){let[n,r]=(0,Z.useState)(e);return[t===void 0?n:t,r]}function aZ(e,t){let[n,r]=eZ(e,t),{startOfMonth:i,endOfMonth:a}=t,o=QX(e,n,r,t),[s,c]=iZ(o,e.month?o:void 0);(0,Z.useEffect)(()=>{let i=QX(e,n,r,t);c(i)},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,Z.useMemo)(()=>{let i=ZX(s,r,{numberOfMonths:e.numberOfMonths},t),o=$X(i,YX(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:rZ(o),days:XX(o),previousMonth:nZ(s,n,e,t),nextMonth:tZ(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var oZ;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(oZ||={});function sZ(e){return!e[EY.disabled]&&!e[EY.hidden]&&!e[EY.outside]}function cZ(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);sZ(e)&&(e[EY.focused]&&a<oZ.FocusedModifier?(i=o,a=oZ.FocusedModifier):r?.isEqualTo(o)&&a<oZ.LastFocused?(i=o,a=oZ.LastFocused):n(o.date)&&a<oZ.Selected?(i=o,a=oZ.Selected):e[EY.today]&&a<oZ.Today&&(i=o,a=oZ.Today))}return i||=e.find(e=>sZ(t(e))),i}function lZ(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function uZ(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=lZ(e,t,n.date,r,i,a,o),l=!!(a.disabled&&oX(c,a.disabled,o)),u=!!(a.hidden&&oX(c,a.hidden,o)),d=new vY(c,c,o);return!l&&!u?d:uZ(e,t,d,r,i,a,o,s+1)}function dZ(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,Z.useState)(),c=cZ(t.days,n,r||(()=>!1),o),[l,u]=(0,Z.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=uZ(n,r,l,t.navStart,t.navEnd,e,i);a&&(e.disableNavigation&&!t.days.some(e=>e.isEqualTo(a))||(t.goToDay(a),u(a)))}}}function fZ(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=iZ(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function pZ(e,t,n=0,r=0,i=!1,a=_Y){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s){if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`)}if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function mZ(e,t,n=_Y){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function hZ(e,t,n=_Y){return $Y(e,t.from,!1,n)||$Y(e,t.to,!1,n)||$Y(t,e.from,!1,n)||$Y(t,e.to,!1,n)}function gZ(e,t,n=_Y){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?$Y(e,t,!1,n):aX(t,n)?t.some(t=>$Y(e,t,!1,n)):tX(t)?t.from&&t.to?hZ(e,{from:t.from,to:t.to},n):!1:iX(t)?mZ(e,t.dayOfWeek,n):eX(t)?n.isAfter(t.before,t.after)?hZ(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):oX(e.from,t,n)||oX(e.to,t,n):nX(t)||rX(t)?oX(e.from,t,n)||oX(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function _Z(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=iZ(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:pZ(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&gZ({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&$Y(u,e,!1,t)}}function vZ(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=iZ(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function yZ(e,t){let n=vZ(e,t),r=fZ(e,t),i=_Z(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function bZ(e,t){return e instanceof lY&&e.timeZone===t?e:new lY(e,t)}function xZ(e,t,n){if(!n)return bZ(e,t);let r=bZ(e,t),i=new lY(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function SZ(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?xZ(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?xZ(e,t,n):e):tX(e)?{...e,from:e.from?bZ(e.from,t):e.from,to:e.to?bZ(e.to,t):e.to}:eX(e)?{before:xZ(e.before,t,n),after:xZ(e.after,t,n)}:nX(e)?{after:xZ(e.after,t,n)}:rX(e)?{before:xZ(e.before,t,n)}:e}function CZ(e,t,n){return e&&(Array.isArray(e)?e.map(e=>SZ(e,t,n)):SZ(e,t,n))}function wZ(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=bZ(t.today,n)),t.month&&(t.month=bZ(t.month,n)),t.defaultMonth&&(t.defaultMonth=bZ(t.defaultMonth,n)),t.startMonth&&(t.startMonth=bZ(t.startMonth,n)),t.endMonth&&(t.endMonth=bZ(t.endMonth,n)),t.mode===`single`&&t.selected?t.selected=bZ(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>bZ(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?bZ(t.selected.from,n):t.selected.from,to:t.selected.to?bZ(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=CZ(t.disabled,n)),t.hidden!==void 0&&(t.hidden=CZ(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=CZ(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,Z.useMemo)(()=>{let e={...hY,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?BX(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new gY({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:lX(t.components),formatters:bX(t.formatters),labels:FX(t.labels,a.options),locale:e,classNames:{...dX(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:v,onNextClick:y,onPrevClick:b,showWeekNumber:x,styles:S}=t,{formatCaption:C,formatDay:w,formatMonthDropdown:T,formatWeekNumber:E,formatWeekNumberHeader:D,formatWeekdayName:O,formatYearDropdown:k}=i,A=aZ(t,o),{days:j,months:M,navStart:N,navEnd:P,previousMonth:F,nextMonth:I,goToMonth:L}=A,R=sX(j,t,N,P,o),{isSelected:z,select:B,selected:V}=yZ(t,o)??{},{blur:ee,focused:te,isFocusTarget:ne,moveFocus:re,setFocused:H}=dZ(t,A,R,z??(()=>!1),o),{labelDayButton:ie,labelGridcell:U,labelGrid:W,labelMonthDropdown:ae,labelNav:G,labelPrevious:oe,labelNext:se,labelWeekday:ce,labelWeekNumber:le,labelWeekNumberHeader:ue,labelYearDropdown:de}=a,fe=(0,Z.useMemo)(()=>RX(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),pe=u!==void 0||m!==void 0,me=(0,Z.useCallback)(()=>{F&&(L(F),b?.(F))},[F,L,b]),he=(0,Z.useCallback)(()=>{I&&(L(I),y?.(I))},[L,I,y]),ge=(0,Z.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),H(e),!t.disabled&&(B?.(e.date,t,n),m?.(e.date,t,n))},[B,m,H]),_e=(0,Z.useCallback)((e,t)=>n=>{H(e),h?.(e.date,t,n)},[h,H]),ve=(0,Z.useCallback)((e,t)=>n=>{ee(),p?.(e.date,t,n)},[ee,p]),ye=(0,Z.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];re(e,t)}g?.(e.date,n,r)},[re,g,t.dir]),be=(0,Z.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),xe=(0,Z.useCallback)((e,t)=>n=>{v?.(e.date,t,n)},[v]),Se=(0,Z.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setMonth(o.startOfMonth(e),r);L(o.addMonths(i,-t))},[o,L]),Ce=(0,Z.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setYear(o.startOfMonth(e),r);L(o.addMonths(i,-t))},[o,L]),{className:we,style:Te}=(0,Z.useMemo)(()=>({className:[c[TY.Root],t.className].filter(Boolean).join(` `),style:{...S?.[TY.Root],...t.style}}),[c,t.className,t.style,S]),Ee=uX(t),De=e=>{let t=S?.[TY.Dropdown],n=S?.[e];if(!(!t&&!n))return{...t,...n}},Oe=(0,Z.useRef)(null);JX(Oe,!!t.animate,{classNames:c,months:M,focused:te,dateLib:o});let ke={dayPickerProps:t,selected:V,select:B,isSelected:z,months:M,nextMonth:I,previousMonth:F,goToMonth:L,getModifiers:R,components:r,classNames:c,styles:S,labels:a,formatters:i};return Z.createElement(kY.Provider,{value:ke},Z.createElement(r.Root,{rootRef:t.animate?Oe:void 0,className:we,style:Te,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...Ee},Z.createElement(r.Months,{className:c[TY.Months],style:S?.[TY.Months]},!t.hideNavigation&&!d&&Z.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[TY.Nav],style:S?.[TY.Nav],"aria-label":G(),onPreviousClick:me,onNextClick:he,previousMonth:F,nextMonth:I}),M.map((e,n)=>{let a=t.reverseMonths?M.length-1-n:n;return Z.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[TY.Month],style:S?.[TY.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&Z.createElement(r.PreviousMonthButton,{type:`button`,className:c[TY.PreviousMonthButton],style:S?.[TY.PreviousMonthButton],tabIndex:F?void 0:-1,"aria-disabled":!F||void 0,"aria-label":oe(F),onClick:me,"data-animated-button":t.animate?`true`:void 0},Z.createElement(r.Chevron,{disabled:!F||void 0,className:c[TY.Chevron],style:S?.[TY.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),Z.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[TY.MonthCaption],style:S?.[TY.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?Z.createElement(r.DropdownNav,{className:c[TY.Dropdowns],style:S?.[TY.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?Z.createElement(r.MonthsDropdown,{key:`month`,className:c[TY.MonthsDropdown],"aria-label":ae(),disabled:!!t.disableNavigation,onChange:Se(e.date,a),options:IX(e.date,N,P,i,o),style:De(TY.MonthsDropdown),value:o.getMonth(e.date)}):Z.createElement(`span`,{key:`month`},T(e.date,o)),s=l===`dropdown`||l===`dropdown-years`?Z.createElement(r.YearsDropdown,{key:`year`,className:c[TY.YearsDropdown],"aria-label":de(o.options),disabled:!!t.disableNavigation,onChange:Ce(e.date,a),options:zX(N,P,i,o,!!t.reverseYears),style:De(TY.YearsDropdown),value:o.getYear(e.date)}):Z.createElement(`span`,{key:`year`},k(e.date,o));return o.getMonthYearOrder()===`year-first`?[s,n]:[n,s]})(),Z.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},C(e.date,o.options,o))):Z.createElement(r.CaptionLabel,{className:c[TY.CaptionLabel],style:S?.[TY.CaptionLabel],role:`status`,"aria-live":`polite`},C(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&Z.createElement(r.NextMonthButton,{type:`button`,className:c[TY.NextMonthButton],style:S?.[TY.NextMonthButton],tabIndex:I?void 0:-1,"aria-disabled":!I||void 0,"aria-label":se(I),onClick:he,"data-animated-button":t.animate?`true`:void 0},Z.createElement(r.Chevron,{disabled:!I||void 0,className:c[TY.Chevron],style:S?.[TY.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&Z.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[TY.Nav],style:S?.[TY.Nav],"aria-label":G(),onPreviousClick:me,onNextClick:he,previousMonth:F,nextMonth:I}),Z.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":W(e.date,o.options,o)||void 0,className:c[TY.MonthGrid],style:S?.[TY.MonthGrid]},!t.hideWeekdays&&Z.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[TY.Weekdays],style:S?.[TY.Weekdays]},x&&Z.createElement(r.WeekNumberHeader,{"aria-label":ue(o.options),className:c[TY.WeekNumberHeader],style:S?.[TY.WeekNumberHeader],scope:`col`},D()),fe.map(e=>Z.createElement(r.Weekday,{"aria-label":ce(e,o.options,o),className:c[TY.Weekday],key:String(e),style:S?.[TY.Weekday],scope:`col`},O(e,o.options,o)))),Z.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[TY.Weeks],style:S?.[TY.Weeks]},e.weeks.map(e=>Z.createElement(r.Week,{className:c[TY.Week],key:e.weekNumber,style:S?.[TY.Week],week:e},x&&Z.createElement(r.WeekNumber,{week:e,style:S?.[TY.WeekNumber],"aria-label":le(e.weekNumber,{locale:s}),className:c[TY.WeekNumber],scope:`row`,role:`rowheader`},E(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=R(e);if(i[EY.focused]=!i.hidden&&!!te?.isEqualTo(e),i[DY.selected]=z?.(n)||i.selected,tX(V)){let{from:e,to:t}=V;i[DY.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[DY.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[DY.range_middle]=$Y(V,n,!0,o)}let a=LX(i,S,t.modifiersStyles),s=cX(i,c,t.modifiersClassNames),l=!pe&&!i.hidden?U(n,i,o.options,o):void 0;return Z.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&pe?Z.createElement(r.DayButton,{className:c[TY.DayButton],style:S?.[TY.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:ne(e)?0:-1,"aria-label":ie(n,i,o.options,o),onClick:ge(e,i),onBlur:ve(e,i),onFocus:_e(e,i),onKeyDown:ye(e,i),onMouseEnter:be(e,i),onMouseLeave:xe(e,i)},w(n,o.options,o)):!i.hidden&&w(e.date,o.options,o))}))))))})),t.footer&&Z.createElement(r.Footer,{className:c[TY.Footer],style:S?.[TY.Footer],role:`status`,"aria-live":`polite`},t.footer)))}function TZ({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...c}){let l=dX();return(0,Q.jsx)(wZ,{showOutsideDays:n,className:s(`bg-white group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent dark:bg-gray-950`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:s(`w-fit`,l.root),months:s(`flex gap-4 flex-col md:flex-row relative`,l.months),month:s(`flex flex-col w-full gap-4`,l.month),nav:s(`flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between`,l.nav),button_previous:s($n({variant:i}),`size-(--cell-size) aria-disabled:opacity-50 p-0 select-none`,l.button_previous),button_next:s($n({variant:i}),`size-(--cell-size) aria-disabled:opacity-50 p-0 select-none`,l.button_next),month_caption:s(`flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)`,l.month_caption),dropdowns:s(`w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5`,l.dropdowns),dropdown_root:s(`relative has-focus:border-gray-950 border border-gray-200 shadow-xs has-focus:ring-gray-950/50 has-focus:ring-[3px] rounded-md dark:has-focus:border-gray-300 dark:border-gray-800 dark:has-focus:ring-gray-300/50`,l.dropdown_root),dropdown:s(`absolute bg-white inset-0 opacity-0 dark:bg-gray-950`,l.dropdown),caption_label:s(`select-none font-medium`,r===`label`?`text-sm`:`rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-gray-500 [&>svg]:size-3.5 dark:[&>svg]:text-gray-400`,l.caption_label),month_grid:`w-full border-collapse`,weekdays:s(`flex`,l.weekdays),weekday:s(`text-gray-500 rounded-md flex-1 font-normal text-[0.8rem] select-none dark:text-gray-400`,l.weekday),week:s(`flex w-full mt-2`,l.week),week_number_header:s(`select-none w-(--cell-size)`,l.week_number_header),week_number:s(`text-[0.8rem] select-none text-gray-500 dark:text-gray-400`,l.week_number),day:s(`relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none`,l.day),range_start:s(`rounded-l-md bg-gray-100 dark:bg-gray-800`,l.range_start),range_middle:s(`rounded-none`,l.range_middle),range_end:s(`rounded-r-md bg-gray-100 dark:bg-gray-800`,l.range_end),today:s(`bg-gray-100 text-gray-900 rounded-md data-[selected=true]:rounded-none dark:bg-gray-800 dark:text-gray-50`,l.today),outside:s(`text-gray-500 aria-selected:text-gray-500 dark:text-gray-400 dark:aria-selected:text-gray-400`,l.outside),disabled:s(`text-gray-500 opacity-50 dark:text-gray-400`,l.disabled),hidden:s(`invisible`,l.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,Q.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:s(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,Q.jsx)(zi,{className:s(`size-4`,e),...n}):t===`right`?(0,Q.jsx)(vn,{className:s(`size-4`,e),...n}):(0,Q.jsx)(pn,{className:s(`size-4`,e),...n}),DayButton:EZ,WeekNumber:({week:e,...t})=>(0,Q.jsx)(`td`,{...t,children:(0,Q.jsx)(`div`,{className:`flex size-(--cell-size) items-center justify-center text-center`,children:e.weekNumber})}),...o},...c})}function EZ({className:e,day:t,modifiers:n,...r}){let i=dX(),a=Z.useRef(null);return Z.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,Q.jsx)(q,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:s(`data-[selected-single=true]:bg-gray-900 data-[selected-single=true]:text-gray-50 data-[range-middle=true]:bg-gray-100 data-[range-middle=true]:text-gray-900 data-[range-start=true]:bg-gray-900 data-[range-start=true]:text-gray-50 data-[range-end=true]:bg-gray-900 data-[range-end=true]:text-gray-50 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-gray-900 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70 dark:data-[selected-single=true]:bg-gray-50 dark:data-[selected-single=true]:text-gray-900 dark:data-[range-middle=true]:bg-gray-800 dark:data-[range-middle=true]:text-gray-50 dark:data-[range-start=true]:bg-gray-50 dark:data-[range-start=true]:text-gray-900 dark:data-[range-end=true]:bg-gray-50 dark:data-[range-end=true]:text-gray-900 dark:dark:hover:text-gray-50`,i.day,e),...r})}function DZ(e){if(Ql.test(e))return e}function OZ(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r)}function kZ({value:e,onChange:t,disabled:n,id:r,...i}){let a=Z.useId(),o=r??a,[s,c]=Z.useState(!1),l=Fk(),[u,d]=Z.useState(e),[f,p]=Z.useState(u?OZ(u):void 0),[m,h]=Z.useState(u??``),g=m.trim()!==``&&!DZ(m),_=`${o}-date-format-error`,v=[typeof i[`aria-describedby`]==`string`?i[`aria-describedby`]:void 0,g?_:void 0].filter(Boolean).join(` `);return(0,Z.useEffect)(()=>{d(t=>(e??null)===(t??null)?t:(p(e?OZ(e):void 0),h(e??``),e))},[e]),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(Un,{children:[(0,Q.jsx)(Pn,{...i,disabled:n,id:o,value:m,placeholder:`Select date`,"aria-invalid":g,"aria-describedby":v||void 0,onChange:e=>{let n=e.target.value;if(h(n),n.trim()===``){d(void 0),t?.(null);return}let r=DZ(n);r&&(d(r),p(r?OZ(r):void 0),t?.(r))},onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),c(!0))}}),(0,Q.jsx)(Kn,{align:`inline-end`,children:(0,Q.jsxs)(VJ,{open:s,onOpenChange:c,modal:!!l,children:[(0,Q.jsx)(HJ,{asChild:!0,children:(0,Q.jsxs)(Bn,{variant:`ghost`,size:`icon-xs`,"aria-label":`Select date`,children:[(0,Q.jsx)(Ri,{}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Select date`})]})}),(0,Q.jsx)(UJ,{className:`w-auto overflow-hidden p-0`,align:`end`,alignOffset:-8,sideOffset:10,container:l,children:(0,Q.jsx)(TZ,{mode:`single`,selected:u?OZ(u):void 0,month:f,onMonthChange:p,onSelect:e=>{let n=e?Or(e,`yyyy-MM-dd`):void 0;h(n??``),d(n),t?.(n??null),c(!1)}})})]})})]}),g?(0,Q.jsx)(`p`,{id:_,className:`text-destructive text-xs`,children:`Date must use YYYY-MM-DD format.`}):null]})}var AZ=`yyyy-MM-dd HH:mm:ss`,jZ=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;function MZ(e){if(!jZ.test(e))return;let t=jl(e,AZ,new Date);return rr(t)?t:void 0}function NZ({value:e,onChange:t,disabled:n,id:r,...i}){let a=Z.useId(),o=r??a,[s,c]=Z.useState(!1),[l,u]=Z.useState(e??void 0),[d,f]=Z.useState(e?Or(e,AZ):``),p=d.trim()!==``&&!MZ(d),m=`${o}-datetime-format-error`;return(0,Z.useEffect)(()=>{f(e?Or(e,AZ):``),e&&u(e)},[e]),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(Un,{children:[(0,Q.jsx)(Pn,{...i,disabled:n,id:o,value:d,placeholder:`YYYY-MM-DD HH:mm:ss`,"aria-invalid":p||void 0,"aria-describedby":p?m:void 0,onChange:e=>{let n=e.target.value;if(f(n),n.trim()===``){t?.(null);return}let r=MZ(n);r&&(u(r),t?.(r))},onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),c(!0))}}),(0,Q.jsx)(Kn,{align:`inline-end`,children:(0,Q.jsxs)(VJ,{open:s,onOpenChange:c,children:[(0,Q.jsx)(HJ,{asChild:!0,children:(0,Q.jsxs)(Bn,{variant:`ghost`,size:`icon-xs`,"aria-label":`Select date and time`,children:[(0,Q.jsx)(Ri,{}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Select date and time`})]})}),(0,Q.jsxs)(UJ,{className:`w-auto overflow-hidden p-0`,align:`end`,alignOffset:-8,sideOffset:10,children:[(0,Q.jsx)(TZ,{mode:`single`,selected:e??void 0,month:l,onMonthChange:u,onSelect:n=>{if(!n){t?.(null),c(!1);return}let r=e??ui(new Date),i=new Date(n.getFullYear(),n.getMonth(),n.getDate(),r.getHours(),r.getMinutes(),r.getSeconds());f(Or(i,AZ)),u(i),t?.(i),c(!1)}}),(0,Q.jsxs)(`div`,{className:`flex gap-2 border-t p-2`,children:[(0,Q.jsx)(PZ,{label:`Hours`,value:e?e.getHours():0,max:23,onChange:n=>{let r=e??ui(new Date),i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),n,r.getMinutes(),r.getSeconds());f(Or(i,AZ)),t?.(i)}}),(0,Q.jsx)(PZ,{label:`Minutes`,value:e?e.getMinutes():0,max:59,onChange:n=>{let r=e??ui(new Date),i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),n,r.getSeconds());f(Or(i,AZ)),t?.(i)}}),(0,Q.jsx)(PZ,{label:`Seconds`,value:e?e.getSeconds():0,max:59,onChange:n=>{let r=e??ui(new Date),i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),n);f(Or(i,AZ)),t?.(i)}})]})]})]})})]}),p?(0,Q.jsx)(`p`,{id:m,className:`text-destructive text-xs`,children:`Date must use YYYY-MM-DD HH:mm:ss format.`}):null]})}function PZ({label:e,value:t,max:n,onChange:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),(0,Q.jsx)(`input`,{type:`number`,min:0,max:n,value:t,onChange:e=>{let t=parseInt(e.target.value,10);!Number.isNaN(t)&&t>=0&&t<=n&&r(t)},className:`w-12 rounded border px-1 py-0.5 text-center text-sm`})]})}var FZ=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),IZ=n(((e,t)=>{var n=FZ();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),LZ=n(((e,t)=>{t.exports=IZ()()})),RZ=new Map([[`aac`,`audio/aac`],[`abw`,`application/x-abiword`],[`arc`,`application/x-freearc`],[`avif`,`image/avif`],[`avi`,`video/x-msvideo`],[`azw`,`application/vnd.amazon.ebook`],[`bin`,`application/octet-stream`],[`bmp`,`image/bmp`],[`bz`,`application/x-bzip`],[`bz2`,`application/x-bzip2`],[`cda`,`application/x-cdf`],[`csh`,`application/x-csh`],[`css`,`text/css`],[`csv`,`text/csv`],[`doc`,`application/msword`],[`docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`eot`,`application/vnd.ms-fontobject`],[`epub`,`application/epub+zip`],[`gz`,`application/gzip`],[`gif`,`image/gif`],[`heic`,`image/heic`],[`heif`,`image/heif`],[`htm`,`text/html`],[`html`,`text/html`],[`ico`,`image/vnd.microsoft.icon`],[`ics`,`text/calendar`],[`jar`,`application/java-archive`],[`jpeg`,`image/jpeg`],[`jpg`,`image/jpeg`],[`js`,`text/javascript`],[`json`,`application/json`],[`jsonld`,`application/ld+json`],[`mid`,`audio/midi`],[`midi`,`audio/midi`],[`mjs`,`text/javascript`],[`mp3`,`audio/mpeg`],[`mp4`,`video/mp4`],[`mpeg`,`video/mpeg`],[`mpkg`,`application/vnd.apple.installer+xml`],[`odp`,`application/vnd.oasis.opendocument.presentation`],[`ods`,`application/vnd.oasis.opendocument.spreadsheet`],[`odt`,`application/vnd.oasis.opendocument.text`],[`oga`,`audio/ogg`],[`ogv`,`video/ogg`],[`ogx`,`application/ogg`],[`opus`,`audio/opus`],[`otf`,`font/otf`],[`png`,`image/png`],[`pdf`,`application/pdf`],[`php`,`application/x-httpd-php`],[`ppt`,`application/vnd.ms-powerpoint`],[`pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`rar`,`application/vnd.rar`],[`rtf`,`application/rtf`],[`sh`,`application/x-sh`],[`svg`,`image/svg+xml`],[`swf`,`application/x-shockwave-flash`],[`tar`,`application/x-tar`],[`tif`,`image/tiff`],[`tiff`,`image/tiff`],[`ts`,`video/mp2t`],[`ttf`,`font/ttf`],[`txt`,`text/plain`],[`vsd`,`application/vnd.visio`],[`wav`,`audio/wav`],[`weba`,`audio/webm`],[`webm`,`video/webm`],[`webp`,`image/webp`],[`woff`,`font/woff`],[`woff2`,`font/woff2`],[`xhtml`,`application/xhtml+xml`],[`xls`,`application/vnd.ms-excel`],[`xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`xml`,`application/xml`],[`xul`,`application/vnd.mozilla.xul+xml`],[`zip`,`application/zip`],[`7z`,`application/x-7z-compressed`],[`mkv`,`video/x-matroska`],[`mov`,`video/quicktime`],[`msg`,`application/vnd.ms-outlook`]]);function zZ(e,t){var n=BZ(e);if(typeof n.path!=`string`){var r=e.webkitRelativePath;Object.defineProperty(n,"path",{value:typeof t==`string`?t:typeof r==`string`&&r.length>0?r:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function BZ(e){var t=e.name;if(t&&t.lastIndexOf(`.`)!==-1&&!e.type){var n=t.split(`.`).pop().toLowerCase(),r=RZ.get(n);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}var VZ=[`.DS_Store`,`Thumbs.db`];function HZ(e){return Vt(this,void 0,void 0,function(){return Ut(this,function(t){return GZ(e)&&UZ(e.dataTransfer)?[2,JZ(e.dataTransfer,e.type)]:WZ(e)?[2,KZ(e)]:Array.isArray(e)&&e.every(function(e){return`getFile`in e&&typeof e.getFile==`function`})?[2,qZ(e)]:[2,[]]})})}function UZ(e){return GZ(e)}function WZ(e){return GZ(e)&&GZ(e.target)}function GZ(e){return typeof e==`object`&&!!e}function KZ(e){return XZ(e.target.files).map(function(e){return zZ(e)})}function qZ(e){return Vt(this,void 0,void 0,function(){var t;return Ut(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(e){return e.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(e){return zZ(e)})]}})})}function JZ(e,t){return Vt(this,void 0,void 0,function(){var n,r;return Ut(this,function(i){switch(i.label){case 0:return e.items?(n=XZ(e.items).filter(function(e){return e.kind===`file`}),t===`drop`?[4,Promise.all(n.map(ZZ))]:[2,n]):[3,2];case 1:return r=i.sent(),[2,YZ(QZ(r))];case 2:return[2,YZ(XZ(e.files).map(function(e){return zZ(e)}))]}})})}function YZ(e){return e.filter(function(e){return VZ.indexOf(e.name)===-1})}function XZ(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r)}return t}function ZZ(e){if(typeof e.webkitGetAsEntry!=`function`)return $Z(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?tQ(t):$Z(e)}function QZ(e){return e.reduce(function(e,t){return jt(jt([],Dt(e),!1),Dt(Array.isArray(t)?QZ(t):[t]),!1)},[])}function $Z(e){var t=e.getAsFile();if(!t)return Promise.reject(`${e} is not a File`);var n=zZ(t);return Promise.resolve(n)}function eQ(e){return Vt(this,void 0,void 0,function(){return Ut(this,function(t){return[2,e.isDirectory?tQ(e):nQ(e)]})})}function tQ(e){var t=e.createReader();return new Promise(function(e,n){var r=[];function i(){var a=this;t.readEntries(function(t){return Vt(a,void 0,void 0,function(){var a,o,s;return Ut(this,function(c){switch(c.label){case 0:if(t.length)return[3,5];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,Promise.all(r)];case 2:return a=c.sent(),e(a),[3,4];case 3:return o=c.sent(),n(o),[3,4];case 4:return[3,6];case 5:s=Promise.all(t.map(eQ)),r.push(s),i(),c.label=6;case 6:return[2]}})})},function(e){n(e)})}i()})}function nQ(e){return Vt(this,void 0,void 0,function(){return Ut(this,function(t){return[2,new Promise(function(t,n){e.file(function(n){t(zZ(n,e.fullPath))},function(e){n(e)})})]})})}var rQ=r(n((e=>{e.__esModule=!0,e.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(`,`);if(n.length===0)return!0;var r=e.name||``,i=(e.type||``).toLowerCase(),a=i.replace(/\/.*$/,``);return n.some(function(e){var t=e.trim().toLowerCase();return t.charAt(0)===`.`?r.toLowerCase().endsWith(t):t.endsWith(`/*`)?a===t.replace(/\/.*$/,``):i===t})}return!0}}))());function iQ(e){return sQ(e)||oQ(e)||pQ(e)||aQ()}function aQ(){throw TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oQ(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function sQ(e){if(Array.isArray(e))return mQ(e)}function cQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lQ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?cQ(Object(n),!0).forEach(function(t){uQ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cQ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uQ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dQ(e,t){return gQ(e)||hQ(e,t)||pQ(e,t)||fQ()}function fQ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pQ(e,t){if(e){if(typeof e==`string`)return mQ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mQ(e,t)}}function mQ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hQ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function gQ(e){if(Array.isArray(e))return e}var _Q=`file-invalid-type`,vQ=`file-too-large`,yQ=`file-too-small`,bQ=`too-many-files`,xQ=function(e){return e=Array.isArray(e)&&e.length===1?e[0]:e,{code:_Q,message:`File type must be ${Array.isArray(e)?`one of ${e.join(`, `)}`:e}`}},SQ=function(e){return{code:vQ,message:`File is larger than ${e} ${e===1?`byte`:`bytes`}`}},CQ=function(e){return{code:yQ,message:`File is smaller than ${e} ${e===1?`byte`:`bytes`}`}},wQ={code:bQ,message:`Too many files`};function TQ(e,t){var n=e.type===`application/x-moz-file`||(0,rQ.default)(e,t);return[n,n?null:xQ(t)]}function EQ(e,t,n){if(DQ(e.size)){if(DQ(t)&&DQ(n)){if(e.size>n)return[!1,SQ(n)];if(e.size<t)return[!1,CQ(t)]}else if(DQ(t)&&e.size<t)return[!1,CQ(t)];else if(DQ(n)&&e.size>n)return[!1,SQ(n)]}return[!0,null]}function DQ(e){return e!=null}function OQ(e){var t=e.files,n=e.accept,r=e.minSize,i=e.maxSize,a=e.multiple,o=e.maxFiles,s=e.validator;return!a&&t.length>1||a&&o>=1&&t.length>o?!1:t.every(function(e){var t=dQ(TQ(e,n),1)[0],a=dQ(EQ(e,r,i),1)[0],o=s?s(e):null;return t&&a&&!o})}function kQ(e){return typeof e.isPropagationStopped==`function`?e.isPropagationStopped():e.cancelBubble!==void 0&&e.cancelBubble}function AQ(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(e){return e===`Files`||e===`application/x-moz-file`}):!!e.target&&!!e.target.files}function jQ(e){e.preventDefault()}function MQ(e){return e.indexOf(`MSIE`)!==-1||e.indexOf(`Trident/`)!==-1}function NQ(e){return e.indexOf(`Edge/`)!==-1}function PQ(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return MQ(e)||NQ(e)}function FQ(){var e=[...arguments];return function(t){var n=[...arguments].slice(1);return e.some(function(e){return!kQ(t)&&e&&e.apply(void 0,[t].concat(n)),kQ(t)})}}function IQ(){return`showOpenFilePicker`in window}function LQ(e){return DQ(e)?[{description:`Files`,accept:Object.entries(e).filter(function(e){var t=dQ(e,2),n=t[0],r=t[1],i=!0;return VQ(n)||(console.warn(`Skipped "${n}" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.`),i=!1),(!Array.isArray(r)||!r.every(HQ))&&(console.warn(`Skipped "${n}" because an invalid file extension was provided.`),i=!1),i}).reduce(function(e,t){var n=dQ(t,2),r=n[0],i=n[1];return lQ(lQ({},e),{},uQ({},r,i))},{})}]:e}function RQ(e){if(DQ(e))return Object.entries(e).reduce(function(e,t){var n=dQ(t,2),r=n[0],i=n[1];return[].concat(iQ(e),[r],iQ(i))},[]).filter(function(e){return VQ(e)||HQ(e)}).join(`,`)}function zQ(e){return e instanceof DOMException&&(e.name===`AbortError`||e.code===e.ABORT_ERR)}function BQ(e){return e instanceof DOMException&&(e.name===`SecurityError`||e.code===e.SECURITY_ERR)}function VQ(e){return e===`audio/*`||e===`video/*`||e===`image/*`||e===`text/*`||/\w+\/[-+.\w]+/g.test(e)}function HQ(e){return/^.*\.[\w]+$/.test(e)}var UQ=r(LZ()),WQ=[`children`],GQ=[`open`],KQ=[`refKey`,`role`,`onKeyDown`,`onFocus`,`onBlur`,`onClick`,`onDragEnter`,`onDragOver`,`onDragLeave`,`onDrop`],qQ=[`refKey`,`onChange`,`onClick`];function JQ(e){return ZQ(e)||XQ(e)||e$(e)||YQ()}function YQ(){throw TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XQ(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function ZQ(e){if(Array.isArray(e))return t$(e)}function QQ(e,t){return r$(e)||n$(e,t)||e$(e,t)||$Q()}function $Q(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function e$(e,t){if(e){if(typeof e==`string`)return t$(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t$(e,t)}}function t$(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n$(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function r$(e){if(Array.isArray(e))return e}function i$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i$(Object(n),!0).forEach(function(t){o$(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o$(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s$(e,t){if(e==null)return{};var n=c$(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function c$(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var l$=(0,Z.forwardRef)(function(e,t){var n=e.children,r=f$(s$(e,WQ)),i=r.open,a=s$(r,GQ);return(0,Z.useImperativeHandle)(t,function(){return{open:i}},[i]),Z.createElement(Z.Fragment,null,n(a$(a$({},a),{},{open:i})))});l$.displayName=`Dropzone`;var u$={disabled:!1,getFilesFromEvent:HZ,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0,autoFocus:!1};l$.defaultProps=u$,l$.propTypes={children:UQ.default.func,accept:UQ.default.objectOf(UQ.default.arrayOf(UQ.default.string)),multiple:UQ.default.bool,preventDropOnDocument:UQ.default.bool,noClick:UQ.default.bool,noKeyboard:UQ.default.bool,noDrag:UQ.default.bool,noDragEventsBubbling:UQ.default.bool,minSize:UQ.default.number,maxSize:UQ.default.number,maxFiles:UQ.default.number,disabled:UQ.default.bool,getFilesFromEvent:UQ.default.func,onFileDialogCancel:UQ.default.func,onFileDialogOpen:UQ.default.func,useFsAccessApi:UQ.default.bool,autoFocus:UQ.default.bool,onDragEnter:UQ.default.func,onDragLeave:UQ.default.func,onDragOver:UQ.default.func,onDrop:UQ.default.func,onDropAccepted:UQ.default.func,onDropRejected:UQ.default.func,onError:UQ.default.func,validator:UQ.default.func};var d$={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function f$(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a$(a$({},u$),e),n=t.accept,r=t.disabled,i=t.getFilesFromEvent,a=t.maxSize,o=t.minSize,s=t.multiple,c=t.maxFiles,l=t.onDragEnter,u=t.onDragLeave,d=t.onDragOver,f=t.onDrop,p=t.onDropAccepted,m=t.onDropRejected,h=t.onFileDialogCancel,g=t.onFileDialogOpen,_=t.useFsAccessApi,v=t.autoFocus,y=t.preventDropOnDocument,b=t.noClick,x=t.noKeyboard,S=t.noDrag,C=t.noDragEventsBubbling,w=t.onError,T=t.validator,E=(0,Z.useMemo)(function(){return RQ(n)},[n]),D=(0,Z.useMemo)(function(){return LQ(n)},[n]),O=(0,Z.useMemo)(function(){return typeof g==`function`?g:m$},[g]),k=(0,Z.useMemo)(function(){return typeof h==`function`?h:m$},[h]),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=QQ((0,Z.useReducer)(p$,d$),2),N=M[0],P=M[1],F=N.isFocused,I=N.isFileDialogActive,L=(0,Z.useRef)(typeof window<`u`&&window.isSecureContext&&_&&IQ()),R=function(){!L.current&&I&&setTimeout(function(){j.current&&(j.current.files.length||(P({type:`closeDialog`}),k()))},300)};(0,Z.useEffect)(function(){return window.addEventListener(`focus`,R,!1),function(){window.removeEventListener(`focus`,R,!1)}},[j,I,k,L]);var z=(0,Z.useRef)([]),B=function(e){A.current&&A.current.contains(e.target)||(e.preventDefault(),z.current=[])};(0,Z.useEffect)(function(){return y&&(document.addEventListener(`dragover`,jQ,!1),document.addEventListener(`drop`,B,!1)),function(){y&&(document.removeEventListener(`dragover`,jQ),document.removeEventListener(`drop`,B))}},[A,y]),(0,Z.useEffect)(function(){return!r&&v&&A.current&&A.current.focus(),function(){}},[A,v,r]);var V=(0,Z.useCallback)(function(e){w?w(e):console.error(e)},[w]),ee=(0,Z.useCallback)(function(e){e.preventDefault(),e.persist(),le(e),z.current=[].concat(JQ(z.current),[e.target]),AQ(e)&&Promise.resolve(i(e)).then(function(t){if(!(kQ(e)&&!C)){var n=t.length,r=n>0&&OQ({files:t,accept:E,minSize:o,maxSize:a,multiple:s,maxFiles:c,validator:T});P({isDragAccept:r,isDragReject:n>0&&!r,isDragActive:!0,type:`setDraggedFiles`}),l&&l(e)}}).catch(function(e){return V(e)})},[i,l,V,C,E,o,a,s,c,T]),te=(0,Z.useCallback)(function(e){e.preventDefault(),e.persist(),le(e);var t=AQ(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect=`copy`}catch{}return t&&d&&d(e),!1},[d,C]),ne=(0,Z.useCallback)(function(e){e.preventDefault(),e.persist(),le(e);var t=z.current.filter(function(e){return A.current&&A.current.contains(e)}),n=t.indexOf(e.target);n!==-1&&t.splice(n,1),z.current=t,!(t.length>0)&&(P({type:`setDraggedFiles`,isDragActive:!1,isDragAccept:!1,isDragReject:!1}),AQ(e)&&u&&u(e))},[A,u,C]),re=(0,Z.useCallback)(function(e,t){var n=[],r=[];e.forEach(function(e){var t=QQ(TQ(e,E),2),i=t[0],s=t[1],c=QQ(EQ(e,o,a),2),l=c[0],u=c[1],d=T?T(e):null;if(i&&l&&!d)n.push(e);else{var f=[s,u];d&&(f=f.concat(d)),r.push({file:e,errors:f.filter(function(e){return e})})}}),(!s&&n.length>1||s&&c>=1&&n.length>c)&&(n.forEach(function(e){r.push({file:e,errors:[wQ]})}),n.splice(0)),P({acceptedFiles:n,fileRejections:r,type:`setFiles`}),f&&f(n,r,t),r.length>0&&m&&m(r,t),n.length>0&&p&&p(n,t)},[P,s,E,o,a,c,f,p,m,T]),H=(0,Z.useCallback)(function(e){e.preventDefault(),e.persist(),le(e),z.current=[],AQ(e)&&Promise.resolve(i(e)).then(function(t){kQ(e)&&!C||re(t,e)}).catch(function(e){return V(e)}),P({type:`reset`})},[i,re,V,C]),ie=(0,Z.useCallback)(function(){if(L.current){P({type:`openDialog`}),O();var e={multiple:s,types:D};window.showOpenFilePicker(e).then(function(e){return i(e)}).then(function(e){re(e,null),P({type:`closeDialog`})}).catch(function(e){zQ(e)?(k(e),P({type:`closeDialog`})):BQ(e)?(L.current=!1,j.current?(j.current.value=null,j.current.click()):V(Error(`Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.`))):V(e)});return}j.current&&(P({type:`openDialog`}),O(),j.current.value=null,j.current.click())},[P,O,k,_,re,V,D,s]),U=(0,Z.useCallback)(function(e){!A.current||!A.current.isEqualNode(e.target)||(e.key===` `||e.key===`Enter`||e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),ie())},[A,ie]),W=(0,Z.useCallback)(function(){P({type:`focus`})},[]),ae=(0,Z.useCallback)(function(){P({type:`blur`})},[]),G=(0,Z.useCallback)(function(){b||(PQ()?setTimeout(ie,0):ie())},[b,ie]),oe=function(e){return r?null:e},se=function(e){return x?null:oe(e)},ce=function(e){return S?null:oe(e)},le=function(e){C&&e.stopPropagation()},ue=(0,Z.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,i=e.role,a=e.onKeyDown,o=e.onFocus,s=e.onBlur,c=e.onClick,l=e.onDragEnter,u=e.onDragOver,d=e.onDragLeave,f=e.onDrop,p=s$(e,KQ);return a$(a$(o$({onKeyDown:se(FQ(a,U)),onFocus:se(FQ(o,W)),onBlur:se(FQ(s,ae)),onClick:oe(FQ(c,G)),onDragEnter:ce(FQ(l,ee)),onDragOver:ce(FQ(u,te)),onDragLeave:ce(FQ(d,ne)),onDrop:ce(FQ(f,H)),role:typeof i==`string`&&i!==``?i:`presentation`},n,A),!r&&!x?{tabIndex:0}:{}),p)}},[A,U,W,ae,G,ee,te,ne,H,x,S,r]),de=(0,Z.useCallback)(function(e){e.stopPropagation()},[]),fe=(0,Z.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,r=e.onChange,i=e.onClick,a=s$(e,qQ);return a$(a$({},o$({accept:E,multiple:s,type:`file`,style:{display:`none`},onChange:oe(FQ(r,H)),onClick:oe(FQ(i,de)),tabIndex:-1},n,j)),a)}},[j,n,s,H,r]);return a$(a$({},N),{},{isFocused:F&&!r,getRootProps:ue,getInputProps:fe,rootRef:A,inputRef:j,open:oe(ie)})}function p$(e,t){switch(t.type){case`focus`:return a$(a$({},e),{},{isFocused:!0});case`blur`:return a$(a$({},e),{},{isFocused:!1});case`openDialog`:return a$(a$({},d$),{},{isFileDialogActive:!0});case`closeDialog`:return a$(a$({},e),{},{isFileDialogActive:!1});case`setDraggedFiles`:return a$(a$({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case`setFiles`:return a$(a$({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case`reset`:return a$({},d$);default:return e}}function m$(){}var[h$,g$]=Fu(`Dropzone component was not found in tree`),_$=Object.getOwnPropertySymbols,v$=Object.prototype.hasOwnProperty,y$=Object.prototype.propertyIsEnumerable,b$=(e,t)=>{var n={};for(var r in e)v$.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_$)for(var r of _$(e))t.indexOf(r)<0&&y$.call(e,r)&&(n[r]=e[r]);return n};function x$(e){let t=t=>{let n=X(`Dropzone${Rd(e)}`,{},t),{children:r}=n,i=b$(n,[`children`]),a=g$(),o=Bu(r)?r:Z.createElement(`span`,null,r);return a[e]?(0,Z.cloneElement)(o,i):null};return t.displayName=`@mantine/dropzone/${Rd(e)}`,t}var S$=x$(`accept`),C$=x$(`reject`),w$=x$(`idle`),T$=Object.defineProperty,E$=Object.defineProperties,D$=Object.getOwnPropertyDescriptors,O$=Object.getOwnPropertySymbols,k$=Object.prototype.hasOwnProperty,A$=Object.prototype.propertyIsEnumerable,j$=(e,t,n)=>t in e?T$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M$=(e,t)=>{for(var n in t||={})k$.call(t,n)&&j$(e,n,t[n]);if(O$)for(var n of O$(t))A$.call(t,n)&&j$(e,n,t[n]);return e},N$=(e,t)=>E$(e,D$(t)),P$=Ur((e,{padding:t,radius:n})=>{let r=e.fn.variant({color:`red`,variant:`light`}),i=e.fn.variant({color:e.primaryColor,variant:`light`});return{root:N$(M$(M$({},e.fn.fontStyles()),e.fn.focusStyles()),{boxSizing:`border-box`,backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.white,border:`${Y(2)} dashed ${e.colorScheme===`dark`?e.colors.dark[4]:e.colors.gray[4]}`,padding:J({size:t,sizes:e.spacing}),borderRadius:e.fn.radius(n),cursor:`pointer`,userSelect:`none`,transition:`background-color 150ms ease`,position:`relative`,"&:hover":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[5]:e.colors.gray[0]},"&[data-loading]":{cursor:`default`,"&:hover":{backgroundColor:e.colorScheme===`dark`?e.colors.dark[6]:e.white}},"&[data-accept]":{backgroundColor:e.colorScheme===`dark`?i.background:e.colors[e.primaryColor][0],borderColor:e.colorScheme===`dark`?i.border:e.colors[e.primaryColor][4],"&:hover":{backgroundColor:e.colorScheme===`dark`?i.background:e.colors[e.primaryColor][0]}},"&[data-reject]":{backgroundColor:e.colorScheme===`dark`?r.background:e.colors.red[0],borderColor:e.colorScheme===`dark`?r.border:e.colors.red[4],"&:hover":{backgroundColor:e.colorScheme===`dark`?r.background:e.colors.red[0]}}}),inner:{pointerEvents:`none`,userSelect:`none`}}}),F$=Object.defineProperty,I$=Object.defineProperties,L$=Object.getOwnPropertyDescriptors,R$=Object.getOwnPropertySymbols,z$=Object.prototype.hasOwnProperty,B$=Object.prototype.propertyIsEnumerable,V$=(e,t,n)=>t in e?F$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,H$=(e,t)=>{for(var n in t||={})z$.call(t,n)&&V$(e,n,t[n]);if(R$)for(var n of R$(t))B$.call(t,n)&&V$(e,n,t[n]);return e},U$=(e,t)=>I$(e,L$(t)),W$=(e,t)=>{var n={};for(var r in e)z$.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&R$)for(var r of R$(e))t.indexOf(r)<0&&B$.call(e,r)&&(n[r]=e[r]);return n},G$={padding:`md`,loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0};function K$(e){let t=X(`Dropzone`,G$,e),{className:n,padding:r,radius:i,disabled:a,classNames:o,styles:s,loading:c,multiple:l,maxSize:u,accept:d,children:f,onDropAny:p,onDrop:m,onReject:h,openRef:g,name:_,unstyled:v,maxFiles:y,autoFocus:b,activateOnClick:x,activateOnDrag:S,dragEventsBubbling:C,activateOnKeyboard:w,onDragEnter:T,onDragLeave:E,onDragOver:D,onFileDialogCancel:O,onFileDialogOpen:k,preventDropOnDocument:A,useFsAccessApi:j,getFilesFromEvent:M,validator:N,variant:P}=t,F=W$(t,`className.padding.radius.disabled.classNames.styles.loading.multiple.maxSize.accept.children.onDropAny.onDrop.onReject.openRef.name.unstyled.maxFiles.autoFocus.activateOnClick.activateOnDrag.dragEventsBubbling.activateOnKeyboard.onDragEnter.onDragLeave.onDragOver.onFileDialogCancel.onFileDialogOpen.preventDropOnDocument.useFsAccessApi.getFilesFromEvent.validator.variant`.split(`.`)),{classes:I,cx:L}=P$({radius:i,padding:r},{name:`Dropzone`,classNames:o,styles:s,unstyled:v,variant:P}),{getRootProps:R,getInputProps:z,isDragAccept:B,isDragReject:V,open:ee}=f$(H$({onDrop:p,onDropAccepted:m,onDropRejected:h,disabled:a||c,accept:Array.isArray(d)?d.reduce((e,t)=>U$(H$({},e),{[t]:[]}),{}):d,multiple:l,maxSize:u,maxFiles:y,autoFocus:b,noClick:!x,noDrag:!S,noDragEventsBubbling:!C,noKeyboard:!w,onDragEnter:T,onDragLeave:E,onDragOver:D,onFileDialogCancel:O,onFileDialogOpen:k,preventDropOnDocument:A,useFsAccessApi:j,validator:N},M?{getFilesFromEvent:M}:null));Td(g,ee);let te=!B&&!V;return Z.createElement(h$,{value:{accept:B,reject:V,idle:te}},Z.createElement(Br,U$(H$(H$({},F),R()),{"data-accept":B||void 0,"data-reject":V||void 0,"data-idle":te||void 0,"data-loading":c||void 0,className:L(I.root,n)}),Z.createElement(HE,{visible:c,radius:i,unstyled:v}),Z.createElement(`input`,U$(H$({},z()),{name:_})),Z.createElement(`div`,{className:I.inner},f)))}K$.displayName=`@mantine/dropzone/Dropzone`,K$.Accept=S$,K$.Reject=C$,K$.Idle=w$;var q$=K$,J$=Object.defineProperty,Y$=Object.defineProperties,X$=Object.getOwnPropertyDescriptors,Z$=Object.getOwnPropertySymbols,Q$=Object.prototype.hasOwnProperty,$$=Object.prototype.propertyIsEnumerable,e1=(e,t,n)=>t in e?J$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,t1=(e,t)=>{for(var n in t||={})Q$.call(t,n)&&e1(e,n,t[n]);if(Z$)for(var n of Z$(t))$$.call(t,n)&&e1(e,n,t[n]);return e},n1=(e,t)=>Y$(e,X$(t)),r1=Ur(e=>({wrapper:n1(t1({},e.fn.cover(0)),{position:`fixed`,backgroundColor:e.colorScheme===`dark`?e.colors.dark[7]:e.white,display:`flex`,padding:e.spacing.xs,transition:`opacity 100ms ease`}),dropzone:{flex:1}})),i1=Object.defineProperty,a1=Object.defineProperties,o1=Object.getOwnPropertyDescriptors,s1=Object.getOwnPropertySymbols,c1=Object.prototype.hasOwnProperty,l1=Object.prototype.propertyIsEnumerable,u1=(e,t,n)=>t in e?i1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d1=(e,t)=>{for(var n in t||={})c1.call(t,n)&&u1(e,n,t[n]);if(s1)for(var n of s1(t))l1.call(t,n)&&u1(e,n,t[n]);return e},f1=(e,t)=>a1(e,o1(t)),p1=(e,t)=>{var n={};for(var r in e)c1.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&s1)for(var r of s1(e))t.indexOf(r)<0&&l1.call(e,r)&&(n[r]=e[r]);return n},m1={padding:`md`,loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:Hu(`max`),withinPortal:!0};function h1(e){let t=X(`DropzoneFullScreen`,m1,e),{classNames:n,styles:r,sx:i,className:a,style:o,unstyled:s,active:c,onDrop:l,onReject:u,zIndex:d,withinPortal:f,portalProps:p}=t,m=p1(t,[`classNames`,`styles`,`sx`,`className`,`style`,`unstyled`,`active`,`onDrop`,`onReject`,`zIndex`,`withinPortal`,`portalProps`]),[h,g]=Z.useState(0),[_,{open:v,close:y}]=Ld(!1),{classes:b,cx:x}=r1(null,{name:`DropzoneFullScreen`,classNames:n,styles:r,unstyled:s}),S=e=>{e.dataTransfer.types.includes(`Files`)&&(g(e=>e+1),v())},C=()=>{g(e=>e-1)};return(0,Z.useEffect)(()=>{h===0&&y()},[h]),(0,Z.useEffect)(()=>{if(c)return document.addEventListener(`dragenter`,S,!1),document.addEventListener(`dragleave`,C,!1),()=>{document.removeEventListener(`dragenter`,S,!1),document.removeEventListener(`dragleave`,C,!1)}},[c]),Z.createElement(tp,f1(d1({},p),{withinPortal:f}),Z.createElement(Br,{className:x(b.wrapper,a),sx:i,style:f1(d1({},o),{opacity:+!!_,pointerEvents:_?`all`:`none`,zIndex:d})},Z.createElement(K$,f1(d1({},m),{classNames:n,styles:r,unstyled:s,className:b.dropzone,onDrop:e=>{l?.(e),y()},onReject:e=>{u?.(e),y()}}))))}h1.displayName=`@mantine/dropzone/DropzoneFullScreen`,q$.FullScreen=h1;var g1=q$,_1=({children:e,chargeId:t})=>{let{uploading:n,uploadMultipleDocuments:r}=vK();function i(e){K.error(`Error`,{description:e,duration:5e3})}return(0,Q.jsx)(g1,{onDrop:e=>r({documents:e,chargeId:t,isSensitive:!1}),onReject:e=>i(`Rejected Files:\n${e.map(e=>`"${e.file.name}": ${e.errors}`).join(`
`)}`),activateOnClick:!1,activateOnKeyboard:!1,radius:0,padding:0,maxFiles:1/0,loading:n,sx:()=>({border:0,cursor:`default`,width:`100%`,height:`100%`,zIndex:1}),children:e})};(0,Z.forwardRef)(function({type:e=`text`,label:t,error:n,onChange:r,showControls:i=!1,rightPadding:a=`pr-2`,precision:o,children:s,isDirty:c,className:l,...u}){function d(e){let t=Number(e.target.value);if(Number.isNaN(t))r(null);else{if(o){let e=10**o;t=Math.round((t+2**-52)*e)/e}r(t)}}return(0,Q.jsxs)(`div`,{className:l,children:[t&&(0,Q.jsx)(`label`,{htmlFor:u.name,className:`text-sm font-medium text-gray-700`,children:t}),(0,Q.jsxs)(`div`,{children:[!i&&e===`number`&&(0,Q.jsx)(`style`,{children:`/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
`}),(0,Q.jsx)(`input`,{type:e,...u,onChange:e===`number`?d:r,className:`w-full bg-gray-100 rounded border border-${n?`red`:c?`green`:`gray`}-300 focus:ring-2 focus:ring-indigo-200 focus:bg-transparent focus:border-indigo-500 text-base outline-hidden text-gray-700 py-1 px-3 leading-8 transition-colors duration-200 ease-in-out ${a} sm:text-sm rounded-md`}),s]}),n&&(0,Q.jsx)(`p`,{className:`text-red-500 text-xs italic`,children:n})]})});var v1=Zn(`m-1 transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300`,{variants:{variant:{default:`border-gray-950/10 text-gray-950 bg-white hover:bg-white/80`,secondary:`border-gray-950/10 bg-gray-100 text-gray-900 hover:bg-gray-100/80`,destructive:`border-transparent bg-red-600 text-destructive-foreground hover:bg-red-600/80`,inverted:`inverted`}},defaultVariants:{variant:`default`}}),y1=Z.forwardRef(({options:e,onValueChange:t,variant:n,defaultValue:r=[],placeholder:i=`Select options`,animation:a=0,maxCount:o=3,modalPopover:c=!1,asChild:l=!1,className:u,removeButton:d,...f},p)=>{let m=Fk(),[h,g]=Z.useState(r),[_,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(r),C=Z.useMemo(()=>{let t=new Set(x);return[...e.filter(e=>t.has(e.value)),...e.filter(e=>!t.has(e.value))]},[e,x]),w=e=>{if(e.key===`Enter`)v(!0);else if(e.key===`Backspace`&&!e.currentTarget.value){let e=[...h];e.pop(),g(e),t(e)}},T=e=>{let n=h.includes(e)?h.filter(t=>t!==e):[...h,e];g(n),t(n)},E=()=>{g([]),t([])},D=()=>{v(e=>!e)},O=()=>{let e=h.slice(0,o);g(e),t(e)},k=()=>{if(h.length===e.length)E();else{let n=e.map(e=>e.value);g(n),t(n)}};return(0,Q.jsxs)(VJ,{open:_,onOpenChange:e=>{e&&S(h),v(e)},modal:c||!!m,children:[(0,Q.jsx)(HJ,{asChild:l,children:(0,Q.jsx)(q,{ref:p,...f,onClick:D,className:s(`flex w-full p-1 rounded-md border min-h-10 h-auto items-center justify-between bg-inherit hover:bg-inherit [&_svg]:pointer-events-auto`,u),children:h.length>0?(0,Q.jsxs)(`div`,{className:`flex justify-between items-center w-full`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center`,children:[h.slice(0,o).map(t=>{let r=e.find(e=>e.value===t),i=r?.icon;return(0,Q.jsxs)(ar,{className:s(y?`animate-bounce`:``,v1({variant:n})),style:{animationDuration:`${a}s`},children:[i&&(0,Q.jsx)(i,{className:`h-4 w-4 mr-2`}),r?.label,d&&(0,Q.jsx)(q,{className:`h-4 w-4 p-0`,variant:`link`,onClick:e=>{e.stopPropagation(),T(t)},children:(0,Q.jsx)(Ui,{className:`h-4 w-4 cursor-pointer`})})]},t)}),h.length>o&&(0,Q.jsxs)(ar,{className:s(`bg-transparent text-gray-950 border-gray-950/1 hover:bg-transparent p-0 gap-0`,y?`animate-bounce`:``,v1({variant:n})),style:{animationDuration:`${a}s`},children:[(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{asChild:!0,children:(0,Q.jsx)(`span`,{role:`button`,tabIndex:0,className:`pl-2 pr-1 py-0.5 cursor-help outline-none focus-visible:underline`,children:`+ ${h.length-o} more`})}),(0,Q.jsx)(yr,{className:`flex flex-col gap-0.5`,container:m,children:h.slice(o).map(t=>{let n=e.find(e=>e.value===t);return(0,Q.jsx)(`span`,{children:n?.label??t},t)})})]}),d&&(0,Q.jsx)(q,{className:`h-4 w-4 p-0 mr-1`,variant:`link`,onClick:e=>{e.stopPropagation(),O()},children:(0,Q.jsx)(Ui,{className:`h-4 w-4 cursor-pointer`})})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(dn,{className:`h-4 mx-2 cursor-pointer text-gray-500`,onClick:e=>{e.stopPropagation(),E()}}),(0,Q.jsx)(qn,{orientation:`vertical`,className:`flex min-h-6 h-full`}),(0,Q.jsx)(pn,{className:`h-4 mx-2 cursor-pointer text-gray-500`})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-center justify-between w-full mx-auto`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-gray-500 mx-3`,children:i}),(0,Q.jsx)(pn,{className:`h-4 cursor-pointer text-gray-500 mx-2`})]})})}),(0,Q.jsx)(UJ,{className:`w-auto p-0`,align:`start`,container:m,onEscapeKeyDown:()=>v(!1),children:(0,Q.jsxs)(Sq,{children:[(0,Q.jsx)(Cq,{placeholder:`Search...`,onKeyDown:w}),(0,Q.jsxs)(wq,{children:[(0,Q.jsx)(Tq,{children:`No results found.`}),(0,Q.jsxs)(Eq,{children:[(0,Q.jsxs)(Oq,{onSelect:k,className:`cursor-pointer`,children:[(0,Q.jsx)(`div`,{className:s(`mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-gray-900`,h.length===e.length?`bg-gray-900 text-gray-50`:`opacity-50 [&_svg]:invisible`),children:(0,Q.jsx)(on,{className:`h-4 w-4`})}),(0,Q.jsx)(`span`,{children:`(Select All)`})]},`all`),C.map(e=>{let t=h.includes(e.value);return(0,Q.jsxs)(Oq,{onSelect:()=>T(e.value),className:`cursor-pointer`,children:[(0,Q.jsx)(`div`,{className:s(`mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-gray-900`,t?`bg-gray-900 text-gray-50`:`opacity-50 [&_svg]:invisible`),children:(0,Q.jsx)(on,{className:`h-4 w-4`})}),e.icon&&(0,Q.jsx)(e.icon,{className:`mr-2 h-4 w-4 text-gray-500`}),(0,Q.jsx)(`span`,{children:e.label}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs opacity-65`,children:e.description})]},e.value)})]}),(0,Q.jsx)(Dq,{}),(0,Q.jsx)(Eq,{children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[h.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Oq,{onSelect:E,className:`flex-1 justify-center cursor-pointer`,children:`Clear`}),(0,Q.jsx)(qn,{orientation:`vertical`,className:`flex min-h-6 h-full`})]}),(0,Q.jsx)(Oq,{onSelect:()=>v(!1),className:`flex-1 justify-center cursor-pointer max-w-full`,children:`Close`})]})})]})]})}),a>0&&h.length>0&&(0,Q.jsx)(ja,{className:s(`cursor-pointer my-2 text-gray-950 bg-white w-5 h-5`,y?``:`text-gray-500`),onClick:()=>b(!y)})]})});y1.displayName=`MultiSelect`;function b1(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}var x1;(function(e){e.event=`event`,e.props=`prop`})(x1||={});function S1(){}function C1(e){var t,n=void 0;return function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return t&&r.length===t.length&&r.every(function(e,n){return e===t[n]})?n:(t=r,n=e.apply(void 0,r),n)}}function w1(e){return!!(e||``).match(/\d/)}function T1(e){return e==null}function E1(e){return typeof e==`number`&&isNaN(e)}function D1(e){return T1(e)||E1(e)||typeof e==`number`&&!isFinite(e)}function O1(e){return e.replace(/[-[\]/{}()*+?.\\^$|]/g,`\\$&`)}function k1(e){switch(e){case`lakh`:return/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;case`wan`:return/(\d)(?=(\d{4})+(?!\d))/g;default:return/(\d)(?=(\d{3})+(?!\d))/g}}function A1(e,t,n){var r=k1(n),i=e.search(/[1-9]/);return i=i===-1?e.length:i,e.substring(0,i)+e.substring(i,e.length).replace(r,`$1`+t)}function j1(e){var t=(0,Z.useRef)(e);return t.current=e,(0,Z.useRef)(function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return t.current.apply(t,e)}).current}function M1(e,t){t===void 0&&(t=!0);var n=e[0]===`-`,r=n&&t;e=e.replace(`-`,``);var i=e.split(`.`);return{beforeDecimal:i[0],afterDecimal:i[1]||``,hasNegation:n,addNegation:r}}function N1(e){if(!e)return e;var t=e[0]===`-`;t&&(e=e.substring(1,e.length));var n=e.split(`.`),r=n[0].replace(/^0+/,``)||`0`,i=n[1]||``;return(t?`-`:``)+r+(i?`.`+i:``)}function P1(e,t,n){for(var r=``,i=n?`0`:``,a=0;a<=t-1;a++)r+=e[a]||i;return r}function F1(e,t){return Array(t+1).join(e)}function I1(e){var t=e+``,n=t[0]===`-`?`-`:``;n&&(t=t.substring(1));var r=t.split(/[eE]/g),i=r[0],a=r[1];if(a=Number(a),!a)return n+i;i=i.replace(`.`,``);var o=1+a,s=i.length;return o<0?i=`0.`+F1(`0`,Math.abs(o))+i:o>=s?i+=F1(`0`,o-s):i=(i.substring(0,o)||`0`)+`.`+i.substring(o),n+i}function L1(e,t,n){if([``,`-`].indexOf(e)!==-1)return e;var r=(e.indexOf(`.`)!==-1||n)&&t,i=M1(e),a=i.beforeDecimal,o=i.afterDecimal,s=i.hasNegation,c=parseFloat(`0.`+(o||`0`)),l=(o.length<=t?`0.`+o:c.toFixed(t)).split(`.`),u=a;a&&Number(l[0])&&(u=a.split(``).reverse().reduce(function(e,t,n){return e.length>n?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e},l[0]));var d=P1(l[1]||``,t,n),f=s?`-`:``,p=r?`.`:``;return``+f+u+p+d}function R1(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var n=e.createTextRange();return n.move(`character`,t),n.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var z1=C1(function(e,t){for(var n=0,r=0,i=e.length,a=t.length;e[n]===t[n]&&n<i;)n++;for(;e[i-1-r]===t[a-1-r]&&a-r>n&&i-r>n;)r++;return{from:{start:n,end:i-r},to:{start:n,end:a-r}}}),B1=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}};function V1(e,t,n){return Math.min(Math.max(e,t),n)}function H1(e){return Math.max(e.selectionStart,e.selectionEnd)}function U1(){return typeof navigator<`u`&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function W1(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:``}}function G1(e){var t=e.currentValue,n=e.formattedValue,r=e.currentValueIndex,i=e.formattedValueIndex;return t[r]===n[i]}function K1(e,t,n,r,i,a,o){o===void 0&&(o=G1);var s=i.findIndex(function(e){return e}),c=e.slice(0,s);!t&&!n.startsWith(c)&&(t=c,n=c+n,r+=c.length);for(var l=n.length,u=e.length,d={},f=Array(l),p=0;p<l;p++){f[p]=-1;for(var m=0,h=u;m<h;m++)if(o({currentValue:n,lastValue:t,formattedValue:e,currentValueIndex:p,formattedValueIndex:m})&&d[m]!==!0){f[p]=m,d[m]=!0;break}}for(var g=r;g<l&&(f[g]===-1||!a(n[g]));)g++;var _=g===l||f[g]===-1?u:f[g];for(g=r-1;g>0&&f[g]===-1;)g--;var v=g===-1||f[g]===-1?0:f[g]+1;return v>_?_:r-v<_-r?v:_}function q1(e,t,n,r){var i=e.length;if(t=V1(t,0,i),r===`left`){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else{for(;t<=i&&!n[t];)t++;t>i&&(t=n.lastIndexOf(!0))}return t===-1&&(t=i),t}function J1(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),n=0,r=t.length;n<r;n++)t[n]=!!(w1(e[n])||w1(e[n-1]));return t}function Y1(e,t,n,r,i,a){a===void 0&&(a=S1);var o=j1(function(e,t){var n,a;return D1(e)?(a=``,n=``):typeof e==`number`||t?(a=typeof e==`number`?I1(e):e,n=r(a)):(a=i(e,void 0),n=r(a)),{formattedValue:n,numAsString:a}}),s=(0,Z.useState)(function(){return o(T1(e)?t:e,n)}),c=s[0],l=s[1],u=j1(function(e,t){e.formattedValue!==c.formattedValue&&l({formattedValue:e.formattedValue,numAsString:e.value}),a(e,t)}),d=e,f=n;T1(e)&&(d=c.numAsString,f=!0);var p=o(d,f);return(0,Z.useMemo)(function(){l(p)},[p.formattedValue]),(0,Z.useEffect)(function(){if(!T1(t)&&T1(e)&&c.formattedValue!==``){var n=parseFloat(c.numAsString);u({formattedValue:c.formattedValue,value:c.numAsString,floatValue:isNaN(n)?void 0:n},{event:void 0,source:x1.props})}},[]),[c,u]}function X1(e){return e.replace(/[^0-9]/g,``)}function Z1(e){return e}function Q1(e){var t=e.type;t===void 0&&(t=`text`);var n=e.displayType;n===void 0&&(n=`input`);var r=e.customInput,i=e.renderText,a=e.getInputRef,o=e.format;o===void 0&&(o=Z1);var s=e.removeFormatting;s===void 0&&(s=X1);var c=e.defaultValue,l=e.valueIsNumericString,u=e.onValueChange,d=e.isAllowed,f=e.onChange;f===void 0&&(f=S1);var p=e.onKeyDown;p===void 0&&(p=S1);var m=e.onMouseUp;m===void 0&&(m=S1);var h=e.onFocus;h===void 0&&(h=S1);var g=e.onBlur;g===void 0&&(g=S1);var _=e.value,v=e.getCaretBoundary;v===void 0&&(v=J1);var y=e.isValidInputCharacter;y===void 0&&(y=w1);var b=e.isCharacterSame,x=b1(e,[`type`,`displayType`,`customInput`,`renderText`,`getInputRef`,`format`,`removeFormatting`,`defaultValue`,`valueIsNumericString`,`onValueChange`,`isAllowed`,`onChange`,`onKeyDown`,`onMouseUp`,`onFocus`,`onBlur`,`value`,`getCaretBoundary`,`isValidInputCharacter`,`isCharacterSame`]),S=Y1(_,c,!!l,o,s,u),C=S[0],w=C.formattedValue,T=C.numAsString,E=S[1],D=(0,Z.useRef)(),O=(0,Z.useRef)({formattedValue:w,numAsString:T}),k=function(e,t){O.current={formattedValue:e.formattedValue,numAsString:e.value},E(e,t)},A=(0,Z.useState)(!1),j=A[0],M=A[1],N=(0,Z.useRef)(null),P=(0,Z.useRef)({setCaretTimeout:null,focusTimeout:null});(0,Z.useEffect)(function(){return M(!0),function(){clearTimeout(P.current.setCaretTimeout),clearTimeout(P.current.focusTimeout)}},[]);var F=o,I=function(e,t){var n=parseFloat(t);return{formattedValue:e,value:t,floatValue:isNaN(n)?void 0:n}},L=function(e,t,n){(e.selectionStart!==0||e.selectionEnd!==e.value.length)&&(R1(e,t),P.current.setCaretTimeout=setTimeout(function(){e.value===n&&e.selectionStart!==t&&R1(e,t)},0))},R=function(e,t,n){return q1(e,t,v(e),n)},z=function(e,t,n){var r=v(t),i=K1(t,w,e,n,r,y,b);return i=q1(t,i,r),i},B=function(e){var t=e.formattedValue;t===void 0&&(t=``);var n=e.input,r=e.source,i=e.event,a=e.numAsString,o;if(n){var s=e.inputValue||n.value,c=H1(n);n.value=t,o=z(s,t,c),o!==void 0&&L(n,o,t)}t!==w&&k(I(t,a),{event:i,source:r})};(0,Z.useEffect)(function(){var e=O.current,t=e.formattedValue,n=e.numAsString;(w!==t||T!==n)&&k(I(w,T),{event:void 0,source:x1.props})},[w,T]);var V=N.current?H1(N.current):void 0;(typeof window<`u`?Z.useLayoutEffect:Z.useEffect)(function(){var e=N.current;if(w!==O.current.formattedValue&&e){var t=z(O.current.formattedValue,w,V);e.value=w,L(e,t,w)}},[w]);var ee=function(e,t,n){var r=t.target,i=D.current?B1(D.current,r.selectionEnd):z1(w,e),a=Object.assign(Object.assign({},i),{lastValue:w}),o=s(e,a),c=F(o);if(o=s(c,void 0),d&&!d(I(c,o))){var l=t.target,u=z(e,w,H1(l));return l.value=w,L(l,u,w),!1}return B({formattedValue:c,numAsString:o,inputValue:e,event:t,source:n,input:t.target}),!0},te=function(e,t){t===void 0&&(t=0),D.current={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd+t}},ne=function(e){var t=e.target.value;ee(t,e,x1.event)&&f(e),D.current=void 0},re=function(e){var t=e.target,n=e.key,r=t.selectionStart,i=t.selectionEnd,a=t.value;a===void 0&&(a=``);var o;n===`ArrowLeft`||n===`Backspace`?o=Math.max(r-1,0):n===`ArrowRight`?o=Math.min(r+1,a.length):n===`Delete`&&(o=r);var s=0;n===`Delete`&&r===i&&(s=1);var c=n===`ArrowLeft`||n===`ArrowRight`;if(o===void 0||r!==i&&!c){p(e),te(t,s);return}var l=o;c?(l=R(a,o,n===`ArrowLeft`?`left`:`right`),l!==o&&e.preventDefault()):n===`Delete`&&!y(a[o])?l=R(a,o,`right`):n===`Backspace`&&!y(a[o])&&(l=R(a,o,`left`)),l!==o&&L(t,l,a),p(e),te(t,s)},H=function(e){var t=e.target,n=function(){var e=t.selectionStart,n=t.selectionEnd,r=t.value;if(r===void 0&&(r=``),e===n){var i=R(r,e);i!==e&&L(t,i,r)}};n(),requestAnimationFrame(function(){n()}),m(e),te(t)},ie=function(e){e.persist&&e.persist();var t=e.target,n=e.currentTarget;N.current=t,P.current.focusTimeout=setTimeout(function(){var r=t.selectionStart,i=t.selectionEnd,a=t.value;a===void 0&&(a=``);var o=R(a,r);o!==r&&(r!==0||i!==a.length)&&L(t,o,a),h(Object.assign(Object.assign({},e),{currentTarget:n}))},0)},U=function(e){N.current=null,clearTimeout(P.current.focusTimeout),clearTimeout(P.current.setCaretTimeout),g(e)},W=j&&U1()?`numeric`:void 0,ae=Object.assign({inputMode:W},x,{type:t,value:w,onChange:ne,onKeyDown:re,onMouseUp:H,onFocus:ie,onBlur:U});if(n===`text`)return i?Z.createElement(Z.Fragment,null,i(w,x)||null):Z.createElement(`span`,Object.assign({},x,{ref:a}),w);if(r){var G=r;return Z.createElement(G,Object.assign({},ae,{ref:a}))}return Z.createElement(`input`,Object.assign({},ae,{ref:a}))}function $1(e,t){var n=t.decimalScale,r=t.fixedDecimalScale,i=t.prefix;i===void 0&&(i=``);var a=t.suffix;a===void 0&&(a=``);var o=t.allowNegative,s=t.thousandsGroupStyle;if(s===void 0&&(s=`thousand`),e===``||e===`-`)return e;var c=e0(t),l=c.thousandSeparator,u=c.decimalSeparator,d=n!==0&&e.indexOf(`.`)!==-1||n&&r,f=M1(e,o),p=f.beforeDecimal,m=f.afterDecimal,h=f.addNegation;return n!==void 0&&(m=P1(m,n,!!r)),l&&(p=A1(p,l,s)),i&&(p=i+p),a&&(m+=a),h&&(p=`-`+p),e=p+(d&&u||``)+m,e}function e0(e){var t=e.decimalSeparator;t===void 0&&(t=`.`);var n=e.thousandSeparator,r=e.allowedDecimalSeparators;return n===!0&&(n=`,`),r||=[t,`.`],{decimalSeparator:t,thousandSeparator:n,allowedDecimalSeparators:r}}function t0(e,t){e===void 0&&(e=``);var n=RegExp(`(-)`),r=RegExp(`(-)(.)*(-)`),i=n.test(e),a=r.test(e);return e=e.replace(/-/g,``),i&&!a&&t&&(e=`-`+e),e}function n0(e,t){return RegExp(`(^-)|[0-9]|`+O1(e),t?`g`:void 0)}function r0(e,t,n){return e===``||!t?.match(/\d/)&&!n?.match(/\d/)&&typeof e==`string`&&!isNaN(Number(e))}function i0(e,t,n){var r;t===void 0&&(t=W1(e));var i=n.allowNegative,a=n.prefix;a===void 0&&(a=``);var o=n.suffix;o===void 0&&(o=``);var s=n.decimalScale,c=t.from,l=t.to,u=l.start,d=l.end,f=e0(n),p=f.allowedDecimalSeparators,m=f.decimalSeparator,h=e[d]===m;if(w1(e)&&(e===a||e===o)&&t.lastValue===``)return e;if(d-u===1&&p.indexOf(e[u])!==-1){var g=s===0?``:m;e=e.substring(0,u)+g+e.substring(u+1,e.length)}var _=function(e,t,n){var r=!1,i=!1;a.startsWith(`-`)?r=!1:e.startsWith(`--`)?(r=!1,i=!0):o.startsWith(`-`)&&e.length===o.length?r=!1:e[0]===`-`&&(r=!0);var s=+!!r;return i&&(s=2),s&&(e=e.substring(s),t-=s,n-=s),{value:e,start:t,end:n,hasNegation:r}},v=_(e,u,d),y=v.hasNegation;r=v,e=r.value,u=r.start,d=r.end;var b=_(t.lastValue,c.start,c.end),x=b.start,S=b.end,C=b.value,w=e.substring(u,d);e.length&&C.length&&(x>C.length-o.length||S<a.length)&&!(w&&o.startsWith(w))&&(e=C);var T=0;e.startsWith(a)?T+=a.length:u<a.length&&(T=u),e=e.substring(T),d-=T;var E=e.length,D=e.length-o.length;e.endsWith(o)?E=D:(d>D||d>e.length-o.length)&&(E=d),e=e.substring(0,E),e=t0(y?`-`+e:e,i),e=(e.match(n0(m,!0))||[]).join(``);var O=e.indexOf(m);e=e.replace(new RegExp(O1(m),`g`),function(e,t){return t===O?`.`:``});var k=M1(e,i),A=k.beforeDecimal,j=k.afterDecimal,M=k.addNegation;return l.end-l.start<c.end-c.start&&A===``&&h&&!parseFloat(j)&&(e=M?`-`:``),e}function a0(e,t){var n=t.prefix;n===void 0&&(n=``);var r=t.suffix;r===void 0&&(r=``);var i=Array.from({length:e.length+1}).map(function(){return!0}),a=e[0]===`-`;i.fill(!1,0,Math.min(n.length+ +!!a,e.length));var o=e.length;return i.fill(!1,o-r.length+1,o+1),i}function o0(e){var t=e0(e),n=t.thousandSeparator,r=t.decimalSeparator,i=e.prefix;i===void 0&&(i=``);var a=e.allowNegative;if(a===void 0&&(a=!0),n===r)throw Error(`
Decimal separator can't be same as thousand separator.
thousandSeparator: `+n+` (thousandSeparator = {true} is same as thousandSeparator = ",")
decimalSeparator: `+r+` (default value for decimalSeparator is .)
`);return i.startsWith(`-`)&&a&&(console.error(`
Prefix can't start with '-' when allowNegative is true.
prefix: `+i+`
allowNegative: `+a+`
`),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function s0(e){e=o0(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=S1);var a=e.onBlur;a===void 0&&(a=S1);var o=e.thousandSeparator,s=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l=``);var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,p=e.onValueChange,m=b1(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=e0(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return $1(t,e)},y=function(t,n){return i0(t,n,e)},b=T1(d)?u:d,x=f??r0(b,l,t);T1(d)?T1(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return D1(e)?e:(typeof e==`number`&&(e=I1(e)),x&&typeof s==`number`?L1(e,s,!!c):e)},C=Y1(S(d),S(u),!!x,v,y,p),w=C[0],T=w.numAsString,E=w.formattedValue,D=C[1];return Object.assign(Object.assign({},m),{value:E,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===g||w1(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],u=r[a],f=z1(n,t).to,p=function(e){return y(e).indexOf(`.`)+l.length};return d===0&&c&&s&&t[f.start]===g&&p(t)<i&&p(r)>a?!1:i>=f.start&&i<f.end&&_&&_.includes(o)&&u===g?!0:o===u},onValueChange:D,format:v,removeFormatting:y,getCaretBoundary:function(t){return a0(t,e)},onKeyDown:function(e){var t=e.target,r=e.key,a=t.selectionStart,u=t.selectionEnd,d=t.value;if(d===void 0&&(d=``),(r===`Backspace`||r===`Delete`)&&u<l.length&&d!==`-`){e.preventDefault();return}if(a!==u){i(e);return}r===`Backspace`&&d[0]===`-`&&a===l.length+1&&n&&R1(t,1),s&&c&&(r===`Backspace`&&d[a-1]===g?(R1(t,a-1),e.preventDefault()):r===`Delete`&&d[a]===g&&e.preventDefault()),_?.includes(r)&&d[a]===g&&R1(t,a+1);var f=o===!0?`,`:o;r===`Backspace`&&d[a-1]===f&&R1(t,a-1),r===`Delete`&&d[a]===f&&R1(t,a+1),i(e)},onBlur:function(t){var n=T;n.match(/\d/g)||(n=``),r||(n=N1(n)),c&&s&&(n=L1(n,s,c)),n!==T&&D({formattedValue:$1(n,e),value:n,floatValue:parseFloat(n)},{event:t,source:x1.event}),a(t)}})}function c0(e){var t=s0(e);return Z.createElement(Q1,Object.assign({},t))}var l0=(0,Z.forwardRef)(function({stepper:e,thousandSeparator:t,placeholder:n,defaultValue:r,min:i=-1/0,max:a=1/0,onValueChange:o,fixedDecimalScale:s=!1,decimalScale:c=0,suffix:l,prefix:u,value:d,hideControls:f=!1,onChange:p,...m},h){let[g,_]=(0,Z.useState)(d??r),v=(0,Z.useCallback)(()=>{_(t=>t===void 0?e??1:Math.min(t+(e??1),a))},[e,a]),y=(0,Z.useCallback)(()=>{_(t=>t===void 0?-(e??1):Math.max(t-(e??1),i))},[e,i]);return(0,Z.useEffect)(()=>{let e=e=>{document.activeElement===h?.current&&(e.key===`ArrowUp`?v():e.key===`ArrowDown`&&y())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[v,y,h]),(0,Z.useEffect)(()=>{d!==void 0&&_(d)},[d]),(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(c0,{value:g,onValueChange:e=>{let t=e.floatValue===void 0?void 0:e.floatValue;_(t),o&&o(t),p?.(t??void 0)},thousandSeparator:t,decimalScale:c,fixedDecimalScale:s,allowNegative:i<0,valueIsNumericString:!0,onBlur:()=>{g!==void 0&&(g<i?(_(i),h.current.value=String(i)):g>a&&(_(a),h.current.value=String(a)))},max:a,min:i,suffix:l,prefix:u,customInput:Sn,placeholder:n,className:`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none relative ${f?``:` rounded-r-none`}`,getInputRef:h,...m}),f?null:(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(q,{"aria-label":`Increase value`,className:`px-2 h-5 rounded-l-none rounded-br-none border-input border-l-0 border-b-[0.5px] focus-visible:relative`,variant:`outline`,onClick:v,disabled:g===a,children:(0,Q.jsx)(tn,{size:15})}),(0,Q.jsx)(q,{"aria-label":`Decrease value`,className:`px-2 h-5 rounded-l-none rounded-tr-none border-input border-l-0 border-t-[0.5px] focus-visible:relative`,variant:`outline`,onClick:y,disabled:g===i,children:(0,Q.jsx)(pn,{size:15})})]})]})});function u0({options:e,value:t,onChange:n,search:r,onSearchChange:i,placeholder:a,empty:o}){let[c,l]=(0,Z.useState)(!1),u=(0,Z.useMemo)(()=>Object.fromEntries(e.map(e=>[e.value,e.label.toLowerCase()])),[e]);return(0,Q.jsx)(`div`,{className:`space-y-2 w-[300px]`,children:(0,Q.jsxs)(VJ,{open:c,onOpenChange:l,children:[(0,Q.jsx)(HJ,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`outline`,role:`combobox`,"aria-expanded":c,className:`w-full justify-between bg-white px-3 font-normal outline-offset-0 hover:bg-white focus-visible:border-gray-950 focus-visible:outline-[3px] focus-visible:outline-ring/20 dark:bg-gray-950 dark:hover:bg-gray-950 dark:focus-visible:border-gray-300`,children:[(0,Q.jsx)(`span`,{className:s(`truncate`,!t&&`text-gray-500 dark:text-gray-400`),children:t?e.find(e=>e.value===t)?.label:`Select`}),(0,Q.jsx)(pn,{strokeWidth:2,className:`shrink-0 text-gray-500/80 dark:text-gray-400/80 size-4`,"aria-hidden":`true`})]})}),(0,Q.jsx)(UJ,{className:`w-full min-w-[var(--radix-popper-anchor-width)] border-gray-200 p-0 dark:border-gray-800`,align:`start`,children:(0,Q.jsxs)(Sq,{filter:(e,t)=>{let n=t.toLowerCase();return+!!u[e]?.includes(n)},children:[(0,Q.jsx)(Cq,{placeholder:a||`Search...`,onValueChange:i,value:r||``}),(0,Q.jsxs)(wq,{children:[(0,Q.jsx)(Tq,{children:o}),(0,Q.jsx)(Eq,{children:e.map(e=>(0,Q.jsxs)(Oq,{value:e.value,onSelect:e=>{n(e===t?null:e),l(!1)},children:[e.label,t===e.value&&(0,Q.jsx)(on,{strokeWidth:2,className:`ml-auto size-4`})]},e.value))})]})]})})]})})}var d0=({ownerId:e})=>{let[{data:t,fetching:n,error:r},i]=W({query:b,variables:{ownerId:e},pause:!e});r&&(console.error(`Error fetching sort codes: ${r}`),K.error(`Error`,{description:`Unable to fetch sort codes`}));let a=(0,Z.useMemo)(()=>t?.allSortCodesByBusiness?.sort((e,t)=>(e.name??``)>(t.name??``)?1:-1)??[],[t]);return{fetching:n,refresh:()=>i(),sortCodes:a,selectableSortCodes:(0,Z.useMemo)(()=>a.map(e=>({value:e.key.toString(),label:e.name??``})),[a])}};function f0({ownerId:e,value:t,onChange:n,disabled:r,placeholder:i=`Scroll to see all options`,formPart:a,error:o,triggerClassName:s,onFetchingChange:c}){let{sortCodes:l,fetching:u}=d0({ownerId:e});(0,Z.useEffect)(()=>{c?.(u)},[c,u]);let d=(0,Z.useMemo)(()=>{let e=l.map(e=>({value:e.key.toString(),label:e.name?`${e.key} - ${e.name}`:e.key.toString()}));if(t!=null){let n=t.toString();e.some(e=>e.value===n)||e.push({value:n,label:n})}return e},[l,t]);return(0,Q.jsx)(WJ,{data:d,value:t?.toString()??null,onChange:e=>{if(!e){n(null,null);return}let t=Number(e);n(t,l.find(e=>Number(e.key)===t)??null)},disabled:r||u,placeholder:i,formPart:a,error:o,triggerProps:s?{className:s}:void 0})}var p0=(0,Z.forwardRef)(({label:e,description:t,...n},r)=>(0,Q.jsx)(`div`,{ref:r,...n,children:(0,Q.jsx)(ST,{noWrap:!0,children:(0,Q.jsxs)(`div`,{children:[t&&(0,Q.jsx)(_i,{size:`xs`,opacity:.65,children:t}),(0,Q.jsx)(_i,{size:`sm`,children:e})]})})}));p0.displayName=`SelectTagItem`;var m0=`updateBusinessTripAccountantApproval`,h0=()=>{let[{fetching:e},t]=H(ie);return{fetching:e,updateBusinessTripAccountantApproval:(0,Z.useCallback)(async e=>{let n=`Error toggling accountant approval for trip [${e.businessTripId}]`,r=`${m0}-${e.businessTripId}`;K.loading(`Updating accountant approval status`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a)return K.success(`Success`,{id:r,description:`Accountant approval status updated`}),a.updateBusinessTripAccountantApproval}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},g0=`updateChargeAccountantApproval`,_0=()=>{let[{fetching:e},t]=H(qe);return{fetching:e,updateChargeAccountantApproval:(0,Z.useCallback)(async e=>{let n=`Error toggling accountant approval to ledger record ID [${e.chargeId}]`,r=`${g0}-${e.chargeId}`;K.loading(`Updating approval status`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateChargeAccountantApproval`);if(a)return K.success(`Success`,{id:r,description:`Accountant approval was updated`}),a.updateChargeAccountantApproval}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},v0={[Ue.Approved]:{icon:on,color:`text-green-600`,bgColor:`hover:bg-green-50`,label:`Approved`,value:Ue.Approved},[Ue.Pending]:{icon:Wi,color:`text-yellow-600`,bgColor:`hover:bg-yellow-50`,label:`Pending`,value:Ue.Pending},[Ue.Unapproved]:{icon:dn,color:`text-red-600`,bgColor:`hover:bg-red-50`,label:`Unapproved`,value:Ue.Unapproved}},y0=e=>v0[e];function b0(e){let{onChange:t,onStatusChange:n,value:r}=e,[i,a]=(0,Z.useState)(r??Ue.Unapproved),{updateChargeAccountantApproval:o}=_0(),{updateBusinessTripAccountantApproval:s}=h0(),c=y0(i),l=c.icon,u=(0,Z.useCallback)(async r=>{let c=i;a(r);let l=null;e.chargeId?l=await o({chargeId:e.chargeId,status:r}):e.businessTripId&&(l=await s({businessTripId:e.businessTripId,status:r})),l?n?.(r):a(c),t?.()},[e.chargeId,o,e.businessTripId,s,i,t,n]);(0,Z.useEffect)(()=>{r&&a(r)},[r]);let d=!e.chargeId&&!e.businessTripId;return(0,Q.jsxs)(Vn,{children:[(0,Q.jsx)(zn,{asChild:!0,disabled:d,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 ${c.bgColor}`,title:c.label,disabled:d,children:(0,Q.jsx)(l,{className:`h-3.5 w-3.5 ${c.color}`})})}),(0,Q.jsxs)(In,{align:`center`,children:[(0,Q.jsxs)(Ln,{onClick:()=>u(Ue.Approved),children:[(0,Q.jsx)(on,{className:`h-4 w-4 mr-2 text-green-600`}),`Approved`]}),(0,Q.jsxs)(Ln,{onClick:()=>u(Ue.Pending),children:[(0,Q.jsx)(Wi,{className:`h-4 w-4 mr-2 text-yellow-600`}),`Pending`]}),(0,Q.jsxs)(Ln,{onClick:()=>u(Ue.Unapproved),children:[(0,Q.jsx)(dn,{className:`h-4 w-4 mr-2 text-red-600`}),`Unapproved`]})]})]})}var x0=({items:e,extraClassName:t=``})=>{let n=[`text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg`,t].join(` `);return(0,Q.jsx)(`ul`,{className:n,children:e.map((t,n)=>{let r=[`w-full px-4 py-2`,n===e.length-1?`rounded-b-lg`:`border-b`,n===0?`rounded-t-lg`:``,`border-gray-200`,t&&typeof t==`object`&&`extraClassName`in t?t.extraClassName??``:``].join(` `);return(0,Q.jsx)(`li`,{className:r,children:t&&typeof t==`object`&&`content`in t?t.content:t},n)})})};function S0({columns:e=5,rows:t=5,headerHeight:n=`h-10`,rowHeight:r=`h-8`,showHeader:i=!0,columnWidths:a,...o}){let s=a||Array(e).fill(`flex-1`);return(0,Q.jsxs)(`div`,{className:`space-y-2`,...o,children:[i&&(0,Q.jsx)(`div`,{className:`flex gap-2 border-b pb-2`,children:s.map((e,t)=>(0,Q.jsx)(Zs,{className:`${n} ${e}`},t))}),[...Array(t)].map((e,t)=>(0,Q.jsx)(`div`,{className:`flex gap-2 border-b py-2`,children:s.map((e,t)=>(0,Q.jsx)(Zs,{className:`${r} ${e}`},t))},t))]})}var C0=`mergeCharges`,w0=()=>{let[{fetching:e},t]=H($e);return{fetching:e,mergeCharges:(0,Z.useCallback)(async e=>{let n=`Error merging into charge ID [${e.baseChargeID}]`,r=`${C0}-${e.baseChargeID}`;K.loading(`Merging Charges`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`mergeCharges`);if(a)return K.success(`Success`,{id:r,description:`Charges were merged`}),a.mergeCharges.charge}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function T0({chargeIds:e,onDone:t,resetMergeList:n}){let{mergeCharges:r,fetching:i}=w0(),a=Array.from(new Set(e)),[{data:o,fetching:s}]=W({query:ot,variables:{chargeIds:a}}),[c,l]=(0,Z.useState)(o?.chargesByIDs[0]),[u,d]=(0,Z.useState)(void 0),[f,p]=(0,Z.useState)(void 0),[m,h]=(0,Z.useState)(void 0),[g,_]=(0,Z.useState)(void 0),[v,y]=(0,Z.useState)(void 0),[b,x]=(0,Z.useState)(void 0),[S,C]=(0,Z.useState)(void 0),w=o?.chargesByIDs.length!==a.length&&`Some charges were not Found`||void 0,T=o?.chargesByIDs||[],E=(0,Z.useCallback)(async()=>{if(!c){K.error(`Error`,{description:`No main charge selected`});return}if(a.length<2){K.error(`Error`,{description:`At least 2 charges are required to execute a merge`});return}let e;return u&&u.value!==c.userDescription&&(e??={},e={...e,userDescription:u.value}),g&&g.value!==c.__typename&&(e??={},e={...e,type:Xl(g.value)}),v&&v.value!==c.decreasedVAT&&(e??={},e={...e,isDecreasedVAT:v.value}),f&&f.value!==c.optionalVAT&&(e??={},e={...e,optionalVAT:f.value}),m&&m.value!==c.optionalDocuments&&(e??={},e={...e,optionalDocuments:m.value}),S&&S.value!==c.tags.map(e=>e.name).join(`,`)&&(e??={},e={...e,tags:S.value.split(`,`).filter(e=>e!==``).map(e=>({id:e}))}),b&&b.value!==c.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await r({baseChargeID:c.id,chargeIdsToMerge:a.filter(e=>e!==c.id),fields:e}),n(),t()},[c,a,r,u,m,g,v,f,b,S,t,n]);return(0,Q.jsxs)(Q.Fragment,{children:[s&&(0,Q.jsx)(`div`,{className:`flex flex-col text-center w-full mb-1`,children:(0,Q.jsx)(Ci,{})}),!s&&w&&(0,Q.jsx)(`div`,{className:`flex flex-col text-center w-full mb-1`,children:(0,Q.jsx)(`h3`,{className:`sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900`,children:w})}),!s&&!w&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`table`,{children:[(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Main`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl`,children:(0,Q.jsx)(Sx,{checked:e.id===c?.id,size:`xl`,onClick:()=>{l(e),d({id:e.id,value:e.userDescription??``}),p({id:e.id,value:e.optionalVAT??!1}),h({id:e.id,value:e.optionalDocuments??!1}),x({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),_({id:e.id,value:e.__typename}),y({id:e.id,value:e.decreasedVAT??!1}),C({id:e.id,value:(e.tags.map(e=>e.name)??[]).join(`,`)})}})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Description`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:!e.userDescription||u?.value===e.userDescription,onClick:()=>d({id:e.id,value:e.userDescription??``}),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:u?.id===e.id?{background:`#228be633`}:{},children:e.userDescription})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Type`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:e.__typename==null||e.__typename===g?.value,onClick:()=>{_({id:e.id,value:e.__typename})},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:g?.id===e.id?{background:`#228be633`}:{},children:(0,Q.jsx)(SK,{content:ql(e.__typename),children:Yl(e.__typename)})})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Is Decreased VAT`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:e.decreasedVAT==null||e.decreasedVAT===v?.value,onClick:()=>{y({id:e.id,value:e.decreasedVAT??!1})},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:v?.id===e.id?{background:`#228be633`}:{},children:e.decreasedVAT?(0,Q.jsx)(Ca,{size:20,color:`green`}):(0,Q.jsx)(Ta,{size:20,color:`red`})})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Optional VAT`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:e.optionalVAT==null||e.optionalVAT===f?.value,onClick:()=>{p({id:e.id,value:e.optionalVAT??!1})},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:f?.id===e.id?{background:`#228be633`}:{},children:e.optionalVAT?(0,Q.jsx)(Ca,{size:20,color:`green`}):(0,Q.jsx)(Ta,{size:20,color:`red`})})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Optional Documents`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:e.optionalDocuments==null||e.optionalDocuments===m?.value,onClick:()=>{h({id:e.id,value:e.optionalDocuments??!1})},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:m?.id===e.id?{background:`#228be633`}:{},children:e.optionalDocuments?(0,Q.jsx)(Ca,{size:20,color:`green`}):(0,Q.jsx)(Ta,{size:20,color:`red`})})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Invoice-Payment Currency Difference`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{x({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:b?.id===e.id?{background:`#228be633`}:{},children:e.isInvoicePaymentDifferentCurrency?(0,Q.jsx)(Ca,{size:20,color:`green`}):(0,Q.jsx)(Ta,{size:20,color:`red`})})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Tags`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`button`,{className:`w-full px-2`,disabled:e.tags==null||e.tags.map(e=>e.name).join(`,`)===S?.value,onClick:()=>{C({id:e.id,value:(e.tags.map(e=>e.name)??[]).join(`,`)})},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center px-2 py-2 border-x-2`,style:S?.id===e.id?{background:`#228be633`}:{},children:(0,Q.jsx)(x0,{items:e.tags.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,Q.jsx)(`div`,{children:e.name}),e.namePath&&(0,Q.jsx)(`div`,{children:e.namePath.join(` > `)})]},e.id))})})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Transactions`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center mx-2 px-2 py-2 border-x-2`,children:e.metadata?.transactionsCount??0})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Invoices`}),T.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl`,children:e.metadata?.invoicesCount??0})},e.id))]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-center gap-5 mt-5`,children:[(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg`,disabled:s||i,onClick:E,children:`Accept`}),(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg`,onClick:t,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg`,onClick:()=>{n(),t()},children:`Reset Merge`})]})]})]})}function E0(e){let[t,n]=(0,Z.useState)(!1),{selected:r,resetMergeList:i}=e,a=new Set(r.map(({id:e})=>e)),o=a.size>1,s=o?`default`:`outline`,c=(0,Z.useCallback)(()=>{n(!1),r.map(({onChange:e})=>e())},[r]),l=(0,Z.useMemo)(()=>o?`Merge ${a.size} selected charges`:`Select at least two different charges to merge`,[o,a.size]);return(0,Q.jsxs)(Xt,{open:t,onOpenChange:n,children:[(0,Q.jsx)(fn,{disabled:!o,children:(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{children:(0,Q.jsx)(q,{disabled:!o,variant:s,className:`size-7.5`,children:(0,Q.jsx)(da,{className:`size-5`})})}),(0,Q.jsx)(yr,{children:(0,Q.jsx)(`p`,{children:l})})]})}),(0,Q.jsxs)(un,{className:`w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto`,children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Merge Charges`})}),(0,Q.jsx)(T0,{chargeIds:Array.from(a),onDone:c,resetMergeList:i})]})]})}var D0=`mergeBusinesses`,O0=()=>{let[{fetching:e},t]=H(xe);return{fetching:e,mergeBusinesses:(0,Z.useCallback)(async e=>{let n=`Error merging into business ID [${e.targetBusinessId}]`,r=`${D0}-${e.targetBusinessId}`;K.loading(`Merging Businesses`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a)return K.success(`Success`,{id:r,description:`Businesses merged`}),a.mergeBusinesses.id}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function k0({businessIds:e,onDone:t,resetMerge:n}){let{mergeBusinesses:r,fetching:i}=O0(),a=Array.from(new Set(e)),[{data:o,fetching:s}]=W({query:ue,variables:{businessIds:a}}),[c,l]=(0,Z.useState)(o?.businesses[0]),u=o?.businesses.length!==a.length&&`Some businesses were not Found`||void 0,d=o?.businesses||[],f=(0,Z.useCallback)(async()=>{if(!c){K.error(`Error`,{description:`No main business selected`});return}if(a.length<2){K.error(`Error`,{description:`At least 2 businesses are required to execute a merge`});return}return await r({targetBusinessId:c.id,businessIdsToMerge:a.filter(e=>e!==c.id)}),n(),t()},[c,a,r,t,n]);return(0,Q.jsxs)(Q.Fragment,{children:[s&&(0,Q.jsx)(`div`,{className:`flex flex-col text-center w-full mb-1`,children:(0,Q.jsx)(Ci,{})}),!s&&u&&(0,Q.jsx)(`div`,{className:`flex flex-col text-center w-full mb-1`,children:(0,Q.jsx)(`h3`,{className:`sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900`,children:u})}),!s&&!u&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`table`,{children:[(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Main`}),d.map(e=>(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl`,children:(0,Q.jsx)(Sx,{checked:e.id===c?.id,size:`xl`,onClick:()=>{l(e)}})})},e.id))]}),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Name`}),d.map(e=>(0,Q.jsx)(`td`,{children:e.name},e.id))]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-center gap-5 mt-5`,children:[(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg`,disabled:s||i,onClick:f,children:`Accept`}),(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg`,onClick:t,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,className:` text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg`,onClick:()=>{n(),t()},children:`Reset Merge`})]})]})]})}function A0(e){let[t,n]=(0,Z.useState)(!1),r=(0,Z.useCallback)(()=>n(!1),[]),{selected:i,resetMerge:a}=e,o=new Set(i.map(({id:e})=>e)),c=o.size>=1,l=c?`default`:`outline`,u=(0,Z.useCallback)(()=>{r(),i.map(({onChange:e})=>e())},[i,r]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{onClick:()=>{c&&n(!0)},disabled:!c,variant:l,className:s(`size-7.5`,c?` bg-blue-500 hover:bg-blue-500/90`:``),size:`icon`,children:(0,Q.jsx)(da,{className:`size-5`})}),(0,Q.jsx)(TD,{opened:t,onClose:r,size:`auto`,centered:!0,children:(0,Q.jsx)(k0,{businessIds:Array.from(o),onDone:u,resetMerge:a})})]})}function j0({labels:e={cancel:`Cancel`,confirm:`Confirm`},title:t,onConfirm:n,onClose:r,children:i,open:a,setOpen:o}){let[s,c]=(0,Z.useState)(!1),l=o??c;return(0,Q.jsxs)(Xt,{open:a??s,onOpenChange:l,children:[i&&(0,Q.jsx)(fn,{asChild:!0,onClick:e=>{e.stopPropagation(),l(e=>!e)},children:i}),(0,Q.jsxs)(un,{className:`sm:max-w-[425px]`,children:[(0,Q.jsx)(en,{children:t&&(0,Q.jsx)(_n,{children:t})}),(0,Q.jsxs)(Zt,{children:[(0,Q.jsx)(q,{onClick:()=>{l(!1),r?.()},variant:`secondary`,children:e.cancel}),(0,Q.jsx)(q,{onClick:()=>{l(!1),n()},variant:`default`,children:e.confirm})]})]})]})}var M0=({children:e,position:t,title:n,withOverlay:r=!1,withCloseButton:i=!0,opened:a=!1,onClose:o=()=>{}})=>{let[s,c]=(0,Z.useState)(null);return(0,Q.jsx)(PJ,{direction:t,open:a,onClose:o,modal:!1,children:(0,Q.jsx)(RJ,{asChild:!0,withOverlay:r,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(zJ,{className:`flex flex-row justify-start`,children:[(0,Q.jsx)(BJ,{}),(0,Q.jsxs)(`div`,{className:`flex flex-row justify-between w-full`,children:[n,i&&(0,Q.jsx)(q,{size:`icon`,className:`size-6`,variant:`ghost`,onClick:o,children:(0,Q.jsx)(dn,{className:`size-4 text-gray-500`})})]})]}),(0,Q.jsx)(`div`,{className:`mx-auto w-full px-4 pb-4`,ref:c,children:(0,Q.jsx)(Pk.Provider,{value:s,children:e})})]})})})},N0=({chargeId:e,close:t,onChange:n})=>{let[{data:r,fetching:i}]=W({query:ke,variables:{chargeId:e},pause:!e}),a=r?.charge;return e?(0,Q.jsx)(M0,{modalSize:`fit-content`,position:`bottom`,title:(0,Q.jsxs)(`div`,{className:`flex flex-row mx-3 pt-3 sm:text-1xl gap-10`,children:[(0,Q.jsx)(`h1`,{className:`sm:text-2xl font-small text-gray-900`,children:`Edit Charge:`}),(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[`ID: `,e,(0,Q.jsx)($k,{isLink:!0,content:`${window.location.origin}${yt.CHARGES.DETAIL(e)}`})]})]}),opened:!!e,onClose:t,children:i||!a?(0,Q.jsx)(ti,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}):(0,Q.jsx)(Wz,{charge:a,close:t,onChange:n??(()=>{})})}):null},P0=({onDone:e,onChange:t,documentId:n})=>n?(0,Q.jsx)(M0,{modalSize:`fit-content`,position:`bottom`,opened:!!n,onClose:e,title:(0,Q.jsxs)(`div`,{className:`flex flex-row mx-3 pt-3 sm:text-1xl gap-5`,children:[(0,Q.jsx)(`h1`,{className:`sm:text-2xl font-small text-gray-900`,children:`Edit Document`}),(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[`ID: `,n,(0,Q.jsx)(SK,{content:`Copy ID`,children:(0,Q.jsx)($k,{content:n})}),(0,Q.jsx)(Mz,{documentId:n,onChange:t}),(0,Q.jsx)(iA,{documentId:n,onChange:t})]})]}),children:(0,Q.jsx)(wG,{documentId:n,onDone:e,onChange:t})}):null,F0=({onDone:e,data:t})=>{let[n,r]=(0,Z.useState)(!1);function i(){r(!1),e?.()}return(0,Q.jsxs)(Xt,{open:n,onOpenChange:r,children:[(0,Q.jsx)(SK,{content:`Edit Misc Expense`,children:(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,children:(0,Q.jsx)(wa,{className:`size-5`})})})}),(0,Q.jsx)(un,{className:`sm:max-w-[425px]`,children:(0,Q.jsx)(DG,{onDone:i,data:t})})]})},I0=`updateSalaryRecord`,L0=()=>{let[{fetching:e},t]=H(Re);return{fetching:e,updateSalaryRecord:(0,Z.useCallback)(async e=>{let n=`Error updating salary record [${e.salaryRecord.month}] employee [${e.salaryRecord.employeeId}]`,r=I0;K.loading(`Updating Salary Record`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateSalaryRecord`);if(a)return K.success(`Success`,{id:r,description:`Salary record was updated`}),a.updateSalaryRecord.salaryRecord}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},R0=({recordVariables:e,onDone:t})=>e?(0,Q.jsx)(z0,{recordVariables:e,onDone:t}):null,z0=({recordVariables:e,onDone:t})=>{let{updateSalaryRecord:n,fetching:r}=L0(),[{data:i,fetching:a}]=W({query:ve,variables:{employeeIDs:[e.employeeId],month:Or(new Date(e.month),`yyyy-MM-dd`)}}),o=i?.salaryRecordsByDates?.[0],s=(0,Z.useCallback)(e=>{t(),e&&n({salaryRecord:e})},[t,n]);if(!o?.employer?.id||!o?.employee?.id)return(0,Q.jsx)(Q.Fragment,{});let c={addedVacationDays:o?.vacationDays?.added,baseSalary:o?.baseAmount?.raw,bonus:o?.bonus?.raw,chargeId:o?.charge?.id,compensationsEmployerAmount:o?.compensationsAmount?.raw,compensationsEmployerPercentage:o?.compensationsPercentage,directPaymentAmount:o?.directAmount?.raw,employer:o.employer.id,employeeId:o.employee.id,gift:o?.gift?.raw,globalAdditionalHours:o?.globalAdditionalHoursAmount?.raw,healthPaymentAmount:o?.healthInsuranceAmount?.raw,month:o?.month,pensionEmployeeAmount:o?.pensionEmployeeAmount?.raw,pensionEmployeePercentage:o?.pensionEmployeePercentage,pensionEmployerAmount:o?.pensionEmployerAmount?.raw,pensionEmployerPercentage:o?.pensionEmployerPercentage,pensionFundId:o?.pensionFund?.id,recovery:o?.recovery?.raw,sicknessDaysBalance:o?.sicknessDays?.balance,socialSecurityAmountEmployee:o?.socialSecurityEmployeeAmount?.raw,socialSecurityAmountEmployer:o?.socialSecurityEmployerAmount?.raw,taxAmount:o?.incomeTaxAmount?.raw,trainingFundEmployeeAmount:o?.trainingFundEmployeeAmount?.raw,trainingFundEmployeePercentage:o?.trainingFundEmployeePercentage,trainingFundEmployerAmount:o?.trainingFundEmployerAmount?.raw,trainingFundEmployerPercentage:o?.trainingFundEmployerPercentage,trainingFundId:o?.trainingFund?.id,travelAndSubsistence:o?.travelAndSubsistence?.raw,vacationDaysBalance:o?.vacationDays?.balance,vacationTakeout:o?.vacationTakeout?.raw,workDays:o?.workDays,zkufot:o?.notionalExpense?.raw};return(0,Q.jsx)(M0,{modalSize:`fit-content`,position:`bottom`,title:(0,Q.jsxs)(`div`,{className:`flex flex-row mx-3 pt-3 sm:text-1xl gap-10`,children:[(0,Q.jsx)(`h1`,{className:`sm:text-2xl font-small text-gray-900`,children:`Edit Salary Record:`}),(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[`month: `,e.month,` employeeId: `,e.employeeId]})]}),opened:!!e,onClose:t,children:a||!o?(0,Q.jsx)(ti,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}):(0,Q.jsx)(mK,{isNewInsert:!1,defaultValues:c,onDone:s,isModifying:r})})},B0=`updateSortCode`,V0=()=>{let[{fetching:e},t]=H(je);return{fetching:e,updateSortCode:(0,Z.useCallback)(async e=>{let n=`Error updating sort code ID [${e.key}]`,r=`${B0}-${e.key}`;K.loading(`Updating Sort Code...`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`updateSortCode`);if(a)return K.success(`Success`,{id:r,description:`SortCode updated`}),a.updateSortCode}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return!1},[t])}};function H0({sortCodeKey:e,ownerId:t,onAdd:n}){let[r,i]=(0,Z.useState)(!1);return(0,Q.jsxs)(Xt,{open:r,onOpenChange:i,children:[(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsx)(q,{variant:`outline`,size:`icon`,children:(0,Q.jsx)(wa,{})})}),(0,Q.jsxs)(un,{className:`w-[400px] max-w-screen-md`,children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Edit Sort Code`})}),(0,Q.jsx)(U0,{sortCodeKey:e,ownerId:t,close:()=>i(!1),onAdd:n})]})]})}function U0({sortCodeKey:e,ownerId:t,close:n,onAdd:r}){let[{data:i,fetching:a}]=W({query:it,variables:{key:e,ownerId:t}}),o=i?.sortCode;return!o&&!a&&K.error(`Error`,{description:`Couldn't find sort code`}),a?(0,Q.jsx)(Qt,{className:`h-10 w-10 animate-spin`}):o?(0,Q.jsx)(W0,{sortCode:o,close:n,onAdd:r}):(0,Q.jsx)(`div`,{children:`Sort code not found`})}function W0({sortCode:e,close:t,onAdd:n}){let r=Mr({defaultValues:e}),{handleSubmit:i,formState:{dirtyFields:a}}=r,{updateSortCode:o,fetching:s}=V0(),c=({key:r,...i})=>{let s=gt(i,a);if(s&&Object.keys(s).length>0){let r;if(s.defaultIrsCode){let e=s.defaultIrsCode,t=Number(e);if(!Number.isInteger(t)||t<2||t>9999)throw Error(`Invalid IRS code: ${e}`);r=t}o({fields:{...s,defaultIrsCode:r},key:e.key}).then(r=>{r&&(n?.(e.key),t())})}};return(0,Q.jsx)(kr,{...r,children:(0,Q.jsxs)(`form`,{onSubmit:i(c),children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-4 my-4`,children:(0,Q.jsx)(hK,{isInsert:!1,formManager:r})}),(0,Q.jsx)(`div`,{className:`flex justify-end mt-4`,children:(0,Q.jsx)(q,{type:`submit`,disabled:s,children:`Update`})})]})})}var G0=({close:e,transactionID:t,onChange:n})=>t?(0,Q.jsx)(M0,{modalSize:`fit-content`,position:`bottom`,title:(0,Q.jsxs)(`div`,{className:`flex flex-row mx-3 pt-3 sm:text-1xl gap-10`,children:[(0,Q.jsx)(`h1`,{className:`sm:text-2xl font-small text-gray-900`,children:`Edit Transaction:`}),(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[`ID: `,t,(0,Q.jsx)($k,{content:t}),(0,Q.jsx)(Fz,{transactionId:t})]})]}),opened:!!t,onClose:e,children:(0,Q.jsx)(OG,{transactionID:t,onDone:e,onChange:n})}):null,K0={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function q0(e){Cr({customError:e})}function J0(){return Cr().customError}var Y0;Y0||={};var X0=`insertClient`,Z0=()=>{let[{fetching:e},t]=H(p);return{fetching:e,insertClient:(0,Z.useCallback)(async e=>{let n=`Error creating client [${e.fields.businessId}]`,r=`${X0}-${e.fields.businessId}`;K.loading(`Creating Client...`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`insertClient`);if(a)return K.success(`Success`,{id:r,description:`Client [${e.fields.businessId}] was created`}),a.insertClient}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},Q0=_r({businessId:Jr().optional(),emails:wr(Xr()).optional(),generatedDocumentType:ii(Object.values(Ve))});function $0({businessId:e,onDone:t,showTrigger:n=!0}){let[r,i]=(0,Z.useState)(!1),{insertClient:a}=Z0(),[o,s]=(0,Z.useState)(``),c={businessId:e,generatedDocumentType:Ve.Proforma,emails:[]};(0,Z.useEffect)(()=>{!n&&e&&i(!0)},[e,n]);let l=Mr({resolver:Qr(Q0),defaultValues:c}),u=()=>{l.reset(c),i(!0)},d=()=>{if(o.trim()){let e=l.getValues(`emails`);l.setValue(`emails`,[...e??[],o.trim()],{shouldDirty:!0}),s(``)}},f=e=>{let t=l.getValues(`emails`);l.setValue(`emails`,(t??[]).filter((t,n)=>n!==e),{shouldDirty:!0})},p=(0,Z.useCallback)(async n=>{a({fields:{...n,businessId:e}}),i(!1),t?.()},[t,e,a]);return(0,Q.jsxs)(Xt,{open:r,onOpenChange:e=>{i(e),e||t?.()},children:[n&&(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsxs)(q,{size:`sm`,onClick:u,children:[(0,Q.jsx)(Dn,{className:`h-4 w-4 mr-2`}),`New Client`]})}),(0,Q.jsxs)(un,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,Q.jsxs)(en,{children:[(0,Q.jsx)(_n,{children:`Create New Client`}),(0,Q.jsx)(En,{children:`Add a new client with all required details`})]}),(0,Q.jsx)(kr,{...l,children:(0,Q.jsxs)(`form`,{onSubmit:l.handleSubmit(p),children:[(0,Q.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(Ar,{control:l.control,name:`emails`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Emails`}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(Sn,{placeholder:`Add email...`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),(0,Q.jsx)(q,{type:`button`,size:`sm`,onClick:d,children:(0,Q.jsx)(Dn,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.value?.map((e,t)=>(0,Q.jsxs)(ar,{variant:`secondary`,className:`gap-1`,children:[e,(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`p-0 size-3`,onClick:()=>f(t),children:(0,Q.jsx)(dn,{className:`size-3 cursor-pointer`})})]},t))}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:l.control,name:`generatedDocumentType`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Default Document Type`}),(0,Q.jsxs)(wn,{onValueChange:e.onChange,defaultValue:e.value,children:[(0,Q.jsx)(dr,{children:(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{})})}),(0,Q.jsx)(mn,{children:Object.values(Ve).map(e=>(0,Q.jsx)(bn,{value:e,children:au(e)},e))})]}),(0,Q.jsx)(mi,{})]})})]})}),(0,Q.jsxs)(Zt,{children:[(0,Q.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>{i(!1),t?.()},children:`Cancel`}),(0,Q.jsx)(q,{type:`submit`,children:`Create Client`})]})]})})]})]})}var e2=`insertNewBusiness`,t2=()=>{let[{fetching:e},t]=H(A);return{fetching:e,insertBusiness:(0,Z.useCallback)(async e=>{let n=`Error creating business [${e.fields.name}]`,r=`${e2}-${e.fields.name}`;K.loading(`Creating Business...`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`insertNewBusiness`);if(a)return K.success(`Success`,{id:r,description:`Business [${e.fields.name}] was created`}),a.insertNewBusiness}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},n2=_r({businessName:Pr().min(1,`Business name is required`),locality:Pr().min(1,`Locality is required`),localName:Pr().optional(),govId:Pr().optional(),address:Pr().optional(),city:Pr().optional(),zipCode:Pr().optional(),generalContacts:wr(Xr()),website:Ti().optional().or(or(``)),phone:Pr().optional(),taxCategory:Pr().optional(),sortCode:Pr().optional(),pcn874RecordType:Pr().optional(),irsCode:qr().optional(),defaultDescription:Pr().optional(),defaultTags:wr(Pr()),isClient:fr().default(!1).optional(),transactionPhrases:wr(Pr()),emailAddresses:wr(Xr())}).refine(e=>e.locality!==`Israel`||!!e.localName&&!!e.govId,{message:`Local name and company number are required for Israeli businesses`,path:[`localName`]});function r2(e){let t=e.defaultDescription||e.defaultTags?.length||e.transactionPhrases?.length||e.emailAddresses?.length?{description:e.defaultDescription,tags:e.defaultTags?.map(e=>({id:e})),phrases:e.transactionPhrases,emails:e.emailAddresses}:void 0;return{name:e.businessName,country:e.locality,hebrewName:e.localName,governmentId:e.govId,address:e.address,city:e.city,zipCode:e.zipCode,phoneNumber:e.phone,website:e.website,email:e.generalContacts.join(`, `)||void 0,sortCode:e.sortCode?parseInt(e.sortCode):void 0,taxCategory:e.taxCategory,pcn874RecordType:e.pcn874RecordType,irsCode:e.irsCode,suggestions:t}}function i2({description:e,onAdd:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null),{insertBusiness:o,fetching:s}=t2(),c=Mr({resolver:Qr(n2),defaultValues:{businessName:e,generalContacts:[],defaultTags:[],transactionPhrases:e?[e]:[],emailAddresses:[],locality:`GAB`}}),l=async e=>{let t=await o({fields:r2(e)});e.isClient&&t?.id?a({businessId:t.id,generatedDocumentType:Ve.Proforma,emails:[]}):u(t?.id)},u=(e=``)=>{a(null),r(!1),c.reset(),t?.(e)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Xt,{open:n,onOpenChange:r,children:[(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsxs)(q,{children:[(0,Q.jsx)(Dn,{className:`size-4 mr-2`}),`New Business`]})}),(0,Q.jsxs)(un,{className:`max-w-3xl max-h-[90vh] overflow-y-auto`,children:[(0,Q.jsxs)(en,{children:[(0,Q.jsx)(_n,{children:`Create New Business`}),(0,Q.jsx)(En,{children:`Add a new business to Accounter.`})]}),(0,Q.jsx)(kr,{...c,children:(0,Q.jsxs)(`form`,{onSubmit:c.handleSubmit(l),className:`space-y-6`,children:[(0,Q.jsx)(a2,{form:c}),(0,Q.jsx)(o2,{form:c}),(0,Q.jsx)(s2,{form:c}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4 border-t`,children:[(0,Q.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(q,{type:`submit`,disabled:s,children:`Create Business`})]})]})})]})]}),i?.businessId&&(0,Q.jsx)($0,{businessId:i.businessId,showTrigger:!1,onDone:()=>{u(i.businessId)}})]})}function a2({form:e}){let[t,n]=(0,Z.useState)(``),{userContext:r}=(0,Z.useContext)(nr),{countries:i,fetching:a}=jG(),{watch:o,setValue:s,control:c}=e,l=o(`locality`),u=e=>{t.trim()&&(s(`generalContacts`,[...e,t.trim()],{shouldDirty:!0}),n(``))},d=(e,t)=>{s(`generalContacts`,e.filter((e,n)=>n!==t),{shouldDirty:!0})},f=l===r?.context.locality;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Contact Information`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Q.jsx)(Ar,{control:c,name:`businessName`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Business Name *`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,required:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`locality`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Locality / Country *`}),(0,Q.jsx)(WJ,{onChange:e.onChange,data:i.map(e=>({value:e.code,label:e.name})),value:e.value,disabled:a,placeholder:`Scroll to see all options`,formPart:!0}),(0,Q.jsx)(mi,{})]})}),f&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{control:c,name:`localName`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Local Name *`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,placeholder:`Business name in local language`})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`govId`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Government ID *`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,placeholder:`Enter Government ID`})}),(0,Q.jsx)(mi,{})]})})]}),(0,Q.jsx)(Ar,{control:c,name:`address`,render:({field:e})=>(0,Q.jsxs)(lr,{className:`md:col-span-2`,children:[(0,Q.jsxs)(hr,{children:[(0,Q.jsx)(la,{className:`size-4`}),`Address`]}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Wn,{...e,rows:2,placeholder:`Enter business address`})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`city`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`City`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,placeholder:`Enter business city`})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`zipCode`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Zip Code`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,placeholder:`Enter business zip code`})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`generalContacts`,render:({field:e})=>(0,Q.jsxs)(lr,{className:`md:col-span-2`,children:[(0,Q.jsxs)(hr,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ca,{className:`size-4`}),`General Contacts`]}),(0,Q.jsx)(dr,{children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.value?.map((t,n)=>(0,Q.jsxs)(ar,{variant:`secondary`,className:`gap-1 pr-1`,children:[t,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>d(e.value??[],n),className:`ml-1 hover:bg-muted rounded-sm p-0.5`,children:(0,Q.jsx)(dn,{className:`size-3`})})]},n)),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(Sn,{value:t,onChange:e=>n(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),u(e.value??[]))},placeholder:`Add contact email`,type:`email`}),(0,Q.jsx)(q,{type:`button`,variant:`outline`,size:`icon`,disabled:!t.trim(),onClick:()=>u(e.value??[]),children:(0,Q.jsx)(Dn,{className:`size-4`})})]})]})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`website`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsxs)(hr,{children:[(0,Q.jsx)(ra,{className:`size-4`}),`Website`]}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,type:`url`,placeholder:`https://example.com`})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:c,name:`phone`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsxs)(hr,{children:[(0,Q.jsx)(ma,{className:`size-4`}),`Phone`]}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,type:`tel`})}),(0,Q.jsx)(mi,{})]})})]})]})}function o2({form:e}){let{userContext:t}=(0,Z.useContext)(nr),{selectableSortCodes:n,fetching:r,sortCodes:i}=d0({ownerId:t?.context.adminBusinessId}),{selectableTaxCategories:a,fetching:o}=zz(),{selectableTags:s,fetching:c}=Rz(),{setValue:l,control:u}=e,d=(0,Z.useCallback)(e=>{if(e){let t=i.find(t=>Number(t.key)===Number(e));t&&(t.defaultIrsCode?l(`irsCode`,t.defaultIrsCode,{shouldDirty:!0}):l(`irsCode`,void 0,{shouldDirty:!0}))}},[l,i]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Defaults`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Q.jsx)(Ar,{control:u,name:`sortCode`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Sort Code`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(WJ,{onChange:t=>{d(t),e.onChange(t)},data:n,value:e.value,disabled:r,placeholder:`Scroll to see all options`,formPart:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:u,name:`taxCategory`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Tax Category`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(WJ,{data:a,disabled:o,value:e.value,onChange:e.onChange,placeholder:`Scroll to see all options`,formPart:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:u,name:`pcn874RecordType`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`PCN874 Record Type`}),(0,Q.jsxs)(wn,{value:e.value,onValueChange:e.onChange,children:[(0,Q.jsx)(dr,{children:(0,Q.jsx)(sn,{children:(0,Q.jsx)(qt,{placeholder:`Select record type`})})}),(0,Q.jsx)(mn,{children:Object.entries(su).map(([e,t])=>(0,Q.jsx)(bn,{value:e,children:`${t} (${e})`},e))})]}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:u,name:`irsCode`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`IRS Code`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(l0,{value:e.value??void 0,onValueChange:t=>e.onChange(t??null),hideControls:!0,decimalScale:0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:u,name:`defaultDescription`,render:({field:e})=>(0,Q.jsxs)(lr,{className:`md:col-span-2`,children:[(0,Q.jsx)(hr,{children:`Default Description`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{placeholder:`Enter default charge description`,...e})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:u,name:`defaultTags`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Tags`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(y1,{options:Object.values(s).map(({value:e,label:t})=>({label:t,value:e})),onValueChange:e.onChange,defaultValue:e.value,value:e.value,placeholder:`Select Default Tags`,variant:`default`,disabled:c,asChild:!0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:e.control,name:`isClient`,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm`,children:[(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(hr,{children:`Client`}),(0,Q.jsx)(Dr,{children:`Business is a client`})]}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{checked:e.value,onCheckedChange:e.onChange})})]})})]})]})}function s2({form:e}){let[t,n]=(0,Z.useState)(``),[r,i]=(0,Z.useState)(``),{getValues:a,setValue:o,control:s}=e,c=()=>{if(t.trim()){let r=a(`transactionPhrases`);e.setValue(`transactionPhrases`,[...r,t.trim()],{shouldDirty:!0}),n(``)}},l=()=>{if(r.trim()){let e=a(`emailAddresses`);o(`emailAddresses`,[...e,r.trim()],{shouldDirty:!0}),i(``)}},u=e=>{let t=a(`transactionPhrases`);o(`transactionPhrases`,t.filter((t,n)=>n!==e),{shouldDirty:!0})},d=e=>{let t=a(`emailAddresses`);o(`emailAddresses`,t.filter((t,n)=>n!==e),{shouldDirty:!0})};return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Auto Matching`}),` `,(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure patterns for automatic matching of bank transactions and documents`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[(0,Q.jsx)(Ar,{control:s,name:`transactionPhrases`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Transaction Phrases`}),!!e.value?.length&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.value.map((e,t)=>(0,Q.jsxs)(ar,{variant:`secondary`,className:`gap-1`,children:[e,(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`p-0 size-3`,onClick:()=>u(t),children:(0,Q.jsx)(dn,{className:`size-3 cursor-pointer`,onClick:()=>u(t)})})]},t))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(Sn,{placeholder:`Add phrase...`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,Q.jsx)(q,{type:`button`,size:`sm`,onClick:c,children:(0,Q.jsx)(Dn,{className:`size-4`})})]}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:s,name:`emailAddresses`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Email Addresses`}),!!e.value?.length&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.value.map((e,t)=>(0,Q.jsxs)(ar,{variant:`secondary`,className:`gap-1`,children:[e,(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`p-0 size-3`,onClick:()=>d(t),children:(0,Q.jsx)(dn,{className:`size-3 cursor-pointer`})})]},t))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(Sn,{type:`email`,placeholder:`Add email...`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l())}}),(0,Q.jsx)(q,{type:`button`,size:`sm`,onClick:l,children:(0,Q.jsx)(Dn,{className:`size-4`})})]}),(0,Q.jsx)(mi,{})]})})]})]})}var c2=({onDone:e})=>{let[t,n]=(0,Z.useState)(!1),r=()=>n(!1);function i(){r(),e?.()}return(0,Q.jsxs)(Xt,{open:t,onOpenChange:n,children:[(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsx)(SK,{asChild:!0,content:`Add New Business Trip`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,onClick:()=>n(!0),children:(0,Q.jsx)(ua,{className:`size-5`})})})}),(0,Q.jsxs)(un,{onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Add Business Trip`})}),(0,Q.jsx)(NG,{onDone:i})]})]})},l2=({chargeId:e,close:t,onChange:n=()=>{}})=>e?(0,Q.jsx)(M0,{modalSize:`40%`,position:`bottom`,title:(0,Q.jsxs)(`div`,{className:`flex flex-row mx-3 pt-3 sm:text-1xl gap-10`,children:[(0,Q.jsx)(`h1`,{className:`sm:text-2xl font-small text-gray-900`,children:`Insert Document:`}),(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[`Charge ID: `,e,(0,Q.jsx)($k,{isLink:!0,content:`${window.location.origin}${yt.CHARGES.DETAIL(e)}`})]})]}),opened:!!e,onClose:t,children:(0,Q.jsx)(IG,{chargeId:e,closeModal:t,onChange:n})}):null,u2=({onDone:e,transactionId:t,chargeId:n})=>{let[r,i]=(0,Z.useState)(!1),[{data:a,fetching:o}]=W({query:lt,pause:!r||!t,variables:{transactionId:t}}),s=a?.transactionsByIDs[0];function c(){i(!1),e?.()}return(0,Q.jsxs)(Xt,{open:r,onOpenChange:i,children:[(0,Q.jsx)(SK,{content:`Insert Related Misc Expense`,children:(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,disabled:o,children:(0,Q.jsx)(sa,{className:`size-5`})})})}),(0,Q.jsxs)(un,{className:`sm:max-w-[425px]`,children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Insert Misc Expense`})}),s&&(0,Q.jsx)(zG,{onDone:c,chargeId:n,defaultValues:{amount:s?.amount.raw?Math.abs(s?.amount.raw):void 0,currency:s?.amount.currency,invoiceDate:s?.eventDate,valueDate:s?.exactEffectiveDate||s?.effectiveDate?new Date(s.exactEffectiveDate??s.effectiveDate):void 0,creditorId:(s?.amount.raw??0)>0?s?.counterparty?.id:void 0,debtorId:(s?.amount.raw??0)<0?s?.counterparty?.id:void 0}})]})]})},d2=`insertSalaryRecords`,f2=()=>{let[{fetching:e},t]=H(E);return{fetching:e,insertSalaryRecord:(0,Z.useCallback)(async e=>{let n=d2;if(K.loading(`Adding salary record`,{id:n}),!e.salaryRecords||Array.isArray(e.salaryRecords)&&e.salaryRecords.length===0){K.error(`Error`,{id:n,description:`No salary records to insert`,duration:1e5,closeButton:!0});return}let r=Array.isArray(e.salaryRecords)?e.salaryRecords[0]:e.salaryRecords;if(!r?.directPaymentAmount||!r?.employeeId||!r?.employer||!r?.month){K.error(`Error`,{id:n,description:`Missing required salary record fields`,duration:1e5,closeButton:!0});return}let i=`Error adding salary record [${r.month}] employee [${r.employeeId}]`;try{let r=await t(e),a=Ke(r,i,n,`insertSalaryRecords`);if(a)return K.success(`Success`,{id:n,description:`Salary record was added`}),a.insertSalaryRecords.salaryRecords[0]}catch(e){console.error(`${i}: ${e}`),K.error(`Error`,{id:n,description:i,duration:1e5,closeButton:!0})}},[t])}},p2=({insertSalaryRecordParams:e,setInsertSalaryRecord:t})=>{let{insertSalaryRecord:n,fetching:r}=f2(),i=(0,Z.useCallback)(e=>{e&&n({salaryRecords:[e]}),t(void 0)},[t,n]);return(0,Q.jsx)(M0,{modalSize:`40%`,position:`bottom`,title:(0,Q.jsx)(`div`,{className:`flex flex-row mx-3 pt-3 sm:text-1xl gap-10`,children:(0,Q.jsx)(`h1`,{className:`sm:text-2xl font-small text-gray-900`,children:`Insert Salary Record:`})}),opened:!!e,onClose:()=>t(void 0),children:(0,Q.jsx)(mK,{isNewInsert:!0,onDone:i,isModifying:r,month:e.month})})},m2=`addSortCode`,h2=()=>{let[{fetching:e},t]=H(be);return{fetching:e,addSortCode:(0,Z.useCallback)(async e=>{let n=`Error adding new sort code [${e.name}]`,r=`${m2}-${e.name}`;K.loading(`Adding sort code`,{id:r});try{let i=await t(e);Ke(i,n,r)&&K.success(`Success`,{id:r,description:`"${e.name}" sort code was successfully added`})}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function g2({onAdd:e}){let[t,n]=(0,Z.useState)(!1);return(0,Q.jsxs)(Xt,{open:t,onOpenChange:n,children:[(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsx)(q,{children:`Add Sort Code`})}),(0,Q.jsxs)(un,{className:`w-[90vw] max-w-screen-md`,children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Add New Sort Code`})}),(0,Q.jsx)(_2,{close:()=>n(!1),onAdd:e})]})]})}function _2({close:e,onAdd:t}){let n=Mr({}),{handleSubmit:r}=n,{addSortCode:i,fetching:a}=h2(),o=n=>{n.key&&=parseInt(n.key.toString()),n.defaultIrsCode&&=parseInt(n.defaultIrsCode.toString()),i(n).then(()=>{e(),t?.()})};return(0,Q.jsx)(kr,{...n,children:(0,Q.jsxs)(`form`,{onSubmit:r(o),children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-4 my-4`,children:(0,Q.jsx)(hK,{isInsert:!0,formManager:n})}),(0,Q.jsx)(`div`,{className:`flex justify-end mt-4`,children:(0,Q.jsx)(q,{type:`submit`,disabled:a,children:`Add Sort Code`})})]})})}var v2=`insertTaxCategory`,y2=()=>{let[{fetching:e},t]=H(Be);return{fetching:e,insertTaxCategory:(0,Z.useCallback)(async e=>{let n=`Error creating tax category`,r=v2;K.loading(`Adding Tax Category`,{id:r});try{let i=await t(e),a=Ke(i,n,r);if(a)return K.success(`Success`,{id:r,description:`${a.insertTaxCategory.name} was created`}),a.insertTaxCategory}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function b2({formManager:e,setFetching:t,isInsert:n,ownerId:r}){let{control:i,setValue:a}=e;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ar,{name:`name`,control:i,rules:{required:`Required`,minLength:{value:2,message:`Must be at least 2 characters`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Name`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,value:e.value??void 0,required:!0,className:n?``:_t(t)})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`sortCode`,control:i,render:({field:e,fieldState:i})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Sort Code`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(f0,{ownerId:r,value:e.value,onChange:(t,n)=>{e.onChange(t),n?.defaultIrsCode&&a(`irsCode`,n.defaultIrsCode,{shouldDirty:!0})},onFetchingChange:t,formPart:!0,triggerClassName:n?void 0:_t(i)})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{name:`irsCode`,control:i,render:({field:e,fieldState:t})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`IRS Code`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(l0,{...e,className:n?``:_t(t),value:e.value??void 0,hideControls:!0,decimalScale:0})}),(0,Q.jsx)(mi,{})]})}),(0,Q.jsx)(Ar,{control:i,name:`taxExcluded`,render:({field:e})=>(0,Q.jsxs)(lr,{className:`flex flex-row items-center justify-between`,children:[(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(hr,{children:`Tax excluded category`})}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Hz,{onCheckedChange:e.onChange,checked:e.value??void 0})})]})})]})}function x2({onAdd:e}){let[t,n]=(0,Z.useState)(!1);return(0,Q.jsxs)(Xt,{open:t,onOpenChange:n,children:[(0,Q.jsx)(fn,{asChild:!0,children:(0,Q.jsx)(q,{children:`Add Tax Category`})}),(0,Q.jsxs)(un,{className:`w-[90vw] max-w-screen-md`,children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Add New Tax Category`})}),(0,Q.jsx)(S2,{close:()=>n(!1),onAdd:e})]})]})}function S2({close:e,onAdd:t}){let n=Mr({}),{handleSubmit:r}=n,[i,a]=(0,Z.useState)(!1),{userContext:o}=(0,Z.useContext)(nr),{insertTaxCategory:s,fetching:c}=y2(),l=n=>{n.sortCode&&=parseInt(n.sortCode.toString()),s({fields:n}).then(n=>{n?.id&&(t?.(n.id),e())})};return(0,Q.jsx)(kr,{...n,children:(0,Q.jsxs)(`form`,{onSubmit:r(l),children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-4 my-4`,children:(0,Q.jsx)(b2,{isInsert:!0,formManager:n,setFetching:a,ownerId:o?.context.adminBusinessId})}),(0,Q.jsx)(`div`,{className:`flex justify-end mt-4`,children:(0,Q.jsx)(q,{type:`submit`,disabled:c||i,children:`Add Tax Category`})})]})})}var C2=`issueDocument`,w2=()=>{let[{fetching:e},t]=H(U);return{fetching:e,issueDocument:(0,Z.useCallback)(async e=>{let n=`Error issuing document`,r=C2;K.loading(`Issuing document...`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`issueGreenInvoiceDocument`);if(a)return K.success(`Success`,{id:r,description:`Document issued successfully`,duration:3e3}),a.issueGreenInvoiceDocument}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},T2=`previewDocument`,E2=()=>{let[{fetching:e},t]=H(Ee);return{fetching:e,previewDocument:(0,Z.useCallback)(async e=>{let n=`Error generating document preview`,r=T2;K.loading(`Generating document preview...`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`previewDocument`);if(a)return K.success(`Success`,{id:r,description:`Document preview generated`,duration:3e3}),a.previewDocument}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function D2({className:e,...t}){return(0,Q.jsx)(Wa,{"data-slot":`checkbox`,className:s(`peer border-gray-200 dark:bg-gray-200/30 data-[state=checked]:bg-gray-900 data-[state=checked]:text-gray-50 dark:data-[state=checked]:bg-gray-900 data-[state=checked]:border-gray-900 focus-visible:border-gray-950 focus-visible:ring-gray-950/50 aria-invalid:ring-red-500/20 dark:aria-invalid:ring-red-500/40 aria-invalid:border-red-500 size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-800 dark:dark:bg-gray-800/30 dark:data-[state=checked]:bg-gray-50 dark:data-[state=checked]:text-gray-900 dark:dark:data-[state=checked]:bg-gray-50 dark:data-[state=checked]:border-gray-50 dark:focus-visible:border-gray-300 dark:focus-visible:ring-gray-300/50 dark:aria-invalid:ring-red-900/20 dark:dark:aria-invalid:ring-red-900/40 dark:aria-invalid:border-red-900`,e),...t,children:(0,Q.jsx)(Ka,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,Q.jsx)(on,{className:`size-3.5`})})})}function O2({isOpen:e,onClose:t,onIssue:n,clientName:r,clientEmails:i=[],documentType:a=Ve.Unprocessed}){let[o,s]=(0,Z.useState)({emailContent:``,attachment:!0,sendEmail:!1}),[c,l]=(0,Z.useState)(!1),u=(e,t)=>{s(n=>({...n,[e]:t}))},d=async e=>{e.preventDefault(),l(!0);try{await n(o),t(),s({emailContent:``,attachment:!0,sendEmail:!1})}catch(e){console.error(`Failed to issue document:`,e)}finally{l(!1)}},f=()=>{c||t()};return(0,Q.jsx)(Xt,{open:e,onOpenChange:f,children:(0,Q.jsxs)(un,{className:`sm:max-w-[500px]`,children:[(0,Q.jsxs)(en,{children:[(0,Q.jsxs)(_n,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ca,{className:`w-5 h-5`}),`Issue Document`]}),(0,Q.jsxs)(En,{children:[`Configure email settings before sending the `,au(a),` to the client.`]})]}),(0,Q.jsxs)(`form`,{onSubmit:d,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsx)(D2,{id:`sendEmail`,checked:o.sendEmail,onCheckedChange:e=>u(`sendEmail`,e===!0),disabled:c}),(0,Q.jsx)(gn,{htmlFor:`sendEmail`,className:`text-sm font-medium`,children:`Send email to client`})]}),(0,Q.jsx)(`div`,{className:`text-xs text-gray-500 ml-6`,children:`When disabled, email will not be sent to the client.`}),r&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 p-3 rounded-lg`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-gray-700`,children:`Sending to:`}),(0,Q.jsx)(`div`,{className:`text-sm text-gray-900`,children:r}),i.length>0&&(0,Q.jsx)(`div`,{className:`text-xs text-gray-600 mt-1`,children:i.join(`, `)})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(gn,{htmlFor:`emailContent`,children:`Email Message`}),(0,Q.jsx)(Wn,{id:`emailContent`,value:o.emailContent,onChange:e=>u(`emailContent`,e.target.value),placeholder:`Add a custom message to include in the email (optional)`,className:`min-h-[100px]`,disabled:c||!o.sendEmail}),(0,Q.jsx)(`div`,{className:`text-xs text-gray-500`,children:`This message will be included in the email sent to the client along with the document.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsx)(D2,{id:`attachment`,checked:o.attachment,onCheckedChange:e=>u(`attachment`,e===!0),disabled:c||!o.sendEmail}),(0,Q.jsx)(gn,{htmlFor:`attachment`,className:`text-sm font-medium`,children:`Attach document to email`})]}),(0,Q.jsx)(`div`,{className:`text-xs text-gray-500 ml-6`,children:`When enabled, the PDF document will be attached to the email sent to the client.`}),(0,Q.jsxs)(Zt,{className:`gap-2`,children:[(0,Q.jsx)(q,{type:`button`,variant:`outline`,onClick:f,disabled:c,children:`Cancel`}),(0,Q.jsx)(q,{type:`submit`,disabled:c,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qt,{className:`w-4 h-4 mr-2 animate-spin`}),`Issuing...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xa,{className:`w-4 h-4 mr-2`}),`Issue Document`]})})]})]})]})})}var k2={},A2={};A2.byteLength=R2,A2.toByteArray=B2,A2.fromByteArray=U2;for(var j2=[],M2=[],N2=typeof Uint8Array<`u`?Uint8Array:Array,P2=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,F2=0,I2=P2.length;F2<I2;++F2)j2[F2]=P2[F2],M2[P2.charCodeAt(F2)]=F2;M2[45]=62,M2[95]=63;function L2(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function R2(e){var t=L2(e),n=t[0],r=t[1];return(n+r)*3/4-r}function z2(e,t,n){return(t+n)*3/4-n}function B2(e){var t,n=L2(e),r=n[0],i=n[1],a=new N2(z2(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=M2[e.charCodeAt(c)]<<18|M2[e.charCodeAt(c+1)]<<12|M2[e.charCodeAt(c+2)]<<6|M2[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=M2[e.charCodeAt(c)]<<2|M2[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=M2[e.charCodeAt(c)]<<10|M2[e.charCodeAt(c+1)]<<4|M2[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function V2(e){return j2[e>>18&63]+j2[e>>12&63]+j2[e>>6&63]+j2[e&63]}function H2(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(V2(r));return i.join(``)}function U2(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(H2(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(j2[t>>2]+j2[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(j2[t>>10]+j2[t>>4&63]+j2[t<<2&63]+`=`)),i.join(``)}var W2={};W2.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},W2.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=A2,n=W2,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=x,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(he(e,o)||e&&he(e.buffer,o)||s!==void 0&&(he(e,s)||e&&he(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=S(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(he(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||ge(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function x(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(he(e,a)&&(e=u.from(e,e.offset,e.byteLength)),he(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(he(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function S(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||he(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return ue(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return pe(e).length;default:if(i)return r?-1:ue(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=S;function C(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return R(this,t,n);case`utf8`:case`utf-8`:return N(this,t,n);case`ascii`:return I(this,t,n);case`latin1`:case`binary`:return L(this,t,n);case`base64`:return M(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return z(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function w(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)w(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?N(this,0,e):C.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e||u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(he(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function T(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,ge(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(i)n=0;else return-1}if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:E(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):E(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function E(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return T(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return T(this,e,t,n,!1)};function D(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(ge(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return me(ue(t,e.length-n),e,n,r)}function k(e,t,n,r){return me(de(t),e,n,r)}function A(e,t,n,r){return me(pe(t),e,n,r)}function j(e,t,n,r){return me(fe(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return D(this,e,t,n);case`utf8`:case`utf-8`:return O(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return k(this,e,t,n);case`base64`:return A(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return j(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function M(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function N(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return F(r)}let P=4096;function F(e){let t=e.length;if(t<=P)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=P));return n}function I(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function L(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function R(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=_e[e[r]];return i}function z(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function B(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||B(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||B(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=t+this[++e]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||B(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||B(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=this[e+4]+this[e+5]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=ve(function(e){e>>>=0,oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&se(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||B(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),n.read(this,e,!1,52,8)};function V(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;V(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;V(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ee(e,t,n,r,i){G(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function te(e,t,n,r,i){G(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=ve(function(e,t=0){return ee(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=ve(function(e,t=0){return te(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);V(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);V(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||V(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=ve(function(e,t=0){return ee(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=ve(function(e,t=0){return te(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ne(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function re(e,t,r,i,a){return t=+t,r>>>=0,a||ne(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return re(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return re(this,e,t,!1,n)};function H(e,t,r,i,a){return t=+t,r>>>=0,a||ne(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return H(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return H(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let ie={};function U(e,t,n){ie[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}U(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),U(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),U(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=W(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=W(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function W(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function ae(e,t,n){oe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&se(t,e.length-(n+1))}function G(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new ie.ERR_OUT_OF_RANGE(`value`,i,e)}ae(r,i,a)}function oe(e,t){if(typeof e!=`number`)throw new ie.ERR_INVALID_ARG_TYPE(t,`number`,e)}function se(e,t,n){throw Math.floor(e)===e?t<0?new ie.ERR_BUFFER_OUT_OF_BOUNDS:new ie.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(oe(e,n),new ie.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let ce=/[^+/0-9A-Za-z-_]/g;function le(e){if(e=e.split(`=`)[0],e=e.trim().replace(ce,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function ue(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function de(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function fe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function pe(e){return t.toByteArray(le(e))}function me(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function he(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function ge(e){return e!==e}let _e=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function ve(e){return typeof BigInt>`u`?ye:e}function ye(){throw Error(`BigInt not supported`)}})(k2);var G2=k2.Buffer;k2.Blob,k2.BlobOptions,k2.Buffer,k2.File,k2.FileOptions,k2.INSPECT_MAX_BYTES,k2.SlowBuffer,k2.TranscodeEncoding,k2.atob,k2.btoa,k2.constants,k2.isAscii,k2.isUtf8,k2.kMaxLength,k2.kStringMaxLength,k2.resolveObjectURL,k2.transcode,i();var K2=typeof t==`object`&&t+``==`[object process]`&&!t.versions.nw&&!(t.versions.electron&&t.type&&t.type!==`browser`),q2=[1/0,1/0,-1/0,-1/0],J2=new Float32Array(q2),Y2=[.001,0,0,.001,0,0],X2=`http://www.w3.org/2000/svg`,Z2={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Q2={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},$2=`pdfjs_internal_id_`,e4=`pdfjs_internal_editor_`,t4={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},n4={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},r4={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},i4={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},a4={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},o4={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},s4={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},c4={ERRORS:0,WARNINGS:1,INFOS:5},l4={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},u4={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},d4={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},f4=c4.WARNINGS;function p4(e){Number.isInteger(e)&&(f4=e)}function m4(){return f4}function h4(e){f4>=c4.INFOS&&console.info(`Info: ${e}`)}function g4(e){f4>=c4.WARNINGS&&console.warn(`Warning: ${e}`)}function _4(e){throw Error(e)}function v4(e,t){e||_4(t)}function y4(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function b4(e,t=null,n=null){if(!e)return null;if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=P4(e)}catch{}let r=t?URL.parse(e,t):URL.parse(e);return y4(r)?r:null}function x4(e,t,n=!1){let r=URL.parse(e);return r?(r.hash=t,r.href):n&&b4(e,`http://example.com`)?e.split(`#`,1)[0]+`${t?`#${t}`:``}`:``}function S4(e){return e.substring(e.lastIndexOf(`/`)+1)}function C4(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var w4=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),T4=class extends w4{constructor(e,t){super(e,`PasswordException`),this.code=t}},E4=class extends w4{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},D4=class extends w4{constructor(e){super(e,`InvalidPDFException`)}},O4=class extends w4{constructor(e,t,n){super(e,`ResponseException`),this.status=t,this.missing=n}},k4=class extends w4{constructor(e){super(e,`FormatError`)}},A4=class extends w4{constructor(e){super(e,`AbortException`)}};function j4(e){(typeof e!=`object`||e?.length===void 0)&&_4(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function M4(e){typeof e!=`string`&&_4(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}var N4=class{static get isLittleEndian(){let e=new Uint8Array(4);e[0]=1;let t=new Uint32Array(e.buffer,0,1);return C4(this,`isLittleEndian`,t[0]===1)}static get isOffscreenCanvasSupported(){return C4(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return C4(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get isFloat16ArraySupported(){return C4(this,`isFloat16ArraySupported`,typeof Float16Array<`u`)}static get isSanitizerSupported(){return C4(this,`isSanitizerSupported`,typeof Sanitizer<`u`)}static get platform(){let{platform:e,userAgent:t}=navigator;return C4(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;return this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext(`2d`):typeof document<`u`&&(e=document.createElement(`canvas`).getContext(`2d`)),C4(this,`isCanvasFilterSupported`,e?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>`u`)return C4(this,`isAlphaColorInputSupported`,!1);let e=document.createElement(`input`);return e.type=`color`,e.setAttribute(`alpha`,``),e.value=`#ff000080`,C4(this,`isAlphaColorInputSupported`,e.value!==`#ff0000`)}static get isBackdropFilterSupported(){return C4(this,`isBackdropFilterSupported`,typeof CSS<`u`&&CSS.supports(`backdrop-filter`,`blur(1px)`))}},$=class{static get hexNums(){return C4(this,`hexNums`,Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)))}static makeHexColor(e,t,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}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,n=0){let r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4],e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];for(let t=0;t<6;t+=2){let l=e[n+t],u=e[n+t+1];e[n+t]=l*r+u*a+s,e[n+t+1]=l*i+u*o+c}}static applyInverseTransform(e,t){let n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=e[0],u=e[1],d=e[2],f=e[3],p=r*l+s,m=p,h=r*d+s,g=h,_=o*u+c,v=_,y=o*f+c,b=y;if(i!==0||a!==0){let e=i*l,t=i*d,n=a*u,r=a*f;p+=n,g+=n,h+=r,m+=r,_+=e,b+=e,y+=t,v+=t}n[0]=Math.min(n[0],p,h,m,g),n[1]=Math.min(n[1],_,y,v,b),n[2]=Math.max(n[2],p,h,m,g),n[3]=Math.max(n[3],_,y,v,b)}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 n=e[0],r=e[1],i=e[2],a=e[3],o=n**2+r**2,s=n*i+r*a,c=i**2+a**2,l=(o+c)/2,u=Math.sqrt(l**2-(o*c-s**2));t[0]=Math.sqrt(l+u||1),t[1]=Math.sqrt(l-u||1)}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,r,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],t,r),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],t,r)}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s),this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c)}};function P4(e){return decodeURIComponent(escape(e))}var F4=null,I4=null;function L4(e){return F4||(F4=/([\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,I4=new Map([[`ſt`,`ſt`]])),e.replaceAll(F4,(e,t,n)=>t?t.normalize(`NFKC`):I4.get(n))}function R4(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),j4(e)}function z4(e,t,n){if(!Array.isArray(n)||n.length<2)return!1;let[r,i,...a]=n;if(!e(r)&&!Number.isInteger(r)||!t(i))return!1;let o=a.length,s=!0;switch(i.name){case`XYZ`:if(o<2||o>3)return!1;break;case`Fit`:case`FitB`:return o===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(o>1)return!1;break;case`FitR`:if(o!==4)return!1;s=!1;break;default:return!1}for(let e of a)if(!(typeof e==`number`||s&&e===null))return!1;return!0}var B4=()=>[],V4=()=>new Map,H4=()=>Object.create(null),U4=()=>new Set;typeof Iterator.prototype.join!=`function`&&(Iterator.prototype.join=function(e){return[...this].join(e)});function W4(e,t,n){return Math.min(Math.max(e,t),n)}var G4=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let e=this.viewBox;return C4(this,`rawDims`,{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){let n=[e,t];return $.applyTransform(n,this.transform),n}convertToPdfPoint(e,t){let n=[e,t];return $.applyInverseTransform(n,this.transform),n}},K4=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return e!==`textarea`&&e!==`input`&&e!==`option`&&e!==`select`}},q4=/url\(|image-set\(/i,J4=/^on/i,Y4=class{static get _allowedHtmlElements(){return C4(this,`_allowedHtmlElements`,new Set([`a`,`b`,`br`,`button`,`div`,`i`,`img`,`input`,`label`,`li`,`ol`,`option`,`p`,`select`,`span`,`sub`,`sup`,`textarea`,`ul`]))}static get _allowedSvgElements(){return C4(this,`_allowedSvgElements`,new Set([`ellipse`,`line`,`path`,`rect`,`svg`]))}static get _allowedRichTextElements(){return C4(this,`_allowedRichTextElements`,new Set([`a`,`b`,`br`,`div`,`i`,`li`,`ol`,`p`,`span`,`sub`,`sup`,`ul`]))}static get _allowedRichTextAttributes(){return C4(this,`_allowedRichTextAttributes`,new Set([`class`,`dir`,`style`]))}static get _allowedRichTextStyles(){return C4(this,`_allowedRichTextStyles`,new Set(`color.font.fontFamily.fontSize.fontStretch.fontStyle.fontWeight.kerningMode.letterSpacing.lineHeight.margin.marginBottom.marginLeft.marginRight.marginTop.orphans.paddingLeft.paddingRight.breakAfter.breakBefore.breakInside.tabInterval.tabStop.textAlign.textDecoration.textIndent.transform.verticalAlign.widows`.split(`.`)))}static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})})}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null&&!J4.test(t)&&!(r===`richText`&&!this._allowedRichTextAttributes.has(t)))switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:if(r===`richText`){let t=this._allowedRichTextStyles;for(let[r,i]of Object.entries(n))t.has(r)&&!q4.test(i)&&(e.style[r]=i)}else Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i?.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static#e(e,t,n){return n===`richText`?!t&&this._allowedRichTextElements.has(e)?document.createElement(e):null:t?t===X2&&this._allowedSvgElements.has(e)?document.createElementNS(X2,e):null:this._allowedHtmlElements.has(e)?document.createElement(e):null}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=this.#e(r.name,r.attributes?.xmlns,i)??document.createElement(`div`);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&K4.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=this.#e(u,s.attributes?.xmlns,i);if(d){if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&K4.shouldBuildText(u)&&c.push(e),d.append(e)}}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.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:n=0}){let{width:r,height:i}=e.attributes.style;return new G4({viewBox:[0,0,parseInt(r,10),parseInt(i,10)],userUnit:1,scale:t,rotation:n})}},X4=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Z4(e,t=`text`){if(i3(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`blob`:return n.blob();case`bytes`:return n.bytes();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t===`bytes`?`arraybuffer`:t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`bytes`:n(new Uint8Array(i.response));return;case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}var Q4=class extends w4{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function $4(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function e3(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function t3(e){return[e]=e.split(/[#?]/,1),S4(e)}function n3(e,t=`document.pdf`){if(typeof e!=`string`)return t;if($4(e))return g4(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=(e=>{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,`https://foo.bar`)}catch{}try{return new URL(decodeURIComponent(e),`https://foo.bar`)}catch{}return null})(e);if(!n)return t;let r=e=>{try{let t=decodeURIComponent(e);return t.includes(`/`)&&(t=S4(t),t.length===4&&i.test(t))?e:t}catch{return e}},i=/\.pdf$/i,a=S4(n.pathname);if(i.test(a))return r(a);if(n.searchParams.size>0){let e=e=>[...e].findLast(e=>i.test(e)),t=e(n.searchParams.values())??e(n.searchParams.keys());if(t)return r(t)}if(n.hash){let e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(e)return r(e[0])}return t}var r3=class{#e=new Map;times=[];time(e){this.#e.has(e)&&g4(`Timer is already running for ${e}`),this.#e.set(e,Date.now())}timeEnd(e){this.#e.has(e)||g4(`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(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join(``)}};function i3(e,t){let n=t?URL.parse(e,t):URL.parse(e);return/https?:/.test(n?.protocol??``)}function a3(e){e.preventDefault()}function o3(e){e.preventDefault(),e.stopPropagation()}var s3=class{static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!=`string`)return null;this.#e||=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 n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}};function c3(e){if(e.startsWith(`#`)){let t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith(`rgb(`)){let[t,n,r]=e.slice(4,-1).split(`,`).map(e=>parseInt(e,10));return[t,n,r,1]}if(e.startsWith(`rgba(`)){let t=e.slice(5,-1).split(`,`);return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[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]:null}function l3(e){let t=c3(e);return t?t.slice(0,3):(g4(`Not a valid color format: "${e}"`),[0,0,0])}function u3(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,t.style.colorScheme=`only light`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,l3(r))}t.remove()}function d3(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function f3(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function p3(e,t,n=!1,r=!0){if(t instanceof G4){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,s=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!n||t.rotation%180==0?(a.width=o,a.height=s):(a.width=s,a.height=o)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var m3=class e{constructor(){let{pixelRatio:t}=e;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,n,r,i,a=-1){let o=1/0,s=1/0,c=1/0;r=e.capPixels(r,a),r>0&&(o=Math.sqrt(r/(t*n))),i!==-1&&(s=i/t,c=i/n);let l=Math.min(o,s,c);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let n=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,n):n}return e}},h3=[`image/apng`,`image/avif`,`image/bmp`,`image/gif`,`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`image/x-icon`],g3=class{static get isDarkMode(){return C4(this,`isDarkMode`,!!window?.matchMedia?.(`(prefers-color-scheme: dark)`).matches)}},_3=class{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:n}=window.getComputedStyle(e);return e.remove(),C4(this,`commentForegroundColor`,l3(n))}};function v3(e,t){t=W4(t??1,0,1);let n=255*(1-t);return e.map(e=>Math.round(e*t+n))}function y3(e,t){let n=e[0]/255,r=e[1]/255,i=e[2]/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)t[0]=t[1]=0;else{let e=a-o;switch(t[1]=s<.5?e/(a+o):e/(2-a-o),a){case n:t[0]=((r-i)/e+(r<i?6:0))*60;break;case r:t[0]=((i-n)/e+2)*60;break;case i:t[0]=((n-r)/e+4)*60}}t[2]=s}function b3(e,t){let n=e[0],r=e[1],i=e[2],a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(n/60%2-1)),s=i-a/2;switch(Math.floor(n/60)){case 0:t[0]=a+s,t[1]=o+s,t[2]=s;break;case 1:t[0]=o+s,t[1]=a+s,t[2]=s;break;case 2:t[0]=s,t[1]=a+s,t[2]=o+s;break;case 3:t[0]=s,t[1]=o+s,t[2]=a+s;break;case 4:t[0]=o+s,t[1]=s,t[2]=a+s;break;case 5:case 6:t[0]=a+s,t[1]=s,t[2]=o+s}}function x3(e){return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function S3(e,t,n){b3(e,n),n.map(x3);let r=.2126*n[0]+.7152*n[1]+.0722*n[2];b3(t,n),n.map(x3);let i=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>i?(r+.05)/(i+.05):(i+.05)/(r+.05)}var C3=new Map;function w3(e,t){let n=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,r=C3.get(n);if(r)return r;let i=new Float32Array(9),a=i.subarray(0,3),o=i.subarray(3,6);y3(e,o);let s=i.subarray(6,9);y3(t,s);let c=s[2]<.5,l=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),S3(o,s,a)<l){let e,t;for(c?(e=o[2],t=1):(e=0,t=o[2]);t-e>.005;){let n=o[2]=(e+t)/2;c===S3(o,s,a)<l?e=n:t=n}o[2]=c?t:e}return b3(o,a),r=$.makeHexColor(Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255)),C3.set(n,r),r}function T3({html:e,dir:t,className:n},r){let i=document.createDocumentFragment();if(typeof e==`string`){let n=document.createElement(`p`);n.dir=t||`auto`;let r=e.split(/\r\n?|\n/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}i.append(n)}else Y4.render({xfaHtml:e,div:i,intent:`richText`});i.firstElementChild.classList.add(`richText`,n),r.append(i)}function E3(e){let t=new Path2D;if(!e)return t;for(let n=0,r=e.length;n<r;)switch(e[n++]){case u4.moveTo:t.moveTo(e[n++],e[n++]);break;case u4.lineTo:t.lineTo(e[n++],e[n++]);break;case u4.curveTo:t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);break;case u4.quadraticCurveTo:t.quadraticCurveTo(e[n++],e[n++],e[n++],e[n++]);break;case u4.closePath:t.closePath();break;default:g4(`Unrecognized drawing path operator: ${e[n-1]}`)}return t}var D3=class e{#e=null;#t=null;#n;#r=null;#i=null;#a=null;#o=null;#s=null;static#c=null;constructor(t){this.#n=t,e.#c||=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 t=this.#e=document.createElement(`div`);t.classList.add(`editToolbar`,`hidden`),t.setAttribute(`role`,`toolbar`);let n=this.#n._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(t.addEventListener(`contextmenu`,a3,{signal:n}),t.addEventListener(`pointerdown`,e.#l,{signal:n}));let r=this.#r=document.createElement(`div`);r.className=`buttons`,t.append(r);let i=this.#n.toolbarPosition;if(i){let{style:e}=t;e.insetInlineEnd=`${100*(this.#n._uiManager.direction===`ltr`?1-i[0]:i[0])}%`,e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#e}static#l(e){e.stopPropagation()}#u(e){this.#n._focusEventsAllowed=!1,o3(e)}#d(e){this.#n._focusEventsAllowed=!0,o3(e)}#f(e){let t=this.#n._uiManager._signal;return!(t instanceof AbortSignal)||t.aborted?!1:(e.addEventListener(`focusin`,this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,a3,{signal:t}),!0)}hide(){this.#e.classList.add(`hidden`),this.#t?.hideDropdown()}show(){this.#e.classList.remove(`hidden`),this.#i?.shown(),this.#a?.shown()}addDeleteButton(){let{editorType:t,_uiManager:n}=this.#n,r=document.createElement(`button`);r.classList.add(`basic`,`deleteButton`),r.tabIndex=0,r.setAttribute(`data-l10n-id`,e.#c[t]),this.#f(r)&&r.addEventListener(`click`,e=>{n.delete()},{signal:n._signal}),this.#r.append(r)}get#p(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#f(t),this.#r.append(t,this.#p),this.#i=e}addComment(e,t=null){if(this.#a)return;let n=e.renderForToolbar();if(!n)return;this.#f(n);let r=this.#o=this.#p;t?(this.#r.insertBefore(n,t),this.#r.insertBefore(r,t)):this.#r.append(n,r),this.#a=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;let t=e.renderButton();this.#f(t),this.#r.append(t,this.#p)}async addEditSignatureButton(e){let t=this.#s=await e.renderEditButton(this.#n);this.#f(t),this.#r.append(t,this.#p)}removeButton(e){e===`comment`&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#o?.remove(),this.#o=null)}async addButton(e,t){switch(e){case`colorPicker`:t&&this.addColorPicker(t);break;case`altText`:t&&await this.addAltText(t);break;case`editSignature`:t&&await this.addEditSignatureButton(t);break;case`delete`:this.addDeleteButton();break;case`comment`:t&&this.addComment(t)}}async addButtonBefore(e,t,n){if(!t&&e===`comment`)return;let r=this.#r.querySelector(n);r&&e===`comment`&&this.addComment(t,r)}updateEditSignatureButton(e){this.#s&&(this.#s.title=e)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},O3=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`);let t=this.#n._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener(`contextmenu`,a3,{signal:t});let n=this.#e=document.createElement(`div`);return n.className=`buttons`,e.append(n),this.#n.hasCommentManager()&&this.#a(`commentButton`,`pdfjs-comment-floating-button`,`pdfjs-comment-floating-button-label`,()=>{this.#n.commentSelection(`floating_button`)}),this.#a(`highlightButton`,`pdfjs-highlight-floating-button1`,`pdfjs-highlight-floating-button-label`,()=>{this.#n.highlightSelection(`floating_button`)}),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);if(e>n){r=a,n=e;continue}t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}show(e,t,n){let[r,i]=this.#i(t,n),{style:a}=this.#t||=this.#r();e.append(this.#t),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(e,t,n,r){let i=document.createElement(`button`);i.classList.add(`basic`,e),i.tabIndex=0,i.setAttribute(`data-l10n-id`,t);let a=document.createElement(`span`);i.append(a),a.className=`visuallyHidden`,a.setAttribute(`data-l10n-id`,n);let o=this.#n._signal;o instanceof AbortSignal&&!o.aborted&&(i.addEventListener(`contextmenu`,a3,{signal:o}),i.addEventListener(`click`,r,{signal:o})),this.#e.append(i)}},k3=Object.freeze({internal:`f63eb798-ea37-4556-98de-f8303ee5a694`});function A3(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var j3=class e{static#e=NaN;static#t=null;static#n=NaN;static#r=null;static initializeAndAddPointerId(t){(e.#t||=new Set).add(t)}static setPointer(t,n){e.#e||=n,e.#r??=t}static setTimeStamp(t){e.#n=t}static isSamePointerId(t){return e.#e===t}static isSamePointerIdOrRemove(t){return e.#e===t||(e.#t?.delete(t),!1)}static isSamePointerType(t){return e.#r===t}static isInitializedAndDifferentPointerType(t){return e.#r!==null&&!e.isSamePointerType(t)}static isSameTimeStamp(t){return e.#n===t}static isUsingMultiplePointers(){return e.#t?.size>=1}static clearPointerType(){e.#r=null}static clearPointerIds(){e.#e=NaN,e.#t=null}static clearTimeStamp(){e.#n=NaN}},M3=class{#e=0;get id(){return`${e4}${this.#e++}`}},N3=class e{#e=R4();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${X2}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),n=new Image;n.src=e;let r=n.decode().then(()=>(t.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0));return C4(this,`_isSVGFittingCanvas`,r)}async#r(t,n){this.#n||=new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await Z4(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){g4(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=new Map;let t=this.#n.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:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},P3=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c<this.#e.length&&this.#e.splice(c)),this.#e.push(s)}undo(){if(this.#r===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1,--this.#r}redo(){if(this.#r<this.#e.length-1){this.#r+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#e.length-1}cleanType(e){if(this.#r!==-1){for(let t=this.#r;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},F3=class e{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:n}=N4.platform;for(let[r,i,a={}]of t){let t=r.some(e=>e.startsWith(`mac+`));for(let o of r){let r=o;if(t){let e=o.startsWith(`mac+`);if(n!==e)continue;e&&(r=o.slice(4))}let[s,c]=e.#e(r);s!==null&&this.callbacks.getOrInsertComputed(s,B4).push({callback:i,options:a,modifiers:c})}}}static#e(t){let n=null,r=0;for(let i of t.split(`+`)){if(i=i.trim(),!i)continue;let a=i.toUpperCase(),o=e[a];if(o){r|=o;continue}if(n!==null){g4(`KeyboardManager: multiple keys in shortcut "${t}"`);break}n=a===`SPACE`?` `:i}return n===null&&g4(`KeyboardManager: no key found in shortcut "${t}"`),[n,r]}static#t(e){let t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?t[1]?.toLowerCase()??t[2]:null}exec(t,n){let r=this.callbacks.get(n.key);if(!r){if(/^[a-z]$/i.test(n.key))return;let t=e.#t(n.code);if(t===null||t===n.key||(r=this.callbacks.get(t),!r))return}let i=(n.altKey?e.ALT:0)|(n.ctrlKey?e.CTRL:0)|(n.metaKey?e.META:0)|(n.shiftKey?e.SHIFT:0),a=r.find(e=>e.modifiers===i);if(!a)return;let{callback:o,options:{bubbles:s=!1,args:c=[],checker:l=null}}=a;l&&!l(t,n)||(o.bind(t,...c,n)(),s||o3(n))}},I3=class e{static _colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return u3(e),C4(this,`_colors`,e)}convert(t){let n=l3(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?$.makeHexColor(...t):e}},L3=class e{#e=new AbortController;#t=null;#n=null;#r=new Map;#i=new Map;#a=null;#o=null;#s=null;#c=null;#l=new P3;#u=null;#d=null;#f=null;#p=0;#m=new Set;#h=null;#g=null;#_=new Set;_editorUndoBar=null;#v=!1;#y=!1;#b=!1;#x=null;#S=null;#C=null;#w=null;#T=!1;#E=null;#D=new M3;#O=!1;#k=!1;#A=!1;#j=null;#M=null;#N=null;#P=null;#F=null;#I=t4.NONE;#L=new Set;#R=null;#z=null;#B=null;#V=null;#H=null;#U={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#W=[0,0];#G=null;#K=null;#q=null;#J=null;#Y=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#K.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return C4(this,`_keyboardManager`,new F3([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#K.contains(t)&&!e.isEnterHandled}],[[`Space`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#K.contains(document.activeElement)}],[[`Escape`],t.unselectAll],[[`ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this._signal=this.#e.signal;this.#K=e,this.#q=t,this.#J=n,this.#o=r,this.#u=i,this.#z=a,this.#H=s,this._eventBus=o;let _={signal:g,...k3};o.on(`editingaction`,this.onEditingAction.bind(this),_),o.on(`pagechanging`,this.onPageChanging.bind(this),_),o.on(`scalechanging`,this.onScaleChanging.bind(this),_),o.on(`rotationchanging`,this.onRotationChanging.bind(this),_),o.on(`setpreference`,this.onSetPreference.bind(this),_),o.on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),_),window.addEventListener(`pointerdown`,()=>{this.#k=!0},{capture:!0,signal:g}),window.addEventListener(`pointerup`,()=>{this.#k=!1},{capture:!0,signal:g}),window.addEventListener(`beforeunload`,this.endCurrentEditing.bind(this),{capture:!0,signal:g}),this.#te(),this.#ce(),this.#ie(),this.#s=s.annotationStorage,this.#x=s.filterFactory,this.#B=c,this.#w=l||null,this.#v=u,this.#y=d,this.#b=f,this.#F=p||null,this.viewParameters={realScale:X4.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=h!==!1,i?.setSidebarUiManager(this)}destroy(){this.#Y?.resolve(),this.#Y=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#i.values())e.destroy();this.#i.clear(),this.#r.clear(),this.#_.clear(),this.#P?.clear(),this.#t=null,this.#L.clear(),this.#l.destroy(),this.#o?.destroy(),this.#u?.destroy(),this.#z?.destroy(),this.#E?.hide(),this.#E=null,this.#N?.destroy(),this.#N=null,this.#n=null,this.#S&&=(clearTimeout(this.#S),null),this.#G&&=(clearTimeout(this.#G),null),this._editorUndoBar?.destroy(),this.#H=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#F}get useNewAltTextFlow(){return this.#y}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return C4(this,`hcmFilter`,this.#B?this.#x.addHCMFilter(this.#B.foreground,this.#B.background):`none`)}get direction(){return C4(this,`direction`,getComputedStyle(this.#K).direction)}get _highlightColors(){return C4(this,`_highlightColors`,this.#w?new Map(this.#w.split(`,`).map(e=>(e=e.split(`=`).map(e=>e.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return C4(this,`highlightColors`,null);let t=new Map,n=!!this.#B;for(let[r,i]of e){let e=r.endsWith(`_HCM`);if(n&&e){t.set(r.replace(`_HCM`,``),i);continue}!n&&!e&&t.set(r,i)}return C4(this,`highlightColors`,t)}get highlightColorNames(){return C4(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){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#f=e}setMainHighlightColorPicker(e){this.#N=e}editAltText(e,t=!1){this.#o?.editAltText(this,e,t)}hasCommentManager(){return!!this.#u}editComment(e,t,n,r){this.#u?.showDialog(this,e,t,n,r)}selectComment(e,t){(this.#i.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 n=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,`comment`),this.toggleComment(null),e.comment=null},undo:n,mustExec:!0})}toggleComment(e,t,n=void 0){this.#u?.toggleCommentPopup(e,t,n)}makeCommentColor(e,t){return e&&this.#u?.makeCommentColor(e,t)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(e){if(this.#i.has(e-1))return;let{resolve:t,promise:n}=Promise.withResolvers(),r=n=>{n.pageNumber===e&&(this._eventBus.off(`editorsrendered`,r),t())};this._eventBus.on(`editorsrendered`,r,k3),await n}getSignature(e){this.#z?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#z}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal,...k3}),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}){e===`enableNewAltTextWhenAddingImage`&&(this.#b=t)}onPageChanging({pageNumber:e}){this.#p=e-1}deletePage(e){for(let t of this.getEditors(e))t.remove();this.#i.delete(e),this.#p===e&&(this.#p=0)}focusMainContainer(){this.#K.focus()}findParent(e,t){for(let n of this.#i.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#q.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#_.add(e)}removeShouldRescale(e){this.#_.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*X4.PDF_TO_CSS_UNITS;for(let e of this.#_)e.onScaleChanging();this.#f?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#X({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Z(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#i.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``,t=!1){let n=document.getSelection();if(!n||n.isCollapsed)return;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n,s=n.toString(),c=this.#X(n).closest(`.textLayer`),l=this.getSelectionBoxes(c);if(!l)return;n.empty();let u=this.#Z(c),d=this.#I===t4.NONE,f=()=>{let n=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o,text:s});d&&this.showAllEditors(`highlight`,!0,!0),t&&n?.editComment()};if(d){this.switchToMode(t4.HIGHLIGHT,f);return}f()}commentSelection(e=``){this.highlightSelection(e,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Q(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#X(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#E||=new O3(this),this.#E.show(t,n,this.direction===`ltr`))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#s)return null;let t=`${e4}${e}`,n=this.#s.getRawValue(t);return n&&this.#s.remove(t),n}addToAnnotationStorage(e){!e.isEmpty()&&this.#s&&!this.#s.has(e.id)&&this.#s.setValue(e.id,e)}a11yAlert(e,t=null){let n=this.#J;n&&(n.setAttribute(`data-l10n-id`,e),t?n.setAttribute(`data-l10n-args`,JSON.stringify(t)):n.removeAttribute(`data-l10n-args`))}#$(){let e=document.getSelection();if(!e||e.isCollapsed){this.#R&&(this.#E?.hide(),this.#R=null,this.#le({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#R)return;let n=this.#X(e).closest(`.textLayer`);if(!n){this.#R&&(this.#E?.hide(),this.#R=null,this.#le({hasSelectedText:!1}));return}if(this.#E?.hide(),this.#R=t,this.#le({hasSelectedText:!0}),(this.#I===t4.HIGHLIGHT||this.#I===t4.NONE)&&(this.#I===t4.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#T=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#I===t4.HIGHLIGHT?this.#Z(n):null;if(e?.toggleDrawing(),this.#k){let t=new AbortController,n=this.combinedSignal(t),r=n=>{(n.type!==`pointerup`||n.button===0)&&(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#ee(`main_toolbar`))};window.addEventListener(`pointerup`,r,{signal:n}),window.addEventListener(`blur`,r,{signal:n})}else e?.toggleDrawing(!0),this.#ee(`main_toolbar`)}}#ee(e=``){this.#I===t4.HIGHLIGHT?this.highlightSelection(e):this.#v&&this.#Q()}#te(){document.addEventListener(`selectionchange`,this.#$.bind(this),{signal:this._signal})}#ne(){if(this.#C)return;this.#C=new AbortController;let e=this.combinedSignal(this.#C);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#re(){this.#C?.abort(),this.#C=null}blur(){if(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#ee(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#L)if(t.div.contains(e)){this.#M=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#M)return;let[e,t]=this.#M;this.#M=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ie(){if(this.#j)return;this.#j=new AbortController;let e=this.combinedSignal(this.#j);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#ae(){this.#j?.abort(),this.#j=null}#oe(){if(this.#d)return;this.#d=new AbortController;let e=this.combinedSignal(this.#d);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})}#se(){this.#d?.abort(),this.#d=null}#ce(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#ie(),this.setEditingState(!0)}removeEditListeners(){this.#ae(),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#g)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#g)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#L){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&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 e of t.items)for(let t of this.#g)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){g4(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#pe(t);this.#ge(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){g4(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#I!==t4.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#ee(`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`)}}updatePageIndex(e,t){for(let n of this.getEditors(e))n.pageIndex=t;let n=this.#a.get(e);n&&(n.pageIndex=t,this.#i.set(t,n),this.#O?n.enable():n.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear()}endUpdatePages(){this.#a=null}clonePage(e,t){for(let n of this.getEditors(e)){let e=n.serialize(n.mode!==t4.HIGHLIGHT);e&&(e.pageIndex=t,e.id=this.getId(),e.isClone=!0,delete e.popupRef,this.#s.setValue(e.id,e))}}findClonesForPage(e){let t=[],{pageIndex:n}=e;for(let[r,i]of this.#s)i.pageIndex===n&&i.isClone&&(this.#s.remove(r),t.push(e.deserialize(i).then(t=>{t&&(t.isClone=!0,e.addOrRebuild(t))})));return Promise.all(t)}#le(e){Object.entries(e).some(([e,t])=>this.#U[e]!==t)&&(this._eventBus.dispatch(`editingstateschanged`,{source:this,details:Object.assign(this.#U,e)}),this.#I===t4.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#ue([[n4.HIGHLIGHT_FREE,!0]]))}#ue(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#ne(),this.#oe(),this.#le({isEditing:this.#I!==t4.NONE,isEmpty:this.#he(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#re(),this.#se(),this.#le({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#g){this.#g=e;for(let e of this.#g)this.#ue(e.defaultPropertiesToUpdate)}}getId(){return this.#D.id}get currentLayer(){return this.#i.get(this.#p)}getLayer(e){return this.#i.get(e)}get currentPageIndex(){return this.#p}addLayer(e){this.#i.set(e.pageIndex,e),this.#O?e.enable():e.disable()}removeLayer(e){this.#i.delete(e.pageIndex)}async updateMode(e,t=null,n=!1,r=!1,i=!1,a=!1){if(this.#I!==e&&!(this.#Y&&(await this.#Y.promise,!this.#Y))){if(this.#Y=Promise.withResolvers(),this.#f?.commitOrRemove(),this.#I===t4.POPUP&&this.#u?.hideSidebar(),this.#u?.destroyPopup(),this.#I=e,e===t4.NONE){this.setEditingState(!1),this.#fe();for(let e of this.#r.values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#Y.resolve();return}for(let e of this.#r.values())e.addStandaloneCommentButton();e===t4.SIGNATURE&&await this.#z?.loadSignatures(),n&&j3.clearPointerType(),this.setEditingState(!0),await this.#de(),this.unselectAll();for(let t of this.#i.values())t.updateMode(e);if(e===t4.POPUP){this.#n||=await this.#H.getAnnotationsByType(new Set(this.#g.map(e=>e._editorType)));let e=new Set,t=[];for(let n of this.#r.values()){let{annotationElementId:r,hasComment:i,deleted:a}=n;r&&e.add(r),i&&!a&&t.push(n.getData())}for(let n of this.#n){let{id:r,popupRef:i,contentsObj:a}=n;i&&a?.str&&!e.has(r)&&!this.#m.has(r)&&t.push(n)}this.#u?.showSidebar(t)}if(!t){r&&this.addNewEditorFromKeyboard(),this.#Y.resolve();return}for(let e of this.#r.values())e.uid===t?(this.setSelected(e),a?e.editComment():i?e.enterInEditMode():e.focus()):e.unselect();this.#Y.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#I&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,...e})}updateParams(e,t){if(this.#g){switch(e){case n4.CREATE:this.currentLayer.addNewEditor(t);return;case n4.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#V||=new Map).set(e,t),this.showAllEditors(`highlight`,t)}if(this.hasSelection)for(let n of this.#L)n.updateParams(e,t);else for(let n of this.#g)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#r.values())n.editorType===e&&n.show(t);(this.#V?.get(n4.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#ue([[n4.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#A!==e){this.#A=e;for(let t of this.#i.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#de(){if(!this.#O){this.#O=!0;let e=[];for(let t of this.#i.values())e.push(t.enable());await Promise.all(e);for(let e of this.#r.values())e.enable()}}#fe(){if(this.unselectAll(),this.#O){this.#O=!1;for(let e of this.#i.values())e.disable();for(let e of this.#r.values())e.disable()}}*getEditors(e){for(let t of this.#r.values())t.pageIndex===e&&(yield t)}getEditor(e){return this.#r.get(e)}addEditor(e){this.#r.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#S&&clearTimeout(this.#S),this.#S=setTimeout(()=>{this.focusMainContainer(),this.#S=null},0)),this.#r.delete(e.id),e.annotationElementId&&this.#P?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#m.has(e.annotationElementId))&&this.#s?.remove(e.id)}addDeletedAnnotationElement(e){this.#m.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#m.has(e)}removeDeletedAnnotationElement(e){this.#m.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#pe(e){let t=this.#i.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#ue(e.propertiesToUpdate))}get#me(){let e=null;for(e of this.#L);return e}updateUI(e){this.#me===e&&this.#ue(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#ue(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#L.has(e)){this.#L.delete(e),e.unselect(),this.#le({hasSelectedEditor:this.hasSelection});return}this.#L.add(e),e.select(),this.#ue(e.propertiesToUpdate),this.#le({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#f?.commitOrRemove();for(let t of this.#L)t!==e&&t.unselect();this.#u?.destroyPopup(),this.#L.clear(),this.#L.add(e),e.select(),this.#ue(e.propertiesToUpdate),this.#le({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#L.values().next().value}unselect(e){e.unselect(),this.#L.delete(e),this.#le({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#L.size!==0}get isEnterHandled(){return this.#L.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#le({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#he()}),this._editorUndoBar?.hide()}redo(){this.#l.redo(),this.#le({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#he()})}addCommands(e){this.#l.add(e),this.#le({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#he()})}cleanUndoStack(e){this.#l.cleanType(e)}#he(){if(this.#r.size===0)return!0;if(this.#r.size===1)for(let e of this.#r.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.#L],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#pe(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ge(e){for(let e of this.#L)e.unselect();this.#L.clear();for(let t of e)t.isEmpty()||(this.#L.add(t),t.select());this.#le({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#L)e.commit();this.#ge(this.#r.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#I!==t4.NONE))&&!this.#f?.commitOrRemove()&&(this.#u?.destroyPopup(),this.hasSelection)){for(let e of this.#L)e.unselect();this.#L.clear(),this.#le({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#W[0]+=e,this.#W[1]+=t;let[r,i]=this.#W,a=[...this.#L];this.#G&&clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#G=null,this.#W[0]=this.#W[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(r,i),e.translationDone())},undo:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(-r,-i),e.translationDone())},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t),n.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#h=new Map;for(let e of this.#L)this.#h.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#h)return!1;this.disableUserSelect(!1);let e=this.#h;this.#h=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#r.has(e.id)){let i=this.#i.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#h)for(let n of this.#h.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#L.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#I}isEditingMode(){return this.#I!==t4.NONE}get imageManager(){return C4(this,`imageManager`,new N3)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a})}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r!==0&&i!==0&&s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#c||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#c?.delete(e)}renderAnnotationElement(e){let t=this.#c?.get(e.data.id);if(!t)return;let n=this.#s.getRawValue(t);n&&(this.#I===t4.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}setMissingCanvas(e,t,n){let r=this.#P?.get(e);r&&(r.setCanvas(t,n),this.#P.delete(e))}addMissingCanvas(e,t){(this.#P||=new Map).set(e,t)}},R3=class e{#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,e.#f||=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(t){e._l10n??=t}async render(){let t=this.#n=document.createElement(`button`);t.className=`altText`,t.tabIndex=`0`;let n=this.#r=document.createElement(`span`);t.append(n),this.#d?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,e.#f.missing),n.setAttribute(`data-l10n-id`,e.#f[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=this.#c._uiManager._signal;t.addEventListener(`contextmenu`,a3,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e){this.#s?.remove(),this.#s=null;return}if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),(this.#e!==e||this.#t!==t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getElementForAltText()?.setAttribute(`aria-describedby`,n.id)}},z3=class{#e=null;#t=null;#n=!1;#r=null;#i=null;#a=null;#o=null;#s=null;#c=!1;#l=null;constructor(e){this.#r=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.#r.commentButtonPosition;if(t){let{style:n}=e;n.insetInlineEnd=`calc(${100*(this.#r._uiManager.direction===`ltr`?1-t[0]:t[0])}% - var(--comment-button-dim))`,n.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let r=this.#r.commentButtonColor;r&&(n.backgroundColor=r)}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;let e=this.#r.commentButtonColor;e&&(this.#e.style.backgroundColor=e),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#e)return null;let{x:e,y:t,height:n}=this.#e.getBoundingClientRect(),{x:r,y:i,width:a,height:o}=this.#r.parent.boundingClientRect;return[(e-r)/a,(t+n-i)/o]}set commentPopupPositionInLayer(e){this.#l=e}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:t}){this.#e&&(this.#e.classList.toggle(`selected`,e),this.#e.ariaExpanded=t)}#u(e,t){if(!this.#r._uiManager.hasCommentManager())return null;e.tabIndex=`0`,e.ariaHasPopup=`dialog`,t?(e.ariaControls=`commentPopup`,e.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`)):(e.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],e.setAttribute(`data-l10n-id`,`pdfjs-editor-add-comment-button`));let n=this.#r._uiManager._signal;if(!(n instanceof AbortSignal)||n.aborted)return e;e.addEventListener(`contextmenu`,a3,{signal:n}),t&&(e.addEventListener(`focusin`,e=>{this.#r._focusEventsAllowed=!1,o3(e)},{capture:!0,signal:n}),e.addEventListener(`focusout`,e=>{this.#r._focusEventsAllowed=!0,o3(e)},{capture:!0,signal:n})),e.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:n});let r=t=>{t.preventDefault(),e===this.#t?this.edit():this.#r.toggleComment(!0)};return e.addEventListener(`click`,r,{capture:!0,signal:n}),e.addEventListener(`keydown`,t=>{t.target===e&&t.key===`Enter`&&(this.#n=!0,r(t))},{signal:n}),e.addEventListener(`pointerenter`,()=>{this.#r.toggleComment(!1,!0)},{signal:n}),e.addEventListener(`pointerleave`,()=>{this.#r.toggleComment(!1,!1)},{signal:n}),e}edit(e){let t=this.commentPopupPositionInLayer,n,r;if(t)[n,r]=t;else{[n,r]=this.#r.commentButtonPosition;let{width:e,height:t,x:i,y:a}=this.#r;n=i+n*e,r=a+r*t}let i=this.#r.parent.boundingClientRect,{x:a,y:o,width:s,height:c}=i;this.#r._uiManager.editComment(this.#r,a+n*s,o+r*c,{...e,parentDimensions:i})}finish(){this.#t&&(this.#t.focus({focusVisible:this.#n}),this.#n=!1)}isDeleted(){return this.#c||this.#o===``}isEmpty(){return this.#o===null}hasBeenEdited(){return this.isDeleted()||this.#o!==this.#i}serialize(){return this.data}get data(){return{text:this.#o,richText:this.#a,date:this.#s,deleted:this.isDeleted()}}set data(e){if(e!==this.#o&&(this.#a=null),e===null){this.#o=``,this.#c=!0;return}this.#o=e,this.#s=new Date,this.#c=!1}restoreData({text:e,richText:t,date:n}){this.#o=e,this.#a=t,this.#s=n,this.#c=!1}setInitialText(e,t=null){this.#i=e,this.data=e,this.#s=null,this.#a=t}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#o=``,this.#a=null,this.#s=null,this.#r=null,this.#n=!1,this.#c=!1}},B3=class e{#e;#t=!1;#n=null;#r;#i;#a;#o;#s=null;#c;#l=null;#u;#d=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#u=new AbortController,this.#c=AbortSignal.any([o,this.#u.signal]),e.addEventListener(`touchstart`,this.#f.bind(this),{passive:!1,signal:this.#c})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/m3.pixelRatio}#f(e){if(this.#r?.())return;if(e.touches.length===1){if(this.#s)return;let e=this.#s=new AbortController,t=AbortSignal.any([this.#c,e.signal]),n=this.#e,r={capture:!0,signal:t,passive:!1},i=e=>{e.pointerType===`touch`&&(this.#s?.abort(),this.#s=null)};n.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(o3(e),i(e))},r),n.addEventListener(`pointerup`,i,r),n.addEventListener(`pointercancel`,i,r);return}if(!this.#d){this.#d=new AbortController;let e=AbortSignal.any([this.#c,this.#d.signal]),t=this.#e,n={signal:e,capture:!1,passive:!1};t.addEventListener(`touchmove`,this.#p.bind(this),n);let r=this.#m.bind(this);t.addEventListener(`touchend`,r,n),t.addEventListener(`touchcancel`,r,n),n.capture=!0,t.addEventListener(`pointerdown`,o3,n),t.addEventListener(`pointermove`,o3,n),t.addEventListener(`pointercancel`,o3,n),t.addEventListener(`pointerup`,o3,n),this.#i?.()}if(o3(e),e.touches.length!==2||this.#n?.()){this.#l=null;return}let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#l={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#p(t){if(!this.#l||t.touches.length!==2)return;o3(t);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=this.#l,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!this.#t&&Math.abs(v-_)<=e.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,!this.#t){this.#t=!0;return}let y=[(i+o)/2,(a+s)/2];this.#a?.(y,v,_)}#m(e){e.touches.length>=2||(this.#d&&(this.#d.abort(),this.#d=null,this.#o?.()),this.#l&&(o3(e),this.#l=null,this.#t=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#s?.abort(),this.#s=null}},V3=class e{#e=null;#t=null;#n=null;#r=null;#i=null;#a=!1;#o=null;#s=``;#c=null;#l=null;#u=null;#d=null;#f=null;#p=``;#m=!1;#h=null;#g=!1;#_=!1;#v=!1;#y=null;#b=0;#x=0;#S=null;#C=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;#w=!1;#T=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new I3;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=L3.TRANSLATE_SMALL,r=L3.TRANSLATE_BIG;return C4(this,`_resizerKeyboardManager`,new F3([[[`ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`],e.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:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,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 C4(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new H3({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._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`}),e._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`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){_4(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#w}set _isDraggable(e){this.#w=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}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.#T}setParent(e){e===null?(this.#W(),this.#d?.remove(),this.#d=null):(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r),this._onTranslated()}#E([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#E(this.parentDimensions,e,t)}translateInPage(e,t){this.#h||=[this.x,this.y,this.width,this.height],this.#E(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){this.#h||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=W4(i,0,n-o),a=W4(a,0,r-s);break;case 90:i=W4(i,0,n-s),a=W4(a,o,r);break;case 180:i=W4(i,o,n),a=W4(a,s,r);break;case 270:i=W4(i,s,n),a=W4(a,0,r-o)}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#D(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#D(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#D(t,n,360-this.parentRotation)}#O(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,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,n]}=this;return[t*e,n*e]}setDims(){let{div:{style:e},width:t,height:n}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*n).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#k(){if(this.#c)return;this.#c=document.createElement(`div`),this.#c.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 n of e){let e=document.createElement(`div`);this.#c.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#A.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,a3,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#c)}#A(e,t){t.preventDefault();let{isMac:n}=N4.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#l=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#N.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,o3,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,a3,{signal:a}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#M()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#j(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#M(){if(!this.#u)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#u;this.#u=null;let i=this.x,a=this.y,o=this.width,s=this.height;(i!==e||a!==t||o!==n||s!==r)&&this.addCommands({cmd:this.#j.bind(this,i,a,o,s),undo:this.#j.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#N(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#O(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#O(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2]}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#l;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#l[0]=e,this.#l[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=W4(Math.abs(b[0]-y[0]-E),l,1)/s:T=W4(Math.abs(b[1]-y[1]-D),u,1)/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#_)return this._editToolbar;this._editToolbar=new D3(this),this.div.append(this._editToolbar.render());let{toolbarButtons:e}=this;if(e)for(let[t,n]of e)await this._editToolbar.addButton(t,n);return this.hasComment||this._editToolbar.addButton(`comment`,this.addCommentButton()),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.#n?.destroy()}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(R3.initialize(e._l10n),this.#n=new R3(this),this.#e&&=(this.#n.data=this.#e,null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}focusCommentButton(){this.#r?.focusButton()}addCommentButton(){return this.canAddComment?this.#r||=new z3(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove(`hidden`);return}this.hasComment&&(this.#i=this.#r.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#r.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add(`hidden`)}get comment(){if(!this.#r)return null;let{data:{richText:e,text:t,date:n,deleted:r}}=this.#r;return{text:t,richText:e,date:n,deleted:r,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){this.#r||=new z3(this),typeof e==`object`&&e?this.#r.restoreData(e):this.#r.data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:n}){if(!t||(this.#r||=new z3(this),this.#r.setInitialText(e,n),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){return this.#r?.hasBeenEdited()}get hasDeletedComment(){return this.#r?.isDeleted()}get hasComment(){return!!this.#r&&!this.#r.isEmpty()&&!this.#r.isDeleted()}async editComment(e){this.#r||=new z3(this),this.#r.edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){this.#r.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,t]=e.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,i=r+n+1,a=t-100,o=i+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[i,a,o,t]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){this.#r.data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let e=this.div=document.createElement(`div`);e.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),e.className=this.name,e.setAttribute(`id`,this.id),e.tabIndex=this.#a?-1:0,e.setAttribute(`role`,`application`),this.defaultL10nId&&e.setAttribute(`data-l10n-id`,this.defaultL10nId),this._isVisible||e.classList.add(`hidden`),this.setInForeground(),this.#z();let[t,n]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*n/t).toFixed(2)}%`,e.style.maxHeight=`${(100*t/n).toFixed(2)}%`);let[r,i]=this.getInitialTranslation();return this.translate(r,i),A3(this,e,[`keydown`,`pointerdown`,`dblclick`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#C||=new B3({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#P.bind(this),onPinching:this.#F.bind(this),onPinchEnd:this.#I.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#P(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#F(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#O(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#h||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#I(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#M()}pointerdown(e){let{isMac:t}=N4.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#R(e);return}this.#L(e)}#L(e){let{isMac:t}=N4.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#R(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#o=null,this.#m=!1,this._uiManager.endDragSession()||this.#L(e),n&&this._onStopDragging()};t&&(this.#b=e.clientX,this.#x=e.clientY,this.#o=e.pointerId,this.#s=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#o){o3(e);return}let[a,o]=this.screenToPageTranslation(t-this.#b,r-this.#x);this.#b=t,this.#x=r,this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,o3,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#s&&(this.#C||e.isPrimary)&&o(e),o3(e)},a));let s=e=>{if(!this.#o||this.#o===e.pointerId){o(e);return}o3(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&e._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#r?.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:n,opacity:r,deleted:i,richText:a},uid:o,pageIndex:s,creationDate:c,modificationDate:l}=this;return{id:o,pageIndex:s,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:c,modificationDate:n||l,popupRef:!i,color:t,opacity:r}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#_=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#_=!1,!0):!1}isInEditMode(){return this.#_}shouldGetKeyboardEvents(){return this.#v}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}#z(){if(this.#f||!this.div)return;this.#f=new AbortController;let e=this._uiManager.combinedSignal(this.#f);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}rebuild(){this.#z()}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,n){let r=new this.prototype.constructor({parent:t,id:n.getId(),uiManager:n,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});r.rotation=e.rotation,r.#e=e.accessibilityData,r._isCopy=e.isCopy||!1;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#y&&=(clearTimeout(this.#y),null),this.#W(),this.removeEditToolbar(),this.#S){for(let e of this.#S.values())clearTimeout(e);this.#S=null}this.parent=null,this.#C?.destroy(),this.#C=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#k(),this.#c.classList.remove(`hidden`))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction===`ltr`?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,n]}=this,[r,i,a,o]=this.getPDFRect();return[e._round(r+(a-r)*t),e._round(i+(o-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#r.commentPopupPositionInLayer}set commentPopupPosition(e){this.#r.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#r.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#r.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#r?.setCommentButtonStates(e)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#c.children;if(!this.#t){this.#t=Array.from(n);let t=this.#B.bind(this),r=this.#V.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#H.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)this.#c.append(this.#c.firstElementChild);else if(a>i)for(let e=0;e<a-i;e++)this.#c.firstElementChild.before(this.#c.lastElementChild);let t=0;for(let r of n){let n=this.#t[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}this.#U(0),this.#v=!0,this.#c.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#B(t){e._resizerKeyboardManager.exec(this,t)}#V(e){this.#v&&e.relatedTarget?.parentNode!==this.#c&&this.#W()}#H(e){this.#p=this.#v?e:``}#U(e){if(this.#t)for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#v&&this.#N(this.#p,{deltaX:e,deltaY:t,fromKeyboard:!0})}#W(){this.#v=!1,this.#U(-1),this.#M()}_stopResizingWithKeyboard(){this.#W(),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(()=>{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#c?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!==`BUTTON`&&(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.#g}set isEditing(e){this.#g=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#S||=new Map;let{action:n}=t,r=this.#S.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},e._telemetryTimeout),this.#S.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(e){if(!this.#d&&!this.deleted){this.#d=e.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.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 e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},H3=class extends V3{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},U3=3285377520,W3=4294901760,G3=65535,K3=class{constructor(e){this.h1=e?e&4294967295:U3,this.h2=e?e&4294967295:U3}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&W3|o*f&G3,o=o<<15|o>>>17,o=o*d&W3|o*p&G3,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&W3|s*f&G3,s=s<<15|s>>>17,s=s*d&W3|s*p&G3,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&W3|o*f&G3,o=o<<15|o>>>17,o=o*d&W3|o*p&G3,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&W3|e*36045&G3,t=t*4283543511&W3|((t<<16|e>>>16)*2950163797&W3)>>>16,e^=t>>>1,e=e*444984403&W3|e*60499&G3,t=t*3301882366&W3|((t<<16|e>>>16)*3120437893&W3)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},q3=Object.freeze({map:null,hash:``,transfer:void 0}),J3=class{#e=!1;#t=null;#n=null;#r=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,t){let n=this.#r.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#r.get(e)}remove(e){let t=this.#r.get(e);t!==void 0&&(t instanceof V3&&this.#n.delete(t.annotationElementId),this.#r.delete(e),this.#r.size===0&&this.resetModified(),!this.#r.values().some(e=>e instanceof V3)&&this.onAnnotationEditor?.(null))}setValue(e,t){let n=this.#r.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#r.set(e,t);r&&this.#i(),t instanceof V3&&((this.#n||=new Map).set(t.annotationElementId,t),this.onAnnotationEditor?.(t.constructor._type))}has(e){return this.#r.has(e)}get size(){return this.#r.size}#i(){this.#e||(this.#e=!0,this.onSetModified?.())}resetModified(){this.#e&&(this.#e=!1,this.onResetModified?.())}get print(){return new Y3(this)}get serializable(){if(this.#r.size===0)return q3;let e=new Map,t=new K3,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#r){let o=a instanceof V3?a.serialize(!1,r):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:q3}get editorStats(){let e=null,t=new Map,n=0,r=0;for(let i of this.#r.values()){if(!(i instanceof V3)){i.popup&&(i.popup.deleted?r+=1:n+=1);continue}i.isCommentDeleted?r+=1:i.hasEditedComment&&(n+=1);let a=i.telemetryFinalData;if(!a)continue;let{type:o}=a;t.getOrInsertComputed(o,()=>Object.getPrototypeOf(i).constructor),e||=Object.create(null);let s=e[o]||=new Map;for(let[e,t]of Object.entries(a)){if(e===`type`)continue;let n=s.getOrInsertComputed(e,V4);n.set(t,(n.get(t)??0)+1)}}if((r>0||n>0)&&(e||=Object.create(null),e.comments={deleted:r,edited:n}),!e)return null;for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,t){let n=this.#n?.get(e);return n?(n.updateFromAnnotationLayer(t),!0):!1}getEditor(e){return this.#n?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;let e=[];if(this.#n)for(let t of this.#n.values())t.serialize()&&e.push(t.annotationElementId);let t=``;if(e.length){let n=new K3;n.update(e.join(`,`)),t=n.hexdigest()}return this.#t={ids:new Set(e),hash:t}}[Symbol.iterator](){return this.#r.entries()}},Y3=class extends J3{#e=q3;constructor(e){super();let{serializable:t}=e;if(t===q3)return;let{map:n,hash:r,transfer:i}=t,a=structuredClone(n,i?{transfer:i}:null);this.#e={map:a,hash:r,transfer:[]}}get print(){_4(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return C4(this,`modifiedIds`,{ids:new Set,hash:``})}},X3=`__forcedDependency`,{floor:Z3,ceil:Q3}=Math;function $3(e,t,n,r,i,a){e[t*4+0]=Math.min(e[t*4+0],n),e[t*4+1]=Math.min(e[t*4+1],r),e[t*4+2]=Math.max(e[t*4+2],i),e[t*4+3]=Math.max(e[t*4+3],a)}function e6(e,t,n,r,i){let a;e?(e<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=e,i[2]*=e,t<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=n,i[1]+=r,i[2]+=n,i[3]+=r}var t6=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],n6=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===t6}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}},r6=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),i6=class{#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#n=new Float64Array(q2);_pendingBBoxIdx=-1;#r;#i;#a;#o;_savesStack=[];_markedContentStack=[];constructor(e,t){this.#r=e.width,this.#i=e.height,this.#s(t)}growOperationsCount(e){e>=this.#o.length&&this.#s(e,this.#o)}#s(e,t){let n=new ArrayBuffer(e*4);this.#a=new Uint8ClampedArray(n),this.#o=new Uint32Array(n),t&&t.length>0?(this.#o.set(t),this.#o.fill(t6,t.length)):this.#o.fill(t6)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,t){let n=Object.getPrototypeOf(this.#t);if(n===null)return this;this.#t=n;let r=this._savesStack.pop();return r!==void 0&&(t?.(r,e),this.#o[e]=this.#o[r]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){let n=this._savesStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let n=this._markedContentStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}pushBaseTransform(e){return this.#e.push($.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){return this.#e.length>1&&this.#e.pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,this.#n.set(q2,0)),this}recordClipBox(e,t,n,r,i,a){let o=$.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform()),s=q2.slice();$.axialAlignedBoundingBox([n,i,r,a],o,s);let c=$.intersect(this.#t,s);return c?(this.#t[0]=c[0],this.#t[1]=c[1],this.#t[2]=c[2],this.#t[3]=c[3]):(this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0),this}recordBBox(e,t,n,r,i,a){let o=this.#t;if(o[0]===1/0)return this;let s=$.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform());if(o[0]===-1/0)return $.axialAlignedBoundingBox([n,i,r,a],s,this.#n),this;let c=q2.slice();return $.axialAlignedBoundingBox([n,i,r,a],s,c),this.#n[0]=W4(c[0],o[0],this.#n[0]),this.#n[1]=W4(c[1],o[1],this.#n[1]),this.#n[2]=W4(c[2],this.#n[2],o[2]),this.#n[3]=W4(c[3],this.#n[3],o[3]),this}recordFullPageBBox(e){return this.#n[0]=Math.max(0,this.#t[0]),this.#n[1]=Math.max(0,this.#t[1]),this.#n[2]=Math.min(this.#r,this.#t[2]),this.#n[3]=Math.min(this.#i,this.#t[3]),this}recordOperation(e,t=!1,n){if(this._pendingBBoxIdx!==e)return this;let r=Z3(this.#n[0]*256/this.#r),i=Z3(this.#n[1]*256/this.#i),a=Q3(this.#n[2]*256/this.#r),o=Q3(this.#n[3]*256/this.#i);if($3(this.#a,e,r,i,a,o),n)for(let t of n)for(let n of t)n!==e&&$3(this.#a,n,r,i,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#n[0]),this.#t[1]=Math.max(this.#t[1],this.#n[1]),this.#t[2]=Math.min(this.#t[2],this.#n[2]),this.#t[3]=Math.min(this.#t[3],this.#n[3])),this}take(){return new n6(this.#o,this.#a)}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,n){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}},a6=class{#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[X3]:[]};#n=new Map;#r=new Set;#i=new Map;#a;#o;#s;constructor(e,t=!1){this.#s=e,t&&(this.#a=new Map,this.#o=(e,t)=>{r6(this.#a,t).dependencies.add(e)})}get clipBox(){return this.#s.clipBox}growOperationsCount(e){this.#s.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},[X3]:{__proto__:this.#t[X3]}},this.#s.save(e),this}restore(e){this.#s.restore(e,this.#o);let t=Object.getPrototypeOf(this.#e);return t===null?this:(this.#e=t,this.#t=Object.getPrototypeOf(this.#t),this)}recordOpenMarker(e){return this.#s.recordOpenMarker(e,this.#o),this}getOpenMarker(){return this.#s.getOpenMarker()}recordCloseMarker(e){return this.#s.recordCloseMarker(e,this.#o),this}beginMarkedContent(e){return this.#s.beginMarkedContent(e),this}endMarkedContent(e){return this.#s.endMarkedContent(e,this.#o),this}pushBaseTransform(e){return this.#s.pushBaseTransform(e),this}popBaseTransform(){return this.#s.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.#n.set(e,t),this}recordSimpleDataFromNamed(e,t,n){this.#e[e]=this.#n.get(t)??n}recordFutureForcedDependency(e,t){return this.recordIncrementalData(X3,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)t in this.#e&&this.recordFutureForcedDependency(t,this.#e[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of this.#r)this.recordFutureForcedDependency(X3,e);return this}resetBBox(e){return this.#s.resetBBox(e),this}recordClipBox(e,t,n,r,i,a){return this.#s.recordClipBox(e,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#s.recordBBox(e,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){let s=n.bbox,c,l;if(s&&(c=s[2]!==s[0]&&s[3]!==s[1]&&this.#i.get(n),c!==!1&&(l=[0,0,0,0],$.axialAlignedBoundingBox(s,n.fontMatrix,l),(r!==1||i!==0||a!==0)&&e6(r,-r,i,a,l),c)))return this.recordBBox(e,t,l[0],l[2],l[1],l[3]);if(!o)return this.recordFullPageBBox(e);let u=o();return s&&l&&c===void 0&&(c=l[0]<=i-u.actualBoundingBoxLeft&&l[2]>=i+u.actualBoundingBoxRight&&l[1]<=a-u.actualBoundingBoxAscent&&l[3]>=a+u.actualBoundingBoxDescent,this.#i.set(n,c),c)?this.recordBBox(e,t,l[0],l[2],l[1],l[3]):this.recordBBox(e,t,i-u.actualBoundingBoxLeft,i+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#s.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,t){let n=this.#r,r=this.#e,i=this.#t;for(let e of t)e in this.#e?n.add(r[e]):e in i&&i[e].forEach(n.add,n);return this}recordNamedDependency(e,t){return this.#n.has(t)&&this.#r.add(this.#n.get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[X3]),this.#a){let t=r6(this.#a,e),{dependencies:n}=t;this.#r.forEach(n.add,n),this.#s._savesStack.forEach(n.add,n),this.#s._markedContentStack.forEach(n.add,n),n.delete(e),t.isRenderingOperation=!0}let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.recordOperation(e,t,[this.#r,this.#s._savesStack,this.#s._markedContentStack]),n&&this.#r.clear(),this}recordShowTextOperation(e,t=!1){let n=Array.from(this.#r);this.recordOperation(e,t),this.recordIncrementalData(`sameLineText`,e);for(let e of n)this.recordIncrementalData(`sameLineText`,e);return this}bboxToClipBoxDropOperation(e,t=!1){let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.bboxToClipBoxDropOperation(e),n&&this.#r.clear(),this}take(){return this.#i.clear(),this.#s.take()}takeDebugMetadata(){return this.#a}},o6=class e{#e;#t;#n;#r=0;#i=0;constructor(t,n,r){if(t instanceof e&&t.#n===!!r)return t;this.#e=t,this.#t=n,this.#n=!!r}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw Error(`Unreachable`)}save(e){return this.#i++,this.#e.save(this.#t),this}restore(e){return this.#i>0&&(this.#e.restore(this.#t),this.#i--),this}recordOpenMarker(e){return this.#r++,this}getOpenMarker(){return this.#r>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#r--,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,n){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){return this.#n||this.#e.resetBBox(this.#t),this}recordClipBox(e,t,n,r,i,a){return this.#n||this.#e.recordClipBox(this.#t,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#n||this.#e.recordBBox(this.#t,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r,i,a,o){return this.#n||this.#e.recordCharacterBBox(this.#t,t,n,r,i,a,o),this}recordFullPageBBox(e){return this.#n||this.#e.recordFullPageBBox(this.#t),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){return this.#n||this.#e.bboxToClipBoxDropOperation(this.#t,!0),this}take(){throw Error(`Unreachable`)}takeDebugMetadata(){throw Error(`Unreachable`)}},s6={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`]},c6=class e{#e;#t;#n=4;#r=0;#i=new e.#a(this.#n*6);static#a=N4.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(t,n,r,i){if(this.#r===this.#n){this.#n*=2;let t=new e.#a(this.#n*6);t.set(this.#i),this.#i=t}let a=d3(t),o;if(i[0]!==1/0){let e=q2.slice();$.axialAlignedBoundingBox([0,-r,n,0],a,e);let t=$.intersect(i,e);if(!t)return;let[s,c,l,u]=t;if(s!==e[0]||c!==e[1]||l!==e[2]||u!==e[3]){let e=Math.atan2(a[1],a[0]),t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e));if(t<1e-6||n<1e-6||Math.abs(t-n)<1e-6)o=[s,c,s,u,l,c];else{let e=l-s,r=u-c,i=t*t,a=n*n,d=n*t,f=a-i,p=(r*a-e*d)/f;o=[s+(r*d-e*i)/f,c,s,c+p,l,u-p]}}}o||(o=[0,-r,0,0,n,-r],$.applyTransform(o,a,0),$.applyTransform(o,a,2),$.applyTransform(o,a,4)),o[0]/=this.#e,o[1]/=this.#t,o[2]/=this.#e,o[3]/=this.#t,o[4]/=this.#e,o[5]/=this.#t,this.#i.set(o,this.#r*6),this.#r++}take(){return this.#i.subarray(0,this.#r*6)}},l6=class{#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.#n();t.insertRule(e,t.cssRules.length)}#n(){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 n=new e;return t.push(n),this.#t=n}}return this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement)),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;e?.includes(this.#t)&&(this._document.adoptedStyleSheets=e.filter(e=>e!==this.#t)),this.#t=null}this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:n}){if(!(!e||this.#e.has(e.loadedName))){if(v4(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:t,src:r,style:i}=e,a=new FontFace(t,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(t),n?.(e)}catch{g4(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}_4(`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 t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw g4(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return C4(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){return C4(this,`isSyncFontLoadingSupported`,K2||N4.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(v4(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return C4(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function i(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let a,o,s=this._document.createElement(`canvas`);s.width=1,s.height=1;let c=s.getContext(`2d`),l=0;function u(e,t){if(++l>30){g4(`Load test font never loaded.`),t();return}if(c.font=`30px `+e,c.fillText(`.`,0,20),c.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(u.bind(null,e,t))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let p=1482184792,m=n(f,16);for(a=0,o=d.length-3;a<o;a+=4)m=m-p+n(d,a)|0;a<d.length&&(m=m-p+n(d+`XXX`,a)|0),f=i(f,16,4,r(m));let h=`@font-face {font-family:"${d}";src:${`url(data:font/opentype;base64,${btoa(f)});`}}`;this.insertRule(h);let g=this._document.createElement(`div`);g.style.visibility=`hidden`,g.style.width=g.style.height=`10px`,g.style.position=`absolute`,g.style.top=g.style.left=`0px`;for(let t of[e.loadedName,d]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,g.append(e)}this._document.body.append(g),u(d,()=>{g.remove(),t.complete()})}},u6=class{compiledGlyphs=Object.create(null);#e;constructor(e,t=null,n,r){this.#e=e,this._inspectFont=t,n&&(this.charProcOperatorList=n),r&&Object.assign(this,r)}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};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 n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){g4(`getPathGenerator - ignoring character: "${e}".`)}let i=E3(r?.path);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){C4(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}},d6=class{static strings=[`fontFamily`,`fontWeight`,`italicAngle`]},f6=class{static strings=[`css`,`loadedName`,`baseFontName`,`src`]},p6=class{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},m6=class{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},h6=class{#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}#r(e){v4(e<d6.strings.length,`Invalid string index`);let t=0;for(let n=0;n<e;n++)t+=this.#n.getUint32(t)+4;let n=this.#n.getUint32(t);return this.#t.decode(new Uint8Array(this.#e,t+4,n))}get fontFamily(){return this.#r(0)}get fontWeight(){return this.#r(1)}get italicAngle(){return this.#r(2)}},g6=class{#e;#t=new TextDecoder;#n;constructor(e){this.#e=e,this.#n=new DataView(e)}get guessFallback(){return this.#n.getUint8(0)!==0}#r(e){v4(e<f6.strings.length,`Invalid string index`);let t=5;for(let n=0;n<e;n++)t+=this.#n.getUint32(t)+4;let n=this.#n.getUint32(t);return this.#t.decode(new Uint8Array(this.#e,t+4,n))}get css(){return this.#r(0)}get loadedName(){return this.#r(1)}get baseFontName(){return this.#r(2)}get src(){return this.#r(3)}get style(){let e=1;e+=4+this.#n.getUint32(e);let t=this.#n.getUint32(e),n=this.#t.decode(new Uint8Array(this.#e,e+4,t));e+=4+t;let r=this.#n.getUint32(e);return{style:n,weight:this.#t.decode(new Uint8Array(this.#e,e+4,r))}}},_6=class{#e;#t=new TextDecoder;#n;constructor({buffer:e,extra:t}){this.#e=e,this.#n=new DataView(e),t&&Object.assign(this,t)}#r(e){v4(e<p6.bools.length,`Invalid boolean index`);let t=Math.floor(e/4),n=e*2%8,r=this.#n.getUint8(t)>>n&3;return r===0?void 0:r===2}get black(){return this.#r(0)}get bold(){return this.#r(1)}get disableFontFace(){return this.#r(2)}get fontExtraProperties(){return this.#r(3)}get isInvalidPDFjsFont(){return this.#r(4)}get isType3Font(){return this.#r(5)}get italic(){return this.#r(6)}get missingFile(){return this.#r(7)}get remeasure(){return this.#r(8)}get vertical(){return this.#r(9)}#i(e){return v4(e<p6.numbers.length,`Invalid number index`),this.#n.getFloat64(p6.OFFSET_NUMBERS+e*8)}get ascent(){return this.#i(0)}get defaultWidth(){return this.#i(1)}get descent(){return this.#i(2)}#a(e,t,n,r){let i=this.#n.getUint8(e);if(i===0)return;v4(i===t,`Invalid array length.`),e+=1;let a=Array(i);for(let t=0;t<i;t++)a[t]=this.#n[n](e,!0),e+=r;return a}get bbox(){return this.#a(p6.OFFSET_BBOX,4,`getInt16`,2)}get fontMatrix(){return this.#a(p6.OFFSET_FONT_MATRIX,6,`getFloat64`,8)}get defaultVMetrics(){return this.#a(p6.OFFSET_DEFAULT_VMETRICS,3,`getInt16`,2)}#o(e){v4(e<p6.strings.length,`Invalid string index`);let t=p6.OFFSET_STRINGS+4;for(let n=0;n<e;n++)t+=this.#n.getUint32(t)+4;let n=this.#n.getUint32(t);return this.#t.decode(new Uint8Array(this.#e,t+4,n))}get fallbackName(){return this.#o(0)}get loadedName(){return this.#o(1)}get mimetype(){return this.#o(2)}get name(){return this.#o(3)}#s(){let e=p6.OFFSET_STRINGS,t=this.#n.getUint32(e);e+=4+t;let n=this.#n.getUint32(e);e+=4+n;let r=this.#n.getUint32(e);e+=4+r;let i=this.#n.getUint32(e);return{offset:e,length:i}}get data(){let{offset:e,length:t}=this.#s();return t===0?void 0:new Uint8Array(this.#e,e+4,t)}clearData(){let{offset:e,length:t}=this.#s();t!==0&&(this.#n.setUint32(e,0),this.#e=new Uint8Array(this.#e,0,e+4).slice().buffer,this.#n=new DataView(this.#e))}get cssFontInfo(){let e=p6.OFFSET_STRINGS,t=this.#n.getUint32(e);e+=4+t;let n=this.#n.getUint32(e);e+=4+n;let r=this.#n.getUint32(e);if(r===0)return null;let i=new Uint8Array(r);return i.set(new Uint8Array(this.#e,e+4,r)),new h6(i.buffer)}get systemFontInfo(){let e=p6.OFFSET_STRINGS,t=this.#n.getUint32(e);e+=4+t;let n=this.#n.getUint32(e);if(n===0)return null;let r=new Uint8Array(n);return r.set(new Uint8Array(this.#e,e+4,n)),new g6(r.buffer)}},v6=class{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){let e=this.view,t=this.data[m6.KIND],n=!!this.data[m6.HAS_BBOX],r=!!this.data[m6.HAS_BACKGROUND],i=e.getUint32(m6.N_COORD,!0),a=e.getUint32(m6.N_COLOR,!0),o=e.getUint32(m6.N_STOP,!0),s=20,c=new Float32Array(this.buffer,s,i*2);s+=i*8;let l=new Uint8Array(this.buffer,s,a*4);s+=a*4;let u=[];for(let t=0;t<o;++t){let t=e.getFloat32(s,!0);s+=4;let n=e.getUint32(s,!0);s+=4,u.push([t,`#${n.toString(16).padStart(6,`0`)}`])}let d=null;if(n){d=[];for(let t=0;t<4;++t)d.push(e.getFloat32(s,!0)),s+=4}let f=null;if(r&&(f=new Uint8Array(this.buffer,s,3),s+=3),t===1)return[`RadialAxial`,`axial`,d,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(t===2)return[`RadialAxial`,`radial`,d,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(t===3){let e=this.data[m6.SHADING_TYPE],t=null;if(c.length>0){t=q2.slice();for(let e=0,n=c.length;e<n;e+=2)$.pointBoundingBox(c[e],c[e+1],t)}return[`Mesh`,e,c,l,i,t,d,f]}throw Error(`Unsupported pattern kind: ${t}`)}},y6=class{#e;constructor(e){this.#e=e}get path(){return N4.isFloat16ArraySupported?new Float16Array(this.#e):new Float32Array(this.#e)}};function b6(e){if(e instanceof URL)return e;if(typeof e==`string`){if(K2){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);let n=t.getBuiltinModule(`url`);return new URL(n.pathToFileURL(e))}let n=URL.parse(e,window.location);if(n)return n}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function x6(e){if(K2&&G2!==void 0&&e instanceof G2)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 M4(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 S6(e){if(typeof e!=`string`)return null;if(e.endsWith(`/`))return e;throw Error(`Invalid factory url: "${e}" must include trailing slash.`)}var C6=e=>typeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,w6=z4.bind(null,C6,e=>typeof e==`object`&&typeof e?.name==`string`),T6=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){g4("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},E6={DATA:1,ERROR:2},D6={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function O6(){}function k6(e){if(e instanceof A4||e instanceof D4||e instanceof T4||e instanceof O4||e instanceof E4)return e;switch(e instanceof Error||typeof e==`object`&&e||_4(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new A4(e.message);case`InvalidPDFException`:return new D4(e.message);case`PasswordException`:return new T4(e.message,e.code);case`ResponseException`:return new O4(e.message,e.status,e.missing);case`UnknownErrorException`:return new E4(e.message,e.details)}return new E4(e.message,e.toString())}var A6=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,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),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===E6.DATA)n.resolve(e.data);else if(e.callback===E6.ERROR)n.reject(k6(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 n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:E6.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:E6.ERROR,callbackId:e.callbackId,reason:k6(t)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:D6.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{v4(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:D6.CANCEL,streamId:i,reason:k6(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:D6.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:D6.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){v4(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:D6.ERROR,streamId:t,reason:k6(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:D6.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:D6.START_COMPLETE,streamId:t,reason:k6(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case D6.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(k6(e.reason));break;case D6.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(k6(e.reason));break;case D6.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:D6.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||O6).then(function(){i.postMessage({sourceName:n,targetName:r,stream:D6.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:D6.PULL_COMPLETE,streamId:t,reason:k6(e)})});break;case D6.ENQUEUE:if(v4(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case D6.CLOSE:if(v4(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case D6.ERROR:v4(a,`error should have stream controller`),a.controller.error(k6(e.reason)),this.#i(a,t);break;case D6.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(k6(e.reason)),this.#i(a,t);break;case D6.CANCEL:if(!o)break;let s=k6(e.reason);Promise.try(o.onCancel||O6,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:D6.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:D6.CANCEL_COMPLETE,streamId:t,reason:k6(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(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}},j6=class{#e=Object.freeze({cMapUrl:`CMap`,standardFontDataUrl:`font`,wasmUrl:`wasm`});constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:n=null}){this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=n}async fetch({kind:e,filename:t}){switch(e){case`cMapUrl`:case`standardFontDataUrl`:case`wasmUrl`:break;default:_4(`Not implemented: ${e}`)}let n=this[e];if(!n)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let r=`${n}${t}`;return this._fetch(r,e).catch(t=>{throw Error(`Unable to load ${this.#e[e]} data at: ${r}`)})}async _fetch(e,t){_4("Abstract method `_fetch` called.")}},M6=class extends j6{async _fetch(e,t){let n=await Z4(e,t===`cMapUrl`&&!e.endsWith(`.bcmap`)?`text`:`bytes`);return n instanceof Uint8Array?n:M4(n)}},N6=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset({canvas:e},t,n){if(!e)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.width=t,e.height=n}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){_4("Abstract method `_createCanvas` called.")}},P6=class extends N6{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},F6=class{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,n,r,i){return`none`}addSelectionHCMFilter(e,t){return`none`}addSelectionFilter(){return`none`}createSelectionStyle(e=null){return null}destroy(e=!1){}},I6=class extends F6{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=new Map}get#c(){return this.#a||=new Map}get#l(){if(!this.#n){let e=this.#i.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 n=this.#i.createElementNS(X2,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(X2,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&($4(e)?g4(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=x4(e,``))}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=$.makeHexColor(...a);let o=this.#v(t);if(t=$.makeHexColor(...o),this.#b(),e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array(256);for(let e=0;e<=255;e++){let t=e/255;s[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let c=s.join(`,`),l=`g_${this.#r}_hcm_filter`,u=i.filter=this.#m(l);this.#g(c,c,c,u),this.#p(u);let d=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(d(0,5),d(1,5),d(2,5),u),i.url=this.#d(l),i.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();return t===`none`||!N4.platform.isFirefox?null:{"backdrop-filter":t,"background-color":`transparent`}}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addKnockoutFilter(e=0){let t=e>0?Math.min(1/e,1e6):1e6,n=`knockout_${t}`,r=this.#s.get(n);if(r)return r;let i=`g_${this.#r}_knockout_filter_${this.#o++}`,a=this.#d(i);this.#s.set(n,a);let o=this.#m(i),s=this.#i.createElementNS(X2,`feComponentTransfer`);o.append(s);let c=this.#i.createElementNS(X2,`feFuncA`);return c.setAttribute(`type`,`linear`),c.setAttribute(`slope`,`${t}`),c.setAttribute(`intercept`,`0`),s.append(c),a}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#x.bind(this));u<l&&([l,u,d,f]=[u,l,f,d]),this.#b();let p=(e,t,n)=>{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(X2,`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)}#p(e){let t=this.#i.createElementNS(X2,`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)}#m(e){let t=this.#i.createElementNS(X2,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(X2,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(X2,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(X2,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,l3(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#y(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,c3(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#b(){this.#l.style.color=``,this.#l.style.backgroundColor=``}#x(e){let[t,n,r,i]=this.#y(e);if(i===1)return[t,n,r];let[a,o,s]=this.#v(`Canvas`);return[L6(t,a,i),L6(n,o,i),L6(r,s,i)]}};function L6(e,t,n){return Math.round(n*e+(1-n)*t)}K2&&g4("Please use the `legacy` build in Node.js environments.");async function R6(e){let n=await t.getBuiltinModule(`fs/promises`).readFile(e);return new Uint8Array(n)}var z6=class extends F6{},B6=class extends N6{_createCanvas(e,n){return t.getBuiltinModule(`module`).createRequire(import.meta.url)(`@napi-rs/canvas`).createCanvas(e,n)}},V6=class extends j6{async _fetch(e,t){return R6(e)}};function H6({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=N4.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=c^l,p=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r<i;++r){for(let r=t+u;t<r;++t,m+=8){let r=e[t];n[m]=c^-(r>>7&1)&f,n[m+1]=c^-(r>>6&1)&f,n[m+2]=c^-(r>>5&1)&f,n[m+3]=c^-(r>>4&1)&f,n[m+4]=c^-(r>>3&1)&f,n[m+5]=c^-(r>>2&1)&f,n[m+6]=c^-(r>>1&1)&f,n[m+7]=c^-(r&1)&f}if(d===0)continue;let r=t<p?e[t++]:255;for(let e=0;e<d;++e,++m)n[m]=c^-(r>>7-e&1)&f}return{srcPos:t,destPos:m}}function U6({src:e,srcPos:t=0,dest:n,destPos:r=0,width:i,height:a}){let o=0,s=i*a*3,c=s>>2,l=new Uint32Array(e.buffer,t,c),u=N4.isLittleEndian?4278190080:255;if(N4.isLittleEndian){for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e>>>24|t<<8|u,n[r+2]=t>>>16|i<<16|u,n[r+3]=i>>>8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]|e[i+1]<<8|e[i+2]<<16|u}else{for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e<<24|t>>>8|u,n[r+2]=t<<16|i>>>16|u,n[r+3]=i<<8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|u}return{srcPos:t+s,destPos:r}}var W6=`
struct Uniforms {
offsetX : f32,
offsetY : f32,
scaleX : f32,
scaleY : f32,
paddedWidth : f32,
paddedHeight : f32,
borderSize : f32,
_pad : f32,
};
@group(0) @binding(0) var<uniform> u : Uniforms;
struct VertexInput {
@location(0) position : vec2<f32>,
@location(1) color : vec4<f32>,
};
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) color : vec3<f32>,
};
@vertex
fn vs_main(in : VertexInput) -> VertexOutput {
var out : VertexOutput;
let cx = (in.position.x + u.offsetX) * u.scaleX;
let cy = (in.position.y + u.offsetY) * u.scaleY;
out.position = vec4<f32>(
((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
0.0,
1.0
);
out.color = in.color.rgb;
return out;
}
@fragment
fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(in.color, 1.0);
}
`,G6=new class{#e=null;#t=null;#n=null;#r=null;async#i(){if(!globalThis.navigator?.gpu)return!1;try{let e=await navigator.gpu.requestAdapter();return e?(this.#r=navigator.gpu.getPreferredCanvasFormat(),this.#t=await e.requestDevice(),!0):!1}catch{return!1}}init(){return this.#e||=this.#i()}get isReady(){return this.#t!==null}loadMeshShader(){if(!this.#t||this.#n)return;let e=this.#t.createShaderModule({code:W6});this.#n=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.#r}]},primitive:{topology:`triangle-list`}})}draw(e,t,n,r,i,a,o,s){this.loadMeshShader();let c=this.#t,{offsetX:l,offsetY:u,scaleX:d,scaleY:f}=r,p=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(p,0,e);let m=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(m,0,t);let h=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(h,0,new Float32Array([l,u,d,f,a,o,s,0]));let g=c.createBindGroup({layout:this.#n.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:h}}]}),_=new OffscreenCanvas(a,o),v=_.getContext(`webgpu`);v.configure({device:c,format:this.#r,alphaMode:i?`opaque`:`premultiplied`});let y=i?{r:i[0]/255,g:i[1]/255,b:i[2]/255,a:1}:{r:0,g:0,b:0,a:0},b=c.createCommandEncoder(),x=b.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:y,loadOp:`clear`,storeOp:`store`}]});return n>0&&(x.setPipeline(this.#n),x.setBindGroup(0,g),x.setVertexBuffer(0,p),x.setVertexBuffer(1,m),x.draw(n)),x.end(),c.queue.submit([b.finish()]),p.destroy(),m.destroy(),h.destroy(),_.transferToImageBitmap()}};function K6(){return G6.init()}function q6(){return G6.isReady}function J6(){G6.loadMeshShader()}function Y6(e,t,n,r,i,a,o,s){return G6.draw(e,t,n,r,i,a,o,s)}var X6={FILL:`Fill`,STROKE:`Stroke`,SHADING:`Shading`};function Z6(e,t){if(!t)return;let n=t[2]-t[0],r=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],n,r),e.clip(i)}var Q6=class{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){_4("Abstract method `getPattern` called.")}},$6=class extends Q6{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]}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 n,r=this._p0,i=this._p1;if(t&&(r=r.slice(),i=i.slice(),$.applyTransform(r,t),$.applyTransform(i,t)),this._type===`axial`)n=e.createLinearGradient(r[0],r[1],i[0],i[1]);else if(this._type===`radial`){let a=this._r0,o=this._r1;if(t){let e=new Float32Array(2);$.singularValueDecompose2dScale(t,e),a*=e[0],o*=e[0]}n=e.createRadialGradient(r[0],r[1],a,i[0],i[1],o)}for(let e of this._colorStops)n.addColorStop(e[0],e[1]);return n}_createReversedGradient(e,t=null){let n=this._p1,r=this._p0;t&&(n=n.slice(),r=r.slice(),$.applyTransform(n,t),$.applyTransform(r,t));let i=this._r1,a=this._r0;if(t){let e=new Float32Array(2);$.singularValueDecompose2dScale(t,e),i*=e[0],a*=e[0]}let o=e.createRadialGradient(n[0],n[1],i,r[0],r[1],a),s=this._colorStops.map(([e,t])=>[1-e,t]).reverse();for(let[e,t]of s)o.addColorStop(e,t);return o}getPattern(e,t,n,r){let i;if(r===X6.STROKE||r===X6.FILL){if(this.isOriginBased()){let r=$.transform(n,t.baseTransform);this.matrix&&(r=$.transform(r,this.matrix));let i=.001,a=Math.hypot(r[0],r[1]),o=Math.hypot(r[2],r[3]),s=(r[0]*r[2]+r[1]*r[3])/(a*o);if(Math.abs(s)<i){if(this.isRadial()){if(Math.abs(a-o)<i)return this._createGradient(e,r)}else return this._createGradient(e,r)}}let a=t.current.getClippedPathBoundingBox(r,d3(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,s=Math.ceil(a[3]-a[1])||1,c=t.canvasFactory.create(o,s),l=c.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),n=$.transform(n,[1,0,0,1,a[0],a[1]]),l.transform(...t.baseTransform),this.matrix&&l.transform(...this.matrix),Z6(l,this._bbox),this.areConic()&&(l.fillStyle=this._createReversedGradient(l),l.fill()),l.fillStyle=this._createGradient(l),l.fill(),i=e.createPattern(c.canvas,`no-repeat`),t.canvasFactory.destroy(c);let u=new DOMMatrix(n);i.setTransform(u)}else this.areConic()&&(e.save(),Z6(e,this._bbox),e.fillStyle=this._createReversedGradient(e),e.fillRect(-1e10,-1e10,2e10,2e10),e.restore()),Z6(e,this._bbox),i=this._createGradient(e);return i}};function e8(e,t,n,r,i,a,o,s){let c=t.coords,l=t.colors,u=e.data,d=e.width*4,f;c[n*2+1]>c[r*2+1]&&(f=n,n=r,r=f,f=a,a=o,o=f),c[r*2+1]>c[i*2+1]&&(f=r,r=i,i=f,f=o,o=s,s=f),c[n*2+1]>c[r*2+1]&&(f=n,n=r,r=f,f=a,a=o,o=f);let p=(c[n*2]+t.offsetX)*t.scaleX,m=(c[n*2+1]+t.offsetY)*t.scaleY,h=(c[r*2]+t.offsetX)*t.scaleX,g=(c[r*2+1]+t.offsetY)*t.scaleY,_=(c[i*2]+t.offsetX)*t.scaleX,v=(c[i*2+1]+t.offsetY)*t.scaleY;if(m>=v)return;let y=l[a*4],b=l[a*4+1],x=l[a*4+2],S=l[o*4],C=l[o*4+1],w=l[o*4+2],T=l[s*4],E=l[s*4+1],D=l[s*4+2],O=Math.round(m),k=Math.round(v),A,j,M,N,P,F,I,L;for(let e=O;e<=k;e++){if(e<g){let t=e<m?0:(m-e)/(m-g);A=p-(p-h)*t,j=y-(y-S)*t,M=b-(b-C)*t,N=x-(x-w)*t}else{let t;t=e>v?1:g===v?0:(g-e)/(g-v),A=h-(h-_)*t,j=S-(S-T)*t,M=C-(C-E)*t,N=w-(w-D)*t}let t;t=e<m?0:e>v?1:(m-e)/(m-v),P=p-(p-_)*t,F=y-(y-T)*t,I=b-(b-E)*t,L=x-(x-D)*t;let n=Math.round(Math.min(A,P)),r=Math.round(Math.max(A,P)),i=d*e+n*4;for(let e=n;e<=r;e++)t=(A-e)/(A-P),t<0?t=0:t>1&&(t=1),u[i++]=j-(j-F)*t|0,u[i++]=M-(M-I)*t|0,u[i++]=N-(N-L)*t|0,u[i++]=255}}var t8=class extends Q6{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],J6()}_createMeshCanvas(e,t,n){let r=1.1,i=3e3,a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,l=Math.min(Math.ceil(Math.abs(s*e[0]*r)),i)||1,u=Math.min(Math.ceil(Math.abs(c*e[1]*r)),i)||1,d=s?s/l:1,f=c?c/u:1,p={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/d,scaleY:1/f},m=l+4,h=u+4,g=n.create(m,h);if(q6()&&this._vertexCount>48)g.context.drawImage(Y6(this._posData,this._colData,this._vertexCount,p,t,m,h,2),0,0);else{let e=g.context.createImageData(l,u);if(t){let n=e.data;for(let e=0,r=n.length;e<r;e+=4)n[e]=t[0],n[e+1]=t[1],n[e+2]=t[2],n[e+3]=255}for(let t=0,n=this._vertexCount;t<n;t+=3)e8(e,p,t,t+1,t+2,t,t+1,t+2);g.context.putImageData(e,2,2)}return{canvas:g.canvas,offsetX:a-2*d,offsetY:o-2*f,scaleX:d,scaleY:f}}isModifyingCurrentTransform(){return!0}getPattern(e,t,n,r){Z6(e,this._bbox);let i=new Float32Array(2);if(r===X6.SHADING)$.singularValueDecompose2dScale(d3(e),i);else if(this.matrix){$.singularValueDecompose2dScale(this.matrix,i);let[e,n]=i;$.singularValueDecompose2dScale(t.baseTransform,i),i[0]*=e,i[1]*=n}else $.singularValueDecompose2dScale(t.baseTransform,i);let a=this._createMeshCanvas(i,r===X6.SHADING?null:this._background,t.canvasFactory);r!==X6.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY);let o=e.createPattern(a.canvas,`no-repeat`);return t.canvasFactory.destroy(a),o}},n8=class extends Q6{getPattern(){return`hotpink`}};function r8(e){switch(e[0]){case`RadialAxial`:return new $6(e);case`Mesh`:return new t8(e);case`Dummy`:return new n8}throw Error(`Unknown IR type: ${e[0]}`)}var i8={COLORED:1,UNCOLORED:2},a8=class e{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,r){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=n,this.baseTransform=r,this.patternBaseMatrix=this.matrix?$.transform(r,this.matrix):r}canSkipPatternCanvas([e,t,n,r]){let[i,a,o,s]=this.bbox,c=Math.abs(this.xstep),l=Math.abs(this.ystep);if(e>c+1e-6||t>l+1e-6)return null;let u=Math.floor((n-o)/c)+1,d=Math.ceil((n+e-i)/c)-1,f=Math.floor((r-s)/l)+1,p=Math.ceil((r+t-a)/l)-1;return d<=u&&p<=f?[u,f]:null}updatePatternDims(e,t){let n=$.inverseTransform(this.patternBaseMatrix),r=[e[0],e[1]],i=[e[2],e[3]];$.applyTransform(r,n),$.applyTransform(i,n),t[0]=Math.abs(i[0]-r[0]),t[1]=Math.abs(i[1]-r[1]),t[2]=Math.min(r[0],i[0]),t[3]=Math.min(r[1],i[1])}_renderTileCanvas(e,t,n,r){let[i,a,o,s]=this.bbox,c=e.canvasFactory.create(n.size,r.size),l=c.context,u=this.canvasGraphicsFactory.createCanvasGraphics(l,t);return u.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(u,this.paintType,this.color),l.translate(-n.scale*i,-r.scale*a),u.transform(0,n.scale,0,0,r.scale,0,0),l.save(),u.dependencyTracker?.save(),this.clipBbox(u,i,a,o,s),u.baseTransform=d3(u.ctx),u.executeOperatorList(this.operatorList),u.endDrawing(),u.dependencyTracker?.restore(),l.restore(),c}_getCombinedScales(){let e=new Float32Array(2);$.singularValueDecompose2dScale(this.matrix,e);let[t,n]=e;return $.singularValueDecompose2dScale(this.baseTransform,e),[t*e[0],n*e[1]]}drawPattern(e,t,n=!1,[r,i],a){let[o,s,c,l]=this.bbox,u=e.dependencyTracker;if(u&&(e.dependencyTracker=new o6(u,a)),e.save(),n?e.ctx.clip(t,`evenodd`):e.ctx.clip(t),e.ctx.setTransform(...this.patternBaseMatrix),e.ctx.translate(r*this.xstep,i*this.ystep),this.needsIsolation||e.ctx.globalAlpha!==1||e.ctx.globalCompositeOperation!==`source-over`||e.inSMaskMode){let t=c-o,n=l-s,[r,i]=this._getCombinedScales(),u=this.getSizeAndScale(t,this.ctx.canvas.width,r),d=this.getSizeAndScale(n,this.ctx.canvas.height,i),f=this._renderTileCanvas(e,a,u,d);e.ctx.drawImage(f.canvas,o,s,t,n),e.canvasFactory.destroy(f)}else this.setFillAndStrokeStyleToContext(e,this.paintType,this.color),this.clipBbox(e,o,s,c,l),e.baseTransformStack.push(e.baseTransform),e.baseTransform=d3(e.ctx),e.executeOperatorList(this.operatorList),e.baseTransform=e.baseTransformStack.pop();e.restore(),u&&(e.dependencyTracker=u)}createPatternCanvas(e,t){let[n,r,i,a]=this.bbox,o=i-n,s=a-r,{xstep:c,ystep:l}=this;c=Math.abs(c),l=Math.abs(l),h4(`TilingType: `+this.tilingType);let[u,d]=this._getCombinedScales(),f=o,p=s,m=!1,h=!1;Math.ceil(c*u)>=Math.ceil(o*u)?f=c:m=!0,Math.ceil(l*d)>=Math.ceil(s*d)?p=l:h=!0;let g=this.getSizeAndScale(f,this.ctx.canvas.width,u),_=this.getSizeAndScale(p,this.ctx.canvas.height,d),v=this._renderTileCanvas(e,t,g,_);if(m||h){let t=v.canvas;m&&(f=c),h&&(p=l);let i=this.getSizeAndScale(f,this.ctx.canvas.width,u),a=this.getSizeAndScale(p,this.ctx.canvas.height,d),g=i.size,_=a.size,y=e.canvasFactory.create(g,_),b=y.context,x=m?Math.floor(o/c):0,S=h?Math.floor(s/l):0;for(let e=0;e<=x;e++)for(let n=0;n<=S;n++)b.drawImage(t,g*e,_*n,g,_,0,0,g,_);return e.canvasFactory.destroy(v),{canvas:y.canvas,canvasEntry:y,scaleX:i.scale,scaleY:a.scale,offsetX:n,offsetY:r}}return{canvas:v.canvas,canvasEntry:v,scaleX:g.scale,scaleY:_.scale,offsetX:n,offsetY:r}}getSizeAndScale(t,n,r){let i=Math.max(e.MAX_PATTERN_SIZE,n),a=Math.ceil(t*r);return a>=i?a=i:r=a/t,{scale:r,size:a}}clipBbox(e,t,n,r,i){let a=r-t,o=i-n,s=new Path2D;s.rect(t,n,a,o),$.axialAlignedBoundingBox([t,n,r,i],d3(e.ctx),e.current.minMax),e.ctx.clip(s),e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,i=e.current;switch(i.patternFill=i.patternStroke=!1,t){case i8.COLORED:let{fillStyle:e,strokeStyle:a}=this.ctx;r.fillStyle=i.fillColor=e,r.strokeStyle=i.strokeColor=a;break;case i8.UNCOLORED:r.fillStyle=r.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new k4(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,n,r,i){let a=r===X6.SHADING?n:$.transform(n,this.patternBaseMatrix),o=this.createPatternCanvas(t,i),s=new DOMMatrix(a);s=s.translate(o.offsetX,o.offsetY),s=s.scale(1/o.scaleX,1/o.scaleY);let c=e.createPattern(o.canvas,`repeat`);return t.canvasFactory.destroy(o.canvasEntry),c.setTransform(s),c}},o8=16,s8=100,c8=15,l8=10,u8=16,d8=new DOMMatrix,f8=new Float32Array(2);function p8(e,t){if(e._removeMirroring)throw Error(`Context is already forwarding operations.`);let n=new Map;for(let r of[`save`,`restore`,`rotate`,`scale`,`translate`,`transform`,`setTransform`,`resetTransform`,`clip`,`moveTo`,`lineTo`,`bezierCurveTo`,`quadraticCurveTo`,`arc`,`arcTo`,`ellipse`,`rect`,`roundRect`,`closePath`,`beginPath`]){let i=e[r];typeof i==`function`&&typeof t[r]==`function`&&(n.set(r,i),e[r]=function(...e){return t[r](...e),i.apply(this,e)})}e._removeMirroring=()=>{for(let[t,r]of n)e[t]=r;delete e._removeMirroring}}function m8(e,t,n,r,i,a,o,s,c,l){let[u,d,f,p,m,h]=d3(e);if(d===0&&f===0){let g=o*u+m,_=Math.round(g),v=s*p+h,y=Math.round(v),b=(o+c)*u+m,x=Math.abs(Math.round(b)-_)||1,S=(s+l)*p+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),_,y),e.drawImage(t,n,r,i,a,0,0,x,C),e.setTransform(u,d,f,p,m,h),[x,C]}if(u===0&&p===0){let g=s*f+m,_=Math.round(g),v=o*d+h,y=Math.round(v),b=(s+l)*f+m,x=Math.abs(Math.round(b)-_)||1,S=(o+c)*d+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,_,y),e.drawImage(t,n,r,i,a,0,0,C,x),e.setTransform(u,d,f,p,m,h),[C,x]}e.drawImage(t,n,r,i,a,o,s,c,l);let g=Math.hypot(u,d),_=Math.hypot(f,p);return[g*c,_*l]}var h8=class{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Y2;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=i4.FILL;textRise=0;fillColor=`#000000`;strokeColor=`#000000`;tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps=`none`;minMax=J2.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=X6.FILL,t=null){let n=this.minMax.slice();if(e===X6.STROKE){t||_4(`Stroke bounding box must include transform.`),$.singularValueDecompose2dScale(t,f8);let e=f8[0]*this.lineWidth/2,r=f8[1]*this.lineWidth/2;n[0]-=e,n[1]-=r,n[2]+=e,n[3]+=r}return n}updateClipFromPath(){let e=$.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(J2,0)}getClippedPathBoundingBox(e=X6.FILL,t=null){return $.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function g8(e,t){let{width:n,height:r,kind:i}=t,a=r%u8,o=(r-a)/u8,s=a===0?o:o+1,c=e.createImageData(n,u8),l=0,u=t.data,d=c.data,f;if(i===a4.GRAYSCALE_1BPP)for(f=0;f<s;f++)({srcPos:l}=H6({src:u,srcPos:l,dest:d,width:n,height:f<o?u8:a})),e.putImageData(c,0,f*u8);else if(i===a4.RGBA_32BPP){let t=0,r=n*u8*4;for(f=0;f<o;f++)d.set(u.subarray(l,l+r)),l+=r,e.putImageData(c,0,t),t+=u8;f<s&&(r=n*a*4,d.set(u.subarray(l,l+r)),e.putImageData(c,0,t))}else if(i===a4.RGB_24BPP)for(f=0;f<s;f++)({srcPos:l}=U6({src:u,srcPos:l,dest:new Uint32Array(d.buffer),width:n,height:f<o?u8:a})),e.putImageData(c,0,f*u8);else throw Error(`bad image kind: ${i}`)}function _8(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let{width:n,height:r}=t,i=r%u8,a=(r-i)/u8,o=i===0?a:a+1,s=e.createImageData(n,u8),c=0,l=t.data,u=s.data;for(let t=0;t<o;t++)({srcPos:c}=H6({src:l,srcPos:c,dest:u,width:n,height:t<a?u8:i,nonBlackColor:0})),e.putImageData(s,0,t*u8)}function v8(e,t){for(let n of[`strokeStyle`,`fillStyle`,`fillRule`,`globalAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`globalCompositeOperation`,`font`,`filter`])e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function y8(e){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;t!==`none`&&t!==``&&(e.filter=`none`)}function b8(e,t){if(t)return!0;$.singularValueDecompose2dScale(e,f8);let n=Math.fround(m3.pixelRatio*X4.PDF_TO_CSS_UNITS);return f8[0]<=n&&f8[1]<=n}var x8=[`butt`,`round`,`square`],S8=[`miter`,`round`,`bevel`],C8={},w8={},T8=class e{#e=0;#t=0;#n=null;#r=null;#i=null;#a=null;#o=1;#s;#c=null;#l=[];constructor(e,t,n,r,i,{optionalContentConfig:a,markedContentStack:o=null},s,c,l,u){this.ctx=e,this.current=new h8(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=i,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=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=s,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=l??null,this.imagesTracker=u??null}getObject(e,t,n=null){return typeof t==`string`?(this.dependencyTracker?.recordNamedDependency(e,t),t.startsWith(`g_`)?this.commonObjs.get(t):this.objs.get(t)):n}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){let i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||`#ffffff`,this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){let e=this.transparentCanvasEntry=this.canvasFactory.create(i,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=e,this.ctx.save(),this.ctx.transform(...d3(this.compositeCtx))}this.ctx.save(),y8(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=d3(this.ctx)}executeOperatorList(e,t,n,r,i){let a=e.argsArray,o=e.fnArray,s=t||0,c=a.length;if(c===s)return s;let l=c-s>l8&&typeof n==`function`,u=l?Date.now()+c8:0,d=0,f=this.commonObjs,p=this.objs,m,h;for(;;){if(r!==void 0){if(s===r.nextBreakPoint)return r.breakIt(s,n),s;if(r.shouldSkip(s)){if(++s===c)return s;continue}}if(!i||i(s)){if(m=o[s],h=a[s]??null,m!==l4.dependency)h===null?this[m](s):this[m](s,...h);else for(let e of h){this.dependencyTracker?.recordNamedData(e,s);let t=e.startsWith(`g_`)?f:p;if(!t.has(e))return t.get(e,n),s}}if(s++,s===c)return s;if(l&&++d>l8){if(Date.now()>u)return n(),s;d=0}}}#u(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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.#l)this.#y(e);this.#l.length=0,this.#n=null,this.#r=null,this.#i=null,this.#a=null,this.#o=1,this.#c=null,this.#t=0,this.#e=0,this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#d()}#d(){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 n=e.width??e.displayWidth,r=e.height??e.displayHeight,i=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),o=[],s=i,c=a,l=n,u=r;for(;s>2&&l>1||c>2&&u>1;){let e=l,t=u;s>2&&l>1&&(e=Math.ceil(l/2),s/=l/e),c>2&&u>1&&(t=Math.ceil(u/2),c/=u/t),o.push({newWidth:e,newHeight:t}),l=e,u=t}if(o.length===0)return{img:e,paintWidth:n,paintHeight:r,tmpCanvas:null};if(o.length===1){let{newWidth:t,newHeight:i}=o[0],a=this.canvasFactory.create(t,i);return a.context.drawImage(e,0,0,n,r,0,0,t,i),{img:a.canvas,paintWidth:t,paintHeight:i,tmpCanvas:a}}let d=this.canvasFactory.create(1,1),f=this.canvasFactory.create(1,1),p=n,m=r,h=e;for(let{newWidth:e,newHeight:t}of o)this.canvasFactory.reset(f,e,t),f.context.drawImage(h,0,0,p,m,0,0,e,t),[d,f]=[f,d],h=d.canvas,p=e,m=t;return this.canvasFactory.destroy(f),{img:d.canvas,paintWidth:p,paintHeight:m,tmpCanvas:d}}_createMaskCanvas(e,t){let n=this.ctx,{width:r,height:i}=t,a=this.current.fillColor,o=this.current.patternFill,s=d3(n),c,l,u,d;if((t.bitmap||t.data)&&t.count>1){let n=t.bitmap||t.data.buffer;l=JSON.stringify(o?s:[s.slice(0,4),a]),c=this._cachedBitmapsMap.getOrInsertComputed(n,V4);let r=c.get(l);if(r&&!o){let t=Math.round(Math.min(s[0],s[2])+s[4]),n=Math.round(Math.min(s[1],s[3])+s[5]);return this.dependencyTracker?.recordDependencies(e,s6.transformAndFill),{canvas:r,offsetX:t,offsetY:n}}u=r}u||(d=this.canvasFactory.create(r,i),_8(d.context,t));let f=$.transform(s,[1/r,0,0,-1/i,0,0]);f=$.transform(f,[1,0,0,1,0,-i]);let p=J2.slice();$.axialAlignedBoundingBox([0,0,r,i],f,p);let[m,h,g,_]=p,v=Math.round(g-m)||1,y=Math.round(_-h)||1,b=this.canvasFactory.create(v,y),x=b.context,S=m,C=h;x.translate(-S,-C),x.transform(...f);let w=null;if(!u){let e=this._scaleImage(d.canvas,f3(x));u=e.img,w=e.tmpCanvas,u!==d.canvas&&(this.canvasFactory.destroy(d),d=null),c&&o&&(c.set(l,u),w=null,d=null)}x.imageSmoothingEnabled=b8(d3(x),t.interpolate),m8(x,u,0,0,u.width,u.height,0,0,r,i),w&&this.canvasFactory.destroy(w),d&&this.canvasFactory.destroy(d),x.globalCompositeOperation=`source-in`;let T=$.transform(f3(x),[1,0,0,1,-S,-C]);return x.fillStyle=o?a.getPattern(n,this,T,X6.FILL,e):a,x.fillRect(0,0,r,i),c&&!o&&c.set(l,b.canvas),this.dependencyTracker?.recordDependencies(e,s6.transformAndFill),{canvas:b.canvas,canvasEntry:c&&!o?null:b,offsetX:Math.round(S),offsetY:Math.round(C)}}setLineWidth(e,t){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=x8[t]}setLineJoin(e,t){this.dependencyTracker?.recordSimpleData(`lineJoin`,e),this.ctx.lineJoin=S8[t]}setMiterLimit(e,t){this.dependencyTracker?.recordSimpleData(`miterLimit`,e),this.ctx.miterLimit=t}setDash(e,t,n){this.dependencyTracker?.recordSimpleData(`dash`,e);let r=this.ctx;r.setLineDash!==void 0&&(r.setLineDash(t),r.lineDashOffset=n)}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(let[n,r]of t)switch(n){case`LW`:this.setLineWidth(e,r);break;case`LC`:this.setLineCap(e,r);break;case`LJ`:this.setLineJoin(e,r);break;case`ML`:this.setMiterLimit(e,r);break;case`D`:this.setDash(e,r[0],r[1]);break;case`RI`:this.setRenderingIntent(e,r);break;case`FL`:this.setFlatness(e,r);break;case`Font`:this.setFont(e,r[0],r[1]);break;case`CA`:this.dependencyTracker?.recordSimpleData(`strokeAlpha`,e),this.current.strokeAlpha=r;break;case`ca`:this.dependencyTracker?.recordSimpleData(`fillAlpha`,e),this.ctx.globalAlpha=this.current.fillAlpha=r;break;case`BM`:this.dependencyTracker?.recordSimpleData(`globalCompositeOperation`,e),this.ctx.globalCompositeOperation=r;break;case`SMask`:this.dependencyTracker?.recordSimpleData(`SMask`,e),this.current.activeSMask=r?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(r)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&=(this.canvasFactory.destroy(this.smaskPreparedEntry),null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){e!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(e))}checkSMaskState(e){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){let{canvas:t,subtype:n,backdrop:r,transferMap:i}=e,a=n===`Luminosity`||n===`Alpha`&&i;if(!a&&!(n===`Luminosity`&&r)){this.smaskPreparedFor=e;return}let o;if(n===`Luminosity`&&r){let[e,t,n]=c3(r),a=Math.round(.3*e+.59*t+.11*n);o=i?.[a]??a}else o=i?.[0]??0;let{width:s,height:c}=this.ctx.canvas,l=t.width*t.height,u=s*c<4*l,d=a?{url:n===`Alpha`?this.filterFactory.addAlphaFilter(i):this.filterFactory.addLuminosityFilter(i),subtype:n,transferMap:i}:null,f=n===`Luminosity`?r:null,p,m,h;u?(p=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,s,c,f,d),m=0,h=0):(p=this._bakeSMaskCanvas(t,0,0,t.width,t.height,f,d),m=e.offsetX,h=e.offsetY),this.smaskPreparedEntry=p,this.smaskPreparedFor=e,this.smaskPreparedOffsetX=m,this.smaskPreparedOffsetY=h,this.smaskPreparedOOBAlpha=!u&&o!==0?o:null}_bakeSMaskCanvas(e,t,n,r,i,a,o){!a&&!o&&_4(`_bakeSMaskCanvas with neither backdrop nor filter`);let s=this.canvasFactory.create(r,i),c=s.context;if(c.drawImage(e,t,n),a&&(c.globalCompositeOperation=`destination-atop`,c.fillStyle=a,c.fillRect(0,0,r,i)),!o)return s;let l=this.canvasFactory.create(r,i),u=l.context;u.filter=o.url;let d=N4.isCanvasFilterSupported&&u.filter!==`none`&&u.filter!==``;if(u.drawImage(s.canvas,0,0),N4.isCanvasFilterSupported&&(u.filter=`none`),!d){let e=u.getImageData(0,0,r,i),{data:t}=e,{transferMap:n}=o;if(o.subtype===`Luminosity`)for(let e=0,r=t.length;e<r;e+=4){let r=.3*t[e]+.59*t[e+1]+.11*t[e+2]+.5|0;t[e]=t[e+1]=t[e+2]=0,t[e+3]=n?.[r]??r}else for(let e=3,r=t.length;e<r;e+=4)t[e]=n[t[e]];u.putImageData(e,0,0)}return this.canvasFactory.destroy(s),l}beginSMaskMode(e){if(this.inSMaskMode)throw Error(`beginSMaskMode called while already in smask mode`);let{width:t,height:n}=this.ctx.canvas,r=this.canvasFactory.create(t,n);this.smaskScratchCanvas=r,this.suspendedCtx=this.ctx;let i=this.ctx=r.context;i.setTransform(this.suspendedCtx.getTransform()),v8(this.suspendedCtx,i),p8(i,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(),v8(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#f(e,t=null,n=1){let{width:r,height:i}=e,a=t??this.canvasFactory.create(r,i),o=a.context;n=Math.round(n*255)/255;let s=n<1;s&&this.#s===void 0&&(this.#s=N4.isCanvasFilterSupported?new Map:`none`);let c=`none`;if(s&&this.#s instanceof Map&&(c=this.#s.getOrInsertComputed(n,()=>this.filterFactory.addKnockoutFilter(n))),!s||c!==`none`)return t&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,r,i),o.restore()),o.filter=c,o.drawImage(e,0,0),o.filter=`none`,a;let l=e.getContext(`2d`,{willReadFrequently:!0}).getImageData(0,0,r,i),u=o.createImageData(r,i),d=l.data,f=u.data,p=n>0?1/n:1e6;for(let e=3,t=d.length;e<t;e+=4)f[e]=Math.min(Math.round(d[e]*p),255);return o.putImageData(u,0,0),a}#p(e,t,n,r){let i=e?.[t]??null;if(i&&(i.canvas.width!==n||i.canvas.height!==r)&&(this.canvasFactory.destroy(i),i=null),!i)return i=this.canvasFactory.create(n,r),e&&(e[t]=i),i;let a=i.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,n,r),a.restore(),i}#m(e,t,n={}){let{backdropCanvas:r=null,destTransform:i=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:s=null,sourceAlpha:c=1,sourceFilter:l=`none`,knockoutAlpha:u=1}=n,{width:d,height:f}=t,p=this.#f(t,o,u),m=e.globalCompositeOperation;if(e.save(),e.setTransform(...i),e.globalAlpha=1,N4.isCanvasFilterSupported&&(e.filter=`none`),e.globalCompositeOperation=`destination-out`,e.drawImage(p.canvas,0,0),r){let[t,n]=a,i=this.#p(s,`knockoutBackdropEntry`,d,f),o=i.context;o.drawImage(r,t,n,d,f,0,0,d,f),o.globalCompositeOperation=`destination-in`,o.drawImage(p.canvas,0,0),o.globalCompositeOperation=`source-over`,e.globalCompositeOperation=`destination-over`,e.drawImage(i.canvas,0,0),s||this.canvasFactory.destroy(i)}e.globalCompositeOperation=m,e.globalAlpha=c,N4.isCanvasFilterSupported&&(e.filter=l??`none`),e.drawImage(t,0,0),e.restore(),o||this.canvasFactory.destroy(p)}#h(e=1){if(this.#e===0||this.#t>0||!this.contentVisible)return!1;this.#t++,this.#o=e;let t=this.#l.at(-1),{canvas:n}=this.ctx,r=this.#p(t,`knockoutTempEntry`,n.width,n.height);this.#n=r;let i=r.context;return i.save(),i.setTransform(this.ctx.getTransform()),v8(this.ctx,i),this.#a=i.globalCompositeOperation,i.globalCompositeOperation=`source-over`,p8(i,this.ctx),this.#c=t,this.#r=this.ctx,this.#i=this.suspendedCtx,this.ctx=i,this.inSMaskMode&&(this.suspendedCtx=i),!0}#g(e){if(!e)return;let t=this.#n,n=this.#r,r=this.#i,i=t.context;this.#n=null,this.#r=null,this.#i=null,this.inSMaskMode&&this.suspendedCtx===i&&this.ctx!==i&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=r),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#a,this.#a=null,v8(this.ctx,n),this.ctx=n;let a=this.#c;this.#c=null;let o=this.#o;this.#o=1;try{this.#m(r??n,t.canvas,{backdropCanvas:a?.backdropCtx?.canvas??null,backdropOffset:a?.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:a?.knockoutMaskEntry??null,poolMeta:a,knockoutAlpha:o})}finally{i.restore(),this.#t--,a||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,n=this.suspendedCtx,r=this.#t>0&&n===this.ctx;this.composeSMask(r?null:n,t,this.ctx,e),!r&&(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,n,r){let i=r[0],a=r[1],o=r[2]-i,s=r[3]-a;if(o===0||s===0)return;let c=this.smaskPreparedEntry;if(c){let e=i,r=a,l=o,u=s,d=this.smaskPreparedOOBAlpha,f=d!==null;if(f){e=Math.max(i,t.offsetX),r=Math.max(a,t.offsetY);let n=Math.min(i+o,t.offsetX+t.canvas.width),c=Math.min(a+s,t.offsetY+t.canvas.height);l=n-e,u=c-r}if(l>0&&u>0){let t=e-this.smaskPreparedOffsetX,i=r-this.smaskPreparedOffsetY;n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0);let a=new Path2D;a.rect(e,r,l,u),n.clip(a),n.globalCompositeOperation=`destination-in`,n.drawImage(c.canvas,t,i,l,u,e,r,l,u),n.restore()}f&&d<255&&this._applySMaskOOBAlpha(n,i,a,o,s,e,r,e+l,r+u,d)}else this.genericComposeSMask(t,n,o,s,i,a);e&&(e.save(),e.globalAlpha=1,e.globalCompositeOperation=t.blendMode||`source-over`,e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,i,a,o,s,i,a,o,s),e.restore())}_applySMaskOOBAlpha(e,t,n,r,i,a,o,s,c,l){let u=a<s&&o<c;if(u&&a===t&&o===n&&s===t+r&&c===n+i)return;let d=new Path2D;d.rect(t,n,r,i),u&&d.rect(a,o,s-a,c-o),e.save(),e.globalAlpha=l/255,e.setTransform(1,0,0,1,0,0),e.clip(d,`evenodd`),e.globalCompositeOperation=`destination-in`,e.fillStyle=`#000000`,e.fillRect(t,n,r,i),e.restore()}genericComposeSMask(e,t,n,r,i,a){let{context:o,offsetX:s,offsetY:c}=e;t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let l=new Path2D;l.rect(i,a,n,r),t.clip(l),t.globalCompositeOperation=`destination-in`,t.drawImage(o.canvas,i-s,a-c,n,r,i,a,n,r),t.restore()}save(e){this.inSMaskMode&&v8(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){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(v8(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,n,r,i,a,o){this.dependencyTracker?.recordIncrementalData(`transform`,e),this.ctx.transform(t,n,r,i,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n,r){let[i]=n;if(!r){i||=n[0]=new Path2D,t!==l4.stroke&&t!==l4.closeStroke&&(this.current.tilingPatternDims=null),this[t](e,i);return}if(this.dependencyTracker!==null){let n=t===l4.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,r[0]-n,r[2]+n,r[1]-n,r[3]+n).recordDependencies(e,[`transform`])}i instanceof Path2D||(i=n[0]=E3(i)),$.axialAlignedBoundingBox(r,d3(this.ctx),this.current.minMax);let a=this.current.tilingPatternDims;if(a&&t!==l4.stroke&&t!==l4.closeStroke&&this.current.fillColor instanceof a8){let e=$.intersect(this.current.clipBox,this.current.minMax);e?this.current.fillColor.updatePatternDims(e,a):this.current.tilingPatternDims=null}this[t](e,i),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,n=!0){let r=n&&this.#h(this.current.strokeAlpha),i=this.ctx,a=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible){if(typeof a==`object`&&a?.getPattern){let n=a.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=a.getPattern(i,this,f3(i),X6.STROKE,e),n){let e=new Path2D;e.addPath(t,i.getTransform().invertSelf().multiplySelf(n)),t=e}this.rescaleAndStroke(t,!1),i.restore()}else this.rescaleAndStroke(t,!0)}this.dependencyTracker?.recordDependencies(e,s6.stroke),n&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(X6.STROKE,d3(this.ctx))),i.globalAlpha=this.current.fillAlpha,this.#g(r)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,n=!0){let r=n&&this.#h(this.current.fillAlpha),i=this.ctx,a=this.current.fillColor,o=this.current.patternFill,s=!1,c=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(e,s6.fill),o){let o=this.current.tilingPatternDims,l=o&&a.canSkipPatternCanvas(o);if(l){a.drawPattern(this,t,this.pendingEOFill,l,e),this.pendingEOFill=!1,n&&this.consumePath(e,t,c),this.current.tilingPatternDims=null,this.#g(r);return}let u=a.isModifyingCurrentTransform()?i.getTransform():null;if(this.dependencyTracker?.save(e),i.save(),i.fillStyle=a.getPattern(i,this,f3(i),X6.FILL,e),u){let e=new Path2D;e.addPath(t,i.getTransform().invertSelf().multiplySelf(u)),t=e}s=!0}this.contentVisible&&c!==null&&(this.pendingEOFill?(i.fill(t,`evenodd`),this.pendingEOFill=!1):i.fill(t)),s&&(i.restore(),this.dependencyTracker?.restore(e)),n&&this.consumePath(e,t,c),this.#g(r)}eoFill(e,t){this.pendingEOFill=!0,this.fill(e,t)}fillStroke(e,t){let n=this.#h(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1),this.stroke(e,t,!1),this.consumePath(e,t),this.#g(n)}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 n=this.#h(this.current.fillAlpha);this.ctx.fill(t),this.dependencyTracker?.recordDependencies(e,s6.rawFillPath).recordOperation(e),this.#g(n)}clip(e){this.dependencyTracker?.recordFutureForcedDependency(`clipMode`,e),this.pendingClip=C8}eoClip(e){this.dependencyTracker?.recordFutureForcedDependency(`clipMode`,e),this.pendingClip=w8}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,n=this.ctx;if(this.dependencyTracker){let{dependencyTracker:n}=this;t!==void 0&&n.recordFutureForcedDependency(`textClip`,n.getOpenMarker()).recordFutureForcedDependency(`textClip`,e),n.recordCloseMarker(e)}if(t!==void 0){let e=new Path2D,r=n.getTransform().invertSelf();for(let{transform:n,x:i,y:a,fontSize:o,path:s}of t)s&&e.addPath(s,new DOMMatrix(n).preMultiplySelf(r).translate(i,a).scale(o,-o));n.clip(e)}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,n){this.dependencyTracker?.recordSimpleData(`font`,e).recordSimpleDataFromNamed(`fontObj`,t,e);let r=this.commonObjs.get(t),i=this.current;if(!r)throw Error(`Can't find font for ${t}`);if(i.fontMatrix=r.fontMatrix||Y2,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&g4(`Invalid font matrix for font `+t),n<0?(n=-n,i.fontDirection=-1):i.fontDirection=1,this.current.font=r,this.current.fontSize=n,r.isType3Font)return;let a=r.loadedName||`sans-serif`,o=r.systemFontInfo?.css||`"${a}", ${r.fallbackName}`,s=`normal`;r.black?s=`900`:r.bold&&(s=`bold`);let c=r.italic?`italic`:`normal`,l=W4(n,o8,s8);this.current.fontSizeScale=n/l,this.ctx.font=`${c} ${s} ${l}px ${o}`}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,n){this.dependencyTracker?.resetIncrementalData(`sameLineText`).recordIncrementalData(`moveText`,e),this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=n}setLeadingMoveText(e,t,n){this.setLeading(e,-n),this.moveText(e,t,n)}setTextMatrix(e,t){this.dependencyTracker?.resetIncrementalData(`sameLineText`).recordSimpleData(`textMatrix`,e);let{current:n}=this;n.textMatrix=t,n.textMatrixScale=Math.hypot(t[0],t[1]),n.x=n.lineX=0,n.y=n.lineY=0}nextLine(e){this.moveText(e,0,this.current.leading),this.dependencyTracker?.recordIncrementalData(`moveText`,this.dependencyTracker.getSimpleIndex(`leading`)??e)}#_(e,t,n){let r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}paintChar(e,t,n,r,i,a){let o=this.ctx,s=this.current,c=s.font,l=s.textRenderingMode,u=s.fontSize/s.fontSizeScale,d=l&i4.FILL_STROKE_MASK,f=!!(l&i4.ADD_TO_PATH_FLAG),p=s.patternFill&&!c.missingFile,m=s.patternStroke&&!c.missingFile,h;if((c.disableFontFace||f||p||m)&&!c.missingFile&&(h=c.getPathGenerator(this.commonObjs,t)),h&&(c.disableFontFace||p||m)){o.save(),o.translate(n,r),o.scale(u,-u),this.dependencyTracker?.recordCharacterBBox(e,o,c);let t;if(d===i4.FILL||d===i4.FILL_STROKE){if(i){t=o.getTransform(),o.setTransform(...i);let e=this.#_(h,t,i);o.fill(e)}else o.fill(h)}if(d===i4.STROKE||d===i4.FILL_STROKE){if(a){t||=o.getTransform(),o.setTransform(...a);let{a:e,b:n,c:r,d:i}=t,s=$.inverseTransform(a),c=$.transform([e,n,r,i,0,0],s);$.singularValueDecompose2dScale(c,f8),o.lineWidth*=Math.max(f8[0],f8[1])/u,o.stroke(this.#_(h,t,a))}else o.lineWidth/=u,o.stroke(h)}o.restore()}else(d===i4.FILL||d===i4.FILL_STROKE)&&(o.fillText(t,n,r),this.dependencyTracker?.recordCharacterBBox(e,o,c,u,n,r,()=>o.measureText(t))),(d===i4.STROKE||d===i4.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(e,o,c,u,n,r,()=>o.measureText(t)).recordDependencies(e,s6.stroke),o.strokeText(t,n,r));f&&((this.pendingTextPaths||=[]).push({transform:d3(o),x:n,y:r,fontSize:u,path:h}),this.dependencyTracker?.recordCharacterBBox(e,o,c,u,n,r))}get isFontSubpixelAAEnabled(){let e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1),t.fillText(`I`,0,10);let n=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let r=!1;for(let e=3;e<n.length;e+=4)if(n[e]>0&&n[e]<255){r=!0;break}return C4(this,`isFontSubpixelAAEnabled`,r)}showText(e,t){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,s6.showText).resetBBox(e),this.current.textRenderingMode&i4.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency(`textClip`,e).inheritPendingDependenciesAsFutureForcedDependencies());let n=this.current,r=n.font;if(r.isType3Font){let r=this.#h(n.fillAlpha);this.showType3Text(e,t),this.dependencyTracker?.recordShowTextOperation(e),this.#g(r);return}let i=n.fontSize;if(i===0){this.dependencyTracker?.recordOperation(e);return}let a=this.#h(n.fillAlpha),o=this.ctx,s=n.fontSizeScale,c=n.charSpacing,l=n.wordSpacing,u=n.fontDirection,d=n.textHScale*u,f=t.length,p=r.vertical,m=p?1:-1,h=r.defaultVMetrics,g=i*n.fontMatrix[0],_=n.textRenderingMode===i4.FILL&&!r.disableFontFace&&!n.patternFill;o.save(),n.textMatrix&&o.transform(...n.textMatrix),o.translate(n.x,n.y+n.textRise),u>0?o.scale(d,-1):o.scale(d,1);let v,y,b=n.textRenderingMode&i4.FILL_STROKE_MASK,x=b===i4.FILL||b===i4.FILL_STROKE,S=b===i4.STROKE||b===i4.FILL_STROKE,C=n.lineWidth,w=n.textMatrixScale;if(w===0||C===0?S&&(C=this.getSinglePixelWidth()):C/=w,s!==1&&(o.scale(s,s),C/=s),o.lineWidth=C,x&&n.patternFill){o.save();let t=n.fillColor.getPattern(o,this,f3(o),X6.FILL,e);v=d3(o),o.restore(),o.fillStyle=t}if(S&&n.patternStroke){o.save();let t=n.strokeColor.getPattern(o,this,f3(o),X6.STROKE,e);y=d3(o),o.restore(),o.strokeStyle=t}if(r.isInvalidPDFjsFont){let r=[],i=0;for(let e of t)r.push(e.unicode),i+=e.width;let s=r.join(``);if(o.fillText(s,0,0),this.dependencyTracker!==null){let t=o.measureText(s);this.dependencyTracker.recordBBox(e,this.ctx,-t.actualBoundingBoxLeft,t.actualBoundingBoxRight,-t.actualBoundingBoxAscent,t.actualBoundingBoxDescent).recordShowTextOperation(e)}n.x+=i*g*d,o.restore(),this.compose(),this.#g(a);return}let T=0,E;for(E=0;E<f;++E){let n=t[E];if(typeof n==`number`){T+=m*n*i/1e3;continue}let a=!1,d=(n.isSpace?l:0)+c,f=n.fontChar,b=n.accent,x,S,C=n.width;if(p){let e=n.vmetric||h,t=-(n.vmetric?e[1]:C*.5)*g,r=e[2]*g;C=e?-e[0]:C,x=t/s,S=(T+r)/s}else x=T/s,S=0;let w;if(r.remeasure&&C>0){w=o.measureText(f);let e=w.width*1e3/i*s;if(C<e&&this.isFontSubpixelAAEnabled){let t=C/e;a=!0,o.save(),o.scale(t,1),x/=t}else C!==e&&(x+=(C-e)/2e3*i/s)}if(this.contentVisible&&(n.isInFont||r.missingFile)){if(_&&!b)o.fillText(f,x,S),this.dependencyTracker?.recordCharacterBBox(e,o,w?{bbox:null}:r,i/s,x,S,()=>w??o.measureText(f));else if(this.paintChar(e,f,x,S,v,y),b){let t=x+i*b.offset.x/s,n=S-i*b.offset.y/s;this.paintChar(e,b.fontChar,t,n,v,y)}}let D=p?C*g-d*u:C*g+d*u;T+=D,a&&o.restore()}p?n.y-=T:n.x+=T*d,o.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(e),this.#g(a)}showType3Text(e,t){let n=this.ctx,r=this.current,i=r.font,a=r.fontSize,o=r.fontDirection,s=i.vertical?1:-1,c=r.charSpacing,l=r.wordSpacing,u=r.textHScale*o,d=r.fontMatrix||Y2,f=t.length,p=r.textRenderingMode===i4.INVISIBLE,m,h,g,_;if(p||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,n.save(),r.textMatrix&&n.transform(...r.textMatrix),n.translate(r.x,r.y+r.textRise),n.scale(u,o);let v=this.dependencyTracker;for(this.dependencyTracker=v?new o6(v,e):null,m=0;m<f;++m){if(h=t[m],typeof h==`number`){_=s*h*a/1e3,this.ctx.translate(_,0),r.x+=_*u;continue}let e=(h.isSpace?l:0)+c,o=i.charProcOperatorList[h.operatorListId];o?this.contentVisible&&(this.save(),o.fnArray[0]===l4.setCharWidth&&(r.fillAlpha=r.strokeAlpha=1,n.globalAlpha=1),n.scale(a,a),n.transform(...d),this.executeOperatorList(o),this.restore()):g4(`Type3 character "${h.operatorListId}" is not available.`);let f=[h.width,0];$.applyTransform(f,d),g=f[0]*a+e,n.translate(g,0),r.x+=g*u}n.restore(),v&&(this.dependencyTracker=v)}setCharWidth(e,t,n){}setCharWidthAndBounds(e,t,n,r,i,a,o){let s=new Path2D;s.rect(r,i,a-r,o-i),this.ctx.clip(s),this.dependencyTracker?.recordBBox(e,this.ctx,r,a,i,o).recordClipBox(e,this.ctx,r,a,i,o),this.endPath(e)}getColorN_Pattern(t,n){let r;if(n[0]===`TilingPattern`){let t=this.baseTransform||d3(this.ctx);r=new a8(n,this.ctx,{createCanvasGraphics:(t,n)=>new e(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new o6(this.dependencyTracker,n,!0):null)},t)}else r=this._getPattern(t,n[1],n[2]);return r}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 n=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0,this.current.tilingPatternDims=n instanceof a8?[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,n=null){let r=this.cachedPatterns.getOrInsertComputed(t,()=>r8(this.getObject(e,t)));return n&&(r.matrix=n),r}shadingFill(e,t){if(!this.contentVisible)return;let n=this.#h(this.current.fillAlpha),r=this.ctx;this.save(e),r.fillStyle=this._getPattern(e,t).getPattern(r,this,f3(r),X6.SHADING,e);let i=f3(r);if(i){let{width:e,height:t}=r.canvas,n=J2.slice();$.axialAlignedBoundingBox([0,0,e,t],i,n);let[a,o,s,c]=n;this.ctx.fillRect(a,o,s-a,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,s6.transform).recordDependencies(e,s6.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e),this.#g(n)}beginInlineImage(){_4(`Should not call beginInlineImage`)}beginImageData(){_4(`Should not call beginImageData`)}paintFormXObjectBegin(e,t,n){if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),t&&this.transform(e,...t),this.baseTransform=d3(this.ctx),n)){$.axialAlignedBoundingBox(n,this.baseTransform,this.current.minMax);let[t,r,i,a]=n,o=new Path2D;o.rect(t,r,i-t,a-r),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(e,this.ctx,t,i,r,a),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,t){if(!this.contentVisible)return;this.save(e);let{inSMaskMode:n}=this;n&&(this.endSMaskMode(),this.current.activeSMask=null);let r=this.ctx;if((!t.needsIsolation||!t.isolated&&!t.hasSoftMask)&&!t.knockout&&!t.isGray&&this.#e===0&&r.globalAlpha===1&&r.globalCompositeOperation===`source-over`&&!n){if(t.bbox){let e=new Path2D,[n,i,a,o]=t.bbox;if(e.rect(n,i,a-n,o-i),t.matrix){let n=new Path2D;n.addPath(e,new DOMMatrix(t.matrix)),e=n}r.clip(e)}this.groupStack.push(null),this.#l.push(null),this.groupLevel++;return}!t.isolated&&!t.knockout&&this.#e===0&&h4(`TODO: Fully support non-isolated non-knockout groups.`);let i=d3(r);t.matrix&&r.transform(...t.matrix);let a=[0,0,r.canvas.width,r.canvas.height],o;t.bbox?(o=J2.slice(),$.axialAlignedBoundingBox(t.bbox,d3(r),o),o=$.intersect(o,a)||[0,0,0,0]):o=a;let s=Math.floor(o[0]),c=Math.floor(o[1]),l=Math.max(Math.ceil(o[2])-s,1),u=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,l,u]);let d=this.canvasFactory.create(l,u);t.smask&&this.smaskGroupCanvases.push(d);let f=d.context,p=t.knockout&&!t.isolated?r:null,m=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&this.#e>0,h=t.knockout?this.canvasFactory.create(l,u):null,g=this.#e;t.knockout?this.#e++:this.#e=0,f.translate(-s,-c),f.transform(...i);let _=!t.isolated&&!t.smask&&t.needsIsolation,v=_&&!n&&g===0&&!t.knockout&&!t.isGray&&t.hasSoftMask&&r.globalAlpha===1&&r.globalCompositeOperation===`source-over`&&this.current.transferMaps===`none`;if(_&&(n||v)&&(f.save(),f.setTransform(1,0,0,1,0,0),f.drawImage(r.canvas,-s,-c),f.restore()),t.bbox){let e=new Path2D,[n,r,i,a]=t.bbox;if(e.rect(n,r,i-n,a-r),t.matrix){let n=new Path2D;n.addPath(e,new DOMMatrix(t.matrix)),e=n}f.clip(e)}t.smask&&this.smaskStack.push({canvas:d.canvas,context:f,offsetX:s,offsetY:c,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null}),(!t.smask||this.dependencyTracker)&&(r.setTransform(1,0,0,1,0,0),r.translate(s,c),r.save()),v8(r,f),this.ctx=f,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies([`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`]).pushBaseTransform(r),this.setGState(e,[[`BM`,`source-over`],[`ca`,1],[`CA`,1],[`TR`,null]]),this.groupStack.push(r),this.#l.push({backdropCtx:p,savedKnockoutLevel:g,offsetX:s,offsetY:c,hasInnerBackdrop:m,replaceBackdrop:v,knockoutMaskEntry:h,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(e,t){if(!this.contentVisible)return;this.groupLevel--;let n=this.ctx,r=this.groupStack.pop(),i=this.#l.pop();if(i&&(this.#e=i.savedKnockoutLevel),r===null){this.restore(e);return}if(t.isGray&&this.#v(n),this.ctx=r,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),t.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#y(i);else{this.ctx.restore();let t=d3(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...t);let a=J2.slice();$.axialAlignedBoundingBox([0,0,n.canvas.width,n.canvas.height],t,a);let o=this.#l.at(-1);if(this.#e>0){if(i.hasInnerBackdrop){let{width:e,height:a}=n.canvas,o=this.canvasFactory.create(e,a),s=o.context;s.drawImage(r.canvas,i.offsetX,i.offsetY,e,a,0,0,e,a),s.globalCompositeOperation=`source-over`,s.drawImage(n.canvas,0,0);let c=this.#f(n.canvas);s.globalCompositeOperation=`destination-in`,s.drawImage(c.canvas,0,0);let l=this.ctx.globalCompositeOperation,u=this.ctx.globalAlpha,d=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...t),this.ctx.globalAlpha=1,N4.isCanvasFilterSupported&&(this.ctx.filter=`none`),this.ctx.globalCompositeOperation=`destination-out`,this.ctx.drawImage(c.canvas,0,0),this.ctx.globalCompositeOperation=l,this.ctx.globalAlpha=u,N4.isCanvasFilterSupported&&(this.ctx.filter=d??`none`),this.ctx.drawImage(o.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(c),this.canvasFactory.destroy(o)}else{let e=o?.backdropCtx??null;this.#m(this.ctx,n.canvas,{backdropCanvas:e?.canvas??null,destTransform:t,backdropOffset:e?[o.offsetX+i.offsetX,o.offsetY+i.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}}else{if(i.replaceBackdrop){let e=new Path2D;e.rect(0,0,n.canvas.width,n.canvas.height),this.ctx.clip(e),this.ctx.globalCompositeOperation=`copy`}this.ctx.drawImage(n.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:n.canvas,context:n}),this.#y(i),this.compose(a)}}#v(e){let{canvas:t}=e,{width:n,height:r}=t;if(N4.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 i=e.getImageData(0,0,n,r),{data:a}=i;for(let e=0,t=a.length;e<t;e+=4){let t=a[e]*.2126+a[e+1]*.7152+a[e+2]*.0722+.5|0;a[e]=a[e+1]=a[e+2]=t}e.putImageData(i,0,0)}#y(e){e&&(e.knockoutMaskEntry&&=(this.canvasFactory.destroy(e.knockoutMaskEntry),null),e.knockoutTempEntry&&=(this.canvasFactory.destroy(e.knockoutTempEntry),null),e.knockoutBackdropEntry&&=(this.canvasFactory.destroy(e.knockoutBackdropEntry),null))}beginAnnotation(e,t,n,r,i,a,o){if(this.#u(),y8(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),n){let i=n[2]-n[0],s=n[3]-n[1];if(a&&this.annotationCanvasMap){r=r.slice(),r[4]-=n[0],r[5]-=n[1],n=n.slice(),n[0]=n[1]=0,n[2]=i,n[3]=s,$.singularValueDecompose2dScale(d3(this.ctx),f8);let{viewportScale:e}=this,a=Math.ceil(i*this.outputScaleX*e),c=Math.ceil(s*this.outputScaleY*e);this.annotationCanvas=this.canvasFactory.create(a,c);let{canvas:l,context:u}=this.annotationCanvas;if(o){let e=this.annotationCanvasMap.getOrInsertComputed(t,B4);l.setAttribute(`data-canvas-name`,o);let n=e.findIndex(e=>e.getAttribute(`data-canvas-name`)===o);n===-1?e.push(l):e[n]=l}else this.annotationCanvasMap.set(t,l);this.annotationCanvas.savedCtx=this.ctx,this.ctx=u,this.ctx.save(),this.ctx.setTransform(f8[0],0,0,-f8[1],0,s*f8[1]),y8(this.ctx)}else{y8(this.ctx),this.endPath(e);let t=new Path2D;t.rect(n[0],n[1],i,s),this.ctx.clip(t)}}this.current=new h8(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(e,...r),this.transform(e,...i),this.baseTransform=d3(this.ctx)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),this.#d(),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 n=t.count;t=this.getObject(e,t.data,t),t.count=n;let r=this.#h(this.current.fillAlpha),i=this.ctx,a=this._createMaskCanvas(e,t),o=a.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(o,a.offsetX,a.offsetY),this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(e),i.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),this.#g(r)}paintImageMaskXObjectRepeat(e,t,n,r=0,i=0,a,o){if(!this.contentVisible)return;t=this.getObject(e,t.data,t);let s=this.#h(this.current.fillAlpha),c=this.ctx;c.save();let l=d3(c);c.transform(n,r,i,a,0,0);let u=this._createMaskCanvas(e,t);c.setTransform(1,0,0,1,u.offsetX-l[4],u.offsetY-l[5]),this.dependencyTracker?.resetBBox(e);for(let t=0,s=o.length;t<s;t+=2){let s=$.transform(l,[n,r,i,a,o[t],o[t+1]]);c.drawImage(u.canvas,s[4],s[5]),this.dependencyTracker?.recordBBox(e,this.ctx,s[4],s[4]+u.canvas.width,s[5],s[5]+u.canvas.height)}c.restore(),u.canvasEntry&&this.canvasFactory.destroy(u.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(e),this.#g(s)}paintImageMaskXObjectGroup(e,t){if(!this.contentVisible)return;let n=this.#h(this.current.fillAlpha),r=this.ctx,i=this.current.fillColor,a=this.current.patternFill;this.dependencyTracker?.resetBBox(e).recordDependencies(e,s6.transformAndFill);for(let n of t){let{data:t,width:o,height:s,transform:c}=n,l=this.canvasFactory.create(o,s),u=l.context;u.save(),_8(u,this.getObject(e,t,n)),u.globalCompositeOperation=`source-in`,u.fillStyle=a?i.getPattern(u,this,f3(r),X6.FILL,e):i,u.fillRect(0,0,o,s),u.restore(),r.save(),r.transform(...c),r.scale(1,-1),m8(r,l.canvas,0,0,o,s,0,-1,1,1),this.canvasFactory.destroy(l),this.dependencyTracker?.recordBBox(e,r,0,o,0,s),r.restore()}this.compose(),this.dependencyTracker?.recordOperation(e),this.#g(n)}paintImageXObject(e,t){if(!this.contentVisible)return;let n=this.getObject(e,t);if(!n){g4(`Dependent image isn't ready yet`);return}this.paintInlineImageXObject(e,n)}paintImageXObjectRepeat(e,t,n,r,i){if(!this.contentVisible)return;let a=this.getObject(e,t);if(!a){g4(`Dependent image isn't ready yet`);return}let o=a.width,s=a.height,c=[];for(let e=0,t=i.length;e<t;e+=2)c.push({transform:[n,0,0,r,i[e],i[e+1]],x:0,y:0,w:o,h:s});this.paintInlineImageXObjectGroup(e,a,c)}applyTransferMapsToCanvas(e){return this.current.transferMaps!==`none`&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter=`none`),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps===`none`)return{img:e.bitmap,canvasEntry:null};let{bitmap:t,width:n,height:r}=e,i=this.canvasFactory.create(n,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter=`none`,{img:i.canvas,canvasEntry:i}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;let n=t.width,r=t.height,i=this.#h(this.current.fillAlpha),a=this.ctx;this.save(e);let{filter:o}=a;o!==`none`&&o!==``&&(a.filter=`none`),a.scale(1/n,-1/r);let s,c=null;if(t.bitmap){let e=this.applyTransferMapsToBitmap(t);s=e.img,c=e.canvasEntry}else{let e=this.canvasFactory.create(n,r);g8(e.context,t),s=this.applyTransferMapsToCanvas(e.context),c=e}let l=this._scaleImage(s,f3(a));a.imageSmoothingEnabled=b8(d3(a),t.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(e).recordBBox(e,a,0,n,-r,0).recordDependencies(e,s6.imageXObject).recordOperation(e),this.imagesTracker?.record(a,n,r,this.dependencyTracker.clipBox)),m8(a,l.img,0,0,l.paintWidth,l.paintHeight,0,-r,n,r),l.tmpCanvas&&this.canvasFactory.destroy(l.tmpCanvas),c&&this.canvasFactory.destroy(c),this.compose(),this.restore(e),this.#g(i)}paintInlineImageXObjectGroup(e,t,n){if(!this.contentVisible)return;let r=this.#h(this.current.fillAlpha),i=this.ctx,a,o=null;if(t.bitmap)a=t.bitmap;else{let e=t.width,n=t.height,r=this.canvasFactory.create(e,n);g8(r.context,t),a=this.applyTransferMapsToCanvas(r.context),o=r}this.dependencyTracker?.resetBBox(e);for(let t of n)i.save(),i.transform(...t.transform),i.scale(1,-1),m8(i,a,t.x,t.y,t.w,t.h,0,-1,1,1),this.dependencyTracker?.recordBBox(e,i,0,1,-1,0),i.restore();o&&this.canvasFactory.destroy(o),this.dependencyTracker?.recordOperation(e),this.compose(),this.#g(r)}paintSolidColorImageMask(e){if(!this.contentVisible)return;let t=this.#h(this.current.fillAlpha);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,s6.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose(),this.#g(t)}markPoint(e,t){}markPointProps(e,t,n){}beginMarkedContent(e,t){this.dependencyTracker?.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,n){this.dependencyTracker?.beginMarkedContent(e),t===`OC`?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(n)}):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,n){let r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(n);let i=this.ctx;this.pendingClip?(r||(this.pendingClip===w8?i.clip(t,`evenodd`):i.clip(t)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(e).recordFutureForcedDependency(`clipPath`,e)):this.dependencyTracker?.recordOperation(e),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=d3(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]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:n,c:r,d:i}=this.ctx.getTransform(),a,o;if(n===0&&r===0){let n=Math.abs(t),r=Math.abs(i);if(n===r){if(e===0)a=o=1/n;else{let t=n*e;a=o=t<1?1/t:1}}else if(e===0)a=1/n,o=1/r;else{let t=n*e,i=r*e;a=t<1?1/t:1,o=i<1?1/i:1}}else{let s=Math.abs(t*i-n*r),c=Math.hypot(t,n),l=Math.hypot(r,i);if(e===0)a=l/s,o=c/s;else{let t=e*s;a=l>t?l/t:1,o=c>t?c/t:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,t){let{ctx:n,current:{lineWidth:r}}=this,[i,a]=this.getScaleForStroking();if(i===a){n.lineWidth=(r||1)*i,n.stroke(e);return}let o=n.getLineDash();t&&n.save(),n.scale(i,a),d8.a=1/i,d8.d=1/a;let s=new Path2D;if(s.addPath(e,d8),o.length>0){let e=Math.max(i,a);n.setLineDash(o.map(t=>t/e)),n.lineDashOffset/=e}n.lineWidth=r||1,n.stroke(s),t&&n.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 l4)T8.prototype[e]!==void 0&&(T8.prototype[l4[e]]=T8.prototype[e]);var E8=class{#e=null;#t=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(e,t,n){this._source=e,this.#e=t,this.#t=n}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return v4(!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 n=new this.#t(this,e,t);return this._rangeReaders.add(n),n}cancelAllRequests(e){this._fullReader?.cancel(e);for(let t of new Set(this._rangeReaders))t.cancel(e)}},D8=class{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(){_4("Abstract method `read` called")}cancel(e){_4("Abstract method `cancel` called")}},O8=class{_stream=null;constructor(e,t,n){this._stream=e}async read(){_4("Abstract method `read` called")}cancel(e){_4("Abstract method `cancel` called")}};function k8(e){let t=!0,n=r(`filename\\*`,`i`).exec(e);if(n){n=n[1];let e=s(n);return e=unescape(e),e=c(e),e=l(e),a(e)}if(n=o(e),n)return a(l(n));if(n=r(`filename`,`i`).exec(e),n){n=n[1];let e=s(n);return e=l(e),a(e)}function r(e,t){return RegExp(`(?:^|;)\\s*`+e+`\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)`,t)}function i(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),i=M4(n);n=r.decode(i),t=!1}catch{}}return n}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=i(`utf-8`,e),t&&(e=i(`iso-8859-1`,e))),e}function o(e){let t=[],n,i=r(`filename\\*((?!0\\d)\\d+)(\\*?)`,`ig`);for(;(n=i.exec(e))!==null;){let[,e,r,i]=n;if(e=parseInt(e,10),e in t){if(e===0)break;continue}t[e]=[r,i]}let a=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=s(r),n&&(r=unescape(r),e===0&&(r=c(r))),a.push(r)}return a.join(``)}function s(e){if(e.startsWith(`"`)){let t=e.slice(1).split(`\\"`);for(let e=0;e<t.length;++e){let n=t[e].indexOf(`"`);n!==-1&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,`$1`)}e=t.join(`"`)}return e}function c(e){let t=e.indexOf(`'`);return t===-1?e:i(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,``))}function l(e){return!e.startsWith(`=?`)||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(e,t,n,r){if(n===`q`||n===`Q`)return r=r.replaceAll(`_`,` `),r=r.replaceAll(/=([0-9a-f]{2})/gi,function(e,t){return String.fromCharCode(parseInt(t,16))}),i(t,r);try{r=atob(r)}catch{}return i(t,r)})}return``}function A8(e,t){let n=new Headers;if(!e||!t||typeof t!=`object`)return n;for(let e in t){let r=t[e];r!==void 0&&n.append(e,r)}return n}function j8(e){return URL.parse(e)?.origin??null}function M8({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){let i={contentLength:0,isRangeSupported:!1},a=parseInt(e.get(`Content-Length`),10);return!Number.isInteger(a)||(i.contentLength=a,a<=2*n)||r||!t||e.get(`Accept-Ranges`)!==`bytes`||(e.get(`Content-Encoding`)||`identity`)===`identity`&&(i.isRangeSupported=!0),i}function N8(e){let t=e.get(`Content-Disposition`);if(t){let e=k8(t);if(e.includes(`%`))try{e=decodeURIComponent(e)}catch{}if(e3(e))return e}return null}function P8(e,t){return new O4(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,e===404||e===0&&t.protocol===`file:`)}function F8(e,t){if(e!==t)throw Error(`Expected range response-origin "${e}" to match "${t}".`)}function I8(e,t,n,r){return fetch(e,{method:`GET`,headers:t,signal:r.signal,mode:`cors`,credentials:n?`include`:`same-origin`,redirect:`follow`})}function L8(e,t){if(e!==200&&e!==206)throw P8(e,t)}function R8(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw Error(`getArrayBuffer - unexpected data: ${e}`)}var z8=class extends E8{_responseOrigin=null;constructor(e){super(e,B8,V8);let{httpHeaders:t,url:n}=e;v4(/https?:/.test(n.protocol),`PDFFetchStream only supports http(s):// URLs.`),this.headers=A8(!0,t)}},B8=class extends D8{_abortController=new AbortController;_reader=null;constructor(e){super(e);let{disableRange:t,disableStream:n,rangeChunkSize:r,url:i,withCredentials:a}=e._source;this._isStreamingSupported=!n,I8(i,new Headers(e.headers),a,this._abortController).then(n=>{e._responseOrigin=j8(n.url),L8(n.status,i),this._reader=n.body.getReader();let a=n.headers,{contentLength:o,isRangeSupported:s}=M8({responseHeaders:a,isHttp:!0,rangeChunkSize:r,disableRange:t});this._contentLength=o,this._isRangeSupported=s,this._filename=N8(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new A4(`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();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:R8(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},V8=class extends O8{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(e,t,n){super(e,t,n);let{url:r,withCredentials:i}=e._source,a=new Headers(e.headers);a.append(`Range`,`bytes=${t}-${n-1}`),I8(r,a,i,this._abortController).then(t=>{F8(j8(t.url),e._responseOrigin),L8(t.status,r),this._reader=t.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:{value:R8(e),done:!1}}cancel(e){this._reader?.cancel(e),this._abortController.abort()}};function H8(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function U8(){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}var W8=class extends E8{_progressiveDone=!1;_queuedChunks=[];constructor(e){super(e,G8,K8);let{pdfDataRangeTransport:t}=e,{initialData:n,progressiveDone:r}=t;if(n?.length>0){let e=H8(n);this._queuedChunks.push(e)}this._progressiveDone=r,t.transportReady(e=>{switch(e.type){case`range`:case`progressiveRead`:this.#e(e.begin,e.chunk);break;case`progressiveDone`:this._fullReader?.progressiveDone(),this._progressiveDone=!0}})}#e(e,t){let n=H8(t);if(e===void 0)this._fullReader?this._fullReader._enqueue(n):this._queuedChunks.push(n);else{let t=this._rangeReaders.keys().find(t=>t._begin===e);v4(t,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),t._enqueue(n)}}getFullReader(){let e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,t){let n=super.getRangeReader(e,t);return n&&(n.onDone=()=>this._rangeReaders.delete(n),this._source.pdfDataRangeTransport.requestDataRange(e,t)),n}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}},G8=class extends D8{#e=U8.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(e){super(e);let{pdfDataRangeTransport:t,disableRange:n,disableStream:r}=e._source,{length:i,contentDispositionFilename:a}=t;this._queuedChunks=e._queuedChunks||[];for(let e of this._queuedChunks)this._loaded+=e.byteLength;this._done=e._progressiveDone,this._contentLength=i,this._isStreamingSupported=!r,this._isRangeSupported=!n,e3(a)&&(this._filename=a),this._headersCapability.resolve();let o=this._loaded;Promise.resolve().then(()=>{o>0&&this._loaded===o&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):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(){this._done||=!0,this._queuedChunks.length===0&&this.#e()}},K8=class extends O8{#e=U8.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(e,t,n){super(e,t,n),this._begin=t}_enqueue(e){this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),this.#e()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,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?.()}},q8=200,J8=206;function Y8(e){return typeof e==`string`?M4(e).buffer:e}var X8=class extends E8{#e=new WeakMap;_responseOrigin=null;constructor(e){super(e,Z8,Q8);let{httpHeaders:t,url:n}=e;this.url=n,this.isHttp=/https?:/.test(n.protocol),this.headers=A8(this.isHttp,t)}_request(e){let t=new XMLHttpRequest,n={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};this.#e.set(t,n),t.open(`GET`,this.url),t.withCredentials=this._source.withCredentials;for(let[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&`begin`in e&&`end`in e?(t.setRequestHeader(`Range`,`bytes=${e.begin}-${e.end-1}`),n.validateStatus=e=>e===J8||e===q8):n.validateStatus=e=>e===q8,t.responseType=`arraybuffer`,v4(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>e.onError(t.status),t.onreadystatechange=this.#n.bind(this,t),t.onprogress=this.#t.bind(this,t),t.send(null),t}#t(e,t){this.#e.get(e)?.onProgress?.(t)}#n(e,t){let n=this.#e.get(e);if(!n||(e.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),e.readyState!==4)||!this.#e.has(e))return;if(this.#e.delete(e),e.status===0&&this.isHttp){n.onError(e.status);return}let r=e.status||q8;if(!n.validateStatus(r)){n.onError(e.status);return}let i=Y8(e.response);if(r===J8){let t=e.getResponseHeader(`Content-Range`);/bytes \d+-\d+\/\d+/.test(t)?n.onDone(i):(g4(`Missing or invalid "Content-Range" header.`),n.onError(0))}else i?n.onDone(i):n.onError(e.status)}_abortRequest(e){this.#e.has(e)&&(this.#e.delete(e),e.abort())}getRangeReader(e,t){let n=super.getRangeReader(e,t);return n&&(n.onClosed=()=>this._rangeReaders.delete(n)),n}},Z8=class extends D8{#e=U8.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(e){super(e),this._fullRequestXhr=e._request({onHeadersReceived:this.#t.bind(this),onDone:this.#n.bind(this),onError:this.#r.bind(this),onProgress:this.#i.bind(this)})}#t(){let e=this._stream,{disableRange:t,rangeChunkSize:n}=e._source,r=this._fullRequestXhr;e._responseOrigin=j8(r.responseURL);let i=r.getAllResponseHeaders(),a=new Headers(i?i.trimStart().replace(/[^\S ]+$/,``).split(/[\r\n]+/).map(e=>{let[t,...n]=e.split(`: `);return[t,n.join(`: `)]}):[]),{contentLength:o,isRangeSupported:s}=M8({responseHeaders:a,isHttp:e.isHttp,rangeChunkSize:n,disableRange:t});this._contentLength=o,this._isRangeSupported=s,this._filename=N8(a),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()}#n(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&this.#e()}#r(e){this._storedError=P8(e,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#i(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}},Q8=class extends O8{#e=U8.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(e,t,n){super(e,t,n),this._requestXhr=e._request({begin:t,end:n,onHeadersReceived:this.#t.bind(this),onDone:this.#n.bind(this),onError:this.#r.bind(this),onProgress:null})}#t(){let e=j8(this._requestXhr?.responseURL);try{F8(e,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#r(0)}}#n(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this.#e(),this.onClosed?.()}#r(e){this._storedError??=P8(e,this._stream.url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,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 $8(e,n=null){let r=t.getBuiltinModule(`fs`),{Readable:i}=t.getBuiltinModule(`stream`),a=r.createReadStream(e,n);return i.toWeb(a)}var e5=class extends E8{constructor(e){super(e,t5,n5);let{url:t}=e;v4(t.protocol===`file:`,`PDFNodeStream only supports file:// URLs.`)}},t5=class extends D8{_reader=null;constructor(e){super(e);let{disableRange:n,disableStream:r,rangeChunkSize:i,url:a}=e._source;this._isStreamingSupported=!r,t.getBuiltinModule(`fs/promises`).lstat(a).then(e=>{let t=$8(a);this._reader=t.getReader();let{size:r}=e;this._contentLength=r,this._isRangeSupported=!n&&r>2*i,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new A4(`Streaming is disabled.`)),this._headersCapability.resolve()}).catch(e=>{e.code===`ENOENT`&&(e=P8(0,a)),this._headersCapability.reject(e)})}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:R8(e),done:!1})}cancel(e){this._reader?.cancel(e)}},n5=class extends O8{_readCapability=Promise.withResolvers();_reader=null;constructor(e,t,n){super(e,t,n);let{url:r}=e._source;try{let e=$8(r,{start:t,end:n-1});this._reader=e.getReader(),this._readCapability.resolve()}catch(e){this._readCapability.reject(e)}}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:{value:R8(e),done:!1}}cancel(e){this._reader?.cancel(e)}};function r5(e){return i3(e)?z8:K2?e5:X8}var i5=class{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}},a5=class{#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()}},o5=Symbol(`INTERNAL`),s5=class{#e=!1;#t=!1;#n=!1;#r=!0;constructor(e,{name:t,intent:n,usage:r,rbGroups:i}){this.#e=!!(e&Z2.DISPLAY),this.#t=!!(e&Z2.PRINT),this.name=t,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(this.#n)return this.#r;if(!this.#r)return!1;let{print:e,view:t}=this.usage;return this.#e?t?.viewState!==`OFF`:!this.#t||e?.printState!==`OFF`}_setVisible(e,t,n=!1){e!==o5&&_4("Internal method `_setVisible` called."),this.#n=n,this.#r=t}get serializable(){return{userSet:this.#n,visible:this.#r}}},c5=class e{#e=null;#t=new Map;#n=null;#r=null;#i;creator=null;name=null;constructor(e,t=Z2.DISPLAY,n=null){if(this.#i=e,this.renderingIntent=t,e!==null){this.name=e.name,this.creator=e.creator,this.#r=e.order;for(let n of e.groups)this.#t.set(n.id,new s5(t,n));if(n){n.size!==this.#t.size&&_4(`Incorrect serialized groupState.`);for(let[e,t]of n)this.#t.get(e)._setVisible(o5,t.visible,t.userSet)}else{if(e.baseState===`OFF`)for(let e of this.#t.values())e._setVisible(o5,!1);for(let t of e.on)this.#t.get(t)._setVisible(o5,!0);for(let t of e.off)this.#t.get(t)._setVisible(o5,!1)}this.#n=this.getHash()}}#a(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let r=1;r<t;r++){let t=e[r],i;if(Array.isArray(t))i=this.#a(t);else if(this.#t.has(t))i=this.#t.get(t).visible;else return g4(`Optional content group not found: ${t}`),!0;switch(n){case`And`:if(!i)return!1;break;case`Or`:if(i)return!0;break;case`Not`:return!i;default:return!0}}return n===`And`}isVisible(e){if(this.#t.size===0)return!0;if(!e)return h4(`Optional content group not defined.`),!0;if(e.type===`OCG`)return this.#t.has(e.id)?this.#t.get(e.id).visible:(g4(`Optional content group not found: ${e.id}`),!0);if(e.type===`OCMD`){if(e.expression)return this.#a(e.expression);if(!e.policy||e.policy===`AnyOn`){for(let t of e.ids){if(!this.#t.has(t))return g4(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!0}return!1}if(e.policy===`AllOn`){for(let t of e.ids){if(!this.#t.has(t))return g4(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!1}return!0}if(e.policy===`AnyOff`){for(let t of e.ids){if(!this.#t.has(t))return g4(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!0}return!1}if(e.policy===`AllOff`){for(let t of e.ids){if(!this.#t.has(t))return g4(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return g4(`Unknown optional content policy ${e.policy}.`),!0}return g4(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){let r=this.#t.get(e);if(!r){g4(`Optional content group not found: ${e}`);return}if(n&&t&&r.rbGroups.length)for(let t of r.rbGroups)for(let n of t)n!==e&&this.#t.get(n)?._setVisible(o5,!1,!0);r._setVisible(o5,!!t,!0),this.#e=null}setOCGState({state:e,preserveRB:t}){let n;for(let r of e){switch(r){case`ON`:case`OFF`:case`Toggle`:n=r;continue}let e=this.#t.get(r);if(e)switch(n){case`ON`:this.setVisibility(r,!0,t);break;case`OFF`:this.setVisibility(r,!1,t);break;case`Toggle`:this.setVisibility(r,!e.visible,t)}}this.#e=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#t.size?this.#r?this.#r.slice():[...this.#t.keys()]:null}getGroup(e){return this.#t.get(e)||null}getHash(){if(this.#e!==null)return this.#e;let e=new K3;for(let[t,n]of this.#t)e.update(`${t}:${n.visible}`);return this.#e=e.hexdigest()}[Symbol.iterator](){return this.#t.entries()}get serializable(){let e=new Map;for(let[t,n]of this.#t)e.set(t,n.serializable);return{data:this.#i,renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:t,renderingIntent:n,groupState:r}){return new e(t,n,r)}},l5=class{#e=null;#t=null;#n=0;#r=null;#i=null;get pagesNumber(){return this.#n}set pagesNumber(e){this.#n!==e&&(this.#n=e,this.#e=null,this.#t=null)}#a(){if(this.#e)return;let e=this.#n,t=this.#e=new Uint32Array(e);for(let n=0;n<e;n++)t[n]=n+1;this.#t=new Int32Array(t)}#o(){let e=new Map,t=this.#e;for(let n=0,r=this.#n;n<r;n++){let r=t[n],i=e.get(r);i?i.push(n+1):e.set(r,[n+1])}return e}movePages(e,t,n){this.#a();let r=this.#e,i=this.#o(),a=t.length,o=new Uint32Array(a),s=0;for(let e=0;e<a;e++){let i=t[e]-1;o[e]=r[i],i<n&&s++}let c=this.#n,l=c-a,u=W4(n-s,0,l);for(let t=0,n=0;t<c;t++)e.has(t+1)||(r[n++]=r[t]);r.copyWithin(u+a,u,l),r.set(o,u),this.#s(i),r.every((e,t)=>e===t+1)&&(this.#e=null)}deletePages(e){this.#a();let t=this.#e,n=this.#o();this.#i={pageNumberToId:t.slice(),pagesNumber:this.#n,prevPageNumbers:this.#t.slice()};let r=this.#n-e.length;this.#n=r;let i=this.#e=new Uint32Array(r);this.#t=new Int32Array(r);let a=0,o=0;for(let n of e){let e=n-1;e!==a&&(i.set(t.subarray(a,e),o),o+=e-a),a=e+1}a<t.length&&i.set(t.subarray(a),o),this.#s(n,new Set(e))}cancelDelete(){this.#i&&=(this.#e=this.#i.pageNumberToId,this.#n=this.#i.pagesNumber,this.#t=this.#i.prevPageNumbers,null)}cleanSavedData(){this.#i=null}copyPages(e){this.#a(),this.#r={pageNumbers:e,pageIds:e.map(e=>this.#e[e-1])}}cancelCopy(){this.#r=null}pastePages(e){this.#a();let t=this.#e,n=this.#o(),{pageNumbers:r,pageIds:i}=this.#r,a=this.#n+r.length;this.#n=a;let o=this.#e=new Uint32Array(a);this.#t=new Int32Array(a),o.set(t.subarray(0,e),0),o.set(i,e),o.set(t.subarray(e),e+r.length),this.#s(n,null,e,r),this.#r=null}#s(e,t=null,n=-1,r=null){let i=this.#t,a=this.#e,o=n+(r?.length??0),s=new Map;for(let c=0,l=this.#n;c<l;c++){if(c>=n&&c<o){i[c]=-r[c-n];continue}let l=a[c],u=e.get(l),d=s.get(l)||0;if(t&&u)for(;d<u.length&&t.has(u[d]);)d++;i[c]=u?.[d],s.set(l,d+1)}}hasBeenAltered(){return this.#e!==null}getPageMappingForSaving(e=null){e??=this.#o();let t=0;for(let n of e.values())t=Math.max(t,n.length);let n=Array(t);for(let e=0;e<t;e++)n[e]={document:null,pageIndices:[],includePages:[]};for(let[t,r]of e)for(let e=0,i=r.length;e<i;e++)n[e].includePages.push([t-1,r[e]-1]);for(let{includePages:e,pageIndices:t}of n){e.sort((e,t)=>e[0]-t[0]);for(let n=0,r=e.length;n<r;n++)t.push(e[n][1]),e[n]=e[n][0]}return n}extractPages(e){e=Array.from(e).sort((e,t)=>e-t);let t=new Map;for(let n=0,r=e.length;n<r;n++){let r=this.getPageId(e[n]);t.getOrInsertComputed(r,B4).push(n+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 n=0,r=this.#n;n<r;n++)if(t[n]===e)return n+1;return 0}getPageId(e){return this.#e?.[e-1]??e}getMapping(){return this.#e?.subarray(0,this.pagesNumber)}},u5=Symbol(`INITIAL_DATA`),d5=()=>({...Promise.withResolvers(),data:u5}),f5=class{#e=new Map;get(e,t=null){if(t){let n=this.#e.getOrInsertComputed(e,d5);return n.promise.then(()=>t(n.data)),null}let n=this.#e.get(e);if(!n||n.data===u5)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=this.#e.get(e);return!!t&&t.data!==u5}delete(e){let t=this.#e.get(e);return!t||t.data===u5?!1:(this.#e.delete(e),!0)}resolve(e,t=null){let n=this.#e.getOrInsertComputed(e,d5);if(n.data!==u5)throw Error(`Object already resolved ${e}.`);n.data=t,n.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)t!==u5&&(yield[e,t])}},p5=1e5,m5=30,h5=class e{#e=Promise.withResolvers();#t=null;#n=!1;#r=!!globalThis.FontInspector?.enabled;#i=null;#a=null;#o=null;#s=0;#c=0;#l=null;#u=null;#d=0;#f=0;#p=Object.create(null);#m=[];#h=null;#g=[];#_=new WeakMap;#v=null;static#y=new Map;static#b=new Map;static#x=new WeakMap;static#S=null;static#C=new Set;constructor({textContentSource:t,images:n,container:r,viewport:i}){if(t instanceof ReadableStream)this.#h=t;else if(typeof t==`object`)this.#h=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error(`No "textContentSource" parameter specified.`);this.#t=this.#u=r,this.#i=n,this.#f=i.scale*m3.pixelRatio,this.#d=i.rotation,this.#o={div:null,properties:null,ctx:null};let{pageWidth:a,pageHeight:o,pageX:s,pageY:c}=i.rawDims;this.#v=[1,0,0,-1,-s,c+o],this.#c=a,this.#s=o,e.#k(),r.style.setProperty(`--min-font-size`,e.#S),p3(r,i),this.#e.promise.finally(()=>{e.#C.delete(this),this.#o=null,this.#p=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=N4.platform;return C4(this,`fontFamilyMap`,new Map([[`sans-serif`,`${e&&t?`Calibri, `:``}sans-serif`],[`monospace`,`${e&&t?`Lucida Console, `:``}monospace`]]))}render(){this.#i&&this.#t.append(this.#i.render());let t=()=>{this.#l.read().then(({value:e,done:n})=>{if(n){this.#e.resolve();return}this.#a??=e.lang,Object.assign(this.#p,e.styles),this.#w(e.items),t()},this.#e.reject)};return this.#l=this.#h.getReader(),e.#C.add(this),t(),this.#e.promise}update({viewport:t,onBefore:n=null}){let r=t.scale*m3.pixelRatio,i=t.rotation;if(i!==this.#d&&(n?.(),this.#d=i,p3(this.#u,{rotation:i})),r!==this.#f){n?.(),this.#f=r;let t={div:null,properties:null,ctx:e.#D(this.#a)};for(let e of this.#g)t.properties=this.#_.get(e),t.div=e,this.#E(t)}}cancel(){let e=new A4(`TextLayer task cancelled.`);this.#l?.cancel(e).catch(()=>{}),this.#l=null,this.#e.reject(e)}get textDivs(){return this.#g}get textContentItemsStr(){return this.#m}#w(t){if(this.#n)return;this.#o.ctx??=e.#D(this.#a);let n=this.#g,r=this.#m;for(let e of t){if(n.length>p5){g4(`Ignoring additional textDivs for performance reasons.`),this.#n=!0;return}if(e.str===void 0){if(e.type===`beginMarkedContentProps`||e.type===`beginMarkedContent`){let t=this.#t;this.#t=document.createElement(`span`),this.#t.classList.add(`markedContent`),e.id&&this.#t.setAttribute(`id`,e.id),e.tag===`Artifact`&&(this.#t.ariaHidden=!0),t.append(this.#t)}else e.type===`endMarkedContent`&&(this.#t=this.#t.parentNode);continue}r.push(e.str),this.#T(e)}}#T(t){let n=document.createElement(`span`),r={angle:0,canvasWidth:0,hasText:t.str!==``,hasEOL:t.hasEOL,fontSize:0};this.#g.push(n);let i=$.transform(this.#v,t.transform),a=Math.atan2(i[1],i[0]),o=this.#p[t.fontName];o.vertical&&(a+=Math.PI/2);let s=this.#r&&o.fontSubstitution||o.fontFamily;s=e.fontFamilyMap.get(s)||s;let c=Math.hypot(i[2],i[3]),l=c*e.#A(s,o,this.#a),u,d;a===0?(u=i[4],d=i[5]-l):(u=i[4]+l*Math.sin(a),d=i[5]-l*Math.cos(a));let f=n.style;f.left=`${(100*u/this.#c).toFixed(2)}%`,f.top=`${(100*d/this.#s).toFixed(2)}%`,f.setProperty(`--font-height`,`${c.toFixed(2)}px`),f.fontFamily=s,r.fontSize=c,n.setAttribute(`role`,`presentation`),n.textContent=t.str,n.dir=t.dir,this.#r&&(n.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),a!==0&&(r.angle=180/Math.PI*a);let p=!1;if(t.str.length>1)p=!0;else if(t.str!==` `&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(p=!0)}if(p&&(r.canvasWidth=o.vertical?t.height:t.width),this.#_.set(n,r),this.#o.div=n,this.#o.properties=r,this.#E(this.#o),r.hasText&&this.#t.append(n),r.hasEOL){let e=document.createElement(`br`);e.setAttribute(`role`,`presentation`),this.#t.append(e)}}#E(t){let{div:n,properties:r,ctx:i}=t,{style:a}=n;if(r.canvasWidth!==0&&r.hasText){let{fontFamily:t}=a,{canvasWidth:o,fontSize:s}=r;e.#O(i,s*this.#f,t);let{width:c}=i.measureText(n.textContent);c>0&&a.setProperty(`--scale-x`,o*this.#f/c)}r.angle!==0&&a.setProperty(`--rotate`,`${r.angle}deg`)}static cleanup(){if(!(this.#C.size>0)){this.#y.clear();for(let{canvas:e}of this.#b.values())e.remove();this.#b.clear()}}static#D(e=null){let t=this.#b.get(e||=``);if(!t){let n=document.createElement(`canvas`);n.style.cssText=`position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal`,n.lang=e,document.body.append(n),t=n.getContext(`2d`,{alpha:!1,willReadFrequently:!0}),this.#b.set(e,t),this.#x.set(t,{size:0,family:``})}return t}static#O(e,t,n){let r=this.#x.get(e);(t!==r.size||n!==r.family)&&(e.font=`${t}px ${n}`,r.size=t,r.family=n)}static#k(){if(this.#S!==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.#S=e.getBoundingClientRect().height,e.remove()}static#A(e,t,n){let r=this.#y.get(e);if(r)return r;let i=this.#D(n);i.canvas.width=i.canvas.height=m5,this.#O(i,m5,e);let a=i.measureText(``),o=a.fontBoundingBoxAscent,s=Math.abs(a.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let c=.8;return o?c=o/(o+s):(N4.platform.isFirefox&&g4("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),t.ascent?c=t.ascent:t.descent&&(c=1+t.descent)),this.#y.set(e,c),c}},g5=100;function _5(e={}){let t=new v5,{docId:n}=t,r=e.url?b6(e.url):null,i=e.data?x6(e.data):null,a=e.httpHeaders||null,o=e.withCredentials===!0,s=e.password??null,c=e.range instanceof y5?e.range:null,l=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:2**16,u=e.worker instanceof S5?e.worker:null,d=e.verbosity,f=typeof e.docBaseUrl==`string`&&!$4(e.docBaseUrl)?e.docBaseUrl:null,p=S6(e.cMapUrl),m=e.cMapPacked!==!1,h=S6(e.iccUrl),g=S6(e.standardFontDataUrl),_=S6(e.wasmUrl),v=e.stopAtErrors!==!0,y=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,b=typeof e.isOffscreenCanvasSupported==`boolean`?e.isOffscreenCanvasSupported:!K2,x=typeof e.isImageDecoderSupported==`boolean`?e.isImageDecoderSupported:!K2,S=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,C=typeof e.disableFontFace==`boolean`?e.disableFontFace:K2,w=e.fontExtraProperties===!0,T=e.enableXfa===!0,E=e.ownerDocument||globalThis.document,D=e.disableRange===!0,O=e.disableStream===!0,k=e.disableAutoFetch===!0,A=e.pdfBug===!0,j=e.CanvasFactory||(K2?B6:P6),M=e.FilterFactory||(K2?z6:I6),N=e.BinaryDataFactory||(K2?V6:M6),P=e.enableHWA===!0,F=e.enableWebGPU===!0?K6():Promise.resolve(!1),I=e.useWasm!==!1,L=e.pagesMapper||new l5,R=typeof e.useSystemFonts==`boolean`?e.useSystemFonts:!K2&&!C,z=typeof e.useWorkerFetch==`boolean`?e.useWorkerFetch:!!(N===M6&&p&&m&&g&&_&&i3(p,document.baseURI)&&i3(g,document.baseURI)&&i3(_,document.baseURI));p4(d);let B={canvasFactory:new j({ownerDocument:E,enableHWA:P}),filterFactory:new M({docId:n,ownerDocument:E}),binaryDataFactory:z?null:new N({cMapUrl:p,standardFontDataUrl:g,wasmUrl:_})};u||(u=S5.create({verbosity:d,port:i5.workerPort}),t._worker=u);let V={docId:n,apiVersion:`6.2.108`,data:i,password:s,disableAutoFetch:k,rangeChunkSize:l,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:y,disableFontFace:C,ignoreErrors:v,isOffscreenCanvasSupported:b,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:w,useSystemFonts:R,useWasm:I,useWorkerFetch:z,cMapUrl:p,cMapPacked:m,iccUrl:h,standardFontDataUrl:g,wasmUrl:_,hasGPU:!1}},ee={ownerDocument:E,pdfBug:A,styleElement:null,enableHWA:P,loadingParams:{disableAutoFetch:k,enableXfa:T}};return Promise.all([u.promise,F]).then(function([,e]){if(u.destroyed)throw Error(`Worker was destroyed`);V.evaluatorOptions.hasGPU=e;let s=u.messageHandler.sendWithPromise(`GetDocRequest`,V,i?[i.buffer]:null),d;if(!i){if(c)d=new W8({pdfDataRangeTransport:c,disableRange:D,disableStream:O});else if(r)d=new(r5(r))({url:r,httpHeaders:a,withCredentials:o,rangeChunkSize:l,disableRange:D,disableStream:O});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.")}return s.then(e=>{if(u.destroyed)throw Error(`Worker was destroyed`);let r=new A6(n,e,u.port),i=new C5(r,t,d,ee,B,L);if(t._transport=i,t.destroyed)throw Error(`Loading aborted`);r.send(`Ready`,null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var v5=class e{static#e=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${e.#e++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}},y5=class{#e=Promise.withResolvers();#t=null;constructor(e,t,n=!1,r=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r}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){_4(`Abstract method PDFDataRangeTransport.requestDataRange`)}abort(){}},b5=class{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 C4(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()}getSignatures(){return this._transport.getSignatures()}getSignatureData(e){return this._transport.getSignatureData(e)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}},x5=class e{#e=!1;#t=null;constructor(e,t,n,r,i=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=i?new r3:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new f5,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#t=r,this.imageCoordinates=null}clone(t){let n=new e(t,this._pageInfo,this._transport,this.#t,this._pdfBug);return n.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(n),n}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:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new G4({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:i})}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 C4(this,`isPureXfa`,!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,canvas:t=e.canvas,viewport:n,intent:r=`display`,annotationMode:i=Q2.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:s=null,annotationCanvasMap:c=null,pageColors:l=null,printAnnotationStorage:u=null,isEditing:d=!1,recordImages:f=!1,recordOperations:p=!1,operationsFilter:m=null}){this._stats?.time(`Overall`);let h=this._transport.getRenderingIntent(r,i,u,d),{renderingIntent:g,cacheKey:_}=h;this.#e=!1,s||=this._transport.getOptionalContentConfig(g);let v=this._intentStates.getOrInsertComputed(_,H4);v.streamReaderCancelTimeout&&=(clearTimeout(v.streamReaderCancelTimeout),null);let y=!!(g&Z2.PRINT);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(h));let b=!!(this._pdfBug&&globalThis.StepperManager?.enabled),x=!!t&&!this.recordedBBoxes&&(p||b),S=!!t&&!this.imageCoordinates&&f,C=e=>{if(v.renderTasks.delete(E),x){let e=E.gfx?.dependencyTracker.take();e&&(E.stepper?.setOperatorBBoxes(e,E.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=e))}S&&!e&&(this.imageCoordinates=E.gfx?.imagesTracker.take()),y&&(this.#e=!0),this.#n(),e?(E.capability.reject(e),this._abortOperatorList({intentState:v,reason:e instanceof Error?e:Error(e)})):E.capability.resolve(),this._stats&&(this._stats.timeEnd(`Rendering`),this._stats.timeEnd(`Overall`),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=null,T=null;(x||S)&&(T=new i6(t,v.operatorList.length)),x&&(w=new a6(T,b));let E=new T5({callback:C,params:{canvas:t,canvasContext:e,dependencyTracker:w??T,imagesTracker:S?new c6(t):null,viewport:n,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!y,pdfBug:this._pdfBug,pageColors:l,enableHWA:this._transport.enableHWA,operationsFilter:m});(v.renderTasks||=new Set).add(E);let D=E.task;return Promise.all([v.displayReadyCapability.promise,s]).then(([e,t])=>{if(this.destroyed){C();return}if(this._stats?.time(`Rendering`),!(t.renderingIntent&g))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");E.initializeGraphics({transparency:e,optionalContentConfig:t}),E.operatorListChanged()}).catch(C),D}getOperatorList({intent:e=`display`,annotationMode:t=Q2.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(s))}let a=this._transport.getRenderingIntent(e,t,n,r,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,H4),s;return o.opListReadCapability||(s=Object.create(null),s.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(s),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(a)),o.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(e){return e.items.length}})}async getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>K4.textContent(e));let t=this.streamTextContent(e),n={items:[],styles:Object.create(null),lang:null};for await(let e of t)n.lang??=e.lang,Object.assign(n.styles,e.styles),n.items.push(...e.items);return n}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)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#e=!1,Promise.all(e)}cleanup(e=!1){this.#e=!0;let t=this.#n();return e&&t&&(this._stats&&=new r3),t}#n(){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 n=this._intentStates.get(t);n&&(this._stats?.timeEnd(`Page Request`),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#n()}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){let{map:i,transfer:a}=n,o=this._transport.messageHandler.sendWithStream(`GetOperatorList`,{pageId:this.#t.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i,modifiedIds:r},void 0,a).getReader(),s=this._intentStates.get(t);s.streamReader=o;let c=()=>{o.read().then(({value:e,done:t})=>{if(t){s.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(e,s),c())},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(let e of s.renderTasks)e.operatorListChanged();this.#n()}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};c()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&=(clearTimeout(e.streamReaderCancelTimeout),null),!n){if(e.renderTasks.size>0)return;if(t instanceof Q4){let n=g5;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new A4(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}},S5=class e{#e=Promise.withResolvers();#t=null;#n=null;#r=null;static#i=0;static#a=!1;static#o=new WeakMap;static{K2&&(this.#a=!0,i5.workerSrc||=`./pdf.worker.mjs`),this._isSameOrigin=(e,t)=>{let n=URL.parse(e);if(!n?.origin||n.origin===`null`)return!1;let r=new URL(t,n);return n.origin===r.origin},this._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:`text/javascript`}))}}constructor({name:t=null,port:n=null,verbosity:r=m4()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=r,n){if(e.#o.has(n))throw Error(`Cannot use more than one PDFWorker per port.`);e.#o.set(n,this),this.#c(n)}else this.#l()}get promise(){return this.#e.promise}#s(){this.#e.resolve(),this.#t.send(`configure`,{verbosity:this.verbosity})}get port(){return this.#n}get messageHandler(){return this.#t}#c(e){this.#n=e,this.#t=new A6(`main`,`worker`,e),this.#t.on(`ready`,()=>{}),this.#s()}#l(){if(e.#a||e.#d){this.#u();return}let{workerSrc:t}=e;try{e._isSameOrigin(window.location,t)||(t=e._createCDNWrapper(new URL(t,window.location).href));let n=new Worker(t,{type:`module`}),r=new A6(`main`,`worker`,n),i=()=>{a.abort(),r.destroy(),n.terminate(),this.destroyed?this.#e.reject(Error(`Worker was destroyed`)):this.#u()},a=new AbortController;n.addEventListener(`error`,()=>{this.#r||i()},{signal:a.signal}),r.on(`test`,e=>{if(a.abort(),this.destroyed||!e){i();return}this.#t=r,this.#n=n,this.#r=n,this.#s()}),r.on(`ready`,e=>{if(a.abort(),this.destroyed){i();return}try{o()}catch{this.#u()}});let o=()=>{let e=new Uint8Array;r.send(`test`,e,[e.buffer])};o();return}catch{h4(`The worker has been disabled.`)}this.#u()}#u(){e.#a||=(g4(`Setting up fake worker.`),!0),e._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this.#e.reject(Error(`Worker was destroyed`));return}let n=new T6;this.#n=n;let r=`fake${e.#i++}`,i=new A6(r+`_worker`,r,n);t.setup(i,n),this.#t=new A6(r,r+`_worker`,n),this.#s()}).catch(e=>{this.#e.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this.#r?.terminate(),this.#r=null,e.#o.delete(this.#n),this.#n=null,this.#t?.destroy(),this.#t=null}static create(t){let n=this.#o.get(t?.port);if(n){if(n._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new e(t)}static get workerSrc(){if(i5.workerSrc)return i5.workerSrc;throw Error(`No "GlobalWorkerOptions.workerSrc" specified.`)}static get#d(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return C4(this,`_setupFakeWorkerGlobal`,(async()=>this.#d?this.#d:(await ht(()=>import(this.workerSrc),[])).WorkerMessageHandler)())}},C5=class{downloadInfoCapability=Promise.withResolvers();#e=null;#t=new Map;#n=null;#r=new Map;#i=new Map;#a=new Map;#o=null;constructor(e,t,n,r,i,a){this.messageHandler=e,this.loadingTask=t,this.#n=n,this.commonObjs=new f5,this.fontLoader=new l6({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.enableHWA=r.enableHWA,this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.binaryDataFactory=i.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(e){let{_pageIndex:t}=e;this.#r.set(t,e),this.#i.set(t,Promise.resolve(e))}#s(e,t=null){return this.#t.getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}#c({loaded:e,total:t}){this.loadingTask.onProgress?.({loaded:e,total:t,percent:t?W4(Math.round(e/t*100),0,100):NaN})}get annotationStorage(){return C4(this,`annotationStorage`,new J3)}getRenderingIntent(e,t=Q2.ENABLE,n=null,r=!1,i=!1){let a=Z2.DISPLAY,o=q3;switch(e){case`any`:a=Z2.ANY;break;case`display`:break;case`print`:a=Z2.PRINT;break;default:g4(`getRenderingIntent - invalid intent: ${e}`)}let s=a&Z2.PRINT&&n instanceof Y3?n:this.annotationStorage;switch(t){case Q2.DISABLE:a+=Z2.ANNOTATIONS_DISABLE;break;case Q2.ENABLE:break;case Q2.ENABLE_FORMS:a+=Z2.ANNOTATIONS_FORMS;break;case Q2.ENABLE_STORAGE:a+=Z2.ANNOTATIONS_STORAGE,o=s.serializable;break;default:g4(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(a+=Z2.IS_EDITING),i&&(a+=Z2.OPLIST);let{ids:c,hash:l}=s.modifiedIds,u=[a,o.hash,l];return{renderingIntent:a,cacheKey:u.join(`_`),annotationStorageSerializable:o,modifiedIds:c}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(Error(`Worker was destroyed during onPassword callback`));let e=[];for(let t of this.#r.values())e.push(t._destroy());this.#r.clear(),this.#i.clear(),this.#a.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(),h5.cleanup(),this.#n?.cancelAllRequests(new A4(`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`,(e,t)=>{v4(this.#n,"GetReader - no `BasePDFStream` instance available."),this.#e=this.#n.getFullReader(),this.#e.onProgress=e=>this.#c(e),t.onPull=()=>{this.#e.read().then(function({value:e,done:n}){if(n){t.close();return}v4(e instanceof ArrayBuffer,`GetReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{this.#e.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`ReaderHeadersReady`,async e=>{await this.#e.headersReady;let{isStreamingSupported:t,isRangeSupported:n,contentLength:r}=this.#e;return t&&n&&(this.#e.onProgress=null),{isStreamingSupported:t,isRangeSupported:n,contentLength:r}}),e.on(`GetRangeReader`,(e,t)=>{v4(this.#n,"GetRangeReader - no `BasePDFStream` instance available.");let n=this.#n.getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}v4(e instanceof ArrayBuffer,`GetRangeReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`GetDoc`,({pdfInfo:e})=>{this.pagesMapper.pagesNumber=e.numPages,this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new b5(e,this))}),e.on(`DocException`,e=>{t._capability.reject(k6(e))}),e.on(`PasswordRequest`,e=>{this.#o=Promise.withResolvers();try{if(!t.onPassword)throw k6(e);t.onPassword(e=>{e instanceof Error?this.#o.reject(e):this.#o.resolve({password:e})},e.code)}catch(e){this.#o.reject(e)}return this.#o.promise}),e.on(`DataLoaded`,e=>{this.#c({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on(`StartRenderPage`,e=>{this.destroyed||this.#r.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),e.on(`commonobj`,([t,n,r])=>{if(this.destroyed||this.commonObjs.has(t))return null;switch(n){case`Font`:if(`error`in r){let e=r.error;g4(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let i=new u6(new _6(r),this._params.pdfBug&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,r.charProcOperatorList,r.extra);this.fontLoader.bind(i).catch(()=>e.sendWithPromise(`FontFallback`,{id:t})).finally(()=>{i.fontExtraProperties||i.clearData(),this.commonObjs.resolve(t,i)});break;case`CopyLocalImage`:let{imageRef:a}=r;v4(a,`The imageRef must be defined.`);for(let e of this.#r.values())for(let[,n]of e.objs){if(n?.ref!==a)continue;if(!n.dataLen)return null;let e=structuredClone(n);return this.commonObjs.resolve(t,e),n.dataLen}break;case`FontPath`:this.commonObjs.resolve(t,new y6(r));break;case`Image`:this.commonObjs.resolve(t,r);break;case`Pattern`:let o=new v6(r);this.commonObjs.resolve(t,o.getIR());break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on(`obj`,([e,t,n,r])=>{if(this.destroyed)return;let i=this.#r.get(t);if(!i.objs.has(e)){if(i._intentStates.size===0){r?.bitmap?.close();return}switch(n){case`Image`:case`Pattern`:i.objs.resolve(e,r);break;default:throw Error(`Got unknown object type ${n}`)}}}),e.on(`DocProgress`,e=>{this.destroyed||this.#c(e)}),e.on(`FetchBinaryData`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise(`GetData`,null)}saveDocument(){this.annotationStorage.size<=0&&g4("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},n,r=globalThis.ImageBitmap;if(typeof r==`function`){let t=Array.isArray(e)?e:[e];for(let e of t)e?.image instanceof r&&(n||=[]).push(e.image)}if(this.annotationStorage.size>0){let e=this.annotationStorage.serializable,{map:r}=e;e.transfer?.length&&(n?n.push(...e.transfer):n=e.transfer);let i=this.pagesMapper.getMapping();if(i){let e=new Map;for(let[t,n]of r){if(n?.pageIndex!==void 0&&n.pageIndex>=0&&n.pageIndex<i.length){let r=i[n.pageIndex]-1;if(r!==n.pageIndex){e.set(t,{...n,pageIndex:r});continue}}e.set(t,n)}r=e}t.annotationStorage=r}return this.messageHandler.sendWithPromise(`ExtractPages`,t,n).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,n=this.pagesMapper.getPageId(e)-1,r=this.#i.get(t);if(r)return r;let i=this.messageHandler.sendWithPromise(`GetPage`,{pageIndex:n}).then(e=>{if(this.destroyed)throw Error(`Transport destroyed`);e.refStr&&this.#a.set(e.refStr,n);let r=new x5(t,e,this,this.pagesMapper,this._params.pdfBug);return this.#r.set(t,r),r});return this.#i.set(t,i),i}async getPageIndex(e){if(!C6(e))throw Error(`Invalid pageIndex request.`);let t=await this.messageHandler.sendWithPromise(`GetPageIndex`,{num:e.num,gen:e.gen}),n=this.pagesMapper.getPageNumber(t+1);if(n===0)throw Error(`GetPageIndex: page has been removed.`);return n-1}getAnnotations(e,t){return this.messageHandler.sendWithPromise(`GetAnnotations`,{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return this.#s(`GetFieldObjects`)}getSignatures(){return this.#s(`GetSignatures`)}getSignatureData(e){return this.messageHandler.sendWithPromise(`GetSignatureData`,e)}hasJSActions(){return this.#s(`HasJSActions`)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise(`GetCalculationOrderIds`,null)}getDestinations(){return this.messageHandler.sendWithPromise(`GetDestinations`,null)}getDestination(e){return typeof e==`string`?this.messageHandler.sendWithPromise(`GetDestination`,{id:e}):Promise.reject(Error(`Invalid destination request.`))}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.#s(`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.#s(`GetOptionalContentConfig`).then(t=>new c5(t,e))}getPermissions(){return this.messageHandler.sendWithPromise(`GetPermissions`,null)}getMetadata(){let e=`GetMetadata`;return this.#t.getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new a5(e[1]):null,contentDispositionFilename:this.#e?.filename??null,contentLength:this.#e?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise(`GetMarkInfo`,null)}getRawData(e){return this.messageHandler.sendWithPromise(`GetRawData`,e)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise(`Cleanup`,null);for(let e of this.#r.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),h5.cleanup()}}cachedPageNumber(e){if(!C6(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`,n=this.#a.get(t);if(n>=0){let e=this.pagesMapper.getPageNumber(n+1);if(e!==0)return e}return null}},w5=class{_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}},T5=class e{#e=null;static#t=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:s,filterFactory:c,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:d=null,enableHWA:f=!1,operationsFilter:p=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=l===!0&&typeof window<`u`,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new w5(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=f,this._dependencyTracker=t.dependencyTracker,this._imagesTracker=t.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:n}){if(this.cancelled)return;if(this._canvas){if(e.#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.`);e.#t.add(this._canvas)}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:r,transform:i,background:a,dependencyTracker:o,imagesTracker:s}=this.params,c=this._canvasContext||this._canvas.getContext(`2d`,{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new T8(c,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors,o,s),this.gfx.beginDrawing({transform:i,viewport:r,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,n=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#e&&=(window.cancelAnimationFrame(this.#e),null),e.#t.delete(this._canvas),t||=new Q4(`Rendering cancelled, page ${this._pageIndex+1}`,n),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#e=window.requestAnimationFrame(()=>{this.#e=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),e.#t.delete(this._canvas),this.callback())))}},E5=`6.2.108`,D5=`0365cbde0`,O5=class e{#e=null;#t=null;#n;#r=null;#i=!1;#a=!1;#o=null;#s;#c=null;#l=null;static#u=null;static get _keyboardManager(){return C4(this,`_keyboardManager`,new F3([[[`Escape`],e.prototype._hideDropdownFromKeyboard],[[`Space`],e.prototype._colorSelectFromKeyboard],[[`ArrowDown`,`ArrowRight`],e.prototype._moveToNext],[[`ArrowUp`,`ArrowLeft`],e.prototype._moveToPrevious],[[`Home`],e.prototype._moveToBeginning],[[`End`],e.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:n=null}){t?(this.#a=!1,this.#o=t):this.#a=!0,this.#l=t?._uiManager||n,this.#s=this.#l._eventBus,this.#n=t?.color?.toUpperCase()||this.#l?.highlightColors.values().next().value||`#FFFF98`,e.#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`);e.className=`colorPicker`,e.tabIndex=`0`,e.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-button`),e.ariaHasPopup=`true`,this.#o&&(e.ariaControls=`${this.#o.id}_colorpicker_dropdown`);let t=this.#l._signal;e.addEventListener(`click`,this.#m.bind(this),{signal:t}),e.addEventListener(`keydown`,this.#p.bind(this),{signal:t});let n=this.#t=document.createElement(`span`);return n.className=`swatch`,n.ariaHidden=`true`,n.style.backgroundColor=this.#n,e.append(n),e}renderMainDropdown(){let e=this.#r=this.#d();return e.ariaOrientation=`horizontal`,e.ariaLabelledBy=`highlightColorPickerLabel`,e}#d(){let t=document.createElement(`div`),n=this.#l._signal;t.addEventListener(`contextmenu`,a3,{signal:n}),t.className=`dropdown`,t.role=`listbox`,t.ariaMultiSelectable=`false`,t.ariaOrientation=`vertical`,t.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-dropdown`),this.#o&&(t.id=`${this.#o.id}_colorpicker_dropdown`);for(let[r,i]of this.#l.highlightColors){let a=document.createElement(`button`);a.tabIndex=`0`,a.role=`option`,a.setAttribute(`data-color`,i),a.title=r,a.setAttribute(`data-l10n-id`,e.#u[r]);let o=document.createElement(`span`);a.append(o),o.className=`swatch`,o.style.backgroundColor=i,a.ariaSelected=i===this.#n,a.addEventListener(`click`,this.#f.bind(this,i),{signal:n}),t.append(a)}return t.addEventListener(`keydown`,this.#p.bind(this),{signal:n}),t}#f(e,t){t.stopPropagation(),this.#s.dispatch(`switchannotationeditorparams`,{source:this,type:n4.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)}_colorSelectFromKeyboard(e){if(e.target===this.#e){this.#m(e);return}let t=e.target.getAttribute(`data-color`);t&&this.#f(t,e)}_moveToNext(e){if(!this.#g){this.#m(e);return}if(e.target===this.#e){this.#r.firstElementChild?.focus();return}e.target.nextSibling?.focus()}_moveToPrevious(e){if(e.target===this.#r?.firstElementChild||e.target===this.#e){this.#g&&this._hideDropdownFromKeyboard();return}this.#g||this.#m(e),e.target.previousSibling?.focus()}_moveToBeginning(e){if(!this.#g){this.#m(e);return}this.#r.firstElementChild?.focus()}_moveToEnd(e){if(!this.#g){this.#m(e);return}this.#r.lastElementChild?.focus()}#p(t){e._keyboardManager.exec(this,t)}#m(e){if(this.#g){this.hideDropdown();return}if(this.#i=e.detail===0,this.#c||(this.#c=new AbortController,window.addEventListener(`pointerdown`,this.#h.bind(this),{signal:this.#l.combinedSignal(this.#c)})),this.#e.ariaExpanded=`true`,this.#r){this.#r.classList.remove(`hidden`);return}let t=this.#r=this.#d();this.#e.append(t)}#h(e){this.#r?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#r?.classList.add(`hidden`),this.#e.ariaExpanded=`false`,this.#c?.abort(),this.#c=null}get#g(){return this.#r&&!this.#r.classList.contains(`hidden`)}_hideDropdownFromKeyboard(){if(!this.#a){if(!this.#g){this.#o?.unselect();return}this.hideDropdown(),this.#e.focus({preventScroll:!0,focusVisible:this.#i})}}updateColor(e){if(this.#t&&(this.#t.style.backgroundColor=e),!this.#r)return;let t=this.#l.highlightColors.values();for(let n of this.#r.children)n.ariaSelected=t.next().value===e.toUpperCase()}destroy(){this.#e?.remove(),this.#e=null,this.#t=null,this.#r?.remove(),this.#r=null}},k5=class e{#e=null;#t=!1;#n=null;#r=null;static#i=null;constructor(t){this.#n=t,this.#r=t._uiManager,e.#i||=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:t,colorType:n,colorAndOpacityType:r,opacityType:i,color:a,opacity:o}=this.#n,s=this.#t=N4.isAlphaColorInputSupported&&i!==void 0,c=this.#e=document.createElement(`input`);if(c.type=`color`,s){c.setAttribute(`alpha`,``);let e=$.hexNums[Math.round((o??1)*255)];c.value=(a||`#000000`)+e}else c.value=a||`#000000`;return c.className=`basicColorPicker`,c.tabIndex=0,c.setAttribute(`data-l10n-id`,e.#i[t]),c.addEventListener(`input`,()=>{if(s){let e=c3(c.value);if(!e)return;let[t,a,o,s]=e,l=$.makeHexColor(t,a,o);r===void 0?(this.#r.updateParams(n,l),this.#r.updateParams(i,s)):this.#r.updateParams(r,{color:l,opacity:s})}else this.#r.updateParams(n,c.value)},{signal:this.#r._signal}),c}update(e){if(this.#e){if(this.#t){let t=$.hexNums[Math.round(this.#n.opacity*255)];this.#e.value=e+t}else this.#e.value=e}}updateOpacity(e){if(!this.#e||!this.#t)return;let t=$.hexNums[Math.round(e*255)];this.#e.value=this.#n.color+t}destroy(){this.#e?.remove(),this.#e=null}hideDropdown(){}};function A5(e){return Math.floor(W4(e,0,1)*255).toString(16).padStart(2,`0`)}function j5(e){return W4(e,0,1)*255}var M5=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}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=j5(e),[e,e,e]}static G_HTML([e]){let t=A5(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(j5)}static RGB_HTML(e){return`#${e.map(A5).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[j5(1-Math.min(1,e+r)),j5(1-Math.min(1,n+r)),j5(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}},N5=class{create(e,t,n=!1){if(e<=0||t<=0)throw Error(`Invalid SVG dimensions`);let r=this._createSVG(`svg:svg`);return r.setAttribute(`version`,`1.1`),n||(r.setAttribute(`width`,`${e}px`),r.setAttribute(`height`,`${t}px`)),r.setAttribute(`preserveAspectRatio`,`none`),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r}createElement(e){if(typeof e!=`string`)throw Error(`Invalid SVG element type`);return this._createSVG(e)}_createSVG(e){_4("Abstract method `_createSVG` called.")}},P5=class extends N5{_createSVG(e){return document.createElementNS(X2,e)}},F5=9,I5=new WeakSet,L5=new Date().getTimezoneOffset()*60*1e3,R5=class{static create(e){switch(e.data.annotationType){case o4.LINK:return new V5(e);case o4.TEXT:return new H5(e);case o4.WIDGET:switch(e.data.fieldType){case`Tx`:return new W5(e);case`Btn`:return e.data.radioButton?new q5(e):e.data.checkBox?new K5(e):new J5(e);case`Ch`:return new Y5(e);case`Sig`:return new G5(e)}return new U5(e);case o4.POPUP:return new X5(e);case o4.FREETEXT:return new Q5(e);case o4.LINE:return new $5(e);case o4.SQUARE:return new e7(e);case o4.CIRCLE:return new t7(e);case o4.POLYLINE:return new n7(e);case o4.CARET:return new i7(e);case o4.INK:return new a7(e);case o4.POLYGON:return new r7(e);case o4.HIGHLIGHT:return new o7(e);case o4.UNDERLINE:return new s7(e);case o4.SQUIGGLY:return new c7(e);case o4.STRIKEOUT:return new l7(e);case o4.STAMP:return new u7(e);case o4.FILEATTACHMENT:return new d7(e);case o4.RICHMEDIA:case o4.SCREEN:case o4.SOUND:return new f7(e);default:return new z5(e)}}},z5=class e{#e=null;#t=!1;#n=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){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(n)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!!(e?.str||t?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:e}=this,t=this.annotationStorage?.getEditor(e.id);return t?t.getData():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:n,rect:r}=this.data,i=-1/0,a=-1/0;if(t?.length>=8){for(let e=0;e<t.length;e+=8)t[e+1]>a?(a=t[e+1],i=t[e+2]):t[e+1]===a&&(i=Math.max(i,t[e+2]));return[i,a]}if(n?.length>=1){for(let e of n)for(let t=0,n=e.length;t<n;t+=2)e[t+1]>a?(a=e[t+1],i=e[t]):e[t+1]===a&&(i=Math.max(i,e[t]));if(i!==1/0)return[i,a]}return r?[r[2],r[3]]:null}_normalizePoint(e){let{page:{view:t},viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}}=this.parent;return e[1]=t[3]-e[1]+t[1],e[0]=100*(e[0]-i)/n,e[1]=100*(e[1]-a)/r,e}get commentText(){let{data:e}=this;return this.annotationStorage.getRawValue(`${e4}${e.id}`)?.popup?.contents||e.contentsObj?.str||``}set commentText(e){let{data:t}=this,n={deleted:!e,contents:e||``};this.annotationStorage.updateEditor(t.id,{popup:n})||this.annotationStorage.setValue(`${e4}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:n,popupRef:t.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){(this.#n?.popup||this.popup)?.remove(),this.#n=this.popup=null}updateEdited(e){if(!this.container)return;e.rect&&(this.#e||={rect:this.data.rect.slice(0)});let{rect:t,popup:n}=e;t&&this.#r(t);let r=this.#n?.popup||this.popup;!r&&n?.text&&(this._createPopup(n),r=this.#n.popup),r&&(r.updateEdited(e),n?.deleted&&(r.remove(),this.#n=null,this.popup=null))}resetEdited(){this.#e&&=(this.#r(this.#e.rect),this.#n?.popup.resetEdited(),null)}#r(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n?.splice(0,4,...e),t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*(e[2]-e[0])/i}%`,t.height=`${100*(e[3]-e[1])/a}%`):this.setRotation(r)}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),!(this instanceof U5)&&!(this instanceof V5)&&!(this instanceof f7)&&(i.tabIndex=0);let{style:a}=i;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,t.alternativeText&&(i.title=t.alternativeText),t.noRotate&&i.classList.add(`norotate`),!t.rect||this instanceof X5){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=this;if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch((e>0||n>0)&&(a.borderRadius=`calc(${e}px * var(--total-scale-factor)) / calc(${n}px * var(--total-scale-factor))`),t.borderStyle.style){case s4.SOLID:a.borderStyle=`solid`;break;case s4.DASHED:a.borderStyle=`dashed`;break;case s4.BEVELED:g4(`Unimplemented border style: beveled`);break;case s4.INSET:g4(`Unimplemented border style: inset`);break;case s4.UNDERLINE:a.borderBottomStyle=`solid`}let r=t.borderColor||null;r?(this.#t=!0,a.borderColor=$.makeHexColor(...r)):a.borderWidth=0}let c=$.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=this;e%180!=0&&([i,a]=[a,i]),t.style.width=`${100*i/n}%`,t.style.height=`${100*a/r}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=M5[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:M5[`${i}_rgb`](a)})};return C4(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail))(e[r]||n[r])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(this.#t){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="${X2}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add(`hasBorder`)}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.classList.add(`quadrilateralsContainer`),u.setAttribute(`width`,0),u.setAttribute(`height`,0),u.role=`none`;let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,g=(r-u)/s,_=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,g),p.setAttribute(`height`,_),f.append(p),o?.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${g}" height="${_}"/>`)}this.#t&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(e=null){let{data:t}=this,n,r;e?(n={str:e.text},r=e.date):(n=t.contentsObj,r=t.modificationDate),this.#n=new X5({data:{color:t.color,titleObj:t.titleObj,modificationDate:r,contentsObj:n,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.#n||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#n}render(){_4("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e]||[];for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);if(o&&!I5.has(o)){g4(`_getElementsByName - element not allowed: ${i}`);continue}n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&I5.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){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){!this.data.oc||!e||(e.isVisible(this.data.oc)?this.show():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`:$.makeHexColor(...t)}},B5=class extends z5{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;e.hasComment&&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){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()}},V5=class extends z5{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,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(this.#t(n,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(this.#n(n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`linkAnnotation`),r&&(this.contentElement=n,this.container.append(n)),this.container}#e(){this.container.setAttribute(`data-internal-link`,``)}_bindLink(e,t,n=``){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&this.#e(),n&&(e.title=n)}_bindNamedAction(e,t,n=``){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),n&&(e.title=n),this.#e()}#t(e,t,n,r=``,i=null){e.href=this.linkService.getAnchorUrl(``),n.description?e.title=n.description:r&&(e.title=r);let a=async()=>{let e=await this.linkService.getAttachmentContent(t);e&&this.downloadManager?.openOrDownloadData(e,n.filename,i)};e.onclick=()=>(a(),!1),this.#e()}#n(e,t,n=``){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),n&&(e.title=n),this.#e()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>(this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1))}t.overlaidText&&(e.title=t.overlaidText),e.onclick||=()=>!1,this.#e()}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl(``)),this.#e(),!this._fieldObjects){g4('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{n?.();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(n){if(!I5.has(n)){g4(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event(`resetform`))}}return this.enableScripting&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}}),!1}}},H5=class extends z5{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add(`textAnnotation`);let e=document.createElement(`img`);return 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()),this.container.append(e),this.container}},U5=class extends z5{render(){return this.container}_getKeyModifier(e){return N4.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}})})}_setEventListeners(e,t,n,r){for(let[i,a]of n)(a===`Action`||this.data.actions?.[a])&&((a===`Focus`||a===`Blur`)&&(t||={focused:!1}),this._setEventListener(e,t,i,a,r),a===`Focus`&&!this.data.actions?.Blur?this._setEventListener(e,t,`blur`,`Blur`,null):a===`Blur`&&!this.data.actions?.Focus&&this._setEventListener(e,t,`focus`,`Focus`,null))}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||F5,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(1.35*r))||1);a=Math.min(r,o(t/1.35))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/1.35))}i.fontSize=`calc(${a}px * var(--total-scale-factor))`,i.color=$.makeHexColor(...n),this.data.textAlignment!==null&&!this.data.comb&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},W5=class extends U5{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`textWidgetAnnotation`);let n=null;if(this.renderForms){let r=e.getValue(t,{value:this.data.fieldValue}),i=r.value||``,a=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;a&&i.length>a&&(i=i.slice(0,a));let o=r.formattedValue||this.data.textContent?.join(`
`)||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,``));let s={userValue:i,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement(`textarea`),n.textContent=o??i,this.data.doNotScroll&&(n.style.overflowY=`hidden`)):(n=document.createElement(`input`),n.type=this.data.password?`password`:`text`,n.setAttribute(`value`,o??i),this.data.doNotScroll&&(n.style.overflowX=`hidden`)),this.data.hasOwnCanvas&&(this.container.classList.add(`hasOwnCanvas`),e.has(t)&&this.container.classList.add(`sandboxModified`)),I5.add(n),this.contentElement=n,n.setAttribute(`data-element-id`,t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;let{datetimeFormat:c,datetimeType:l,timeStep:u}=this.data,d=!!l&&this.enableScripting;c&&(n.title=c),this._setRequired(n,this.data.required),a&&(n.maxLength=a),n.addEventListener(`input`,r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,`value`,r.target.value,`value`),s.formattedValue=null}),n.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue??``;n.value=s.userValue=t,s.formattedValue=null});let f=e=>{let{formattedValue:t}=s;t!=null&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener(`focus`,e=>{if(s.focused)return;let{target:t}=e;if(d&&(t.type=l,u&&(t.step=u)),s.userValue){let e=s.userValue;if(d){if(l===`time`){let n=new Date(e);t.value=[n.getHours(),n.getMinutes(),n.getSeconds()].map(e=>e.toString().padStart(2,`0`)).join(`:`)}else t.value=new Date(e-L5).toISOString().split(l===`date`?`T`:`.`,1)[0]}else t.value=e}s.lastCommittedValue=t.value,s.commitKey=1,this.data.actions?.Focus||(s.focused=!0)}),n.addEventListener(`updatefromsandbox`,n=>{this.container.classList.add(`sandboxModified`),this._dispatchEventFromSandbox({value(n){s.userValue=n.detail.value??``,d||e.setValue(t,{value:s.userValue.toString()}),n.target.value=s.userValue},formattedValue(n){let{formattedValue:r}=n.detail;s.formattedValue=r,r!=null&&n.target!==document.activeElement&&(n.target.value=r);let i={formattedValue:r};d&&(i.value=r),e.setValue(t,i)},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{let{charLimit:r}=n.detail,{target:i}=n;if(r===0){i.removeAttribute(`maxLength`);return}i.setAttribute(`maxLength`,r);let a=s.userValue;!a||a.length<=r||(a=a.slice(0,r),i.value=s.userValue=a,e.setValue(t,{value:a}),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,willCommit:!0,commitKey:1,selStart:i.selectionStart,selEnd:i.selectionEnd}}))}},n)}),n.addEventListener(`keydown`,e=>{s.commitKey=1;let n=-1;if(e.key===`Escape`?n=0:e.key===`Enter`&&!this.data.multiLine?n=2:e.key===`Tab`&&(s.commitKey=3),n===-1)return;let{value:r}=e.target;s.lastCommittedValue!==r&&(s.lastCommittedValue=r,s.userValue=r,this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))});let r=f;f=null,n.addEventListener(`blur`,e=>{if(!s.focused||!e.relatedTarget)return;this.data.actions?.Blur||(s.focused=!1);let{target:n}=e,{value:i}=n;if(d){if(i&&l===`time`){let e=i.split(`:`).map(e=>parseInt(e,10));i=new Date(2e3,0,1,e[0],e[1],e[2]||0).valueOf(),n.step=``}else i.includes(`T`)||(i=`${i}T00:00`),i=new Date(i).valueOf();n.type=`text`}s.userValue=i,s.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,willCommit:!0,commitKey:s.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),r(e)}),this.data.actions?.Keystroke&&n.addEventListener(`beforeinput`,e=>{s.lastCommittedValue=null;let{data:n,target:r}=e,{value:i,selectionStart:a,selectionEnd:o}=r,c=a,l=o;switch(e.inputType){case`deleteWordBackward`:{let e=i.substring(0,a).match(/\w*\W*$/);e&&(c-=e[0].length);break}case`deleteWordForward`:{let e=i.substring(a).match(/^\W*\w*/);e&&(l+=e[0].length);break}case`deleteContentBackward`:a===o&&--c;break;case`deleteContentForward`:a===o&&(l+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,change:n||``,willCommit:!1,selStart:c,selEnd:l}})}),this._setEventListeners(n,s,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.value)}if(f&&n.addEventListener(`blur`,f),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/a;n.classList.add(`comb`),n.style.setProperty(`--comb-width`,`calc(${e}px * var(--total-scale-factor))`);let t=this.data.textAlignment;if(t===1||t===2){let e=()=>{let e=a-n.value.length;n.style.setProperty(`--comb-offset`,`${t===1?e>>1:e}`)};e();for(let t of[`input`,`blur`,`resetform`,`updatefromsandbox`])n.addEventListener(t,e)}}}else n=document.createElement(`div`),n.textContent=this.data.fieldValue,n.style.verticalAlign=`middle`,n.style.display=`table-cell`,this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},G5=class extends U5{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},K5=class extends U5{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;typeof r==`string`&&(r=r!==`Off`,e.setValue(n,{value:r})),this.container.classList.add(`buttonWidgetAnnotation`,`checkBox`);let i=document.createElement(`input`);return I5.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`checkbox`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.setAttribute(`exportValue`,t.exportValue),i.tabIndex=0,i.addEventListener(`change`,r=>{let{name:i,checked:a}=r.target;for(let r of this._getElementsByName(i,n)){let n=a&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:a})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue||`Off`;e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},q5=class extends U5{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`buttonWidgetAnnotation`,`radioButton`);let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.buttonValue!==null&&t.fieldValue===t.buttonValue}).value;if(typeof r==`string`&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(let r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});let i=document.createElement(`input`);if(I5.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`radio`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.tabIndex=0,i.addEventListener(`change`,t=>{let{name:r,checked:i}=t.target;for(let t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:i})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue;e.target.checked=n!=null&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value:t=>{let i=r===t.detail.value;for(let r of this._getElementsByName(t.target.name)){let t=i&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)}return this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},J5=class extends V5{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add(`buttonWidgetAnnotation`,`pushButton`);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener(`updatefromsandbox`,e=>{this._dispatchEventFromSandbox({},e)})),e}},Y5=class extends U5{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`choiceWidgetAnnotation`);let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement(`select`);I5.add(r),r.setAttribute(`data-element-id`,t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue;for(let e of r.options)e.selected=e.value===t});let a=(e,t)=>{let n=t.replaceAll(` `,`\xA0`);e.textContent=n,n!==t&&e.setAttribute(`display-value`,t)};for(let e of this.data.options){let t=document.createElement(`option`);a(t,e.displayValue),t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute(`selected`,!0),i=!1),r.append(t)}let o=null;if(i){let e=document.createElement(`option`);e.value=` `,e.setAttribute(`hidden`,!0),e.setAttribute(`selected`,!0),r.prepend(e),o=()=>{e.remove(),r.removeEventListener(`input`,o),o=null},r.addEventListener(`input`,o)}let s=e=>{let t=e?`value`:`textContent`,{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):n.selectedIndex===-1?null:n[n.selectedIndex][t]},c=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.getAttribute(`display-value`)||e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener(`updatefromsandbox`,n=>{this._dispatchEventFromSandbox({value(n){o?.();let i=n.detail.value,a=new Set(Array.isArray(i)?i:[i]);for(let e of r.options)e.selected=a.has(e.value);e.setValue(t,{value:s(!0)}),c=s(!1)},multipleSelection(e){r.multiple=!0},remove(n){let i=r.options,a=n.detail.remove;i[a].selected=!1,r.remove(a),i.length>0&&Array.prototype.findIndex.call(i,e=>e.selected)===-1&&(i[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},clear(n){for(;r.length!==0;)r.remove(0);e.setValue(t,{value:null,items:[]}),c=s(!1)},insert(n){let{index:i,displayValue:o,exportValue:u}=n.detail.insert,d=r.children[i],f=document.createElement(`option`);a(f,o),f.value=u,d?d.before(f):r.append(f),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},items(n){let{items:i}=n.detail;for(;r.length!==0;)r.remove(0);for(let e of i){let{displayValue:t,exportValue:n}=e,i=document.createElement(`option`);a(i,t),i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},indices(n){let r=new Set(n.detail.indices);for(let e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:s(!0)}),c=s(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),r.addEventListener(`input`,n=>{let r=s(!0),i=s(!1);e.setValue(t,{value:r}),n.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:c,change:i,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`],[`input`,`Action`],[`input`,`Validate`]],e=>e.target.value)):r.addEventListener(`input`,function(n){e.setValue(t,{value:s(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},X5=class extends z5{constructor(e){let{data:t,elements:n,parent:r}=e,i=!!r._commentManager;if(super(e,{isRenderable:!i&&z5._hasPopupData(t)}),this.elements=n,i&&z5._hasPopupData(t)){let e=this.popup=this.#e();for(let t of n)t.popup=e}else this.popup=null}#e(){return new Z5({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(),n=[];for(let e of this.elements)e.popup=t,e.container.ariaHasPopup=`dialog`,n.push(e.data.id),e.addHighlightArea();return this.container.setAttribute(`aria-controls`,n.map(e=>`${$2}${e}`).join(`,`)),this.container}},Z5=class{#e=null;#t=this.#P.bind(this);#n=this.#R.bind(this);#r=this.#L.bind(this);#i=this.#I.bind(this);#a=null;#o=null;#s=null;#c=null;#l=null;#u=null;#d=null;#f=!1;#p=null;#m=null;#h=null;#g=null;#_=null;#v=null;#y=null;#b=null;#x=null;#S=null;#C=!1;#w=null;#T=null;constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:s,rect:c,parentRect:l,open:u,commentManager:d=null}){this.#o=e,this.#x=r,this.#s=a,this.#b=o,this.#u=s,this.#a=t,this.#y=c,this.#d=l,this.#l=n,this.#e=d,this.#w=n[0],this.#c=s3.toDateObject(i),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup()),d||(this.#E(),this.#o.hidden=!0,u&&this.#I())}#E(){if(this.#m)return;this.#m=new AbortController;let{signal:e}=this.#m;for(let t of this.trigger)t.addEventListener(`click`,this.#i,{signal:e}),t.addEventListener(`pointerenter`,this.#r,{signal:e}),t.addEventListener(`pointerleave`,this.#n,{signal:e}),t.classList.add(`popupTriggerArea`);for(let t of this.#l)t.container?.addEventListener(`keydown`,this.#t,{signal:e})}#D(){let e=this.#l.find(e=>e.hasCommentButton);e&&(this.#_=e._normalizePoint(e.commentButtonPosition))}renderCommentButton(){if(this.#g){this.#g.parentNode||this.#w.container.after(this.#g);return}if(this.#_||this.#D(),!this.#_)return;let{signal:e}=this.#m=new AbortController,t=this.#w.hasOwnCommentButton,n=()=>{this.#e.toggleCommentPopup(this,!0,void 0,!t)},r=()=>{this.#e.toggleCommentPopup(this,!1,!0,!t)},i=()=>{this.#e.toggleCommentPopup(this,!1,!1)};if(t){this.#g=this.#w.container;for(let t of this.trigger)t.ariaHasPopup=`dialog`,t.ariaControls=`commentPopup`,t.addEventListener(`keydown`,this.#t,{signal:e}),t.addEventListener(`click`,n,{signal:e}),t.addEventListener(`pointerenter`,r,{signal:e}),t.addEventListener(`pointerleave`,i,{signal:e}),t.classList.add(`popupTriggerArea`)}else{let t=this.#g=document.createElement(`button`);t.className=`annotationCommentButton`;let a=this.#w.container;t.style.zIndex=parseInt(a.style.zIndex,10)+1,t.tabIndex=0,t.ariaHasPopup=`dialog`,t.ariaControls=`commentPopup`,t.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`),this.#k(),this.#O(),t.addEventListener(`keydown`,this.#t,{signal:e}),t.addEventListener(`click`,n,{signal:e}),t.addEventListener(`pointerenter`,r,{signal:e}),t.addEventListener(`pointerleave`,i,{signal:e}),a.after(t)}}#O(){if(this.#w.extraPopupElement&&!this.#w.editor)return;this.#g||this.renderCommentButton();let[e,t]=this.#_,{style:n}=this.#g;n.left=`calc(${e}%)`,n.top=`calc(${t}% - var(--comment-button-dim))`}#k(){this.#w.extraPopupElement||(this.#g||this.renderCommentButton(),this.#g.style.backgroundColor=this.commentButtonColor||``)}get commentButtonColor(){let{color:e,opacity:t}=this.#w.commentData;return e?this.#u._commentManager.makeCommentColor(e,t):null}focusCommentButton(){setTimeout(()=>{this.#g?.focus()},0)}getData(){let{richText:e,color:t,opacity:n,creationDate:r,modificationDate:i}=this.#w.commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:n,creationDate:r,modificationDate:i}}get elementBeforePopup(){return this.#g}get comment(){return this.#T||=this.#w.commentText,this.#T}set comment(e){e!==this.comment&&(this.#w.commentText=this.#T=e)}focus(){this.#w.container?.focus()}get parentBoundingClientRect(){return this.#w.layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){this.#g&&(this.#g.classList.toggle(`selected`,e),this.#g.ariaExpanded=t)}setSelectedCommentButton(e){this.#g.classList.toggle(`selected`,e)}get commentPopupPosition(){if(this.#v)return this.#v;let{x:e,y:t,height:n}=this.#g.getBoundingClientRect(),{x:r,y:i,width:a,height:o}=this.#w.layer.getBoundingClientRect();return[(e-r)/a,(t+n-i)/o]}set commentPopupPosition(e){this.#v=e}hasDefaultPopupPosition(){return this.#v===null}get commentButtonPosition(){return this.#_}get commentButtonWidth(){return this.#g.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){let[t,n]=this.#v||this.commentButtonPosition.map(e=>e/100),r=this.parentBoundingClientRect,{x:i,y:a,width:o,height:s}=r;this.#e.showDialog(null,this,i+t*o,a+n*s,{...e,parentDimensions:r})}render(){if(this.#p)return;let e=this.#p=document.createElement(`div`);if(e.className=`popup`,this.#a){let t=e.style.outlineColor=$.makeHexColor(...this.#a);e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}let t=document.createElement(`span`);if(t.className=`header`,this.#x?.str){let e=document.createElement(`span`);e.className=`title`,t.append(e),{dir:e.dir,str:e.textContent}=this.#x}if(e.append(t),this.#c){let e=document.createElement(`time`);e.className=`popupDate`,e.setAttribute(`data-l10n-id`,`pdfjs-annotation-date-time-string`),e.setAttribute(`data-l10n-args`,JSON.stringify({dateObj:this.#c.valueOf()})),e.dateTime=this.#c.toISOString(),t.append(e)}T3({html:this.#A||this.#s.str,dir:this.#s?.dir,className:`popupContent`},e),this.#o.append(e)}get#A(){let e=this.#b,t=this.#s;return e?.str&&(!t?.str||t.str===e.str)&&this.#b.html||null}get#j(){return this.#A?.attributes?.style?.fontSize||0}get#M(){return this.#A?.attributes?.style?.color||null}#N(e){let t=[],n={str:e,html:{name:`div`,attributes:{dir:`auto`},children:[{name:`p`,children:t}]}},r={style:{color:this.#M,fontSize:this.#j?`calc(${this.#j}px * var(--total-scale-factor))`:``}};for(let n of e.split(`
`))t.push({name:`span`,value:n,attributes:r});return n}#P(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key===`Enter`||e.key===`Escape`&&this.#f)&&this.#I()}updateEdited({rect:e,popup:t,deleted:n}){if(this.#e){n?(this.remove(),this.#T=null):t&&(t.deleted?this.remove():(this.#k(),this.#T=t.text)),e&&(this.#_=null,this.#D(),this.#O());return}if(n||t?.deleted){this.remove();return}this.#E(),this.#S||={contentsObj:this.#s,richText:this.#b},e&&(this.#h=null),t&&t.text&&(this.#b=this.#N(t.text),this.#c=s3.toDateObject(t.date),this.#s=null),this.#p?.remove(),this.#p=null}resetEdited(){this.#S&&({contentsObj:this.#s,richText:this.#b}=this.#S,this.#S=null,this.#p?.remove(),this.#p=null,this.#h=null)}remove(){if(this.#m?.abort(),this.#m=null,this.#p?.remove(),this.#p=null,this.#C=!1,this.#f=!1,this.#g?.remove(),this.#g=null,this.trigger)for(let e of this.trigger)e.classList.remove(`popupTriggerArea`)}#F(){if(this.#h!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:i}}}=this.#u,a=!!this.#d,o=a?this.#d:this.#y;for(let e of this.#l)if(!o||$.intersect(e.data.rect,o)!==null){o=e.data.rect,a=!0;break}let s=$.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,l=s[0]+c,u=s[1];this.#h=[100*(l-r)/t,100*(u-i)/n];let{style:d}=this.#o;d.left=`${this.#h[0]}%`,d.top=`${this.#h[1]}%`}#I(){if(this.#e){this.#e.toggleCommentPopup(this,!1);return}this.#f=!this.#f,this.#f?(this.#L(),this.#o.addEventListener(`click`,this.#i),this.#o.addEventListener(`keydown`,this.#t)):(this.#R(),this.#o.removeEventListener(`click`,this.#i),this.#o.removeEventListener(`keydown`,this.#t))}#L(){this.#p||this.render(),this.isVisible?this.#f&&this.#o.classList.add(`focused`):(this.#F(),this.#o.hidden=!1,this.#o.style.zIndex=parseInt(this.#o.style.zIndex,10)+1e3)}#R(){this.#o.classList.remove(`focused`),!(this.#f||!this.isVisible)&&(this.#o.hidden=!0,this.#o.style.zIndex=parseInt(this.#o.style.zIndex,10)-1e3)}forceHide(){this.#C=this.isVisible,this.#C&&(this.#o.hidden=!0)}maybeShow(){this.#e||(this.#E(),this.#C&&(this.#p||this.#L(),this.#C=!1,this.#o.hidden=!1))}get isVisible(){return!this.#e&&this.#o.hidden===!1}},Q5=class extends z5{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=t4.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 n=document.createElement(`span`);n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},$5=class extends z5{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`lineAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=this.#e=this.svgFactory.createElement(`svg:line`);return i.setAttribute(`x1`,e.rect[2]-e.lineCoordinates[0]),i.setAttribute(`y1`,e.rect[3]-e.lineCoordinates[1]),i.setAttribute(`x2`,e.rect[2]-e.lineCoordinates[2]),i.setAttribute(`y2`,e.rect[3]-e.lineCoordinates[3]),i.setAttribute(`stroke-width`,e.borderStyle.width||1),i.setAttribute(`stroke`,`transparent`),i.setAttribute(`fill`,`transparent`),r.append(i),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},e7=class extends z5{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`squareAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=this.#e=this.svgFactory.createElement(`svg:rect`);return a.setAttribute(`x`,i/2),a.setAttribute(`y`,i/2),a.setAttribute(`width`,t-i),a.setAttribute(`height`,n-i),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},t7=class extends z5{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`circleAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=this.#e=this.svgFactory.createElement(`svg:ellipse`);return a.setAttribute(`cx`,t/2),a.setAttribute(`cy`,n/2),a.setAttribute(`rx`,t/2-i/2),a.setAttribute(`ry`,n/2-i/2),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},n7=class extends z5{#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:n,popupRef:r},width:i,height:a}=this;if(!t)return this.container;let o=this.svgFactory.create(i,a,!0),s=[];for(let n=0,r=t.length;n<r;n+=2){let r=t[n]-e[0],i=e[3]-t[n+1];s.push(`${r},${i}`)}s=s.join(` `);let c=this.#e=this.svgFactory.createElement(this.svgElementName);return c.setAttribute(`points`,s),c.setAttribute(`stroke-width`,n.width||1),c.setAttribute(`stroke`,`transparent`),c.setAttribute(`fill`,`transparent`),o.append(c),this.container.append(o),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},r7=class extends n7{constructor(e){super(e),this.containerClassName=`polygonAnnotation`,this.svgElementName=`svg:polygon`}},i7=class extends z5{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add(`caretAnnotation`),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}},a7=class extends z5{#e=null;#t=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName=`inkAnnotation`,this.svgElementName=`svg:polyline`,this.annotationEditorType=this.data.it===`InkHighlight`?t4.HIGHLIGHT:t4.INK}#n(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:n,borderStyle:r,popupRef:i}}=this,{transform:a,width:o,height:s}=this.#n(t,e),c=this.svgFactory.create(o,s,!0),l=this.#e=this.svgFactory.createElement(`svg:g`);c.append(l),l.setAttribute(`stroke-width`,r.width||1),l.setAttribute(`stroke-linecap`,`round`),l.setAttribute(`stroke-linejoin`,`round`),l.setAttribute(`stroke-miterlimit`,10),l.setAttribute(`stroke`,`transparent`),l.setAttribute(`fill`,`transparent`),l.setAttribute(`transform`,a);for(let e of n){let t=this.svgFactory.createElement(this.svgElementName);this.#t.push(t),t.setAttribute(`points`,e.join(`,`)),l.append(t)}return!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:n,rect:r}=e,i=this.#e;if(t>=0&&i.setAttribute(`stroke-width`,t||1),n)for(let e=0,t=this.#t.length;e<t;e++)this.#t[e].setAttribute(`points`,n[e].join(`,`));if(r){let{transform:e,width:t,height:n}=this.#n(this.data.rotation,r);i.parentElement.setAttribute(`viewBox`,`0 0 ${t} ${n}`),i.setAttribute(`transform`,e)}}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add(`highlightArea`)}},o7=class extends z5{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=t4.HIGHLIGHT}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`highlightAnnotation`),this._editOnDoubleClick(),e){let t=document.createElement(`mark`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},s7=class extends z5{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()),this.container.classList.add(`underlineAnnotation`),e){let t=document.createElement(`u`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},c7=class extends z5{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()),this.container.classList.add(`squigglyAnnotation`),e){let t=document.createElement(`u`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},l7=class extends z5{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()),this.container.classList.add(`strikeoutAnnotation`),e){let t=document.createElement(`s`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},u7=class extends z5{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=t4.STAMP}render(){return this.container.classList.add(`stampAnnotation`),this.container.setAttribute(`role`,`img`),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},d7=class extends z5{#e=null;constructor(e){super(e,{isRenderable:!0});let{fileId:t,file:n}=this.data;this.filename=n.filename,this.content=n.content,this.fileId=t,this.linkService.eventBus?.dispatch(`fileattachmentannotation`,{source:this,attachmentId:this.fileId,...n})}render(){this.container.classList.add(`fileAttachmentAnnotation`);let{container:e,data:t}=this,n;t.hasAppearance||t.fillAlpha===0?n=document.createElement(`div`):(n=document.createElement(`img`),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?`paperclip`:`pushpin`}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),n.addEventListener(`dblclick`,this.#t.bind(this)),this.#e=n;let{isMac:r}=N4.platform;return e.addEventListener(`keydown`,e=>{e.key===`Enter`&&(r?e.metaKey:e.ctrlKey)&&this.#t()}),!t.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add(`popupTriggerArea`),e.append(n),e}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}async#t(){let{fileId:e,filename:t,content:n}=this,r=await this.linkService.getAttachmentContent(e)||n;r&&this.downloadManager?.openOrDownloadData(r,t)}},f7=class extends z5{#e=new AbortController;#t=null;#n=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.#r(t),{signal:this.#e.signal}),this.container.append(t),this.container}async#r(e){let{fileId:t,filename:n,contentType:r}=this.data.richMedia;e.disabled=!0;let i;try{i=await this.linkService.getAttachmentContent(t)}catch{return}finally{e.disabled=!1}if(!i||!e.isConnected)return;let{signal:a}=this.#e,o=URL.createObjectURL(new Blob([i],{type:r}));this.#t=o;let s=r.startsWith(`audio/`),c=document.createElement(s?`audio`:`video`);if(this.#n=c,c.className=`mediaContent`,this._setBackgroundColor(c),c.src=o,c.title=n,c.controls=!0,c.autoplay=!0,c.tabIndex=0,s){let e=!1,t=!1,n=()=>{c.controls=e||t};this.container.addEventListener(`pointerenter`,()=>{e=!0,n()},{signal:a}),this.container.addEventListener(`pointerleave`,()=>{e=!1,n()},{signal:a}),this.container.addEventListener(`focusin`,()=>{t=!0,n()},{signal:a}),this.container.addEventListener(`focusout`,()=>{t=!1,n()},{signal:a})}c.addEventListener(`emptied`,()=>this.#i(o),{once:!0,signal:a}),e.replaceWith(c),c.play().catch(()=>{})}#i(e=this.#t){e&&e===this.#t&&(URL.revokeObjectURL(e),this.#t=null)}destroy(){this.#e.abort(),this.#n&&=(this.#n.pause(),this.#n.removeAttribute(`src`),this.#n.load(),null),this.#i()}},p7=class e{#e=null;#t=null;#n=null;#r=new Map;#i=null;#a=null;#o=[];#s=!1;zIndex=0;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:a,structTreeLayer:o,commentManager:s,linkService:c,annotationStorage:l}){this.div=e,this.#e=t,this.#t=n,this.#i=o||null,this.#a=c||null,this.#n=l||new J3,this.page=i,this.viewport=a,this._annotationEditorUIManager=r,this._commentManager=s||null}hasEditableAnnotations(){return this.#r.size>0}async render(e){let{annotations:t,optionalContentConfig:n}=e,r=this.div;p3(r,this.viewport);let i=new Map,a=[],o={data:null,layer:r,linkService:this.#a,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||``,renderForms:e.renderForms!==!1,svgFactory:new P5,annotationStorage:this.#n,enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===o4.POPUP;if(t){let t=i.get(e.id);if(!t)continue;if(!this._commentManager){a.push(e);continue}o.elements=t}else if(e.rect[2]===e.rect[0]||e.rect[3]===e.rect[1])continue;o.data=e;let r=R5.create(o);if(!r.isRenderable)continue;t||(this.#o.push(r),e.popupRef&&i.getOrInsertComputed(e.popupRef,B4).push(r));let s=r.render();e.hidden&&(s.style.visibility=`hidden`),r.updateOC(n),r._isEditable&&(this.#r.set(r.data.id,r),this._annotationEditorUIManager?.renderAnnotationElement(r))}await this.#c();for(let e of a){let t=o.elements=i.get(e.id);o.data=e;let n=R5.create(o);if(!n.isRenderable)continue;let r=n.render();n.contentElement.id=`${$2}${e.id}`,e.hidden&&(r.style.visibility=`hidden`),t.at(-1).container.after(r)}this.#l()}async#c(){if(this.#o.length===0)return;this.div.replaceChildren();let e=[];if(!this.#s){this.#s=!0;for(let{contentElement:t,data:{id:n}}of this.#o){let r=t.id=`${$2}${n}`;e.push(this.#i?.getAriaAttributes(r).then(e=>{if(e)for(let[n,r]of e)t.setAttribute(n,r)}))}}this.#o.sort(({data:{rect:[e,t,n,r]}},{data:{rect:[i,a,o,s]}})=>{if(e===n&&t===r)return 1;if(i===o&&a===s)return-1;let c=r,l=t,u=(t+r)/2,d=s,f=a,p=(a+s)/2;return u>=d&&p<=l?-1:p>=c&&u<=f?1:(e+n)/2-(i+o)/2});let t=document.createDocumentFragment();for(let e of this.#o)t.append(e.container),this._commentManager?(e.extraPopupElement?.popup||e.popup)?.renderCommentButton():e.extraPopupElement&&t.append(e.extraPopupElement.render());if(this.div.append(t),await Promise.all(e),this.#e)for(let e of this.#o)this.#e.addPointerInTextLayer(e.contentElement,!1)}async addLinkAnnotations(t){let n={data:null,layer:this.div,linkService:this.#a,svgFactory:new P5,parent:this};for(let r of t){r.borderStyle||=e._defaultBorderStyle,n.data=r;let t=R5.create(n);t.isRenderable&&(t.render(),t.contentElement.id=`${$2}${r.id}`,this.#o.push(t))}await this.#c()}update({viewport:e,optionalContentConfig:t}){let n=this.div;this.viewport=e,p3(n,{rotation:e.rotation});for(let e of this.#o)e.updateOC(t);this.#l(),n.hidden=!1}destroy(){for(let e of this.#o)e.destroy?.(),this.#e?.removePointerInTextLayer(e.contentElement);this.#o.length=0,this.#r.clear(),this.div.replaceChildren()}#l(){if(!this.#t)return;let e=this.div;for(let[t,n]of this.#t){let r=e.querySelector(`[data-annotation-id="${t}"]`);if(!r)continue;if(Array.isArray(n))for(let e of n)e.className=`annotationContent`,e.ariaHidden=!0;else n.className=`annotationContent`,n.ariaHidden=!0;let i=[];for(let e of r.children)e.nodeName===`CANVAS`&&i.push(e);for(let e of i)e.remove();let a=Array.isArray(n)?n[0]:n,{firstChild:o}=r;if(o?o.classList.contains(`annotationContent`)?o.after(a):o.before(a):r.append(a),Array.isArray(n)){let e=a;for(let t=1,r=n.length;t<r;t++)e.after(n[t]),e=n[t]}this.#t.delete(t);let s=this.#r.get(t);s&&(s._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(t,r.id,n),s._hasNoCanvas=!1):s.canvas=n)}}refreshCanvases(){this.#l()}getEditableAnnotations(){return this.#r.values()}getEditableAnnotation(e){return this.#r.get(e)}addFakeAnnotation(e){let{div:t}=this,{id:n,rotation:r}=e,i=new B5({data:{id:n,rect:e.getPDFRect(),rotation:r},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:this.#a,annotationStorage:this.#n});return i.render(),i.contentElement.id=`${$2}${n}`,i.createOrUpdatePopup(),this.#o.push(i),i}removeAnnotation(e){let t=this.#o.findIndex(t=>t.data.id===e);if(t<0)return;let[n]=this.#o.splice(t,1);this.#e?.removePointerInTextLayer(n.contentElement)}updateFakeAnnotations(e){if(e.length!==0){for(let t of e)t.updateFakeAnnotationElement(this);this.#c()}}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}static get _defaultBorderStyle(){return C4(this,`_defaultBorderStyle`,Object.freeze({width:1,rawWidth:1,style:s4.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},m7=/\r\n?|\n/g,h7=class e extends V3{#e=``;#t=`${this.id}-editor`;#n=null;#r;_colorPicker=null;static _freeTextDefaultContent=``;static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.isEmpty(),r=L3.TRANSLATE_SMALL,i=L3.TRANSLATE_BIG;return C4(this,`_keyboardManager`,new F3([[[`ctrl+s`,`mac+meta+s`,`ctrl+p`,`mac+meta+p`],t.commitOrRemove,{bubbles:!0}],[[`ctrl+Enter`,`mac+meta+Enter`],t.commitOrRemove],[[`Escape`],t.commitOrRemove],[[`ArrowLeft`],t._translateEmpty,{args:[-r,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t._translateEmpty,{args:[-i,0],checker:n}],[[`ArrowRight`],t._translateEmpty,{args:[r,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t._translateEmpty,{args:[i,0],checker:n}],[[`ArrowUp`],t._translateEmpty,{args:[0,-r],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t._translateEmpty,{args:[0,-i],checker:n}],[[`ArrowDown`],t._translateEmpty,{args:[0,r],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t._translateEmpty,{args:[0,i],checker:n}]]))}static _type=`freetext`;static _editorType=t4.FREETEXT;constructor(t){super({...t,name:`freeTextEditor`}),this.color=t.color||e._defaultColor||V3._defaultLineColor,this.#r=t.fontSize||e._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(V3._l10nAlert.freetext),this.canAddComment=!1}static initialize(e,t){V3.initialize(e,t);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue(`--freetext-padding`))}static updateDefaultParams(t,n){switch(t){case n4.FREETEXT_SIZE:e._defaultFontSize=n;break;case n4.FREETEXT_COLOR:e._defaultColor=n}}updateParams(e,t){switch(e){case n4.FREETEXT_SIZE:this.#i(t);break;case n4.FREETEXT_COLOR:this.#a(t)}}static get defaultPropertiesToUpdate(){return[[n4.FREETEXT_SIZE,e._defaultFontSize],[n4.FREETEXT_COLOR,e._defaultColor||V3._defaultLineColor]]}get propertiesToUpdate(){return[[n4.FREETEXT_SIZE,this.#r],[n4.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new k5(this),[[`colorPicker`,this._colorPicker]]}get colorType(){return n4.FREETEXT_COLOR}#i(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--total-scale-factor))`,this.translate(0,-(e-this.#r)*this.parentScale),this.#r=e,this.#s()},n=this.#r;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n4.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#a(e){let t=e=>{this.color=e,this.onUpdatedColor()},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n4.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let t=this.parentScale;return[-e._internalPadding*t,-(e._internalPadding+this.#r)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(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.#n=new AbortController;let e=this._uiManager.combinedSignal(this.#n);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(){return super.disableEditMode()?(this.overlayDiv.classList.add(`enabled`),this.editorDiv.contentEditable=!1,this.div.setAttribute(`aria-activedescendant`,this.#t),this._isDraggable=!0,this.#n?.abort(),this.#n=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add(`freetextEditing`),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===``}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add(`freetextEditing`)),super.remove()}#o(){let t=[];this.editorDiv.normalize();let n=null;for(let r of this.editorDiv.childNodes)(n?.nodeType!==Node.TEXT_NODE||r.nodeName!==`BR`)&&(t.push(e.#c(r)),n=r);return t.join(`
`)}#s(){let[e,t]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:e,div:t}=this,r=t.style.display,i=t.classList.contains(`hidden`);t.classList.remove(`hidden`),t.style.display=`hidden`,e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle(`hidden`,i)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#e,t=this.#e=this.#o().trimEnd();if(e===t)return;let n=e=>{if(this.#e=e,!e){this.remove();return}this.#l(),this._uiManager.rebuild(this),this.#s()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#s()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key===`Enter`&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(t){e._keyboardManager.exec(this,t)}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;(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:n}=this.editorDiv;if(n.fontSize=`calc(${this.#r}px * var(--total-scale-factor))`,n.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,r]=this.parentDimensions;if(this.annotationElementId){let{position:i}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[s,c]=this.pageDimensions,[l,u]=this.pageTranslation,d,f;switch(this.rotation){case 0:d=e+(i[0]-l)/s,f=t+this.height-(i[1]-u)/c;break;case 90:d=e+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[o,-a];break;case 180:d=e-this.width+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[-a,-o];break;case 270:d=e+(i[0]-l-this.height*c)/s,f=t+(i[1]-u-this.width*s)/c,[a,o]=[-o,a]}this.setAt(d*n,f*r,a,o)}else this._moveAfterPaste(e,t);this.#l(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#c(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(m7,``)}editorDivPaste(t){let n=t.clipboardData||window.clipboardData,{types:r}=n;if(r.length===1&&r[0]===`text/plain`)return;t.preventDefault();let i=e.#d(n.getData(`text`)||``).replaceAll(m7,`
`);if(!i)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let o=a.getRangeAt(0);if(!i.includes(`
`)){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:s,startOffset:c}=o,l=[],u=[];if(s.nodeType===Node.TEXT_NODE){let t=s.parentElement;if(u.push(s.nodeValue.slice(c).replaceAll(m7,``)),t!==this.editorDiv){let n=l;for(let r of this.editorDiv.childNodes){if(r===t){n=u;continue}n.push(e.#c(r))}}l.push(s.nodeValue.slice(0,c).replaceAll(m7,``))}else if(s===this.editorDiv){let t=l,n=0;for(let r of this.editorDiv.childNodes)n++===c&&(t=u),t.push(e.#c(r))}this.#e=`${l.join(`
`)}${i}${u.join(`
`)}`,this.#l();let d=new Range,f=Math.sumPrecise(l.map(e=>e.length));for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(f<=t){d.setStart(e,f),d.setEnd(e,f);break}f-=t}a.removeAllRanges(),a.addRange(d)}#l(){if(this.editorDiv.replaceChildren(),this.#e)for(let e of this.#e.split(`
`)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`)),this.editorDiv.append(t)}}#u(){return this.#e.replaceAll(`\xA0`,` `)}static#d(e){return e.replaceAll(` `,`\xA0`)}get contentDiv(){return this.editorDiv}getPDFRect(){let t=e._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,n,r){let i=null;if(t instanceof Q5){let{data:{defaultAppearanceData:{fontSize:e,fontColor:n},rect:r,rotation:a,id:o,popupRef:s,richText:c,contentsObj:l,creationDate:u,modificationDate:d},textContent:f,textPosition:p,parent:{page:{pageNumber:m}}}=t;if(!f?.length)return null;i=t={annotationType:t4.FREETEXT,color:Array.from(n),fontSize:e,value:f.join(`
`),position:p,pageIndex:m-1,rect:r.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,popupRef:s,comment:l?.str||null,richText:c,creationDate:u,modificationDate:d}}let a=await super.deserialize(t,n,r);return a.#r=t.fontSize,a.color=$.makeHexColor(...t.color),a.#e=e.#d(t.value),a._initialData=i,t.comment&&a.setCommentData(t),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=V3._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:t,fontSize:this.#r,value:this.#u()});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!this.#f(n)?null:(n.id=this.annotationElementId,n)}#f(e){let{value:t,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(!t)return null;let{style:n}=t;n.fontSize=`calc(${this.#r}px * var(--total-scale-factor))`,n.color=this.color,t.replaceChildren();for(let e of this.#e.split(`
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`)),t.append(n)}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()}},g7=class{static PRECISION=1e-4;toSVGPath(){_4("Abstract method `toSVGPath` must be implemented.")}get box(){_4("Abstract getter `box` must be implemented.")}serialize(e,t){_4("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o]*r,a[o+1]=n+e[o+1]*i;return a}static _rescaleAndSwap(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o+1]*r,a[o+1]=n+e[o]*i;return a}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let i=0,a=e.length;i<a;i+=2)r[i]=t+e[i],r[i+1]=n+e[i+1];return r}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}},_7=class e{#e;#t=[];#n;#r;#i=[];#a=new Float32Array(18);#o;#s;#c;#l;#u;#d;#f=[];static#p=8;static#m=2;static#h=e.#p+e.#m;constructor({x:t,y:n},r,i,a,o,s=0){this.#e=r,this.#d=a*i,this.#r=o,this.#a.set([NaN,NaN,NaN,NaN,t,n],6),this.#n=s,this.#l=e.#p*i,this.#c=e.#h*i,this.#u=i,this.#f.push(t,n)}isEmpty(){return isNaN(this.#a[8])}#g(){let e=this.#a.subarray(4,6),t=this.#a.subarray(16,18),[n,r,i,a]=this.#e;return[(this.#o+(e[0]-t[0])/2-n)/i,(this.#s+(e[1]-t[1])/2-r)/a,(this.#o+(t[0]-e[0])/2-n)/i,(this.#s+(t[1]-e[1])/2-r)/a]}add({x:e,y:t}){this.#o=e,this.#s=t;let[n,r,i,a]=this.#e,[o,s,c,l]=this.#a.subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<this.#c)return!1;let p=f-this.#l,m=p/f,h=m*u,g=m*d,_=o,v=s;o=c,s=l,c+=h,l+=g,this.#f?.push(e,t);let y=-g/p,b=h/p,x=y*this.#d,S=b*this.#d;return this.#a.set(this.#a.subarray(2,8),0),this.#a.set([c+x,l+S],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([c-x,l-S],16),isNaN(this.#a[6])?(this.#i.length===0&&(this.#a.set([o+x,s+S],2),this.#i.push(NaN,NaN,NaN,NaN,(o+x-n)/i,(s+S-r)/a),this.#a.set([o-x,s-S],14),this.#t.push(NaN,NaN,NaN,NaN,(o-x-n)/i,(s-S-r)/a)),this.#a.set([_,v,o,s,c,l],6),!this.isEmpty()):(this.#a.set([_,v,o,s,c,l],6),Math.abs(Math.atan2(v-s,_-o)-Math.atan2(g,h))<Math.PI/2?([o,s,c,l]=this.#a.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a),[o,s,_,v]=this.#a.subarray(14,18),this.#t.push(NaN,NaN,NaN,NaN,((_+o)/2-n)/i,((v+s)/2-r)/a),!0):([_,v,o,s,c,l]=this.#a.subarray(0,6),this.#i.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a),[c,l,o,s,_,v]=this.#a.subarray(12,18),this.#t.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a),!0))}toSVGPath(){if(this.isEmpty())return``;let e=this.#i,t=this.#t;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#_();let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#y(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return this.#v(n),n.join(` `)}#_(){let[e,t,n,r]=this.#e,[i,a,o,s]=this.#g();return`M${(this.#a[2]-e)/n} ${(this.#a[3]-t)/r} L${(this.#a[4]-e)/n} ${(this.#a[5]-t)/r} L${i} ${a} L${o} ${s} L${(this.#a[16]-e)/n} ${(this.#a[17]-t)/r} L${(this.#a[14]-e)/n} ${(this.#a[15]-t)/r} Z`}#v(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#y(e){let[t,n,r,i]=this.#e,a=this.#a.subarray(4,6),o=this.#a.subarray(16,18),[s,c,l,u]=this.#g();e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}newFreeDrawOutline(e,t,n,r,i,a){return new v7(e,t,n,r,i,a)}getOutlines(){let e=this.#i,t=this.#t,n=this.#a,[r,i,a,o]=this.#e,s=new Float32Array((this.#f?.length??0)+2);for(let e=0,t=s.length-2;e<t;e+=2)s[e]=(this.#f[e]-r)/a,s[e+1]=(this.#f[e+1]-i)/o;if(s[s.length-2]=(this.#o-r)/a,s[s.length-1]=(this.#s-i)/o,isNaN(n[6])&&!this.isEmpty())return this.#b(s);let c=new Float32Array(this.#i.length+24+this.#t.length),l=e.length;for(let t=0;t<l;t+=2){if(isNaN(e[t])){c[t]=c[t+1]=NaN;continue}c[t]=e[t],c[t+1]=e[t+1]}l=this.#S(c,l);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2){if(isNaN(t[e+n])){c[l]=c[l+1]=NaN,l+=2;continue}c[l]=t[e+n],c[l+1]=t[e+n+1],l+=2}return this.#x(c,l),this.newFreeDrawOutline(c,s,this.#e,this.#u,this.#n,this.#r)}#b(e){let t=this.#a,[n,r,i,a]=this.#e,[o,s,c,l]=this.#g(),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0),this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#n,this.#r)}#x(e,t){let n=this.#t;return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+=6}#S(e,t){let n=this.#a.subarray(4,6),r=this.#a.subarray(16,18),[i,a,o,s]=this.#e,[c,l,u,d]=this.#g();return e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t),t+=24}},v7=class extends g7{#e;#t=new Float32Array(4);#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a){super(),this.#o=e,this.#i=t,this.#e=n,this.#a=r,this.#n=i,this.#r=a,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#s(a);let[o,s,c,l]=this.#t;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-o)/c,e[t+1]=(e[t+1]-s)/l;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-o)/c,t[e+1]=(t[e+1]-s)/l}toSVGPath(){let e=[`M${this.#o[4]} ${this.#o[5]}`];for(let t=6,n=this.#o.length;t<n;t+=6){if(isNaN(this.#o[t])){e.push(`L${this.#o[t+4]} ${this.#o[t+5]}`);continue}e.push(`C${this.#o[t]} ${this.#o[t+1]} ${this.#o[t+2]} ${this.#o[t+3]} ${this.#o[t+4]} ${this.#o[t+5]}`)}return e.push(`Z`),e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=g7._rescale(this.#o,e,r,a,-o),c=g7._rescale(this.#i,e,r,a,-o);break;case 90:s=g7._rescaleAndSwap(this.#o,e,t,a,o),c=g7._rescaleAndSwap(this.#i,e,t,a,o);break;case 180:s=g7._rescale(this.#o,n,t,-a,o),c=g7._rescale(this.#i,n,t,-a,o);break;case 270:s=g7._rescaleAndSwap(this.#o,n,r,-a,-o),c=g7._rescaleAndSwap(this.#i,n,r,-a,-o)}return{outline:Array.from(s),points:[Array.from(c)]}}#s(e){let t=this.#o,n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,u=new Float32Array(4);for(let e=6,d=t.length;e<d;e+=6){let d=t[e+4],f=t[e+5];isNaN(t[e])?($.pointBoundingBox(d,f,i),o>f?(a=d,o=f):o===f&&(a=l(a,d)),c<f?(s=d,c=f):c===f&&(s=l(s,d))):(u.set(q2,0),$.bezierBoundingBox(n,r,...t.slice(e,e+6),u),$.rectBoundingBox(...u,i),o>u[1]?(a=u[0],o=u[1]):o===u[1]&&(a=l(a,u[0])),c<u[3]?(s=u[2],c=u[3]):c===u[3]&&(s=l(s,u[2]))),n=d,r=f}let d=this.#t;d[0]=i[0]-this.#n,d[1]=i[1]-this.#n,d[2]=i[2]-i[0]+2*this.#n,d[3]=i[3]-i[1]+2*this.#n,this.firstPoint=[a,o],this.lastPoint=[s,c]}get box(){return this.#t}newOutliner(e,t,n,r,i,a=0){return new _7(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=this.#t,[o,s,c,l]=this.#e,u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:this.#i[0]*u+f,y:this.#i[1]*d+p},this.#e,this.#a,e,this.#r,t??this.#n);for(let e=2;e<this.#i.length;e+=2)m.add({x:this.#i[e]*u+f,y:this.#i[e+1]*d+p});return m.getOutlines()}},y7=class{#e;#t;#n;#r=[];#i=[];constructor(e,t=0,n=0,r=!0){let i=q2.slice(),a=10**-4;for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];this.#r.push(d,f),$.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,u=r?-1/0:1/0,d=1/0,f=this.#r.at(r?-1:-2),p=[f[0],f[2]];for(let e of this.#r){let[t,n,i,a]=e;!a&&r?n<d?(d=n,u=t):n===d&&(u=Math.max(u,t)):a&&!r&&(n<d?(d=n,u=t):n===d&&(u=Math.min(u,t))),e[0]=(t-c)/o,e[1]=(n-l)/s,e[2]=(i-l)/s}this.#e=new Float32Array([c,l,o,s]),this.#t=[u,d],this.#n=p}getOutlines(){this.#r.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#r)t[3]?(e.push(...this.#l(t)),this.#s(t)):(this.#c(t),e.push(...this.#l(t)));return this.#a(e)}#a(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i),i.push(r),n.add(r),n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;for(i=[t,o],r.push(i);;){let e;if(n.has(s))e=s;else if(n.has(c))e=c;else break;n.delete(e),[t,a,o,s,c]=e,l!==t&&(i.push(l,u,t,u===a?a:o),l=t),u=u===a?o:a}i.push(l,u)}return new b7(r,this.#e,this.#t,this.#n)}#o(e){let t=this.#i,n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}#s([,e,t]){let n=this.#o(e);this.#i.splice(n,0,[e,t])}#c([,e,t]){let n=this.#o(e);for(let r=n;r<this.#i.length;r++){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}}#l(e){let[t,n,r]=e,i=[[t,n,r]],a=this.#o(r);for(let e=0;e<a;e++){let[n,r]=this.#i[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1),e--,a--}continue}i[e][2]=n,s>r&&i.push([t,r,s])}}}return i}},b7=class extends g7{#e;#t;constructor(e,t,n,r){super(),this.#t=e,this.#e=t,this.firstPoint=n,this.lastPoint=r}toSVGPath(){let e=[];for(let t of this.#t){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];a===n?(e.push(`V${o}`),r=o):o===r&&(e.push(`H${a}`),n=a)}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of this.#t){let n=Array(t.length);for(let i=0;i<t.length;i+=2)n[i]=e+t[i]*o,n[i+1]=r-t[i+1]*s;a.push(n)}return a}get box(){return this.#e}},x7=class extends _7{newFreeDrawOutline(e,t,n,r,i,a){return new S7(e,t,n,r,i,a)}},S7=class extends v7{newOutliner(e,t,n,r,i,a=0){return new x7(e,t,n,r,i,a)}},C7=class e extends V3{#e=null;#t=0;#n;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=``;#g;#_=``;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type=`highlight`;static _editorType=t4.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId=``;static get _keyboardManager(){let t=e.prototype;return C4(this,`_keyboardManager`,new F3([[[`ArrowLeft`],t._moveCaret,{args:[0]}],[[`ArrowRight`],t._moveCaret,{args:[1]}],[[`ArrowUp`],t._moveCaret,{args:[2]}],[[`ArrowDown`],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:`highlightEditor`}),this.color=t.color||e._defaultColor,this.#g=t.thickness||e._defaultThickness,this.opacity=t.opacity||e._defaultOpacity,this.#n=t.boxes||null,this.#_=t.methodOfCreation||``,this.#h=t.text||``,this._isDraggable=!1,this.defaultL10nId=`pdfjs-editor-highlight-editor`,t.highlightId>-1?(this.#d=!0,this.#y(t),this.#w()):this.#n&&(this.#e=t.anchorNode,this.#t=t.anchorOffset,this.#o=t.focusNode,this.#s=t.focusOffset,this.#v(),this.#w(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(V3._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:this.#d?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#g,methodOfCreation:this.#_}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}#v(){let e=new y7(this.#n,.001);this.#l=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;let t=new y7(this.#n,.0025,.001,this._uiManager.direction===`ltr`);this.#a=t.getOutlines();let{firstPoint:n}=this.#l;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height];let{lastPoint:r}=this.#a;this.#p=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#y({highlightOutlines:t,highlightId:n,clipPathId:r}){if(this.#l=t,this.#a=t.getNewOutline(this.#g/2+1.5,.0025),n>=0)this.#u=n,this.#r=r,this.parent.drawLayer.finalizeDraw(n,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#m=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0);else if(this.parent){let n=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:e.#T(this.#l.box,(n-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#m,{bbox:e.#T(this.#a.box,n),path:{d:this.#a.toSVGPath()}})}let[i,a,o,s]=t.box;switch(this.rotation){case 0:this.x=i,this.y=a,this.width=o,this.height=s;break;case 90:{let[e,t]=this.parentDimensions;this.x=a,this.y=1-i,this.width=o*t/e,this.height=s*e/t;break}case 180:this.x=1-i,this.y=1-a,this.width=o,this.height=s;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-a,this.y=i,this.width=o*t/e,this.height=s*e/t;break}}let{firstPoint:c}=t;this.#f=[(c[0]-i)/o,(c[1]-a)/s];let{lastPoint:l}=this.#a;this.#p=[(l[0]-i)/o,(l[1]-a)/s]}static initialize(t,n){V3.initialize(t,n),e._defaultColor||=n.highlightColors?.values().next().value||`#fff066`}static updateDefaultParams(t,n){switch(t){case n4.HIGHLIGHT_COLOR:e._defaultColor=n;break;case n4.HIGHLIGHT_THICKNESS:e._defaultThickness=n}}translateInPage(e,t){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#f}updateParams(e,t){switch(e){case n4.HIGHLIGHT_COLOR:this.#b(t);break;case n4.HIGHLIGHT_THICKNESS:this.#x(t)}}static get defaultPropertiesToUpdate(){return[[n4.HIGHLIGHT_COLOR,e._defaultColor],[n4.HIGHLIGHT_THICKNESS,e._defaultThickness]]}get propertiesToUpdate(){return[[n4.HIGHLIGHT_COLOR,this.color||e._defaultColor],[n4.HIGHLIGHT_THICKNESS,this.#g||e._defaultThickness],[n4.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#i?.updateColor(this.color),super.onUpdatedColor()}#b(t){let n=(e,t)=>{this.color=e,this.opacity=t,this.onUpdatedColor()},r=this.color,i=this.opacity;this.addCommands({cmd:n.bind(this,t,e._defaultOpacity),undo:n.bind(this,r,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n4.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(t)},!0)}#x(e){let t=this.#g,n=e=>{this.#g=e,this.#S(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n4.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[[`colorPicker`,this.#i=new O5({editor:this})]]: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.#O())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#O())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#C(),this._reportTelemetry({action:`deleted`}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#w(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#C():e&&(this.#w(e),t=!this.parent&&this.div?.classList.contains(`selectedEditor`)),super.setParent(e),this.show(this._isVisible),t&&this.select()}#S(e){this.#d&&(this.#y({highlightOutlines:this.#l.getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())}#C(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#m),this.#m=null)}#w(e=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#m=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d),this.#c&&(this.#c.style.clipPath=this.#r))}static#T([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(t){let{drawLayer:n}=this.parent,r;this.#d?(t=(t-this.rotation+360)%360,r=e.#T(this.#l.box,t)):r=e.#T([this.x,this.y,this.width,this.height],t),n.updateProperties(this.#u,{bbox:r,root:{"data-main-rotation":t}}),n.updateProperties(this.#m,{bbox:e.#T(this.#a.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let e=super.render();this.#h&&(e.setAttribute(`aria-label`,this.#h),e.setAttribute(`role`,`mark`)),this.#d?e.classList.add(`free`):this.div.addEventListener(`keydown`,this.#E.bind(this),{signal:this._uiManager._signal});let t=this.#c=document.createElement(`div`);return e.append(t),t.setAttribute(`aria-hidden`,`true`),t.className=`internal`,t.style.clipPath=this.#r,this.setDims(),A3(this,this.#c,[`pointerover`,`pointerleave`]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1}})}#E(t){e._keyboardManager.exec(this,t)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#D(!0);break;case 1:case 3:this.#D(!1)}}#D(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#o,this.#s)}select(){super.select(),this.#m&&this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#m&&(this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{selected:!1}}),this.#d||this.#D(!1))}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#m,{rootClass:{hidden:!e}}))}#O(){return this.#d?this.rotation:0}#k(){if(this.#d)return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=this.#n,a=new Float32Array(i.length*8),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i,a[o+1]=a[o+3]=d,a[o+2]=a[o+6]=i+l*e,a[o+5]=a[o+7]=d-u*t,o+=8}return a}#A(e){return this.#l.serialize(e,this.#O())}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=t=>{l.abort(),this.#M(e,t)};window.addEventListener(`blur`,d,{signal:u}),window.addEventListener(`pointerup`,d,{signal:u}),window.addEventListener(`pointerdown`,o3,{capture:!0,passive:!1,signal:u}),window.addEventListener(`contextmenu`,a3,{signal:u}),n.addEventListener(`pointermove`,this.#j.bind(this,e),{signal:u}),this._freeHighlight=new x7({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.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#j(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#M(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=``}static async deserialize(e,t,n){let r=null;if(e instanceof o7){let{data:{quadPoints:t,rect:n,rotation:i,id:a,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:t4.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}else if(e instanceof a7){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:t4.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}let{color:i,quadPoints:a,inkLists:o,outlines:s,opacity:c}=e,l=await super.deserialize(e,t,n);l.color=$.makeHexColor(...i),l.opacity=c||1,o&&(l.#g=e.thickness),l._initialData=r,e.comment&&l.setCommentData(e);let[u,d]=l.pageDimensions,[f,p]=l.pageTranslation;if(a){let e=l.#n=[];for(let t=0;t<a.length;t+=8)e.push({x:(a[t]-f)/u,y:1-(a[t+1]-p)/d,width:(a[t+2]-a[t])/u,height:(a[t+1]-a[t+5])/d});l.#v(),l.#w(),l.rotate(l.rotation)}else if(o||s){l.#d=!0;let e=(o||s.points)[0],n={x:e[0]-f,y:d-(e[1]-p)},r=new x7(n,[0,0,u,d],1,l.#g/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2)n.x=e[t]-f,n.y=d-(e[t+1]-p),r.add(n);let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#y({highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a}),l.#w(),l.rotate(l.parentRotation)}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=V3._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:t,opacity:this.opacity,thickness:this.#g,quadPoints:this.#k(),outlines:this.#A(n.rect)}),this.addComment(n),this.annotationElementId&&!this.#N(n)?null:(n.id=this.annotationElementId,n)}#N(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}},w7=class{#e=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}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(){_4(`Not implemented`)}},T7=class e extends V3{#e=null;#t;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=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){e.drawOutlines&&(this.#a(e),this.#c())}#a({drawOutlines:e,drawId:t,drawingOptions:n}){this.#e=e,this._drawingOptions||=n,this.annotationElementId||this._uiManager.a11yAlert(V3._l10nAlert[this.editorType]),t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=this.#o(e,this.parent),this.#d(e.box)}#o(t,n){let{id:r}=n.drawLayer.draw(e._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return r}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){_4(`Not implemented`)}static get typesMap(){_4(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,n){let r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,n),this._currentParent&&(e.#n.updateProperty(r,n),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{r.updateProperty(t,n);let i=this.#e.updateProperty(t,n);i&&this.#d(i),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{i.updateProperty(n,e),i.updateProperty(r,t),this.#e.updateProperty(n,e),this.#e.updateProperty(r,t),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n4.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#f()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#u()),{bbox:this.#f()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#f()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#f()}))}_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){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#t&&(this.#t=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#s(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#c(),this.#d(this.#e.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#s()):e&&(this._uiManager.addShouldRescale(this),this.#c(e),t=!this.parent&&this.div?.classList.contains(`selectedEditor`)),super.setParent(e),t&&this.select()}#s(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#c(e=this.parent){if(this._drawId===null||this.parent!==e){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#o(this.#e,e)}}#l([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}#u(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}#d(e){[this.x,this.y,this.width,this.height]=this.#l(e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#f(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((i*4+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties({bbox:this.#f()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;this._isCopy&&(e=this.x,t=this.y);let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);return n.append(r),r.setAttribute(`aria-hidden`,`true`),r.className=`internal`,this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,t),n}static createDrawerInstance(e,t,n,r,i){_4(`Not implemented`)}static startDrawing(t,n,r,i){let{target:a,offsetX:o,offsetY:s,pointerId:c,pointerType:l}=i;if(j3.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:u}}=t,{width:d,height:f}=a.getBoundingClientRect(),p=e.#r=new AbortController,m=t.combinedSignal(p);if(j3.setPointer(l,c),window.addEventListener(`pointerup`,e=>{j3.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:m}),window.addEventListener(`pointercancel`,e=>{j3.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:m}),window.addEventListener(`pointerdown`,t=>{j3.isSamePointerType(t.pointerType)&&(j3.initializeAndAddPointerId(t.pointerId),e.#n.isCancellable()&&(e.#n.removeLastElement(),e.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener(`contextmenu`,a3,{signal:m}),a.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:m}),a.addEventListener(`touchmove`,e=>{j3.isSameTimeStamp(e.timeStamp)&&o3(e)},{signal:m}),t.toggleDrawing(),n._editorUndoBar?.hide(),e.#n){t.drawLayer.updateProperties(this._currentDrawId,e.#n.startNew(o,s,d,f,u));return}n.updateUIForDefaultProperties(this),e.#n=this.createDrawerInstance(o,s,d,f,u),e.#i=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(e.#i.toSVGProperties(),e.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(j3.isSameTimeStamp(t.timeStamp),!e.#n)return;let{offsetX:n,offsetY:r,pointerId:i}=t;if(j3.isSamePointerId(i)){if(j3.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,e.#n.add(n,r)),j3.setTimeStamp(t.timeStamp),o3(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,e.#n=null,e.#i=null,j3.clearTimeStamp()),e.#r&&(e.#r.abort(),e.#r=null,j3.clearPointerIds())}static _endDraw(t){let n=this._currentParent;if(n){if(n.toggleDrawing(!0),this._cleanup(!1),t?.target===n.div&&n.drawLayer.updateProperties(this._currentDrawId,e.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=e.#n,r=this._currentDrawId,i=t.getLastElement();n.addCommands({cmd:()=>{n.drawLayer.updateProperties(r,t.setLastElement(i))},undo:()=>{n.drawLayer.updateProperties(r,t.removeLastElement())},mustExec:!1,type:n4.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(n4.DRAW_STEP),!e.#n.isEmpty()){let{pageDimensions:[r,i],scale:a}=n,o=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:e.#n.getOutlines(r*a,i*a,a,this._INNER_MARGIN),drawingOptions:e.#i,mustBeCommitted:!t});return this._cleanup(!0),o}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){_4(`Not implemented`)}static async deserialize(e,t,n){let{rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=t.viewport,s=this.deserializeDraw(a,o,r,i,this._INNER_MARGIN,e),c=await super.deserialize(e,t,n);return c.createDrawingOptions(e),c.#a({drawOutlines:s}),c.#c(),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return this.#e.serialize([t,n,r,i],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}},E7=class{#e=new Float64Array(6);#t;#n;#r;#i;#a;#o=``;#s=0;#c=new D7;#l;#u;constructor(e,t,n,r,i,a){this.#l=n,this.#u=r,this.#r=i,this.#i=a,[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t],this.#n=[{line:o,points:this.#a}],this.#e.set(o,0)}updateProperty(e,t){e===`stroke-width`&&(this.#i=t)}#d(e,t){return g7._normalizePoint(e,t,this.#l,this.#u,this.#r)}isEmpty(){return!this.#n?.length}isCancellable(){return this.#a.length<=10}add(e,t){[e,t]=this.#d(e,t);let[n,r,i,a]=this.#e.subarray(2,6),o=e-i,s=t-a;return Math.hypot(this.#l*o,this.#u*s)<=2?null:(this.#a.push(e,t),isNaN(n)?(this.#e.set([i,a,e,t],2),this.#t.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#e[0])&&this.#t.splice(6,6),this.#e.set([n,r,i,a,e,t],0),this.#t.push(...g7.createBezierPoints(n,r,i,a,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){this.#l=n,this.#u=r,this.#r=i,[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];let o=this.#n.at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),this.#n.push({line:a,points:this.#a}),this.#e.set(a,0),this.#s=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(e){return this.#n?(this.#n.push(e),this.#t=e.line,this.#a=e.points,this.#s=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(e)}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop(),this.#o=``;for(let e=0,t=this.#n.length;e<t;e++){let{line:t,points:n}=this.#n[e];this.#t=t,this.#a=n,this.#s=0,this.toSVGPath()}return{path:{d:this.#o}}}toSVGPath(){let e=g7.svgRound(this.#t[4]),t=g7.svgRound(this.#t[5]);if(this.#a.length===2)return this.#o=`${this.#o} M ${e} ${t} Z`,this.#o;if(this.#a.length<=6){let n=this.#o.lastIndexOf(`M`);this.#o=`${this.#o.slice(0,n)} M ${e} ${t}`,this.#s=6}if(this.#a.length===4){let e=g7.svgRound(this.#t[10]),t=g7.svgRound(this.#t[11]);return this.#o=`${this.#o} L ${e} ${t}`,this.#s=12,this.#o}let n=[];this.#s===0&&(n.push(`M ${e} ${t}`),this.#s=6);for(let e=this.#s,t=this.#t.length;e<t;e+=6){let[t,r,i,a,o,s]=this.#t.slice(e,e+6).map(g7.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}return this.#o+=n.join(` `),this.#s=this.#t.length,this.#o}getOutlines(e,t,n,r){let i=this.#n.at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),this.#c.build(this.#n,e,t,n,this.#r,this.#i,r),this.#e=null,this.#t=null,this.#n=null,this.#o=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}},D7=class extends g7{#e;#t=0;#n;#r;#i;#a;#o;#s;#c;build(e,t,n,r,i,a,o){this.#i=t,this.#a=n,this.#o=r,this.#s=i,this.#c=a,this.#n=o??0,this.#r=e,this.#d()}get thickness(){return this.#c}setLastElement(e){return this.#r.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#r.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r){if(e.push(`M${g7.svgRound(t[4])} ${g7.svgRound(t[5])}`),t.length===6){e.push(`Z`);continue}if(t.length===12&&isNaN(t[6])){e.push(`L${g7.svgRound(t[10])} ${g7.svgRound(t[11])}`);continue}for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(g7.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=this.#u(),d,f,p,m,h,g,_,v,y;switch(this.#s){case 0:y=g7._rescale,d=e,f=t+r,p=n,m=-r,h=e+s*n,g=t+(1-c-u)*r,_=e+(s+l)*n,v=t+(1-c)*r;break;case 90:y=g7._rescaleAndSwap,d=e,f=t,p=n,m=r,h=e+c*n,g=t+s*r,_=e+(c+u)*n,v=t+(s+l)*r;break;case 180:y=g7._rescale,d=e+n,f=t,p=-n,m=r,h=e+(1-s-l)*n,g=t+c*r,_=e+(1-s)*n,v=t+(c+u)*r;break;case 270:y=g7._rescaleAndSwap,d=e+n,f=t+r,p=-n,m=-r,h=e+(1-c-u)*n,g=t+(1-s-l)*r,_=e+(1-c)*n,v=t+(1-s)*r}for(let{line:e,points:t}of this.#r)a.push(y(e,d,f,p,m,i?Array(e.length):null)),o.push(y(t,d,f,p,m,i?Array(t.length):null));return{lines:a,points:o,rect:[h,g,_,v]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=g7._rescale,u=-e/n,d=t/r+1,f=1/n,p=-1/r;break;case 90:m=g7._rescaleAndSwap,u=-t/r,d=-e/n,f=1/r,p=1/n;break;case 180:m=g7._rescale,u=e/n+1,d=-t/r,f=-1/n,p=1/r;break;case 270:m=g7._rescaleAndSwap,u=t/r+1,d=e/n+1,f=-1/r,p=-1/n}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(g7.createBezierPoints(r,i,o,s,t,c),(a-2)*3),[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e??NaN),u,d,f,p),points:m(o[e].map(e=>e??NaN),u,d,f,p)});let h=new this.prototype.constructor;return h.build(l,n,r,1,s,c,i),h}#l(e=this.#c){let t=this.#n+e/2*this.#o;return this.#s%180==0?[t/this.#i,t/this.#a]:[t/this.#a,t/this.#i]}#u(){let[e,t,n,r]=this.#e,[i,a]=this.#l(0);return[e+i,t+a,n-2*i,r-2*a]}#d(){let e=this.#e=J2.slice();for(let{line:t}of this.#r){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)$.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);$.bezierBoundingBox(n,r,a,o,s,c,l,u,e),n=l,r=u}}let[t,n]=this.#l();e[0]=W4(e[0]-t,0,1),e[1]=W4(e[1]-n,0,1),e[2]=W4(e[2]+t,0,1),e[3]=W4(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e===`stroke-width`?this.#f(t):null}#f(e){let[t,n]=this.#l();this.#c=e;let[r,i]=this.#l(),[a,o]=[r-t,i-n],s=this.#e;return s[0]-=a,s[1]-=o,s[2]+=2*a,s[3]+=2*o,s}updateParentDimensions([e,t],n){let[r,i]=this.#l();this.#i=e,this.#a=t,this.#o=n;let[a,o]=this.#l(),s=a-r,c=o-i,l=this.#e;return l[0]-=s,l[1]-=c,l[2]+=2*s,l[3]+=2*c,l}updateRotation(e){return this.#t=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(g7.svgRound).join(` `)}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${g7.svgRound(e)} ${g7.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,n=0,r=0,i=0,a=0,o=0,s=0;switch(this.#t){case 90:r=t/e,i=-e/t,o=e;break;case 180:n=-1,a=-1,o=e,s=t;break;case 270:r=-t/e,i=e/t,s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${g7.svgRound(o)} ${g7.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=this.#l(),[o,s,c,l]=this.#e;if(Math.abs(c-i)<=g7.PRECISION||Math.abs(l-a)<=g7.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${g7.svgRound(e)} ${g7.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),f=c/n,p=l/r;return{path:{"transform-origin":`${g7.svgRound(o)} ${g7.svgRound(s)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${g7.svgRound(i)} ${g7.svgRound(a)}) scale(${u} ${d}) translate(${g7.svgRound(-i)} ${g7.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=this.#l(),o=this.#e,[s,c,l,u]=o;if(o[0]=e,o[1]=t,o[2]=n,o[3]=r,Math.abs(l-i)<=g7.PRECISION||Math.abs(u-a)<=g7.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of this.#r)g7._translate(e,i,a,e),g7._translate(t,i,a,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${g7.svgRound(e)} ${g7.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),f=(r-2*a)/(u-2*a),p=-d*(s+i)+e+i,m=-f*(c+a)+t+a;if(d!==1||f!==1||p!==0||m!==0)for(let{line:e,points:t}of this.#r)g7._rescale(e,p,m,d,f,e),g7._rescale(t,p,m,d,f,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${g7.svgRound(e)} ${g7.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=this.#e,o=e-a[0],s=t-a[1];if(this.#i===r&&this.#a===i)for(let{line:e,points:t}of this.#r)g7._translate(e,o,s,e),g7._translate(t,o,s,t);else{let e=this.#i/r,t=this.#a/i;this.#i=r,this.#a=i;for(let{line:n,points:r}of this.#r)g7._rescale(n,o,s,e,t,n),g7._rescale(r,o,s,e,t,r);a[2]*=e,a[3]*=t}return a[0]=e,a[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${g7.svgRound(e)} ${g7.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${g7.svgRound(e[0])} ${g7.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}},O7=class e extends w7{constructor(e){super(),this._viewParameters=e,super.updateProperties({fill:`none`,stroke:V3._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){e===`stroke-width`&&(t??=this[`stroke-width`],t*=this._viewParameters.realScale),super.updateSVGProperty(e,t)}clone(){let t=new e(this._viewParameters);return t.updateAll(this),t}},k7=class e extends T7{static _type=`ink`;static _editorType=t4.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:`inkEditor`}),this._willKeepAspectRatio=!0,this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){V3.initialize(e,t),this._defaultDrawingOptions=new O7(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return C4(this,`typesMap`,new Map([[n4.INK_THICKNESS,`stroke-width`],[n4.INK_COLOR,`stroke`],[n4.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new E7(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return D7.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=null;if(e instanceof a7){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;r=e={annotationType:t4.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let i=await super.deserialize(e,t,n);return i._initialData=r,e.comment&&i.setCommentData(e),i}get toolbarButtons(){return this._colorPicker||=new k5(this),[[`colorPicker`,this._colorPicker]]}get colorType(){return n4.INK_COLOR}get colorAndOpacityType(){return n4.INK_COLOR_AND_OPACITY}get opacityType(){return n4.INK_OPACITY}updateParams(e,t){if(e===n4.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(t.color,t.opacity);return}super.updateParams(e,t)}static updateDefaultParams(e,t){if(e===n4.INK_COLOR_AND_OPACITY){super.updateDefaultParams(n4.INK_COLOR,t.color),super.updateDefaultParams(n4.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:n}=this;t.updateSVGProperty(`stroke-width`),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty(`stroke-width`),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:n,opacity:r}){this._drawingOptions=e.getDefaultDrawingOptions({stroke:$.makeHexColor(...t),"stroke-width":n,"stroke-opacity":r})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:V3._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});return this.addComment(o),e?(o.isCopy=!0,o):this.annotationElementId&&!this.#e(o)?null:(o.id=this.annotationElementId,o)}#e(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment}),null}},A7=class extends D7{toSVGPath(){let e=super.toSVGPath();return e.endsWith(`Z`)||(e+=`Z`),e}},j7=8,M7=3,N7=class{static#e={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#t(e,t,n,r){return n-=e,r-=t,n===0?r>0?0:4:n===1?r+6:2-r}static#n=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#r(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8,c=this.#n[2*a],l=this.#n[2*a+1];if(e[(n+c)*t+(r+l)]!==0)return a}return-1}static#i(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8,c=this.#n[2*a],l=this.#n[2*a+1];if(e[(n+c)*t+(r+l)]!==0)return a}return-1}static#a(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o=1,s,c=[];for(let e=1;e<n-1;e++){s=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0)o+=1,--u;else if(i>=1&&a[r+1]===0)o+=1,u+=1,i>1&&(s=i);else{i!==1&&(s=Math.abs(i));continue}let d=[n,e],f=u===n+1,p={isHole:f,points:d,id:o,parent:0};c.push(p);let m;for(let e of c)if(e.id===s){m=e;break}p.parent=m?m.isHole?f?m.parent:s:f?s:m.parent:f?s:0;let h=this.#r(a,t,e,n,l,u,0);if(h===-1){a[r]=-o,a[r]!==1&&(s=Math.abs(a[r]));continue}let g=this.#n[2*h],_=this.#n[2*h+1],v=e+g,y=n+_;l=v,u=y;let b=e,x=n;for(;;){let i=this.#i(a,t,b,x,l,u,1);g=this.#n[2*i],_=this.#n[2*i+1];let c=b+g,f=x+_;d.push(f,c);let p=b*t+x;if(a[p+1]===0?a[p]=-o:a[p]===1&&(a[p]=o),c===e&&f===n&&b===v&&x===y){a[r]!==1&&(s=Math.abs(a[r]));break}l=b,u=x,b=c,x=f}}}return c}static#o(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,f=s/o,p=1/c,m=Math.atan(f),h=Math.cos(m),g=Math.sin(m),_=p*(Math.abs(h)+Math.abs(g)),v=p*(1-_+_**2),y=Math.max(Math.atan(Math.abs(g+h)*v),Math.atan(Math.abs(g-h)*v)),b=0,x=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);t>b&&(x=r,b=t)}b>(c*y)**2?(this.#o(e,t,x+2,r),this.#o(e,x,n,r)):r.push(i,a)}static#s(e){let t=[],n=e.length;return this.#o(e,0,n,t),t.push(e[n-2],e[n-1]),t.length<=4?null:t}static#c(e,t,n,r,i,a){let o=new Float32Array(a**2),s=-2*r**2,c=a>>1;for(let e=0;e<a;e++){let t=(e-c)**2;for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+(n-c)**2)/s)}let l=new Float32Array(256),u=-2*i**2;for(let e=0;e<256;e++)l[e]=Math.exp(e**2/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h,m+=h}}let h=f[s]=Math.round(d/m);p[h]++}return[f,p]}static#l(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}static#u(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a),i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}static#d(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];i>n&&(t-a>r&&(r=t-a,o=t-1),n=i,a=t)}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}static#f(e){let t=e,{width:n,height:r}=e,{maxDim:i}=this.#e,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2),o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o),s=a,c=o,e!==t&&e.close(),e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d),o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`,s.fillRect(0,0,a,o),s.filter=`grayscale(1)`,s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[this.#u(c),a,o]}static extractContoursFromText(e,{fontFamily:t,fontStyle:n,fontWeight:r},i,a,o,s){let c=new OffscreenCanvas(1,1),l=c.getContext(`2d`,{alpha:!1}),u=l.font=`${n} ${r} 200px ${t}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:m,fontBoundingBoxAscent:h,fontBoundingBoxDescent:g,width:_}=l.measureText(e),v=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||0,_)*v),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||200,Math.abs(h)+Math.abs(g)||200)*v);c=new OffscreenCanvas(y,b),l=c.getContext(`2d`,{alpha:!0,willReadFrequently:!0}),l.font=u,l.filter=`grayscale(1)`,l.fillStyle=`white`,l.fillRect(0,0,y,b),l.fillStyle=`black`,l.fillText(e,y*.5/2,b*1.5/2);let x=this.#u(l.getImageData(0,0,y,b).data),S=this.#l(x),C=this.#d(S),w=this.#a(x,y,b,C);return this.processDrawnLines({lines:{curves:w,width:y,height:b},pageWidth:i,pageHeight:a,rotation:o,innerMargin:s,mustSmooth:!0,areContours:!0})}static process(e,t,n,r,i){let[a,o,s]=this.#f(e),[c,l]=this.#c(a,o,s,Math.hypot(o,s)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#d(l),d=this.#a(c,o,s,u);return this.processDrawnLines({lines:{curves:d,width:o,height:s},pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:a,areContours:o}){r%180!=0&&([t,n]=[n,t]);let{curves:s,width:c,height:l}=e,u=e.thickness??0,d=[],f=Math.min(t/c,n/l),p=f/t,m=f/n,h=[];for(let{points:e}of s){let t=a?this.#s(e):e;if(!t)continue;h.push(t);let n=t.length,r=new Float32Array(n),i=new Float32Array(3*(n===2?2:n-2));if(d.push({line:i,points:r}),n===2){r[0]=t[0]*p,r[1]=t[1]*m,i.set([NaN,NaN,NaN,NaN,r[0],r[1]],0);continue}let[o,s,c,l]=t;o*=p,s*=m,c*=p,l*=m,r.set([o,s,c,l],0),i.set([NaN,NaN,NaN,NaN,o,s],0);for(let e=4;e<n;e+=2){let n=r[e]=t[e]*p,a=r[e+1]=t[e+1]*m;i.set(g7.createBezierPoints(o,s,c,l,n,a),(e-2)*3),[o,s,c,l]=[c,l,n,a]}}if(d.length===0)return null;let g=o?new A7:new D7;return g.build(d,t,n,1,r,o?0:u,i),{outline:g,newCurves:h,areContours:o,thickness:u,width:c,height:l}}static async compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){let a=1/0,o=-1/0,s=0;for(let t of e){s+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];a=Math.min(a,n),o=Math.max(o,n)}}let c;c=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let l=e.length,u=j7+M7*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(s-2*l)*c.BYTES_PER_ELEMENT,d[f++]=0,d[f++]=r,d[f++]=i,d[f++]=+!t,d[f++]=Math.max(0,Math.floor(n??0)),d[f++]=l,d[f++]=c.BYTES_PER_ELEMENT;for(let t of e)d[f++]=t.length-2,d[f++]=t[0],d[f++]=t[1];let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();await m.ready,m.write(d);let h=c.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}return m.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(e){try{let t=Uint8Array.fromBase64(e),{readable:n,writable:r}=new DecompressionStream(`deflate-raw`),i=r.getWriter();await i.ready,i.write(t).then(async()=>{await i.ready,await i.close()}).catch(()=>{});let a=null,o=0;for await(let e of n)a||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]),a.set(e,o),o+=e.length;let s=new Uint32Array(a.buffer,0,a.length>>2),c=s[1];if(c!==0)throw Error(`Invalid version: ${c}`);let l=s[2],u=s[3],d=s[4]===0,f=s[5],p=s[6],m=s[7],h=[],g=(j7+M7*p)*Uint32Array.BYTES_PER_ELEMENT,_;switch(m){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(a.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(a.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(a.buffer,g)}o=0;for(let e=0;e<p;e++){let t=s[M7*e+j7],n=new Float32Array(t+2);h.push(n);for(let t=0;t<2;t++)n[t]=s[M7*e+j7+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+_[o++]}return{areContours:d,thickness:f,outlines:h,width:l,height:u}}catch(e){return g4(`decompressSignature: ${e}`),null}}},P7=class e extends w7{constructor(){super(),super.updateProperties({fill:V3._defaultLineColor,"stroke-width":0})}clone(){let t=new e;return t.updateAll(this),t}},F7=class e extends O7{constructor(e){super(e),super.updateProperties({stroke:V3._defaultLineColor,"stroke-width":1})}clone(){let t=new e(this._viewParameters);return t.updateAll(this),t}},I7=class e extends T7{#e=!1;#t=null;#n=null;#r=null;static _type=`signature`;static _editorType=t4.SIGNATURE;static _defaultDrawingOptions=null;constructor(e){super({...e,mustBeCommitted:!0,name:`signatureEditor`}),this._willKeepAspectRatio=!0,this.#n=e.signatureData||null,this.#t=null,this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){V3.initialize(e,t),this._defaultDrawingOptions=new P7,this._defaultDrawnSignatureOptions=new F7(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!1}static get typesMap(){return C4(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(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,n,{_isCopy:r}=this;if(r&&(this._isCopy=!1,t=this.x,n=this.y),super.render(),this._drawId===null){if(this.#n){let{lines:t,mustSmooth:n,areContours:r,description:i,uuid:a,heightInPage:o}=this.#n,{rawDims:{pageWidth:s,pageHeight:c},rotation:l}=this.parent.viewport,u=N7.processDrawnLines({lines:t,pageWidth:s,pageHeight:c,rotation:l,innerMargin:e._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(u,o,i,a)}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||``}));return r&&(this._isCopy=!0,this._moveAfterPaste(t,n)),this.div}setUuid(e){this.#r=e,this.addEditToolbar()}getUuid(){return this.#r}get description(){return this.#t}set description(e){this.#t=e,this.div&&(this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e})),super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)}))}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=this.#n,a=Math.max(r,i);return{areContours:t,outline:N7.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,n,r,i){let{x:a,y:o}=this,{outline:s}=this.#n=t;this.#e=s instanceof A7,this.description=r;let c;this.#e?c=e.getDefaultDrawingOptions():(c=e._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":s.thickness})),this._addOutlines({drawOutlines:s,drawingOptions:c});let[,l]=this.pageDimensions,u=n/l;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!i,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return N7.process(t,n,r,i,e._INNER_MARGIN)}getFromText(t,n){let{rawDims:{pageWidth:r,pageHeight:i},rotation:a}=this.parent.viewport;return N7.extractContoursFromText(t,n,r,i,a,e._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return N7.processDrawnLines({lines:t,pageWidth:n,pageHeight:r,rotation:i,innerMargin:e._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:n}){t?this._drawingOptions=e.getDefaultDrawingOptions():(this._drawingOptions=e._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":n}))}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:this.#e,color:[0,0,0],thickness:this.#e?0:r});return this.addComment(i),e?(i.paths={lines:t,points:n},i.uuid=this.#r,i.isCopy=!0):i.lines=t,this.#t&&(i.accessibilityData={type:`Figure`,alt:this.#t}),i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?A7.deserialize(e,t,n,r,i,a):D7.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=await super.deserialize(e,t,n);return r.#e=e.areContours,r.description=e.accessibilityData?.alt||``,r.#r=e.uuid,r}},L7=class extends V3{#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=!1;#c=null;#l=!1;#u=!1;static _type=`stamp`;static _editorType=t4.STAMP;constructor(e){super({...e,name:`stampEditor`}),this.#r=e.bitmapUrl,this.#i=e.bitmapFile,this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){V3.initialize(e,t)}static isHandlingMimeForPasting(e){return h3.includes(e)}static paste(e,t){t.pasteEditor({mode:t4.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){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}}#d(e,t=!1){if(!e){this.remove();return}this.#e=e.bitmap,t||(this.#t=e.id,this.#l=e.isSvg),e.file&&(this.#a=e.file.name),this.#m()}#f(){if(this.#n=null,this._uiManager.enableWaiting(!1),this.#o){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:n}=this._uiManager;if(!n)throw Error(`No ML.`);if(!await n.isEnabledFor(`altText`))throw Error(`ML isn't enabled for alt text.`);let{data:r,width:i,height:a}=e||this.copyCanvas(null,null,!0).imageData,o=await n.guess({name:`altText`,request:{data:r,width:i,height:a,channels:r.length/(i*a)}});if(!o)throw Error(`No response from the AI service.`);if(o.error)throw Error(`Error from the AI service.`);if(o.cancel)return null;if(!o.output)throw Error(`No valid response from the AI service.`);let s=o.output;return await this.setGuessedAltText(s),t&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1}),s}#p(){if(this.#t){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#t).then(e=>this.#d(e,!0)).finally(()=>this.#f());return}if(this.#r){let e=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#d(e)).finally(()=>this.#f());return}if(this.#i){let e=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(e).then(e=>this.#d(e)).finally(()=>this.#f());return}let e=document.createElement(`input`);e.type=`file`,e.accept=h3.join(`,`);let t=this._uiManager._signal;this.#n=new Promise(n=>{e.addEventListener(`change`,async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(t)}n()},{signal:t}),e.addEventListener(`cancel`,()=>{this.remove(),n()},{signal:t})}).finally(()=>this.#f()),e.click()}remove(){this.#t&&(this.#e=null,this._uiManager.imageManager.deleteId(this.#t),this.#o?.remove(),this.#o=null,this.#c&&=(clearTimeout(this.#c),null)),super.remove()}rebuild(){if(!this.parent){this.#t&&this.#p();return}super.rebuild(),this.div!==null&&(this.#t&&this.#o===null&&this.#p(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#i||this.#t||this.#s)}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;return this._isCopy&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#s||(this.#e?this.#m():this.#p()),this._isCopy&&this._moveAfterPaste(e,t),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(this.#t=n,r&&(this.#e=r),this.#s=!1,this.#m())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(this.#c!==null&&clearTimeout(this.#c),this.#c=setTimeout(()=>{this.#c=null,this.#g()},200))}#m(){let{div:e}=this,{width:t,height:n}=this.#e,[r,i]=this.pageDimensions,a=.75;if(this.width)t=this.width*r,n=this.height*i;else if(t>a*r||n>a*i){let e=Math.min(a*r/t,a*i/n);t*=e,n*=e}this._uiManager.enableWaiting(!1);let o=this.#o=document.createElement(`canvas`);o.setAttribute(`role`,`img`),this.addContainer(o),this.width=t/r,this.height=n/i,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),this.#g(),this.#u||=(this.parent.addUndoableEditor(this),!0),this._reportTelemetry({action:`inserted_image`}),this.#a&&this.div.setAttribute(`aria-description`,this.#a),this.annotationElementId||this._uiManager.a11yAlert(V3._l10nAlert.stamp)}copyCanvas(e,t,n=!1){e||=224;let{width:r,height:i}=this.#e,a=new m3,o=this.#e,s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e),c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);this.#l||(o=this.#h(e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,f=`#cfcfd8`;this._uiManager.hcmFilter===`none`?g3.isDarkMode&&(d=`#8f8f9d`,f=`#42414d`):f=`black`;let p=15*a.sx,m=15*a.sy,h=new OffscreenCanvas(p*2,m*2),g=h.getContext(`2d`);g.fillStyle=d,g.fillRect(0,0,p*2,m*2),g.fillStyle=f,g.fillRect(0,0,p,m),g.fillRect(p,m,p,m),u.fillStyle=u.createPattern(h,`repeat`),u.fillRect(0,0,e,n),u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e)t=o.width,n=o.height;else if(o=this.#e,r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a),n=Math.floor(i*a),this.#l||(o=this.#h(t,n))}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n),u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}#h(e,t){let{width:n,height:r}=this.#e,i=n,a=r,o=this.#e;for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2)),a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a),o=s.transferToImageBitmap()}return o}#g(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new m3,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=this.#o;if(!s||s.width===a&&s.height===o)return;s.width=a,s.height=o;let c=this.#l?this.#e:this.#h(a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter,l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}#_(e){if(e){if(this.#l){let e=this._uiManager.imageManager.getSvgUrl(this.#t);if(e)return e}let e=document.createElement(`canvas`);return{width:e.width,height:e.height}=this.#e,e.getContext(`2d`).drawImage(this.#e,0,0),e.toDataURL()}if(this.#l){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*X4.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*X4.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);return i.getContext(`2d`).drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,n){let r=null,i=!1;if(e instanceof u7){let{data:{rect:a,rotation:o,id:s,structParent:c,popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},container:m,parent:{page:{pageNumber:h}},canvas:g}=e,_,v;g?(delete e.canvas,{id:_,bitmap:v}=n.imageManager.getFromCanvas(m.id,g),g.remove()):(i=!0,e._hasNoCanvas=!0);let y=(await t._structTree.getAriaAttributes(`${$2}${s}`))?.get(`aria-label`)||``;r=e={annotationType:t4.STAMP,bitmapId:_,bitmap:v,pageIndex:h-1,rect:a.slice(0),rotation:o,annotationElementId:s,id:s,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:c,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let a=await super.deserialize(e,t,n),{rect:o,bitmap:s,bitmapUrl:c,bitmapId:l,isSvg:u,accessibilityData:d}=e;i?(n.addMissingCanvas(e.id,a),a.#s=!0):l&&n.imageManager.isValidId(l)?(a.#t=l,s&&(a.#e=s)):a.#r=c,a.#l=u;let[f,p]=a.pageDimensions;return a.width=(o[2]-o[0])/f,a.height=(o[3]-o[1])/p,d&&(a.altTextData=d),a._initialData=r,e.comment&&a.setCommentData(e),a.#u=!!r,a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:this.#t,isSvg:this.#l});if(this.addComment(n),e)return n.bitmapUrl=this.#_(!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;let{decorative:r,altText:i}=this.serializeAltText(!1);if(!r&&i&&(n.accessibilityData={type:`Figure`,alt:i}),this.annotationElementId){let e=this.#v(n);return e.isSame?null:(e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1,n.id=this.annotationElementId,delete n.bitmapId,n)}if(t===null)return n;t.stamps||=new Map;let a=this.#l?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!t.stamps.has(this.#t))t.stamps.set(this.#t,{area:a,serialized:n}),n.bitmap=this.#_(!1);else if(this.#l){let e=t.stamps.get(this.#t);a>e.area&&(e.area=a,e.serialized.bitmap.close(),e.serialized.bitmap=this.#_(!1))}return n}#v(e){let{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,i=(e.accessibilityData?.alt||``)===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&i,isSameAltText:i}}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}},R7=class e{#e;#t=!1;#n=null;#r=null;#i=null;#a=new Map;#o=!1;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=null;#p=null;#m=-1;#h;static _initialized=!1;static#g=new Map([h7,k7,L7,C7,I7].map(e=>[e._editorType,e]));constructor({uiManager:t,pageIndex:n,div:r,structTreeLayer:i,accessibilityManager:a,annotationLayer:o,drawLayer:s,textLayer:c,viewport:l,l10n:u}){let d=[...e.#g.values()];if(!e._initialized){e._initialized=!0;for(let e of d)e.initialize(u,t)}t.registerEditorTypes(d),this.#h=t,this.pageIndex=n,this.div=r,this.#e=a,this.#n=o,this.viewport=l,this.#d=c,this.drawLayer=s,this._structTree=i,this.#h.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===t4.NONE}updateToolbar(e){this.#h.updateToolbar(e)}updateMode(t=this.#h.getMode()){switch(this.#S(),t){case t4.NONE:this.div.classList.toggle(`nonEditing`,!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case t4.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case t4.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:n}=this.div;if(n.toggle(`nonEditing`,!1),t===t4.POPUP)n.toggle(`commentEditing`,!0);else{n.toggle(`commentEditing`,!1);for(let r of e.#g.values())n.toggle(`${r._type}Editing`,t===r._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#h.setEditingState(e)}addCommands(e){this.#h.addCommands(e)}cleanUndoStack(e){this.#h.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#n?.togglePointerEvents(e)}get#_(){return this.#a.size===0?this.#h.getEditors(this.pageIndex):this.#a.values()}async enable(){this.#c=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle(`nonEditing`,!1),this.#p?.abort(),this.#p=null;let e=new Set;for(let t of this.#_)t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#h.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));let t=this.#n;if(t)for(let n of t.getEditableAnnotations()){if(n.hide(),this.#h.isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;let t=await this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}this.#c=!1,this.#h._eventBus.dispatch(`editorsrendered`,{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#s=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle(`nonEditing`,!0),this.#d&&!this.#p){this.#p=new AbortController;let e=this.#h.combinedSignal(this.#p);this.#d.div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-this.#m>500){this.#m=r;return}this.#m=-1;let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);if(i.toggle(`getElements`,!1),!this.div.contains(a[0]))return;let o,s=RegExp(`^${e4}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=this.#a.get(o);c?.annotationElementId===null&&(o3(e),c.dblclick(e))},{signal:e,capture:!0})}let t=this.#n,n=[];if(t){let e=new Map,r=new Map;for(let t of this.#_){if(t.disableEditing(),!t.annotationElementId){n.push(t);continue}if(t.serialize()!==null){e.set(t.annotationElementId,t);continue}r.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()}for(let n of t.getEditableAnnotations()){let{id:t}=n.data;if(this.#h.isDeletedAnnotationElement(t)){n.updateEdited({deleted:!0});continue}let i=r.get(t);if(i){i.resetAnnotationElement(n),i.show(!1),n.show();continue}i=e.get(t),i&&(this.#h.addChangedExistingAnnotation(i),i.renderAnnotationElement(n)&&i.show(!1)),n.show()}}this.#S(),this.isEmpty&&(this.div.hidden=!0);let{classList:r}=this.div;for(let t of e.#g.values())r.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(n),this.#s=!1}getEditableAnnotation(e){return this.#n?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#h.getActive()!==e&&this.#h.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#h.combinedSignal(this.#f);this.#d.div.addEventListener(`pointerdown`,this.#v.bind(this),{signal:e}),this.#d.div.classList.add(`highlighting`)}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove(`highlighting`))}#v(e){this.#h.unselectAll();let{target:t}=e;if(t===this.#d.div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&this.#d.div.contains(t)){let{isMac:t}=N4.platform;if(e.button!==0||e.ctrlKey&&t)return;this.#h.showAllEditors(`highlight`,!0,!0),this.#d.div.classList.add(`free`),this.toggleDrawing(),C7.startHighlighting(this,this.#h.direction===`ltr`,{target:this.#d.div,x:e.x,y:e.y}),this.#d.div.addEventListener(`pointerup`,()=>{this.#d.div.classList.remove(`free`),this.toggleDrawing(!0)},{once:!0,signal:this.#h._signal}),e.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let e=this.#h.combinedSignal(this.#r);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.#r?.abort(),this.#r=null}attach(e){this.#a.set(e.id,e);let{annotationElementId:t}=e;t&&this.#h.isDeletedAnnotationElement(t)&&this.#h.removeDeletedAnnotationElement(e)}detach(e){this.#a.delete(e.id),this.#e?.removePointerInTextLayer(e.contentDiv),!this.#s&&e.annotationElementId&&this.#h.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#h.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#h.addDeletedAnnotationElement(e),V3.deleteAnnotationElement(e),e.annotationElementId=null),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)){if(this.changeParent(e),this.#h.addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#c),this.#h.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;e.div.contains(t)&&!this.#i&&(e._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal}),t.focus())},0)),e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of this.#a.values())if(t.uid===e)return t;return null}get#y(){return e.#g.get(this.#h.getMode())}combinedSignal(e){return this.#h.combinedSignal(e)}#b(e){let t=this.#y;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#y?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e),await this.#h.updateMode(e.mode);let{offsetX:n,offsetY:r}=this.#x(),i=this.#h.getId(),a=this.#b({parent:this,id:i,x:n,y:r,uiManager:this.#h,isCentered:!0,...t});a&&this.add(a)}async deserialize(t){return await e.#g.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#h)||null}createAndAddNewEditor(e,t,n={}){let r=this.#h.getId(),i=this.#b({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#h,isCentered:t,...n});return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=Math.min(window.innerWidth,e+n),s=Math.min(window.innerHeight,t+r),c=(i+o)/2-e,l=(a+s)/2-t,[u,d]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:u,offsetY:d}}addNewEditor(e={}){this.createAndAddNewEditor(this.#x(),!0,e)}setSelected(e){this.#h.setSelected(e)}toggleSelected(e){this.#h.toggleSelected(e)}unselect(e){this.#h.unselect(e)}pointerup(e){let{isMac:t}=N4.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div||!this.#o||(this.#o=!1,this.#y?.isDrawer&&this.#y.supportMultipleDrawings))return;if(!this.#t){this.#t=!0;return}let n=this.#h.getMode();if(n===t4.STAMP||n===t4.POPUP||n===t4.SIGNATURE){this.#h.unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){if(this.#h.getMode()===t4.HIGHLIGHT&&this.enableTextSelection(),this.#o){this.#o=!1;return}let{isMac:t}=N4.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;if(this.#o=!0,this.#y?.isDrawer){this.startDrawingSession(e);return}let n=this.#h.getActive();this.#t=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),this.#l){this.#y.startDrawing(this,this.#h,!1,e);return}this.#h.setCurrentDrawingSession(this),this.#l=new AbortController;let t=this.#h.combinedSignal(this.#l);this.div.addEventListener(`blur`,({relatedTarget:e})=>{e&&!this.div.contains(e)&&(this.#u=null,this.commitOrRemove())},{signal:t}),this.#y.startDrawing(this,this.#h,!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(e=!1){return this.#l?(this.#h.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#u=null,this.#y.endDrawing(e)):null}findNewParent(e,t,n){let r=this.#h.findParent(t,n);return r===null||r===this?!1:(r.changeParent(e),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#y.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#h.getActive()?.parent===this&&(this.#h.commitOrRemove(),this.#h.setActiveEditor(null)),this.#i&&=(clearTimeout(this.#i),null);for(let e of this.#a.values())this.#e?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#a.clear(),this.#h.removeLayer(this)}#S(){for(let e of this.#a.values())e.isEmpty()&&e.remove()}async render({viewport:e}){this.viewport=e,p3(this.div,e);for(let e of this.#h.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#h.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:e}){this.#h.commitOrRemove(),this.#S();let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,p3(this.div,{rotation:n}),t!==n)for(let e of this.#a.values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#h.viewParameters.realScale}};function z7(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function B7(e){return e?e.nodeType===Node.ELEMENT_NODE?e.closest(`.textLayer`):e.parentElement?.closest(`.textLayer`)||null:null}function V7(e,t,n,r){if(e===n)return t<=r;let i=e.compareDocumentPosition(n);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function H7(e,t,n){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains(`textLayer`)||t!==e.childNodes.length)return{container:e,offset:t};let r=e.lastChild;return r?.nodeType===Node.ELEMENT_NODE&&r.classList.contains(`endOfContent`)&&(r=r.previousSibling),!r||!n.contains(r)?null:r.nodeType===Node.TEXT_NODE?{container:r,offset:r.textContent.length}:{container:r,offset:r.childNodes.length}}var U7=class e{#e=null;#t=new Map;#n=null;#r=null;#i=null;#a=null;#o=new Map;static#s=0;static#c=0;static#l=null;static#u=new Set;static#d=!1;static#f=new Set;static#p=new WeakMap;constructor({filterFactory:t=null,pageColors:n=null,pageIndex:r,textLayer:i=null}){if(this.pageIndex=r,this.#r=t,this.#i=n,i){let t=e.#p.get(i);if(t?.selectionDiv&&(t.selectionDiv.remove(),e.#u.delete(t.selectionDiv)),e.#p.set(i,{drawLayer:this}),e.#f.add(i),this.#n=i,this.#a=new MutationObserver(t=>{if(!(!this.#e||!this.#n?.isConnected||!e.#h())){for(let{addedNodes:n}of t)for(let t of n)if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains(`endOfContent`)){e.#_();return}}}),this.#a.observe(i,{childList:!0}),e.#l===null){e.#l=new AbortController;let{signal:t}=e.#l;document.addEventListener(`selectionchange`,e.#_.bind(e),{signal:t}),document.addEventListener(`pointerdown`,()=>{e.#d=!0},{signal:t}),document.addEventListener(`pointerup`,()=>{e.#d=!1},{signal:t}),window.addEventListener(`blur`,()=>{e.#d=!1},{signal:t})}}}setParent(t){if(!this.#e){this.#e=t,this.#n?.isConnected&&e.#h()&&e.#_();return}if(this.#e!==t){if(this.#t.size>0)for(let e of this.#t.values())e.remove(),t.append(e);this.#e=t}}static#m(e){let t=this.#p.get(e);t?.selectionDiv&&(t.selectionDiv.remove(),this.#u.delete(t.selectionDiv),t.selectionDiv=null,t.path=null)}static#h(){let e=document.getSelection();return!!e&&!e.isCollapsed}static#g(){return this.#f.keys().filter(e=>e.isConnected).toArray().sort(z7)}static#_(){let t=document.getSelection();if(!t||t.isCollapsed){for(let e of this.#u)e.remove();this.#u.clear();return}let n=new WeakMap,r=this.#g(),i=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(n.collapsed)continue;let{startContainer:a,startOffset:o,endContainer:s,endOffset:c}=n,l=B7(a),u=B7(s),d=l===null,f=u===null;if(this.#d&&d!==f)return;if(t.rangeCount===1){let{anchorNode:e,anchorOffset:n,focusNode:r,focusOffset:i}=t,d=B7(e),f=B7(r),p=V7(e,n,r,i);d&&f&&p!==null&&(p?(a=e,o=n,l=d,s=r,c=i,u=f):(a=r,o=i,l=f,s=e,c=n,u=d))}let p=r.filter(e=>n.intersectsNode(e));if(p.length===0)continue;let m=!1;if(l||(l=p[0],a=l,o=0,m=!0),u||(u=p.at(-1),s=u,c=u.childNodes.length,m=!0),s.nodeType===Node.ELEMENT_NODE){if(s.classList.contains(`endOfContent`)){let e=s.previousSibling;if(!e)continue;s=e,c=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length}else if(s.classList.contains(`textLayer`)&&s.childNodes.length===c){let e=H7(s,c,u);if(!e)continue;s=e.container,c=e.offset}}if(a.nodeType===Node.ELEMENT_NODE){let e=H7(a,o,l);if(!e)continue;a=e.container,o=e.offset}if(l===u&&!m&&p.includes(l)){i.push([n,l]);continue}for(let e of p){let t=e.firstChild;if(!t)continue;let n=document.createRange();if(e===l?n.setStart(a,o):n.setStartBefore(t),e===u)n.setEnd(s,c);else{let t=e.lastChild;if(!t)continue;if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains(`endOfContent`)){let e=t.previousSibling;if(!e)continue;n.setEndAfter(e)}else n.setEndAfter(t)}n.collapsed||i.push([n,e])}}let a=new Set(i.map(e=>e[1]));for(let e of this.#f)a.has(e)||this.#m(e);for(let[t,r]of i){let i=e.#p.get(r);if(!i)continue;let a=n.get(r);if(!a){let e=r.getBoundingClientRect();a=(t,n,r,i)=>({x:(t-e.x)/e.width,y:(n-e.y)/e.height,width:r/e.width,height:i/e.height}),n.set(r,a)}let o=[];for(let{x:e,y:n,width:r,height:i}of t.getClientRects())r!==0&&i!==0&&({x:e,y:n,width:r,height:i}=a(e,n,r,i),(r!==1||i!==1)&&o.push(`M${e} ${n} h${r} v${i} h-${r} Z`));if(o.length===0)continue;let s=i.drawLayer,c=i.selectionDiv,l=i.path;if(!c){let t=`clip_selection_${e.#c++}`;c=document.createElement(`div`),c.className=`selection`,c.style.clipPath=`url(#${t})`;let n=s.#r?.createSelectionStyle(s.#i);if(n)for(let[e,t]of Object.entries(n))c.style.setProperty(e,t);let r=e._svgFactory.create(1,1,!0);r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`width`,`100%`),r.setAttribute(`height`,`100%`);let a=e._svgFactory.createElement(`clipPath`);a.setAttribute(`id`,t),a.setAttribute(`clipPathUnits`,`objectBoundingBox`),l=e._svgFactory.createElement(`path`),a.append(l),r.append(a),c.append(r),i.path=l,i.selectionDiv=c}!c.parentNode&&s.#e&&(s.#e.append(c),this.#u.add(c)),l.setAttribute(`d`,o.join(` `))}}static get _svgFactory(){return C4(this,`_svgFactory`,new P5)}static#v(e,[t,n,r,i]){let{style:a}=e;a.top=`${100*n}%`,a.left=`${100*t}%`,a.width=`${100*r}%`,a.height=`${100*i}%`}#y(){let t=e._svgFactory.create(1,1,!0);return this.#e.append(t),t.setAttribute(`aria-hidden`,`true`),t}#b(t,n){let r=e._svgFactory.createElement(`clipPath`);t.append(r);let i=`clip_${n}`;r.setAttribute(`id`,i),r.setAttribute(`clipPathUnits`,`objectBoundingBox`);let a=e._svgFactory.createElement(`use`);return r.append(a),a.setAttribute(`href`,`#${n}`),a.classList.add(`clip`),i}#x(e,t){for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r)}draw(t,n=!1,r=!1){let i=e.#s++,a=this.#y(),o=e._svgFactory.createElement(`defs`);a.append(o);let s=e._svgFactory.createElement(`path`);o.append(s);let c=`path_${i}`;s.setAttribute(`id`,c),s.setAttribute(`vector-effect`,`non-scaling-stroke`),n&&this.#o.set(i,s);let l=r?this.#b(o,c):null,u=e._svgFactory.createElement(`use`);return a.append(u),u.setAttribute(`href`,`#${c}`),this.updateProperties(a,t),this.#t.set(i,a),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,n){let r=e.#s++,i=this.#y(),a=e._svgFactory.createElement(`defs`);i.append(a);let o=e._svgFactory.createElement(`path`);a.append(o);let s=`path_${r}`;o.setAttribute(`id`,s),o.setAttribute(`vector-effect`,`non-scaling-stroke`);let c;if(n){let t=e._svgFactory.createElement(`mask`);a.append(t),c=`mask_${r}`,t.setAttribute(`id`,c),t.setAttribute(`maskUnits`,`objectBoundingBox`);let n=e._svgFactory.createElement(`rect`);t.append(n),n.setAttribute(`width`,`1`),n.setAttribute(`height`,`1`),n.setAttribute(`fill`,`white`);let i=e._svgFactory.createElement(`use`);t.append(i),i.setAttribute(`href`,`#${s}`),i.setAttribute(`stroke`,`none`),i.setAttribute(`fill`,`black`),i.setAttribute(`fill-rule`,`nonzero`),i.classList.add(`mask`)}let l=e._svgFactory.createElement(`use`);i.append(l),l.setAttribute(`href`,`#${s}`),c&&l.setAttribute(`mask`,`url(#${c})`);let u=l.cloneNode();return i.append(u),l.classList.add(`mainOutline`),u.classList.add(`secondaryOutline`),this.updateProperties(i,t),this.#t.set(r,i),r}finalizeDraw(e,t){this.#o.delete(e),this.updateProperties(e,t)}updateProperties(t,n){if(!n)return;let{root:r,bbox:i,rootClass:a,path:o}=n,s=typeof t==`number`?this.#t.get(t):t;if(s){if(r&&this.#x(s,r),i&&e.#v(s,i),a){let{classList:e}=s;for(let[t,n]of Object.entries(a))e.toggle(t,n)}if(o){let e=s.firstElementChild.firstElementChild;this.#x(e,o)}}}updateParent(e,t){if(t===this)return;let n=this.#t.get(e);n&&(t.#e.append(n),this.#t.delete(e),t.#t.set(e,n))}remove(e){this.#o.delete(e),this.#e!==null&&(this.#t.get(e).remove(),this.#t.delete(e))}destroy(){this.#e=null;for(let e of this.#t.values())e.remove();this.#t.clear(),this.#o.clear(),this.#a?.disconnect(),this.#a=null,this.#n&&=(e.#p.get(this.#n)?.drawLayer===this&&(e.#m(this.#n),e.#p.delete(this.#n),e.#f.delete(this.#n),e.#f.size===0&&(e.#l?.abort(),e.#l=null,e.#d=!1)),null)}};function W7(e){return`${(e*100).toFixed(2)}%`}var G7=class e{#e=[];#t=new Map;#n=null;#r=0;#i=0;#a=0;static#o=null;constructor(e,t,n,r){this.#r=e,this.#e=t,this.#i=n.rawDims.pageWidth,this.#a=n.rawDims.pageHeight,this.#n=r}render(){let t=document.createElement(`div`);t.className=`textLayerImages`;for(let e=0;e<this.#e.length;e+=6){let n=this.#s(this.#e.subarray(e,e+6));n&&t.append(n)}return t.addEventListener(`contextmenu`,t=>{if(!(t.target instanceof HTMLCanvasElement))return;let n=t.target,r=this.#t.get(n);if(!r)return;let i=e.#o?.deref();if(i===n)return;i&&(i.width=0,i.height=0),e.#o=new WeakRef(n);let{inverseTransform:a,x1:o,y1:s,width:c,height:l}=r,u=this.#n(),d=Math.ceil(o*u.width),f=Math.ceil(s*u.height),p=Math.floor((o+c/this.#i)*u.width),m=Math.floor((s+l/this.#a)*u.height);n.width=p-d,n.height=m-f;let h=n.getContext(`2d`);h.setTransform(...a),h.translate(-d,-f),h.drawImage(u,0,0)}),t}#s([e,t,n,r,i,a]){let o=Math.hypot((i-e)*this.#i,(a-t)*this.#a),s=Math.hypot((n-e)*this.#i,(r-t)*this.#a);if(o<this.#r||s<this.#r)return null;let c=[(i-e)*this.#i/o,(a-t)*this.#a/o,(n-e)*this.#i/s,(r-t)*this.#a/s,0,0],l=$.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:W7(e),top:W7(t),width:W7(o/this.#i),height:W7(s/this.#a),transformOrigin:`0% 0%`,transform:`matrix(${c.join(`,`)})`}),this.#t.set(u,{inverseTransform:l,width:o,height:s,x1:e,y1:t}),u}};globalThis._pdfjsTestingUtils={HighlightOutliner:y7},globalThis.pdfjsLib={AbortException:A4,AnnotationEditorLayer:R7,AnnotationEditorParamsType:n4,AnnotationEditorType:t4,AnnotationEditorUIManager:L3,AnnotationLayer:p7,AnnotationMode:Q2,AnnotationType:o4,applyOpacity:v3,build:D5,ColorPicker:O5,createValidAbsoluteUrl:b4,CSSConstants:_3,DOMSVGFactory:P5,DrawLayer:U7,FeatureTest:N4,fetchData:Z4,findContrastColor:w3,getDocument:_5,getFilenameFromUrl:t3,getPdfFilenameFromUrl:n3,getRGB:l3,getRGBA:c3,getUuid:R4,GlobalWorkerOptions:i5,ImageKind:a4,InvalidPDFException:D4,isDataScheme:$4,isPdfFile:e3,isValidExplicitDest:w6,makeArr:B4,makeMap:V4,makeObj:H4,makeSet:U4,MathClamp:W4,noContextMenu:a3,normalizeUnicode:L4,OPS:l4,OutputScale:m3,PasswordException:T4,PasswordResponses:d4,PDFDataRangeTransport:y5,PDFDateString:s3,PDFWorker:S5,PermissionFlag:r4,PixelsPerInch:X4,RenderingCancelledException:Q4,renderRichText:T3,ResponseException:O4,setLayerDimensions:p3,shadow:C4,SignatureExtractor:N7,stopEvent:o3,SupportedImageMimeTypes:h3,TextLayer:h5,TextLayerImages:G7,TouchManager:B3,updateUrlHash:x4,Util:$,VerbosityLevel:c4,version:E5,XfaLayer:Y4};function K7(e){let t=atob(e),{length:n}=t,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r}function q7(e){let{src:t}=e,n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(),[c,l]=(0,Z.useState)(1),u=(0,Z.useRef)(null),d=(0,Z.useCallback)((e,t,n=o,r=1)=>{let i=e.current;!i||!n||(i.height=0,i.width=0,n.getPage(t).then(e=>{let t=e.getViewport({scale:r});i.height=t.height,i.width=t.width;let n={canvasContext:i.getContext(`2d`),viewport:t,canvas:i};try{return u.current&&u.current.cancel(),u.current=e.render(n),u.current.promise}catch(e){console.error(`Error rendering page:`,e);return}}).catch(e=>console.error(e)))},[o]);return(0,Z.useEffect)(()=>{d(n,c,o)},[o,c,d]),(0,Z.useEffect)(()=>{i&&new Promise(e=>setTimeout(e,100)).then(()=>{d(r,c,o,2)})},[i,o,c,d]),(0,Z.useEffect)(()=>{i5.workerSrc=`https://unpkg.com/pdfjs-dist@${E5}/build/pdf.worker.min.mjs`},[]),(0,Z.useEffect)(()=>{_5({data:K7(t)}).promise.then(e=>{s(e)},e=>{console.error(e)})},[t]),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(q,{onClick:()=>c>1&&l(c-1),disabled:c<=1,children:`Previous`}),(0,Q.jsx)(q,{onClick:()=>o&&c<o.numPages&&l(c+1),disabled:c>=(o?.numPages??-1),children:`Next`}),(0,Q.jsx)(`canvas`,{ref:n,onClick:()=>a(!0)}),(0,Q.jsx)(PJ,{open:i,onOpenChange:a,children:(0,Q.jsxs)(RJ,{children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{})}),(0,Q.jsx)(lu,{className:`h-100 w-full rounded-md border p-4`,children:(0,Q.jsx)(`canvas`,{ref:r})})]})})]})}var J7=[Ve.Unprocessed,Ve.Other],Y7=({document:e,onChange:t})=>{let n=`creditor`in e?e.creditor:void 0,r=!e.documentType||!J7.includes(e.documentType),i=r&&!n?.id||Ve.Unprocessed===e.documentType,{selectableBusinesses:a,refresh:o}=pK(),s=(0,Z.useMemo)(()=>{if(n||!(`missingInfoSuggestions`in e)||!e.missingInfoSuggestions)return;let t=e.missingInfoSuggestions.owner,r=e.missingInfoSuggestions.counterparty;if(e.missingInfoSuggestions?.isIncome==null){if(e.debtor?.id){let n=e.debtor.id;if(t?.id===n&&r)return r;if(r?.id===n&&t)return t}}else if(e.missingInfoSuggestions.isIncome&&t)return t;else if(!e.missingInfoSuggestions.isIncome&&r)return r},[e,n]),c=!n&&!!s,{name:l=`Missing`,id:u}=(n??s)||{},{updateDocument:d,fetching:f}=jz(),p=(0,Z.useCallback)(t=>{t!==void 0&&d({documentId:e.id,fields:{creditorId:t}}).then(e.onUpdate)},[e.id,d,e.onUpdate]),[m,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async e=>{await p(e),o(),t?.()},[p,t,o]);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col justify-center whitespace-normal`,children:(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!i,color:`red`,zIndex:`auto`,children:r&&(u?(0,Q.jsx)(vt,{to:yt.BUSINESSES.DETAIL(u),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:l}):(0,Q.jsx)(u0,{options:a,value:u??null,onChange:e=>e&&p(e),search:m,onSearchChange:h,placeholder:`Choose or create a business`,empty:m?(0,Q.jsx)(i2,{description:m,onAdd:g}):null}))})}),c&&(0,Q.jsx)(Qk,{onClick:()=>p(s.id),disabled:f})]})},X7=({document:e})=>{let t=`amount`in e?e.amount:void 0,n=`missingInfoSuggestions`in e?e.missingInfoSuggestions?.amount:void 0,r=!t&&!!n,i=t??n,{updateDocument:a,fetching:o}=jz(),s=(0,Z.useCallback)(t=>{t!==void 0&&a({documentId:e.id,fields:{amount:{raw:t.raw,currency:t.currency}}}).then(e.onUpdate)},[e.id,a,e.onUpdate]),c=Ve.Other!==e.documentType&&i?.formatted==null;return(0,Q.jsxs)(`div`,{className:`flex flex-wrap`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col justify-center`,children:(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!c,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{className:[`whitespace-nowrap`,r?`bg-yellow-400`:``,Number(i?.raw)>0?`text-green-700`:`text-red-500`].join(` `),children:i?.formatted})})}),r&&(0,Q.jsx)(Qk,{onClick:()=>s(n),disabled:o})]})},Z7=({document:e})=>{let t=`date`in e?e.date:void 0,n=Ve.Other!==e.documentType,r=n&&!t,i=t?Or(new Date(t),`dd/MM/yy`):`Missing Data`;return(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!r,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`div`,{children:n?i:null})})},Q7=({document:e,onChange:t})=>{let n=`debtor`in e?e.debtor:void 0,r=!e.documentType||!J7.includes(e.documentType),i=r&&!n?.id||Ve.Unprocessed===e.documentType,{selectableBusinesses:a,refresh:o}=pK(),s=(0,Z.useMemo)(()=>{if(n||!(`missingInfoSuggestions`in e)||!e.missingInfoSuggestions)return;let t=e.missingInfoSuggestions.owner,r=e.missingInfoSuggestions.counterparty;if(e.missingInfoSuggestions?.isIncome==null){if(e.creditor?.id){let n=e.creditor.id;if(t?.id===n&&r)return r;if(r?.id===n&&t)return t}}else if(e.missingInfoSuggestions.isIncome&&r)return r;else if(!e.missingInfoSuggestions.isIncome&&t)return t},[e,n]),c=!n&&!!s,{name:l=`Missing`,id:u}=(n??s)||{},{updateDocument:d,fetching:f}=jz(),p=(0,Z.useCallback)(t=>{t!==void 0&&d({documentId:e.id,fields:{debtorId:t}}).then(e.onUpdate)},[e.id,d,e.onUpdate]),[m,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async e=>{await p(e),o(),t?.()},[p,t,o]);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col justify-center whitespace-normal`,children:(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!i,color:`red`,zIndex:`auto`,children:r&&(u?(0,Q.jsx)(vt,{to:yt.BUSINESSES.DETAIL(u),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:l}):(0,Q.jsx)(u0,{options:a,value:u??null,onChange:e=>e&&p(e),search:m,onSearchChange:h,placeholder:`Choose or create a business`,empty:m?(0,Q.jsx)(i2,{description:m,onAdd:g}):null}))})}),c&&(0,Q.jsx)(Qk,{onClick:()=>p(s.id),disabled:f})]})},$7=({document:e})=>{let t=``;if(e.description)t=e.description;else if(`issuedDocumentInfo`in e&&e.issuedDocumentInfo?.originalDocument?.income){let{income:n}=e.issuedDocumentInfo.originalDocument;t=n.map(e=>e.description).join(`, `)}return(0,Q.jsx)(`div`,{className:`flex flex-col justify-center whitespace-normal`,children:(0,Q.jsx)(`p`,{children:t})})},e9=({document:{image:e,file:t}})=>{let[n,r]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap`,children:(0,Q.jsx)(`div`,{className:`flex flex-col justify-center`,children:(0,Q.jsxs)(dk,{cols:1,children:[(0,Q.jsx)(SK,{disabled:!e,content:`Open Image`,children:(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!!e,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,disabled:!e,onClick:()=>r(!!e),children:(0,Q.jsx)(aa,{className:`size-5`})})})}),(0,Q.jsx)(SK,{disabled:!t,content:`Open File`,children:(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!!t,color:`red`,zIndex:`auto`,children:t?(0,Q.jsx)(`a`,{href:typeof t==`string`?t:t.href,target:`_blank`,rel:`noreferrer`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,children:(0,Q.jsx)(ta,{className:`size-5`})})}):(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7.5`,disabled:!0,children:(0,Q.jsx)(ta,{className:`size-5`})})})})]})})}),e&&(0,Q.jsx)($C,{classNames:{content:`overflow-y-auto drop-shadow-lg`},withCloseButton:!0,withOverlay:!1,position:`right`,opened:n,onClose:()=>r(!1),size:`30%`,children:(0,Q.jsx)(`div`,{className:`m-2`,children:(0,Q.jsx)(CK,{src:e.toString(),zoomLevel:3,magnifierHeight:300,magnifierWidth:300})})})]})},t9=({document:e})=>(0,Q.jsx)(`div`,{className:`flex flex-col justify-center whitespace-normal`,children:(0,Q.jsx)(`p`,{children:e.remarks})}),n9=({document:e})=>{let t=`serialNumber`in e?e.serialNumber:void 0,n=`allocationNumber`in e?e.allocationNumber:void 0,r=Ve.Other!==e.documentType&&!t;return(0,Q.jsxs)(`div`,{className:`flex flex-col align-center justify-center flex-wrap`,children:[(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!r,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{children:t})}),n&&(0,Q.jsxs)(`p`,{className:`text-xs`,children:[`(`,n,`)`]})]})},r9=({document:{documentType:e},isOpen:t})=>{let n=!e||e===Ve.Unprocessed,r=e??Ve.Unprocessed;return(0,Q.jsx)(`div`,{className:`flex flex-wrap`,children:(0,Q.jsx)(`div`,{className:`flex flex-col justify-center whitespace-normal`,children:(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!n&&!t,color:n?`red`:t?`orange`:`blue`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{children:au(r)})})})})},i9=({document:e})=>{let t=`vat`in e?e.vat:void 0,n=Ve.Other!==e.documentType&&t?.formatted==null;return(0,Q.jsx)(UT,{inline:!0,size:12,disabled:!n,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`div`,{style:{color:Number(t?.raw)>0?`green`:`red`,whiteSpace:`nowrap`},children:t?.formatted})})},a9=[{id:`date`,accessorKey:`date`,sortFn:e=>`date`in e.original&&e.original.date?new Date(e.original.date).getTime():0,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Date`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(Z7,{document:e.original})},{id:`amount`,accessorKey:`amount.raw`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(X7,{document:e.original})},{id:`vat`,accessorKey:`vat.raw`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`VAT`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(i9,{document:e.original})},{id:`type`,accessorKey:`documentType`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Type`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(r9,{document:e.original,isOpen:`issuedDocumentInfo`in e.original&&e.original.issuedDocumentInfo?.status===`OPEN`})},{id:`serial`,accessorKey:`serialNumber`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Serial`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(n9,{document:e.original})},{id:`description`,accessorKey:`description`,header:`Description`,cell:({row:e})=>(0,Q.jsx)($7,{document:e.original})},{id:`remarks`,accessorKey:`remarks`,header:`Remarks`,cell:({row:e})=>(0,Q.jsx)(t9,{document:e.original})},{id:`creditor`,accessorKey:`creditor.name`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Creditor`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(Y7,{document:e.original,onChange:e.original.onUpdate})},{id:`debtor`,accessorKey:`debtor.name`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Debtor`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(Q7,{document:e.original,onChange:e.original.onUpdate})},{id:`file`,accessorKey:`file`,header:({column:e})=>(0,Q.jsxs)(q,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`files`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(tn,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(pn,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(e9,{document:e.original})},{id:`edit`,accessorKey:`id`,header:`Edit`,cell:({row:e})=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,Q.jsx)(sA,{onClick:e.original.editDocument,tooltip:`Edit Document`}),`issuedDocumentInfo`in e.original&&e.original.issuedDocumentInfo?.status===`OPEN`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Zk,{documentId:e.original.id,couldIssueCreditInvoice:e.original.documentType===Ve.Invoice||e.original.documentType===Ve.InvoiceReceipt}),(0,Q.jsx)(h9,{documentId:e.original.id,tooltip:`Issue Document out of This Document`})]})]})}];function o9({businessId:e,linkedDocumentIds:t,limit:n}){let[r,i]=(0,Z.useState)(void 0),[{data:a,fetching:o}]=W({query:O,variables:{businessId:e,limit:n}}),s=(0,Z.useMemo)(()=>a?.recentDocumentsByBusiness?.map(e=>{let t=Lr(h,e);return t?{...t,onUpdate:()=>{},editDocument:()=>i(t.id)}:null}).filter(e=>!!e)??[],[a?.recentDocumentsByBusiness]),c=[`date`,`amount`,`vat`,`type`,`serial`,`description`,`remarks`,`file`,`edit`],l=Hr({features:yi,data:s,columns:a9.filter(e=>e.id&&c.includes(e.id)),state:{}});return(0,Q.jsxs)(Mi,{children:[(0,Q.jsx)(Oi,{children:(0,Q.jsx)(Ai,{children:`Recent Client Documents`})}),(0,Q.jsx)(ki,{children:o?(0,Q.jsx)(`div`,{children:`Loading...`}):(0,Q.jsxs)(Si,{children:[(0,Q.jsx)(zr,{children:l.getHeaderGroups().map(e=>(0,Q.jsx)(di,{children:e.headers.map(e=>(0,Q.jsx)(ei,{colSpan:e.colSpan,children:e.isPlaceholder?null:Gr(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Q.jsx)(ci,{children:l.getRowModel().rows?.length?l.getRowModel().rows.map(e=>(0,Q.jsx)(di,{"data-state":e.getIsSelected()&&`selected`,className:e.original.issuedDocumentInfo?.externalId&&t.includes(e.original.issuedDocumentInfo.externalId)?`bg-blue-100`:``,children:e.getVisibleCells().map(e=>(0,Q.jsx)(gi,{children:Gr(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,Q.jsx)(di,{children:(0,Q.jsx)(gi,{colSpan:l.options.columns.length,className:`h-24 text-center`,children:`No results.`})})})]})}),(0,Q.jsx)(P0,{documentId:r,onDone:()=>i(void 0),onChange:()=>{}})]})}var s9=r(ri(),1),c9=({documentsProps:e,onChange:t,limited:n=!1})=>{let[r,i]=(0,Z.useState)(void 0),[a,o]=(0,Z.useState)([]),s=(0,Z.useMemo)(()=>e?.map(e=>Lr(h,e))??[],[e]),[c,l]=(0,Z.useState)(s);(0,Z.useEffect)(()=>{l(e=>{let t=new Map(e.map(e=>[e.id,e])),n=s.map(e=>{let n=t.get(e.id);if(!n)return e;let r={...n};for(let[t,n]of Object.entries(e))n!==void 0&&(r[t]=n);return r});return(0,s9.default)(e,n)?e:n})},[s]);let u=(0,Z.useMemo)(()=>c.map(e=>({...e,editDocument:()=>i(e.id),onUpdate:t??(()=>{})})),[c,t]),[d,f]=(0,Z.useState)({}),p=[`date`,`amount`,`vat`,`type`,`serial`,`file`],m=Hr({features:yi,data:u,columns:n?a9.filter(e=>e.id&&p.includes(e.id)):a9,onSortingChange:o,onColumnVisibilityChange:f,state:{sorting:a,columnVisibility:d}});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Si,{children:[(0,Q.jsx)(zr,{children:m.getHeaderGroups().map(e=>(0,Q.jsx)(di,{children:e.headers.map(e=>(0,Q.jsx)(ei,{colSpan:e.colSpan,children:e.isPlaceholder?null:Gr(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Q.jsx)(ci,{children:m.getRowModel().rows?.length?m.getRowModel().rows.map(e=>(0,Q.jsx)(di,{"data-state":e.getIsSelected()&&`selected`,children:e.getVisibleCells().map(e=>(0,Q.jsx)(gi,{children:Gr(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,Q.jsx)(di,{children:(0,Q.jsx)(gi,{colSpan:a9.length,className:`h-24 text-center`,children:`No results.`})})})]}),(0,Q.jsx)(P0,{documentId:r,onDone:()=>i(void 0),onChange:()=>t?.()})]})};function l9({documentType:e}){let[{data:t,fetching:n}]=W({query:L,variables:{documentType:e}}),r=t?.recentIssuedDocumentsByType??[];return(0,Q.jsxs)(Mi,{children:[(0,Q.jsx)(Oi,{children:(0,Q.jsx)(Ai,{children:`Recent Documents of the Same Type`})}),(0,Q.jsx)(ki,{children:n?(0,Q.jsx)(`div`,{children:`Loading...`}):(0,Q.jsx)(c9,{documentsProps:r})})]})}var u9=JG(),d9={type:Ve.Invoice,language:Je.English,currency:k.Usd,vatType:we.Default,date:Or(new Date,`yyyy-MM-dd`),rounding:!1,signed:!0,income:[],payment:[]};function f9({initialFormData:e,onDone:t,onClose:n,chargeId:r}){let[i,a]=(0,Z.useState)({...d9,...e}),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),{previewDocument:f,fetching:p}=E2(),{issueDocument:m}=w2(),[h,g]=(0,Z.useState)(!1),_=(0,Z.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]);(0,Z.useEffect)(()=>{d(!0),l(!1)},[i]);let v=(0,Z.useMemo)(()=>JSON.stringify(e||{}),[e]);(0,Z.useEffect)(()=>{a({...d9,...e})},[v]);let y=(0,Z.useCallback)(async()=>{try{let e=await f({input:i});if(!e)throw Error(`No preview data returned`);s(e),l(!0),d(!1)}catch(e){console.error(`Failed to generate preview:`,e)}},[i,f]),b=(0,Z.useCallback)(()=>{t?t(i):g(!0)},[t,i]),x=(0,Z.useCallback)(async e=>{await m({input:i,chargeId:r,...e})},[i,r,m]),S=!c||p||u,C=(0,Z.useMemo)(()=>i.income?.reduce((e,t)=>{let n=t.price*t.quantity,r=n*((t.vatRate||0)/100);return e+n+r},0)||0,[i.income]);return(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 p-4`,children:(0,Q.jsxs)(`div`,{className:`max-w-7xl mx-auto`,children:[(0,Q.jsxs)(`div`,{className:`mb-6`,children:[(0,Q.jsx)(`h1`,{className:`text-3xl font-bold text-gray-900`,children:`Generate Document`}),(0,Q.jsx)(`p`,{className:`text-gray-600 mt-2`,children:`Create and preview your accounting document before issuing`})]}),(0,Q.jsxs)(`div`,{className:`grid lg:grid-cols-2 gap-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(dK,{formData:i,updateFormData:_}),(0,Q.jsx)(Mi,{children:(0,Q.jsxs)(ki,{className:`pt-6`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Q.jsx)(q,{onClick:y,disabled:p||c,variant:`outline`,className:`flex-1 bg-transparent`,children:p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qt,{className:`w-4 h-4 mr-2 animate-spin`}),`Generating...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qi,{className:`w-4 h-4 mr-2`}),`Preview`]})}),(0,Q.jsxs)(q,{onClick:b,disabled:S,className:`flex-1`,children:[(0,Q.jsx)(xa,{className:`w-4 h-4 mr-2`}),t?`Accept Changes`:`Issue Document`]})]}),u&&!p&&(0,Q.jsx)(`p`,{className:`text-sm text-amber-600 bg-amber-50 p-2 rounded mt-3`,children:`Form has been modified. Click Preview to update the document before issuing.`}),C>0&&(0,Q.jsx)(`div`,{className:`mt-4 p-3 bg-blue-50 rounded-lg`,children:(0,Q.jsxs)(`div`,{className:`flex justify-between items-center font-medium text-blue-900`,children:[(0,Q.jsx)(`span`,{children:`Total Document Amount:`}),(0,Q.jsxs)(`span`,{children:[C.toFixed(2),` `,i.currency]})]})})]})})]}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(Mi,{className:`h-fit`,children:[(0,Q.jsx)(Oi,{children:(0,Q.jsx)(Ai,{children:`Document Preview`})}),(0,Q.jsx)(ki,{children:(0,Q.jsx)(`div`,{className:`border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50`,children:p?(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(Qt,{className:`w-8 h-8 animate-spin mx-auto mb-4 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-gray-500`,children:`Generating document preview...`})]}):o?(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(`div`,{className:`bg-white shadow-lg rounded-lg overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`aspect-[8.5/11] bg-white border`,children:(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`text-center p-6`,children:[(0,Q.jsx)(q7,{src:o}),!c&&(0,Q.jsx)(`p`,{className:`text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded`,children:`Preview may be outdated`})]})})})})}):(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(ea,{className:`w-16 h-16 mx-auto mb-4 text-gray-300`}),(0,Q.jsx)(`p`,{className:`text-gray-500 mb-2`,children:`No preview available`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Click Preview to generate document`})]})})})]}),i.client?.id&&(0,Q.jsx)(o9,{businessId:i.client?.id,linkedDocumentIds:i.linkedDocumentIds??[]}),(0,Q.jsx)(l9,{documentType:i.type})]})]}),(0,Q.jsx)(O2,{isOpen:h,onClose:()=>{g(!1),n()},onIssue:x,clientName:i.client?.name,clientEmails:i.client?.emails,documentType:u9.find(e=>e.value===i.type)?.value})]})})}function p9(e){return{address:e.originalBusiness.address??void 0,city:e.originalBusiness.city??void 0,country:e.originalBusiness.country.code,emails:e.emails,id:e.id,name:e.originalBusiness.name,phone:e.originalBusiness.phoneNumber??void 0,taxId:e.originalBusiness.governmentId??void 0,zipCode:e.originalBusiness.zipCode??void 0}}function m9(e,t){let n;e.remarks&&(n=e.remarks,t===Ve.CreditInvoice&&(n=n.replace(au(Ve.Receipt),au(Ve.CreditInvoice))));let{currency:r}=e;return t===Ve.CreditInvoice&&(r=e.income?.[0]?.currency||r),{...e,currency:r,description:e.description||void 0,remarks:n,footer:e.footer||void 0,date:e.date||void 0,dueDate:e.dueDate||void 0,discount:e.discount||void 0,rounding:e.rounding||void 0,signed:e.signed||void 0,maxPayments:e.maxPayments||void 0,client:e.client?p9(Lr(T,e.client)):void 0,income:e.income?.map(e=>({...e,currencyRate:e.currencyRate??void 0,itemId:e.itemId||void 0,vatRate:e.vatRate??void 0})),payment:e.payment?.map(e=>({...e,currencyRate:e.currencyRate||void 0,date:e.date||void 0,bankName:e.bankName||void 0,bankBranch:e.bankBranch||void 0,bankAccount:e.bankAccount||void 0,chequeNum:e.chequeNum||void 0,accountId:e.accountId||void 0,transactionId:e.transactionId||void 0,cardType:e.cardType||void 0,cardNum:e.cardNum||void 0,numPayments:e.numPayments||void 0,firstPayment:e.firstPayment||void 0})),linkedDocumentIds:e.linkedDocumentIds||void 0,linkedPaymentId:e.linkedPaymentId||void 0,type:t||e.type}}function h9({open:e=!1,setOpen:t,tooltip:n,chargeId:r,documentId:i,documentType:a,onDone:o,trigger:s,...c}){let[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>t?e:l,[e,l,t]),f=(0,Z.useCallback)(e=>{t?t(e):u(e)},[t]),[{data:p,fetching:m,error:h},_]=W({query:y,pause:!r||!d,variables:{chargeId:r||``}}),[{data:v,fetching:b,error:x},S]=W({query:g,pause:!i||!d,variables:{documentId:i||``}});(0,Z.useEffect)(()=>{d&&(r&&!p&&!m&&!h?_():i&&!v&&!b&&!x&&S())},[r,p,m,h,_,i,v,b,x,S,d]);let C=(0,Z.useMemo)(()=>{if(p?.newDocumentDraftByCharge)return Lr(N,p.newDocumentDraftByCharge);if(v?.newDocumentDraftByDocument)return Lr(N,v.newDocumentDraftByDocument)},[v,p]),w=(0,Z.useMemo)(()=>{if(C)return m9(C,a);if(`initialFormData`in c&&c.initialFormData)return c.initialFormData},[C,a,c]);return(0,Q.jsxs)(Xt,{open:d,onOpenChange:f,children:[(!t||!!s)&&(0,Q.jsx)(fn,{onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{children:s??(0,Q.jsx)(q,{className:`size-7.5`,variant:`ghost`,children:(0,Q.jsx)(va,{className:`size-5`})})}),(0,Q.jsx)(yr,{children:(0,Q.jsx)(`p`,{children:n||`Issue new document`})})]})}),(0,Q.jsxs)(un,{className:`w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(en,{children:(0,Q.jsx)(_n,{children:`Issue New Document`})}),m||b?(0,Q.jsx)(Qt,{className:`h-10 w-10 animate-spin`}):(0,Q.jsx)(f9,{initialFormData:w,onDone:o?e=>{o(e),f(!1)}:void 0,onClose:()=>f(!1),chargeId:r})]})]})}var g9=({content:e,title:t,opened:n=!1,onClose:r=()=>{},modalSize:i,withCloseButton:a=!1})=>(0,Q.jsx)(TD,{size:i,opened:n,onClose:r,title:t,withCloseButton:a,children:e}),_9=()=>{let[{data:e,fetching:t,error:n},r]=W({query:le});(0,Z.useEffect)(()=>{n&&(console.error(`Error fetching admin businesses: ${n}`),K.error(`Error`,{description:`Unable to fetch admin businesses`}))},[n]);let i=(0,Z.useMemo)(()=>e?.allAdminBusinesses?.slice().sort((e,t)=>e.name.localeCompare(t.name))??[],[e]);return{fetching:t,refresh:()=>r(),adminBusinesses:i,selectableAdminBusinesses:(0,Z.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i])}},v9=`sync-green-invoice-documents`,y9=()=>{let[{fetching:e},t]=H(ee);return{fetching:e,syncGreenInvoiceDocuments:(0,Z.useCallback)(async e=>{let n=`Error syncing documents owned by [${e.ownerId}]`;K.loading(`Syncing Documents`,{id:v9});try{let r=await t(e),i=Ke(r,n,v9);if(i)return K.success(`Success`,{id:v9,description:i.syncGreenInvoiceDocuments.length>0?gK({data:i.syncGreenInvoiceDocuments}):`No new documents found`,duration:i.syncGreenInvoiceDocuments.length>0?1/0:5e3,closeButton:i.syncGreenInvoiceDocuments.length>0}),i.syncGreenInvoiceDocuments}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:v9,description:n,duration:1e5,closeButton:!0})}},[t])}};function b9({opened:e,close:t,setIsLoading:n}){let{selectableAdminBusinesses:r,fetching:i}=_9(),{control:a,handleSubmit:o}=Mr({defaultValues:{ownerId:`6a20aa69-57ff-446e-8d6a-1e96d095e988`}}),{syncGreenInvoiceDocuments:s,fetching:c}=y9();return(0,Z.useEffect)(()=>{n?.(i||c)},[i,c,n]),(0,Q.jsxs)(TD,{opened:e,onClose:t,size:`auto`,centered:!0,children:[(0,Q.jsx)(TD.Title,{children:`Sync Green Invoice Documents`}),(0,Q.jsxs)(TD.Body,{children:[i?(0,Q.jsx)(`div`,{children:`Loading...`}):(0,Q.jsx)(`div`,{}),(0,Q.jsxs)(`form`,{onSubmit:o(e=>{s(e),t()}),children:[(0,Q.jsx)(pr,{name:`ownerId`,control:a,render:({field:e,fieldState:t})=>(0,Q.jsx)(JO,{...e,data:r,value:e.value,disabled:i,label:`Owner:`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message})}),(0,Q.jsx)(`div`,{className:`flex justify-center mt-5 gap-3`,children:(0,Q.jsx)(`button`,{type:`submit`,className:`text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg`,children:`Sync`})})]})]})]})}var x9=(0,Z.createContext)(null),S9={didCatch:!1,error:null},C9=class extends Z.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=S9}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(S9))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&w9(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(S9))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,Z.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Z.createElement)(x9.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function w9(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var T9=`batchUpdateCharges`,E9=()=>{let[{fetching:e},t]=H(ce);return{fetching:e,batchUpdateCharges:(0,Z.useCallback)(async e=>{let n=Array.isArray(e.chargeIds)?e.chargeIds:[e.chargeIds],r=`Error updating charge IDs [${n.join(`, `)}]`,i=`${T9}-${n[0]}`;K.loading(`Updating charge`,{id:i});try{let a=await t(e),o=Ke(a,r,i,`batchUpdateCharges`);if(o)return K.success(`Success`,{id:i,description:`${n.length} charge${n.length>1?`s`:``} updated`}),o.batchUpdateCharges.charges}catch(e){console.error(`${r}: ${e}`),K.error(`Error`,{id:i,description:r,duration:1e5,closeButton:!0})}},[t])}},D9=[{id:`select`,header:({table:e})=>(0,Q.jsx)(D2,{checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&`indeterminate`,onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,Q.jsx)(D2,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`}),enableSorting:!1,enableHiding:!1},{accessorKey:`chargeType`,header:`Type`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.getValue(`chargeType`)})},{accessorKey:`counterpartyName`,header:`Counterparty`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.getValue(`counterpartyName`)})},{accessorKey:`date`,header:`Date`,cell:({row:e})=>{let t=e.getValue(`date`);return(0,Q.jsx)(`div`,{children:t?Or(new Date(t),`yyyy-MM-dd`):`Missing`})}},{accessorKey:`amountRaw`,header:`Amount`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.original.amountFormatted})},{accessorKey:`vatAmountRaw`,header:`VAT Amount`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.original.vatAmountFormatted})},{accessorKey:`description`,header:`Description`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.getValue(`description`)})},{accessorKey:`taxCategoryName`,header:`Tax Category`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.getValue(`taxCategoryName`)})},{accessorKey:`tags`,header:`Tags`,cell:({row:e})=>{let t=e.getValue(`tags`);return!t||!Array.isArray(t)||t.length===0?(0,Q.jsx)(`div`,{children:`No tags`}):(0,Q.jsx)(`div`,{children:t.join(` | `)})}},{accessorKey:`businessTripName`,header:`Business Trip`,cell:({row:e})=>(0,Q.jsx)(`div`,{children:e.getValue(`businessTripName`)})},{accessorKey:`moreInfo`,header:`More Info`,cell:({row:e})=>{let t=e.original.transactions||0,n=e.original.documents||0,r=e.original.miscExpenses||0,i=e.original.ledgerRecords||0;return(0,Q.jsxs)(`div`,{className:`flex flex-col justify-center text-sm`,children:[t>0&&(0,Q.jsxs)(`div`,{children:[`Transactions: `,t]}),n>0&&(0,Q.jsxs)(`div`,{children:[`Documents: `,n]}),r>0&&(0,Q.jsxs)(`div`,{children:[`Misc Expenses: `,r]}),i>0&&(0,Q.jsxs)(`div`,{children:[`Ledger Records: `,i]})]})},enableSorting:!1}];function O9({data:e,tagIds:t,description:n,onOpenChange:r,title:i=`Similar Charges`}){let[a,o]=Z.useState([]),[s,c]=Z.useState({}),l=(0,Z.useMemo)(()=>e.map(e=>Lr(ct,e)),[e]),u=(0,Z.useMemo)(()=>l.map(e=>({id:e.id,chargeType:ql(e.__typename),counterpartyName:e.counterparty?.name,date:e.minEventDate||e.minDebitDate||e.minDocumentsDate||void 0,amountRaw:e.totalAmount?.raw,amountFormatted:e.totalAmount?.formatted,vatAmountRaw:e.vat?.raw,vatAmountFormatted:e.vat?.formatted,description:e.userDescription||void 0,tags:e.tags.map(e=>e.name),taxCategoryName:e.taxCategory?.name,businessTripName:e.__typename===`BusinessTripCharge`?e.businessTrip?.name:void 0,ledgerRecords:e.metadata?.ledgerCount??0,documents:e.metadata?.documentsCount??0,transactions:e.metadata?.transactionsCount??0,miscExpenses:e.metadata?.miscExpensesCount??0}))??[],[l]);(0,Z.useEffect)(()=>{e&&u.length===0&&r(!1)},[e,u.length,r]);let d=Hr({features:yi,data:u,columns:D9,onSortingChange:o,onRowSelectionChange:c,state:{sorting:a,rowSelection:s}}),{batchUpdateCharges:f}=E9(),p=(0,Z.useCallback)(async()=>{let e=d.getSelectedRowModel().rows.map(e=>e.original.id);await f({chargeIds:e,fields:{...t?{tags:t}:{},...n?{userDescription:n}:{}}}),r(!1)},[f,r,d,t,n]);return(0,Z.useEffect)(()=>{e.length===0&&r(!1)},[e.length,r]),e.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(en,{className:`flex flex-row items-center justify-between`,children:[(0,Q.jsx)(_n,{children:i}),(0,Q.jsx)(q,{onClick:p,children:`Approve selected`})]}),(0,Q.jsx)(Mi,{children:(0,Q.jsxs)(Si,{children:[(0,Q.jsx)(zr,{children:d.getHeaderGroups().map(e=>(0,Q.jsx)(di,{children:e.headers.map(e=>(0,Q.jsx)(ei,{children:e.isPlaceholder?null:Gr(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Q.jsx)(ci,{children:d.getRowModel().rows.map(e=>(0,Q.jsx)(di,{"data-state":e.getIsSelected()&&`selected`,children:e.getVisibleCells().map(e=>(0,Q.jsx)(gi,{children:Gr(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})})]}):null}function k9({chargeId:e,tagIds:t,description:n,open:r,onOpenChange:i,onClose:a,showChargesWithExistingSuggestions:o=!1}){let[{data:s,fetching:c},l]=W({pause:!0,query:Qe,variables:{chargeId:e,withMissingTags:!o&&!!t,withMissingDescription:!o&&!!n,tagsDifferentThan:o&&t?t.map(e=>e.id):void 0,descriptionDifferentThan:o?n:void 0}});(0,Z.useEffect)(()=>{r&&(t||n)&&!s&&l()},[r,t,n,l,s]);let u=(0,Z.useCallback)(e=>{i(e),r&&!e&&a?.()},[i,a,r]);(0,Z.useEffect)(()=>{r&&!c&&s?.similarCharges.length===0&&a?.()},[r,c,s,a]);let d=(0,Z.useMemo)(()=>r&&(!!t||!!n)&&s&&s?.similarCharges.length>0,[r,t,n,s]);return(0,Z.useEffect)(()=>{r&&!t&&!n&&a?.()},[r,t,n,a]),(0,Q.jsx)(Xt,{open:d,onOpenChange:u,children:(0,Q.jsx)(un,{className:`overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(C9,{fallback:(0,Q.jsx)(`div`,{children:`Error fetching similar charges`}),children:c?(0,Q.jsx)(Ci,{}):t||n?(0,Q.jsx)(O9,{data:s?.similarCharges??[],tagIds:t,description:n,onOpenChange:u}):null})})})}function A9({businessId:e,tagIds:t,description:n,open:r,onOpenChange:i,onClose:a}){let[{data:o,fetching:s},c]=W({pause:!0,query:ae,variables:{businessId:e,tagsDifferentThan:t?t.map(e=>e.id):void 0,descriptionDifferentThan:n}});(0,Z.useEffect)(()=>{r&&(t||n)&&!o&&c()},[r,t,n,c,o]);let l=(0,Z.useCallback)(e=>{i(e),r&&!e&&a?.()},[i,a,r]),u=(0,Z.useMemo)(()=>r&&(!!t||!!n)&&o&&o?.similarChargesByBusiness.length>0,[r,t,n,o]);return(0,Q.jsx)(Xt,{open:u,onOpenChange:l,children:(0,Q.jsx)(un,{className:`overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(C9,{fallback:(0,Q.jsx)(`div`,{children:`Error fetching similar charges`}),children:s?(0,Q.jsx)(Ci,{}):t||n?(0,Q.jsx)(O9,{data:o?.similarChargesByBusiness??[],tagIds:t,description:n,onOpenChange:l,title:`Similar Charges by Business`}):null})})})}var j9=`uploadDocumentsFromGoogleDrive`,M9=()=>{let[{fetching:e},t]=H(nt);return{uploading:e,uploadDocumentsFromGoogleDrive:(0,Z.useCallback)(async e=>{let n=`Error uploading documents`,r=`${j9}-${e.chargeId}`;K.loading(`Uploading Documents`,{id:r});try{let i=await t(e),a=Ke(i,n,r,`batchUploadDocumentsFromGoogleDrive`);if(a){let e=!1,t=a.batchUploadDocumentsFromGoogleDrive.filter(t=>`message`in t?(console.error(`Error uploading document: ${t.message}`),e=!0,!1):`document`in t).map(({document:e})=>e);return K.success(`Upload Successful`,{id:r,description:t.length>0?gK({data:t}):`No successful document uploads`,duration:t.length>0?1/0:5e3,dismissible:!0,closeButton:!0}),e&&K.error(`Some files failed to upload`,{duration:1e5,closeButton:!0}),t}}catch(e){console.error(`${n}: ${e}`),K.error(`Error`,{id:r,description:n,duration:1/0,closeButton:!0})}},[t])}};function N9({className:e,...t}){return(0,Q.jsx)(qs,{"data-slot":`tabs`,className:s(`flex flex-col gap-2`,e),...t})}function P9({className:e,...t}){return(0,Q.jsx)(Js,{"data-slot":`tabs-list`,className:s(`bg-gray-100 text-gray-500 inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px] dark:bg-gray-800 dark:text-gray-400`,e),...t})}function F9({className:e,...t}){return(0,Q.jsx)(Ys,{"data-slot":`tabs-trigger`,className:s(`data-[state=active]:bg-white dark:data-[state=active]:text-gray-950 focus-visible:border-gray-950 focus-visible:ring-gray-950/50 focus-visible:outline-ring dark:data-[state=active]:border-gray-200 dark:data-[state=active]:bg-gray-200/30 text-gray-950 dark:text-gray-500 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-gray-200 border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 dark:data-[state=active]:bg-gray-950 dark:dark:data-[state=active]:text-gray-50 dark:focus-visible:border-gray-300 dark:focus-visible:ring-gray-300/50 dark:dark:data-[state=active]:border-gray-800 dark:dark:data-[state=active]:bg-gray-800/30 dark:text-gray-50 dark:dark:text-gray-400 dark:border-gray-800`,e),...t})}function I9({className:e,...t}){return(0,Q.jsx)(Xs,{"data-slot":`tabs-content`,className:s(`flex-1 outline-none`,e),...t})}var L9=10485760,R9=br(File).refine(e=>[`application/pdf`,`image/png`,`image/jpeg`,`image/jpg`,`image/svg+xml`,`image/gif`].includes(e.type),{message:`Invalid document file type`}).refine(e=>e.size<=L9,{message:`File size should not exceed 5MB`}),z9=_r({googleDriveUrl:Pr().url({message:`Invalid url`}).includes(`drive.google.com`,{message:`Invalid url: origin must be "drive.google.com"`}).includes(`/folders/`,{message:`Invalid url: is this a folder link?`}).optional(),documents:wr(R9).optional(),method:ii([`local-files`,`google-drive`]),isSensitive:fr().optional()}).superRefine((e,t)=>{e.method===`local-files`&&(e.documents===void 0||e.documents.length===0)&&t.addIssue({code:K0.custom,message:`At least one document is required`}),e.method===`google-drive`&&e.googleDriveUrl===void 0&&t.addIssue({code:K0.custom,message:`The Google Drive URL is required`})});function B9({open:e,onOpenChange:t,chargeId:n,onChange:r}){let[i,a]=(0,Z.useState)(`local-files`),{uploading:o,uploadDocumentsFromGoogleDrive:s}=M9(),{uploading:c,uploadMultipleDocuments:l}=vK(),u=Mr({resolver:Qr(z9),defaultValues:{method:`local-files`,isSensitive:!1}}),d=e=>{u.setValue(`method`,e),e===`google-drive`?(u.clearErrors(`documents`),u.setValue(`documents`,void 0)):(u.clearErrors(`googleDriveUrl`),u.setValue(`googleDriveUrl`,void 0)),a(e)},f=(0,Z.useCallback)(async e=>{let i=Promise.resolve();switch(e.method){case`local-files`:e.documents?i=l({documents:e.documents,chargeId:n,isSensitive:e.isSensitive}):u.setError(`documents`,{message:`At least one document is required`});break;case`google-drive`:e.googleDriveUrl?i=s({sharedFolderUrl:e.googleDriveUrl,chargeId:n,isSensitive:e.isSensitive}):u.setError(`googleDriveUrl`,{message:`The Google Drive URL is required`})}try{await i,r?.(),t(!1)}catch(e){u.setError(`root`,{message:e instanceof Error?e.message:`Failed to upload documents`})}},[n,u,r,t,s,l]),p=(0,Z.useMemo)(()=>o||c,[o,c]);return(0,Q.jsx)(Xt,{open:e,onOpenChange:t,children:(0,Q.jsx)(un,{onClick:e=>e.stopPropagation(),className:`overflow-scroll max-h-screen`,children:(0,Q.jsxs)(C9,{fallback:(0,Q.jsx)(`div`,{children:`Error uploading files`}),children:[(0,Q.jsx)(en,{className:`flex flex-row items-center justify-between`,children:(0,Q.jsx)(_n,{children:`Upload Documents`})}),(0,Q.jsx)(kr,{...u,children:(0,Q.jsxs)(`form`,{onSubmit:u.handleSubmit(f),children:[(0,Q.jsxs)(N9,{value:i,onValueChange:e=>d(e),className:`my-4`,children:[(0,Q.jsxs)(P9,{className:`grid w-full grid-cols-2`,children:[(0,Q.jsx)(F9,{disabled:p,value:`local-files`,children:`Local Files`}),(0,Q.jsx)(F9,{disabled:p,value:`google-drive`,children:`Google Drive`})]}),(0,Q.jsx)(I9,{value:`local-files`,children:(0,Q.jsxs)(Mi,{children:[(0,Q.jsxs)(Oi,{children:[(0,Q.jsx)(Ai,{children:`Local Files`}),(0,Q.jsx)(ji,{children:`Upload documents from your computer`})]}),(0,Q.jsx)(ki,{className:`space-y-2`,children:(0,Q.jsx)(Ar,{control:u.control,name:`documents`,render:({field:{value:e,onChange:t,...n}})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`Files`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...n,required:!0,type:`file`,multiple:!0,accept:`.jpg, .jpeg, .gif, .png, .pdf`,onChange:e=>{t(e.target.files?Object.values(e.target.files):null)}})}),(0,Q.jsx)(mi,{})]})})})]})}),(0,Q.jsx)(I9,{value:`google-drive`,children:(0,Q.jsxs)(Mi,{children:[(0,Q.jsxs)(Oi,{children:[(0,Q.jsx)(Ai,{children:`Google Shared Folder`}),(0,Q.jsx)(ji,{children:`Upload documents from Google Drive shared folder`})]}),(0,Q.jsx)(ki,{className:`space-y-2`,children:(0,Q.jsx)(Ar,{control:u.control,name:`googleDriveUrl`,render:({field:e})=>(0,Q.jsxs)(lr,{children:[(0,Q.jsx)(hr,{children:`URL`}),(0,Q.jsx)(dr,{children:(0,Q.jsx)(Sn,{...e,required:!0,placeholder:`Folder URL`})}),(0,Q.jsx)(mi,{})]})})})]})})]}),(0,Q.jsx)(mi,{}),(0,Q.jsx)(Zt,{children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-row justify-between items-center`,children:[(0,Q.jsx)(Ar,{control:u.control,name:`isSensitive`,render:({field:{value:e,onChange:t,...n}})=>(0,Q.jsx)(xr,{delayDuration:0,children:(0,Q.jsxs)(vr,{children:[(0,Q.jsx)(cr,{asChild:!0,children:(0,Q.jsxs)(lr,{className:`flex flex-row gap-2 items-center`,children:[(0,Q.jsx)(dr,{children:(0,Q.jsx)(D2,{...n,checked:e,onCheckedChange:e=>t(!!e),className:`mt-2`})}),(0,Q.jsx)(hr,{children:`Is sensitive`})]})}),(0,Q.jsx)(yr,{side:`right`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,Q.jsx)(`p`,{children:`Sensitive content will not be processed`}),(0,Q.jsx)(`p`,{children:`by OCR to protect confidential data`})]})})]})})}),(0,Q.jsx)(q,{disabled:p,type:`submit`,children:`Upload`})]})})]})})]})})})}var V9=({className:e,...t})=>(0,Q.jsx)(`nav`,{role:`navigation`,"aria-label":`pagination`,className:s(`mx-auto flex w-full justify-center`,e),...t});V9.displayName=`Pagination`;var H9=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`ul`,{ref:n,className:s(`flex flex-row items-center gap-1`,e),...t}));H9.displayName=`PaginationContent`;var U9=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`li`,{ref:n,className:s(``,e),...t}));U9.displayName=`PaginationItem`;var W9=({className:e,isActive:t,size:n=`icon`,children:r,...i})=>(0,Q.jsx)(q,{"aria-current":t?`page`:void 0,variant:t?`outline`:`ghost`,size:n,className:e,...i,children:r});W9.displayName=`PaginationLink`;var G9=({className:e,...t})=>(0,Q.jsx)(W9,{"aria-label":`Go to previous page`,size:`default`,className:s(`gap-1 pl-2.5`,e),...t,children:(0,Q.jsx)(zi,{className:`h-4 w-4`})});G9.displayName=`PaginationPrevious`;var K9=({className:e,...t})=>(0,Q.jsx)(W9,{"aria-label":`Go to next page`,size:`default`,className:s(`gap-1 pr-2.5`,e),...t,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})});K9.displayName=`PaginationNext`;var q9=({className:e,...t})=>(0,Q.jsxs)(`span`,{"aria-hidden":!0,className:s(`flex h-9 w-9 items-center justify-center`,e),...t,children:[(0,Q.jsx)(Yn,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`More pages`})]});q9.displayName=`PaginationEllipsis`;var J9=(e,t)=>{let n=e-1;if(n<=0)return[];let r=[];return r.push(0),t>2&&r.push(`...`),t>1&&r.push(t-1),t>0&&t<n&&r.push(t),t<n-1&&r.push(t+1),t<n-2&&r.push(`...`),r.push(n),r},Y9=({onChange:e,totalPages:t,currentPageIndex:n,...r})=>{let i=J9(t,n);return i.length?(0,Q.jsx)(V9,{...r,children:(0,Q.jsxs)(H9,{children:[(0,Q.jsx)(U9,{children:(0,Q.jsx)(G9,{disabled:n<1,onClick:()=>e(n-1)})}),i.map((t,r)=>t===`...`?(0,Q.jsx)(U9,{children:(0,Q.jsx)(q9,{})},`ellipsis-${r}`):(0,Q.jsx)(U9,{children:(0,Q.jsx)(W9,{onClick:()=>e(t),isActive:t===n,children:t+1})},`page-${t}`)),(0,Q.jsx)(U9,{children:(0,Q.jsx)(K9,{disabled:n>=t-1,onClick:()=>e(n+1)})})]})}):null};Y9.displayName=`Pagination`;var X9=({cols:e,spacing:t,children:n})=>(0,Q.jsx)(dk,{cols:e,spacing:t,breakpoints:[{maxWidth:980,cols:3,spacing:`md`},{maxWidth:900,cols:2,spacing:`sm`},{maxWidth:755,cols:2,spacing:`sm`},{maxWidth:600,cols:1,spacing:`sm`}],children:n});function Z9(e){switch(e){case`xs`:return`size-8`;case`sm`:return`size-10`;case`md`:return`size-15`;case`lg`:return`size-25`;case`xl`:return`size-40`;default:return`size-10`}}function Q9(e){switch(e){case`xs`:return`text-2xs`;case`sm`:return`text-base`;case`md`:return`text-2xl`;case`lg`:return`text-3xl`;case`xl`:return`text-5xl`;default:return`text-base`}}var $9=({value:e,size:t=`xl`})=>{let n=(e=>{let t=Math.max(0,Math.min(100,e));return`rgb(${Math.round(155*(1-t/100)+100)}, ${Math.round(t/100*155+0)}, 0)`})(e),r=e/100*75;return(0,Q.jsxs)(`div`,{className:`relative `+Z9(t),children:[(0,Q.jsxs)(`svg`,{className:`rotate-[135deg] size-full`,viewBox:`0 0 36 36`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,Q.jsx)(`circle`,{cx:`18`,cy:`18`,r:`16`,fill:`none`,className:`stroke-current text-gray-200 dark:text-neutral-700`,strokeWidth:`1`,strokeDasharray:`75 100`,strokeLinecap:`round`}),(0,Q.jsx)(`circle`,{cx:`18`,cy:`18`,r:`16`,fill:`none`,stroke:n,strokeWidth:`2`,strokeDasharray:`${r} 100`,strokeLinecap:`round`})]}),(0,Q.jsx)(`div`,{className:`absolute top-1/2 start-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center`,children:(0,Q.jsx)(`span`,{className:`font-bold `+Q9(t),style:{color:n},children:e.toFixed(0)})})]})};export{u0 as $,iu as $n,bE as $t,i2 as A,Pd as An,ea as Ar,tj as At,P0 as B,Fu as Bn,Ri as Br,qk as Bt,x2 as C,Bh as Cn,la as Cr,Iz as Ct,u2 as D,tp as Dn,aa as Dr,Dz as Dt,p2 as E,bp as En,oa as Er,Oz as Et,q0 as F,Cd as Fn,Yi as Fr,sA as Ft,w0 as G,wu as Gn,Nk as Gt,j0 as H,Tu as Hn,Hk as Ht,G0 as I,od as In,Ji as Ir,oA as It,b0 as J,su as Jn,JO as Jt,S0 as K,hu as Kn,dk as Kt,H0 as L,Hu as Ln,qi as Lr,tA as Lt,Y0 as M,Od as Mn,Qi as Mr,QA as Mt,K0 as N,Ed as Nn,Zi as Nr,uA as Nt,l2 as O,ff as On,ia as Or,Ez as Ot,J0 as P,Dd as Pn,Xi as Pr,cA as Pt,d0 as Q,ru as Qn,HE as Qt,R0 as R,Bu as Rn,Wi as Rr,Qk as Rt,E2 as S,Hh as Sn,fa as Sr,Lz as St,g2 as T,Qp as Tn,sa as Tr,kz as Tt,A0 as U,Mu as Un,Lk as Ut,N0 as V,Pu as Vn,Kk as Vt,E0 as W,Eu as Wn,Ik as Wt,p0 as X,au as Xn,tO as Xt,v0 as Y,ou as Yn,MO as Yt,f0 as Z,tu as Zn,TD as Zt,l9 as _,Fg as _n,ba as _r,eG as _t,I9 as a,ab as an,ql as ar,YJ as at,q7 as b,Lg as bn,ma as br,zz as bt,A9 as c,nv as cn,$s as cr,SK as ct,b9 as d,f_ as dn,Aa as dr,dK as dt,UT as en,nu as er,l0 as et,_9 as f,Rg as fn,ka as fr,WG as ft,f9 as g,Mg as gn,Sa as gr,xG as gt,m9 as h,yg as hn,wa as hr,SG as ht,N9 as i,gb as in,Yl as ir,kZ as it,$0 as j,kd as jn,$i as jr,$A as jt,c2 as k,rf as kn,ra as kr,wz as kt,k9 as l,X_ as ln,Qs as lr,xK as lt,h9 as m,xg as mn,Ea as mr,jG as mt,Y9 as n,uT as nn,Ql as nr,_1 as nt,P9 as o,Uy as on,fc as or,WJ as ot,g9 as p,bg as pn,Oa as pr,zG as pt,x0 as q,lu as qn,YO as qt,B9 as r,aS as rn,Zl as rr,NZ as rt,F9 as s,dv as sn,tc as sr,wK as st,$9 as t,ST as tn,eu as tr,y1 as tt,C9 as u,L_ as un,Zs as ur,pK as ut,c9 as v,Ng as vn,ya as vr,Hz as vt,b2 as w,om as wn,ca as wr,Pz as wt,D2 as x,Pg as xn,pa as xr,Rz as xt,o9 as y,_g as yn,va as yr,Vz as yt,F0 as z,zu as zn,zi as zr,Jk as zt};