wiki-viewer 2.1.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +2 -0
- package/.next/standalone/.next/build-manifest.json +6 -6
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +14 -0
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js +5 -5
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js +6 -6
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js +7 -6
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/pdf/save/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/pdf/save/route/build-manifest.json +9 -0
- package/.next/standalone/.next/server/app/api/pdf/save/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/pdf/save/route.js +15 -0
- package/.next/standalone/.next/server/app/api/pdf/save/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/pdf/save/route_client-reference-manifest.js +3 -0
- package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route/build-manifest.json +9 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js +15 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route_client-reference-manifest.js +3 -0
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/page/react-loadable-manifest.json +10 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/signin/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/signin/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +2 -0
- package/.next/standalone/.next/server/chunks/0p91_next_dist_esm_build_templates_app-route_0d2jbo5.js +1 -1
- package/.next/standalone/.next/server/chunks/0zjb_server_app_api_system_workspaces_[id]_branch_route_actions_0y4z5lw.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__09t4v4r._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ajw6de._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0m6r9ip._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0stkifk._.js → [root-of-the-server]__0oruwos._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ovhccp._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0n-chxk._.js → [root-of-the-server]__0vxex1w._.js} +3 -3
- package/.next/standalone/.next/server/chunks/_079xuln._.js +1 -1
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_pdf_save_route_actions_12o20jg.js +3 -0
- package/.next/standalone/.next/server/chunks/src_lib_workspaces_ts_0qon40u._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_0s4yb1t._.js → 0~w0_katex_dist_katex_mjs_0ef9kx4._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__10te1ye._.js → [root-of-the-server]__0jerjyj._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_0hpi._s._.js → _0h8pw_0._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{_026lnd.._.js → _0tz4-ka._.js} +4 -4
- package/.next/standalone/.next/server/chunks/ssr/_0v4uz-4._.js +19 -0
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0mtrsi0._.js → node_modules__pnpm_0-xasf1._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0s-cj7c._.js → node_modules__pnpm_01zl9xh._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_05ans~m._.js → node_modules__pnpm_02ipeoh._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0u.uija._.js → node_modules__pnpm_02vec-5._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_04frxp9._.js → node_modules__pnpm_04lfp99._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_05_oahi._.js → node_modules__pnpm_057iess._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0eqjo2f._.js → node_modules__pnpm_076~crc._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0iu44jv._.js → node_modules__pnpm_07sm52w._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0cahog3._.js → node_modules__pnpm_09-~ynq._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-a_zjq._.js → node_modules__pnpm_0b7yz5c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_03rzttw._.js → node_modules__pnpm_0e8cct3._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0f-yazg._.js → node_modules__pnpm_0fpiq-_._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0n_swwn._.js → node_modules__pnpm_0f~p3pg._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0cxanql._.js → node_modules__pnpm_0ic~tgj._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ndyy93._.js → node_modules__pnpm_0ltuml.._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ygzt82._.js → node_modules__pnpm_0m7~7m_._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_02l_1_8._.js → node_modules__pnpm_0ms-p~~._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0m39f~t._.js → node_modules__pnpm_0nm~rx8._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ma-8l.._.js → node_modules__pnpm_0n~4rgy._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_06-2ia.._.js → node_modules__pnpm_0sl7atd._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0jh8q66._.js → node_modules__pnpm_0w3t223._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0tr41-t._.js → node_modules__pnpm_0wrbfuh._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_057-t6m._.js → node_modules__pnpm_0~azz1f._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0wiyn6d._.js → node_modules__pnpm_0~jz5ce._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0e09gmf._.js → node_modules__pnpm_10db3bh._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_086.ow4._.js → node_modules__pnpm_11mk8o4._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0met6sx._.js → node_modules__pnpm_13c9fa3._.js} +2 -2
- package/.next/standalone/.next/server/functions-config-manifest.json +1 -0
- package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
- package/.next/standalone/.next/server/middleware-manifest.json +5 -5
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/0-p6_utxe5a_8.js +1 -0
- package/.next/standalone/.next/static/chunks/04_l8s7dy454_.js +1 -0
- package/.next/standalone/.next/static/chunks/057l2ju6dh43x.js +31 -0
- package/.next/standalone/.next/static/chunks/06eionk6sdadm.css +1 -0
- package/.next/standalone/.next/static/chunks/08mxtht3nlspn.css +5 -0
- package/.next/standalone/.next/static/chunks/0bu-qg3xcusv2.js +17 -0
- package/.next/standalone/.next/static/chunks/0cy32os0684dj.js +113 -0
- package/.next/standalone/.next/static/chunks/0ff5z2ti4cs.2.js +1 -0
- package/.next/standalone/.next/static/chunks/0k31ncl7m_j9q.js +5 -0
- package/.next/standalone/.next/static/chunks/0sshdogvg3twu.js +113 -0
- package/.next/standalone/.next/static/chunks/0~m~l6t.25dxo.js +1 -0
- package/.next/standalone/.next/static/chunks/10~nefki4aqgv.js +5 -0
- package/.next/standalone/.next/static/chunks/14~-bgg0b~4bh.js +1 -0
- package/.next/standalone/.next/static/chunks/{turbopack-12~z-mr7b9b50.js → turbopack-1105gjd__15ti.js} +1 -1
- package/.next/standalone/.next/static/media/altText_add.11l4.nysz0z47.svg +3 -0
- package/.next/standalone/.next/static/media/altText_disclaimer.0-fkoyz3r4.vr.svg +3 -0
- package/.next/standalone/.next/static/media/altText_done.09w1jqvk3ga77.svg +3 -0
- package/.next/standalone/.next/static/media/altText_spinner.011~3weg7vxwh.svg +30 -0
- package/.next/standalone/.next/static/media/altText_warning.0uszsbnztiu38.svg +3 -0
- package/.next/standalone/.next/static/media/comment-closeButton.09x_diuuox8.p.svg +3 -0
- package/.next/standalone/.next/static/media/comment-popup-editButton.0ncym9lg9cwyw.svg +5 -0
- package/.next/standalone/.next/static/media/cursor-editorFreeHighlight.089qa-ugkz~ml.svg +6 -0
- package/.next/standalone/.next/static/media/cursor-editorFreeText.13jy27m_lk2jb.svg +3 -0
- package/.next/standalone/.next/static/media/cursor-editorInk.0w~p4njb_q99n.svg +4 -0
- package/.next/standalone/.next/static/media/cursor-editorTextHighlight.0e14z1tamqi61.svg +8 -0
- package/.next/standalone/.next/static/media/editor-toolbar-delete.03wunzr0m9rov.svg +5 -0
- package/.next/standalone/.next/static/media/editor-toolbar-edit.0hg-w4v6gf5-d.svg +3 -0
- package/.next/standalone/.next/static/media/loading-icon.0gtb0.n871aax.gif +0 -0
- package/.next/standalone/.next/static/media/messageBar_closingButton.15rqkmbgrfbfy.svg +3 -0
- package/.next/standalone/.next/static/media/messageBar_info.17crwltyl6qk5.svg +3 -0
- package/.next/standalone/.next/static/media/messageBar_warning.0zri3991i~s-j.svg +3 -0
- package/.next/standalone/.next/static/media/toolbarButton-editorHighlight.0ni3w.c8~58pj.svg +6 -0
- package/.next/standalone/.next/static/media/toolbarButton-menuArrow.0tx16jlj3l~wi.svg +3 -0
- package/.next/standalone/package.json +2 -1
- package/.next/standalone/public/pdfjs/pdf.worker.min.mjs +28 -0
- package/package.json +2 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0k9mili._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0yxauu6._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/src_app_page_tsx_0ss2.w7._.js +0 -19
- package/.next/standalone/.next/static/chunks/02c9264uigqjd.js +0 -1
- package/.next/standalone/.next/static/chunks/0_p-~rp2hak3c.js +0 -113
- package/.next/standalone/.next/static/chunks/0lrkdb9w.6kl1.js +0 -1
- package/.next/standalone/.next/static/chunks/0ocp.6r7w_saw.js +0 -31
- package/.next/standalone/.next/static/chunks/0oy4xayqkedl5.js +0 -113
- package/.next/standalone/.next/static/chunks/0quh-cfcrp2ib.js +0 -5
- package/.next/standalone/.next/static/chunks/0r0fa52s8puxv.js +0 -17
- package/.next/standalone/.next/static/chunks/0sx~65~lg4mgl.css +0 -5
- package/.next/standalone/.next/static/chunks/139g2hzko-flp.js +0 -1
- package/.next/standalone/.next/static/chunks/14_efa7172tp-.js +0 -1
- /package/.next/standalone/.next/static/{czHazDjTGrE8lFhf8IAtQ → w9MY1r-wlK_u_Hsax3Zde}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{czHazDjTGrE8lFhf8IAtQ → w9MY1r-wlK_u_Hsax3Zde}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{czHazDjTGrE8lFhf8IAtQ → w9MY1r-wlK_u_Hsax3Zde}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,394872,t=>{"use strict";let e,i,s;var n=t.i(44501),r=t.i(101685),a=t.i(412473),o=t.i(605993);let l=(0,o.default)("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);var h=t.i(109680);let d=(0,o.default)("pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);var c=t.i(264917);let u=(0,o.default)("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);var p=t.i(801273),g=t.i(691520),m=t.i(61086),f=t.i(519455),b=t.i(975157),v=t.i(671485),y=t.i(335884),w=t.i(920688);let x={get url(){return`file://${t.P("node_modules/.pnpm/pdfjs-dist@5.4.296/node_modules/pdfjs-dist/build/pdf.mjs")}`}};var A={};A.d=(t,e)=>{for(var i in e)A.o(e,i)&&!A.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},A.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let _="object"==typeof y.default&&y.default+""=="[object process]"&&!y.default.versions.nw&&!(y.default.versions.electron&&y.default.type&&"browser"!==y.default.type),C=[.001,0,0,.001,0,0],S={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},E="pdfjs_internal_editor_",T={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},P={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},M={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},k={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},D={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},I={ERRORS:0,WARNINGS:1,INFOS:5},L={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},R={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},F=I.WARNINGS;function B(t){F>=I.INFOS&&console.info(`Info: ${t}`)}function N(t){F>=I.WARNINGS&&console.warn(`Warning: ${t}`)}function O(t){throw Error(t)}function j(t,e){t||O(e)}function U(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let n=e?URL.parse(t,e):URL.parse(t);return!function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n)?null:n}function z(t,e,i=!1){let s=URL.parse(t);return s?(s.hash=e,s.href):i&&U(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function H(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let $=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class V extends ${constructor(t,e){super(t,"PasswordException"),this.code=e}}class G extends ${constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class W extends ${constructor(t){super(t,"InvalidPDFException")}}class q extends ${constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class X extends ${constructor(t){super(t,"FormatError")}}class K extends ${constructor(t){super(t,"AbortException")}}function Y(t){("object"!=typeof t||t?.length===void 0)&&O("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let n=Math.min(s+8192,e),r=t.subarray(s,n);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function Q(t){"string"!=typeof t&&O("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class J{static get isLittleEndian(){let t;return H(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]))}static get isEvalSupported(){return H(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return H(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return H(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get platform(){let{platform:t,userAgent:e}=navigator;return H(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return H(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let Z=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class tt{static makeHexColor(t,e,i){return`#${Z[t]}${Z[e]}${Z[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){let s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*r+o,t[i+e+1]=h*n+d*a+l}}static applyInverseTransform(t,e){let i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){let s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=s*h+o,g=p,m=s*c+o,f=m,b=a*d+l,v=b,y=a*u+l,w=y;if(0!==n||0!==r){let t=n*h,e=n*c,i=r*d,s=r*u;p+=i,f+=i,m+=s,g+=s,b+=t,w+=t,y+=e,v+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,y,v,w),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,y,v,w)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let i=t[0],s=t[1],n=t[2],r=t[3],a=i**2+s**2,o=n**2+r**2,l=(a+o)/2,h=Math.sqrt(l**2-(a*o-(i*n+s*r)**2));e[0]=Math.sqrt(l+h||1),e[1]=Math.sqrt(l-h||1)}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;let n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static #t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*r)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,n,r,a,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,c),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,i,n,a,e,s,r,o,3*(-t+3*(i-n)+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),l)}}let te=null,ti=null;function ts(t){return te||(te=/([\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,ti=new Map([["ſt","ſt"]])),t.replaceAll(te,(t,e,i)=>e?e.normalize("NFKC"):ti.get(i))}function tn(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),Y(t)}let tr="pdfjs_internal_id_";function ta(t,e,i){return Math.min(Math.max(t,e),i)}function to(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(Y(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class tl{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,n=i.name;if("#text"===n)s=i.value;else{if(!tl.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class th{static setupStorage(t,e,i,s,n){let r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value)for(let e of(t.setAttribute("value",r.value),i.children))e.attributes.value===r.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===r.type&&(r.name=`${r.name}-${s}`),Object.entries(r)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:a&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});let a="richText"!==n,o=t.div;if(o.append(r),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);r.append(t),a&&tl.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,r]];for(;h.length>0;){let[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),r.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&tl.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let td="http://www.w3.org/2000/svg";class tc{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function tu(t,e="text"){if(tw(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(200===n.status||0===n.status){switch(e){case"arraybuffer":case"blob":case"json":i(n.response);return}i(n.responseText);return}s(Error(n.statusText))}},n.send(null)})}class tp{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const m=(t[2]+t[0])/2,f=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(f-t[1])*i+n,u=Math.abs(m-t[0])*i+r,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(m-t[0])*i+n,u=Math.abs(f-t[1])*i+r,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*m-h*i*f,u-l*i*m-d*i*f],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return H(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new tp({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){let i=[t,e];return tt.applyTransform(i,this.transform),i}convertToViewportRectangle(t){let e=[t[0],t[1]];tt.applyTransform(e,this.transform);let i=[t[2],t[3]];return tt.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){let i=[t,e];return tt.applyInverseTransform(i,this.transform),i}}class tg extends ${constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function tm(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function tf(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function tb(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function tv(t,e="document.pdf"){if("string"!=typeof t)return e;if(tm(t))return N('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;let s=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")){if((e=e.split("/").at(-1)).test(/^\.pdf$/i))return e;return t}return e}catch{return t}},n=/\.pdf$/i,r=i.pathname.split("/").at(-1);if(n.test(r))return s(r);if(i.searchParams.size>0){for(let t of Array.from(i.searchParams.values()).reverse())if(n.test(t))return s(t);for(let t of Array.from(i.searchParams.keys()).reverse())if(n.test(t))return s(t)}if(i.hash){let t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class ty{started=Object.create(null);times=[];time(t){t in this.started&&N(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||N(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms
|
|
2
|
+
`);return t.join("")}}function tw(t,e){let i=e?URL.parse(t,e):URL.parse(t);return i?.protocol==="http:"||i?.protocol==="https:"}function tx(t){t.preventDefault()}function tA(t){t.preventDefault(),t.stopPropagation()}class t_{static #i;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#i.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,a+=d):"+"===l&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}}function tC(t,{scale:e=1,rotation:i=0}){let{width:s,height:n}=t.attributes.style;return new tp({viewBox:[0,0,parseInt(s),parseInt(n)],userUnit:1,scale:e,rotation:i})}function tS(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(0xff0000&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(N(`Not a valid color format: "${t}"`),[0,0,0])}function tE(t){let{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function tT(t){let{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function tP(t,e,i=!1,s=!0){if(e instanceof tp){let{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=J.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tM{constructor(){const{pixelRatio:t}=tM;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let r=1/0,a=1/0,o=1/0;(i=tM.capPixels(i,n))>0&&(r=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);let l=Math.min(r,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}let tk=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class tD{static get isDarkMode(){return H(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class tI{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:i}=window.getComputedStyle(t);return t.remove(),H(this,"commentForegroundColor",tS(i))}}function tL(t,e,i,s){let n=255*(1-(s=Math.min(Math.max(s??1,0),1)));return[t=Math.round(t*s+n),e=Math.round(e*s+n),i=Math.round(i*s+n)]}function tR(t,e){let i=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(i,s,n),a=Math.min(i,s,n),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{let t=r-a;switch(e[1]=o<.5?t/(r+a):t/(2-r-a),r){case i:e[0]=((s-n)/t+6*(s<n))*60;break;case s:e[0]=((n-i)/t+2)*60;break;case n:e[0]=((i-s)/t+4)*60}}e[2]=o}function tF(t,e){let i=t[0],s=t[1],n=t[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(i/60%2-1)),o=n-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o}}function tB(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function tN(t,e,i){tF(t,i),i.map(tB);let s=.2126*i[0]+.7152*i[1]+.0722*i[2];tF(e,i),i.map(tB);let n=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}let tO=new Map;function tj(t,e){let i=t[0]+256*t[1]+65536*t[2]+0x1000000*e[0]+0x100000000*e[1]+0x10000000000*e[2],s=tO.get(i);if(s)return s;let n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);tR(t,a);let o=n.subarray(6,9);tR(e,o);let l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),tN(a,o,r)<h){let t,e;for(l?(t=a[2],e=1):(t=0,e=a[2]);e-t>.005;){let i=a[2]=(t+e)/2;l===tN(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return tF(a,r),s=tt.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),tO.set(i,s),s}function tU({html:t,dir:e,className:i},s){let n=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}n.append(i)}else th.render({xfaHtml:t,div:n,intent:"richText"});n.firstChild.classList.add("richText",i),s.append(n)}class tz{#s=null;#n=null;#r;#a=null;#o=null;#l=null;#h=null;#d=null;static #c=null;constructor(t){this.#r=t,tz.#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.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#r._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",tx,{signal:e}),t.addEventListener("pointerdown",tz.#u,{signal:e}));let i=this.#a=document.createElement("div");i.className="buttons",t.append(i);let s=this.#r.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#s}static #u(t){t.stopPropagation()}#p(t){this.#r._focusEventsAllowed=!1,tA(t)}#g(t){this.#r._focusEventsAllowed=!0,tA(t)}#m(t){let e=this.#r._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",tx,{signal:e}),!0)}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown(),this.#l?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",tz.#c[t]),this.#m(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#a.append(i)}get #f(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#m(e),this.#a.append(e,this.#f),this.#o=t}addComment(t,e=null){if(this.#l)return;let i=t.renderForToolbar();if(!i)return;this.#m(i);let s=this.#h=this.#f;e?(this.#a.insertBefore(i,e),this.#a.insertBefore(s,e)):this.#a.append(i,s),this.#l=t,t.toolbar=this}addColorPicker(t){if(this.#n)return;this.#n=t;let e=t.renderButton();this.#m(e),this.#a.append(e,this.#f)}async addEditSignatureButton(t){let e=this.#d=await t.renderEditButton(this.#r);this.#m(e),this.#a.append(e,this.#f)}removeButton(t){"comment"===t&&(this.#l?.removeToolbarCommentButton(),this.#l=null,this.#h?.remove(),this.#h=null)}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}}async addButtonBefore(t,e,i){let s=this.#a.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#d&&(this.#d.title=t)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class tH{#a=null;#s=null;#b;constructor(t){this.#b=t}#v(){let t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#b._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",tx,{signal:e});let i=this.#a=document.createElement("div");return i.className="buttons",t.append(i),this.#b.hasCommentManager()&&this.#y("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#b.commentSelection("floating_button")}),this.#y("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#b.highlightSelection("floating_button")}),t}#w(t,e){let i=0,s=0;for(let n of t){let t=n.y+n.height;if(t<i)continue;let r=n.x+(e?n.width:0);if(t>i){s=r,i=t;continue}e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){let[s,n]=this.#w(e,i),{style:r}=this.#s||=this.#v();t.append(this.#s),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#y(t,e,i,s){let n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);let r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);let a=this.#b._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",tx,{signal:a}),n.addEventListener("click",s,{signal:a})),this.#a.append(n)}}function t$(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tV{#x=0;get id(){return`${E}${this.#x++}`}}class tG{#A=tn();#x=0;#_=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',H(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async #C(t,e){this.#_||=new Map;let i=this.#_.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#A}_${this.#x++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await tu(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tG._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){N(t),i=null}return this.#_.set(t,i),i&&this.#_.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:n}=t;return this.#C(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#C(t,t)}async getFromBlob(t,e){let i=await e;return this.#C(t,i)}async getFromId(t){this.#_||=new Map;let e=this.#_.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#_||=new Map;let i=this.#_.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#A}_${this.#x++}`,refCounter:1,isSvg:!1},this.#_.set(t,i),this.#_.set(i.id,i),i}getSvgUrl(t){let e=this.#_.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#_||=new Map;let e=this.#_.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#A}_`)}}class tW{#S=[];#E=!1;#T;#P=-1;constructor(t=128){this.#T=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#E)return;let o={cmd:t,undo:e,post:i,type:n};if(-1===this.#P){this.#S.length>0&&(this.#S.length=0),this.#P=0,this.#S.push(o);return}if(r&&this.#S[this.#P].type===n){a&&(o.undo=this.#S[this.#P].undo),this.#S[this.#P]=o;return}let l=this.#P+1;l===this.#T?this.#S.splice(0,1):(this.#P=l,l<this.#S.length&&this.#S.splice(l)),this.#S.push(o)}undo(){if(-1===this.#P)return;this.#E=!0;let{undo:t,post:e}=this.#S[this.#P];t(),e?.(),this.#E=!1,this.#P-=1}redo(){if(this.#P<this.#S.length-1){this.#P+=1,this.#E=!0;let{cmd:t,post:e}=this.#S[this.#P];t(),e?.(),this.#E=!1}}hasSomethingToUndo(){return -1!==this.#P}hasSomethingToRedo(){return this.#P<this.#S.length-1}cleanType(t){if(-1!==this.#P){for(let e=this.#P;e>=0;e--)if(this.#S[e].type!==t){this.#S.splice(e+1,this.#P-e),this.#P=e;return}this.#S.length=0,this.#P=-1}}destroy(){this.#S=null}}class tq{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=J.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#M(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#M(e));if(!i)return;let{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;(!a||a(t,e))&&(s.bind(t,...r,e)(),n||tA(e))}}class tX{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,tS(s))}return e.remove(),H(this,"_colors",t)}convert(t){let e=tS(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tX._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?tt.makeHexColor(...e):t}}class tK{#k=new AbortController;#D=null;#I=null;#L=new Map;#R=new Map;#F=null;#B=null;#N=null;#O=new tW;#j=null;#U=null;#z=null;#H=0;#$=new Set;#V=null;#G=null;#W=new Set;_editorUndoBar=null;#q=!1;#X=!1;#K=!1;#Y=null;#Q=null;#J=null;#Z=null;#tt=!1;#te=null;#ti=new tV;#ts=!1;#tn=!1;#tr=!1;#ta=null;#to=null;#tl=null;#th=null;#td=null;#tc=T.NONE;#tu=new Set;#tp=null;#tg=null;#tm=null;#tf=null;#tb=null;#tv={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ty=[0,0];#tw=null;#tx=null;#tA=null;#t_=null;#tC=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tK.prototype,e=t=>t.#tx.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return H(this,"_keyboardManager",new tq([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["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:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tx.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tx.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,a,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#k.signal;this.#tx=t,this.#tA=e,this.#t_=i,this.#F=s,this.#j=n,this.#tg=r,this.#tb=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:f}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),a._on("setpreference",this.onSetPreference.bind(this),{signal:f}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:f}),window.addEventListener("pointerdown",()=>{this.#tn=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#tn=!1},{capture:!0,signal:f}),this.#tS(),this.#tE(),this.#tT(),this.#B=o.annotationStorage,this.#Y=o.filterFactory,this.#tm=l,this.#Z=h||null,this.#q=d,this.#X=c,this.#K=u,this.#td=p||null,this.viewParameters={realScale:tc.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,n?.setSidebarUiManager(this)}destroy(){for(let t of(this.#tC?.resolve(),this.#tC=null,this.#k?.abort(),this.#k=null,this._signal=null,this.#R.values()))t.destroy();this.#R.clear(),this.#L.clear(),this.#W.clear(),this.#th?.clear(),this.#D=null,this.#tu.clear(),this.#O.destroy(),this.#F?.destroy(),this.#j?.destroy(),this.#tg?.destroy(),this.#te?.hide(),this.#te=null,this.#tl?.destroy(),this.#tl=null,this.#I=null,this.#Q&&(clearTimeout(this.#Q),this.#Q=null),this.#tw&&(clearTimeout(this.#tw),this.#tw=null),this._editorUndoBar?.destroy(),this.#tb=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#td}get useNewAltTextFlow(){return this.#X}get useNewAltTextWhenAddingImage(){return this.#K}get hcmFilter(){return H(this,"hcmFilter",this.#tm?this.#Y.addHCMFilter(this.#tm.foreground,this.#tm.background):"none")}get direction(){return H(this,"direction",getComputedStyle(this.#tx).direction)}get _highlightColors(){return H(this,"_highlightColors",this.#Z?new Map(this.#Z.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return H(this,"highlightColors",null);let e=new Map,i=!!this.#tm;for(let[s,n]of t){let t=s.endsWith("_HCM");if(i&&t){e.set(s.replace("_HCM",""),n);continue}i||t||e.set(s,n)}return H(this,"highlightColors",e)}get highlightColorNames(){return H(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#z=t}setMainHighlightColorPicker(t){this.#tl=t}editAltText(t,e=!1){this.#F?.editAltText(this,t,e)}hasCommentManager(){return!!this.#j}editComment(t,e,i,s){this.#j?.showDialog(this,t,e,i,s)}selectComment(t,e){let i=this.#R.get(t),s=i?.getEditorByUID(e);s?.toggleComment(!0,!0)}updateComment(t){this.#j?.updateComment(t.getData())}updatePopupColor(t){this.#j?.updatePopupColor(t)}removeComment(t){this.#j?.removeComments([t.uid])}toggleComment(t,e,i){this.#j?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#j?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#j?.dialogElement||null}async waitForEditorsRendered(t){if(this.#R.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){this.#tg?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#tg}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){"enableNewAltTextWhenAddingImage"===t&&(this.#K=e)}onPageChanging({pageNumber:t}){this.#H=t-1}focusMainContainer(){this.#tx.focus()}findParent(t,e){for(let i of this.#R.values()){let{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#tA.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#W.add(t)}removeShouldRescale(t){this.#W.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*tc.PDF_TO_CSS_UNITS,this.#W))e.onScaleChanging();this.#z?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tP({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tM(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#R.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a}=i,o=i.toString(),l=this.#tP(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();let d=this.#tM(l),c=this.#tc===T.NONE,u=()=>{let i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(T.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}#tk(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tP(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#te||=new tH(this),this.#te.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#B)return null;let e=`${E}${t}`,i=this.#B.getRawValue(e);return i&&this.#B.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#B||this.#B.has(t.id)||this.#B.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#t_;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#tD(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tp&&(this.#te?.hide(),this.#tp=null,this.#tI({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#tp)return;let i=this.#tP(t).closest(".textLayer");if(!i){this.#tp&&(this.#te?.hide(),this.#tp=null,this.#tI({hasSelectedText:!1}));return}if(this.#te?.hide(),this.#tp=e,this.#tI({hasSelectedText:!0}),(this.#tc===T.HIGHLIGHT||this.#tc===T.NONE)&&(this.#tc===T.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#tt=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tc===T.HIGHLIGHT?this.#tM(i):null;if(t?.toggleDrawing(),this.#tn){let e=new AbortController,i=this.combinedSignal(e),s=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tL("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#tL("main_toolbar")}}#tL(t=""){this.#tc===T.HIGHLIGHT?this.highlightSelection(t):this.#q&&this.#tk()}#tS(){document.addEventListener("selectionchange",this.#tD.bind(this),{signal:this._signal})}#tR(){if(this.#J)return;this.#J=new AbortController;let t=this.combinedSignal(this.#J);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#tF(){this.#J?.abort(),this.#J=null}blur(){if(this.isShiftKeyDown=!1,this.#tt&&(this.#tt=!1,this.#tL("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#tu)if(e.div.contains(t)){this.#to=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#to)return;let[t,e]=this.#to;this.#to=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tT(){if(this.#ta)return;this.#ta=new AbortController;let t=this.combinedSignal(this.#ta);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tB(){this.#ta?.abort(),this.#ta=null}#tN(){if(this.#U)return;this.#U=new AbortController;let t=this.combinedSignal(this.#U);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#tO(){this.#U?.abort(),this.#U=null}#tE(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tT(),this.#tN()}removeEditListeners(){this.#tB(),this.#tO()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#G)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#G)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#D?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#tu){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#G)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){N(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tj(e);this.#tU(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){N(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tc===T.NONE||this.isEditorHandlingKeyboard||tK._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#tt&&(this.#tt=!1,this.#tL("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}#tI(t){Object.entries(t).some(([t,e])=>this.#tv[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#tv,t)}),this.#tc===T.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tz([[P.HIGHLIGHT_FREE,!0]]))}#tz(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tR(),this.#tN(),this.#tI({isEditing:this.#tc!==T.NONE,isEmpty:this.#tH(),hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:this.#O.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#tF(),this.#tO(),this.#tI({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#G)for(let e of(this.#G=t,this.#G))this.#tz(e.defaultPropertiesToUpdate)}getId(){return this.#ti.id}get currentLayer(){return this.#R.get(this.#H)}getLayer(t){return this.#R.get(t)}get currentPageIndex(){return this.#H}addLayer(t){this.#R.set(t.pageIndex,t),this.#ts?t.enable():t.disable()}removeLayer(t){this.#R.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,n=!1){if(this.#tc!==t&&(!this.#tC||(await this.#tC.promise,this.#tC))){if(this.#tC=Promise.withResolvers(),this.#z?.commitOrRemove(),this.#tc===T.POPUP&&this.#j?.hideSidebar(),this.#j?.destroyPopup(),this.#tc=t,t===T.NONE){for(let t of(this.setEditingState(!1),this.#t$(),this.#L.values()))t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#tC.resolve();return}for(let t of this.#L.values())t.addStandaloneCommentButton();for(let e of(t===T.SIGNATURE&&await this.#tg?.loadSignatures(),this.setEditingState(!0),await this.#tV(),this.unselectAll(),this.#R.values()))e.updateMode(t);if(t===T.POPUP){this.#I||=await this.#tb.getAnnotationsByType(new Set(this.#G.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#L.values()){let{annotationElementId:s,hasComment:n,deleted:r}=i;s&&t.add(s),n&&!r&&e.push(i.getData())}for(let i of this.#I){let{id:s,popupRef:n,contentsObj:r}=i;n&&r?.str&&!t.has(s)&&!this.#$.has(s)&&e.push(i)}this.#j?.showSidebar(e)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#tC.resolve();return}for(let t of this.#L.values())t.uid===e?(this.setSelected(t),n?t.editComment():s?t.enterInEditMode():t.focus()):t.unselect();this.#tC.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#tc&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#G){switch(t){case P.CREATE:this.currentLayer.addNewEditor(e);return;case P.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tf||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#tu)i.updateParams(t,e);else for(let i of this.#G)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#L.values())i.editorType===t&&i.show(e);(this.#tf?.get(P.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tz([[P.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tr!==t)for(let e of(this.#tr=t,this.#R.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tV(){if(!this.#ts){this.#ts=!0;let t=[];for(let e of this.#R.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#L.values()))e.enable()}}#t$(){if(this.unselectAll(),this.#ts){for(let t of(this.#ts=!1,this.#R.values()))t.disable();for(let t of this.#L.values())t.disable()}}*getEditors(t){for(let e of this.#L.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#L.get(t)}addEditor(t){this.#L.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#Q&&clearTimeout(this.#Q),this.#Q=setTimeout(()=>{this.focusMainContainer(),this.#Q=null},0)),this.#L.delete(t.id),t.annotationElementId&&this.#th?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#$.has(t.annotationElementId)||this.#B?.remove(t.id)}addDeletedAnnotationElement(t){this.#$.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#$.has(t)}removeDeletedAnnotationElement(t){this.#$.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tj(t){let e=this.#R.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#D!==t&&(this.#D=t,t&&this.#tz(t.propertiesToUpdate))}get #tG(){let t=null;for(t of this.#tu);return t}updateUI(t){this.#tG===t&&this.#tz(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tz(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#tu.has(t)){this.#tu.delete(t),t.unselect(),this.#tI({hasSelectedEditor:this.hasSelection});return}this.#tu.add(t),t.select(),this.#tz(t.propertiesToUpdate),this.#tI({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.updateToolbar({mode:t.mode,editId:t.id}),this.#z?.commitOrRemove(),this.#tu))e!==t&&e.unselect();this.#tu.clear(),this.#tu.add(t),t.select(),this.#tz(t.propertiesToUpdate),this.#tI({hasSelectedEditor:!0})}isSelected(t){return this.#tu.has(t)}get firstSelectedEditor(){return this.#tu.values().next().value}unselect(t){t.unselect(),this.#tu.delete(t),this.#tI({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#tu.size}get isEnterHandled(){return 1===this.#tu.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#O.undo(),this.#tI({hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tH()}),this._editorUndoBar?.hide()}redo(){this.#O.redo(),this.#tI({hasSomethingToUndo:!0,hasSomethingToRedo:this.#O.hasSomethingToRedo(),isEmpty:this.#tH()})}addCommands(t){this.#O.add(t),this.#tI({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tH()})}cleanUndoStack(t){this.#O.cleanType(t)}#tH(){if(0===this.#L.size)return!0;if(1===this.#L.size)for(let t of this.#L.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#tu],i=()=>{for(let t of(this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length),e))t.remove()},s=()=>{for(let t of e)this.#tj(t)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#D?.commitOrRemove()}hasSomethingToControl(){return this.#D||this.hasSelection}#tU(t){for(let t of this.#tu)t.unselect();for(let e of(this.#tu.clear(),t))e.isEmpty()||(this.#tu.add(e),e.select());this.#tI({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#tu)t.commit();this.#tU(this.#L.values())}unselectAll(){if(!this.#D||(this.#D.commitOrRemove(),this.#tc===T.NONE)){if(!this.#z?.commitOrRemove()&&this.hasSelection){for(let t of this.#tu)t.unselect();this.#tu.clear(),this.#tI({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ty[0]+=t,this.#ty[1]+=e;let[s,n]=this.#ty,r=[...this.#tu];for(let i of(this.#tw&&clearTimeout(this.#tw),this.#tw=setTimeout(()=>{this.#tw=null,this.#ty[0]=this.#ty[1]=0,this.addCommands({cmd:()=>{for(let t of r)this.#L.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(let t of r)this.#L.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})},1e3),r))i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#V=new Map,this.#tu))this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);let t=this.#V;this.#V=null;let e=!1;for(let[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#L.has(t.id)){let n=this.#R.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(let[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(let i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#tu.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#D===t}getActive(){return this.#D}getMode(){return this.#tc}isEditingMode(){return this.#tc!==T.NONE}get imageManager(){return H(this,"imageManager",new tG)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:n,width:r,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-n)/a,y:1-(t+i-s)/r,width:o/a,height:i/r});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/r,y:1-(e+o-n)/a,width:i/r,height:o/a});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-n)/a,y:(t-s)/r,width:o/a,height:i/r});break;default:e=(t,e,i,o)=>({x:(t-s)/r,y:(e-n)/a,width:i/r,height:o/a})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:n,height:r}of s.getClientRects())0!==n&&0!==r&&o.push(e(t,i,n,r))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#N||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#N?.delete(t)}renderAnnotationElement(t){let e=this.#N?.get(t.data.id);if(!e)return;let i=this.#B.getRawValue(e);!i||(this.#tc!==T.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let s=this.#th?.get(t);s&&(s.setCanvas(e,i),this.#th.delete(t))}addMissingCanvas(t,e){(this.#th||=new Map).set(t,e)}}class tY{#o=null;#tW=!1;#tq=null;#tX=null;#tK=null;#tY=null;#tQ=!1;#tJ=null;#r=null;#tZ=null;#t0=null;#t1=!1;static #t2=null;static _l10n=null;constructor(t){this.#r=t,this.#t1=t._uiManager.useNewAltTextFlow,tY.#t2||=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){tY._l10n??=t}async render(){let t=this.#tq=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#tX=document.createElement("span");t.append(e),this.#t1?(t.classList.add("new"),t.setAttribute("data-l10n-id",tY.#t2.missing),e.setAttribute("data-l10n-id",tY.#t2["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#r._uiManager._signal;t.addEventListener("contextmenu",tx,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#t1&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#t3}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#tQ=!0,s(e))},{signal:i}),await this.#t5(),t}get #t3(){return this.#o&&"added"||null===this.#o&&this.guessedText&&"review"||"missing"}finish(){this.#tq&&(this.#tq.focus({focusVisible:this.#tQ}),this.#tQ=!1)}isEmpty(){return this.#t1?null===this.#o:!this.#o&&!this.#tW}hasData(){return this.#t1?null!==this.#o||!!this.#tZ:this.isEmpty()}get guessedText(){return this.#tZ}async setGuessedText(t){null===this.#o&&(this.#tZ=t,this.#t0=await tY._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#t5())}toggleAltTextBadge(t=!1){if(!this.#t1||this.#o){this.#tJ?.remove(),this.#tJ=null;return}if(!this.#tJ){let t=this.#tJ=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#tJ.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#tZ!==e||(e=this.#t0),{altText:e,decorative:this.#tW,guessedText:this.#tZ,textWithDisclaimer:this.#t0}}get data(){return{altText:this.#o,decorative:this.#tW}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#tZ=i,this.#t0=s),(this.#o!==t||this.#tW!==e)&&(n||(this.#o=t,this.#tW=e),this.#t5())}toggle(t=!1){this.#tq&&(!t&&this.#tY&&(clearTimeout(this.#tY),this.#tY=null),this.#tq.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#t3}})}destroy(){this.#tq?.remove(),this.#tq=null,this.#tX=null,this.#tK=null,this.#tJ?.remove(),this.#tJ=null}async #t5(){let t=this.#tq;if(!t)return;if(this.#t1){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",tY.#t2[this.#t3]),this.#tX?.setAttribute("data-l10n-id",tY.#t2[`${this.#t3}-label`]),!this.#o)return void this.#tK?.remove()}else{if(!this.#o&&!this.#tW){t.classList.remove("done"),this.#tK?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#tK;if(!e){this.#tK=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;let i=this.#r._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#tY),this.#tY=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#tY=setTimeout(()=>{this.#tY=null,this.#tK.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#tY&&(clearTimeout(this.#tY),this.#tY=null),this.#tK?.classList.remove("show")},{signal:i})}this.#tW?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);let i=this.#r.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class tQ{#t4=null;#t6=null;#t8=!1;#r=null;#t9=null;#t7=null;#et=null;#ee=null;#ei=!1;#es=null;constructor(t){this.#r=t}renderForToolbar(){let t=this.#t6=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){let t=this.#t4=document.createElement("button");t.className="annotationCommentButton";let e=this.#r.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#r._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let s=this.#r.commentButtonColor;s&&(i.backgroundColor=s)}return this.#v(t,!0)}focusButton(){setTimeout(()=>{(this.#t4??this.#t6)?.focus()},0)}onUpdatedColor(){if(!this.#t4)return;let t=this.#r.commentButtonColor;t&&(this.#t4.style.backgroundColor=t),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#t4?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#es)return this.#es;if(!this.#t4)return null;let{x:t,y:e,height:i}=this.#t4.getBoundingClientRect(),{x:s,y:n,width:r,height:a}=this.#r.parent.boundingClientRect;return[(t-s)/r,(e+i-n)/a]}set commentPopupPositionInLayer(t){this.#es=t}hasDefaultPopupPosition(){return null===this.#es}removeStandaloneCommentButton(){this.#t4?.remove(),this.#t4=null}removeToolbarCommentButton(){this.#t6?.remove(),this.#t6=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t4&&(this.#t4.classList.toggle("selected",t),this.#t4.ariaExpanded=e)}#v(t,e){if(!this.#r._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));let i=this.#r._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",tx,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#r._focusEventsAllowed=!1,tA(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#r._focusEventsAllowed=!0,tA(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=e=>{e.preventDefault(),t===this.#t6?this.edit():this.#r.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t8=!0,s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#r.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#r.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,s=this.commentPopupPositionInLayer;if(s)[e,i]=s;else{[e,i]=this.#r.commentButtonPosition;let{width:t,height:s,x:n,y:r}=this.#r;e=n+e*t,i=r+i*s}let n=this.#r.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#r._uiManager.editComment(this.#r,r+e*o,a+i*l,{...t,parentDimensions:n})}finish(){this.#t6&&(this.#t6.focus({focusVisible:this.#t8}),this.#t8=!1)}isDeleted(){return this.#ei||""===this.#et}isEmpty(){return null===this.#et}hasBeenEdited(){return this.isDeleted()||this.#et!==this.#t9}serialize(){return this.data}get data(){return{text:this.#et,richText:this.#t7,date:this.#ee,deleted:this.isDeleted()}}set data(t){if(t!==this.#et&&(this.#t7=null),null===t){this.#et="",this.#ei=!0;return}this.#et=t,this.#ee=new Date,this.#ei=!1}setInitialText(t,e=null){this.#t9=t,this.data=t,this.#ee=null,this.#t7=e}shown(){}destroy(){this.#t6?.remove(),this.#t6=null,this.#t4?.remove(),this.#t4=null,this.#et="",this.#t7=null,this.#ee=null,this.#r=null,this.#t8=!1,this.#ei=!1}}class tJ{#tx;#en=!1;#er=null;#ea;#eo;#el;#eh;#ed=null;#ec;#eu=null;#ep;#eg=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#tx=t,this.#er=i,this.#ea=e,this.#eo=s,this.#el=n,this.#eh=r,this.#ep=new AbortController,this.#ec=AbortSignal.any([a,this.#ep.signal]),t.addEventListener("touchstart",this.#em.bind(this),{passive:!1,signal:this.#ec})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/tM.pixelRatio}#em(t){if(this.#ea?.())return;if(1===t.touches.length){if(this.#ed)return;let t=this.#ed=new AbortController,e=AbortSignal.any([this.#ec,t.signal]),i=this.#tx,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ed?.abort(),this.#ed=null)};i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(tA(t),n(t))},s),i.addEventListener("pointerup",n,s),i.addEventListener("pointercancel",n,s);return}if(!this.#eg){this.#eg=new AbortController;let t=AbortSignal.any([this.#ec,this.#eg.signal]),e=this.#tx,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#ef.bind(this),i);let s=this.#eb.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",tA,i),e.addEventListener("pointermove",tA,i),e.addEventListener("pointercancel",tA,i),e.addEventListener("pointerup",tA,i),this.#eo?.()}if(tA(t),2!==t.touches.length||this.#er?.()){this.#eu=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#eu={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#ef(t){if(!this.#eu||2!==t.touches.length)return;tA(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:n}=e,{screenX:r,screenY:a}=i,o=this.#eu,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(r-s,a-n)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#en&&Math.abs(p-u)<=tJ.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,!this.#en){this.#en=!0;return}let g=[(s+r)/2,(n+a)/2];this.#el?.(g,p,u)}#eb(t){t.touches.length>=2||(this.#eg&&(this.#eg.abort(),this.#eg=null,this.#eh?.()),this.#eu&&(tA(t),this.#eu=null,this.#en=!1))}destroy(){this.#ep?.abort(),this.#ep=null,this.#ed?.abort(),this.#ed=null}}class tZ{#ev=null;#ey=null;#o=null;#l=null;#t4=null;#ew=!1;#ex=null;#eA="";#e_=null;#eC=null;#eS=null;#eE=null;#eT=null;#eP="";#eM=!1;#ek=null;#eD=!1;#eI=!1;#eL=!1;#eR=null;#eF=0;#eB=0;#eN=null;#eO=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ej=!1;#eU=tZ._zIndex++;static _borderLineWidth=-1;static _colorManager=new tX;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tZ.prototype._resizeWithKeyboard,e=tK.TRANSLATE_SMALL,i=tK.TRANSLATE_BIG;return H(this,"_resizerKeyboardManager",new tq([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],tZ.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}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 H(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new t0({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(tZ._l10n??=t,tZ._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"}),-1!==tZ._borderLineWidth)return;let i=getComputedStyle(document.documentElement);tZ._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){O("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ej}set _isDraggable(t){this.#ej=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#eU}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#ez(),this.#eE?.remove(),this.#eE=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#eM?this.#eM=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#eH([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#eH(this.parentDimensions,t,e)}translateInPage(t,e){this.#ek||=[this.x,this.y,this.width,this.height],this.#eH(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#ek||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this,[o,l]=this.getBaseTranslation();r+=o,a+=l;let{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#ek&&(this.#ek[0]!==this.x||this.#ek[1]!==this.y)}get _hasBeenResized(){return!!this.#ek&&(this.#ek[2]!==this.width||this.#ek[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tZ,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=ta(n,0,i-a),r=ta(r,0,s-o);break;case 90:n=ta(n,0,i-o),r=ta(r,a,s);break;case 180:n=ta(n,a,i),r=ta(r,o,s);break;case 270:n=ta(n,o,i),r=ta(r,0,s-a)}this.x=n/=i,this.y=r/=s;let[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static #e$(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return tZ.#e$(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tZ.#e$(t,e,360-this.parentRotation)}#eV(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#eG(){if(this.#e_)return;this.#e_=document.createElement("div"),this.#e_.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#e_.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#eW.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tx,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#e_)}#eW(t,e){e.preventDefault();let{isMac:i}=J.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#eC=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#eq.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",tA,{passive:!1,signal:r}),window.addEventListener("contextmenu",tx,{signal:r}),this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#eX()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#eK(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#eX(){if(!this.#eS)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eS;this.#eS=null;let n=this.x,r=this.y,a=this.width,o=this.height;(n!==t||r!==e||a!==i||o!==s)&&this.addCommands({cmd:this.#eK.bind(this,n,r,a,o),undo:this.#eK.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#eq(t,e){let i,s,n,r,a,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=tZ.MIN_SIZE/l,m=tZ.MIN_SIZE/h,f=this.#eV(this.rotation),b=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e],v=this.#eV(360-this.rotation),y=!1,w=!1;switch(t){case"topLeft":y=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":y=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":w=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":y=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":y=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":w=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let x=i(u,p),A=s(u,p),_=b(...A),C=tZ._round(d+_[0]),S=tZ._round(c+_[1]),E=1,T=1;if(e.fromKeyboard)({deltaX:n,deltaY:r}=e);else{let{screenX:t,screenY:i}=e,[s,a]=this.#eC;[n,r]=this.screenToPageTranslation(t-s,i-a),this.#eC[0]=t,this.#eC[1]=i}if([n,r]=(a=n/l,o=r/h,[v[0]*a+v[2]*o,v[1]*a+v[3]*o]),y){let t=Math.hypot(u,p);E=T=Math.max(Math.min(Math.hypot(A[0]-x[0]-n,A[1]-x[1]-r)/t,1/u,1/p),g/u,m/p)}else w?E=ta(Math.abs(A[0]-x[0]-n),g,1)/u:T=ta(Math.abs(A[1]-x[1]-r),m,1)/p;let P=tZ._round(u*E),M=tZ._round(p*T),k=C-(_=b(...s(P,M)))[0],D=S-_[1];this.#ek||=[this.x,this.y,this.width,this.height],this.width=P,this.height=M,this.x=k,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#eI)return this._editToolbar;this._editToolbar=new tz(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,i]of t)await this._editToolbar.addButton(e,i);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.#o?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return!this.#o&&(tY.initialize(tZ._l10n),this.#o=new tY(this),this.#ev&&(this.#o.data=this.#ev,this.#ev=null)),this.#o}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await this.#o?.setGuessedText(t)}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}focusCommentButton(){this.#l?.focusButton()}addCommentButton(){return this.#l||=new tQ(this)}addStandaloneCommentButton(){if(this.#t4){this._uiManager.isEditingMode()&&this.#t4.classList.remove("hidden");return}this.hasComment&&(this.#t4=this.#l.renderForStandalone(),this.div.append(this.#t4))}removeStandaloneCommentButton(){this.#l.removeStandaloneCommentButton(),this.#t4=null}hideStandaloneCommentButton(){this.#t4?.classList.add("hidden")}get comment(){let{data:{richText:t,text:e,date:i,deleted:s}}=this.#l;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#l||=new tQ(this),this.#l.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e||(this.#l||=new tQ(this),this.#l.setInitialText(t,i),!this.annotationElementId))return;let s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#l?.hasBeenEdited()}get hasDeletedComment(){return this.#l?.isDeleted()}get hasComment(){return!!this.#l&&!this.#l.isEmpty()&&!this.#l.isDeleted()}async editComment(t){this.#l||=new tQ(this),this.#l.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#l.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,n=s+i+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[n,e-100,n+180,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#l.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#ew?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#eY();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,n]=this.getInitialTranslation();return this.translate(s,n),t$(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eO||=new tJ({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#eQ.bind(this),onPinching:this.#eJ.bind(this),onPinchEnd:this.#eZ.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#eQ(){this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#eJ(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let n=this.#eV(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),tZ.MIN_SIZE/a/d,tZ.MIN_SIZE/o/c);let u=tZ._round(d*s),p=tZ._round(c*s);if(u===d&&p===c)return;this.#ek||=[l,h,d,c];let g=r(d/2,c/2),m=tZ._round(l+g[0]),f=tZ._round(h+g[1]),b=r(u/2,p/2);this.x=m-b[0],this.y=f-b[1],this.width=u,this.height=p,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#eZ(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#eX()}pointerdown(t){let{isMac:e}=J.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#eM=!0,this._isDraggable)?this.#e0(t):this.#e1(t)}#e1(t){let{isMac:e}=J.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#e0(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#ex=null,this.#eM=!1,this._uiManager.endDragSession()||this.#e1(t),i&&this._onStopDragging()};e&&(this.#eF=t.clientX,this.#eB=t.clientY,this.#ex=t.pointerId,this.#eA=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ex)return void tA(t);let[r,a]=this.screenToPageTranslation(e-this.#eF,s-this.#eB);this.#eF=e,this.#eB=s,this._uiManager.dragSelectedEditors(r,a)},r),window.addEventListener("touchmove",tA,r),window.addEventListener("pointerdown",t=>{t.pointerType===this.#eA&&(this.#eO||t.isPrimary)&&a(t),tA(t)},r));let o=t=>{this.#ex&&this.#ex!==t.pointerId?tA(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#eR&&clearTimeout(this.#eR),this.#eR=setTimeout(()=>{this.#eR=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){let s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-c-h-p+o,d+l+u+a,r-c-h+o];case 90:return[d+h+a,r-c+l+o,d+h+p+a,r-c+l+u+o];case 180:return[d-l-u+a,r-c+h+o,d-l+a,r-c+h+p+o];case 270:return[d-h-p+a,r-c-l-u+o,d-h+a,r-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&tZ._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#l?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:s,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!n,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#eI=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#eI=!1,!0)}isInEditMode(){return this.#eI}shouldGetKeyboardEvents(){return this.#eL}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#eY(){if(this.#eT||!this.div)return;this.#eT=new AbortController;let t=this._uiManager.combinedSignal(this.#eT);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#eY()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#ev=t.accessibilityData,s._isCopy=t.isCopy||!1;let[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#eT?.abort(),this.#eT=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#eR&&(clearTimeout(this.#eR),this.#eR=null),this.#ez(),this.removeEditToolbar(),this.#eN){for(let t of this.#eN.values())clearTimeout(t);this.#eN=null}this.parent=null,this.#eO?.destroy(),this.#eO=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eG(),this.#e_.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,s,n,r]=this.getPDFRect();return[tZ._round(i+(n-i)*t),tZ._round(s+(r-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#l.commentPopupPositionInLayer}set commentPopupPosition(t){this.#l.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#l.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#l.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#l.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#e_.children;if(!this.#ey){this.#ey=Array.from(e);let t=this.#e2.bind(this),i=this.#e3.bind(this),s=this._uiManager._signal;for(let e of this.#ey){let n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#e5.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",tZ._l10nResizer[n])}}let i=this.#ey[0],s=0;for(let t of e){if(t===i)break;s++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#ey.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#e_.append(this.#e_.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#e_.firstChild.before(this.#e_.lastChild);let t=0;for(let i of e){let e=this.#ey[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",tZ._l10nResizer[e])}}this.#e4(0),this.#eL=!0,this.#e_.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#e2(t){tZ._resizerKeyboardManager.exec(this,t)}#e3(t){this.#eL&&t.relatedTarget?.parentNode!==this.#e_&&this.#ez()}#e5(t){this.#eP=this.#eL?t:""}#e4(t){if(this.#ey)for(let e of this.#ey)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#eL&&this.#eq(this.#eP,{deltaX:t,deltaY:e,fromKeyboard:!0})}#ez(){this.#eL=!1,this.#e4(-1),this.#eX()}_stopResizingWithKeyboard(){this.#ez(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar)?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#e_?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#eD}set isEditing(t){this.#eD=t,this.parent&&(t?(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,e=!1){if(e){this.#eN||=new Map;let{action:e}=t,i=this.#eN.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eN.delete(e),0===this.#eN.size&&(this.#eN=null)},tZ._telemetryTimeout),this.#eN.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ew=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ew=!0}updateFakeAnnotationElement(t){if(!this.#eE&&!this.deleted){this.#eE=t.addFakeAnnotation(this);return}if(this.deleted){this.#eE.remove(),this.#eE=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#eE.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class t0 extends tZ{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class t1{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){let n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s),a=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=r[t])&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=r[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=0x1b873593*(a=(a=0xcc9e2d51*a&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let t2=Object.freeze({map:null,hash:"",transfer:void 0});class t3{#e6=!1;#e8=null;#e9=null;#e7=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#e7.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#e7.get(t)}remove(t){let e=this.#e7.get(t);if(void 0!==e&&(e instanceof tZ&&this.#e9.delete(e.annotationElementId),this.#e7.delete(t),0===this.#e7.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(let t of this.#e7.values())if(t instanceof tZ)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#e7.get(t),s=!1;if(void 0!==i)for(let[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#e7.set(t,e);s&&this.#it(),e instanceof tZ&&((this.#e9||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#e7.has(t)}get size(){return this.#e7.size}#it(){this.#e6||(this.#e6=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#e6&&(this.#e6=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new t5(this)}get serializable(){if(0===this.#e7.size)return t2;let t=new Map,e=new t1,i=[],s=Object.create(null),n=!1;for(let[i,r]of this.#e7){let a=r instanceof tZ?r.serialize(!1,s):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:t2}get editorStats(){let t=null,e=new Map,i=0,s=0;for(let n of this.#e7.values()){if(!(n instanceof tZ)){n.popup&&(n.popup.deleted?s+=1:i+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(i+=1);let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(n).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[t,e]of Object.entries(r)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));let s=i.get(e)??0;i.set(e,s+1)}}if((s>0||i>0)&&((t||=Object.create(null)).comments={deleted:s,edited:i}),!t)return null;for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e8=null}updateEditor(t,e){let i=this.#e9?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#e9?.get(t)||null}get modifiedIds(){if(this.#e8)return this.#e8;let t=[];if(this.#e9)for(let e of this.#e9.values())e.serialize()&&t.push(e.annotationElementId);return this.#e8={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#e7.entries()}}class t5 extends t3{#ie;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ie={map:n,hash:i,transfer:s}}get print(){O("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ie}get modifiedIds(){return H(this,"modifiedIds",{ids:new Set,hash:""})}}class t4{#ii=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||this.#ii.has(t.loadedName))){if(j(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:s,style:n}=t,r=new FontFace(e,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ii.add(e),i?.(t)}catch{N(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}O("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw N(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return H(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return H(this,"isSyncFontLoadingSupported",_||J.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(j(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return H(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,n;function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function a(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=r(c=a(c,976,d.length,d),16);for(s=0,n=d.length-3;s<n;s+=4)u=u-0x58585858+r(d,s)|0;s<d.length&&(u=u-0x58585858+r(d+"XXX",s)|0),c=a(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){N("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class t6{#is;constructor(t,e=null,i,s){this.compiledGlyphs=Object.create(null),this.#is=t,this._inspectFont=e,i&&Object.assign(this,i),s&&(this.charProcOperatorList=s)}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){let t;if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${to(this.data)});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){N(`getPathGenerator - ignoring character: "${t}".`)}let n=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}get black(){return this.#is.black}get bold(){return this.#is.bold}get disableFontFace(){return this.#is.disableFontFace??!1}get fontExtraProperties(){return this.#is.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#is.isInvalidPDFjsFont}get isType3Font(){return this.#is.isType3Font}get italic(){return this.#is.italic}get missingFile(){return this.#is.missingFile}get remeasure(){return this.#is.remeasure}get vertical(){return this.#is.vertical}get ascent(){return this.#is.ascent}get defaultWidth(){return this.#is.defaultWidth}get descent(){return this.#is.descent}get bbox(){return this.#is.bbox}get fontMatrix(){return this.#is.fontMatrix}get fallbackName(){return this.#is.fallbackName}get loadedName(){return this.#is.loadedName}get mimetype(){return this.#is.mimetype}get name(){return this.#is.name}get data(){return this.#is.data}clearData(){this.#is.clearData()}get cssFontInfo(){return this.#is.cssFontInfo}get systemFontInfo(){return this.#is.systemFontInfo}get defaultVMetrics(){return this.#is.defaultVMetrics}}function t8(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}let t9=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,t7=(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[s,n,...r]=i;if(!t(s)&&!Number.isInteger(s)||!e(n))return!1;let a=r.length,o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(let t of r)if("number"!=typeof t&&(!o||null!==t))return!1;return!0}).bind(null,t9,t=>"object"==typeof t&&"string"==typeof t?.name);class et{#ir=new Map;#ia=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#ia.then(()=>{for(let[t]of this.#ir)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:n}=i;if(n.aborted)return void N("LoopbackPort - cannot use an `aborted` signal.");let r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#ir.set(e,s)}removeEventListener(t,e){let i=this.#ir.get(e);i?.(),this.#ir.delete(e)}terminate(){for(let[,t]of this.#ir)t?.();this.#ir.clear()}}function ee(){}function ei(t){if(t instanceof K||t instanceof W||t instanceof V||t instanceof q||t instanceof G)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&O('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new K(t.message);case"InvalidPDFException":return new W(t.message);case"PasswordException":return new V(t.message,t.code);case"ResponseException":return new q(t.message,t.status,t.missing);case"UnknownErrorException":return new G(t.message,t.details)}return new G(t.message,t.toString())}class es{#io=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#il.bind(this),{signal:this.#io.signal})}#il({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ih(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(ei(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(e){n.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){n.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:ei(e)})});return}t.streamId?this.#id(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:6,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{j(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:1,streamId:n,reason:ei(t)}),e.promise}},i)}#id(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete r.streamSinks[e])},error(t){j(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:ei(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:ei(t)})})}#ih(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(ei(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(ei(t.reason));break;case 6:if(!a){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||ee).then(function(){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:ei(t)})});break;case 4:if(j(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(j(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#ic(r,e);break;case 5:j(r,"error should have stream controller"),r.controller.error(ei(t.reason)),this.#ic(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(ei(t.reason)),this.#ic(r,e);break;case 1:if(!a)break;let o=ei(t.reason);Promise.try(a.onCancel||ee,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:ei(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #ic(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#io?.abort(),this.#io=null}}class en{#iu=!1;constructor({enableHWA:t=!1}){this.#iu=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#iu})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){O("Abstract method `_createCanvas` called.")}}class er extends en{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class ea{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){O("Abstract method `_fetch` called.")}}class eo extends ea{async _fetch(t){let e=await tu(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Q(e)}}class el{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class eh extends el{#ip;#ig;#im;#ib;#iv;#iy;#x=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ib=t,this.#iv=e}get #_(){return this.#ig||=new Map}get #iw(){return this.#iy||=new Map}get #ix(){if(!this.#im){let t=this.#iv.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let i=this.#iv.createElementNS(td,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#im=this.#iv.createElementNS(td,"defs"),t.append(i),i.append(this.#im),this.#iv.body.append(t)}return this.#im}#iA(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,n=Array(256),r=Array(256),a=Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#i_(t){if(void 0===this.#ip){this.#ip="";let t=this.#iv.URL;t!==this.#iv.baseURI&&(tm(t)?N('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ip=z(t,""))}return`url(${this.#ip}#${t})`}addFilter(t){if(!t)return"none";let e=this.#_.get(t);if(e)return e;let[i,s,n]=this.#iA(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#_.get(r))return this.#_.set(t,e),e;let a=`g_${this.#ib}_transfer_map_${this.#x++}`,o=this.#i_(a);this.#_.set(t,o),this.#_.set(r,o);let l=this.#iC(a);return this.#iS(i,s,n,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",n=this.#iw.get(s);if(n?.key===i||(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#iw.set(s,n)),!t||!e))return n.url;let r=this.#iE(t);t=tt.makeHexColor(...r);let a=this.#iE(e);if(e=tt.makeHexColor(...a),this.#ix.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#ib}_hcm_filter`,d=n.filter=this.#iC(h);this.#iS(l,l,l,d),this.#iT(d);let c=(t,e)=>{let i=r[t]/255,s=a[t]/255,n=Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#iS(c(0,5),c(1,5),c(2,5),d),n.url=this.#i_(h),n.url}addAlphaFilter(t){let e=this.#_.get(t);if(e)return e;let[i]=this.#iA([t]),s=`alpha_${i}`;if(e=this.#_.get(s))return this.#_.set(t,e),e;let n=`g_${this.#ib}_alpha_map_${this.#x++}`,r=this.#i_(n);this.#_.set(t,r),this.#_.set(s,r);let a=this.#iC(n);return this.#iP(i,a),r}addLuminosityFilter(t){let e,i,s=this.#_.get(t||"luminosity");if(s)return s;if(t?([e]=this.#iA([t]),i=`luminosity_${e}`):i="luminosity",s=this.#_.get(i))return this.#_.set(t,s),s;let n=`g_${this.#ib}_luminosity_map_${this.#x++}`,r=this.#i_(n);this.#_.set(t,r),this.#_.set(i,r);let a=this.#iC(n);return this.#iM(a),t&&this.#iP(e,a),r}addHighlightHCMFilter(t,e,i,s,n){let r=`${e}-${i}-${s}-${n}`,a=this.#iw.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#iw.set(t,a)),!e||!i))return a.url;let[o,l]=[e,i].map(this.#iE.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#iE.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#ix.style.color="";let p=(t,e,i)=>{let s=Array(256),n=(d-h)/i,r=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ib}_hcm_${t}_filter`,m=a.filter=this.#iC(g);return this.#iT(m),this.#iS(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),a.url=this.#i_(g),a.url}destroy(t=!1){t&&this.#iy?.size||(this.#im?.parentNode.parentNode.remove(),this.#im=null,this.#ig?.clear(),this.#ig=null,this.#iy?.clear(),this.#iy=null,this.#x=0)}#iM(t){let e=this.#iv.createElementNS(td,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#iT(t){let e=this.#iv.createElementNS(td,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#iC(t){let e=this.#iv.createElementNS(td,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#ix.append(e),e}#ik(t,e,i){let s=this.#iv.createElementNS(td,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#iS(t,e,i,s){let n=this.#iv.createElementNS(td,"feComponentTransfer");s.append(n),this.#ik(n,"feFuncR",t),this.#ik(n,"feFuncG",e),this.#ik(n,"feFuncB",i)}#iP(t,e){let i=this.#iv.createElementNS(td,"feComponentTransfer");e.append(i),this.#ik(i,"feFuncA",t)}#iE(t){return this.#ix.style.color=t,tS(getComputedStyle(this.#ix).getPropertyValue("color"))}}class ed{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}async _fetch(t){O("Abstract method `_fetch` called.")}}class ec extends ed{async _fetch(t){return new Uint8Array(await tu(t,"arraybuffer"))}}class eu{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw Error("Wasm filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){O("Abstract method `_fetch` called.")}}class ep extends eu{async _fetch(t){return new Uint8Array(await tu(t,"arraybuffer"))}}async function eg(t){let e=y.default.getBuiltinModule("fs");return new Uint8Array(await e.promises.readFile(t))}_&&N("Please use the `legacy` build in Node.js environments.");class em extends el{}class ef extends en{_createCanvas(t,e){return y.default.getBuiltinModule("module").createRequire(x.url)("@napi-rs/canvas").createCanvas(t,e)}}class eb extends ea{async _fetch(t){return eg(t)}}class ev extends ed{async _fetch(t){return eg(t)}}class ey extends eu{async _fetch(t){return eg(t)}}let ew="__forcedDependency",{floor:ex,ceil:eA}=Math;function e_(t,e,i,s,n,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],n),t[4*e+3]=Math.max(t[4*e+3],r)}let eC=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class eS{#iD;#iI;constructor(t,e){this.#iD=t,this.#iI=e}get length(){return this.#iD.length}isEmpty(t){return this.#iD[t]===eC}minX(t){return this.#iI[4*t+0]/256}minY(t){return this.#iI[4*t+1]/256}maxX(t){return(this.#iI[4*t+2]+1)/256}maxY(t){return(this.#iI[4*t+3]+1)/256}}let eE=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class eT{#iL={__proto__:null};#iR={__proto__:null,transform:[],moveText:[],sameLineText:[],[ew]:[]};#iF=new Map;#iB=[];#iN=[];#iO=[[1,0,0,1,0,0]];#ij=[-1/0,-1/0,1/0,1/0];#iU=new Float64Array([1/0,1/0,-1/0,-1/0]);#iz=-1;#iH=new Set;#i$=new Map;#iV=new Map;#iG;#iW;#iq;#iD;#iX;constructor(t,e,i=!1){this.#iG=t.width,this.#iW=t.height,this.#iK(e),i&&(this.#iX=new Map)}growOperationsCount(t){t>=this.#iD.length&&this.#iK(t,this.#iD)}#iK(t,e){let i=new ArrayBuffer(4*t);this.#iq=new Uint8ClampedArray(i),this.#iD=new Uint32Array(i),e&&e.length>0?(this.#iD.set(e),this.#iD.fill(eC,e.length)):this.#iD.fill(eC)}save(t){return this.#iL={__proto__:this.#iL},this.#iR={__proto__:this.#iR,transform:{__proto__:this.#iR.transform},moveText:{__proto__:this.#iR.moveText},sameLineText:{__proto__:this.#iR.sameLineText},[ew]:{__proto__:this.#iR[ew]}},this.#ij={__proto__:this.#ij},this.#iB.push(t),this}restore(t){let e=Object.getPrototypeOf(this.#iL);if(null===e)return this;this.#iL=e,this.#iR=Object.getPrototypeOf(this.#iR),this.#ij=Object.getPrototypeOf(this.#ij);let i=this.#iB.pop();return void 0!==i&&(eE(this.#iX,t)?.dependencies.add(i),this.#iD[t]=this.#iD[i]),this}recordOpenMarker(t){return this.#iB.push(t),this}getOpenMarker(){return 0===this.#iB.length?null:this.#iB.at(-1)}recordCloseMarker(t){let e=this.#iB.pop();return void 0!==e&&(eE(this.#iX,t)?.dependencies.add(e),this.#iD[t]=this.#iD[e]),this}beginMarkedContent(t){return this.#iN.push(t),this}endMarkedContent(t){let e=this.#iN.pop();return void 0!==e&&(eE(this.#iX,t)?.dependencies.add(e),this.#iD[t]=this.#iD[e]),this}pushBaseTransform(t){return this.#iO.push(tt.multiplyByDOMMatrix(this.#iO.at(-1),t.getTransform())),this}popBaseTransform(){return this.#iO.length>1&&this.#iO.pop(),this}recordSimpleData(t,e){return this.#iL[t]=e,this}recordIncrementalData(t,e){return this.#iR[t].push(e),this}resetIncrementalData(t,e){return this.#iR[t].length=0,this}recordNamedData(t,e){return this.#iF.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#iL[t]=this.#iF.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ew,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#iL&&this.recordFutureForcedDependency(e,this.#iL[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#iH)this.recordFutureForcedDependency(ew,t);return this}resetBBox(t){return this.#iz!==t&&(this.#iz=t,this.#iU[0]=1/0,this.#iU[1]=1/0,this.#iU[2]=-1/0,this.#iU[3]=-1/0),this}recordClipBox(t,e,i,s,n,r){let a=tt.multiplyByDOMMatrix(this.#iO.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];tt.axialAlignedBoundingBox([i,n,s,r],a,o);let l=tt.intersect(this.#ij,o);return l?(this.#ij[0]=l[0],this.#ij[1]=l[1],this.#ij[2]=l[2],this.#ij[3]=l[3]):(this.#ij[0]=this.#ij[1]=1/0,this.#ij[2]=this.#ij[3]=-1/0),this}recordBBox(t,e,i,s,n,r){let a=this.#ij;if(a[0]===1/0)return this;let o=tt.multiplyByDOMMatrix(this.#iO.at(-1),e.getTransform());if(a[0]===-1/0)return tt.axialAlignedBoundingBox([i,n,s,r],o,this.#iU),this;let l=[1/0,1/0,-1/0,-1/0];return tt.axialAlignedBoundingBox([i,n,s,r],o,l),this.#iU[0]=Math.min(this.#iU[0],Math.max(l[0],a[0])),this.#iU[1]=Math.min(this.#iU[1],Math.max(l[1],a[1])),this.#iU[2]=Math.max(this.#iU[2],Math.min(l[2],a[2])),this.#iU[3]=Math.max(this.#iU[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,a){let o,l,h=i.bbox;if(h&&!1!==(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#iV.get(i))&&(l=[0,0,0,0],tt.axialAlignedBoundingBox(h,i.fontMatrix,l),(1!==s||0!==n||0!==r)&&tt.scaleMinMax([s,0,0,-s,n,r],l),o))return this.recordBBox(t,e,l[0],l[2],l[1],l[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return h&&l&&void 0===o&&(o=l[0]<=n-d.actualBoundingBoxLeft&&l[2]>=n+d.actualBoundingBoxRight&&l[1]<=r-d.actualBoundingBoxAscent&&l[3]>=r+d.actualBoundingBoxDescent,this.#iV.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,n-d.actualBoundingBoxLeft,n+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#iU[0]=Math.max(0,this.#ij[0]),this.#iU[1]=Math.max(0,this.#ij[1]),this.#iU[2]=Math.min(this.#iG,this.#ij[2]),this.#iU[3]=Math.min(this.#iW,this.#ij[3]),this}getSimpleIndex(t){return this.#iL[t]}recordDependencies(t,e){let i=this.#iH,s=this.#iL,n=this.#iR;for(let t of e)t in this.#iL?i.add(s[t]):t in n&&n[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#iF.has(e)&&this.#iH.add(this.#iF.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ew]),this.#iX){let e=eE(this.#iX,t),{dependencies:i}=e;this.#iH.forEach(i.add,i),this.#iB.forEach(i.add,i),this.#iN.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#iz===t){let i=ex(256*this.#iU[0]/this.#iG),s=ex(256*this.#iU[1]/this.#iW),n=eA(256*this.#iU[2]/this.#iG),r=eA(256*this.#iU[3]/this.#iW);for(let e of(e_(this.#iq,t,i,s,n,r),this.#iH))e!==t&&e_(this.#iq,e,i,s,n,r);for(let e of this.#iB)e!==t&&e_(this.#iq,e,i,s,n,r);for(let e of this.#iN)e!==t&&e_(this.#iq,e,i,s,n,r);e||(this.#iH.clear(),this.#iz=-1)}return this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#iH);for(let s of(this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t),i))this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#iz===t&&(this.#iz=-1,this.#ij[0]=Math.max(this.#ij[0],this.#iU[0]),this.#ij[1]=Math.max(this.#ij[1],this.#iU[1]),this.#ij[2]=Math.min(this.#ij[2],this.#iU[2]),this.#ij[3]=Math.min(this.#ij[3],this.#iU[3]),e||this.#iH.clear()),this}_takePendingDependencies(){let t=this.#iH;return this.#iH=new Set,t}_extractOperation(t){let e=this.#i$.get(t);return this.#i$.delete(t),e}_pushPendingDependencies(t){for(let e of t)this.#iH.add(e)}take(){return this.#iV.clear(),new eS(this.#iD,this.#iq)}takeDebugMetadata(){return this.#iX}}class eP{#iY;#iQ;#iJ;#iZ=0;#i0=0;constructor(t,e,i){if(t instanceof eP&&!!i===t.#iJ)return t;this.#iY=t,this.#iQ=e,this.#iJ=!!i}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#i0++,this.#iY.save(this.#iQ),this}restore(t){return this.#i0>0&&(this.#iY.restore(this.#iQ),this.#i0--),this}recordOpenMarker(t){return this.#iZ++,this}getOpenMarker(){return this.#iZ>0?this.#iQ:this.#iY.getOpenMarker()}recordCloseMarker(t){return this.#iZ--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#iY.pushBaseTransform(t),this}popBaseTransform(){return this.#iY.popBaseTransform(),this}recordSimpleData(t,e){return this.#iY.recordSimpleData(t,this.#iQ),this}recordIncrementalData(t,e){return this.#iY.recordIncrementalData(t,this.#iQ),this}resetIncrementalData(t,e){return this.#iY.resetIncrementalData(t,this.#iQ),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#iY.recordSimpleDataFromNamed(t,e,this.#iQ),this}recordFutureForcedDependency(t,e){return this.#iY.recordFutureForcedDependency(t,this.#iQ),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#iY.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#iY.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#iJ||this.#iY.resetBBox(this.#iQ),this}recordClipBox(t,e,i,s,n,r){return this.#iJ||this.#iY.recordClipBox(this.#iQ,e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return this.#iJ||this.#iY.recordBBox(this.#iQ,e,i,s,n,r),this}recordCharacterBBox(t,e,i,s,n,r,a){return this.#iJ||this.#iY.recordCharacterBBox(this.#iQ,e,i,s,n,r,a),this}recordFullPageBBox(t){return this.#iJ||this.#iY.recordFullPageBBox(this.#iQ),this}getSimpleIndex(t){return this.#iY.getSimpleIndex(t)}recordDependencies(t,e){return this.#iY.recordDependencies(this.#iQ,e),this}recordNamedDependency(t,e){return this.#iY.recordNamedDependency(this.#iQ,e),this}recordOperation(t){return this.#iY.recordOperation(this.#iQ,!0),this}recordShowTextOperation(t){return this.#iY.recordShowTextOperation(this.#iQ,!0),this}bboxToClipBoxDropOperation(t){return this.#iJ||this.#iY.bboxToClipBoxDropOperation(this.#iQ,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}let eM=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],ek=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],eD=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],eI=["filter","fillColor","fillAlpha"],eL=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],eR=["transform"],eF=["transform","fillColor"],eB="Fill",eN="Stroke",eO="Shading";function ej(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class eU{isModifyingCurrentTransform(){return!1}getPattern(){O("Abstract method `getPattern` called.")}}class ez extends eU{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;for(let i of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let n;if(s===eN||s===eB){let r=e.current.getClippedPathBoundingBox(s,tE(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=tt.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),ej(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);n.setTransform(d)}else ej(t,this._bbox),n=this._createGradient(t);return n}}function eH(t,e,i,s,n,r,a,o){let l,h,d,c,u,p,g,m,f,b=e.coords,v=e.colors,y=t.data,w=4*t.width;b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=a,a=l),b[s+1]>b[n+1]&&(l=s,s=n,n=l,l=a,a=o,o=l),b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=a,a=l);let x=(b[i]+e.offsetX)*e.scaleX,A=(b[i+1]+e.offsetY)*e.scaleY,_=(b[s]+e.offsetX)*e.scaleX,C=(b[s+1]+e.offsetY)*e.scaleY,S=(b[n]+e.offsetX)*e.scaleX,E=(b[n+1]+e.offsetY)*e.scaleY;if(A>=E)return;let T=v[r],P=v[r+1],M=v[r+2],k=v[a],D=v[a+1],I=v[a+2],L=v[o],R=v[o+1],F=v[o+2],B=Math.round(A),N=Math.round(E);for(let t=B;t<=N;t++){let e;if(t<C){let e=t<A?0:(A-t)/(A-C);h=x-(x-_)*e,d=T-(T-k)*e,c=P-(P-D)*e,u=M-(M-I)*e}else{let e;h=_-(_-S)*(e=t>E?1:C===E?0:(C-t)/(C-E)),d=k-(k-L)*e,c=D-(D-R)*e,u=I-(I-F)*e}p=x-(x-S)*(e=t<A?0:t>E?1:(A-t)/(A-E)),g=T-(T-L)*e,m=P-(P-R)*e,f=M-(M-F)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),n=w*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),y[n++]=d-(d-g)*e|0,y[n++]=c-(c-m)*e|0,y[n++]=u-(u-f)*e|0,y[n++]=255}}class e$ extends eU{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){let t=f.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(let t of this._figures)!function(t,e,i){let s,n,r=e.coords,a=e.colors;switch(e.type){case"lattice":let o=e.verticesPerRow,l=Math.floor(r.length/o)-1,h=o-1;for(s=0;s<l;s++){let e=s*o;for(let s=0;s<h;s++,e++)eH(t,i,r[e],r[e+1],r[e+o],a[e],a[e+1],a[e+o]),eH(t,i,r[e+o+1],r[e+1],r[e+o],a[e+o+1],a[e+1],a[e+o])}break;case"triangles":for(s=0,n=r.length;s<n;s+=3)eH(t,i,r[s],r[s+1],r[s+2],a[s],a[s+1],a[s+2]);break;default:throw Error("illegal figure")}}(f,t,c);return m.putImageData(f,2,2),{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){ej(t,this._bbox);let n=new Float32Array(2);if(s===eO)tt.singularValueDecompose2dScale(tE(t),n);else if(this.matrix){tt.singularValueDecompose2dScale(this.matrix,n);let[t,i]=n;tt.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else tt.singularValueDecompose2dScale(e.baseTransform,n);let r=this._createMeshCanvas(n,s===eO?null:this._background,e.cachedCanvases);return s!==eO&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class eV extends eU{getPattern(){return"hotpink"}}class eG{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t,e){let{bbox:i,operatorList:s,paintType:n,tilingType:r,color:a,canvasGraphicsFactory:o}=this,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),B("TilingType: "+r);let d=i[0],c=i[1],u=i[2],p=i[3],g=u-d,m=p-c,f=new Float32Array(2);tt.singularValueDecompose2dScale(this.matrix,f);let[b,v]=f;tt.singularValueDecompose2dScale(this.baseTransform,f);let y=b*f[0],w=v*f[1],x=g,A=m,_=!1,C=!1,S=Math.ceil(h*w),E=Math.ceil(m*w);Math.ceil(l*y)>=Math.ceil(g*y)?x=l:_=!0,S>=E?A=h:C=!0;let T=this.getSizeAndScale(x,this.ctx.canvas.width,y),P=this.getSizeAndScale(A,this.ctx.canvas.height,w),M=t.cachedCanvases.getCanvas("pattern",T.size,P.size),k=M.context,D=o.createCanvasGraphics(k,e);if(D.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(D,n,a),k.translate(-T.scale*d,-P.scale*c),D.transform(0,T.scale,0,0,P.scale,0,0),k.save(),D.dependencyTracker?.save(),this.clipBbox(D,d,c,u,p),D.baseTransform=tE(D.ctx),D.executeOperatorList(s),D.endDrawing(),D.dependencyTracker?.restore(),k.restore(),_||C){let e=M.canvas;_&&(x=l),C&&(A=h);let i=this.getSizeAndScale(x,this.ctx.canvas.width,y),s=this.getSizeAndScale(A,this.ctx.canvas.height,w),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),o=a.context,u=_?Math.floor(g/l):0,p=C?Math.floor(m/h):0;for(let t=0;t<=u;t++)for(let i=0;i<=p;i++)o.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:d,offsetY:c}}return{canvas:M.canvas,scaleX:T.scale,scaleY:P.scale,offsetX:d,offsetY:c}}getSizeAndScale(t,e,i){let s=Math.max(eG.MAX_PATTERN_SIZE,e),n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){let r=s-e,a=n-i;t.ctx.rect(e,i,r,a),tt.axialAlignedBoundingBox([e,i,s,n],tE(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,n=t.current;switch(e){case 1:let{fillStyle:r,strokeStyle:a}=this.ctx;s.fillStyle=n.fillColor=r,s.strokeStyle=n.strokeColor=a;break;case 2:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new X(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,n){let r=i;s!==eO&&(r=tt.transform(r,e.baseTransform),this.matrix&&(r=tt.transform(r,this.matrix)));let a=this.createPatternCanvas(e,n),o=new DOMMatrix(r);o=(o=o.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}}let eW=new DOMMatrix,eq=new Float32Array(2),eX=new Float32Array([1/0,1/0,-1/0,-1/0]);class eK{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function eY(t,e,i,s,n,r,a,o,l,h){let[d,c,u,p,g,m]=tE(t);if(0===c&&0===u){let f=Math.round(a*d+g),b=Math.round(o*p+m),v=Math.abs(Math.round((a+l)*d+g)-f)||1,y=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,n,r,0,0,v,y),t.setTransform(d,c,u,p,g,m),[v,y]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(a*c+m),v=Math.abs(Math.round((o+h)*u+g)-f)||1,y=Math.abs(Math.round((a+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,n,r,0,0,y,v),t.setTransform(d,c,u,p,g,m),[y,v]}return t.drawImage(e,i,s,n,r,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class eQ{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=C;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,i){i?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=eX.slice()}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=eB,e=null){let i=this.minMax.slice();if(t===eN){e||O("Stroke bounding box must include transform."),tt.singularValueDecompose2dScale(e,eq);let t=eq[0]*this.lineWidth/2,s=eq[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){let t=tt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(eX,0)}getClippedPathBoundingBox(t=eB,e=null){return tt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function eJ(t,e){let i,s,n,r;if(e instanceof ImageData)return void t.putImageData(e,0,0);let a=e.height,o=e.width,l=a%16,h=(a-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,p,g=e.data,m=c.data;if(e.kind===k.GRAYSCALE_1BPP){let e=g.byteLength,r=new Uint32Array(m.buffer,0,m.byteLength>>2),a=r.length,f=o+7>>3,b=J.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(s=0,n=i<h?16:l,p=0;s<n;s++){let t=e-u,i=0,s=t>f?o:8*t-7,n=-8&s,a=0,l=0;for(;i<n;i+=8)l=g[u++],r[p++]=128&l?0xffffffff:b,r[p++]=64&l?0xffffffff:b,r[p++]=32&l?0xffffffff:b,r[p++]=16&l?0xffffffff:b,r[p++]=8&l?0xffffffff:b,r[p++]=4&l?0xffffffff:b,r[p++]=2&l?0xffffffff:b,r[p++]=1&l?0xffffffff:b;for(;i<s;i++)0===a&&(l=g[u++],a=128),r[p++]=l&a?0xffffffff:b,a>>=1}for(;p<a;)r[p++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===k.RGBA_32BPP){for(i=0,s=0,r=16*o*4;i<h;i++)m.set(g.subarray(u,u+r)),u+=r,t.putImageData(c,0,s),s+=16;i<d&&(r=o*l*4,m.set(g.subarray(u,u+r)),t.putImageData(c,0,s))}else if(e.kind===k.RGB_24BPP)for(i=0,r=o*(n=16);i<d;i++){for(i>=h&&(r=o*(n=l)),p=0,s=r;s--;)m[p++]=g[u++],m[p++]=g[u++],m[p++]=g[u++],m[p++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function eZ(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,s=e.width,n=i%16,r=(i-n)/16,a=0===n?r:r+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++){let i=e<r?16:n;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=0xffffffff,inverseDecode:a=!1}){let o=J.isLittleEndian?0xff000000:255,[l,h]=a?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(let s=e+d;e<s;e++){let s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;let s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function e0(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function e1(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function e2(t,e){if(e)return!0;tt.singularValueDecompose2dScale(t,eq);let i=Math.fround(tM.pixelRatio*tc.PDF_TO_CSS_UNITS);return eq[0]<=i&&eq[1]<=i}let e3=["butt","round","square"],e5=["miter","round","bevel"],e4={},e6={};class e8{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new eQ(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new eK(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){let t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...tE(this.compositeCtx))}this.ctx.save(),e1(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=tE(this.ctx)}executeOperatorList(t,e,i,s,n){let r,a,o=t.argsArray,l=t.fnArray,h=e||0,d=o.length;if(d===h)return h;let c=d-h>10&&"function"==typeof i,u=c?Date.now()+15:0,p=0,g=this.commonObjs,m=this.objs;for(;;){if(void 0!==s&&h===s.nextBreakPoint)return s.breakIt(h,i),h;if(!n||n(h))if(r=l[h],a=o[h]??null,r!==L.dependency)null===a?this[r](h):this[r](h,...a);else for(let t of a){this.dependencyTracker?.recordNamedData(t,h);let e=t.startsWith("g_")?g:m;if(!e.has(t))return e.get(t,i),h}if(++h===d)return h;if(c&&++p>10){if(Date.now()>u)return i(),h;p=0}}}#i1(){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.transparentCanvas=null)}endDrawing(){for(let t of(this.#i1(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#i2()}#i2(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,s,n=t.width??t.displayWidth,r=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=n,h=r,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,n=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(n=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/n),(s=(i=this.cachedCanvases.getCanvas(d,e,n)).context).clearRect(0,0,e,n),s.drawImage(t,0,0,l,h,0,0,e,n),t=i.canvas,l=e,h=n,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){let i,s,n,r,a=this.ctx,{width:o,height:l}=e,h=this.current.fillColor,d=this.current.patternFill,c=tE(a);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;s=JSON.stringify(d?c:[c.slice(0,4),h]),(i=this._cachedBitmapsMap.get(r))||(i=new Map,this._cachedBitmapsMap.set(r,i));let a=i.get(s);if(a&&!d){let e=Math.round(Math.min(c[0],c[2])+c[4]),i=Math.round(Math.min(c[1],c[3])+c[5]);return this.dependencyTracker?.recordDependencies(t,eF),{canvas:a,offsetX:e,offsetY:i}}n=a}n||eZ((r=this.cachedCanvases.getCanvas("maskCanvas",o,l)).context,e);let u=tt.transform(c,[1/o,0,0,-1/l,0,0]);u=tt.transform(u,[1,0,0,1,0,-l]);let p=eX.slice();tt.axialAlignedBoundingBox([0,0,o,l],u,p);let[g,m,f,b]=p,v=Math.round(f-g)||1,y=Math.round(b-m)||1,w=this.cachedCanvases.getCanvas("fillCanvas",v,y),x=w.context;x.translate(-g,-m),x.transform(...u),!n&&(n=(n=this._scaleImage(r.canvas,tT(x))).img,i&&d&&i.set(s,n)),x.imageSmoothingEnabled=e2(tE(x),e.interpolate),eY(x,n,0,0,n.width,n.height,0,0,o,l),x.globalCompositeOperation="source-in";let A=tt.transform(tT(x),[1,0,0,1,-g,-m]);return x.fillStyle=d?h.getPattern(a,this,A,eB,t):h,x.fillRect(0,0,o,l),i&&!d&&(this.cachedCanvases.delete("fillCanvas"),i.set(s,w.canvas)),this.dependencyTracker?.recordDependencies(t,eF),{canvas:w.canvas,offsetX:Math.round(g),offsetY:Math.round(m)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=e3[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=e5[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,i=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(s,e,i);this.suspendedCtx=this.ctx;let r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),e0(this.suspendedCtx,r);var a=this.suspendedCtx;if(r._removeMirroring)throw Error("Context is already forwarding operations.");r.__originalSave=r.save,r.__originalRestore=r.restore,r.__originalRotate=r.rotate,r.__originalScale=r.scale,r.__originalTranslate=r.translate,r.__originalTransform=r.transform,r.__originalSetTransform=r.setTransform,r.__originalResetTransform=r.resetTransform,r.__originalClip=r.clip,r.__originalMoveTo=r.moveTo,r.__originalLineTo=r.lineTo,r.__originalBezierCurveTo=r.bezierCurveTo,r.__originalRect=r.rect,r.__originalClosePath=r.closePath,r.__originalBeginPath=r.beginPath,r._removeMirroring=()=>{r.save=r.__originalSave,r.restore=r.__originalRestore,r.rotate=r.__originalRotate,r.scale=r.__originalScale,r.translate=r.__originalTranslate,r.transform=r.__originalTransform,r.setTransform=r.__originalSetTransform,r.resetTransform=r.__originalResetTransform,r.clip=r.__originalClip,r.moveTo=r.__originalMoveTo,r.lineTo=r.__originalLineTo,r.bezierCurveTo=r.__originalBezierCurveTo,r.rect=r.__originalRect,r.closePath=r.__originalClosePath,r.beginPath=r.__originalBeginPath,delete r._removeMirroring},r.save=function(){a.save(),this.__originalSave()},r.restore=function(){a.restore(),this.__originalRestore()},r.translate=function(t,e){a.translate(t,e),this.__originalTranslate(t,e)},r.scale=function(t,e){a.scale(t,e),this.__originalScale(t,e)},r.transform=function(t,e,i,s,n,r){a.transform(t,e,i,s,n,r),this.__originalTransform(t,e,i,s,n,r)},r.setTransform=function(t,e,i,s,n,r){a.setTransform(t,e,i,s,n,r),this.__originalSetTransform(t,e,i,s,n,r)},r.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},r.rotate=function(t){a.rotate(t),this.__originalRotate(t)},r.clip=function(t){a.clip(t),this.__originalClip(t)},r.moveTo=function(t,e){a.moveTo(t,e),this.__originalMoveTo(t,e)},r.lineTo=function(t,e){a.lineTo(t,e),this.__originalLineTo(t,e)},r.bezierCurveTo=function(t,e,i,s,n,r){a.bezierCurveTo(t,e,i,s,n,r),this.__originalBezierCurveTo(t,e,i,s,n,r)},r.rect=function(t,e,i,s){a.rect(t,e,i,s),this.__originalRect(t,e,i,s)},r.closePath=function(){a.closePath(),this.__originalClosePath()},r.beginPath=function(){a.beginPath(),this.__originalBeginPath()},this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),e0(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),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(t,e,i,s){let n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r)if(u<0||p<0||u+i>c.width||p+s>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(c,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(t){this.inSMaskMode&&e0(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),0===this.stateStack.length){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&e0(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,s,n,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[n]=i;if(!s){n||=i[0]=new Path2D,this[e](t,n);return}if(null!==this.dependencyTracker){let i=e===L.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}if(!(n instanceof Path2D)){let t=i[0]=new Path2D;for(let e=0,i=n.length;e<i;)switch(n[e++]){case 0:t.moveTo(n[e++],n[e++]);break;case 1:t.lineTo(n[e++],n[e++]);break;case 2:t.bezierCurveTo(n[e++],n[e++],n[e++],n[e++],n[e++],n[e++]);break;case 3:t.closePath();break;default:N(`Unrecognized drawing path operator: ${n[e-1]}`)}n=t}tt.axialAlignedBoundingBox(s,tE(this.ctx),this.current.minMax),this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let s=this.ctx,n=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof n&&n?.getPattern){let i=n.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=n.getPattern(s,this,tT(s),eN,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),s.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,eM),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(eN,tE(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let s=this.ctx,n=this.current.fillColor,r=this.current.patternFill,a=!1;if(r){let i=n.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=n.getPattern(s,this,tT(s),eB,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}a=!0}let o=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==o&&(this.pendingEOFill?(s.fill(e,"evenodd"),this.pendingEOFill=!1):s.fill(e)),this.dependencyTracker?.recordDependencies(t,ek),a&&(s.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,eI).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=e4}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=e6}beginText(t){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(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,s=i.getTransform().invertSelf();for(let{transform:i,x:n,y:r,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(n,r).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let s=this.commonObjs.get(e),n=this.current;if(!s)throw Error(`Can't find font for ${e}`);if(n.fontMatrix=s.fontMatrix||C,(0===n.fontMatrix[0]||0===n.fontMatrix[3])&&N("Invalid font matrix for font "+e),i<0?(i=-i,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;let r=s.loadedName||"sans-serif",a=s.systemFontInfo?.css||`"${r}", ${s.fallbackName}`,o="normal";s.black?o="900":s.bold&&(o="bold");let l=s.italic?"italic":"normal",h=i;i<16?h=16:i>100&&(h=100),this.current.fontSizeScale=i/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.recordSimpleData("textMatrix",t);let{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#i3(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n,r){let a,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,m=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||m)&&!h.missingFile&&(a=h.getPathGenerator(this.commonObjs,e)),a&&(h.disableFontFace||g||m)){let e;if(o.save(),o.translate(i,s),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(n){e=o.getTransform(),o.setTransform(...n);let t=this.#i3(a,e,n);o.fill(t)}else o.fill(a);if(1===u||2===u)if(r){e||=o.getTransform(),o.setTransform(...r);let{a:t,b:i,c:s,d:n}=e,l=tt.inverseTransform(r),h=tt.transform([t,i,s,n,0,0],l);tt.singularValueDecompose2dScale(h,eq),o.lineWidth*=Math.max(eq[0],eq[1])/c,o.stroke(this.#i3(a,e,r))}else o.lineWidth/=c,o.stroke(a);o.restore()}else(0===u||2===u)&&(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e))),(1===u||2===u)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e)).recordDependencies(t,eM),o.strokeText(e,i,s));p&&((this.pendingTextPaths||=[]).push({transform:tE(o),x:i,y:s,fontSize:c,path:a}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s))}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return H(this,"isFontSubpixelAAEnabled",i)}showText(t,e){let i,s;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,eL).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let n=this.current,r=n.font;if(r.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}let a=n.fontSize;if(0===a)return void this.dependencyTracker?.recordOperation(t);let o=this.ctx,l=n.fontSizeScale,h=n.charSpacing,d=n.wordSpacing,c=n.fontDirection,u=n.textHScale*c,p=e.length,g=r.vertical,m=g?1:-1,f=r.defaultVMetrics,b=a*n.fontMatrix[0],v=0===n.textRenderingMode&&!r.disableFontFace&&!n.patternFill;if(o.save(),n.textMatrix&&o.transform(...n.textMatrix),o.translate(n.x,n.y+n.textRise),c>0?o.scale(u,-1):o.scale(u,1),n.patternFill){o.save();let e=n.fillColor.getPattern(o,this,tT(o),eB,t);i=tE(o),o.restore(),o.fillStyle=e}if(n.patternStroke){o.save();let e=n.strokeColor.getPattern(o,this,tT(o),eN,t);s=tE(o),o.restore(),o.strokeStyle=e}let y=n.lineWidth,w=n.textMatrixScale;if(0===w||0===y){let t=3&n.textRenderingMode;(1===t||2===t)&&(y=this.getSinglePixelWidth())}else y/=w;if(1!==l&&(o.scale(l,l),y/=l),o.lineWidth=y,r.isInvalidPDFjsFont){let i=[],s=0;for(let t of e)i.push(t.unicode),s+=t.width;let r=i.join("");if(o.fillText(r,0,0),null!==this.dependencyTracker){let e=o.measureText(r);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}n.x+=s*b*u,o.restore(),this.compose();return}let x=0,A;for(A=0;A<p;++A){let n,u,p,y=e[A];if("number"==typeof y){x+=m*y*a/1e3;continue}let w=!1,_=(y.isSpace?d:0)+h,C=y.fontChar,S=y.accent,E=y.width;if(g){let t=y.vmetric||f,e=-(y.vmetric?t[1]:.5*E)*b,i=t[2]*b;E=t?-t[0]:E,n=e/l,u=(x+i)/l}else n=x/l,u=0;if(r.remeasure&&E>0){let t=1e3*(p=o.measureText(C)).width/a*l;if(E<t&&this.isFontSubpixelAAEnabled){let e=E/t;w=!0,o.save(),o.scale(e,1),n/=e}else E!==t&&(n+=(E-t)/2e3*a/l)}if(this.contentVisible&&(y.isInFont||r.missingFile)){if(v&&!S)o.fillText(C,n,u),this.dependencyTracker?.recordCharacterBBox(t,o,p?{bbox:null}:r,a/l,n,u,()=>p??o.measureText(C));else if(this.paintChar(t,C,n,u,i,s),S){let e=n+a*S.offset.x/l,r=u-a*S.offset.y/l;this.paintChar(t,S.fontChar,e,r,i,s)}}x+=g?E*b-_*c:E*b+_*c,w&&o.restore()}g?n.y-=x:n.x+=x*u,o.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){let i,s,n,r,a=this.ctx,o=this.current,l=o.font,h=o.fontSize,d=o.fontDirection,c=l.vertical?1:-1,u=o.charSpacing,p=o.wordSpacing,g=o.textHScale*d,m=o.fontMatrix||C,f=e.length;if(3===o.textRenderingMode||0===h)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),o.textMatrix&&a.transform(...o.textMatrix),a.translate(o.x,o.y+o.textRise),a.scale(g,d);let b=this.dependencyTracker;for(i=0,this.dependencyTracker=b?new eP(b,t):null;i<f;++i){if("number"==typeof(s=e[i])){r=c*s*h/1e3,this.ctx.translate(r,0),o.x+=r*g;continue}let t=(s.isSpace?p:0)+u,d=l.charProcOperatorList[s.operatorListId];d?this.contentVisible&&(this.save(),a.scale(h,h),a.transform(...m),this.executeOperatorList(d),this.restore()):N(`Type3 character "${s.operatorListId}" is not available.`);let f=[s.width,0];tt.applyTransform(f,m),n=f[0]*h+t,a.translate(n,0),o.x+=n*g}a.restore(),b&&(this.dependencyTracker=b)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,n,r,a){let o=new Path2D;o.rect(s,n,r-s,a-n),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,r,n,a).recordClipBox(t,this.ctx,s,r,n,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||tE(this.ctx);i=new eG(e,this.ctx,{createCanvasGraphics:(t,e)=>new e8(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new eP(this.dependencyTracker,e,!0):null)},t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new ez(t);case"Mesh":return new e$(t);case"Dummy":return new eV}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;let i=this.ctx;this.save(t),i.fillStyle=this._getPattern(t,e).getPattern(i,this,tT(i),eO,t);let s=tT(i);{let{width:t,height:e}=i.canvas,n=eX.slice();tt.axialAlignedBoundingBox([0,0,t,e],s,n);let[r,a,o,l]=n;this.ctx.fillRect(r,a,o-r,l-a)}this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,eR).recordDependencies(t,ek).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){O("Should not call beginInlineImage")}beginImageData(){O("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=tE(this.ctx),i)){tt.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,s,n,r]=i,a=new Path2D;a.rect(e,s,n-e,r-s),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,n,s,r),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let i=this.ctx;e.isolated||B("TODO: Support non-isolated groups."),e.knockout&&N("Knockout groups not supported.");let s=tE(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw Error("Bounding box is required.");let n=eX.slice();tt.axialAlignedBoundingBox(e.bbox,tE(i),n);let r=[0,0,i.canvas.width,i.canvas.height],a=Math.floor((n=tt.intersect(n,r)||[0,0,0,0])[0]),o=Math.floor(n[1]),l=Math.max(Math.ceil(n[2])-a,1),h=Math.max(Math.ceil(n[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let c=this.cachedCanvases.getCanvas(d,l,h),u=c.context;u.translate(-a,-o),u.transform(...s);let p=new Path2D,[g,m,f,b]=e.bbox;if(p.rect(g,m,f-g,b-m),e.matrix){let t=new Path2D;t.addPath(p,new DOMMatrix(e.matrix)),p=t}u.clip(p),e.smask&&this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(a,o),i.save()),e0(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();let e=tE(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let s=eX.slice();tt.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,s),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,i,s,n,r){if(this.#i1(),e1(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let n=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){s=s.slice(),s[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=n,i[3]=a,tt.singularValueDecompose2dScale(tE(this.ctx),eq);let{viewportScale:t}=this,r=Math.ceil(n*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);let{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(eq[0],0,0,-eq[1],0,a*eq[1]),e1(this.ctx)}else{e1(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],n,a),this.ctx.clip(e)}}this.current=new eQ(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...s),this.transform(t,...n)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#i2(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let s=this.ctx,n=this._createMaskCanvas(t,e),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.ctx;o.save();let l=tE(o);o.transform(i,s,n,r,0,0);let h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,d=a.length;e<d;e+=2){let d=tt.transform(l,[i,s,n,r,a[e],a[e+1]]);o.drawImage(h.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(t,this.ctx,d[4],d[4]+h.canvas.width,d[5],d[5]+h.canvas.height)}o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.ctx,s=this.current.fillColor,n=this.current.patternFill;for(let r of(this.dependencyTracker?.resetBBox(t).recordDependencies(t,eF),e)){let{data:e,width:a,height:o,transform:l}=r,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save(),eZ(d,this.getObject(t,e,r)),d.globalCompositeOperation="source-in",d.fillStyle=n?s.getPattern(d,this,tT(i),eB,t):s,d.fillRect(0,0,a,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),eY(i,h.canvas,0,0,a,o,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,a,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):N("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,n){if(!this.contentVisible)return;let r=this.getObject(t,e);if(!r)return void N("Dependent image isn't ready yet");let a=r.width,o=r.height,l=[];for(let t=0,e=n.length;t<e;t+=2)l.push({transform:[i,0,0,s,n[t],n[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;let{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t,e){let i;if(!this.contentVisible)return;let s=e.width,n=e.height,r=this.ctx;this.save(t);let{filter:a}=r;if("none"!==a&&""!==a&&(r.filter="none"),r.scale(1/s,-1/n),e.bitmap)i=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)i=e;else{let t=this.cachedCanvases.getCanvas("inlineImage",s,n).context;eJ(t,e),i=this.applyTransferMapsToCanvas(t)}let o=this._scaleImage(i,tT(r));r.imageSmoothingEnabled=e2(tE(r),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,eD).recordOperation(t),eY(r,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,s,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){let s;if(!this.contentVisible)return;let n=this.ctx;if(e.bitmap)s=e.bitmap;else{let t=e.width,i=e.height,n=this.cachedCanvases.getCanvas("inlineImage",t,i).context;eJ(n,e),s=this.applyTransferMapsToCanvas(n)}for(let e of(this.dependencyTracker?.resetBBox(t),i))n.save(),n.transform(...e.transform),n.scale(1,-1),eY(n,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,ek).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){let s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let n=this.ctx;this.pendingClip?(s||(this.pendingClip===e6?n.clip(e,"evenodd"):n.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=tE(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:n,c:r,d:a}=this.ctx.getTransform();if(0===n&&0===r){let n=Math.abs(s),r=Math.abs(a);if(n===r)if(0===i)t=e=1/n;else{let s=n*i;t=e=s<1?1/s:1}else if(0===i)t=1/n,e=1/r;else{let s=n*i,a=r*i;t=s<1?1/s:1,e=a<1?1/a:1}}else{let o=Math.abs(s*a-n*r),l=Math.hypot(s,n),h=Math.hypot(r,a);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r){i.lineWidth=(s||1)*n,i.stroke(t);return}let a=i.getLineDash();e&&i.save(),i.scale(n,r),eW.a=1/n,eW.d=1/r;let o=new Path2D;if(o.addPath(t,eW),a.length>0){let t=Math.max(n,r);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in L)void 0!==e8.prototype[t]&&(e8.prototype[L[t]]=e8.prototype[t]);class e9{#i5;#i4;#i6;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){let e=new TextEncoder,i={},s=0;for(let n of e9.strings){let r=e.encode(t[n]);i[n]=r,s+=4+r.length}let n=new ArrayBuffer(s),r=new Uint8Array(n),a=new DataView(n),o=0;for(let t of e9.strings){let e=i[t],s=e.length;a.setUint32(o,s),r.set(e,o+4),o+=4+s}return j(o===n.byteLength,"CssFontInfo.write: Buffer overflow"),n}constructor(t){this.#i5=t,this.#i4=new DataView(this.#i5),this.#i6=new TextDecoder}#i8(t){j(t<e9.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#i4.getUint32(e)+4;let i=this.#i4.getUint32(e);return this.#i6.decode(new Uint8Array(this.#i5,e+4,i))}get fontFamily(){return this.#i8(0)}get fontWeight(){return this.#i8(1)}get italicAngle(){return this.#i8(2)}}class e7{#i5;#i4;#i6;static strings=["css","loadedName","baseFontName","src"];static write(t){let e=new TextEncoder,i={},s=0;for(let n of e7.strings){let r=e.encode(t[n]);i[n]=r,s+=4+r.length}let n,r,a=1+(s+=4);t.style&&(n=e.encode(t.style.style),r=e.encode(t.style.weight),a+=4+n.length+4+r.length);let o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o),d=0;for(let e of(h.setUint8(d++,+!!t.guessFallback),h.setUint32(d,0),d+=4,s=0,e7.strings)){let t=i[e],n=t.length;s+=4+n,h.setUint32(d,n),l.set(t,d+4),d+=4+n}return h.setUint32(d-s-4,s),t.style&&(h.setUint32(d,n.length),l.set(n,d+4),d+=4+n.length,h.setUint32(d,r.length),l.set(r,d+4),d+=4+r.length),j(d<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(d)}constructor(t){this.#i5=t,this.#i4=new DataView(this.#i5),this.#i6=new TextDecoder}get guessFallback(){return 0!==this.#i4.getUint8(0)}#i8(t){j(t<e7.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#i4.getUint32(e)+4;let i=this.#i4.getUint32(e);return this.#i6.decode(new Uint8Array(this.#i5,e+4,i))}get css(){return this.#i8(0)}get loadedName(){return this.#i8(1)}get baseFontName(){return this.#i8(2)}get src(){return this.#i8(3)}get style(){let t=1;t+=4+this.#i4.getUint32(t);let e=this.#i4.getUint32(t),i=this.#i6.decode(new Uint8Array(this.#i5,t+4,e));t+=4+e;let s=this.#i4.getUint32(t),n=this.#i6.decode(new Uint8Array(this.#i5,t+4,s));return{style:i,weight:n}}}class it{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static #i9=Math.ceil(2*this.bools.length/8);static #i7=this.#i9+8*this.numbers.length;static #st=this.#i7+1+8;static #se=this.#st+1+48;static #si=this.#se+1+6;#i5;#i6;#i4;constructor({data:t,extra:e}){this.#i5=t,this.#i6=new TextDecoder,this.#i4=new DataView(this.#i5),e&&Object.assign(this,e)}#ss(t){j(t<it.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=this.#i4.getUint8(e)>>2*t%8&3;return 0===i?void 0:2===i}get black(){return this.#ss(0)}get bold(){return this.#ss(1)}get disableFontFace(){return this.#ss(2)}get fontExtraProperties(){return this.#ss(3)}get isInvalidPDFjsFont(){return this.#ss(4)}get isType3Font(){return this.#ss(5)}get italic(){return this.#ss(6)}get missingFile(){return this.#ss(7)}get remeasure(){return this.#ss(8)}get vertical(){return this.#ss(9)}#sn(t){return j(t<it.numbers.length,"Invalid number index"),this.#i4.getFloat64(it.#i9+8*t)}get ascent(){return this.#sn(0)}get defaultWidth(){return this.#sn(1)}get descent(){return this.#sn(2)}get bbox(){let t=it.#i7;if(0===this.#i4.getUint8(t))return;t+=1;let e=[];for(let i=0;i<4;i++)e.push(this.#i4.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=it.#st;if(0===this.#i4.getUint8(t))return;t+=1;let e=[];for(let i=0;i<6;i++)e.push(this.#i4.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=it.#se;if(0===this.#i4.getUint8(t))return;t+=1;let e=[];for(let i=0;i<3;i++)e.push(this.#i4.getInt16(t,!0)),t+=2;return e}#i8(t){j(t<it.strings.length,"Invalid string index");let e=it.#si+4;for(let i=0;i<t;i++)e+=this.#i4.getUint32(e)+4;let i=this.#i4.getUint32(e),s=new Uint8Array(i);return s.set(new Uint8Array(this.#i5,e+4,i)),this.#i6.decode(s)}get fallbackName(){return this.#i8(0)}get loadedName(){return this.#i8(1)}get mimetype(){return this.#i8(2)}get name(){return this.#i8(3)}get data(){let t=it.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);t+=4+i;let s=this.#i4.getUint32(t);t+=4+s;let n=this.#i4.getUint32(t);if(0!==n)return new Uint8Array(this.#i5,t+4,n)}clearData(){let t=it.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);t+=4+i;let s=this.#i4.getUint32(t);t+=4+s;let n=this.#i4.getUint32(t);new Uint8Array(this.#i5,t+4,n).fill(0),this.#i4.setUint32(t,0)}get cssFontInfo(){let t=it.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);t+=4+i;let s=this.#i4.getUint32(t);if(0===s)return null;let n=new Uint8Array(s);return n.set(new Uint8Array(this.#i5,t+4,s)),new e9(n.buffer)}get systemFontInfo(){let t=it.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);if(0===i)return null;let s=new Uint8Array(i);return s.set(new Uint8Array(this.#i5,t+4,i)),new e7(s.buffer)}static write(t){let e=t.systemFontInfo?e7.write(t.systemFontInfo):null,i=t.cssFontInfo?e9.write(t.cssFontInfo):null,s=new TextEncoder,n={},r=0;for(let e of it.strings)n[e]=s.encode(t[e]),r+=4+n[e].length;let a=new ArrayBuffer(it.#si+4+r+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0)),o=new Uint8Array(a),l=new DataView(a),h=0,d=it.bools.length,c=0,u=0;for(let e=0;e<d;e++){let i=t[it.bools[e]];c|=(void 0===i?0:i?2:1)<<u,(8===(u+=2)||e===d-1)&&(l.setUint8(h++,c),c=0,u=0)}for(let e of(j(h===it.#i9,"FontInfo.write: Boolean properties offset mismatch"),it.numbers))l.setFloat64(h,t[e]),h+=8;if(j(h===it.#i7,"FontInfo.write: Number properties offset mismatch"),t.bbox)for(let e of(l.setUint8(h++,4),t.bbox))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=8;if(j(h===it.#st,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix)for(let e of(l.setUint8(h++,6),t.fontMatrix))l.setFloat64(h,e,!0),h+=8;else l.setUint8(h++,0),h+=48;if(j(h===it.#se,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics)for(let e of(l.setUint8(h++,1),t.defaultVMetrics))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=6;for(let t of(j(h===it.#si,"FontInfo.write: DefaultVMetrics properties offset mismatch"),l.setUint32(it.#si,0),h+=4,it.strings)){let e=n[t],i=e.length;l.setUint32(h,i),o.set(e,h+4),h+=4+i}if(l.setUint32(it.#si,h-it.#si-4),e){let t=e.byteLength;l.setUint32(h,t),j(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),o.set(new Uint8Array(e),h+4),h+=4+t}else l.setUint32(h,0),h+=4;if(i){let t=i.byteLength;l.setUint32(h,t),j(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),o.set(new Uint8Array(i),h+4),h+=4+t}else l.setUint32(h,0),h+=4;return void 0===t.data?(l.setUint32(h,0),h+=4):(l.setUint32(h,t.data.length),o.set(t.data,h+4),h+=4+t.data.length),j(h<=a.byteLength,"FontInfo.write: Buffer overflow"),a.transferToFixedLength(h)}}class ie{static #sr=null;static #sa="";static get workerPort(){return this.#sr}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#sr=t}static get workerSrc(){return this.#sa}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#sa=t}}class ii{#so;#sl;constructor({parsedData:t,rawData:e}){this.#so=t,this.#sl=e}getRaw(){return this.#sl}get(t){return this.#so.get(t)??null}[Symbol.iterator](){return this.#so.entries()}}let is=Symbol("INTERNAL");class ir{#sh=!1;#sd=!1;#sc=!1;#su=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#sh=!!(2&t),this.#sd=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#sc)return this.#su;if(!this.#su)return!1;let{print:t,view:e}=this.usage;return this.#sh?e?.viewState!=="OFF":!this.#sd||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==is&&O("Internal method `_setVisible` called."),this.#sc=i,this.#su=e}}class ia{#sp=null;#sg=new Map;#sm=null;#sf=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#sf=t.order,t.groups))this.#sg.set(i.id,new ir(e,i));if("OFF"===t.baseState)for(const t of this.#sg.values())t._setVisible(is,!1);for(const e of t.on)this.#sg.get(e)._setVisible(is,!0);for(const e of t.off)this.#sg.get(e)._setVisible(is,!1);this.#sm=this.getHash()}#sb(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,n=t[s];if(Array.isArray(n))e=this.#sb(n);else{if(!this.#sg.has(n))return N(`Optional content group not found: ${n}`),!0;e=this.#sg.get(n).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#sg.size)return!0;if(!t)return B("Optional content group not defined."),!0;if("OCG"===t.type)return this.#sg.has(t.id)?this.#sg.get(t.id).visible:(N(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#sb(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#sg.has(e)){N(`Optional content group not found: ${e}`);break}if(!this.#sg.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#sg.has(e))return N(`Optional content group not found: ${e}`),!0;if(!this.#sg.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#sg.has(e)){N(`Optional content group not found: ${e}`);break}if(this.#sg.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#sg.has(e))return N(`Optional content group not found: ${e}`),!0;if(this.#sg.get(e).visible)return!0}return!1}return N(`Unknown optional content policy ${t.policy}.`),!0}return N(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#sg.get(t);if(!s)return void N(`Optional content group not found: ${t}`);if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#sg.get(i)?._setVisible(is,!1,!0);s._setVisible(is,!!e,!0),this.#sp=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#sg.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#sp=null}get hasInitialVisibility(){return null===this.#sm||this.getHash()===this.#sm}getOrder(){return this.#sg.size?this.#sf?this.#sf.slice():[...this.#sg.keys()]:null}getGroup(t){return this.#sg.get(t)||null}getHash(){if(null!==this.#sp)return this.#sp;let t=new t1;for(let[e,i]of this.#sg)t.update(`${e}:${i.visible}`);return this.#sp=t.hexdigest()}[Symbol.iterator](){return this.#sg.entries()}}class io{constructor(t,{disableRange:e=!1,disableStream:i=!1}){j(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):j(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){j(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new il(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ih(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeReaders.slice(0)))e.cancel(t);this._pdfDataRangeTransport.abort()}}class il{constructor(t,e,i=!1,s=null){for(const n of(this._stream=t,this._done=i||!1,this._filename=tf(s)?s:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ih{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function id(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function ic(t){return URL.parse(t)?.origin??null}function iu({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)&&(n.suggestedLength=r,r<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0)),n}function ip(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=a(i=i[1]);return r(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=n.exec(t));){let[,t,s,n]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,n]}let r=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=a(s),e&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t))return r(l(i));if(i=s("filename","i").exec(t)){let t=a(i=i[1]);return r(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),n=Q(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return n(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(tf(t))return t}return null}function ig(t,e){return new q(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function im(t){return 200===t||206===t}function ib(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function iv(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(N(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class iy{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=id(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return j(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new iw(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ix(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class iw{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,ib(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=ic(e.url),!im(e.status))throw ig(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();let i=e.headers,{allowRangeRequests:n,suggestedLength:r}=iu({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=ip(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new K("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}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(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:iv(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ix{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,ib(n,this._withCredentials,this._abortController)).then(e=>{let i=ic(e.url);if(i!==t._responseOrigin)throw Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!im(e.status))throw ig(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:iv(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class iA{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=id(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};for(let[t,i]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",j(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){let i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){let i,s=this.pendingRequests[t];if(!s)return;let n=s.xhr;if(n.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==n.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===n.status&&this.isHttp)return void s.onError(n.status);let r=n.status||200;if((200!==r||206!==s.expectedStatus)&&r!==s.expectedStatus)return void s.onError(n.status);let a="string"!=typeof(i=n.response)?i:Q(i).buffer;if(206===r){let t=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?s.onDone({begin:parseInt(e[1],10),chunk:a}):(N('Missing or invalid "Content-Range" header.'),s.onError(0))}else a?s.onDone({begin:0,chunk:a}):s.onError(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class i_{constructor(t){this._source=t,this._manager=new iA(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return j(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new iC(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let i=new iS(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class iC{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=ic(e.responseURL);let i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=iu({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=ip(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(let e of(this._storedError=ig(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class iS{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=ic(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;for(let t of(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){for(let e of(this._storedError??=ig(t,this._url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}let iE=/^[a-z][a-z0-9\-+.]+:/i;class iT{constructor(t){this.source=t,this.url=function(t){return new URL(iE.test(t)?t:y.default.getBuiltinModule("url").pathToFileURL(t))}(t.url),j("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return j(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new iP(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new iM(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class iP{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=y.default.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=ig(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new K("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class iM{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=y.default.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}let ik=Symbol("INITIAL_DATA");class iD{#sv=Object.create(null);#sy(t){return this.#sv[t]||={...Promise.withResolvers(),data:ik}}get(t,e=null){if(e){let i=this.#sy(t);return i.promise.then(()=>e(i.data)),null}let i=this.#sv[t];if(!i||i.data===ik)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#sv[t];return!!e&&e.data!==ik}delete(t){let e=this.#sv[t];return!!e&&e.data!==ik&&(delete this.#sv[t],!0)}resolve(t,e=null){let i=this.#sy(t);i.data=e,i.resolve()}clear(){for(let t in this.#sv){let{data:e}=this.#sv[t];e?.bitmap?.close()}this.#sv=Object.create(null)}*[Symbol.iterator](){for(let t in this.#sv){let{data:e}=this.#sv[t];e!==ik&&(yield[t,e])}}}class iI{#sw=Promise.withResolvers();#tx=null;#sx=!1;#sA=!!globalThis.FontInspector?.enabled;#s_=null;#sC=null;#sS=0;#sE=0;#sT=null;#sP=null;#sM=0;#sk=0;#sD=Object.create(null);#sI=[];#sL=null;#sR=[];#sF=new WeakMap;#sB=null;static #sN=new Map;static #sO=new Map;static #sj=new WeakMap;static #sU=null;static #sz=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#sL=t;else if("object"==typeof t)this.#sL=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tx=this.#sP=e,this.#sk=i.scale*tM.pixelRatio,this.#sM=i.rotation,this.#sC={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:r,pageY:a}=i.rawDims;this.#sB=[1,0,0,-1,-r,a+n],this.#sE=s,this.#sS=n,iI.#sH(),tP(e,i),this.#sw.promise.finally(()=>{iI.#sz.delete(this),this.#sC=null,this.#sD=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=J.platform;return H(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#sT.read().then(({value:e,done:i})=>{i?this.#sw.resolve():(this.#s_??=e.lang,Object.assign(this.#sD,e.styles),this.#s$(e.items),t())},this.#sw.reject)};return this.#sT=this.#sL.getReader(),iI.#sz.add(this),t(),this.#sw.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*tM.pixelRatio,s=t.rotation;if(s!==this.#sM&&(e?.(),this.#sM=s,tP(this.#sP,{rotation:s})),i!==this.#sk){e?.(),this.#sk=i;let t={div:null,properties:null,ctx:iI.#sV(this.#s_)};for(let e of this.#sR)t.properties=this.#sF.get(e),t.div=e,this.#sG(t)}}cancel(){let t=new K("TextLayer task cancelled.");this.#sT?.cancel(t).catch(()=>{}),this.#sT=null,this.#sw.reject(t)}get textDivs(){return this.#sR}get textContentItemsStr(){return this.#sI}#s$(t){if(this.#sx)return;this.#sC.ctx??=iI.#sV(this.#s_);let e=this.#sR,i=this.#sI;for(let s of t){if(e.length>1e5){N("Ignoring additional textDivs for performance reasons."),this.#sx=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tx;this.#tx=document.createElement("span"),this.#tx.classList.add("markedContent"),s.id&&this.#tx.setAttribute("id",`${s.id}`),t.append(this.#tx)}else"endMarkedContent"===s.type&&(this.#tx=this.#tx.parentNode);continue}i.push(s.str),this.#sW(s)}}#sW(t){let e,i,s=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#sR.push(s);let r=tt.transform(this.#sB,t.transform),a=Math.atan2(r[1],r[0]),o=this.#sD[t.fontName];o.vertical&&(a+=Math.PI/2);let l=this.#sA&&o.fontSubstitution||o.fontFamily;l=iI.fontFamilyMap.get(l)||l;let h=Math.hypot(r[2],r[3]),d=h*iI.#sq(l,o,this.#s_);0===a?(e=r[4],i=r[5]-d):(e=r[4]+d*Math.sin(a),i=r[5]-d*Math.cos(a));let c="calc(var(--total-scale-factor) *",u=s.style;this.#tx===this.#sP?(u.left=`${(100*e/this.#sE).toFixed(2)}%`,u.top=`${(100*i/this.#sS).toFixed(2)}%`):(u.left=`${c}${e.toFixed(2)}px)`,u.top=`${c}${i.toFixed(2)}px)`),u.fontSize=`${c}${(iI.#sU*h).toFixed(2)}px)`,u.fontFamily=l,n.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#sA&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==a&&(n.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]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(n.canvasWidth=o.vertical?t.height:t.width),this.#sF.set(s,n),this.#sC.div=s,this.#sC.properties=n,this.#sG(this.#sC),n.hasText&&this.#tx.append(s),n.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tx.append(t)}}#sG(t){let{div:e,properties:i,ctx:s}=t,{style:n}=e,r="";if(iI.#sU>1&&(r=`scale(${1/iI.#sU})`),0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=n,{canvasWidth:a,fontSize:o}=i;iI.#sX(s,o*this.#sk,t);let{width:l}=s.measureText(e.textContent);l>0&&(r=`scaleX(${a*this.#sk/l}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#sz.size>0)){for(let{canvas:t}of(this.#sN.clear(),this.#sO.values()))t.remove();this.#sO.clear()}}static #sV(t=null){let e=this.#sO.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#sO.set(t,e),this.#sj.set(e,{size:0,family:""})}return e}static #sX(t,e,i){let s=this.#sj.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #sH(){if(null!==this.#sU)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#sU=t.getBoundingClientRect().height,t.remove()}static #sq(t,e,i){let s=this.#sN.get(t);if(s)return s;let n=this.#sV(i);n.canvas.width=n.canvas.height=30,this.#sX(n,30,t);let r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return a?l=a/(a+o):(J.platform.isFirefox&&N("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#sN.set(t,l),l}}function iL(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new iR,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(_)return t;let e=URL.parse(t,window.location);if(e)return e.href}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(_&&void 0!==w.Buffer&&t instanceof w.Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Q(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof iF?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,d=t.worker instanceof iO?t.worker:null,c=t.verbosity,u="string"!=typeof t.docBaseUrl||tm(t.docBaseUrl)?null:t.docBaseUrl,p=t8(t.cMapUrl),g=!1!==t.cMapPacked,m=t.CMapReaderFactory||(_?eb:eo),f=t8(t.iccUrl),b=t8(t.standardFontDataUrl),v=t.StandardFontDataFactory||(_?ev:ec),y=t8(t.wasmUrl),x=t.WasmFactory||(_?ey:ep),A=!0!==t.stopAtErrors,C=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,S=!1!==t.isEvalSupported,E="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!_,T="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!_&&(J.platform.isFirefox||!globalThis.chrome),P=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,M="boolean"==typeof t.disableFontFace?t.disableFontFace:_,k=!0===t.fontExtraProperties,D=!0===t.enableXfa,I=t.ownerDocument||globalThis.document,L=!0===t.disableRange,R=!0===t.disableStream,B=!0===t.disableAutoFetch,N=!0===t.pdfBug,O=t.CanvasFactory||(_?ef:er),j=t.FilterFactory||(_?em:eh),U=!0===t.enableHWA,z=!1!==t.useWasm,H=l?l.length:t.length??NaN,$="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!_&&!M,V="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(m===eo&&v===ec&&x===ep&&p&&b&&y&&tw(p,document.baseURI)&&tw(b,document.baseURI)&&tw(y,document.baseURI));Number.isInteger(c)&&(F=c);let G={canvasFactory:new O({ownerDocument:I,enableHWA:U}),filterFactory:new j({docId:i,ownerDocument:I}),cMapReaderFactory:V?null:new m({baseUrl:p,isCompressed:g}),standardFontDataFactory:V?null:new v({baseUrl:b}),wasmFactory:V?null:new x({baseUrl:y})};d||(e._worker=d=iO.create({verbosity:c,port:ie.workerPort}));let W={docId:i,apiVersion:"5.4.296",data:n,password:o,disableAutoFetch:B,rangeChunkSize:h,length:H,docBaseUrl:u,enableXfa:D,evaluatorOptions:{maxImageSize:C,disableFontFace:M,ignoreErrors:A,isEvalSupported:S,isOffscreenCanvasSupported:E,isImageDecoderSupported:T,canvasMaxAreaInBytes:P,fontExtraProperties:k,useSystemFonts:$,useWasm:z,useWorkerFetch:V,cMapUrl:p,iccUrl:f,standardFontDataUrl:b,wasmUrl:y}},q={ownerDocument:I,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:B,enableXfa:D}};return d.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(d.destroyed)throw Error("Worker was destroyed");let o=d.messageHandler.sendWithPromise("GetDocRequest",W,n?[n.buffer]:null);if(l)t=new io(l,{disableRange:L,disableStream:R});else if(!n){if(!s)throw Error("getDocument - no `url` parameter provided.");t=new(tw(s)?iy:_?iT:i_)({url:s,length:H,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:L,disableStream:R})}return o.then(s=>{if(e.destroyed)throw Error("Loading aborted");if(d.destroyed)throw Error("Worker was destroyed");let n=new es(i,s,d.port),r=new ij(n,e,t,q,G,U);e._transport=r,n.send("Ready",null)})}).catch(e._capability.reject),e}class iR{static #ib=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${iR.#ib++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class iF{#sw=Promise.withResolvers();#sK=[];#sY=[];#sQ=[];#sJ=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){this.#sJ.push(t)}addProgressListener(t){this.#sQ.push(t)}addProgressiveReadListener(t){this.#sY.push(t)}addProgressiveDoneListener(t){this.#sK.push(t)}onDataRange(t,e){for(let i of this.#sJ)i(t,e)}onDataProgress(t,e){this.#sw.promise.then(()=>{for(let i of this.#sQ)i(t,e)})}onDataProgressiveRead(t){this.#sw.promise.then(()=>{for(let e of this.#sY)e(t)})}onDataProgressiveDone(){this.#sw.promise.then(()=>{for(let t of this.#sK)t()})}transportReady(){this.#sw.resolve()}requestDataRange(t,e){O("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iB{constructor(t,e){this._pdfInfo=t,this._transport=e}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 H(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}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()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class iN{#sZ=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new ty:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new iD,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}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:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new tp({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return H(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=S.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:c=!1,recordOperations:u=!1,operationsFilter:p=null}){this._stats?.time("Overall");let g=this._transport.getRenderingIntent(s,n,d,c),{renderingIntent:m,cacheKey:f}=g;this.#sZ=!1,o||=this._transport.getOptionalContentConfig(m);let b=this._intentStates.get(f);b||(b=Object.create(null),this._intentStates.set(f,b)),b.streamReaderCancelTimeout&&(clearTimeout(b.streamReaderCancelTimeout),b.streamReaderCancelTimeout=null);let v=!!(4&m);b.displayReadyCapability||(b.displayReadyCapability=Promise.withResolvers(),b.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));let y=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!this.recordedBBoxes&&(u||y),x=t=>{if(b.renderTasks.delete(A),w){let t=A.gfx?.dependencyTracker.take();t&&(A.stepper&&A.stepper.setOperatorBBoxes(t,A.gfx.dependencyTracker.takeDebugMetadata()),u&&(this.recordedBBoxes=t))}v&&(this.#sZ=!0),this.#s0(),t?(A.capability.reject(t),this._abortOperatorList({intentState:b,reason:t instanceof Error?t:Error(t)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new iz({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:w?new eT(e,b.operatorList.length,y):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:b.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(b.renderTasks||=new Set).add(A);let _=A.task;return Promise.all([b.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)return void x();if(this._stats?.time("Rendering"),!(e.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:t,optionalContentConfig:e}),A.operatorListChanged()}).catch(x),_}getOperatorList({intent:t="display",annotationMode:e=S.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let n,r=this._transport.getRenderingIntent(t,e,i,s,!0),a=this._intentStates.get(r.cacheKey);return a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a)),a.opListReadCapability||((n=Object.create(null)).operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(n))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(n),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>tl.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#sZ=!1,Promise.all(t)}cleanup(t=!1){this.#sZ=!0;let e=this.#s0();return t&&e&&(this._stats&&=new ty),e}#s0(){if(!this.#sZ||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#sZ=!1,!0}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#s0()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#s0()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof tg){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new K(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class iO{#sw=Promise.withResolvers();#s1=null;#sr=null;#s2=null;static #s3=0;static #s5=!1;static #s4=new WeakMap;static{_&&(this.#s5=!0,ie.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{if(console.log("Deprecated API usage: `PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=F}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(iO.#s4.has(e))throw Error("Cannot use more than one PDFWorker per port.");iO.#s4.set(e,this),this.#s6(e)}else this.#s8()}get promise(){return this.#sw.promise}#s9(){this.#sw.resolve(),this.#s1.send("configure",{verbosity:this.verbosity})}get port(){return this.#sr}get messageHandler(){return this.#s1}#s6(t){this.#sr=t,this.#s1=new es("main","worker",t),this.#s1.on("ready",()=>{}),this.#s9()}#s8(){if(iO.#s5||iO.#s7)return void this.#nt();let{workerSrc:t}=iO;try{iO._isSameOrigin(window.location,t)||(t=iO._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new es("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#sw.reject(Error("Worker was destroyed")):this.#nt()},n=new AbortController;e.addEventListener("error",()=>{this.#s2||s()},{signal:n.signal}),i.on("test",t=>{(n.abort(),this.destroyed||!t)?s():(this.#s1=i,this.#sr=e,this.#s2=e,this.#s9())}),i.on("ready",t=>{if(n.abort(),this.destroyed)return void s();try{r()}catch{this.#nt()}});let r=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};r();return}catch{B("The worker has been disabled.")}this.#nt()}#nt(){iO.#s5||(N("Setting up fake worker."),iO.#s5=!0),iO._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#sw.reject(Error("Worker was destroyed"));let e=new et;this.#sr=e;let i=`fake${iO.#s3++}`,s=new es(i+"_worker",i,e);t.setup(s,e),this.#s1=new es(i,i+"_worker",e),this.#s9()}).catch(t=>{this.#sw.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#s2?.terminate(),this.#s2=null,iO.#s4.delete(this.#sr),this.#sr=null,this.#s1?.destroy(),this.#s1=null}static create(t){let e=this.#s4.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new iO(t)}static get workerSrc(){if(ie.workerSrc)return ie.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #s7(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return H(this,"_setupFakeWorkerGlobal",(async()=>this.#s7?this.#s7:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ij{#ne=new Map;#ni=new Map;#ns=new Map;#nn=new Map;#nr=null;constructor(t,e,i,s,n,r){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new iD,this.fontLoader=new t4({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=r,this.setupMessageHandler()}#na(t,e=null){let i=this.#ne.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise(t,e);return this.#ne.set(t,s),s}get annotationStorage(){return H(this,"annotationStorage",new t3)}getRenderingIntent(t,e=S.ENABLE,i=null,s=!1,n=!1){let r=2,a=t2;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:N(`getRenderingIntent - invalid intent: ${t}`)}let o=4&r&&i instanceof t5?i:this.annotationStorage;switch(e){case S.DISABLE:r+=64;break;case S.ENABLE:break;case S.ENABLE_FORMS:r+=16;break;case S.ENABLE_STORAGE:r+=32,a=o.serializable;break;default:N(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=128),n&&(r+=256);let{ids:l,hash:h}=o.modifiedIds,d=[r,a.hash,h];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#nr?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#ni.values())t.push(e._destroy());this.#ni.clear(),this.#ns.clear(),this.#nn.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#ne.clear(),this.filterFactory.destroy(),iI.cleanup(),this._networkStream?.cancelAllRequests(new K("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{j(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(j(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}}),t.on("GetRangeReader",(t,e)=>{j(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(j(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new iB(t,this))}),t.on("DocException",t=>{e._capability.reject(ei(t))}),t.on("PasswordRequest",t=>{this.#nr=Promise.withResolvers();try{if(!e.onPassword)throw ei(t);let i=t=>{t instanceof Error?this.#nr.reject(t):this.#nr.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#nr.reject(t)}return this.#nr.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#ni.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){let t=s.error;N(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let n=new t6(new it(s),this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s.extra,s.charProcOperatorList);this.fontLoader.bind(n).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!n.fontExtraProperties&&n.data&&n.clearData(),this.commonObjs.resolve(e,n)});break;case"CopyLocalImage":let{imageRef:r}=s;for(let t of(j(r,"The imageRef must be defined."),this.#ni.values()))for(let[,i]of t.objs)if(i?.ref===r){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let n=this.#ni.get(e);if(!n.objs.has(t)){if(0===n._intentStates.size)return void s?.bitmap?.close();switch(i){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");let e=this[t.type];if(!e)throw Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&N("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#ns.get(e);if(i)return i;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw Error("Transport destroyed");i.refStr&&this.#nn.set(i.refStr,t);let s=new iN(e,i,this,this._params.pdfBug);return this.#ni.set(e,s),s});return this.#ns.set(e,s),s}getPageIndex(t){return t9(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#na("GetFieldObjects")}hasJSActions(){return this.#na("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#na("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#na("GetOptionalContentConfig").then(e=>new ia(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#ne.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new ii(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#ne.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#ni.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#ne.clear(),this.filterFactory.destroy(!0),iI.cleanup()}}cachedPageNumber(t){if(!t9(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#nn.get(e)??null}}class iU{#no=null;onContinue=null;onError=null;constructor(t){this.#no=t}get promise(){return this.#no.capability.promise}cancel(t=0){this.#no.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#no.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#no;return t.form||t.canvas&&e?.size>0}}class iz{#nl=null;static #nh=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new iU(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=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(iz.#nh.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.");iz.#nh.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:i,transform:s,background:n,dependencyTracker:r}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new e8(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#nl&&(window.cancelAnimationFrame(this.#nl),this.#nl=null),iz.#nh.delete(this._canvas),t||=new tg(`Rendering cancelled, page ${this._pageIndex+1}`,e),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.#nl=window.requestAnimationFrame(()=>{this.#nl=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(),iz.#nh.delete(this._canvas),this.callback())))}}let iH="5.4.296",i$="f56dc8601";class iV{#nd=null;#nc=null;#nu;#np=null;#ng=!1;#nm=!1;#r=null;#nf;#nb=null;#b=null;static #nv=null;static get _keyboardManager(){return H(this,"_keyboardManager",new tq([[["Escape","mac+Escape"],iV.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],iV.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],iV.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],iV.prototype._moveToPrevious],[["Home","mac+Home"],iV.prototype._moveToBeginning],[["End","mac+End"],iV.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#nm=!1,this.#r=t):this.#nm=!0,this.#b=t?._uiManager||e,this.#nf=this.#b._eventBus,this.#nu=t?.color?.toUpperCase()||this.#b?.highlightColors.values().next().value||"#FFFF98",iV.#nv||=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 t=this.#nd=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r&&(t.ariaControls=`${this.#r.id}_colorpicker_dropdown`);let e=this.#b._signal;t.addEventListener("click",this.#ny.bind(this),{signal:e}),t.addEventListener("keydown",this.#nw.bind(this),{signal:e});let i=this.#nc=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#nu,t.append(i),t}renderMainDropdown(){let t=this.#np=this.#nx();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#nx(){let t=document.createElement("div"),e=this.#b._signal;for(let[i,s]of(t.addEventListener("contextmenu",tx,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r&&(t.id=`${this.#r.id}_colorpicker_dropdown`),this.#b.highlightColors)){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",iV.#nv[i]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===this.#nu,n.addEventListener("click",this.#nA.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#nw.bind(this),{signal:e}),t}#nA(t,e){e.stopPropagation(),this.#nf.dispatch("switchannotationeditorparams",{source:this,type:P.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#nd)return void this.#ny(t);let e=t.target.getAttribute("data-color");e&&this.#nA(e,t)}_moveToNext(t){this.#n_?t.target===this.#nd?this.#np.firstChild?.focus():t.target.nextSibling?.focus():this.#ny(t)}_moveToPrevious(t){if(t.target===this.#np?.firstChild||t.target===this.#nd){this.#n_&&this._hideDropdownFromKeyboard();return}this.#n_||this.#ny(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#n_?this.#np.firstChild?.focus():this.#ny(t)}_moveToEnd(t){this.#n_?this.#np.lastChild?.focus():this.#ny(t)}#nw(t){iV._keyboardManager.exec(this,t)}#ny(t){if(this.#n_)return void this.hideDropdown();if(this.#ng=0===t.detail,this.#nb||(this.#nb=new AbortController,window.addEventListener("pointerdown",this.#u.bind(this),{signal:this.#b.combinedSignal(this.#nb)})),this.#nd.ariaExpanded="true",this.#np)return void this.#np.classList.remove("hidden");let e=this.#np=this.#nx();this.#nd.append(e)}#u(t){this.#np?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#np?.classList.add("hidden"),this.#nd.ariaExpanded="false",this.#nb?.abort(),this.#nb=null}get #n_(){return this.#np&&!this.#np.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#nm){if(!this.#n_)return void this.#r?.unselect();this.hideDropdown(),this.#nd.focus({preventScroll:!0,focusVisible:this.#ng})}}updateColor(t){if(this.#nc&&(this.#nc.style.backgroundColor=t),!this.#np)return;let e=this.#b.highlightColors.values();for(let i of this.#np.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#nd?.remove(),this.#nd=null,this.#nc=null,this.#np?.remove(),this.#np=null}}class iG{#nC=null;#r=null;#b=null;static #nv=null;constructor(t){this.#r=t,this.#b=t._uiManager,iG.#nv||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#nC)return this.#nC;let{editorType:t,colorType:e,colorValue:i}=this.#r,s=this.#nC=document.createElement("input");return s.type="color",s.value=i||"#000000",s.className="basicColorPicker",s.tabIndex=0,s.setAttribute("data-l10n-id",iG.#nv[t]),s.addEventListener("input",()=>{this.#b.updateParams(e,s.value)},{signal:this.#b._signal}),s}update(t){this.#nC&&(this.#nC.value=t)}destroy(){this.#nC?.remove(),this.#nC=null}hideDropdown(){}}function iW(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function iq(t){return Math.max(0,Math.min(255,255*t))}class iX{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=iq(t),t,t]}static G_HTML([t]){let e=iW(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(iq)}static RGB_HTML(t){return`#${t.map(iW).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[iq(1-Math.min(1,t+s)),iq(1-Math.min(1,i+s)),iq(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,n=1-e,r=1-i,a=Math.min(s,n,r);return["CMYK",s,n,r,a]}}class iK{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){O("Abstract method `_createSVG` called.")}}class iY extends iK{_createSVG(t){return document.createElementNS(td,t)}}let iQ=new WeakSet,iJ=60*new Date().getTimezoneOffset()*1e3;class iZ{static create(t){switch(t.data.annotationType){case D.LINK:return new i2(t);case D.TEXT:return new i3(t);case D.WIDGET:switch(t.data.fieldType){case"Tx":return new i4(t);case"Btn":if(t.data.radioButton)return new i9(t);if(t.data.checkBox)return new i8(t);return new i7(t);case"Ch":return new st(t);case"Sig":return new i6(t)}return new i5(t);case D.POPUP:return new se(t);case D.FREETEXT:return new ss(t);case D.LINE:return new sn(t);case D.SQUARE:return new sr(t);case D.CIRCLE:return new sa(t);case D.POLYLINE:return new so(t);case D.CARET:return new sh(t);case D.INK:return new sd(t);case D.POLYGON:return new sl(t);case D.HIGHLIGHT:return new sc(t);case D.UNDERLINE:return new su(t);case D.SQUIGGLY:return new sp(t);case D.STRIKEOUT:return new sg(t);case D.STAMP:return new sm(t);case D.FILEATTACHMENT:return new sf(t);default:return new i0(t)}}}class i0{#nS=null;#nE=!1;#nT=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return i0._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:s}=this.data,n=-1/0,r=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>r?(r=e[t+1],n=e[t+2]):e[t+1]===r&&(n=Math.max(n,e[t+2]));return[n,r]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>r?(r=t[e+1],n=t[e]):t[e+1]===r&&(n=Math.max(n,t[e]));if(n!==1/0)return[n,r]}return s?[s[2],s[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/i,t[1]=100*(t[1]-r)/s,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${E}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${E}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#nT?.popup||this.popup)?.remove(),this.#nT=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#nS||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#nP(e);let s=this.#nT?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#nT.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#nT=null,this.popup=null))}resetEdited(){this.#nS&&(this.#nP(this.#nS.rect),this.#nT?.popup.resetEdited(),this.#nS=null)}#nP(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,0===s?(e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/r}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof i5||this instanceof i2||(n.tabIndex=0);let{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof se){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?r.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof i9&&(r.borderRadius=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:N("Unimplemented border style: beveled");break;case 4:N("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#nE=!0,r.borderColor=tt.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}let l=tt.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=`${100*(l[0]-c)/h}%`,r.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=`${100*a/h}%`,r.height=`${100*o/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),e.style.width=`${100*n/i}%`,e.style.height=`${100*r/s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=iX[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:iX[`${n}_rgb`](r)})};return H(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,n]of Object.entries(e)){let r=i[s];r&&(r({detail:{[s]:n},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,n,r]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,a,o,l]=e.subarray(2,6);if(n===t&&r===a&&i===o&&s===l)return}let{style:a}=this.container;if(this.#nE){let{borderColor:e,borderWidth:i}=a;a.borderWidth=0,t=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=n-i,l=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,n=e.length;s<n;s+=8){let n=e[s],a=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,m=(r-a)/l,f=(n-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#nE&&(t.push("</g></svg>')"),a.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let e,i,{data:s}=this;t?(e={str:t.text},i=t.date):(e=s.contentsObj,i=s.modificationDate);let n=this.#nT=new se({data:{color:s.color,titleObj:s.titleObj,modificationDate:i,contentsObj:e,richText:s.richText,parentRect:s.rect,borderStyle:0,id:`popup_${s.id}`,rotation:s.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]});this.parent._commentManager||this.parent.div.append(n.render())}get hasPopupElement(){return!!(this.#nT||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#nT}render(){O("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:n,exportValues:r}of s){if(-1===t||n===e)continue;let s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);if(a&&!iQ.has(a)){N(`_getElementsByName - element not allowed: ${n}`);continue}i.push({id:n,exportValue:s,domElement:a})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&iQ.has(s)&&i.push({id:n,exportValue:t,domElement:s})}return i}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 t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class i1 extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class i2 extends i0{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(this.#nM(i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#nk(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#nD(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#nD(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#nD()}#nM(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#nD()}#nk(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#nD()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#nD()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#nD(),!this._fieldObjects){N('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===n&&r.push(i)}else for(let t of Object.values(this._fieldObjects))r.push(...t);let a=this.annotationStorage,o=[];for(let t of r){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!iQ.has(i)){N(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class i3 extends i0{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class i5 extends i0{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return J.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})})}_setEventListeners(t,e,i,s){for(let[n,r]of i)("Action"===r||this.data.actions?.[r])&&(("Focus"===r||"Blur"===r)&&(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":tt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style,r=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,r(t/i/1.35))}else e=Math.min(s,r(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));n.fontSize=`calc(${e}px * var(--total-scale-factor))`,n.color=tt.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class i4 extends i5{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){let n=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),n=s.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type=this.data.password?"password":"text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),iQ.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){let t=o.userValue;if(c)if("time"===h){let i=new Date(t);e.value=[i.getHours(),i.getMinutes(),i.getSeconds()].map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-iJ).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s);let n={formattedValue:s};c&&(n.value=s),t.setValue(e,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;r&&!(r.length<=s)&&(n.value=o.userValue=r=r.slice(0,s),t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:i}=t,{value:n}=i;if(c){if(n&&"time"===h){let t=n.split(":").map(t=>parseInt(t,10));n=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else n.includes("T")||(n=`${n}T00:00`),n=new Date(n).valueOf();i.type="text"}o.userValue=n,o.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s,l=r,h=a;switch(t.inputType){case"deleteWordBackward":{let t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else(i=document.createElement("div")).textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class i6 extends i5{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class i8 extends i5{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let n=document.createElement("input");return iQ.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",s=>{let{name:n,checked:r}=s.target;for(let s of this._getElementsByName(n,i)){let i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})}),n.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class i9 extends i5{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let n=document.createElement("input");if(iQ.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",e=>{let{name:s,checked:n}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})}),n.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let n=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class i7 extends i2{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class st extends i5{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");iQ.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}let a=t=>{let e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=a(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){r?.();let n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(let t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){let n=s.options,r=i.detail.remove;n[r].selected=!1,s.remove(r),n.length>0&&-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){let{index:n,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){let{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of n){let{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class se extends i0{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&i0._hasPopupData(e)}),this.elements=i,n&&i0._hasPopupData(e)){const t=this.popup=this.#nI();for(const e of i)e.popup=t}else this.popup=null}#nI(){return new si({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:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#nI(),i=[];for(let t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${tr}${t}`).join(",")),this.container}}class si{#j=null;#nL=this.#nw.bind(this);#nR=this.#nF.bind(this);#nB=this.#nN.bind(this);#nO=this.#nj.bind(this);#nU=null;#tx=null;#nz=null;#nH=null;#n$=null;#nV=null;#nG=null;#nW=!1;#nq=null;#nX=null;#P=null;#nK=null;#nY=null;#es=null;#nQ=null;#t7=null;#nJ=null;#nS=null;#nZ=!1;#n0=null;#n1=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#tx=t,this.#nJ=s,this.#nz=r,this.#t7=a,this.#nV=o,this.#nU=e,this.#nQ=l,this.#nG=h,this.#n$=i,this.#j=c,this.#n0=i[0],this.#nH=t_.toDateObject(n),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),c?this.renderCommentButton():(this.#n2(),this.#tx.hidden=!0,d&&this.#nj())}#n2(){if(this.#nX)return;this.#nX=new AbortController;let{signal:t}=this.#nX;for(let e of this.trigger)e.addEventListener("click",this.#nO,{signal:t}),e.addEventListener("pointerenter",this.#nB,{signal:t}),e.addEventListener("pointerleave",this.#nR,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#n$)e.container?.addEventListener("keydown",this.#nL,{signal:t})}#n3(){let t=this.#n$.find(t=>t.hasCommentButton);t&&(this.#nY=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#nK||(this.#nY||this.#n3(),!this.#nY))return;let{signal:t}=this.#nX=new AbortController,e=!!this.#n0.extraPopupElement,i=()=>{this.#j.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#j.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#j.toggleCommentPopup(this,!1,!1)};if(e)for(let e of(this.#nK=this.#n0.container,this.trigger))e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#nL,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),e.classList.add("popupTriggerArea");else{let e=this.#nK=document.createElement("button");e.className="annotationCommentButton";let r=this.#n0.container;e.style.zIndex=r.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#n5(),this.#n4(),e.addEventListener("keydown",this.#nL,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),r.after(e)}}#n4(){if(this.#n0.extraPopupElement&&!this.#n0.editor)return;this.renderCommentButton();let[t,e]=this.#nY,{style:i}=this.#nK;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#n5(){this.#n0.extraPopupElement||(this.renderCommentButton(),this.#nK.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#n0.commentData;return t?this.#nV._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#nK?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}=this.#n0.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}}get elementBeforePopup(){return this.#nK}get comment(){return this.#n1||=this.#n0.commentText,this.#n1}set comment(t){t!==this.comment&&(this.#n0.commentText=this.#n1=t)}get parentBoundingClientRect(){return this.#n0.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#nK&&(this.#nK.classList.toggle("selected",t),this.#nK.ariaExpanded=e)}setSelectedCommentButton(t){this.#nK.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#es)return this.#es;let{x:t,y:e,height:i}=this.#nK.getBoundingClientRect(),{x:s,y:n,width:r,height:a}=this.#n0.layer.getBoundingClientRect();return[(t-s)/r,(e+i-n)/a]}set commentPopupPosition(t){this.#es=t}hasDefaultPopupPosition(){return null===this.#es}get commentButtonPosition(){return this.#nY}get commentButtonWidth(){return this.#nK.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#es||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=s;this.#j.showDialog(null,this,n+e*a,r+i*o,{...t,parentDimensions:s})}render(){if(this.#nq)return;let t=this.#nq=document.createElement("div");if(t.className="popup",this.#nU){let e=t.style.outlineColor=tt.makeHexColor(...this.#nU);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#nJ?.str){let t=document.createElement("span");t.className="title",e.append(t),{dir:t.dir,str:t.textContent}=this.#nJ}if(t.append(e),this.#nH){let t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#nH.valueOf()})),t.dateTime=this.#nH.toISOString(),e.append(t)}tU({html:this.#n6||this.#nz.str,dir:this.#nz?.dir,className:"popupContent"},t),this.#tx.append(t)}get #n6(){let t=this.#t7,e=this.#nz;return t?.str&&(!e?.str||e.str===t.str)&&this.#t7.html||null}get #n8(){return this.#n6?.attributes?.style?.fontSize||0}get #n9(){return this.#n6?.attributes?.style?.color||null}#n7(t){let e=[],i={style:{color:this.#n9,fontSize:this.#n8?`calc(${this.#n8}px * var(--total-scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}#nw(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#nW)&&this.#nj()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#j){i?(this.remove(),this.#n1=null):e&&(e.deleted?this.remove():(this.#n5(),this.#n1=e.text)),t&&(this.#nY=null,this.#n3(),this.#n4());return}i||e?.deleted?this.remove():(this.#n2(),this.#nS||={contentsObj:this.#nz,richText:this.#t7},t&&(this.#P=null),e&&e.text&&(this.#t7=this.#n7(e.text),this.#nH=t_.toDateObject(e.date),this.#nz=null),this.#nq?.remove(),this.#nq=null)}resetEdited(){this.#nS&&({contentsObj:this.#nz,richText:this.#t7}=this.#nS,this.#nS=null,this.#nq?.remove(),this.#nq=null,this.#P=null)}remove(){if(this.#nX?.abort(),this.#nX=null,this.#nq?.remove(),this.#nq=null,this.#nZ=!1,this.#nW=!1,this.#nK?.remove(),this.#nK=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#rt(){if(null!==this.#P)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nV,r=!!this.#nG,a=r?this.#nG:this.#nQ;for(let t of this.#n$)if(!a||null!==tt.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}let o=tt.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#P=[100*(h-s)/e,100*(d-n)/i];let{style:c}=this.#tx;c.left=`${this.#P[0]}%`,c.top=`${this.#P[1]}%`}#nj(){this.#j?this.#j.toggleCommentPopup(this,!1):(this.#nW=!this.#nW,this.#nW?(this.#nN(),this.#tx.addEventListener("click",this.#nO),this.#tx.addEventListener("keydown",this.#nL)):(this.#nF(),this.#tx.removeEventListener("click",this.#nO),this.#tx.removeEventListener("keydown",this.#nL)))}#nN(){this.#nq||this.render(),this.isVisible?this.#nW&&this.#tx.classList.add("focused"):(this.#rt(),this.#tx.hidden=!1,this.#tx.style.zIndex=parseInt(this.#tx.style.zIndex)+1e3)}#nF(){this.#tx.classList.remove("focused"),!this.#nW&&this.isVisible&&(this.#tx.hidden=!0,this.#tx.style.zIndex=parseInt(this.#tx.style.zIndex)-1e3)}forceHide(){this.#nZ=this.isVisible,this.#nZ&&(this.#tx.hidden=!0)}maybeShow(){this.#j||(this.#n2(),this.#nZ&&(this.#nq||this.#nN(),this.#nZ=!1,this.#tx.hidden=!1))}get isVisible(){return!this.#j&&!1===this.#tx.hidden}}class ss extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=T.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class sn extends i0{#re=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#re=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#re}addHighlightArea(){this.container.classList.add("highlightArea")}}class sr extends i0{#ri=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#ri=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ri}addHighlightArea(){this.container.classList.add("highlightArea")}}class sa extends i0{#rs=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#rs=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#rs}addHighlightArea(){this.container.classList.add("highlightArea")}}class so extends i0{#rn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;let a=this.svgFactory.create(n,r,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");let l=this.#rn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#rn}addHighlightArea(){this.container.classList.add("highlightArea")}}class sl extends so{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class sh extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class sd extends i0{#rr=null;#ra=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?T.HIGHLIGHT:T.INK}#ro(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#ro(e,t),l=this.svgFactory.create(a,o,!0),h=this.#rr=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#ra.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,n=this.#rr;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#ra.length;t<e;t++)this.#ra[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#ro(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#ra}addHighlightArea(){this.container.classList.add("highlightArea")}}class sc extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=T.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class su extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sp extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sg extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){let e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sm extends i0{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=T.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class sf extends i0{#rl=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#rh.bind(this)),this.#rl=t;let{isMac:s}=J.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#rh()}),!i.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#rl}addHighlightArea(){this.container.classList.add("highlightArea")}#rh(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class sb{#rd=null;#rc=null;#B=null;#ru=new Map;#rp=null;#rg=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#rd=e,this.#rc=i,this.#rp=a||null,this.#rg=l||null,this.#B=h||new t3,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return this.#ru.size>0}async #rm(t,e,i){let s=t.firstChild||t,n=s.id=`${tr}${e}`,r=await this.#rp?.getAriaAttributes(n);if(r)for(let[t,e]of r)s.setAttribute(t,e);i?i.at(-1).container.after(t):(this.div.append(t),this.#rd?.moveElementInDOM(this.div,t,s,!1))}async render(t){let{annotations:e}=t,i=this.div;tP(i,this.viewport);let s=new Map,n={data:null,layer:i,linkService:this.#rg,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new iY,annotationStorage:this.#B,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===D.POPUP;if(e){let e=s.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;let i=iZ.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){let e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}let r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#rm(r,t.id,n.elements),i.extraPopupElement?.popup?.renderCommentButton(),i._isEditable&&(this.#ru.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#rf()}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#rg,svgFactory:new iY,parent:this};for(let i of t){i.borderStyle||=sb._defaultBorderStyle,e.data=i;let t=iZ.create(e);if(!t.isRenderable)continue;let s=t.render();await this.#rm(s,i.id,null)}}update({viewport:t}){let e=this.div;this.viewport=t,tP(e,{rotation:t.rotation}),this.#rf(),e.hidden=!1}#rf(){if(!this.#rc)return;let t=this.div;for(let[e,i]of this.#rc){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i);let r=this.#ru.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#rc.clear()}getEditableAnnotations(){return Array.from(this.#ru.values())}getEditableAnnotation(t){return this.#ru.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:i,rotation:s}=t,n=new i1({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#rg,annotationStorage:this.#B}),r=n.render();return e.append(r),this.#rd?.moveElementInDOM(e,r,r,!1),n.createOrUpdatePopup(),n}static get _defaultBorderStyle(){return H(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}let sv=/\r\n?|\n/g;class sy extends tZ{#rb="";#rv=`${this.id}-editor`;#ry=null;#n8;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=sy.prototype,e=t=>t.isEmpty(),i=tK.TRANSLATE_SMALL,s=tK.TRANSLATE_BIG;return H(this,"_keyboardManager",new tq([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=T.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||sy._defaultColor||tZ._defaultLineColor,this.#n8=t.fontSize||sy._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static initialize(t,e){tZ.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case P.FREETEXT_SIZE:sy._defaultFontSize=e;break;case P.FREETEXT_COLOR:sy._defaultColor=e}}updateParams(t,e){switch(t){case P.FREETEXT_SIZE:this.#rw(e);break;case P.FREETEXT_COLOR:this.#n5(e)}}static get defaultPropertiesToUpdate(){return[[P.FREETEXT_SIZE,sy._defaultFontSize],[P.FREETEXT_COLOR,sy._defaultColor||tZ._defaultLineColor]]}get propertiesToUpdate(){return[[P.FREETEXT_SIZE,this.#n8],[P.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new iG(this),[["colorPicker",this._colorPicker]]}get colorType(){return P.FREETEXT_COLOR}#rw(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#n8)*this.parentScale),this.#n8=t,this.#rx()},i=this.#n8;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#n5(t){let e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-sy._internalPadding*t,-(sy._internalPadding+this.#n8)*t]}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(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.#ry=new AbortController;let t=this._uiManager.combinedSignal(this.#ry);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#rv),this._isDraggable=!0,this.#ry?.abort(),this.#ry=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&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()}#rA(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(sy.#r_(i)),e=i);return t.join("\n")}#rx(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,n=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#rb,e=this.#rb=this.#rA().trimEnd();if(t===e)return;let i=t=>{(this.#rb=t,t)?(this.#rC(),this._uiManager.rebuild(this),this.#rx()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#rx()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){sy._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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(){let t,e;if(this.div)return this.div;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#rv),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:i}=this.editorDiv;if(i.fontSize=`calc(${this.#n8}px * var(--total-scale-factor))`,i.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[i,s]=this.parentDimensions;if(this.annotationElementId){let n,r,{position:a}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:n=t+(a[0]-c)/h,r=e+this.height-(a[1]-u)/d;break;case 90:n=t+(a[0]-c)/h,r=e-(a[1]-u)/d,[o,l]=[l,-o];break;case 180:n=t-this.width+(a[0]-c)/h,r=e-(a[1]-u)/d,[o,l]=[-o,-l];break;case 270:n=t+(a[0]-c-this.height*d)/h,r=e+(a[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(n*i,r*s,o,l)}else this._moveAfterPaste(t,e);this.#rC(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #r_(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(sv,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=sy.#rS(e.getData("text")||"").replaceAll(sv,"\n");if(!s)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!s.includes("\n")){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(sv,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(sy.#r_(i))}}l.push(a.nodeValue.slice(0,o).replaceAll(sv,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(sy.#r_(i))}this.#rb=`${l.join("\n")}${s}${h.join("\n")}`,this.#rC();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#rC(){if(this.editorDiv.replaceChildren(),this.#rb)for(let t of this.#rb.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#rE(){return this.#rb.replaceAll(" "," ")}static #rS(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=sy._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof ss){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=t;if(!u||0===u.length)return null;s=t={annotationType:T.FREETEXT,color:Array.from(i),fontSize:e,value:u.join("\n"),position:p,pageIndex:g-1,rect:n.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}let n=await super.deserialize(t,e,i);return n.#n8=t.fontSize,n.color=tt.makeHexColor(...t.color),n.#rb=sy.#rS(t.value),n._initialData=s,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=tZ._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#n8,value:this.#rE()});return(this.addComment(i),t)?(i.isCopy=!0,i):this.annotationElementId&&!this.#rT(i)?null:(i.id=this.annotationElementId,i)}#rT(t){let{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==n}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#n8}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren(),this.#rb.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#rb}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class sw{static PRECISION=1e-4;toSVGPath(){O("Abstract method `toSVGPath` must be implemented.")}get box(){O("Abstract getter `box` must be implemented.")}serialize(t,e){O("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class sx{#rP;#rM=[];#rk;#rD;#rI=[];#rL=new Float32Array(18);#rR;#rF;#rB;#rN;#rO;#rj;#rU=[];static #rz=8;static #rH=2;static #r$=sx.#rz+sx.#rH;constructor({x:t,y:e},i,s,n,r,a=0){this.#rP=i,this.#rj=n*s,this.#rD=r,this.#rL.set([NaN,NaN,NaN,NaN,t,e],6),this.#rk=a,this.#rN=sx.#rz*s,this.#rB=sx.#r$*s,this.#rO=s,this.#rU.push(t,e)}isEmpty(){return isNaN(this.#rL[8])}#rV(){let t=this.#rL.subarray(4,6),e=this.#rL.subarray(16,18),[i,s,n,r]=this.#rP;return[(this.#rR+(t[0]-e[0])/2-i)/n,(this.#rF+(t[1]-e[1])/2-s)/r,(this.#rR+(e[0]-t[0])/2-i)/n,(this.#rF+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#rR=t,this.#rF=e;let[i,s,n,r]=this.#rP,[a,o,l,h]=this.#rL.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#rB)return!1;let p=u-this.#rN,g=p/u,m=g*d,f=g*c,b=a,v=o;a=l,o=h,l+=m,h+=f,this.#rU?.push(t,e);let y=-f/p*this.#rj,w=m/p*this.#rj;return(this.#rL.set(this.#rL.subarray(2,8),0),this.#rL.set([l+y,h+w],4),this.#rL.set(this.#rL.subarray(14,18),12),this.#rL.set([l-y,h-w],16),isNaN(this.#rL[6]))?(0===this.#rI.length&&(this.#rL.set([a+y,o+w],2),this.#rI.push(NaN,NaN,NaN,NaN,(a+y-i)/n,(o+w-s)/r),this.#rL.set([a-y,o-w],14),this.#rM.push(NaN,NaN,NaN,NaN,(a-y-i)/n,(o-w-s)/r)),this.#rL.set([b,v,a,o,l,h],6),!this.isEmpty()):((this.#rL.set([b,v,a,o,l,h],6),Math.abs(Math.atan2(v-o,b-a)-Math.atan2(f,m))<Math.PI/2)?([a,o,l,h]=this.#rL.subarray(2,6),this.#rI.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#rL.subarray(14,18),this.#rM.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r)):([b,v,a,o,l,h]=this.#rL.subarray(0,6),this.#rI.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,v]=this.#rL.subarray(12,18),this.#rM.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#rI,e=this.#rM;if(isNaN(this.#rL[6])&&!this.isEmpty())return this.#rG();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#rW(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#rq(i),i.join(" ")}#rG(){let[t,e,i,s]=this.#rP,[n,r,a,o]=this.#rV();return`M${(this.#rL[2]-t)/i} ${(this.#rL[3]-e)/s} L${(this.#rL[4]-t)/i} ${(this.#rL[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#rL[16]-t)/i} ${(this.#rL[17]-e)/s} L${(this.#rL[14]-t)/i} ${(this.#rL[15]-e)/s} Z`}#rq(t){let e=this.#rM;t.push(`L${e[4]} ${e[5]} Z`)}#rW(t){let[e,i,s,n]=this.#rP,r=this.#rL.subarray(4,6),a=this.#rL.subarray(16,18),[o,l,h,d]=this.#rV();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new sA(t,e,i,s,n,r)}getOutlines(){let t=this.#rI,e=this.#rM,i=this.#rL,[s,n,r,a]=this.#rP,o=new Float32Array((this.#rU?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#rU[t]-s)/r,o[t+1]=(this.#rU[t+1]-n)/a;if(o[o.length-2]=(this.#rR-s)/r,o[o.length-1]=(this.#rF-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#rX(o);let l=new Float32Array(this.#rI.length+24+this.#rM.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#rK(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#rY(l,h),this.newFreeDrawOutline(l,o,this.#rP,this.#rO,this.#rk,this.#rD)}#rX(t){let e=this.#rL,[i,s,n,r]=this.#rP,[a,o,l,h]=this.#rV(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#rP,this.#rO,this.#rk,this.#rD)}#rY(t,e){let i=this.#rM;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#rK(t,e){let i=this.#rL.subarray(4,6),s=this.#rL.subarray(16,18),[n,r,a,o]=this.#rP,[l,h,d,c]=this.#rV();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+=24}}class sA extends sw{#rP;#rQ=new Float32Array(4);#rk;#rD;#rU;#rO;#rJ;constructor(t,e,i,s,n,r){super(),this.#rJ=t,this.#rU=e,this.#rP=i,this.#rO=s,this.#rk=n,this.#rD=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#rZ(r);const[a,o,l,h]=this.#rQ;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#rJ[4]} ${this.#rJ[5]}`];for(let e=6,i=this.#rJ.length;e<i;e+=6){if(isNaN(this.#rJ[e])){t.push(`L${this.#rJ[e+4]} ${this.#rJ[e+5]}`);continue}t.push(`C${this.#rJ[e]} ${this.#rJ[e+1]} ${this.#rJ[e+2]} ${this.#rJ[e+3]} ${this.#rJ[e+4]} ${this.#rJ[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){let r,a,o=i-t,l=s-e;switch(n){case 0:r=sw._rescale(this.#rJ,t,s,o,-l),a=sw._rescale(this.#rU,t,s,o,-l);break;case 90:r=sw._rescaleAndSwap(this.#rJ,t,e,o,l),a=sw._rescaleAndSwap(this.#rU,t,e,o,l);break;case 180:r=sw._rescale(this.#rJ,i,e,-o,l),a=sw._rescale(this.#rU,i,e,-o,l);break;case 270:r=sw._rescaleAndSwap(this.#rJ,i,s,-o,-l),a=sw._rescaleAndSwap(this.#rU,i,s,-o,-l)}return{outline:Array.from(r),points:[Array.from(a)]}}#rZ(t){let e=this.#rJ,i=e[4],s=e[5],n=[i,s,i,s],r=i,a=s,o=i,l=s,h=t?Math.max:Math.min,d=new Float32Array(4);for(let t=6,c=e.length;t<c;t+=6){let c=e[t+4],u=e[t+5];isNaN(e[t])?(tt.pointBoundingBox(c,u,n),a>u?(r=c,a=u):a===u&&(r=h(r,c)),l<u?(o=c,l=u):l===u&&(o=h(o,c))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,tt.bezierBoundingBox(i,s,...e.slice(t,t+6),d),tt.rectBoundingBox(d[0],d[1],d[2],d[3],n),a>d[1]?(r=d[0],a=d[1]):a===d[1]&&(r=h(r,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=h(o,d[2]))),i=c,s=u}let c=this.#rQ;c[0]=n[0]-this.#rk,c[1]=n[1]-this.#rk,c[2]=n[2]-n[0]+2*this.#rk,c[3]=n[3]-n[1]+2*this.#rk,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#rQ}newOutliner(t,e,i,s,n,r=0){return new sx(t,e,i,s,n,r)}getNewOutline(t,e){let[i,s,n,r]=this.#rQ,[a,o,l,h]=this.#rP,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#rU[0]*d+u,y:this.#rU[1]*c+p},this.#rP,this.#rO,t,this.#rD,e??this.#rk);for(let t=2;t<this.#rU.length;t+=2)g.add({x:this.#rU[t]*d+u,y:this.#rU[t+1]*c+p});return g.getOutlines()}}class s_{#rP;#r0;#r1;#r2=[];#r3=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0];for(const{x:i,y:s,width:r,height:a}of t){const t=1e-4*Math.floor((i-e)/1e-4),o=1e-4*Math.ceil((i+r+e)/1e-4),l=1e-4*Math.floor((s-e)/1e-4),h=1e-4*Math.ceil((s+a+e)/1e-4),d=[t,l,h,!0],c=[o,l,h,!1];this.#r2.push(d,c),tt.rectBoundingBox(t,l,o,h,n)}const r=n[2]-n[0]+2*i,a=n[3]-n[1]+2*i,o=n[0]-i,l=n[1]-i;let h=s?-1/0:1/0,d=1/0;const c=this.#r2.at(s?-1:-2),u=[c[0],c[2]];for(const t of this.#r2){const[e,i,n,c]=t;!c&&s?i<d?(d=i,h=e):i===d&&(h=Math.max(h,e)):c&&!s&&(i<d?(d=i,h=e):i===d&&(h=Math.min(h,e))),t[0]=(e-o)/r,t[1]=(i-l)/a,t[2]=(n-l)/a}this.#rP=new Float32Array([o,l,r,a]),this.#r0=[h,d],this.#r1=u}getOutlines(){this.#r2.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#r2)e[3]?(t.push(...this.#r5(e)),this.#r4(e)):(this.#r6(e),t.push(...this.#r5(e)));return this.#r8(t)}#r8(t){let e,i=[],s=new Set;for(let e of t){let[t,s,n]=e;i.push([t,s,e],[t,n,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],n=i[t+1][2];e.push(n),n.push(e),s.add(e),s.add(n)}let n=[];for(;s.size>0;){let t=s.values().next().value,[i,r,a,o,l]=t;s.delete(t);let h=i,d=r;for(e=[i,a],n.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,r,a,o,l]=t,h!==i&&(e.push(h,d,i,d===r?r:a),h=i),d=d===r?a:r}e.push(h,d)}return new sC(n,this.#rP,this.#r0,this.#r1)}#r9(t){let e=this.#r3,i=0,s=e.length-1;for(;i<=s;){let n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#r4([,t,e]){let i=this.#r9(t);this.#r3.splice(i,0,[t,e])}#r6([,t,e]){let i=this.#r9(t);for(let s=i;s<this.#r3.length;s++){let[i,n]=this.#r3[s];if(i!==t)break;if(i===t&&n===e)return void this.#r3.splice(s,1)}for(let s=i-1;s>=0;s--){let[i,n]=this.#r3[s];if(i!==t)break;if(i===t&&n===e)return void this.#r3.splice(s,1)}}#r5(t){let[e,i,s]=t,n=[[e,i,s]],r=this.#r9(s);for(let t=0;t<r;t++){let[i,s]=this.#r3[t];for(let t=0,r=n.length;t<r;t++){let[,a,o]=n[t];if(!(s<=a)&&!(o<=i)){if(a>=i){if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}continue}n[t][2]=i,o>s&&n.push([e,s,o])}}}return n}}class sC extends sw{#rP;#r7;constructor(t,e,i,s){super(),this.#r7=t,this.#rP=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#r7){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){let r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){let r=[],a=i-t,o=s-e;for(let e of this.#r7){let i=Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#rP}get classNamesForOutlining(){return["highlightOutline"]}}class sS extends sx{newFreeDrawOutline(t,e,i,s,n,r){return new sE(t,e,i,s,n,r)}}class sE extends sA{newOutliner(t,e,i,s,n,r=0){return new sS(t,e,i,s,n,r)}}class sT extends tZ{#at=null;#ae=0;#ai;#as=null;#n=null;#an=null;#ar=null;#aa=0;#ao=null;#al=null;#x=null;#ah=!1;#r0=null;#r1=null;#ad=null;#et="";#rj;#ac="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=T.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=sT.prototype;return H(this,"_keyboardManager",new tq([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||sT._defaultColor,this.#rj=t.thickness||sT._defaultThickness,this.opacity=t.opacity||sT._defaultOpacity,this.#ai=t.boxes||null,this.#ac=t.methodOfCreation||"",this.#et=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#ah=!0,this.#au(t),this.#ap()):this.#ai&&(this.#at=t.anchorNode,this.#ae=t.anchorOffset,this.#ar=t.focusNode,this.#aa=t.focusOffset,this.#ag(),this.#ap(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#ah?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#rj,methodOfCreation:this.#ac}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ag(){let t=new s_(this.#ai,.001);this.#al=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#al.box;let e=new s_(this.#ai,.0025,.001,"ltr"===this._uiManager.direction);this.#an=e.getOutlines();let{firstPoint:i}=this.#al;this.#r0=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:s}=this.#an;this.#r1=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#au({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#al=t,this.#an=t.getNewOutline(this.#rj/2+1.5,.0025),e>=0)this.#x=e,this.#as=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ad=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#an.box,path:{d:this.#an.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#x,{bbox:sT.#am(this.#al.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ad,{bbox:sT.#am(this.#an.box,e),path:{d:this.#an.toSVGPath()}})}let[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e}}let{firstPoint:o}=t;this.#r0=[(o[0]-s)/r,(o[1]-n)/a];let{lastPoint:l}=this.#an;this.#r1=[(l[0]-s)/r,(l[1]-n)/a]}static initialize(t,e){tZ.initialize(t,e),sT._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case P.HIGHLIGHT_COLOR:sT._defaultColor=e;break;case P.HIGHLIGHT_THICKNESS:sT._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#r1}get commentButtonPosition(){return this.#r0}updateParams(t,e){switch(t){case P.HIGHLIGHT_COLOR:this.#n5(e);break;case P.HIGHLIGHT_THICKNESS:this.#af(e)}}static get defaultPropertiesToUpdate(){return[[P.HIGHLIGHT_COLOR,sT._defaultColor],[P.HIGHLIGHT_THICKNESS,sT._defaultThickness]]}get propertiesToUpdate(){return[[P.HIGHLIGHT_COLOR,this.color||sT._defaultColor],[P.HIGHLIGHT_THICKNESS,this.#rj||sT._defaultThickness],[P.HIGHLIGHT_FREE,this.#ah]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#x,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#n?.updateColor(this.color),super.onUpdatedColor()}#n5(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,sT._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#af(t){let e=this.#rj,i=t=>{this.#rj=t,this.#ab(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#n=new iV({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.#av())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#av())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#ay(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#ap(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#ay():t&&(this.#ap(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#ab(t){this.#ah&&(this.#au({highlightOutlines:this.#al.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))}#ay(){null!==this.#x&&this.parent&&(this.parent.drawLayer.remove(this.#x),this.#x=null,this.parent.drawLayer.remove(this.#ad),this.#ad=null)}#ap(t=this.parent){null===this.#x&&({id:this.#x,clipPathId:this.#as}=t.drawLayer.draw({bbox:this.#al.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#ah},path:{d:this.#al.toSVGPath()}},!1,!0),this.#ad=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ah},bbox:this.#an.box,path:{d:this.#an.toSVGPath()}},this.#ah),this.#ao&&(this.#ao.style.clipPath=this.#as))}static #am([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){let e,{drawLayer:i}=this.parent;this.#ah?(t=(t-this.rotation+360)%360,e=sT.#am(this.#al.box,t)):e=sT.#am([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#x,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#ad,{bbox:sT.#am(this.#an.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#et&&(t.setAttribute("aria-label",this.#et),t.setAttribute("role","mark")),this.#ah?t.classList.add("free"):this.div.addEventListener("keydown",this.#aw.bind(this),{signal:this._uiManager._signal});let e=this.#ao=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#as,this.setDims(this.width,this.height),t$(this,this.#ao,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!1}})}#aw(t){sT._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ax(!0);break;case 1:case 3:this.#ax(!1)}}#ax(t){if(!this.#at)return;let e=window.getSelection();t?e.setPosition(this.#at,this.#ae):e.setPosition(this.#ar,this.#aa)}select(){super.select(),this.#ad&&this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ad&&(this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{selected:!1}}),this.#ah||this.#ax(!1))}get _mustFixPosition(){return!this.#ah}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#x,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ad,{rootClass:{hidden:!t}}))}#av(){return this.#ah?this.rotation:0}#aA(){if(this.#ah)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#ai,r=new Float32Array(8*n.length),a=0;for(let{x:o,y:l,width:h,height:d}of n){let n=o*t+i,c=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#a_(t){return this.#al.serialize(t,this.#av())}static startHighlighting(t,e,{target:i,x:s,y:n}){let{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#aC(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",tA,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",tx,{signal:d}),i.addEventListener("pointermove",this.#aS.bind(this,t),{signal:d}),this._freeHighlight=new sS({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.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 #aS(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #aC(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!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(t,e,i){let s=null;if(t instanceof sc){let{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:T.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}else if(t instanceof sd){let{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:T.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}let{color:n,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=tt.makeHexColor(...n),l.opacity=o||1,a&&(l.#rj=t.thickness),l._initialData=s,t.comment&&l.setCommentData(t);let[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){let t=l.#ai=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-c)/h,y:1-(r[e+1]-u)/d,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/d});l.#ag(),l.#ap(),l.rotate(l.rotation)}else if(a){l.#ah=!0;let t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new sS(i,[0,0,h,d],1,l.#rj/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),s.add(i);let{id:n,clipPathId:r}=e.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:s.toSVGPath()}},!0,!0);l.#au({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#ap(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=tZ._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return(Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#rj,quadPoints:this.#aA(),outlines:this.#a_(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#rT(i))?null:(i.id=this.annotationElementId,i)}#rT(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class sP{#aE=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#aE[t]=e}toSVGProperties(){let t=this.#aE;return this.#aE=Object.create(null),{root:t}}reset(){this.#aE=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){O("Not implemented")}}class sM extends tZ{#aT=null;#aP;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #aM=null;static #ak=null;static #aD=null;static #aI=NaN;static #aL=null;static #aR=null;static #aF=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#aP=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(this.#aB(t),this.#ap())}#aB({drawOutlines:t,drawId:e,drawingOptions:i}){this.#aT=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#aN(t,this.parent),this.#aO(t.box)}#aN(t,e){let{id:i}=e.drawLayer.draw(sM._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){O("Not implemented")}static get typesMap(){O("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(sM.#aM.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,n=s[e],r=i=>{s.updateProperty(e,i);let n=this.#aT.updateProperty(e,i);n&&this.#aO(n),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,sM._mergeSVGProperties(this.#aT.getPathResizingSVGProperties(this.#aj()),{bbox:this.#aU()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sM._mergeSVGProperties(this.#aT.getPathResizedSVGProperties(this.#aj()),{bbox:this.#aU()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#aU()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sM._mergeSVGProperties(this.#aT.getPathTranslatedSVGProperties(this.#aj(),this.parentDimensions),{bbox:this.#aU()}))}_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(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#aP&&(this.#aP=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#ay(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#ap(),this.#aO(this.#aT.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#ay()):t&&(this._uiManager.addShouldRescale(this),this.#ap(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#ay(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ap(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#aN(this.#aT,t)}}#az([t,e,i,s]){let{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,r/n*i,n/r*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,r/n*i,n/r*s];default:return[t,e,i,s]}}#aj(){let{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,n/r*i,r/n*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,n/r*i,r/n*s];default:return[t,e,i,s]}}#aO(t){[this.x,this.y,this.width,this.height]=this.#az(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#aU(){let{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-a/o*i,o/a*s,a/o*i];case 5:return[1-e,t,a/o*i,o/a*s];case 6:return[1-t-o/a*s,1-e,o/a*s,a/o*i];case 7:return[e-a/o*i,1-t-o/a*s,a/o*i,o/a*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/a*s,e,o/a*s,a/o*i];case 13:return[1-e-a/o*i,t-o/a*s,a/o*i,o/a*s];case 14:return[1-t,1-e-a/o*i,o/a*s,a/o*i];case 15:return[e,1-t,a/o*i,o/a*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,sM._mergeSVGProperties({bbox:this.#aU()},this.#aT.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#aO(this.#aT.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){let t,e;if(this.div)return this.div;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){O("Not implemented")}static startDrawing(t,e,i,s){let{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(sM.#aL&&sM.#aL!==l)return;let{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=sM.#ak=new AbortController,p=t.combinedSignal(u);(sM.#aI||=o,sM.#aL??=l,window.addEventListener("pointerup",t=>{sM.#aI===t.pointerId?this._endDraw(t):sM.#aR?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointercancel",t=>{sM.#aI===t.pointerId?this._currentParent.endDrawingSession():sM.#aR?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointerdown",t=>{sM.#aL===t.pointerType&&((sM.#aR||=new Set).add(t.pointerId),sM.#aM.isCancellable()&&(sM.#aM.removeLastElement(),sM.#aM.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",tx,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",t=>{t.timeStamp===sM.#aF&&tA(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sM.#aM)?t.drawLayer.updateProperties(this._currentDrawId,sM.#aM.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),sM.#aM=this.createDrawerInstance(r,a,d,c,h),sM.#aD=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sM.#aD.toSVGProperties(),sM.#aM.defaultSVGProperties),!0,!1))}static _drawMove(t){if(sM.#aF=-1,!sM.#aM)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(sM.#aI===s){if(sM.#aR?.size>=1)return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,sM.#aM.add(e,i)),sM.#aF=t.timeStamp,tA(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sM.#aM=null,sM.#aD=null,sM.#aL=null,sM.#aF=NaN),sM.#ak&&(sM.#ak.abort(),sM.#ak=null,sM.#aI=NaN,sM.#aR=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,sM.#aM.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=sM.#aM,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:P.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(P.DRAW_STEP),!sM.#aM.isEmpty()){let{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sM.#aM.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:sM.#aD,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){O("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#aB({drawOutlines:o}),l.#ap(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#aT.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class sk{#rL=new Float64Array(6);#re;#aH;#sM;#rj;#rU;#a$="";#aV=0;#r7=new sD;#aG;#aW;constructor(t,e,i,s,n,r){this.#aG=i,this.#aW=s,this.#sM=n,this.#rj=r,[t,e]=this.#aq(t,e);const a=this.#re=[NaN,NaN,NaN,NaN,t,e];this.#rU=[t,e],this.#aH=[{line:a,points:this.#rU}],this.#rL.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#rj=e)}#aq(t,e){return sw._normalizePoint(t,e,this.#aG,this.#aW,this.#sM)}isEmpty(){return!this.#aH||0===this.#aH.length}isCancellable(){return this.#rU.length<=10}add(t,e){[t,e]=this.#aq(t,e);let[i,s,n,r]=this.#rL.subarray(2,6),a=t-n,o=e-r;return 2>=Math.hypot(this.#aG*a,this.#aW*o)?null:((this.#rU.push(t,e),isNaN(i))?(this.#rL.set([n,r,t,e],2),this.#re.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#rL[0])&&this.#re.splice(6,6),this.#rL.set([i,s,n,r,t,e],0),this.#re.push(...sw.createBezierPoints(i,s,n,r,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);return i||(2===this.#rU.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#aG=i,this.#aW=s,this.#sM=n,[t,e]=this.#aq(t,e);let r=this.#re=[NaN,NaN,NaN,NaN,t,e];this.#rU=[t,e];let a=this.#aH.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#aH.push({line:r,points:this.#rU}),this.#rL.set(r,0),this.#aV=0,this.toSVGPath(),null}getLastElement(){return this.#aH.at(-1)}setLastElement(t){return this.#aH?(this.#aH.push(t),this.#re=t.line,this.#rU=t.points,this.#aV=0,{path:{d:this.toSVGPath()}}):this.#r7.setLastElement(t)}removeLastElement(){if(!this.#aH)return this.#r7.removeLastElement();this.#aH.pop(),this.#a$="";for(let t=0,e=this.#aH.length;t<e;t++){let{line:e,points:i}=this.#aH[t];this.#re=e,this.#rU=i,this.#aV=0,this.toSVGPath()}return{path:{d:this.#a$}}}toSVGPath(){let t=sw.svgRound(this.#re[4]),e=sw.svgRound(this.#re[5]);if(2===this.#rU.length)return this.#a$=`${this.#a$} M ${t} ${e} Z`,this.#a$;if(this.#rU.length<=6){let i=this.#a$.lastIndexOf("M");this.#a$=`${this.#a$.slice(0,i)} M ${t} ${e}`,this.#aV=6}if(4===this.#rU.length){let t=sw.svgRound(this.#re[10]),e=sw.svgRound(this.#re[11]);return this.#a$=`${this.#a$} L ${t} ${e}`,this.#aV=12,this.#a$}let i=[];0===this.#aV&&(i.push(`M ${t} ${e}`),this.#aV=6);for(let t=this.#aV,e=this.#re.length;t<e;t+=6){let[e,s,n,r,a,o]=this.#re.slice(t,t+6).map(sw.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#a$+=i.join(" "),this.#aV=this.#re.length,this.#a$}getOutlines(t,e,i,s){let n=this.#aH.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#r7.build(this.#aH,t,e,i,this.#sM,this.#rj,s),this.#rL=null,this.#re=null,this.#aH=null,this.#a$=null,this.#r7}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class sD extends sw{#rQ;#aX=0;#rk;#aH;#aG;#aW;#aK;#sM;#rj;build(t,e,i,s,n,r,a){this.#aG=e,this.#aW=i,this.#aK=s,this.#sM=n,this.#rj=r,this.#rk=a??0,this.#aH=t,this.#aY()}get thickness(){return this.#rj}setLastElement(t){return this.#aH.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#aH.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#aH){if(t.push(`M${sw.svgRound(e[4])} ${sw.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length&&isNaN(e[6])){t.push(`L${sw.svgRound(e[10])} ${sw.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,n,r,a,o,l]=e.subarray(i,i+6).map(sw.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],n){let r,a,o,l,h,d,c,u,p,g=[],m=[],[f,b,v,y]=this.#aQ();switch(this.#sM){case 0:p=sw._rescale,r=t,a=e+s,o=i,l=-s,h=t+f*i,d=e+(1-b-y)*s,c=t+(f+v)*i,u=e+(1-b)*s;break;case 90:p=sw._rescaleAndSwap,r=t,a=e,o=i,l=s,h=t+b*i,d=e+f*s,c=t+(b+y)*i,u=e+(f+v)*s;break;case 180:p=sw._rescale,r=t+i,a=e,o=-i,l=s,h=t+(1-f-v)*i,d=e+b*s,c=t+(1-f)*i,u=e+(b+y)*s;break;case 270:p=sw._rescaleAndSwap,r=t+i,a=e+s,o=-i,l=-s,h=t+(1-b-y)*i,d=e+(1-f-v)*s,c=t+(1-b)*i,u=e+(1-f)*s}for(let{line:t,points:e}of this.#aH)g.push(p(t,r,a,o,l,n?Array(t.length):null)),m.push(p(e,r,a,o,l,n?Array(e.length):null));return{lines:g,points:m,rect:[h,d,c,u]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=sw._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=sw._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=sw._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=sw._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!r)for(let t of(r=[],a)){let e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){let e=t[r],l=t[r+1];i.set(sw.createBezierPoints(s,n,a,o,e,l),(r-2)*3),[s,n,a,o]=[a,o,e,l]}}for(let t=0,e=r.length;t<e;t++)g.push({line:p(r[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let m=new this.prototype.constructor;return m.build(g,i,s,1,o,l,n),m}#aJ(t=this.#rj){let e=this.#rk+t/2*this.#aK;return this.#sM%180==0?[e/this.#aG,e/this.#aW]:[e/this.#aW,e/this.#aG]}#aQ(){let[t,e,i,s]=this.#rQ,[n,r]=this.#aJ(0);return[t+n,e+r,i-2*n,s-2*r]}#aY(){let t=this.#rQ=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:e}of this.#aH){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)tt.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){let[r,a,o,l,h,d]=e.subarray(n,n+6);tt.bezierBoundingBox(i,s,r,a,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#aJ();t[0]=ta(t[0]-e,0,1),t[1]=ta(t[1]-i,0,1),t[2]=ta(t[2]+e,0,1),t[3]=ta(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#rQ}updateProperty(t,e){return"stroke-width"===t?this.#af(e):null}#af(t){let[e,i]=this.#aJ();this.#rj=t;let[s,n]=this.#aJ(),[r,a]=[s-e,n-i],o=this.#rQ;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[s,n]=this.#aJ();this.#aG=t,this.#aW=e,this.#aK=i;let[r,a]=this.#aJ(),o=r-s,l=a-n,h=this.#rQ;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#aX=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#rQ.map(sw.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#rQ;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sw.svgRound(t)} ${sw.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#rQ,i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#aX){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${sw.svgRound(a)} ${sw.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[n,r]=this.#aJ(),[a,o,l,h]=this.#rQ;if(Math.abs(l-n)<=sw.PRECISION||Math.abs(h-r)<=sw.PRECISION){let n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${sw.svgRound(t)} ${sw.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}let d=(i-2*n)/(l-2*n),c=(s-2*r)/(h-2*r);return{path:{"transform-origin":`${sw.svgRound(a)} ${sw.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${sw.svgRound(n)} ${sw.svgRound(r)}) scale(${d} ${c}) translate(${sw.svgRound(-n)} ${sw.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[n,r]=this.#aJ(),a=this.#rQ,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=sw.PRECISION||Math.abs(d-r)<=sw.PRECISION){let n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#aH)sw._translate(t,n,r,t),sw._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sw.svgRound(t)} ${sw.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*n)/(h-2*n),u=(s-2*r)/(d-2*r),p=-c*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#aH)sw._rescale(t,p,g,c,u,t),sw._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sw.svgRound(t)} ${sw.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,n]=i,r=this.#rQ,a=t-r[0],o=e-r[1];if(this.#aG===s&&this.#aW===n)for(let{line:t,points:e}of this.#aH)sw._translate(t,a,o,t),sw._translate(e,a,o,e);else{let t=this.#aG/s,e=this.#aW/n;for(let{line:i,points:r}of(this.#aG=s,this.#aW=n,this.#aH))sw._rescale(i,a,o,t,e,i),sw._rescale(r,a,o,t,e,r);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${sw.svgRound(t)} ${sw.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#rQ;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${sw.svgRound(t[0])} ${sw.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class sI extends sP{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:tZ._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new sI(this._viewParameters);return t.updateAll(this),t}}class sL extends sM{static _type="ink";static _editorType=T.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){tZ.initialize(t,e),this._defaultDrawingOptions=new sI(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return H(this,"typesMap",new Map([[P.INK_THICKNESS,"stroke-width"],[P.INK_COLOR,"stroke"],[P.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new sk(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return sD.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof sd){let{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:T.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}let n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new iG(this),[["colorPicker",this._colorPicker]]}get colorType(){return P.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=sL.getDefaultDrawingOptions({stroke:tt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:tZ._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:e,points:i}});return(this.addComment(a),t)?(a.isCopy=!0,a):this.annotationElementId&&!this.#rT(a)?null:(a.id=this.annotationElementId,a)}#rT(t){let{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class sR extends sD{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class sF{static #aZ={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static #a0(t,e,i,s){return(i-=t,s-=e,0===i)?s>0?0:4:1===i?s+6:2-s}static #a1=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static #a2(t,e,i,s,n,r,a){let o=this.#a0(i,s,n,r);for(let n=0;n<8;n++){let r=(-n+o-a+16)%8;if(0!==t[(i+this.#a1[2*r])*e+(s+this.#a1[2*r+1])])return r}return -1}static #a3(t,e,i,s,n,r,a){let o=this.#a0(i,s,n,r);for(let n=0;n<8;n++){let r=(n+o+a+16)%8;if(0!==t[(i+this.#a1[2*r])*e+(s+this.#a1[2*r+1])])return r}return -1}static #a5(t,e,i,s){let n,r=t.length,a=new Int32Array(r);for(let e=0;e<r;e++)a[e]=+(t[e]<=s);for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let o=1,l=[];for(let t=1;t<i-1;t++){n=1;for(let i=1;i<e-1;i++){let s,r=t*e+i,h=a[r];if(0===h)continue;let d=t,c=i;if(1===h&&0===a[r-1])o+=1,c-=1;else if(h>=1&&0===a[r+1])o+=1,c+=1,h>1&&(n=h);else{1!==h&&(n=Math.abs(h));continue}let u=[i,t],p=c===i+1,g={isHole:p,points:u,id:o,parent:0};for(let t of(l.push(g),l))if(t.id===n){s=t;break}s?s.isHole?g.parent=p?s.parent:n:g.parent=p?n:s.parent:g.parent=p?n:0;let m=this.#a2(a,e,t,i,d,c,0);if(-1===m){a[r]=-o,1!==a[r]&&(n=Math.abs(a[r]));continue}let f=this.#a1[2*m],b=this.#a1[2*m+1],v=t+f,y=i+b;d=v,c=y;let w=t,x=i;for(;;){let s=this.#a3(a,e,w,x,d,c,1);f=this.#a1[2*s],b=this.#a1[2*s+1];let l=w+f,h=x+b;u.push(h,l);let p=w*e+x;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&h===i&&w===v&&x===y){1!==a[r]&&(n=Math.abs(a[r]));break}d=w,c=x,w=l,x=h}}}return l}static #a4(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}let n=t[e],r=t[e+1],a=t[i-4]-n,o=t[i-3]-r,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*r-d*n,u=1/l,p=Math.atan(o/a),g=Math.cos(p),m=Math.sin(p),f=u*(Math.abs(g)+Math.abs(m)),b=u*(1-f+f**2),v=Math.max(Math.atan(Math.abs(m+g)*b),Math.atan(Math.abs(m-g)*b)),y=0,w=e;for(let s=e+2;s<i-2;s+=2){let e=Math.abs(c-h*t[s+1]+d*t[s]);e>y&&(w=s,y=e)}y>(l*v)**2?(this.#a4(t,e,w+2,s),this.#a4(t,w,i,s)):s.push(n,r)}static #a6(t){let e=[],i=t.length;return this.#a4(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static #a8(t,e,i,s,n,r){let a=new Float32Array(r**2),o=-2*s**2,l=r>>1;for(let t=0;t<r;t++){let e=(t-l)**2;for(let i=0;i<r;i++)a[t*r+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*n**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=new Uint8Array(t.length),u=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){let o=s*e+n,d=t[o],p=0,g=0;for(let o=0;o<r;o++){let c=s+o-l;if(!(c<0)&&!(c>=i))for(let i=0;i<r;i++){let s=n+i-l;if(s<0||s>=e)continue;let u=t[c*e+s],m=a[o*r+i]*h[Math.abs(u-d)];p+=u*m,g+=m}}let m=c[o]=Math.round(p/g);u[m]++}return[c,u]}static #a9(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static #a7(t){let e=new Uint8ClampedArray(t.length>>2),i=-1/0,s=1/0;for(let n=0,r=e.length;n<r;n++){let r=e[n]=t[n<<2];i=Math.max(i,r),s=Math.min(s,r)}let n=255/(i-s);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-s)*n;return e}static #ot(t){let e,i=-1/0,s=-1/0,n=t.findIndex(t=>0!==t),r=n,a=n;for(e=n;e<256;e++){let n=t[e];n>i&&(e-r>s&&(s=e-r,a=e-1),i=n,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static #oe(t){let e=t,{width:i,height:s}=t,{maxDim:n}=this.#aZ,r=i,a=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){let i=new OffscreenCanvas(r=Math.ceil(o/2),a=Math.ceil(l/2));i.getContext("2d").drawImage(t,0,0,o,l,0,0,r,a),o=r,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(n/r,n/a);r=Math.round(r*c),a=Math.round(a*c)}let o=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,r,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,r,a);let l=o.getImageData(0,0,r,a).data;return[this.#a7(l),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),v=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,b)),y=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200));(h=(l=new OffscreenCanvas(v,y)).getContext("2d",{alpha:!0,willReadFrequently:!0})).font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,v,y),h.fillStyle="black",h.fillText(t,.5*v/2,1.5*y/2);let w=this.#a7(h.getImageData(0,0,v,y).data),x=this.#a9(w),A=this.#ot(x),_=this.#a5(w,v,y,A);return this.processDrawnLines({lines:{curves:_,width:v,height:y},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){let[r,a,o]=this.#oe(t),[l,h]=this.#a8(r,a,o,Math.hypot(a,o)*this.#aZ.sigmaSFactor,this.#aZ.sigmaR,this.#aZ.kernelSize),d=this.#ot(h),c=this.#a5(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:a}){s%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(let{points:t}of o){let e=r?this.#a6(t):t;if(!e)continue;m.push(e);let i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(c.push({line:n,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,s.set([a,o,l,h],0),n.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){let i=s[t]=e[t]*p,r=s[t+1]=e[t+1]*g;n.set(sw.createBezierPoints(a,o,l,h,i,r),(t-2)*3),[a,o,l,h]=[l,h,i,r]}}if(0===c.length)return null;let f=a?new sR:new sD;return f.build(c,e,i,1,s,a?0:d,n),{outline:f,newCurves:m,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r,a=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}r=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;for(let a of(c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*r.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=n,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=r.BYTES_PER_ELEMENT,t))c[u++]=a.length-2,c[u++]=a[0],c[u++]=a[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let m=r.prototype.constructor;for(let e of t){let t=new m(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),to(new Uint8Array(await new Response(p.readable).arrayBuffer()))}static async decompressSignature(t){try{let e,i=Uint8Array.fromBase64?Uint8Array.fromBase64(t):Q(atob(t)),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(i).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(let t of s)(a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])).set(t,o),o+=t.length;let l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw Error(`Invalid version: ${h}`);let d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(m){case Int8Array.BYTES_PER_ELEMENT:e=new Int8Array(a.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:e=new Int16Array(a.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:e=new Int32Array(a.buffer,b)}o=0;for(let t=0;t<g;t++){let i=l[3*t+8],s=new Float32Array(i+2);f.push(s);for(let e=0;e<2;e++)s[e]=l[3*t+8+e+1];for(let t=0;t<i;t++)s[t+2]=s[t]+e[o++]}return{areContours:u,thickness:p,outlines:f,width:d,height:c}}catch(t){return N(`decompressSignature: ${t}`),null}}}class sB extends sP{constructor(){super(),super.updateProperties({fill:tZ._defaultLineColor,"stroke-width":0})}clone(){let t=new sB;return t.updateAll(this),t}}class sN extends sI{constructor(t){super(t),super.updateProperties({stroke:tZ._defaultLineColor,"stroke-width":1})}clone(){let t=new sN(this._viewParameters);return t.updateAll(this),t}}class sO extends sM{#oi=!1;#os=null;#on=null;#or=null;static _type="signature";static _editorType=T.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#on=t.signatureData||null,this.#os=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){tZ.initialize(t,e),this._defaultDrawingOptions=new sB,this._defaultDrawnSignatureOptions=new sN(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return H(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#os}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){let t,e;if(this.div)return this.div;let{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#on){let{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:r}=this.#on,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=sF.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:sO._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,r,s,n)}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.#os||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#or=t,this.addEditToolbar()}getUuid(){return this.#or}get description(){return this.#os}set description(t){this.#os=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#on,r=Math.max(s,n),a=sF.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){let n,{x:r,y:a}=this,{outline:o}=this.#on=t;this.#oi=o instanceof sR,this.description=i,this.#oi?n=sO.getDefaultDrawingOptions():(n=sO._defaultDrawnSignatureOptions.clone()).updateProperties({"stroke-width":o.thickness}),this._addOutlines({drawOutlines:o,drawingOptions:n});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=r,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sF.process(t,e,i,s,sO._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return sF.extractContoursFromText(t,e,i,s,n,sO._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sF.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:sO._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=sO.getDefaultDrawingOptions():(this._drawingOptions=sO._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#oi,color:[0,0,0],thickness:this.#oi?0:s});return this.addComment(n),t?(n.paths={lines:e,points:i},n.uuid=this.#or,n.isCopy=!0):n.lines=e,this.#os&&(n.accessibilityData={type:"Figure",alt:this.#os}),n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?sR.deserialize(t,e,i,s,n,r):sD.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=await super.deserialize(t,e,i);return s.#oi=t.areContours,s.description=t.accessibilityData?.alt||"",s.#or=t.uuid,s}}class sj extends tZ{#oa=null;#oo=null;#ol=null;#oh=null;#od=null;#oc="";#ou=null;#op=!1;#og=null;#om=!1;#of=!1;static _type="stamp";static _editorType=T.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#oh=t.bitmapUrl,this.#od=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){tZ.initialize(t,e)}static isHandlingMimeForPasting(t){return tk.includes(t)}static paste(t,e){e.pasteEditor({mode:T.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#ob(t,e=!1){t?(this.#oa=t.bitmap,e||(this.#oo=t.id,this.#om=t.isSvg),t.file&&(this.#oc=t.file.name),this.#ov()):this.remove()}#oy(){if(this.#ol=null,this._uiManager.enableWaiting(!1),this.#ou){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oa)return void this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oa){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(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#ow(){if(this.#oo){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#oo).then(t=>this.#ob(t,!0)).finally(()=>this.#oy());return}if(this.#oh){let t=this.#oh;this.#oh=null,this._uiManager.enableWaiting(!0),this.#ol=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#ob(t)).finally(()=>this.#oy());return}if(this.#od){let t=this.#od;this.#od=null,this._uiManager.enableWaiting(!0),this.#ol=this._uiManager.imageManager.getFromFile(t).then(t=>this.#ob(t)).finally(()=>this.#oy());return}let t=document.createElement("input");t.type="file",t.accept=tk.join(",");let e=this._uiManager._signal;this.#ol=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#ob(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#oy()),t.click()}remove(){this.#oo&&(this.#oa=null,this._uiManager.imageManager.deleteId(this.#oo),this.#ou?.remove(),this.#ou=null,this.#og&&(clearTimeout(this.#og),this.#og=null)),super.remove()}rebuild(){if(!this.parent){this.#oo&&this.#ow();return}super.rebuild(),null!==this.div&&(this.#oo&&null===this.#ou&&this.#ow(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#ol||this.#oa||this.#oh||this.#od||this.#oo||this.#op)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){let t,e;return this.div||(this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#op||(this.#oa?this.#ov():this.#ow()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this)),this.div}setCanvas(t,e){let{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#oo=i,s&&(this.#oa=s),this.#op=!1,this.#ov())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#og&&clearTimeout(this.#og),this.#og=setTimeout(()=>{this.#og=null,this.#ox()},200))}#ov(){let{div:t}=this,{width:e,height:i}=this.#oa,[s,n]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*n;else if(e>.75*s||i>.75*n){let t=Math.min(.75*s/e,.75*n/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let r=this.#ou=document.createElement("canvas");r.setAttribute("role","img"),this.addContainer(r),this.width=e/s,this.height=i/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#ox(),this.#of||(this.parent.addUndoableEditor(this),this.#of=!0),this._reportTelemetry({action:"inserted_image"}),this.#oc&&this.div.setAttribute("aria-description",this.#oc),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:n}=this.#oa,r=new tM,a=this.#oa,o=s,l=n,h=null;if(e){if(s>e||n>e){let t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#om||(a=this.#oA(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":tD.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*r.sx,g=15*r.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=c,f.fillRect(0,0,2*p,2*g),f.fillStyle=u,f.fillRect(0,0,p,g),f.fillRect(p,g,p,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#oa,s>t||n>t){let r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#om||(a=this.#oA(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#oA(t,e){let{width:i,height:s}=this.#oa,n=i,r=s,a=this.#oa;for(;n>2*t||r>2*e;){let i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));let o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#ox(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new tM,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#ou;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;let l=this.#om?this.#oa:this.#oA(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#o_(t){if(t){if(this.#om){let t=this._uiManager.imageManager.getSvgUrl(this.#oo);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#oa,t.getContext("2d").drawImage(this.#oa,0,0),t.toDataURL()}if(this.#om){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*tc.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*tc.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#oa,0,0,this.#oa.width,this.#oa.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#oa)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof sm){let r,a,{data:{rect:o,rotation:l,id:h,structParent:d,popupRef:c,richText:u,contentsObj:p,creationDate:g,modificationDate:m},container:f,parent:{page:{pageNumber:b}},canvas:v}=t;v?(delete t.canvas,{id:r,bitmap:a}=i.imageManager.getFromCanvas(f.id,v),v.remove()):(n=!0,t._hasNoCanvas=!0);let y=(await e._structTree.getAriaAttributes(`${tr}${h}`))?.get("aria-label")||"";s=t={annotationType:T.STAMP,bitmapId:r,bitmap:a,pageIndex:b-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:d,popupRef:c,richText:u,comment:p?.str||null,creationDate:g,modificationDate:m}}let r=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;n?(i.addMissingCanvas(t.id,r),r.#op=!0):h&&i.imageManager.isValidId(h)?(r.#oo=h,o&&(r.#oa=o)):r.#oh=l,r.#om=d;let[u,p]=r.pageDimensions;return r.width=(a[2]-a[0])/u,r.height=(a[3]-a[1])/p,c&&(r.altTextData=c),r._initialData=s,t.comment&&r.setCommentData(t),r.#of=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#oo,isSvg:this.#om});if(this.addComment(i),t)return i.bitmapUrl=this.#o_(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){let t=this.#rT(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;let r=this.#om?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#oo)){if(this.#om){let t=e.stamps.get(this.#oo);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#o_(!1))}}else e.stamps.set(this.#oo,{area:r,serialized:i}),i.bitmap=this.#o_(!1);return i}#rT(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class sU{#rd;#oC=!1;#oS=null;#oE=null;#oT=null;#oP=new Map;#oM=!1;#ok=!1;#oD=!1;#oI=null;#oL=null;#oR=null;#oF=null;#oB=null;#oN=-1;#b;static _initialized=!1;static #G=new Map([sy,sL,sj,sT,sO].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const d=[...sU.#G.values()];if(!sU._initialized)for(const e of(sU._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#b=t,this.pageIndex=e,this.div=i,this.#rd=n,this.#oS=r,this.viewport=l,this.#oR=o,this.drawLayer=a,this._structTree=s,this.#b.addLayer(this)}get isEmpty(){return 0===this.#oP.size}get isInvisible(){return this.isEmpty&&this.#b.getMode()===T.NONE}updateToolbar(t){this.#b.updateToolbar(t)}updateMode(t=this.#b.getMode()){switch(this.#oO(),t){case T.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case T.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case T.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===T.POPUP)e.toggle("commentEditing",!0);else for(let i of(e.toggle("commentEditing",!1),sU.#G.values()))e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#oR?.div}setEditingState(t){this.#b.setEditingState(t)}addCommands(t){this.#b.addCommands(t)}cleanUndoStack(t){this.#b.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#oS?.div.classList.toggle("disabled",!t)}get #oj(){return 0!==this.#oP.size?this.#oP.values():this.#b.getEditors(this.pageIndex)}async enable(){this.#oD=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#oB?.abort(),this.#oB=null;let t=new Set;for(let e of this.#oj)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#b.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));let e=this.#oS;if(e)for(let i of e.getEditableAnnotations()){if(i.hide(),this.#b.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#oD=!1,this.#b._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#ok=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#oR&&!this.#oB){this.#oB=new AbortController;let t=this.#b.combinedSignal(this.#oB);this.#oR.div.addEventListener("pointerdown",t=>{let e,{clientX:i,clientY:s,timeStamp:n}=t;if(n-this.#oN>500){this.#oN=n;return}this.#oN=-1;let{classList:r}=this.div;r.toggle("getElements",!0);let a=document.elementsFromPoint(i,s);if(r.toggle("getElements",!1),!this.div.contains(a[0]))return;let o=RegExp(`^${E}[0-9]+$`);for(let t of a)if(o.test(t.id)){e=t.id;break}if(!e)return;let l=this.#oP.get(e);l?.annotationElementId===null&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))},{signal:t,capture:!0})}let t=this.#oS;if(t){let e=new Map,i=new Map;for(let s of this.#oj){if(s.disableEditing(),!s.annotationElementId){s.updateFakeAnnotationElement(t);continue}if(null!==s.serialize()){e.set(s.annotationElementId,s);continue}i.set(s.annotationElementId,s),this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()}for(let s of t.getEditableAnnotations()){let{id:t}=s.data;if(this.#b.isDeletedAnnotationElement(t)){s.updateEdited({deleted:!0});continue}let n=i.get(t);if(n){n.resetAnnotationElement(s),n.show(!1),s.show();continue}(n=e.get(t))&&(this.#b.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show()}}this.#oO(),this.isEmpty&&(this.div.hidden=!0);let{classList:e}=this.div;for(let t of sU.#G.values())e.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#ok=!1}getEditableAnnotation(t){return this.#oS?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#b.getActive()!==t&&this.#b.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#oR?.div&&!this.#oF){this.#oF=new AbortController;let t=this.#b.combinedSignal(this.#oF);this.#oR.div.addEventListener("pointerdown",this.#oU.bind(this),{signal:t}),this.#oR.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#oR?.div&&this.#oF&&(this.#oF.abort(),this.#oF=null,this.#oR.div.classList.remove("highlighting"))}#oU(t){this.#b.unselectAll();let{target:e}=t;if(e===this.#oR.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#oR.div.contains(e)){let{isMac:e}=J.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#b.showAllEditors("highlight",!0,!0),this.#oR.div.classList.add("free"),this.toggleDrawing(),sT.startHighlighting(this,"ltr"===this.#b.direction,{target:this.#oR.div,x:t.x,y:t.y}),this.#oR.div.addEventListener("pointerup",()=>{this.#oR.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#b._signal}),t.preventDefault()}}enableClick(){if(this.#oE)return;this.#oE=new AbortController;let t=this.#b.combinedSignal(this.#oE);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#oE?.abort(),this.#oE=null}attach(t){this.#oP.set(t.id,t);let{annotationElementId:e}=t;e&&this.#b.isDeletedAnnotationElement(e)&&this.#b.removeDeletedAnnotationElement(t)}detach(t){this.#oP.delete(t.id),this.#rd?.removePointerInTextLayer(t.contentDiv),!this.#ok&&t.annotationElementId&&this.#b.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#b.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#b.addDeletedAnnotationElement(t.annotationElementId),tZ.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#b.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#oD),this.#b.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#oT&&(t._focusEventsAllowed=!1,this.#oT=setTimeout(()=>{this.#oT=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#b._signal}),e.focus())},0)),t._structTreeParentId=this.#rd?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getEditorByUID(t){for(let e of this.#oP.values())if(e.uid===t)return e;return null}getNextId(){return this.#b.getId()}get #oz(){return sU.#G.get(this.#b.getMode())}combinedSignal(t){return this.#b.combinedSignal(t)}#oH(t){let e=this.#oz;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#oz?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#b.updateMode(t.mode);let{offsetX:i,offsetY:s}=this.#o$(),n=this.getNextId(),r=this.#oH({parent:this,id:n,x:i,y:s,uiManager:this.#b,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await sU.#G.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#b)||null}createAndAddNewEditor(t,e,i={}){let s=this.getNextId(),n=this.#oH({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#b,isCentered:e,...i});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#o$(){let{x:t,y:e,width:i,height:s}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(n+a)/2-t,h=(r+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#o$(),!0,t)}setSelected(t){this.#b.setSelected(t)}toggleSelected(t){this.#b.toggleSelected(t)}unselect(t){this.#b.unselect(t)}pointerup(t){let{isMac:e}=J.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#oM||(this.#oM=!1,this.#oz?.isDrawer&&this.#oz.supportMultipleDrawings))return;if(!this.#oC){this.#oC=!0;return}let i=this.#b.getMode();i===T.STAMP||i===T.SIGNATURE?this.#b.unselectAll():this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#b.getMode()===T.HIGHLIGHT&&this.enableTextSelection(),this.#oM){this.#oM=!1;return}let{isMac:e}=J.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#oM=!0,this.#oz?.isDrawer)return void this.startDrawingSession(t);let i=this.#b.getActive();this.#oC=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#oI)return void this.#oz.startDrawing(this,this.#b,!1,t);this.#b.setCurrentDrawingSession(this),this.#oI=new AbortController;let e=this.#b.combinedSignal(this.#oI);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#oL=null,this.commitOrRemove())},{signal:e}),this.#oz.startDrawing(this,this.#b,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#oL=t);return}this.#oL&&setTimeout(()=>{this.#oL?.focus(),this.#oL=null},0)}endDrawingSession(t=!1){return this.#oI?(this.#b.setCurrentDrawingSession(null),this.#oI.abort(),this.#oI=null,this.#oL=null,this.#oz.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#b.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#oI&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#oI&&this.#oz.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#b.getActive()?.parent===this&&(this.#b.commitOrRemove(),this.#b.setActiveEditor(null)),this.#oT&&(clearTimeout(this.#oT),this.#oT=null),this.#oP.values()))this.#rd?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#oP.clear(),this.#b.removeLayer(this)}#oO(){for(let t of this.#oP.values())t.isEmpty()&&t.remove()}render({viewport:t}){for(let e of(this.viewport=t,tP(this.div,t),this.#b.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#b.commitOrRemove(),this.#oO();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tP(this.div,{rotation:i}),e!==i)for(let t of this.#oP.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#b.viewParameters.realScale}}class sz{#nV=null;#oV=new Map;#oG=new Map;static #x=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#nV){this.#nV=t;return}if(this.#nV!==t){if(this.#oV.size>0)for(let e of this.#oV.values())e.remove(),t.append(e);this.#nV=t}}static get _svgFactory(){return H(this,"_svgFactory",new iY)}static #oW(t,[e,i,s,n]){let{style:r}=t;r.top=`${100*i}%`,r.left=`${100*e}%`,r.width=`${100*s}%`,r.height=`${100*n}%`}#oq(){let t=sz._svgFactory.create(1,1,!0);return this.#nV.append(t),t.setAttribute("aria-hidden",!0),t}#oX(t,e){let i=sz._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let n=sz._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#oK(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=sz.#x++,n=this.#oq(),r=sz._svgFactory.createElement("defs");n.append(r);let a=sz._svgFactory.createElement("path");r.append(a);let o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#oG.set(s,a);let l=i?this.#oX(r,o):null,h=sz._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#oV.set(s,n),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,s=sz.#x++,n=this.#oq(),r=sz._svgFactory.createElement("defs");n.append(r);let a=sz._svgFactory.createElement("path");r.append(a);let o=`path_p${this.pageIndex}_${s}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e){let t=sz._svgFactory.createElement("mask");r.append(t),i=`mask_p${this.pageIndex}_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=sz._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let n=sz._svgFactory.createElement("use");t.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}let l=sz._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return n.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(n,t),this.#oV.set(s,n),s}finalizeDraw(t,e){this.#oG.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:n,path:r}=e,a="number"==typeof t?this.#oV.get(t):t;if(a){if(i&&this.#oK(a,i),s&&sz.#oW(a,s),n){let{classList:t}=a;for(let[e,i]of Object.entries(n))t.toggle(e,i)}if(r){let t=a.firstChild.firstChild;this.#oK(t,r)}}}updateParent(t,e){if(e===this)return;let i=this.#oV.get(t);i&&(e.#nV.append(i),this.#oV.delete(t),e.#oV.set(t,i))}remove(t){this.#oG.delete(t),null!==this.#nV&&(this.#oV.get(t).remove(),this.#oV.delete(t))}destroy(){for(let t of(this.#nV=null,this.#oV.values()))t.remove();this.#oV.clear(),this.#oG.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:s_},globalThis.pdfjsLib={AbortException:K,AnnotationEditorLayer:sU,AnnotationEditorParamsType:P,AnnotationEditorType:T,AnnotationEditorUIManager:tK,AnnotationLayer:sb,AnnotationMode:S,AnnotationType:D,applyOpacity:tL,build:i$,ColorPicker:iV,createValidAbsoluteUrl:U,CSSConstants:tI,DOMSVGFactory:iY,DrawLayer:sz,FeatureTest:J,fetchData:tu,findContrastColor:tj,getDocument:iL,getFilenameFromUrl:tb,getPdfFilenameFromUrl:tv,getRGB:tS,getUuid:tn,getXfaPageViewport:tC,GlobalWorkerOptions:ie,ImageKind:k,InvalidPDFException:W,isDataScheme:tm,isPdfFile:tf,isValidExplicitDest:t7,MathClamp:ta,noContextMenu:tx,normalizeUnicode:ts,OPS:L,OutputScale:tM,PasswordResponses:R,PDFDataRangeTransport:iF,PDFDateString:t_,PDFWorker:iO,PermissionFlag:M,PixelsPerInch:tc,RenderingCancelledException:tg,renderRichText:tU,ResponseException:q,setLayerDimensions:tP,shadow:H,SignatureExtractor:sF,stopEvent:tA,SupportedImageMimeTypes:tk,TextLayer:iI,TouchManager:tJ,updateUrlHash:z,Util:tt,VerbosityLevel:I,version:iH,XfaLayer:th},t.s(["AbortException",0,K,"AnnotationEditorLayer",0,sU,"AnnotationEditorParamsType",0,P,"AnnotationEditorType",0,T,"AnnotationEditorUIManager",0,tK,"AnnotationLayer",0,sb,"AnnotationMode",0,S,"AnnotationType",0,D,"CSSConstants",0,tI,"ColorPicker",0,iV,"DOMSVGFactory",0,iY,"DrawLayer",0,sz,"FeatureTest",0,J,"GlobalWorkerOptions",0,ie,"ImageKind",0,k,"InvalidPDFException",0,W,"MathClamp",0,ta,"OPS",0,L,"OutputScale",0,tM,"PDFDataRangeTransport",0,iF,"PDFDateString",0,t_,"PDFWorker",0,iO,"PasswordResponses",0,R,"PermissionFlag",0,M,"PixelsPerInch",0,tc,"RenderingCancelledException",0,tg,"ResponseException",0,q,"SignatureExtractor",0,sF,"SupportedImageMimeTypes",0,tk,"TextLayer",0,iI,"TouchManager",0,tJ,"Util",0,tt,"VerbosityLevel",0,I,"XfaLayer",0,th,"applyOpacity",0,tL,"build",0,i$,"createValidAbsoluteUrl",0,U,"fetchData",0,tu,"findContrastColor",0,tj,"getDocument",0,iL,"getFilenameFromUrl",0,tb,"getPdfFilenameFromUrl",0,tv,"getRGB",0,tS,"getUuid",0,tn,"getXfaPageViewport",0,tC,"isDataScheme",0,tm,"isPdfFile",0,tf,"isValidExplicitDest",0,t7,"noContextMenu",0,tx,"normalizeUnicode",0,ts,"renderRichText",0,tU,"setLayerDimensions",0,tP,"shadow",0,H,"stopEvent",0,tA,"updateUrlHash",0,z,"version",0,iH],65467);var sH=t.i(65467),s$={};s$.d=(t,e)=>{for(var i in e)s$.o(e,i)&&!s$.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s$.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let{AbortException:sV,AnnotationEditorLayer:sG,AnnotationEditorParamsType:sW,AnnotationEditorType:sq,AnnotationEditorUIManager:sX,AnnotationLayer:sK,AnnotationMode:sY,AnnotationType:sQ,applyOpacity:sJ,build:sZ,ColorPicker:s0,createValidAbsoluteUrl:s1,CSSConstants:s2,DOMSVGFactory:s3,DrawLayer:s5,FeatureTest:s4,fetchData:s6,findContrastColor:s8,getDocument:s9,getFilenameFromUrl:s7,getPdfFilenameFromUrl:nt,getRGB:ne,getUuid:ni,getXfaPageViewport:ns,GlobalWorkerOptions:nn,ImageKind:nr,InvalidPDFException:na,isDataScheme:no,isPdfFile:nl,isValidExplicitDest:nh,MathClamp:nd,noContextMenu:nc,normalizeUnicode:nu,OPS:np,OutputScale:ng,PasswordResponses:nm,PDFDataRangeTransport:nf,PDFDateString:nb,PDFWorker:nv,PermissionFlag:ny,PixelsPerInch:nw,RenderingCancelledException:nx,renderRichText:nA,ResponseException:n_,setLayerDimensions:nC,shadow:nS,SignatureExtractor:nE,stopEvent:nT,SupportedImageMimeTypes:nP,TextLayer:nM,TouchManager:nk,updateUrlHash:nD,Util:nI,VerbosityLevel:nL,version:nR,XfaLayer:nF}=globalThis.pdfjsLib,nB={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},nN={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},nO={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function nj(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,!(s=s.offsetParent))return;if(e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left)){if(i){let i=t.getBoundingClientRect().width,n=nd((s.clientWidth-i)/2,20,400);r+=e.left-n}else r+=e.left;s.scrollLeft=r}s.scrollTop=n}function nU(t){let e=new Map;for(let[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}let nz=/[\x00-\x1F]/g;function nH(t,e=!1){return nz.test(t)?e?t.replaceAll(nz,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t}function n$(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){let i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function nV(t){if(Math.floor(t)===t)return[t,1];let e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];let i=t>1?e:t,s=0,n=1,r=1,a=1;for(;;){let t=s+r,e=n+a;if(e>8)break;i<=t/e?(r=t,a=e):(s=t,n=e)}return i-s/n<r/a-i?i===t?[s,n]:[n,s]:i===t?[r,a]:[a,r]}function nG(t){return Number.isInteger(t)&&t%90==0}function nW(t){return t.width<=t.height}new Promise(function(t){window.requestAnimationFrame(t)});let nq=document.documentElement.style,nX=((s=document.createElement("div")).style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===s.style.width?Math.fround:t=>t);function nK(t){if(t<11904){if((65408&t)==0)return 32===t||9===t||13===t||10===t?0:t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t?1:2;return(65408&t)==3584?7:1*(160!==t)}if(t>=13312&&t<=40959||t>=63744&&t<=64255)return 3;if(t>=12448&&t<=12543)return 4;if(t>=12352&&t<=12447)return 5;if(t>=65376&&t<=65439)return 6;return 1}let nY={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},nQ={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},nJ=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]),nZ=/\p{M}+/gu,n0=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,n1=/([^\p{M}])\p{M}*$/u,n2=/^\p{M}*([^\p{M}])/u,n3=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,n5=new Map,n4=new Map,n6=null,n8=null;function n9(t,i={}){let s,n,r=[];for(;null!==(s=n3.exec(t));){let{index:t}=s;for(let e of s[0]){let i=n5.get(e);i||(i=e.normalize("NFD").length,n5.set(e,i)),r.push([i,t++])}}let a=r.length>0,o=i.ignoreDashEOL??!1;if(!a&&n6)n=n6;else if(a&&n8)n=n8;else{let t=Object.keys(nQ).join(""),i=e||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩";n=RegExp([`[${t}]`,`[${i}]`,"(?:゙|゚)\\n","\\p{M}+(?:-\\n)?","\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})","\\S-\\n","(?:\\p{Ideographic}|[-ヿ])\\n","\\n",a?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map(t=>`(${t})`).join("|"),"gum"),a?n8=n:n6=n}let l=[];for(;null!==(s=nZ.exec(t));)l.push([s[0].length,s.index]);let h=t.normalize("NFD"),d=[0,0],c=0,u=0,p=0,g=0,m=0,f=!1;h=h.replace(n,(t,e,i,s,n,a,h,b,v,y,w)=>{if(w-=g,e){let t=nQ[e],i=t.length;for(let t=1;t<i;t++)d.push(w-p+t,p-t);return p-=i-1,t}if(i){let t=n4.get(i);t||(t=i.normalize("NFKC"),n4.set(i,t));let e=t.length;for(let t=1;t<e;t++)d.push(w-p+t,p-t);return p-=e-1,t}if(s)return f=!0,w+m===l[c]?.[1]?++c:(d.push(w-1-p+1,p-1),p-=1,g+=1),d.push(w-p+1,p),g+=1,m+=1,s.charAt(0);if(n){let t=n.endsWith("\n"),e=t?n.length-2:n.length;f=!0;let i=e;w+m===l[c]?.[1]&&(i-=l[c][0],++c);for(let t=1;t<=i;t++)d.push(w-1-p+t,p-t);return(p-=i,g+=i,t)?(w+=e-1,d.push(w-p+1,1+p),p+=1,g+=1,m+=1,n.slice(0,e)):n}if(a){if(o)return g+=1,m+=1,a.slice(0,-1);let t=a.length-2;return d.push(w-p+t,1+p),p+=1,g+=1,m+=1,a.slice(0,-2)}if(h)return g+=1,m+=1,h.slice(0,-1);if(b){let t=b.length-1;return d.push(w-p+t,p),g+=1,m+=1,b.slice(0,-1)}if(v)return d.push(w-p+1,p-1),p-=1,g+=1,m+=1," ";if(w+m===r[u]?.[1]){let t=r[u][0]-1;++u;for(let e=1;e<=t;e++)d.push(w-(p-e),p-e);p-=t,g+=t}return y}),d.push(h.length,p);let b=new Uint32Array(d.length>>1),v=new Int32Array(d.length>>1);for(let t=0,e=d.length;t<e;t+=2)b[t>>1]=d[t],v[t>>1]=d[t+1];return[h,[b,v],f]}function n7(t,e,i){if(!t)return[e,i];let[s,n]=t,r=e+i-1,a=n$(s,t=>t>=e);s[a]>e&&--a;let o=n$(s,t=>t>=r,a);s[o]>r&&--o;let l=e+n[a];return[l,r+n[o]+1-l]}let rt={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class re{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(t){let e,i,s;if(!this.pdfDocument)return;if("string"==typeof t?(e=t,i=await this.pdfDocument.getDestination(t)):(e=null,i=await t),!Array.isArray(i))return void console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${t}".`);let[n]=i;if(n&&"object"==typeof n){if(!(s=this.pdfDocument.cachedPageNumber(n)))try{s=await this.pdfDocument.getPageIndex(n)+1}catch{console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`);return}}else Number.isInteger(n)&&(s=n+1);if(!s||s<1||s>this.pagesCount)return void console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`);this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});let r=new AbortController;this.eventBus._on("textlayerrendered",t=>{t.pageNumber===s&&(t.source.textLayer.div.focus(),r.abort())},{signal:r.signal})}goToPage(t){if(!this.pdfDocument)return;let e="string"==typeof t&&this.pdfViewer.pageLabelToPageNumber(t)||0|t;Number.isInteger(e)&&e>0&&e<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})):console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`)}goToXY(t,e,i,s={}){this.pdfViewer.scrollPageIntoView({pageNumber:t,destArray:[null,{name:"XYZ"},e,i],ignoreDestinationZoom:!0,...s})}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw Error('A valid "url" parameter must provided.');let s=i?rt.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(s){case rt.NONE:break;case rt.SELF:r="_self";break;case rt.BLANK:r="_blank";break;case rt.PARENT:r="_parent";break;case rt.TOP:r="_top"}t.target=r,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){let e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){let e,i;if(this.pdfDocument){if(t.includes("=")){let s=nU(t);if(s.has("search")){let t=s.get("search").replaceAll('"',""),e="true"===s.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(s.has("page")&&(e=0|s.get("page")||1),s.has("zoom")){let t=s.get("zoom").split(","),e=t[0],n=parseFloat(e);e.includes("Fit")?"Fit"===e||"FitB"===e?i=[null,{name:e}]:"FitH"===e||"FitBH"===e||"FitV"===e||"FitBV"===e?i=[null,{name:e},t.length>1?0|t[1]:null]:"FitR"===e?5!==t.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:e},0|t[1],0|t[2],0|t[3],0|t[4]]:console.error(`PDFLinkService.setHash: "${e}" is not a valid zoom value.`):i=[null,{name:"XYZ"},t.length>1?0|t[1]:null,t.length>2?0|t[2]:null,n?n/100:e]}i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),s.has("nameddest")&&this.goToDestination(s.get("nameddest"));return}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}if("string"==typeof i||nh(i))return void this.goToDestination(i);console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;let e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}}class ri extends re{setDocument(t,e=null){}}class rs{#oY=null;#j=null;#oQ=!1;#oJ=null;#oZ=null;#o0=!1;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableComment:a=!1,commentManager:o=null,enableScripting:l=!1,hasJSActionsPromise:h=null,fieldObjectsPromise:d=null,annotationCanvasMap:c=null,accessibilityManager:u=null,annotationEditorUIManager:p=null,onAppend:g=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableComment=a,this.#j=o,this.enableScripting=l,this._hasJSActionsPromise=h||Promise.resolve(!1),this._fieldObjectsPromise=d||Promise.resolve(null),this._annotationCanvasMap=c,this._accessibilityManager=u,this._annotationEditorUIManager=p,this.#oJ=g,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render({viewport:t,intent:e="display",structTreeLayer:i=null}){if(this.div){if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:t.clone({dontFlip:!0})});return}let[s,n,r]=await Promise.all([this.pdfPage.getAnnotations({intent:e}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;let a=this.div=document.createElement("div");if(a.className="annotationLayer",this.#oJ?.(a),this.#o1(t,i),0===s.length){this.#oY=s,nC(this.div,t);return}await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r}),this.#oY=s,this.linkService.isInPresentationMode&&this.#o2(3),this.#oZ||(this.#oZ=new AbortController,this._eventBus?._on("presentationmodechanged",t=>{this.#o2(t.state)},{signal:this.#oZ.signal}))}#o1(t,e){this.annotationLayer=new sK({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e,commentManager:this.#j,linkService:this.linkService})}cancel(){this._cancelled=!0,this.#oZ?.abort(),this.#oZ=null}hide(t=!1){this.#oQ=!t,this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(t){if(null===this.#oY)throw Error("`render` method must be called before `injectLinkAnnotations`.");if(this._cancelled||this.#o0)return;this.#o0=!0;let e=this.#oY.length?this.#o3(t):t;e.length&&(await this.annotationLayer.addLinkAnnotations(e),this.#oQ||(this.div.hidden=!1))}#o2(t){if(!this.div)return;let e=!1;switch(t){case 3:e=!0;break;case 1:break;default:return}for(let t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}#o3(t){function e(t){if(!t.quadPoints)return[t.rect];let e=[];for(let i=2,s=t.quadPoints.length;i<s;i+=8){let s=t.quadPoints[i],n=t.quadPoints[i+1],r=t.quadPoints[i+2],a=t.quadPoints[i+3];e.push([r,a,s,n])}return e}function i(t){let e=0;for(let i of t)e+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return e}return t.filter(t=>{let s;for(let n of this.#oY){if(n.annotationType!==sQ.LINK||!n.url)continue;let r=function(t,i){let s=[],n=e(t),r=e(i);for(let t of n)for(let e of r){let i=nI.intersect(t,e);i&&s.push(i)}return s}(n,t);if(0!==r.length&&(s??=i(e(t)),i(r)/s>.5))return!1}return!0})}}function rn(t,e){let i=document.createElement("a");if(!i.click)throw Error('DownloadManager: "a.click()" is not supported.');i.href=t,i.target="_parent","download"in i&&(i.download=e),(document.body||document.documentElement).append(i),i.click(),i.remove()}class rr{#o5=new WeakMap;downloadData(t,e,i){rn(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){let s=nl(e);return this.downloadData(t,e,s?"application/pdf":""),!1}download(t,e,i){let s;if(t)s=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!s1(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}rn(s,i)}}async function ra({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(e&&"string"==typeof e)||!(Number.isInteger(i)&&i>=0))throw Error("waitOnEventOrTimeout - invalid parameters.");let{promise:s,resolve:n}=Promise.withResolvers(),r=new AbortController;function a(t){r.abort(),clearTimeout(l),n(t)}let o=t instanceof ro?"_on":"addEventListener";t[o](e,a.bind(null,"event"),{signal:r.signal});let l=setTimeout(a.bind(null,"timeout"),i);return s}class ro{#ir=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){let i,s=this.#ir[t];if(s&&0!==s.length){for(let{listener:n,external:r,once:a}of s.slice(0)){if(a&&this._off(t,n),r){(i||=[]).push(n);continue}n(e)}if(i){for(let t of i)t(e);i=null}}}_on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:n}=i;if(n.aborted)return void console.error("Cannot use an `aborted` signal.");let r=()=>this._off(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}(this.#ir[t]||=[]).push({listener:e,external:i?.external===!0,once:i?.once===!0,rmAbort:s})}_off(t,e,i=null){let s=this.#ir[t];if(s)for(let t=0,i=s.length;t<i;t++){let i=s[t];if(i.listener===e){i.rmAbort?.(),s.splice(t,1);return}}}}class rl{constructor(t){this.value=t}valueOf(){return this.value}}class rh extends rl{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class rd extends rl{constructor(t,e={}){super(t),this.opts=e}toString(t){if(t)try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return this.value.toString(10)}}class rc extends rl{static supportsValue(t){if("number"==typeof t||t instanceof Date)return!0;if(t instanceof rl)return rc.supportsValue(t.valueOf());if("Temporal"in globalThis){let e=globalThis.Temporal;if(t instanceof e.Instant||t instanceof e.PlainDateTime||t instanceof e.PlainDate||t instanceof e.PlainMonthDay||t instanceof e.PlainTime||t instanceof e.PlainYearMonth)return!0}return!1}constructor(t,e={}){t instanceof rc?(e={...t.opts,...e},t=t.value):t instanceof rl&&(t=t.valueOf()),"object"==typeof t&&"calendarId"in t&&void 0===e.calendar&&(e={...e,calendar:t.calendarId}),super(t),this.opts=e}[Symbol.toPrimitive](t){return"string"===t?this.toString():this.toNumber()}toNumber(){let t=this.value;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("epochMilliseconds"in t)return t.epochMilliseconds;if("toZonedDateTime"in t)return t.toZonedDateTime("UTC").epochMilliseconds;throw TypeError("Unwrapping a non-number value as a number")}toString(t){if(t)try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function ru(t,e,i){return e[i]?rf(t,e[i].value):(t.reportError(RangeError("No default")),new rh)}function rp(t,e){let i=[],s=Object.create(null);for(let n of e)"narg"===n.type?s[n.name]=rg(t,n.value):i.push(rg(t,n));return{positional:i,named:s}}function rg(t,e){switch(e.type){case"str":return e.value;case"num":return new rd(e.value,{minimumFractionDigits:e.precision});case"var":return function(t,{name:e}){let i;if(t.params)if(!Object.prototype.hasOwnProperty.call(t.params,e))return new rh(`$${e}`);else i=t.params[e];else{if(!(t.args&&Object.prototype.hasOwnProperty.call(t.args,e)))return t.reportError(ReferenceError(`Unknown variable: $${e}`)),new rh(`$${e}`);i=t.args[e]}if(i instanceof rl)return i;switch(typeof i){case"string":return i;case"number":return new rd(i);case"object":if(rc.supportsValue(i))return new rc(i);default:return t.reportError(TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new rh(`$${e}`)}}(t,e);case"mesg":return function(t,{name:e,attr:i}){let s=t.bundle._messages.get(e);if(!s)return t.reportError(ReferenceError(`Unknown message: ${e}`)),new rh(e);if(i){let n=s.attributes[i];return n?rf(t,n):(t.reportError(ReferenceError(`Unknown attribute: ${i}`)),new rh(`${e}.${i}`))}return s.value?rf(t,s.value):(t.reportError(ReferenceError(`No value: ${e}`)),new rh(e))}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){let n=`-${e}`,r=t.bundle._terms.get(n);if(!r)return t.reportError(ReferenceError(`Unknown term: ${n}`)),new rh(n);if(i){let e=r.attributes[i];if(e){t.params=rp(t,s).named;let i=rf(t,e);return t.params=null,i}return t.reportError(ReferenceError(`Unknown attribute: ${i}`)),new rh(`${n}.${i}`)}t.params=rp(t,s).named;let a=rf(t,r.value);return t.params=null,a}(t,e);case"func":return function(t,{name:e,args:i}){let s=t.bundle._functions[e];if(!s)return t.reportError(ReferenceError(`Unknown function: ${e}()`)),new rh(`${e}()`);if("function"!=typeof s)return t.reportError(TypeError(`Function ${e}() is not callable`)),new rh(`${e}()`);try{let e=rp(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new rh(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=rg(t,e);if(n instanceof rh)return ru(t,i,s);for(let e of i){var r,a,o;let i=rg(t,e.key);if(r=t,a=n,(o=i)===a||o instanceof rd&&a instanceof rd&&o.value===a.value||a instanceof rd&&"string"==typeof o&&o===r.memoizeIntlObject(Intl.PluralRules,a.opts).select(a.value)||0)return rf(t,e.value)}return ru(t,i,s)}(t,e);default:return new rh}}function rm(t,e){if(t.dirty.has(e))return t.reportError(RangeError("Cyclic reference")),new rh;t.dirty.add(e);let i=[],s=t.bundle._useIsolating&&e.length>1;for(let n of e){if("string"==typeof n){i.push(t.bundle._transform(n));continue}if(t.placeables++,t.placeables>100)throw t.dirty.delete(e),RangeError(`Too many placeables expanded: ${t.placeables}, max allowed is 100`);s&&i.push(""),i.push(rg(t,n).toString(t)),s&&i.push("")}return t.dirty.delete(e),i.join("")}function rf(t,e){return"string"==typeof e?t.bundle._transform(e):rm(t,e)}class rb{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!this.errors||!(t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let s=JSON.stringify(e);return i[s]||(i[s]=new t(this.bundle.locales,e)),i[s]}}function rv(t,e){let i=Object.create(null);for(let[s,n]of Object.entries(t))e.includes(s)&&(i[s]=n.valueOf());return i}let ry=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function rw(t,e){let i=t[0];if(i instanceof rh)return new rh(`NUMBER(${i.valueOf()})`);if(i instanceof rd)return new rd(i.valueOf(),{...i.opts,...rv(e,ry)});if(i instanceof rc)return new rd(i.toNumber(),{...rv(e,ry)});throw TypeError("Invalid argument to NUMBER")}let rx=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function rA(t,e){let i=t[0];if(i instanceof rh)return new rh(`DATETIME(${i.valueOf()})`);if(i instanceof rc||i instanceof rd)return new rc(i,rv(e,rx));throw TypeError("Invalid argument to DATETIME")}let r_=new Map;class rC{constructor(t,{functions:e,useIsolating:i=!0,transform:s=t=>t}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:rw,DATETIME:rA,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){let e=Array.isArray(t)?t.join(" "):t,i=r_.get(e);return void 0===i&&(i=new Map,r_.set(e,i)),i}(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){let i=[];for(let s=0;s<t.body.length;s++){let n=t.body[s];if(n.id.startsWith("-")){if(!1===e&&this._terms.has(n.id)){i.push(Error(`Attempt to override an existing term: "${n.id}"`));continue}this._terms.set(n.id,n)}else{if(!1===e&&this._messages.has(n.id)){i.push(Error(`Attempt to override an existing message: "${n.id}"`));continue}this._messages.set(n.id,n)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let s=new rb(this,i,e);try{return rm(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),new rh().toString(s);throw t}}}let rS=/^(-?[a-zA-Z][\w-]*) *= */gm,rE=/\.([a-zA-Z][\w-]*) *= */y,rT=/\*?\[/y,rP=/(-?[0-9]+(?:\.([0-9]+))?)/y,rM=/([a-zA-Z][\w-]*)/y,rk=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,rD=/^[A-Z][A-Z0-9_-]*$/,rI=/([^{}\n\r]+)/y,rL=/([^\\"\n\r]*)/y,rR=/\\([\\"])/y,rF=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,rB=/^\n+/,rN=/ +$/,rO=/ *\r?\n/g,rj=/( *)$/,rU=/{\s*/y,rz=/\s*}/y,rH=/\[\s*/y,r$=/\s*] */y,rV=/\s*\(\s*/y,rG=/\s*->\s*/y,rW=/\s*:\s*/y,rq=/\s*,?\s*/y,rX=/\s+/y;class rK{constructor(t){this.body=[],rS.lastIndex=0;let e=0;for(;;){let s=rS.exec(t);if(null===s)break;e=rS.lastIndex;try{this.body.push(function(t){let e=o(),s=function(){let t=Object.create(null);for(;i(rE);){let e=a(rE),i=o();if(null===i)throw SyntaxError("Expected attribute value");t[e]=i}return t}();if(null===e&&0===Object.keys(s).length)throw SyntaxError("Expected message value or attributes");return{id:t,value:e,attributes:s}}(s[1]))}catch(t){if(t instanceof SyntaxError)continue;throw t}}function i(i){return i.lastIndex=e,i.test(t)}function s(i,s){if(t[e]===i)return e++,!0;if(s)throw new s(`Expected ${i}`);return!1}function n(t,s){if(i(t))return e=t.lastIndex,!0;if(s)throw new s(`Expected ${t.toString()}`);return!1}function r(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function a(t){return r(t)[1]}function o(){let s;if(i(rI)&&(s=a(rI)),"{"===t[e]||"}"===t[e])return l(s?[s]:[],1/0);let n=u();return n?s?l([s,n],n.length):(n.value=p(n.value,rB),l([n],n.length)):s?p(s,rN):null}function l(s=[],n){for(;;){if(i(rI)){s.push(a(rI));continue}if("{"===t[e]){s.push(h());continue}if("}"===t[e])throw SyntaxError("Unbalanced closing brace");let r=u();if(r){s.push(r),n=Math.min(n,r.length);continue}break}let r=s.length-1,o=s[r];"string"==typeof o&&(s[r]=p(o,rN));let d=[];for(let t of s)t instanceof rY&&(t=t.value.slice(0,t.value.length-n)),t&&d.push(t);return d}function h(){n(rU,SyntaxError);let l=function s(){if("{"===t[e])return h();if(i(rk)){let[,i,a,o=null]=r(rk);if("$"===i)return{type:"var",name:a};if(n(rV)){let r=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw SyntaxError("Unclosed argument list")}i.push(function(){let t=s();return"mesg"!==t.type?t:n(rW)?{type:"narg",name:t.name,value:d()}:t}()),n(rq)}}();if("-"===i)return{type:"term",name:a,attr:o,args:r};if(rD.test(a))return{type:"func",name:a,args:r};throw SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:a,attr:o,args:[]}:{type:"mesg",name:a,attr:o}}return d()}();if(n(rz))return l;if(n(rG)){let t=function(){let t,e=[],r=0;for(;i(rT);){s("*")&&(t=r);let l=function(){let t;return n(rH,SyntaxError),t=i(rP)?c():{type:"str",value:a(rM)},n(r$,SyntaxError),t}(),h=o();if(null===h)throw SyntaxError("Expected variant value");e[r++]={key:l,value:h}}if(0===r)return null;if(void 0===t)throw SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(rz,SyntaxError),{type:"select",selector:l,...t}}throw SyntaxError("Unclosed placeable")}function d(){if(i(rP))return c();if('"'===t[e]){s('"',SyntaxError);let n="";for(;;){if(n+=a(rL),"\\"===t[e]){n+=function(){if(i(rR))return a(rR);if(i(rF)){let[,t,e]=r(rF),i=parseInt(t||e,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw SyntaxError("Unknown escape sequence")}();continue}if(s('"'))return{type:"str",value:n};throw SyntaxError("Unclosed string literal")}return}throw SyntaxError("Invalid expression")}function c(){let[,t,e=""]=r(rP),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function u(){let i=e;switch(n(rX),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return g(t.slice(i,e))}return" "===t[e-1]&&g(t.slice(i,e))}function p(t,e){return t.replace(e,"")}function g(t){return new rY(t.replace(rO,"\n"),rj.exec(t)[1].length)}}}class rY{constructor(t,e){this.value=t,this.length=e}}let rQ=/<|&#?\w+;/,rJ={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},rZ={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function r0(t,e){let i=e.hasAttribute("data-l10n-attrs")?e.getAttribute("data-l10n-attrs").split(",").map(t=>t.trim()):null;for(let s of Array.from(e.attributes))r2(s.name,e,i)&&!function(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(let s of Array.from(t.attributes))r2(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function r1(t){return t.ownerDocument.createTextNode(t.textContent)}function r2(t,e,i=null){if(i&&i.includes(t))return!0;let s=rZ[e.namespaceURI];if(!s)return!1;let n=t.toLowerCase(),r=e.localName;if(s.global.includes(n))return!0;if(!s[r])return!1;if(s[r].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===r&&"value"===n){let t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function r3(t,e){return e.textContent=t.textContent,r0(t,e),e}class r5 extends Array{static from(t){return t instanceof this?t:new this(t)}}class r4 extends r5{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else if(Symbol.iterator in Object(t))this.iterator=t[Symbol.iterator]();else throw TypeError("Argument must implement the iteration protocol.")}[Symbol.asyncIterator](){let t=this,e=0;return{next:async()=>(t.length<=e&&t.push(t.iterator.next()),t[e++])}}async touchNext(t=1){let e=0;for(;e++<t;){let t=this[this.length-1];if(t&&(await t).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class r6{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter(e=>!t.includes(e)),this.onChange(),this.resourceIds.length}async formatWithFallback(t,e){let i=[],s=!1;for await(let n of this.bundles){s=!0;let r=function(t,e,i,s){let n=[],r=new Set;return i.forEach(({id:i,args:a},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,a),n.length>0&&"u">typeof console){let t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else r.add(i)}),r}(e,n,t,i);if(0===r.size)break;if("u">typeof console){let t=n.locales[0],e=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return!s&&"u">typeof console&&console.warn(`[fluent] Request for keys failed because no resource bundles got generated.
|
|
3
|
+
keys: ${JSON.stringify(t)}.
|
|
4
|
+
resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,r9)}formatValues(t){return this.formatWithFallback(t,r8)}async formatValue(t,e){let[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=r4.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function r8(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function r9(t,e,i,s){let n={value:null,attributes:null};i.value&&(n.value=t.formatPattern(i.value,s,e));let r=Object.keys(i.attributes);if(r.length>0)for(let[a,o]of(n.attributes=Array(r.length),r.entries())){let r=t.formatPattern(i.attributes[o],s,e);n.attributes[a]={name:o,value:r}}return n}let r7="data-l10n-id",at="data-l10n-args",ae=`[${r7}]`;class ai extends r6{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[r7,at]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(r7,e),i?t.setAttribute(at,JSON.stringify(i)):t.removeAttribute(at),t}getAttributes(t){return{id:t.getAttribute(r7),args:JSON.parse(t.getAttribute(at)||null)}}connectRoot(t){for(let e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw Error(`Cannot connect a root:
|
|
5
|
+
DOMLocalization already has a root from a different window.`)}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver(t=>this.translateMutations(t));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return(this.roots.delete(t),this.pauseObserving(),0===this.roots.size)?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){return Promise.all(Array.from(this.roots).map(t=>this.translateFragment(t)))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(let t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(let e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(let t of e.addedNodes)if(t.nodeType===t.ELEMENT_NODE)if(t.childElementCount)for(let e of this.getTranslatables(t))this.pendingElements.add(e);else t.hasAttribute(r7)&&this.pendingElements.add(t)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null}))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}async translateElements(t){if(!t.length)return;let e=t.map(this.getKeysForElement),i=await this.formatMessages(e);return this.applyTranslations(t,i)}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)void 0!==e[i]&&function(t,e){let{value:i}=e;if("string"==typeof i)if("title"===t.localName&&"http://www.w3.org/1999/xhtml"===t.namespaceURI)t.textContent=i;else if(rQ.test(i)){let e=t.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");e.innerHTML=i,function(t,e){for(let i of t.childNodes)if(i.nodeType!==i.TEXT_NODE){if(i.hasAttribute("data-l10n-name")){let s=function(t,e){let i=e.getAttribute("data-l10n-name"),s=t.querySelector(`[data-l10n-name="${i}"]`);return s?s.localName!==e.localName?(console.warn(`An element named "${i}" was found in the translation but its type ${e.localName} didn't match the element found in the source (${s.localName}).`),r1(e)):(t.removeChild(s),r3(e,s.cloneNode(!1))):(console.warn(`An element named "${i}" wasn't found in the source.`),r1(e))}(e,i);t.replaceChild(s,i);continue}if(function(t){let e=rJ[t.namespaceURI];return e&&e.includes(t.localName)}(i)){let e=function(t){let e=t.ownerDocument.createElement(t.localName);return r3(t,e)}(i);t.replaceChild(e,i);continue}console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),t.replaceChild(r1(i),i)}e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;r0(e,t)}(t[i],e[i]);this.resumeObserving()}getTranslatables(t){let e=Array.from(t.querySelectorAll(ae));return"function"==typeof t.hasAttribute&&t.hasAttribute(r7)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(r7),args:JSON.parse(t.getAttribute(at)||null)}}}class as{#o4;#n$;#s_;#o6;constructor({lang:t,isRTL:e},i=null){this.#s_=as.#o8(t),this.#o6=i,this.#o4=e??as.#o9(this.#s_)?"rtl":"ltr"}_setL10n(t){this.#o6=t}getLanguage(){return this.#s_}getDirection(){return this.#o4}async get(t,e=null,i){if(Array.isArray(t))return t=t.map(t=>({id:t})),(await this.#o6.formatMessages(t)).map(t=>t.value);let s=await this.#o6.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#n$||=new Set).add(t);try{this.#o6.connectRoot(t),await this.#o6.translateRoots()}catch{}}async translateOnce(t){try{await this.#o6.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#n$){for(let t of this.#n$)this.#o6.disconnectRoot(t);this.#n$.clear(),this.#n$=null}this.#o6.pauseObserving()}pause(){this.#o6.pauseObserving()}resume(){this.#o6.resumeObserving()}static #o8(t){return({en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"})[t=t?.toLowerCase()||"en-us"]||t}static #o9(t){return["ar","he","fa","ps","ur"].includes(t.split("-",1)[0])}}function an(){let{isAndroid:t,isLinux:e,isMac:i,isWindows:s}=s4.platform;return e?"linux":s?"windows":i?"macos":t?"android":"other"}function ar(t,e){let i=new rK(e),s=new rC(t,{functions:{PLATFORM:an}}),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class aa extends as{constructor(t){super({lang:t});const e=t?aa.#o7.bind(aa,"en-us",this.getLanguage()):aa.#lt.bind(aa,this.getLanguage());this._setL10n(new ai([],e))}static async *#o7(t,e){let{baseURL:i,paths:s}=await this.#le(),n=[e];if(t!==e){let i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}for(let[t,e]of n.map(t=>[t,this.#li(t,i,s)])){let i=await e;i?yield i:"en-us"===t&&(yield this.#ls(t))}}static async #li(t,e,i){let s=i[t];if(!s)return null;let n=new URL(s,e);return ar(t,await s6(n,"text"))}static async #le(){try{let{href:t}=document.querySelector('link[type="application/l10n"]'),e=await s6(t,"json");return{baseURL:t.substring(0,t.lastIndexOf("/")+1)||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async *#lt(t){yield this.#ls(t)}static async #ls(t){return ar(t,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-color-picker-free-text-input =\n .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-color-picker-ink-input =\n .title = Change drawing color\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-comment-floating-button =\n .title = Comment\n .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n .title = Comment\n .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-remove-signature-button =\n .title = Remove signature\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-editor-comments-sidebar-title =\n { $count ->\n [one] Comment\n *[other] Comments\n }\npdfjs-editor-comments-sidebar-close-button =\n .title = Close the sidebar\n .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading…\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-signature = Signature removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can’t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove comment\npdfjs-editor-delete-comment-popup-button =\n .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n .placeholder = Start typing…\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-edit-comment-button =\n .title = Edit comment')}}function ao(){return document.location.hash}class al{#oS=null;#ln=null;#oJ=null;#rp=null;#oR=null;#b;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new aa,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#b=t.uiManager,this.#oS=t.annotationLayer||null,this.#oR=t.textLayer||null,this.#ln=t.drawLayer||null,this.#oJ=t.onAppend||null,this.#rp=t.structTreeLayer||null}async render({viewport:t,intent:e="display"}){if("display"!==e||this._cancelled)return;let i=t.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:i}),this.show();return}let s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#b.direction,this.#oJ?.(s),this.annotationEditorLayer=new sG({uiManager:this.#b,div:s,structTreeLayer:this.#rp,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#oS,textLayer:this.#oR,drawLayer:this.#ln}),this.annotationEditorLayer.render({viewport:i,div:s,annotations:null,intent:e}),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var ah=new Map;let{maxTouchPoints:t,platform:e,userAgent:i}=navigator,s=/Android/.test(i);(/\b(iPad|iPhone|iPod)(?=;)/.test(i)||"MacIntel"===e&&t>1||s)&&ah.set("maxCanvasPixels",5242880),s&&ah.set("useSystemFonts",!1)}let ad={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},ac={allowedGlobalEvents:{value:null,kind:1},canvasMaxAreaInBytes:{value:-1,kind:5},isInAutomation:{value:!1,kind:1},localeProperties:{value:{lang:navigator.language||"en-US"},kind:1},maxCanvasDim:{value:32767,kind:3},nimbusDataStr:{value:"",kind:1},supportsCaretBrowsingMode:{value:!1,kind:1},supportsDocumentFonts:{value:!0,kind:1},supportsIntegratedFind:{value:!1,kind:1},supportsMouseWheelZoomCtrlKey:{value:!0,kind:1},supportsMouseWheelZoomMetaKey:{value:!0,kind:1},supportsPinchToZoom:{value:!0,kind:1},supportsPrinting:{value:!0,kind:1},toolbarDensity:{value:0,kind:17},altTextLearnMoreUrl:{value:"",kind:130},annotationEditorMode:{value:0,kind:130},annotationMode:{value:2,kind:130},capCanvasAreaFactor:{value:200,kind:130},commentLearnMoreUrl:{value:"",kind:130},cursorToolOnLoad:{value:0,kind:130},debuggerSrc:{value:"./debugger.mjs",kind:2},defaultZoomDelay:{value:400,kind:130},defaultZoomValue:{value:"",kind:130},disableHistory:{value:!1,kind:2},disablePageLabels:{value:!1,kind:130},enableAltText:{value:!1,kind:130},enableAltTextModelDownload:{value:!0,kind:146},enableAutoLinking:{value:!0,kind:130},enableComment:{value:!1,kind:130},enableDetailCanvas:{value:!0,kind:2},enableGuessAltText:{value:!0,kind:146},enableHighlightFloatingButton:{value:!1,kind:130},enableNewAltTextWhenAddingImage:{value:!0,kind:130},enableOptimizedPartialRendering:{value:!1,kind:130},enablePermissions:{value:!1,kind:130},enablePrintAutoRotate:{value:!0,kind:130},enableScripting:{value:!0,kind:130},enableSignatureEditor:{value:!1,kind:130},enableUpdatedAddImage:{value:!1,kind:130},externalLinkRel:{value:"noopener noreferrer nofollow",kind:2},externalLinkTarget:{value:0,kind:130},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:130},historyUpdateUrl:{value:!1,kind:130},ignoreDestinationZoom:{value:!1,kind:130},imageResourcesPath:{value:"./images/",kind:2},maxCanvasPixels:{value:0x2000000,kind:2},minDurationToUpdateCanvas:{value:500,kind:2},forcePageColors:{value:!1,kind:130},pageColorsBackground:{value:"Canvas",kind:130},pageColorsForeground:{value:"CanvasText",kind:130},pdfBugEnabled:{value:!1,kind:130},printResolution:{value:150,kind:2},sidebarViewOnLoad:{value:-1,kind:130},scrollModeOnLoad:{value:-1,kind:130},spreadModeOnLoad:{value:-1,kind:130},textLayerMode:{value:1,kind:130},viewerCssTheme:{value:0,kind:130},viewOnLoad:{value:0,kind:130},cMapPacked:{value:!0,kind:4},cMapUrl:{value:"../web/cmaps/",kind:4},disableAutoFetch:{value:!1,kind:132},disableFontFace:{value:!1,kind:132},disableRange:{value:!1,kind:132},disableStream:{value:!1,kind:132},docBaseUrl:{value:"",kind:4},enableHWA:{value:!0,kind:134},enableXfa:{value:!0,kind:132},fontExtraProperties:{value:!1,kind:4},iccUrl:{value:"../web/iccs/",kind:4},isEvalSupported:{value:!0,kind:4},isOffscreenCanvasSupported:{value:!0,kind:4},maxImageSize:{value:-1,kind:4},pdfBug:{value:!1,kind:4},standardFontDataUrl:{value:"../web/standard_fonts/",kind:4},useSystemFonts:{value:void 0,kind:4,type:ad.BOOLEAN+ad.UNDEFINED},verbosity:{value:1,kind:4},wasmUrl:{value:"../web/wasm/",kind:4},workerPort:{value:null,kind:8},workerSrc:{value:"../build/pdf.worker.mjs",kind:8}};ac.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:2},ac.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:2},ac.enableFakeMLManager={value:!0,kind:2},ac.disablePreferences={value:!1,kind:2};class au{static eventBus;static #lr=new Map;static{for(const t in ac)this.#lr.set(t,ac[t].value);for(const[t,e]of ah)this.#lr.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#lr.get(t)}static getAll(t=null,e=!1){let i=Object.create(null);for(let s in ac){let n=ac[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#lr.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;for(let s in this._hasInvokedSet||=!0,t){let n=ac[s],r=t[s];if(!n||!(typeof r==typeof n.value||ad[(typeof r).toUpperCase()]&n.type))continue;let{kind:a}=n;(!e||1&a||128&a)&&(this.eventBus&&16&a&&(i||=new Map).set(s,r),this.#lr.set(s,r))}if(i)for(let[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}function ap({width:t,height:e,left:i,top:s},n){if(0===t||0===e)return null;let r=n.textLayer.div.getBoundingClientRect(),a=n.getPagePoint(i-r.left,s-r.top),o=n.getPagePoint(i-r.left+t,s-r.top+e);return nI.normalizeRect([a[0],a[1],o[0],o[1]])}function ag(t,e){let i=t;do{if(i.nodeType===Node.TEXT_NODE){let t=i.textContent.length;if(e<=t)return[i,e];e-=t}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==t;)i=i.parentNode;i!==t&&(i=i.nextSibling)}while(i!==t)throw Error("Offset is bigger than container's contents length.")}class am{static #la=0;static #i;static findLinks(t){this.#i??=RegExp("\\b(?:https?:\\/\\/|mailto:|www\\.)(?:[\\S--[\\p{P}<>]]|\\/|[\\S--[\\[\\]]]+[\\S--[\\p{P}<>]])+|\\b[\\S--[@\\p{Ps}\\p{Pe}<>]]+@([\\S--[\\p{P}<>]]+(?:\\.[\\S--[\\p{P}<>]]+)+)","gmv");let[e,i]=n9(t,{ignoreDashEOL:!0}),s=e.matchAll(this.#i),n=[];for(let t of s){let e,[s,r]=t;if(s.startsWith("www.")||s.startsWith("http://")||s.startsWith("https://"))e=s;else{if(!URL.canParse(`http://${r}`))continue;e=s.startsWith("mailto:")?s:`mailto:${s}`}let a=s1(e,null,{addDefaultProtocol:!0});if(a){let[e,r]=n7(i,t.index,s.length);n.push({url:a.href,index:e,length:r})}}return n}static processLinks(t){return this.findLinks(t._textHighlighter.textContentItemsStr.join("\n")).map(e=>(function({url:t,index:e,length:i},s,n){let r=s._textHighlighter,[{begin:a,end:o}]=r._convertMatches([e],[i]),l=new Range;return l.setStart(...ag(r.textDivs[a.divIdx],a.offset)),l.setEnd(...ag(r.textDivs[o.divIdx],o.offset)),{id:`inferred_link_${n}`,unsafeUrl:t,url:t,annotationType:sQ.LINK,rotation:0,...function(t,e){let i=t.getClientRects();if(1===i.length)return{rect:ap(i[0],e)};let s=[1/0,1/0,-1/0,-1/0],n=[],r=0;for(let t of i){let i=ap(t,e);null!==i&&(n[r]=n[r+4]=i[0],n[r+1]=n[r+3]=i[3],n[r+2]=n[r+6]=i[2],n[r+5]=n[r+7]=i[1],nI.rectBoundingBox(...i,s),r+=8)}return{quadPoints:n,rect:s}}(l,s),borderStyle:null}})(e,t,this.#la++))}}class af{#lo=null;#ll=0;#lh=null;#ld=nB.INITIAL;#lc=null;#lu=0;#lp=null;canvas=null;div=null;enableOptimizedPartialRendering=!1;eventBus=null;id=null;pageColors=null;recordedBBoxes=null;renderingQueue=null;renderTask=null;resume=null;constructor(t){this.eventBus=t.eventBus,this.id=t.id,this.pageColors=t.pageColors||null,this.renderingQueue=t.renderingQueue,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.#ll=t.minDurationToUpdateCanvas??500}get renderingState(){return this.#ld}set renderingState(t){if(t!==this.#ld)switch(this.#ld=t,this.#lo&&(clearTimeout(this.#lo),this.#lo=null),t){case nB.PAUSED:this.div.classList.remove("loading"),this.#lu=0,this.#lc?.(!1);break;case nB.RUNNING:this.div.classList.add("loadingIcon"),this.#lo=setTimeout(()=>{this.div.classList.add("loading"),this.#lo=null},0),this.#lu=Date.now();break;case nB.INITIAL:case nB.FINISHED:this.div.classList.remove("loadingIcon","loading"),this.#lu=0}}_createCanvas(t,e=!1){let{pageColors:i}=this,s=!!(i?.background&&i?.foreground),n=this.canvas,r=!n&&!s&&!e,a=this.canvas=document.createElement("canvas");return this.#lc=e=>{if(r){let i=this.#lp;if(!e&&this.#ll>0){if(Date.now()-this.#lu<this.#ll)return;i||(i=this.#lp=a,t(a=this.canvas=a.cloneNode(!1)))}if(i){a.getContext("2d",{alpha:!1}).drawImage(i,0,0),e?this.#lg():this.#lu=Date.now();return}t(a),this.#lc=null;return}e&&(n?(n.replaceWith(a),n.width=n.height=0):t(a))},{canvas:a,prevCanvas:n}}#lm=t=>{if(this.#lc?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this)){this.renderingState=nB.PAUSED,this.resume=()=>{this.renderingState=nB.RUNNING,t()};return}t()};_resetCanvas(){let{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#lg())}#lg(){this.#lp&&(this.#lp.width=this.#lp.height=0,this.#lp=null)}async _drawCanvas(t,e,i){let s=this.renderTask=this.pdfPage.render(t);s.onContinue=this.#lm,s.onError=t=>{t instanceof nx&&(e(),this.#lh=null)};let n=null;try{await s.promise,this.#lc?.(!0)}catch(t){if(t instanceof nx)return;n=t,this.#lc?.(!0)}finally{this.#lh=n,s===this.renderTask&&(this.renderTask=null,this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=s.recordedBBoxes))}if(this.renderingState=nB.FINISHED,i(s),n)throw n}cancelRendering({cancelExtraDelay:t=0}={}){this.renderTask&&(this.renderTask.cancel(t),this.renderTask=null),this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(t,e){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:t,isDetailView:e,timestamp:performance.now(),error:this.#lh})}}class ab{#ln=null;constructor(t){this.pageIndex=t.pageIndex}async render({intent:t="display"}){"display"!==t||this.#ln||this._cancelled||(this.#ln=new s5({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#ln&&(this.#ln.destroy(),this.#ln=null)}setParent(t){this.#ln?.setParent(t)}getDrawLayer(){return this.#ln}}class av extends af{#lf=null;renderingCancelled=!1;constructor({pageView:t}){super(t),this.pageView=t,this.renderingId="detail"+this.id,this.div=t.div}setPdfPage(t){this.pageView.setPdfPage(t)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(t){this.renderingCancelled=!1,super.renderingState=t}reset({keepCanvas:t=!1}={}){let e=this.renderingCancelled||this.renderingState===nB.RUNNING||this.renderingState===nB.PAUSED;this.cancelRendering(),this.renderingState=nB.INITIAL,this.renderingCancelled=e,t||this._resetCanvas()}#lb(t){if(!this.#lf)return!0;let e=this.#lf.minX,i=this.#lf.minY,s=this.#lf.width+e,n=this.#lf.height+i;if(t.minX<e||t.minY<i||t.maxX>s||t.maxY>n)return!0;let{width:r,height:a,scale:o}=this.pageView.viewport;if(this.#lf.scale!==o)return!0;let l=t.minX-e,h=s-t.maxX,d=t.minY-i,c=n-t.maxY;return!!(e>0)&&!!(h/l>3)||!!(s<r)&&!!(l/h>3)||!!(i>0)&&!!(c/d>3)||!!(n<a)&&!!(d/c>3)}update({visibleArea:t=null,underlyingViewUpdated:e=!1}={}){if(e){this.cancelRendering(),this.renderingState=nB.INITIAL;return}if(!this.#lb(t))return;let{viewport:i,maxCanvasPixels:s,capCanvasAreaFactor:n}=this.pageView,r=t.maxX-t.minX,a=t.maxY-t.minY,o=r*a*ng.pixelRatio**2,l=Math.min(1,(Math.sqrt(ng.capPixels(s,n)/o)-1)/2);l<0&&(l=0);let h=r*l,d=a*l,c=Math.max(0,t.minX-h),u=Math.min(i.width,t.maxX+h),p=Math.max(0,t.minY-d),g=Math.min(i.height,t.maxY+d);this.#lf={minX:c,minY:p,width:u-c,height:g-p,scale:i.scale},this.reset({keepCanvas:!0})}_getRenderingContext(t,e){let i=this.pageView._getRenderingContext(t,e,!1),s=this.pdfPage.recordedBBoxes;if(!s||!this.enableOptimizedPartialRendering)return i;let{viewport:{width:n,height:r}}=this.pageView,{width:a,height:o,minX:l,minY:h}=this.#lf,d=l/n,c=h/r,u=(l+a)/n,p=(h+o)/r;return{...i,operationsFilter:t=>!s.isEmpty(t)&&s.minX(t)<=u&&s.maxX(t)>=d&&s.minY(t)<=p&&s.maxY(t)>=c}}async draw(){if(this.pageView.detailView!==this)return;let t=this.pageView.renderingState===nB.FINISHED||this.renderingState===nB.FINISHED;this.renderingState!==nB.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());let{div:e,pdfPage:i,viewport:s}=this.pageView;if(!i)throw this.renderingState=nB.FINISHED,Error("pdfPage is not loaded");this.renderingState=nB.RUNNING;let n=this.pageView._ensureCanvasWrapper(),{canvas:r,prevCanvas:a}=this._createCanvas(t=>{n.firstElementChild?.tagName==="CANVAS"?n.firstElementChild.after(t):n.prepend(t)},t);r.ariaHidden=!0,this.enableOptimizedPartialRendering&&(r.className="detailView");let{width:o,height:l}=s,h=this.#lf,{pixelRatio:d}=ng,c=[d,0,0,d,-h.minX*d,-h.minY*d];r.width=h.width*d,r.height=h.height*d;let{style:u}=r;u.width=`${100*h.width/o}%`,u.height=`${100*h.height/l}%`,u.top=`${100*h.minY/l}%`,u.left=`${100*h.minX/o}%`;let p=this._drawCanvas(this._getRenderingContext(r,c),()=>{this.canvas?.remove(),this.canvas=a},()=>{this.dispatchPageRendered(!1,!0)});return e.setAttribute("data-loaded",!0),this.dispatchPageRender(),p}}let ay={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},aw=/^H(\d+)$/;class ax{#lv;#ly=null;#lw;#lx=new Map;#lA;#l_=null;constructor(t,e){this.#lv=t.getStructTree(),this.#lA=e}async render(){if(this.#lw)return this.#lw;let{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#lw=t;try{this.#ly=this.#lC(await this.#lv)}catch(t){i(t)}return this.#lv=null,this.#ly?.classList.add("structTree"),e(this.#ly),t}async getAriaAttributes(t){try{return await this.render(),this.#lx.get(t)}catch{}return null}hide(){this.#ly&&!this.#ly.hidden&&(this.#ly.hidden=!0)}show(){this.#ly?.hidden&&(this.#ly.hidden=!1)}#lS(t,e){let{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1,n=nH(i);for(let e of t.children)if("annotation"===e.type){let t=this.#lx.get(e.id);t||(t=new Map,this.#lx.set(e.id,t)),t.set("aria-label",n),s=!0}s||e.setAttribute("aria-label",n)}void 0!==s&&e.setAttribute("aria-owns",s),void 0!==n&&e.setAttribute("lang",nH(n,!0))}#lE(t,e){let{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#lA||!i||!s||r?.type!=="content")return!1;let{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);let o=document.createElement("span");(this.#l_||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",nH(i));let{pageHeight:l,pageX:h,pageY:d}=this.#lA,c="calc(var(--total-scale-factor) *",{style:u}=o;return u.width=`${c}${s[2]-s[0]}px)`,u.height=`${c}${s[3]-s[1]}px)`,u.left=`${c}${s[0]-h}px)`,u.top=`${c}${l-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#l_){for(let[t,e]of this.#l_)document.getElementById(t)?.append(e);this.#l_.clear(),this.#l_=null}}#lC(t){if(!t)return null;let e=document.createElement("span");if("role"in t){let{role:i}=t,s=i.match(aw);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):ay[i]&&e.setAttribute("role",ay[i]),"Figure"===i&&this.#lE(t,e))return e}if(this.#lS(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#lS(t.children[0],e);else for(let i of t.children)e.append(this.#lC(i));return e}}class aA{#lT=!1;#lP=null;#lM=new Map;#lk=new Map;setTextMapping(t){this.#lP=t}static #lD(t,e){let i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return -1;let n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;return a<=o&&h>=r?-1:h<=n&&a>=l?1:i.x+i.width/2-(s.x+s.width/2)}enable(){if(this.#lT)throw Error("TextAccessibilityManager is already enabled.");if(!this.#lP)throw Error("Text divs and strings have not been set.");if(this.#lT=!0,this.#lP=this.#lP.slice(),this.#lP.sort(aA.#lD),this.#lM.size>0){let t=this.#lP;for(let[e,i]of this.#lM){if(!document.getElementById(e)){this.#lM.delete(e);continue}this.#lI(e,t[i])}}for(let[t,e]of this.#lk)this.addPointerInTextLayer(t,e);this.#lk.clear()}disable(){this.#lT&&(this.#lk.clear(),this.#lP=null,this.#lT=!1)}removePointerInTextLayer(t){if(!this.#lT)return void this.#lk.delete(t);let e=this.#lP;if(!e||0===e.length)return;let{id:i}=t,s=this.#lM.get(i);if(void 0===s)return;let n=e[s];this.#lM.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&((r=r.split(" ").filter(t=>t!==i).join(" "))?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#lI(t,e){let i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){let{id:i}=t;if(!i)return null;if(!this.#lT)return this.#lk.set(t,e),null;e&&this.removePointerInTextLayer(t);let s=this.#lP;if(!s||0===s.length)return null;let n=Math.max(0,n$(s,e=>0>aA.#lD(t,e))-1),r=s[n];this.#lI(i,r),this.#lM.set(i,n);let a=r.parentNode;return a?.classList.contains("markedContent")?a.id:null}moveElementInDOM(t,e,i,s){let n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;let r=Array.from(t.childNodes).filter(t=>t!==e);if(0===r.length)return n;let a=i||e,o=n$(r,t=>0>aA.#lD(a,t));return 0===o?r[0].before(e):r[o-1].after(e),n}}class a_{#oZ=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw Error("Text divs and strings have not been set.");if(this.enabled)throw Error("TextHighlighter is already enabled.");this.enabled=!0,this.#oZ||(this.#oZ=new AbortController,this.eventBus._on("updatetextlayermatches",t=>{(t.pageIndex===this.pageIdx||-1===t.pageIndex)&&this._updateMatches()},{signal:this.#oZ.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#oZ?.abort(),this.#oZ=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];let{textContentItemsStr:i}=this,s=0,n=0,r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==r&&l>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");let h={begin:{divIdx:s,offset:l-n}};for(l+=e[o];s!==r&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},a.push(h)}return a}_renderMatches(t){if(0===t.length)return;let{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx,o=e.state.highlightAll,l=null,h;function d(t,e){let i=t.divIdx;return n[i].textContent="",c(i,0,t.offset,e)}function c(t,e,i,r){let a=n[t];if(a.nodeType===Node.TEXT_NODE){let e=document.createElement("span");a.before(e),e.append(a),n[t]=e,a=e}let o=s[t].substring(e,i),l=document.createTextNode(o);if(r){let t=document.createElement("span");if(t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")){let{left:e}=t.getClientRects()[0];return e-a.getBoundingClientRect().left}return 0}return a.append(l),0}let u=a,p=u+1;if(o)u=0,p=t.length;else if(!r)return;let g=-1,m=-1;for(let s=u;s<p;s++){let o=t[s],u=o.begin;if(u.divIdx===g&&u.offset===m)continue;g=u.divIdx,m=u.offset;let p=o.end,f=r&&s===a,b=f?" selected":"",v=0;if(l&&u.divIdx===l.divIdx?c(l.divIdx,l.offset,u.offset):(null!==l&&c(l.divIdx,l.offset,h),d(u)),u.divIdx===p.divIdx)v=c(u.divIdx,u.offset,p.offset,"highlight"+b);else{v=c(u.divIdx,u.offset,h,"highlight begin"+b);for(let t=u.divIdx+1,e=p.divIdx;t<e;t++)n[t].className="highlight middle"+b;d(p,"highlight end"+b)}l=p,f&&e.scrollMatchIntoView({element:n[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}l&&c(l.divIdx,l.offset,h)}_updateMatches(t=!1){if(!this.enabled&&!t)return;let{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this,a=-1;for(let t of i){let e=Math.max(a,t.begin.divIdx);for(let i=e,s=t.end.divIdx;i<=s;i++){let t=r[i];t.textContent=n[i],t.className=""}a=t.end.divIdx+1}if(!e?.highlightMatches||t)return;let o=e.pageMatches[s]||null,l=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class aC{#lL=!1;#oJ=null;#lR=!1;#oR=null;static #lF=new Map;static #lB=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#lL=!0===s,this.#oJ=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render({viewport:t,textContentParams:e=null}){if(this.#lR&&this.#oR){this.#oR.update({viewport:t,onBefore:this.hide.bind(this)}),this.show();return}this.cancel(),this.#oR=new nM({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});let{textDivs:i,textContentItemsStr:s}=this.#oR;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#oR.render(),this.#lR=!0;let n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#lN(n),this.#oJ?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#lR&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#lR&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#oR?.cancel(),this.#oR=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),aC.#lO(this.div)}#lN(t){let{div:e}=this;e.addEventListener("mousedown",()=>{e.classList.add("selecting")}),e.addEventListener("copy",t=>{if(!this.#lL){let e=document.getSelection();t.clipboardData.setData("text/plain",nH(nu(e.toString())))}nT(t)}),aC.#lF.set(e,t),aC.#lj()}static #lO(t){this.#lF.delete(t),0===this.#lF.size&&(this.#lB?.abort(),this.#lB=null)}static #lj(){var t,e;if(this.#lB)return;this.#lB=new AbortController;let{signal:i}=this.#lB,s=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")},n=!1;document.addEventListener("pointerdown",()=>{n=!0},{signal:i}),document.addEventListener("pointerup",()=>{n=!1,this.#lF.forEach(s)},{signal:i}),window.addEventListener("blur",()=>{n=!1,this.#lF.forEach(s)},{signal:i}),document.addEventListener("keyup",()=>{n||this.#lF.forEach(s)},{signal:i}),document.addEventListener("selectionchange",()=>{let i=document.getSelection();if(0===i.rangeCount)return void this.#lF.forEach(s);let n=new Set;for(let t=0;t<i.rangeCount;t++){let e=i.getRangeAt(t);for(let t of this.#lF.keys())!n.has(t)&&e.intersectsNode(t)&&n.add(t)}for(let[t,e]of this.#lF)n.has(t)?t.classList.add("selecting"):s(e,t);if(t??="none"===getComputedStyle(this.#lF.values().next().value).getPropertyValue("-moz-user-select"))return;let r=i.getRangeAt(0),a=e&&(0===r.compareBoundaryPoints(Range.END_TO_END,e)||0===r.compareBoundaryPoints(Range.START_TO_END,e)),o=a?r.startContainer:r.endContainer;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentNode),!a&&0===r.endOffset)do{for(;!o.previousSibling;)o=o.parentNode;o=o.previousSibling}while(!o.childNodes.length)let l=o.parentElement?.closest(".textLayer"),h=this.#lF.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,a?o:o.nextSibling)),e=r.cloneRange()},{signal:i})}}class aS{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render({viewport:t,intent:e="display"}){if("print"===e){let i={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),i.div=this.div,nF.render(i)}let i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};let s={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div?nF.update(s):(this.div=document.createElement("div"),s.div=this.div,nF.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}let aE={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new ri}},aT=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class aP extends af{#lU=sY.ENABLE_FORMS;#lz=null;#j=null;#lH=!0;#l$=!1;#eD=!1;#lV=null;#lG=!1;#lW=null;#lq=null;#lX=1;#lK=1;#lY=1;#lQ=1;#lJ={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#lZ=[null,null,null,null];constructor(t){super(t);const e=t.container,i=t.defaultViewport;this.renderingId="page"+this.id,this.#lV=t.layerProperties||aE,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#lY=t.textLayerMode??1,this.#lU=t.annotationMode??sY.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.enableDetailCanvas=t.enableDetailCanvas??!0,this.maxCanvasPixels=t.maxCanvasPixels??au.get("maxCanvasPixels"),this.maxCanvasDim=t.maxCanvasDim||au.get("maxCanvasDim"),this.capCanvasAreaFactor=t.capCanvasAreaFactor??au.get("capCanvasAreaFactor"),this.#lH=!1!==t.enableAutoLinking,this.#j=t.commentManager||null,this.l10n=t.l10n,this.l10n||=new aa,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null,this.detailView=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#l0(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*nw.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=t;i&&i.then(t=>{i===this._optionalContentConfigPromise&&(this.#lJ.initialOptionalContent=t.hasInitialVisibility)}),t.l10n||this.l10n.translate(this.div)}}#l1(t,e){let i=aT.get(e),s=this.#lZ[i];if(this.#lZ[i]=t,s)return void s.replaceWith(t);for(let e=i-1;e>=0;e--){let i=this.#lZ[e];if(i)return void i.after(t)}this.div.prepend(t)}#l0(){let{div:t,viewport:e}=this;if(e.userUnit!==this.#lQ&&(1!==e.userUnit?t.style.setProperty("--user-unit",e.userUnit):t.style.removeProperty("--user-unit"),this.#lQ=e.userUnit),this.pdfPage){if(this.#lq===e.rotation)return;this.#lq=e.rotation}nC(t,e,!0,!1)}setPdfPage(t){this._isStandalone&&(this.pageColors?.foreground==="CanvasText"||this.pageColors?.background==="Canvas")&&(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;let e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*nw.PDF_TO_CSS_UNITS,rotation:e}),this.#l0(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return nS(this,"_textHighlighter",new a_({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#lV.findController}))}#l2(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async #l3(){let t=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer})}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#l2("annotationlayerrendered",t)}}async #l5(){let t=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#l2("annotationeditorlayerrendered",t)}}async #l4(){try{await this.drawLayer.render({intent:"display"})}catch(t){console.error("#renderDrawLayer:",t)}}async #l6(){let t=null;try{let t=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});t?.textDivs&&this._textHighlighter&&this.#l8(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#l1(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#l2("xfalayerrendered",t)}}async #l9(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render({viewport:this.viewport})}catch(e){if(e instanceof sV)return;console.error("#renderTextLayer:",e),t=e}this.#l2("textlayerrendered",t),this.#l7()}async #l7(){if(!this.textLayer)return;let t=await this.structTreeLayer?.render();t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async #l8(t){let e=await this.pdfPage.getTextContent(),i=[];for(let t of e.items)i.push(t.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}async #ht(t){try{if(await t,!this.annotationLayer)return;await this.annotationLayer.injectLinkAnnotations(am.processLinks(this))}catch(t){console.error("#injectLinkAnnotations:",t)}}_resetCanvas(){super._resetCanvas(),this.#lW=null}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1,preserveDetailViewState:r=!1}={}){let a=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=nB.INITIAL;let o=this.div,l=o.childNodes,h=t&&this.annotationLayer?.div||null,d=e&&this.annotationEditorLayer?.div||null,c=i&&this.xfaLayer?.div||null,u=s&&this.textLayer?.div||null,p=n&&this.#lz||null;for(let t=l.length-1;t>=0;t--){let e=l[t];switch(e){case h:case d:case c:case u:case p:continue}if(a&&e.classList.contains("pdfBugGroupsLayer"))continue;e.remove();let i=this.#lZ.indexOf(e);i>=0&&(this.#lZ[i]=null)}o.removeAttribute("data-loaded"),h&&this.annotationLayer.hide(),d&&this.annotationEditorLayer.hide(),c&&this.xfaLayer.hide(),u&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#lz&&(this.#lz=null,this._resetCanvas()),!r&&(this.detailView?.reset({keepCanvas:n}),n||(this.detailView=null))}toggleEditingMode(t){this.#eD=t,this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(t){this.enableDetailCanvas&&(this.#lG&&this.maxCanvasPixels>0&&t?(this.detailView??=new av({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering}),this.detailView.update({visibleArea:t})):this.detailView&&(this.detailView.reset(),this.detailView=null))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then(t=>{i===this._optionalContentConfigPromise&&(this.#lJ.initialOptionalContent=t.hasInitialVisibility)})),this.#lJ.directDrawing=!0;let n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*nw.PDF_TO_CSS_UNITS,rotation:n}),this.#l0(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.#he(),this.canvas){let t=this.#l$&&this.#lG,e=s>=0&&s<1e3;if(e||t){e&&!t&&this.renderingState!==nB.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=nB.FINISHED,this.#lJ.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),e||(this.detailView?.update({underlyingViewUpdated:!0}),this.dispatchPageRendered(!0,!1));return}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0}),this.detailView?.update({underlyingViewUpdated:!0})}#he(){let{width:t,height:e}=this.viewport,i=this.outputScale=new ng;if(0===this.maxCanvasPixels){let t=1/this.scale;i.sx*=t,i.sy*=t,this.#lG=!0}else if(this.#lG=i.limitCanvas(t,e,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor),this.#lG&&this.enableDetailCanvas){let t=this.enableOptimizedPartialRendering?4:2;i.sx/=t,i.sy/=t}}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){super.cancelRendering({cancelExtraDelay:n}),!this.textLayer||s&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),!this.annotationLayer||t&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationEditorLayer||e&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){let{canvas:r}=this;if(!r)return;let a=this.#lW;if(this.viewport!==a){let t=(360+this.viewport.rotation-a.rotation)%360;if(90===t||270===t){let{width:e,height:i}=this.viewport;r.style.transform=`rotate(${t}deg) scale(${i/e},${e/i})`}else r.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#l3(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#l4(),this.#l5()),i&&this.xfaLayer&&this.#l6(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#l9())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}_ensureCanvasWrapper(){let t=this.#lz;return t||((t=this.#lz=document.createElement("div")).classList.add("canvasWrapper"),this.#l1(t,"canvasWrapper")),t}_getRenderingContext(t,e,i){return{canvas:t,transform:e,viewport:this.viewport,annotationMode:this.#lU,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:this.#eD,recordOperations:i}}async draw(){var t,e,i,s;this.renderingState!==nB.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());let{div:n,l10n:r,pdfPage:a,viewport:o}=this;if(!a)throw this.renderingState=nB.FINISHED,Error("pdfPage is not loaded");this.renderingState=nB.RUNNING;let l=this._ensureCanvasWrapper();if(this.textLayer||0===this.#lY||a.isPureXfa||(this._accessibilityManager||=new aA,this.textLayer=new aC({pdfPage:a,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:2===this.#lY,onAppend:t=>{this.l10n.pause(),this.#l1(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#lU!==sY.DISABLE){let{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableComment:s,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:o,linkService:l}=this.#lV;this._annotationCanvasMap||=new Map,this.annotationLayer=new rs({pdfPage:a,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#lU===sY.ENABLE_FORMS,linkService:l,downloadManager:i,enableComment:s,enableScripting:n,hasJSActionsPromise:o,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,commentManager:this.#j,onAppend:t=>{this.#l1(t,"annotationLayer")}})}let{width:h,height:d}=o;this.#lW=o;let{canvas:c,prevCanvas:u}=this._createCanvas(t=>{l.prepend(t)});c.setAttribute("role","presentation"),this.outputScale||this.#he();let{outputScale:p}=this;this.#l$=this.#lG;let g=nV(p.sx),m=nV(p.sy),f=c.width=(t=nX(h*p.sx))-t%g[0],b=c.height=(e=nX(d*p.sy))-e%m[0],v=(i=nX(h))-i%g[1],y=(s=nX(d))-s%m[1];p.sx=f/v,p.sy=b/y,this.#lX!==g[1]&&(n.style.setProperty("--scale-round-x",`${g[1]}px`),this.#lX=g[1]),this.#lK!==m[1]&&(n.style.setProperty("--scale-round-y",`${m[1]}px`),this.#lK=m[1]);let w=this.enableOptimizedPartialRendering&&this.#l$&&!this.recordedBBoxes,x=p.scaled?[p.sx,0,0,p.sy,0,0]:null,A=this._drawCanvas(this._getRenderingContext(c,x,w),()=>{u?.remove(),this._resetCanvas()},t=>{this.#lJ.regularAnnotations=!t.separateAnnots,this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==nB.FINISHED)return;this.structTreeLayer||=new ax(a,o.rawDims);let t=this.#l9();this.annotationLayer&&(await this.#l3(),this.#lH&&this.annotationLayer&&this.textLayer&&await this.#ht(t));let{annotationEditorUIManager:e}=this.#lV;e&&(this.drawLayer||=new ab({pageIndex:this.id}),await this.#l4(),this.drawLayer.setParent(l),(this.annotationLayer||this.#lU===sY.DISABLE)&&(this.annotationEditorLayer||=new al({uiManager:e,pdfPage:a,l10n:r,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#l1(t,"annotationEditorLayer")}}),this.#l5()))});if(a.isPureXfa){if(!this.xfaLayer){let{annotationStorage:t,linkService:e}=this.#lV;this.xfaLayer=new aS({pdfPage:a,annotationStorage:t,linkService:e})}this.#l6()}return n.setAttribute("data-loaded",!0),this.dispatchPageRender(),A}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){let{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#lJ;return t&&e&&i?this.canvas:null}}async function aM(t){let{info:e,metadata:i,contentDispositionFilename:s,contentLength:n}=await t.getMetadata();return{...e,baseURL:"",filesize:n||(await t.getDownloadInfo()).length,filename:s||nt(""),metadata:i?.getRaw(),authors:i?.get("dc:creator"),numPages:t.numPages,URL:""}}class ak{constructor(t){this._ready=new Promise((e,i)=>{import(t).then(t=>{e(t.QuickJSSandbox())}).catch(i)})}async createSandbox(t){(await this._ready).create(t)}async dispatchEventInSandbox(t){let e=await this._ready;setTimeout(()=>e.dispatchEvent(t),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class aD{#hi=null;#hs=null;#hn=null;#oZ=null;#nf=null;#hr=null;#tb=null;#ha=null;#ho=!1;#hl=null;#hh=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#nf=t,this.#hr=e,this.#hn=i}setViewer(t){this.#ha=t}async setDocument(t){if(this.#tb&&await this.#hd(),this.#tb=t,!t)return;let[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#hd();if(t!==this.#tb)return;try{this.#hl=this.#hc()}catch(t){console.error("setDocument:",t),await this.#hd();return}let n=this.#nf;this.#oZ=new AbortController;let{signal:r}=this.#oZ;n._on("updatefromsandbox",t=>{t?.source===window&&this.#hu(t.detail)},{signal:r}),n._on("dispatcheventinsandbox",t=>{this.#hl?.dispatchEventInSandbox(t.detail)},{signal:r}),n._on("pagechanging",({pageNumber:t,previous:e})=>{t!==e&&(this.#hp(e),this.#hg(t))},{signal:r}),n._on("pagerendered",({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#ha.currentPageNumber&&this.#hg(t)},{signal:r}),n._on("pagesdestroy",async()=>{await this.#hp(this.#ha.currentPageNumber),await this.#hl?.dispatchEventInSandbox({id:"doc",name:"WillClose"}),this.#hi?.resolve()},{signal:r});try{let r=await this.#hn(t);if(t!==this.#tb)return;await this.#hl.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){console.error("setDocument:",t),await this.#hd();return}await this.#hl?.dispatchEventInSandbox({id:"doc",name:"Open"}),await this.#hg(this.#ha.currentPageNumber,!0),Promise.resolve().then(()=>{t===this.#tb&&(this.#ho=!0)})}async dispatchWillSave(){return this.#hl?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#hl?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#hl){await this.#hh?.promise,this.#hh=Promise.withResolvers();try{await this.#hl.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#hh.resolve(),this.#hh=null,t}await this.#hh.promise}}async dispatchDidPrint(){return this.#hl?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#hs?.promise||null}get ready(){return this.#ho}get _pageOpenPending(){return nS(this,"_pageOpenPending",new Set)}get _visitedPages(){return nS(this,"_visitedPages",new Map)}async #hu(t){let e=this.#ha,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":i||(e.spreadMode=function(t){let e=nN.VERTICAL,i=nO.NONE;switch(t){case"SinglePage":e=nN.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=nN.PAGE;case"TwoColumnLeft":i=nO.ODD;break;case"TwoPageRight":e=nN.PAGE;case"TwoColumnRight":i=nO.EVEN}return{scrollMode:e,spreadMode:i}}(a).spreadMode);break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#nf.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#nf.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#hh?.resolve(),this.#hh=null}return}if(!i||!t.focus)for(let e of(delete t.id,delete t.siblings,n?[s,...n]:[s])){let i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#tb?.annotationStorage.setValue(e,t)}}async #hg(t,e=!1){let i=this.#tb,s=this._visitedPages;if(e&&(this.#hi=Promise.withResolvers()),!this.#hi)return;let n=this.#ha.getPageView(t-1);if(n?.renderingState!==nB.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);let r=(async()=>{let e=await (!s.has(t)?n.pdfPage?.getJSActions():null);i===this.#tb&&await this.#hl?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e})})();s.set(t,r)}async #hp(t){let e=this.#tb,i=this._visitedPages;if(!this.#hi||this._pageOpenPending.has(t))return;let s=i.get(t);s&&(i.set(t,null),await s,e===this.#tb&&await this.#hl?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t}))}#hc(){if(this.#hs=Promise.withResolvers(),this.#hl)throw Error("#initScripting: Scripting already exists.");return this.#hr.createScripting()}async #hd(){if(!this.#hl){this.#tb=null,this.#hs?.resolve();return}this.#hi&&(await Promise.race([this.#hi.promise,new Promise(t=>{setTimeout(t,1e3)})]).catch(()=>{}),this.#hi=null),this.#tb=null;try{await this.#hl.destroySandbox()}catch{}this.#hh?.reject(Error("Scripting destroyed.")),this.#hh=null,this.#oZ?.abort(),this.#oZ=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#hl=null,this.#ho=!1,this.#hs?.resolve()}}class aI{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||!this.printing&&this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1,n=!1){let r=t.views,a=r.length;if(0===a)return null;for(let t=0;t<a;t++){let e=r[t].view;if(!this.isViewFinished(e))return e}if(!n)for(let t=0;t<a;t++){let{detailView:e}=r[t].view;if(e&&!this.isViewFinished(e))return e}let o=t.first.id,l=t.last.id;if(l-o+1>a){let s=t.ids;for(let t=1,n=l-o;t<n;t++){let n=i?o+t:l-t;if(s.has(n))continue;let r=e[n-1];if(!this.isViewFinished(r))return r}}let h=i?l:o-2,d=e[h];return d&&!this.isViewFinished(d)||s&&(h+=i?1:-1,(d=e[h])&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===nB.FINISHED}renderView(t){switch(t.renderingState){case nB.FINISHED:return!1;case nB.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case nB.RUNNING:this.highestPriorityPage=t.renderingId;break;case nB.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof nx||console.error("renderView:",t)})}return!0}}function aL(t){return Object.values(sq).includes(t)&&t!==sq.DISABLE}class aR{#hm=new Set;#hf=0;constructor(t){this.#hf=t}push(t){let e=this.#hm;e.has(t)&&e.delete(t),e.add(t),e.size>this.#hf&&this.#hb()}resize(t,e=null){this.#hf=t;let i=this.#hm;if(e){let t=i.size,s=1;for(let n of i)if(e.has(n.id)&&(i.delete(n),i.add(n)),++s>t)break}for(;i.size>this.#hf;)this.#hb()}has(t){return this.#hm.has(t)}[Symbol.iterator](){return this.#hm.keys()}#hb(){let t=this.#hm.keys().next().value;t?.destroy(),this.#hm.delete(t)}}class aF{#i5=null;#F=null;#hv=null;#hy=sq.NONE;#hw=null;#lU=sY.ENABLE_FORMS;#j=null;#hx=null;#hA=null;#iu=!1;#q=!1;#lL=!1;#X=!1;#K=!1;#lH=!0;#oZ=null;#ll=0;#td=null;#h_=!0;#hC=null;#hS=null;#hE=null;#hT=!1;#hP=null;#hM=!1;#hk=0;#hD=new ResizeObserver(this.#hI.bind(this));#hL=null;#hR=null;#tg=null;#hF=!0;#lY=1;#t_=null;constructor(t){const e="5.4.296";if(nR!==e)throw Error(`The API version "${nR}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,this.#t_=t.viewerAlert||null,this.container?.tagName!=="DIV"||this.viewer?.tagName!=="DIV")throw Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw Error("The `container` must be absolutely positioned.");this.#hD.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new ri,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#F=t.altTextManager||null,this.#j=t.commentManager||null,this.#tg=t.signatureManager||null,this.#hA=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#lY=t.textLayerMode??1,this.#lU=t.annotationMode??sY.ENABLE_FORMS,this.#hy=t.annotationEditorMode??sq.NONE,this.#hv=t.annotationEditorHighlightColors||null,this.#q=!0===t.enableHighlightFloatingButton,this.#X=!0===t.enableUpdatedAddImage,this.#K=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.maxCanvasDim=t.maxCanvasDim,this.capCanvasAreaFactor=t.capCanvasAreaFactor,this.enableDetailCanvas=t.enableDetailCanvas??!0,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.l10n=t.l10n,this.l10n||=new aa,this.#lL=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#td=t.mlManager||null,this.#iu=t.enableHWA||!1,this.#hF=!1!==t.supportsPinchToZoom,this.#lH=!1!==t.enableAutoLinking,this.#ll=t.minDurationToUpdateCanvas??500,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new aI,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",()=>{this.#hD.disconnect(),this.#hD=null},{once:!0}),this.scroll=function(t,e,i){let s=function(i){r||(r=window.requestAnimationFrame(function(){r=null;let i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;let a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)}))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s},r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",()=>window.cancelAnimationFrame(r),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=0,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#hB(),this.eventBus._on("thumbnailrendered",({pageNumber:t,pdfPage:e})=>{let i=this._pages[t-1];this.#i5.has(i)||e?.cleanup()}),t.l10n||this.l10n.translate(this.container)}get printingAllowed(){return this.#h_}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#i5)}get pageViewsReady(){return this._pages.every(t=>t?.pdfPage)}get renderForms(){return this.#lU===sY.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#hN(),!0;if(!(0<t&&t<=this.pagesCount))return!1;let i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#hN(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){let i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw Error("Invalid numeric scale.");this.pdfDocument&&this.#hO(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#hO(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!nG(t))throw Error("Invalid pages rotation angle.");if(!this.pdfDocument||((t%=360)<0&&(t+=360),this._pagesRotation===t))return;this._pagesRotation=t;let e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#hO(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){let t=this;return nS(this,"_layerProperties",{get annotationEditorUIManager(){return t.#hw},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableComment(){return!!t.#j},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#hj(t){let e={annotationEditorMode:this.#hy,annotationMode:this.#lU,textLayerMode:this.#lY};return t?(this.#h_=t.includes(ny.PRINT_HIGH_QUALITY)||t.includes(ny.PRINT),this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#h_}),t.includes(ny.COPY)||1!==this.#lY||(e.textLayerMode=2),t.includes(ny.MODIFY_CONTENTS)||(e.annotationEditorMode=sq.DISABLE),t.includes(ny.MODIFY_ANNOTATIONS)||t.includes(ny.FILL_INTERACTIVE_FORMS)||this.#lU!==sY.ENABLE_FORMS||(e.annotationMode=sY.ENABLE)):(this.#h_=!0,this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#h_})),e}async #hU(t){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;let e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&e.resolve()},{signal:AbortSignal.any([t,i.signal])}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){let t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#hM)return null;e.length=0;let s=await this.pdfDocument.getPage(i),{items:n}=await s.getTextContent();for(let t of n)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(nH(e.join("")))}return t.join("\n")}#hz(t,e){let i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#hP)){if(this.#hT||2===t)return void nT(e);this.#hT=!0;let{classList:i}=this.viewer;i.add("copyAll");let s=new AbortController;window.addEventListener("keydown",t=>this.#hM="Escape"===t.key,{signal:s.signal}),this.getAllText().then(async t=>{null!==t&&await navigator.clipboard.writeText(t)}).catch(t=>{console.warn(`Something goes wrong when extracting the text: ${t.message}`)}).finally(()=>{this.#hT=!1,this.#hM=!1,s.abort(),i.remove("copyAll")}),nT(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#hw?.destroy(),this.#hw=null,this.#hy=sq.NONE,this.#h_=!0),this.pdfDocument=t,!t)return;let e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#lL?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#oZ=new AbortController;let{signal:l}=this.#oZ;if(e>1e4){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");let t=this._scrollMode=nN.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then(()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})},()=>{});let h=t=>{let e=this._pages[t.pageNumber-1];e&&this.#i5.push(e)};r._on("pagerender",h,{signal:l});let d=t=>{t.cssTransform||t.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),r._off("pagerendered",d))};r._on("pagerendered",d,{signal:l}),Promise.all([i,n]).then(([i,n])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=s;let{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#hj(n);if(0!==c){let t=this.#hP=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}h!==sq.DISABLE&&(t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):aL(h)?(this.#hw=new sX(this.container,o,this.#t_,this.#F,this.#j,this.#tg,r,t,a,this.#hv,this.#q,this.#X,this.#K,this.#td,this.#hA,this.#hF),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#hw}),h!==sq.NONE&&(this.#hH(h),this.#hw.updateMode(h))):console.error(`Invalid AnnotationEditor mode: ${h}`));let u=this._scrollMode===nN.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*nw.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),(a?.foreground==="CanvasText"||a?.background==="Canvas")&&(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let t=1;t<=e;++t){let e=new aP({container:u,eventBus:r,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#iu,enableAutoLinking:this.#lH,minDurationToUpdateCanvas:this.#ll,commentManager:this.#j});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===nN.PAGE?this.#h$():this._spreadMode!==nO.NONE&&this._updateSpreadMode(),r._on("annotationeditorlayerrendered",t=>{this.#hw&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#hy})},{once:!0,signal:l}),this.#hU(l).then(async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#hP&&document.addEventListener("copy",this.#hz.bind(this,c),{signal:l}),t.loadingParams.disableAutoFetch||e>5e3)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)return void this._pagesCapability.resolve();for(let s=2;s<=e;++s){let e=t.getPage(s).then(t=>{let e=this._pages[s-1];e.pdfPage||e.setPdfPage(t),0==--i&&this._pagesCapability.resolve()},t=>{console.error(`Unable to get page ${s} to initialize viewer`,t),0==--i&&this._pagesCapability.resolve()});s%250==0&&await e}}),r.dispatch("pagesinit",{source:this}),t.getMetadata().then(({info:e})=>{t===this.pdfDocument&&e.Language&&(o.lang=e.Language)}),this.defaultRenderingQueue&&this.update()}).catch(t=>{console.error("Unable to initialize viewer",t),this._pagesCapability.reject(t)})}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,e=this._pages.length;t<e;t++)this._pages[t].setPageLabel(this._pageLabels?.[t]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#i5=new aR(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=nN.VERTICAL,this._previousScrollMode=nN.UNKNOWN,this._spreadMode=nO.NONE,this.#hL={previousPageNumber:1,scrollDown:!0,pages:[]},this.#oZ?.abort(),this.#oZ=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#hP?.remove(),this.#hP=null,this.#hV(),this.#hG()}#h$(){if(this._scrollMode!==nN.PAGE)throw Error("#ensurePageViewVisible: Invalid scrollMode value.");let t=this._currentPageNumber,e=this.#hL,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==nO.NONE||this.isInPresentationMode){let s=new Set,n=this._spreadMode-1;-1===n?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));let r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){let t=document.createElement("div");t.className="dummyPage",r.append(t)}for(let t of s){let i=this._pages[t];i&&(r.append(i.div),e.pages.push(i))}i.append(r)}else{let s=this._pages[t-1];i.append(s.div),e.pages.push(s)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&(this.#hC&&clearTimeout(this.#hC),this.#hC=setTimeout(()=>{this.#hC=null,this.update()},100),this.update())}#hW(t,e=null){let{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===nN.PAGE&&(this.#h$(),this.update()),!e&&!this.isInPresentationMode){let t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:r}=this.container;(this._scrollMode===nN.HORIZONTAL||t<n||s>n+r)&&(e={left:0,top:0})}nj(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#hq(t){return t===this._currentScale||1e-15>Math.abs(t-this._currentScale)}#hX(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#hq(t)){s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e});return}this.viewer.style.setProperty("--scale-factor",t*nw.PDF_TO_CSS_UNITS);let a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#hR=setTimeout(()=>{this.#hR=null,this.refresh()},n));let o=this._currentScale;if(this._currentScale=t,!i){let e=this._currentPageNumber,i;if(this._location&&!(this.isInPresentationMode||this.isChangingPresentationMode)&&(e=this._location.pageNumber,i=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:e,destArray:i,allowNegativeOffset:!0}),Array.isArray(r)){let e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-s)*e,this.container.scrollTop+=(r[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get #hK(){return this._spreadMode!==nO.NONE&&this._scrollMode!==nN.HORIZONTAL?2:1}#hO(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#hX(i,t,e);else{let s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,r=5;this.isInPresentationMode?(n=r=4,this._spreadMode!==nO.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===nN.HORIZONTAL&&([n,r]=[r,n]);let a=(this.container.clientWidth-n)/s.width*s.scale/this.#hK,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":i=Math.min(1.25,nW(s)?a:Math.min(o,a));break;default:console.error(`#setScale: "${t}" is an unknown zoom value.`);return}e.preset=!0,this.#hX(i,t,e)}}#hN(){let t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#hO(this._currentScaleValue,{noScroll:!0}),this.#hW(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;let e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1,center:n=null}){if(!this.pdfDocument)return;let r=Number.isInteger(t)&&this._pages[t-1];if(!r)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let a=0,o=0,l=0,h=0,d=r.rotation%180!=0,c=(d?r.height:r.width)/r.scale/nw.PDF_TO_CSS_UNITS,u=(d?r.width:r.height)/r.scale/nw.PDF_TO_CSS_UNITS,p=0;switch(e[1].name){case"XYZ":a=e[2],o=e[3],p=e[4],a=null!==a?a:0,o=null!==o?o:u;break;case"Fit":case"FitB":p="page-fit";break;case"FitH":case"FitBH":o=e[2],p="page-width",null===o&&this._location?(a=this._location.left,o=this._location.top):("number"!=typeof o||o<0)&&(o=u);break;case"FitV":case"FitBV":a=e[2],l=c,h=u,p="page-height";break;case"FitR":a=e[2],o=e[3],l=e[4]-a,h=e[5]-o;let g=40,m=5;this.removePageBorders&&(g=m=0),p=Math.min(Math.abs((this.container.clientWidth-g)/l/nw.PDF_TO_CSS_UNITS),Math.abs((this.container.clientHeight-m)/h/nw.PDF_TO_CSS_UNITS));break;default:console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`);return}if(s||(p&&p!==this._currentScale?this.currentScaleValue=p:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===p&&!e[4])return void this.#hW(r);let f=[r.viewport.convertToViewportPoint(a,o),r.viewport.convertToViewportPoint(a+l,o+h)],b=Math.min(f[0][0],f[1][0]),v=Math.min(f[0][1],f[1][1]);n?(("both"===n||"vertical"===n)&&(v-=(this.container.clientHeight-Math.abs(f[1][1]-f[0][1]))/2),("both"===n||"horizontal"===n)&&(b-=(this.container.clientWidth-Math.abs(f[1][0]-f[0][0]))/2)):i||(b=Math.max(b,0),v=Math.max(v,0)),this.#hW(r,{left:b,top:v})}_updateLocation(t){let e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(1e4*e)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),l=Math.round(o[0]),h=Math.round(o[1]),d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${l},${h}`),this._location={pageNumber:n,scale:s,top:h,left:l,rotation:this._pagesRotation,pdfOpenParams:d}}update(){let t=this._getVisiblePages(),e=t.views,i=e.length;if(0===i)return;let s=Math.max(10,2*i+1);for(let{view:i,visibleArea:n}of(this.#i5.resize(s,t.ids),e))i.updateVisibleArea(n);for(let e of this.#i5)t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);let n=this._spreadMode===nO.NONE&&(this._scrollMode===nN.PAGE||this._scrollMode===nN.VERTICAL),r=this._currentPageNumber,a=!1;for(let t of e){if(t.percent<100)break;if(t.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#hY(){let t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(let t of s){let{view:s}=t;if(!s.hasEditableAnnotations()){i.delete(s.id);continue}e.push(t)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return 3===this.presentationModeState}get isChangingPresentationMode(){return 2===this.presentationModeState}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){let t=this._scrollMode===nN.PAGE?this.#hL.pages:this._pages,e=this._scrollMode===nN.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){let r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;function h(t){let e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r}function d(t){let e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}let c=[],u=new Set,p=e.length,g=n$(e,s?d:h);g>0&&g<p&&!s&&(g=function(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(n=(s=e[t-1].div).offsetTop+s.clientTop);for(let i=t-2;i>=0&&!((s=e[i].div).offsetTop+s.clientTop+s.clientHeight<=n);--i)t=i;return t}(g,e,r));let m=s?l:-1;for(let t=g;t<p;t++){let i=e[t],n=i.div,h=n.offsetLeft+n.clientLeft,d=n.offsetTop+n.clientTop,p=n.clientWidth,g=n.clientHeight,f=h+p,b=d+g;if(-1===m)b>=a&&(m=b);else if((s?h:d)>m)break;if(b<=r||d>=a||f<=o||h>=l)continue;let v=Math.max(0,r-d),y=Math.max(0,o-h),w=(p-(y+Math.max(0,f-l)))/p,x=(g-(v+Math.max(0,b-a)))/g*w*100|0;c.push({id:i.id,x:h,y:d,visibleArea:100===x?null:{minX:y,minY:v,maxX:Math.min(f,l)-h,maxY:Math.min(b,a)-d},view:i,percent:x,widthPercent:100*w|0}),u.add(i.id)}let f=c[0],b=c.at(-1);return i&&c.sort(function(t,e){let i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id}),{first:f,last:b,views:c,ids:u}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(let t of this._pages)t.renderingState!==nB.FINISHED&&t.reset()}_cancelRendering(){for(let t of this._pages)t.cancelRendering()}async #hQ(t){if(t.pdfPage)return t.pdfPage;try{let e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for page view",t),null}}#hJ(t){if(t.first?.id===1)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case nN.PAGE:return this.#hL.scrollDown;case nN.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){let e=t||this._getVisiblePages(),i=this.#hJ(e),s=this._spreadMode!==nO.NONE&&this._scrollMode!==nN.HORIZONTAL,n=null!==this.#hR||null!==this.#hC&&e.views.some(t=>t.detailView?.renderingCancelled),r=this.renderingQueue.getHighestPriority(e,this._pages,i,s,n);return!!r&&(this.#hQ(r).then(()=>{this.renderingQueue.renderView(r)}),!0)}get hasEqualPageSizes(){let t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){let i=this._pages[e];if(i.width!==t.width||i.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map(e=>{let i=e.pdfPage.getViewport({scale:1}),s=nW(i);if(void 0===t)t=s;else if(this.enablePrintAutoRotate&&s!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw Error(`Invalid optionalContentConfigPromise: ${t}`);!this.pdfDocument||this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!(Number.isInteger(t)&&Object.values(nN).includes(t)&&t!==nN.UNKNOWN))throw Error(`Invalid scroll mode: ${t}`);this.pagesCount>1e4||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){let e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===nN.HORIZONTAL),i.classList.toggle("scrollWrapped",e===nN.WRAPPED),this.pdfDocument&&t&&(e===nN.PAGE?this.#h$():this._previousScrollMode===nN.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#hO(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!(Number.isInteger(t)&&Object.values(nO).includes(t)&&t!==nO.UNKNOWN))throw Error(`Invalid spread mode: ${t}`);this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;let e=this.viewer,i=this._pages;if(this._scrollMode===nN.PAGE)this.#h$();else if(e.textContent="",this._spreadMode===nO.NONE)for(let t of this._pages)e.append(t.div);else{let t=this._spreadMode-1,s=null;for(let n=0,r=i.length;n<r;++n)null===s?((s=document.createElement("div")).className="spread",e.append(s)):n%2===t&&(s=s.cloneNode(!1),e.append(s)),s.append(i[n].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#hO(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case nN.WRAPPED:{let{views:i}=this._getVisiblePages(),s=new Map;for(let{id:t,y:e,percent:n,widthPercent:r}of i){if(0===n||r<100)continue;let i=s.get(e);i||s.set(e,i||=[]),i.push(t)}for(let i of s.values()){let s=i.indexOf(t);if(-1===s)continue;let n=i.length;if(1===n)break;if(e)for(let e=s-1;e>=0;e--){let s=i[e],n=i[e+1]-1;if(s<n)return t-n}else for(let e=s+1;e<n;e++){let s=i[e],n=i[e-1]+1;if(s>n)return n-t}if(e){let e=i[0];if(e<t)return t-e+1}else{let e=i[n-1];if(e>t)return e-t+1}break}break}case nN.HORIZONTAL:break;case nN.PAGE:case nN.VERTICAL:{if(this._spreadMode===nO.NONE)break;let i=this._spreadMode-1;if(e&&t%2!==i||!e&&t%2===i)break;let{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(let{id:t,percent:e,widthPercent:i}of s)if(t===n){if(e>0&&100===i)return 2;break}}}return 1}nextPage(){let t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;let i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){let t=this._currentPageNumber;if(t<=1)return!1;let e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(null===i&&null===e)throw Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&1!==e)n=Math.round(n*e*100)/100;else if(i){let t=i>0?1.1:.9090909090909091,e=i>0?Math.ceil:Math.floor;i=Math.abs(i);do n=e(10*(n*t).toFixed(2))/10;while(--i>0)}n=nd(n,.1,10),this.#hO(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#hB(t=this.container.clientHeight){t!==this.#hk&&(this.#hk=t,nq.setProperty("--viewer-container-height",`${t}px`))}#hI(t){for(let e of t)if(e.target===this.container){this.#hB(Math.floor(e.borderBoxSize[0].blockSize)),this.#hx=null;break}}get containerTopLeft(){return this.#hx||=[this.container.offsetTop,this.container.offsetLeft]}#hV(){null!==this.#hR&&(clearTimeout(this.#hR),this.#hR=null),null!==this.#hC&&(clearTimeout(this.#hC),this.#hC=null)}#hG(){this.#hS?.abort(),this.#hS=null,null!==this.#hE&&(clearTimeout(this.#hE),this.#hE=null)}#hH(t){switch(t){case sq.STAMP:this.#td?.loadModel("altText");break;case sq.SIGNATURE:this.#tg?.loadSignatures()}}get annotationEditorMode(){return this.#hw?this.#hy:sq.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1,mustEnterInEditMode:s=!1,editComment:n=!1}){if(!this.#hw)throw Error("The AnnotationEditor is not enabled.");if(this.#hy===t)return;if(!aL(t))throw Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;this.#hH(t);let{eventBus:r,pdfDocument:a}=this,o=async()=>{this.#hG(),this.#hy=t,await this.#hw.updateMode(t,e,i,s,n),t===this.#hy&&a===this.pdfDocument&&r.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===sq.NONE||this.#hy===sq.NONE){let e=t!==sq.NONE;for(let t of(e||this.pdfDocument.annotationStorage.resetModifiedIds(),this.cleanup(),this._pages))t.toggleEditingMode(e);let i=this.#hY();if(e&&i){this.#hG(),this.#hS=new AbortController;let t=AbortSignal.any([this.#oZ.signal,this.#hS.signal]);r._on("pagerendered",({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#hE=setTimeout(o,0))},{signal:t});return}}o()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(let t of this._pages)t.update(e);this.#hV(),t||this.update()}}}globalThis.pdfjsViewer={AnnotationLayerBuilder:rs,DownloadManager:rr,EventBus:ro,FindState:nY,GenericL10n:aa,LinkTarget:rt,parseQueryString:nU,PDFFindController:class{#hZ=null;#h0=!0;#h1=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#h0=i,this.onIsPageVisible=null,this.#h2(),e._on("find",this.#h3.bind(this)),e._on("findbarclose",this.#h5.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#hZ}setDocument(t){this._pdfDocument&&this.#h2(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#h3(t){if(!t)return;let e=this._pdfDocument,{type:i}=t;(null===this.#hZ||this.#h4(t))&&(this._dirtyMatch=!0),this.#hZ=t,"highlightallchange"!==i&&this.#h6(nY.PENDING),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#rA();let t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#h8():"again"===i?(this.#h8(),t&&this.#hZ.highlightAll&&this.#h9()):"highlightallchange"===i?(s?this.#h8():this._highlightMatches=!0,this.#h9()):this.#h8():this._findTimeout=setTimeout(()=>{this.#h8(),this._findTimeout=null},250)})}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){this._scrollMatches&&t&&-1!==s&&s===this._selected.matchIdx&&-1!==i&&i===this._selected.pageIdx&&(this._scrollMatches=!1,nj(t,{top:-50,left:e},!0))}#h2(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#h1=0,this.#hZ=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get #h7(){let{query:t}=this.#hZ;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=n9(t)),this._normalizedQuery):(t||[]).filter(t=>!!t).map(t=>n9(t)[0])}#h4(t){let e=t.query,i=this.#hZ.query,s=typeof e;if(s!==typeof i)return!0;if("string"===s){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":let n=this._selected.pageIdx+1,r=this._linkService;return n>=1&&n<=r.pagesCount&&n!==r.page&&!(this.onIsPageVisible?.(n)??!0);case"highlightallchange":return!1}return!0}#dt(t,e,i){let s=t.slice(0,e).match(n1);if(s){let i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(nK(i)===nK(n))return!1}if(s=t.slice(e+i).match(n2)){let n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(nK(n)===nK(r))return!1}return!0}#de(t,e){let{matchDiacritics:s}=this.#hZ,n=!1;t=t.replaceAll(n0,(t,i,r,a,o,l)=>i?`[ ]*\\${i}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":s?o||l:o?nJ.has(o.charCodeAt(0))?o:"":e?(n=!0,`${l}\\p{M}*`):l);let r="[ ]*";return t.endsWith(r)&&(t=t.slice(0,t.length-r.length)),s&&e&&(i||=String.fromCharCode(...nJ),n=!0,t=`${t}(?=[${i}]|[^\\p{M}]|$)`),[n,t]}#di(t){if(!this.#hZ)return;let e=this.#h7;if(0===e.length)return;let i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach(({index:t,length:e})=>{let[i,s]=n7(a,t,e);s&&(n.push(i),r.push(s))}),this.#hZ.highlightAll&&this.#ds(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#dn());let o=n.length;this._matchesCountTotal+=o,this.#h0?o>0&&this.#dr():++this.#h1===this._linkService.pagesCount&&this.#dr()}match(t,e,i){let s,n=this._hasDiacritics[i],r=!1;if("string"==typeof t?[r,t]=this.#de(t,n):t=t.sort().reverse().map(t=>{let[e,i]=this.#de(t,n);return r||=e,`(${i})`}).join("|"),!t)return;let{caseSensitive:a,entireWord:o}=this.#hZ,l=`g${r?"u":""}${a?"":"i"}`;t=new RegExp(t,l);let h=[];for(;null!==(s=t.exec(e));)(!o||this.#dt(e,s.index,s[0].length))&&h.push({index:s.index,length:s[0].length});return h}#rA(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve(),e={disableNormalization:!0},i=this._pdfDocument;for(let s=0,n=this._linkService.pagesCount;s<n;s++){let{promise:n,resolve:r}=Promise.withResolvers();this._extractTextPromises[s]=n,t=t.then(async()=>{i!==this._pdfDocument?r():await i.getPage(s+1).then(t=>t.getTextContent(e)).then(t=>{let e=[];for(let i of t.items)e.push(i.str),i.hasEOL&&e.push("\n");[this._pageContents[s],this._pageDiffs[s],this._hasDiacritics[s]]=n9(e.join("")),r()},t=>{console.error(`Unable to get text content for page ${s+1}`,t),this._pageContents[s]="",this._pageDiffs[s]=null,this._hasDiacritics[s]=!1,r()})})}}#ds(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#h9(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#h8(){let t=this.#hZ.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#h1=0,this._matchesCountTotal=0,this.#h9();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then(()=>{this._pendingFindMatches.delete(t),this.#di(t)}))}if(0===this.#h7.length)return void this.#h6(nY.FOUND);if(this._resumePageIdx)return;let s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){let e=this._pageMatches[s.pageIdx].length;if(!t&&s.matchIdx+1<e||t&&s.matchIdx>0){s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,this.#da(!0);return}this.#dl(t)}this.#dn()}#dh(t){let e=this._offset,i=t.length,s=this.#hZ.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#da(!0),!0):(this.#dl(s),!!e.wrapped&&(e.matchIdx=null,!!(this._pagesToSearch<0))&&(this.#da(!1),!0))}#dn(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{let e=this._offset.pageIdx;if(!(t=this._pageMatches[e])){this._resumePageIdx=e;break}}while(!this.#dh(t))}#dl(t){let e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#da(t=!1){let e=nY.NOT_FOUND,i=this._offset.wrapped;if(this._offset.wrapped=!1,t){let t=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?nY.WRAPPED:nY.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#ds(t)}this.#h6(e,this.#hZ.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#ds(this._selected.pageIdx))}#h5(t){let e=this._pdfDocument;this._firstPageCapability.promise.then(()=>{this._pdfDocument&&(!e||this._pdfDocument===e)&&(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#h6(nY.FOUND),this._highlightMatches=!1,this.#h9())})}#dd(){let{pageIdx:t,matchIdx:e}=this._selected,i=0,s=this._matchesCountTotal;if(-1!==e){for(let e=0;e<t;e++)i+=this._pageMatches[e]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#dr(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#dd()})}#h6(t,e=!1){(this.#h0||this.#h1===this._linkService.pagesCount&&t!==nY.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#hZ?.entireWord??null,matchesCount:this.#dd(),rawQuery:this.#hZ?.query??null})}},PDFHistory:class{#oZ=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",t=>{this._isPagesLoaded=!!t.pagesCount},{once:!0})})}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();let s=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#dc();let n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=ao(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#du(n,!0)||e){let{hash:t,page:i,rotation:n}=this.#dp(!0);return!t||s||e?void this.#dg(null,!0):void this.#dg({hash:t,page:i,rotation:n},!0)}let r=n.destination;this.#dm(r,n.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#df(),this._initialized=!1,this.#db()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){var s,n;if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#dv(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);let r=t||JSON.stringify(e);if(!r)return;let a=!1;if(this._destination&&(s=this._destination.hash,n=r,"string"==typeof s&&"string"==typeof n&&(s===n||nU(s).get("nameddest")===n)||function(t,e){if(!(Array.isArray(t)&&Array.isArray(e))||t.length!==e.length)return!1;for(let i=0,s=t.length;i<s;i++)if(!function t(e,i){if(typeof e!=typeof i||Array.isArray(e)||Array.isArray(i))return!1;if(null!==e&&"object"==typeof e&&null!==i){if(Object.keys(e).length!==Object.keys(i).length)return!1;for(let s in e)if(!t(e[s],i[s]))return!1;return!0}return e===i||Number.isNaN(e)&&Number.isNaN(i)}(t[i],e[i]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;a=!0}(!this._popStateInProgress||a)&&(this.#dg({dest:e,hash:r,page:i,rotation:this.linkService.rotation},a),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(t){this._initialized&&(this.#dv(t)?this._destination?.page===t||!this._popStateInProgress&&(this.#dg({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1}))):console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#dy()}back(){if(!this._initialized||this._popStateInProgress)return;let t=window.history.state;this.#du(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;let t=window.history.state;this.#du(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#dg(t,e=!1){let i,s=e||!this._destination,n={fingerprint:this._fingerprint,uid:s?this._uid:this._uid+1,destination:t};if(this.#dm(t,n.uid),this._updateUrl&&t?.hash){let{href:e,protocol:s}=document.location;"file:"!==s&&(i=nD(e,t.hash))}s?window.history.replaceState(n,"",i):window.history.pushState(n,"",i)}#dy(t=!1){if(!this._position)return;let e=this._position;if(t&&((e=Object.assign(Object.create(null),this._position)).temporary=!0),!this._destination)return void this.#dg(e);if(this._destination.temporary)return void this.#dg(e,!0);if(this._destination.hash===e.hash||!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#dg(e,i)}#dv(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#du(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint)if(!e)return!1;else{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;let[e]=performance.getEntriesByType("navigation");if(e?.type!=="reload")return!1}return!!Number.isInteger(t.uid)&&!(t.uid<0)&&null!==t.destination&&"object"==typeof t.destination}#dm(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#dp(t=!1){let e=unescape(ao()).substring(1),i=nU(e),s=i.get("nameddest")||"",n=0|i.get("page");return(!this.#dv(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#dw({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||this.#dy(!0),this._updateViewareaTimeout=null},1e3))}#dx({state:t}){let e=ao(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;let{hash:t,page:e,rotation:i}=this.#dp();this.#dg({hash:t,page:e,rotation:i},!0);return}if(!this.#du(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,ra({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--}));let s=t.destination;this.#dm(s,t.uid,!0),nG(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#df(){(!this._destination||this._destination.temporary)&&this.#dy()}#dc(){if(this.#oZ)return;this.#oZ=new AbortController;let{signal:t}=this.#oZ;this.eventBus._on("updateviewarea",this.#dw.bind(this),{signal:t}),window.addEventListener("popstate",this.#dx.bind(this),{signal:t}),window.addEventListener("pagehide",this.#df.bind(this),{signal:t})}#db(){this.#oZ?.abort(),this.#oZ=null}},PDFLinkService:re,PDFPageView:aP,PDFScriptingManager:class extends aD{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})}),t.externalServices||={createScripting:()=>new ak(t.sandboxBundleSrc)},t.docProperties||=t=>aM(t),super(t)}},PDFSinglePageViewer:class extends aF{_resetView(){super._resetView(),this._scrollMode=nN.PAGE,this._spreadMode=nO.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}},PDFViewer:aF,ProgressBar:class{#dA=null;#d_=null;#dC=0;#dS=null;#su=!0;constructor(t){this.#dA=t.classList,this.#dS=t.style}get percent(){return this.#dC}set percent(t){(this.#dC=nd(t,0,100),isNaN(t))?this.#dA.add("indeterminate"):(this.#dA.remove("indeterminate"),this.#dS.setProperty("--progressBar-percent",`${this.#dC}%`))}setWidth(t){if(!t)return;let e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#dS.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#dC||isNaN(this.#dC)||(this.#d_&&clearTimeout(this.#d_),this.show(),this.#d_=setTimeout(()=>{this.#d_=null,this.hide()},t))}hide(){this.#su&&(this.#su=!1,this.#dA.add("hidden"))}show(){this.#su||(this.#su=!0,this.#dA.remove("hidden"))}},RenderingStates:nB,ScrollMode:nN,SimpleLinkService:ri,SpreadMode:nO,StructTreeLayerBuilder:ax,TextLayerBuilder:aC,XfaLayerBuilder:aS};let{AnnotationEditorType:aB}=sH;sH.GlobalWorkerOptions.workerSrc="/pdfjs/pdf.worker.min.mjs";let aN=[{mode:aB.NONE,icon:u,label:"Select"},{mode:aB.HIGHLIGHT,icon:l,label:"Highlight"},{mode:aB.FREETEXT,icon:h.Type,label:"Text"},{mode:aB.INK,icon:d,label:"Draw"},{mode:aB.STAMP,icon:c.Image,label:"Image"}];t.s(["PdfViewer",0,function({path:t,title:e}){let i=(0,v.withWs)(`/api/assets/${t}`),s=(0,r.useRef)(null),o=(0,r.useRef)(null),l=(0,r.useRef)(null),[h,d]=(0,r.useState)(aB.NONE),[c,u]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),[x,A]=(0,r.useState)(null),[_,C]=(0,r.useState)(null);(0,r.useEffect)(()=>{let t=s.current;if(!t)return;let e=!1,n=null,r=null,a=new ro,h=new re({eventBus:a});return n=new aF({container:t,eventBus:a,linkService:h}),h.setViewer(n),o.current=n,a.on("pagesinit",()=>{n&&(n.currentScaleValue="page-width")}),a.on("annotationeditorstateschanged",()=>{e||u(!0)}),sH.getDocument({url:i}).promise.then(t=>{e?t.destroy():(r=t,l.current=t,n.setDocument(t),h.setDocument(t,null))}).catch(t=>{e||C(t instanceof Error?t.message:"Failed to load PDF")}),()=>{e=!0,o.current=null,l.current=null,r?.destroy(),n?.cleanup()}},[i]);let S=(0,r.useCallback)(t=>{let e=o.current;if(e)try{e.annotationEditorMode={mode:t},d(t)}catch{}},[]),E=(0,r.useCallback)(async()=>{let e=l.current;if(e){w(!0),A(null);try{let i=await e.saveDocument(),s=await fetch((0,v.withWs)(`/api/pdf/save?path=${encodeURIComponent(t)}`),{method:"PUT",headers:{"Content-Type":"application/pdf"},body:new Blob([i],{type:"application/pdf"})});if(!s.ok){let t=await s.json().catch(()=>({}));throw Error("WORKSPACE_READ_ONLY"===t.error?"Workspace is read-only":t.error||"Save failed")}u(!1)}catch(t){A(t instanceof Error?t.message:"Save failed")}finally{w(!1)}}},[t]);return(0,r.useEffect)(()=>{if(!c)return;let t=t=>t.preventDefault();return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[c]),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)(m.ViewerToolbar,{path:t,badge:"PDF",children:[(0,n.jsx)("div",{className:"flex items-center gap-0.5",children:aN.map(t=>(0,n.jsx)(f.Button,{variant:"ghost",size:"sm",title:t.label,className:(0,b.cn)("h-7 w-7 p-0",h===t.mode&&"bg-accent-soft text-foreground"),onClick:()=>S(t.mode),children:(0,n.jsx)(t.icon,{className:"h-3.5 w-3.5"})},t.mode))}),(0,n.jsx)("div",{className:"mx-1 h-4 w-px bg-border"}),(0,n.jsxs)(f.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",disabled:!c||y,onClick:()=>void E(),title:c?"Save annotations to file":"No unsaved changes",children:[y?(0,n.jsx)(g.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(p.Save,{className:"h-3.5 w-3.5"}),c?"Save*":"Saved"]}),(0,n.jsxs)(f.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(i,"_blank"),children:[(0,n.jsx)(a.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),x&&(0,n.jsx)("div",{className:"bg-destructive/10 px-3 py-1 text-xs text-destructive",children:x}),_?(0,n.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:_}):(0,n.jsx)("div",{ref:s,className:"absolute-container relative flex-1 overflow-auto bg-muted/30",children:(0,n.jsx)("div",{className:"pdfViewer"})})]})}],394872)},904378,t=>{t.n(t.i(394872))}]);
|