turbollm 1.11.8 → 1.11.9
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/dist/cli.js +58 -0
- package/dist/webdist/assets/{AgentEditPage-BEYv2dqk.js → AgentEditPage-Cfbfakkc.js} +1 -1
- package/dist/webdist/assets/{ChatScreen-Be3s4Apt.js → ChatScreen-CYggEGs5.js} +1 -1
- package/dist/webdist/assets/{CodeComposer-UXWorvxM.js → CodeComposer-CPq9MB0A.js} +1 -1
- package/dist/webdist/assets/{CodeHomeScreen-DoLM7wZ7.js → CodeHomeScreen-DJd7UNqS.js} +1 -1
- package/dist/webdist/assets/{CodeSessionScreen-B2_E1nGk.js → CodeSessionScreen-DANRbQym.js} +1 -1
- package/dist/webdist/assets/{CustomizeScreen-oXSoHBmc.js → CustomizeScreen-BHsYmBrR.js} +1 -1
- package/dist/webdist/assets/{DeveloperScreen-XtW_r1xe.js → DeveloperScreen-C_m-yLRt.js} +1 -1
- package/dist/webdist/assets/{EnginesScreen-DFPKVQmY.js → EnginesScreen-WNm64lCr.js} +1 -1
- package/dist/webdist/assets/{ModelDetailDialog-Bf99Dj9I.js → ModelDetailDialog-CCmZhT_-.js} +1 -1
- package/dist/webdist/assets/{ModelLoadMenu-DIsk-jZz.js → ModelLoadMenu-BoD8vGEb.js} +1 -1
- package/dist/webdist/assets/{ModelsScreen-CaPBgqJn.js → ModelsScreen-B1eaJCK_.js} +1 -1
- package/dist/webdist/assets/{OnboardingScreen-DKB8rxlq.js → OnboardingScreen-Dp2_T3xE.js} +1 -1
- package/dist/webdist/assets/{RoutineEditPage-HxYBqm4v.js → RoutineEditPage-_ego0aCV.js} +1 -1
- package/dist/webdist/assets/{RoutinesPanel-DG2Sxz7g.js → RoutinesPanel-DHwZQ9Gk.js} +1 -1
- package/dist/webdist/assets/{SettingsScreen-CXP_EZLC.js → SettingsScreen-DbKvB_mp.js} +1 -1
- package/dist/webdist/assets/{SidebarResizeHandle-BEjYiHxx.js → SidebarResizeHandle-Bc3QBs84.js} +1 -1
- package/dist/webdist/assets/{SkillEditPage-CFLxX-PG.js → SkillEditPage-CwGusPDb.js} +1 -1
- package/dist/webdist/assets/{TokensScreen-EAg6SpPg.js → TokensScreen-UaGvsqtF.js} +1 -1
- package/dist/webdist/assets/ToolApprovalBar-Chx2y-tr.js +21 -0
- package/dist/webdist/assets/WorkspaceScreen-a7V07mMZ.js +1 -0
- package/dist/webdist/assets/{abnfDiagram-N423BO3Z-Com8iOkP.js → abnfDiagram-N423BO3Z-iiGkfE9c.js} +1 -1
- package/dist/webdist/assets/{agent-api-Bbbnu920.js → agent-api-CmhXBBT6.js} +1 -1
- package/dist/webdist/assets/{alert-dialog-DBTMGpVB.js → alert-dialog-B7ASyTxr.js} +1 -1
- package/dist/webdist/assets/{arc-CxAPh_XT.js → arc-CitM3TjF.js} +1 -1
- package/dist/webdist/assets/{architectureDiagram-T3A2C74G-cmEV3ecV.js → architectureDiagram-T3A2C74G-B81sGCwi.js} +1 -1
- package/dist/webdist/assets/{arrow-left-CqNHa_nR.js → arrow-left-Cx0V34bU.js} +1 -1
- package/dist/webdist/assets/{badge-DLVv8YlA.js → badge-BJPgZflb.js} +1 -1
- package/dist/webdist/assets/{blockDiagram-VBNYF7ZC-Dzszoo8X.js → blockDiagram-VBNYF7ZC-StpQormu.js} +1 -1
- package/dist/webdist/assets/{bot-DFV9NaDI.js → bot-XI_iobdp.js} +1 -1
- package/dist/webdist/assets/{c4Diagram-5PPSVZJV-CT06LjAB.js → c4Diagram-5PPSVZJV-Csa8aK4v.js} +1 -1
- package/dist/webdist/assets/channel-DS6QHRxP.js +1 -0
- package/dist/webdist/assets/{chat-api-CmDwSCUy.js → chat-api-Zyxy4wka.js} +1 -1
- package/dist/webdist/assets/{chat-queries-opwsCDIy.js → chat-queries-DIm_a9NN.js} +1 -1
- package/dist/webdist/assets/{chevron-down-DiyKHxC-.js → chevron-down-BWfjeD2C.js} +1 -1
- package/dist/webdist/assets/{chevron-left-CwO2nWWZ.js → chevron-left-CBtdrcDZ.js} +1 -1
- package/dist/webdist/assets/{chevron-right-Ck02yYBx.js → chevron-right-DRLCoDa8.js} +1 -1
- package/dist/webdist/assets/{chunk-2GRJ4B5K-Blj1u1OW.js → chunk-2GRJ4B5K-2MKQX9Og.js} +1 -1
- package/dist/webdist/assets/{chunk-2Q5K7J3B-VRS9aN4X.js → chunk-2Q5K7J3B-B_27rm1N.js} +1 -1
- package/dist/webdist/assets/{chunk-5RXB4S5H-CoTOA-QY.js → chunk-5RXB4S5H-BlhTP0-3.js} +1 -1
- package/dist/webdist/assets/{chunk-5VM5RSS4-DigOrHns.js → chunk-5VM5RSS4-C7IJCBfZ.js} +1 -1
- package/dist/webdist/assets/{chunk-6Q2QTUOP-MsJl24GT.js → chunk-6Q2QTUOP-Bj14OW8u.js} +1 -1
- package/dist/webdist/assets/{chunk-GF5L2VYU-xgSZn13t.js → chunk-GF5L2VYU-aT8ppbPL.js} +1 -1
- package/dist/webdist/assets/{chunk-JWPE2WC7-DJ7ETxvg.js → chunk-JWPE2WC7-Bt4dl9CN.js} +1 -1
- package/dist/webdist/assets/{chunk-KBJHAD2P-DypQCgcq.js → chunk-KBJHAD2P-J4coc1ol.js} +1 -1
- package/dist/webdist/assets/{chunk-RYQCIY6F-0xN4i17N.js → chunk-RYQCIY6F-Dv_7Q2hX.js} +1 -1
- package/dist/webdist/assets/{chunk-XXDRQBXY-CLumzVtu.js → chunk-XXDRQBXY-zQnucktD.js} +1 -1
- package/dist/webdist/assets/{circle-check-CM_EzD0B.js → circle-check-loUJak9B.js} +1 -1
- package/dist/webdist/assets/{circle-x-DDCTEjWL.js → circle-x-Bgnj4qQZ.js} +1 -1
- package/dist/webdist/assets/classDiagram-JCYQIIEL-DmMoUKDN.js +1 -0
- package/dist/webdist/assets/classDiagram-v2-OCEON4UE-DmMoUKDN.js +1 -0
- package/dist/webdist/assets/{common-BmIDcygp.js → common-B5JH_OFR.js} +1 -1
- package/dist/webdist/assets/{cose-bilkent-JH36ORCC-CctbomzF.js → cose-bilkent-JH36ORCC-CvYv-f5s.js} +1 -1
- package/dist/webdist/assets/{cynefin-VYW2F7L2-CAOiUD35.js → cynefin-VYW2F7L2-DVwHpekX.js} +1 -1
- package/dist/webdist/assets/{cynefinDiagram-MW4NZA55-BmenpAyg.js → cynefinDiagram-MW4NZA55-BcdPKvtX.js} +1 -1
- package/dist/webdist/assets/{dagre-VZM6K2ZE-CUSeYeIs.js → dagre-VZM6K2ZE-4sSe5M8W.js} +1 -1
- package/dist/webdist/assets/{diagram-7IWD3JNH-CTmJsE0m.js → diagram-7IWD3JNH-COLSWeIR.js} +1 -1
- package/dist/webdist/assets/{diagram-B4RE2ZJO-D5tXNWQT.js → diagram-B4RE2ZJO-ER5prsGm.js} +1 -1
- package/dist/webdist/assets/{diagram-LBJQPF4R-5tR892LO.js → diagram-LBJQPF4R-FfvD4Hay.js} +1 -1
- package/dist/webdist/assets/{diagram-Q27KOJAE-BgZg9KkM.js → diagram-Q27KOJAE-DnwPL2tG.js} +1 -1
- package/dist/webdist/assets/{diagram-UB23O5K3-DzD2EEfH.js → diagram-UB23O5K3-B6lZME5q.js} +1 -1
- package/dist/webdist/assets/{dropdown-menu-CaMJbKX5.js → dropdown-menu-DRRO0ftt.js} +1 -1
- package/dist/webdist/assets/{ebnfDiagram-BXEA7PRR-BsE4pbuB.js → ebnfDiagram-BXEA7PRR-DLx8zqdK.js} +1 -1
- package/dist/webdist/assets/{erDiagram-JOGREHBK-BSNniK5W.js → erDiagram-JOGREHBK-DdSmD2ix.js} +1 -1
- package/dist/webdist/assets/{external-link-B73_NSLw.js → external-link-dolckdL9.js} +1 -1
- package/dist/webdist/assets/{file-text-SkW8GJLf.js → file-text-BJHbdxSm.js} +1 -1
- package/dist/webdist/assets/{flowDiagram-UKHOOZJN-LTHTwtbo.js → flowDiagram-UKHOOZJN-C71SbKr7.js} +1 -1
- package/dist/webdist/assets/{folder-input-DdDYio8z.js → folder-input-ubj-7_tQ.js} +1 -1
- package/dist/webdist/assets/{folder-plus-By4aZIqn.js → folder-plus-Bz7B7UnH.js} +1 -1
- package/dist/webdist/assets/{ganttDiagram-PKOTCBZU-DhWk0fZI.js → ganttDiagram-PKOTCBZU-C5doF3y3.js} +1 -1
- package/dist/webdist/assets/{git-branch-C6MWgM1t.js → git-branch-CNpNkvMr.js} +1 -1
- package/dist/webdist/assets/{gitGraphDiagram-DS77QQ5N-Cnp_ieRP.js → gitGraphDiagram-DS77QQ5N-iCuj4BOQ.js} +1 -1
- package/dist/webdist/assets/{index-DDdTmEU4.js → index-D0Emka7d.js} +2 -2
- package/dist/webdist/assets/index-D44YD6EJ.css +1 -0
- package/dist/webdist/assets/{infoDiagram-6WML65LV-BfVAgcHy.js → infoDiagram-6WML65LV-CVbutaQs.js} +1 -1
- package/dist/webdist/assets/{ishikawaDiagram-WSZJBQD7-rRt3dfj6.js → ishikawaDiagram-WSZJBQD7-CZyy_met.js} +1 -1
- package/dist/webdist/assets/{journeyDiagram-NVQOT4AX-BSy-shCM.js → journeyDiagram-NVQOT4AX-BIwZvXA4.js} +1 -1
- package/dist/webdist/assets/{kanban-definition-27J2QSJJ-DGOAYCO1.js → kanban-definition-27J2QSJJ-DOERNBKz.js} +1 -1
- package/dist/webdist/assets/{linear-CS_iPZyK.js → linear-Bf8xCMRw.js} +1 -1
- package/dist/webdist/assets/{link-queries-DvYdzQm8.js → link-queries-DBf0L0p4.js} +1 -1
- package/dist/webdist/assets/{lock-_paqX_bJ.js → lock-CnmBV2sW.js} +1 -1
- package/dist/webdist/assets/{mermaid.core-CPhj_3A-.js → mermaid.core-DcQR7vsm.js} +4 -4
- package/dist/webdist/assets/{mindmap-definition-FAOFIHXS-CZbX1tkX.js → mindmap-definition-FAOFIHXS-C3T3OIGM.js} +1 -1
- package/dist/webdist/assets/{monitor-Buq_3Xsq.js → monitor-Dj5hVZG9.js} +1 -1
- package/dist/webdist/assets/{pegDiagram-VL7TDLO6-PpIZIssA.js → pegDiagram-VL7TDLO6-J5nkSsO9.js} +1 -1
- package/dist/webdist/assets/{pencil-D9a-4tCA.js → pencil-CJDKBSrc.js} +1 -1
- package/dist/webdist/assets/personas-CeAQ6niU.js +109 -0
- package/dist/webdist/assets/{pieDiagram-7S7Q4E2Y-vt-POtMx.js → pieDiagram-7S7Q4E2Y-2RGDZc8u.js} +1 -1
- package/dist/webdist/assets/{plus-DP3JYEma.js → plus-CtCCCtT9.js} +1 -1
- package/dist/webdist/assets/{quadrantDiagram-CIZ2JOQS-Yr9F3dX4.js → quadrantDiagram-CIZ2JOQS-DsYpj2qg.js} +1 -1
- package/dist/webdist/assets/{railroadDiagram-AXF67PYL-CZ7FpINV.js → railroadDiagram-AXF67PYL-DvObbGSI.js} +1 -1
- package/dist/webdist/assets/{refresh-cw-bRtvR0Iv.js → refresh-cw-Qd40C8Nj.js} +1 -1
- package/dist/webdist/assets/{remote-failure-agE6nknQ.js → remote-failure-B7wlj-_A.js} +1 -1
- package/dist/webdist/assets/{requirementDiagram-LRYGKXZP-BUmCzzYZ.js → requirementDiagram-LRYGKXZP-CdeOzUDb.js} +1 -1
- package/dist/webdist/assets/{rocket-BFudVOBf.js → rocket-D2AvWWtP.js} +1 -1
- package/dist/webdist/assets/{rotate-ccw-CTfSFG3x.js → rotate-ccw-BpPatpxx.js} +1 -1
- package/dist/webdist/assets/{sankeyDiagram-W5VNT64P-BuLGkmEP.js → sankeyDiagram-W5VNT64P-DVrYRLqU.js} +1 -1
- package/dist/webdist/assets/{sequenceDiagram-SI44F4Z6-D8vmzIyW.js → sequenceDiagram-SI44F4Z6-BZAK6xg6.js} +1 -1
- package/dist/webdist/assets/{sizeCapture-X5ZJPWSS-DYgUs44t.js → sizeCapture-X5ZJPWSS-BHOY8h1t.js} +1 -1
- package/dist/webdist/assets/{skeleton-kNhR6J5G.js → skeleton-C1KITEIJ.js} +1 -1
- package/dist/webdist/assets/{sliders-horizontal-GlSfzSwu.js → sliders-horizontal-D48--I0k.js} +1 -1
- package/dist/webdist/assets/{sparkles-CJPHP-dp.js → sparkles-DDOla5js.js} +1 -1
- package/dist/webdist/assets/{star-BDNzpKYY.js → star-B2buMvXV.js} +1 -1
- package/dist/webdist/assets/{stateDiagram-OKZ733FA-Sztzkc4z.js → stateDiagram-OKZ733FA-VUJTdkvj.js} +1 -1
- package/dist/webdist/assets/stateDiagram-v2-UEYNNEHI-DslkN__b.js +1 -0
- package/dist/webdist/assets/{swimlanes-SLNWSIFB-CWR36cS5.js → swimlanes-SLNWSIFB-MjxXyCvR.js} +2 -2
- package/dist/webdist/assets/swimlanesDiagram-ULZ7WXOC-CQoli8MP.js +8 -0
- package/dist/webdist/assets/{switch-CJAukDSs.js → switch-Cs9dlnwb.js} +1 -1
- package/dist/webdist/assets/{terminal-5a1B-6y4.js → terminal-CiOZKaJb.js} +1 -1
- package/dist/webdist/assets/{timeline-definition-Z64GVDOM-Bs1ZNlGU.js → timeline-definition-Z64GVDOM-Bw8Iivgn.js} +1 -1
- package/dist/webdist/assets/{trash-2-BNNKBgll.js → trash-2-DbQqCHSH.js} +1 -1
- package/dist/webdist/assets/{triangle-alert-vMymArLW.js → triangle-alert-Buguln0S.js} +1 -1
- package/dist/webdist/assets/{useIsDesktop-BWN1ktaj.js → useIsDesktop-BdbkbmUH.js} +1 -1
- package/dist/webdist/assets/{vennDiagram-T6HMQDX7-bfP-4l5-.js → vennDiagram-T6HMQDX7-UptwMBTb.js} +1 -1
- package/dist/webdist/assets/{wardleyDiagram-T6FBY63Y-CT_Drudb.js → wardleyDiagram-T6FBY63Y-DBzcNfG5.js} +1 -1
- package/dist/webdist/assets/{wrench-BleM5jpH.js → wrench-ByDKNN2K.js} +1 -1
- package/dist/webdist/assets/{xychartDiagram-ELKLHX3M-BeJSlb68.js → xychartDiagram-ELKLHX3M-DrO-tWl0.js} +1 -1
- package/dist/webdist/index.html +2 -2
- package/package.json +1 -1
- package/dist/webdist/assets/ToolApprovalBar-BdNLuB0r.js +0 -21
- package/dist/webdist/assets/WorkspaceScreen-C2X82u27.js +0 -1
- package/dist/webdist/assets/channel-C1ooZeJ8.js +0 -1
- package/dist/webdist/assets/classDiagram-JCYQIIEL-c_ApQIjk.js +0 -1
- package/dist/webdist/assets/classDiagram-v2-OCEON4UE-c_ApQIjk.js +0 -1
- package/dist/webdist/assets/index-rQri1Mzm.css +0 -1
- package/dist/webdist/assets/personas-B7q-7L3z.js +0 -109
- package/dist/webdist/assets/stateDiagram-v2-UEYNNEHI-CaotCWUJ.js +0 -1
- package/dist/webdist/assets/swimlanesDiagram-ULZ7WXOC-BwXNVqW3.js +0 -8
package/dist/cli.js
CHANGED
|
@@ -6412,6 +6412,27 @@ function isQualifiedId(id) {
|
|
|
6412
6412
|
|
|
6413
6413
|
// src/cli-launch.ts
|
|
6414
6414
|
var AUTH_TOKEN = "turbollm-local";
|
|
6415
|
+
var PI_SEARCH_PACKAGE_NAME = "@heyhuynhgiabuu/pi-search";
|
|
6416
|
+
var PI_SEARCH_PACKAGE_SPEC = `${PI_SEARCH_PACKAGE_NAME}@0.3.0`;
|
|
6417
|
+
var PI_SEARCH_INSTALL_DISABLED = () => ["1", "true", "yes"].includes(process.env.TOBOLLM_PI_DISABLE_SEARCH_INSTALL?.toLowerCase() ?? "");
|
|
6418
|
+
var PI_SEARCH_PACKAGES_PREFIX = `npm:${PI_SEARCH_PACKAGE_NAME}@`;
|
|
6419
|
+
var PI_SEARCH_INSTALL_TIMEOUT_MS = 3e4;
|
|
6420
|
+
async function piSearchPackagePresent(fs2) {
|
|
6421
|
+
const path = join17(fs2.home, ".pi", "agent", "settings.json");
|
|
6422
|
+
let raw;
|
|
6423
|
+
try {
|
|
6424
|
+
raw = await fs2.readFile(path);
|
|
6425
|
+
} catch {
|
|
6426
|
+
return false;
|
|
6427
|
+
}
|
|
6428
|
+
let cfg2;
|
|
6429
|
+
try {
|
|
6430
|
+
cfg2 = JSON.parse(stripJsonComments(raw));
|
|
6431
|
+
} catch {
|
|
6432
|
+
return false;
|
|
6433
|
+
}
|
|
6434
|
+
return Array.isArray(cfg2.packages) && cfg2.packages.some((p) => typeof p === "string" && p.startsWith(PI_SEARCH_PACKAGES_PREFIX));
|
|
6435
|
+
}
|
|
6415
6436
|
var SUPPORTED = {
|
|
6416
6437
|
claude: {
|
|
6417
6438
|
bin: "claude",
|
|
@@ -6495,6 +6516,18 @@ var realSpawn = (cmd, args, opts) => {
|
|
|
6495
6516
|
}
|
|
6496
6517
|
return spawn4(buildShellCommand(cmd, args), opts);
|
|
6497
6518
|
};
|
|
6519
|
+
function runWithTimeout(spawnImpl, bin, args, timeoutMs) {
|
|
6520
|
+
return new Promise((resolve6) => {
|
|
6521
|
+
const timer2 = setTimeout(() => resolve6(false), timeoutMs);
|
|
6522
|
+
const child = spawnImpl(bin, args, { stdio: "ignore", shell: process.platform === "win32" });
|
|
6523
|
+
const settle = (code) => {
|
|
6524
|
+
clearTimeout(timer2);
|
|
6525
|
+
resolve6(code === 0);
|
|
6526
|
+
};
|
|
6527
|
+
child.on("error", () => settle(null));
|
|
6528
|
+
child.on("exit", (code) => settle(code));
|
|
6529
|
+
});
|
|
6530
|
+
}
|
|
6498
6531
|
async function fetchStatus(base2, _fetch = fetch) {
|
|
6499
6532
|
try {
|
|
6500
6533
|
const res = await _fetch(`${base2}/api/v1/status`, { signal: AbortSignal.timeout(3e3) });
|
|
@@ -6975,6 +7008,27 @@ async function syncHarnessModelConfig(target, opts, fs2 = realFs) {
|
|
|
6975
7008
|
AUTH_TOKEN
|
|
6976
7009
|
);
|
|
6977
7010
|
}
|
|
7011
|
+
async function ensurePiSearchPackage(run2 = realRunCommand, fs2 = realFs) {
|
|
7012
|
+
if (PI_SEARCH_INSTALL_DISABLED()) return;
|
|
7013
|
+
if (await piSearchPackagePresent(fs2)) return;
|
|
7014
|
+
let ok = false;
|
|
7015
|
+
try {
|
|
7016
|
+
ok = await run2("pi", ["install", `npm:${PI_SEARCH_PACKAGE_SPEC}`]);
|
|
7017
|
+
} catch {
|
|
7018
|
+
ok = false;
|
|
7019
|
+
}
|
|
7020
|
+
if (ok) {
|
|
7021
|
+
process.stderr.write(
|
|
7022
|
+
`Note: installed pi research tools (${PI_SEARCH_PACKAGE_SPEC}); web search is now available. Opt out any time with TOBOLLM_PI_DISABLE_SEARCH_INSTALL=1.
|
|
7023
|
+
`
|
|
7024
|
+
);
|
|
7025
|
+
} else {
|
|
7026
|
+
process.stderr.write(
|
|
7027
|
+
`Note: could not auto-install pi research tools (${PI_SEARCH_PACKAGE_SPEC}); web search will be unavailable until you run: pi install npm:${PI_SEARCH_PACKAGE_SPEC}.
|
|
7028
|
+
`
|
|
7029
|
+
);
|
|
7030
|
+
}
|
|
7031
|
+
}
|
|
6978
7032
|
async function launchCli(target, port2, passthrough, _spawn = realSpawn, modelKey, _fetch = fetch, authToken, _mcpFs = realFs) {
|
|
6979
7033
|
const spec = SUPPORTED[target];
|
|
6980
7034
|
if (!target || !spec) {
|
|
@@ -7120,6 +7174,10 @@ Open ${base2} \u2192 Models \u2192 Load a model, then run this again.
|
|
|
7120
7174
|
return 1;
|
|
7121
7175
|
}
|
|
7122
7176
|
}
|
|
7177
|
+
if (target === "pi") {
|
|
7178
|
+
const piSearchRun = (bin, args2) => runWithTimeout(_spawn, bin, args2, PI_SEARCH_INSTALL_TIMEOUT_MS);
|
|
7179
|
+
await ensurePiSearchPackage(piSearchRun, _mcpFs);
|
|
7180
|
+
}
|
|
7123
7181
|
const env = {
|
|
7124
7182
|
...inheritedEnv(process.env, spec.parentEnvMarkers),
|
|
7125
7183
|
...await spec.env?.(launchCtx) ?? {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-B0YBjihE.js";import{b as W,u as $,r as b}from"./vendor-C1I6euDx.js";import{u as G,d as H,e as Y,f as J,g as U,a as z,B as C,t as j,c as q,b as h,A as _}from"./index-DDdTmEU4.js";import{f as V}from"./chat-api-CmDwSCUy.js";import{f as X,a as Z}from"./agent-api-Bbbnu920.js";import{P as B}from"./personas-B7q-7L3z.js";import{C as ee}from"./chevron-left-CwO2nWWZ.js";import{R as te}from"./rotate-ccw-CTfSFG3x.js";import{T as se}from"./trash-2-BNNKBgll.js";import{C as ne}from"./chevron-right-Ck02yYBx.js";import"./dropdown-menu-CaMJbKX5.js";const ae=()=>({name:"",description:"",systemPrompt:"",skillIds:[],tools:[]});function oe(s){const d=[],x=new Map;for(const n of s){const a=/^mcp__([^_]+(?:_[^_]+)*)__/.exec(n.name);if(!a){d.push(n);continue}const i=a[1],p=/^\[([^\]]+)\]/.exec(n.description),c=p?p[1]:i.replace(/_/g," ");x.has(i)||x.set(i,{key:i,label:c,tools:[]}),x.get(i).tools.push(n)}return{builtin:d,groups:[...x.values()].sort((n,a)=>n.label.localeCompare(a.label))}}function le(s){return s.replace(/^mcp__[^_]+(?:_[^_]+)*__/,"")}function re(s){return s.replace(/^\[[^\]]+\]\s*/,"")}function D({tool:s,checked:d,onToggle:x}){return e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:d,onChange:x}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-ink",children:le(s.name)}),s.description&&e.jsx("span",{className:"text-faint",children:re(s.description)})]})]})}function ie({group:s,selected:d,onToggleAll:x,onToggleOne:n}){const[a,i]=b.useState(!1),p=s.tools.map(l=>l.name),c=p.filter(l=>d.has(l)).length,o=c===p.length,g=c>0&&!o,u=b.useRef(null);return b.useEffect(()=>{u.current&&(u.current.indeterminate=g)},[g]),e.jsxs("div",{className:"rounded-md border border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[e.jsx("input",{ref:u,type:"checkbox",checked:o,onChange:()=>x(p,!o)}),e.jsxs("button",{type:"button",onClick:()=>{j("agents","toggle_agent_tool_group"),i(l=>!l)},className:"flex flex-1 items-center gap-1.5 text-left text-[13px] text-ink",children:[e.jsx(ne,{size:12,className:q("shrink-0 text-faint transition-transform",a&&"rotate-90")}),s.label,e.jsxs("span",{className:"text-[11px] text-faint",children:["(",c,"/",p.length,")"]})]})]}),a&&e.jsx("div",{className:"flex flex-col gap-1.5 border-t border-border px-3 py-2 pl-9",children:s.tools.map(l=>e.jsx(D,{tool:l,checked:d.has(l.name),onToggle:()=>n(l.name)},l.name))})]})}function ce({tools:s,selected:d,onChange:x}){const n=new Set(d),{builtin:a,groups:i}=oe(s),p=o=>x(n.has(o)?d.filter(g=>g!==o):[...d,o]),c=(o,g)=>{const u=d.filter(l=>!o.includes(l));x(g?[...u,...o]:u)};return s.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No tools available yet."}):e.jsxs("div",{className:"flex flex-col gap-2",children:[a.length>0&&e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:a.map(o=>e.jsx(D,{tool:o,checked:n.has(o.name),onToggle:()=>p(o.name)},o.name))}),i.map(o=>e.jsx(ie,{group:o,selected:n,onToggleAll:c,onToggleOne:p},o.key))]})}function je(){const{agentId:s="new"}=W(),d=$(),x=G(),n=s==="new",a=!n&&B.some(t=>t.id===s),i=a?B.find(t=>t.id===s):void 0,p=H(),c=!n&&!a?(p.data??[]).find(t=>t.id===s):void 0,o=Y(),g=J(),u=U(),l=a?g.data?.[s]:void 0,I=z({queryKey:Z.list(),queryFn:X,staleTime:0}),k=I.data??[],w=z({queryKey:["available-tools"],queryFn:V}),N=w.data??[],[m,f]=b.useState(ae()),[S,T]=b.useState(!1),[A,P]=b.useState(!1),[L,R]=b.useState(!1),[E,Q]=b.useState("skills");n&&!S&&(k.length||N.length)&&(f(t=>({...t,skillIds:k.map(r=>r.id),tools:N.map(r=>r.name)})),T(!0)),!n&&!a&&!S&&c&&(f({name:c.name,description:c.description,systemPrompt:c.systemPrompt,skillIds:c.skillIds,tools:c.tools}),T(!0)),a&&!S&&i&&g.isSuccess&&(k.length||N.length)&&(f({name:l?.name??i.name,description:l?.description??i.description,systemPrompt:l?.systemPrompt??i.systemPrompt,skillIds:l?.skillIds??k.map(t=>t.id),tools:l?.tools??N.map(t=>t.name)}),T(!0));const y=()=>{j("agents","back_to_agents"),d("/customize")},O=t=>f(r=>({...r,skillIds:r.skillIds.includes(t)?r.skillIds.filter(v=>v!==t):[...r.skillIds,t]})),F=()=>{if(!m.name.trim()){h.error("Name is required.");return}P(!0);const t={name:m.name.trim(),description:m.description.trim(),systemPrompt:m.systemPrompt,skillIds:m.skillIds,tools:m.tools};if(a){u.save.mutate({id:s,override:t},{onSuccess:()=>{h.success("Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}});return}const r={onSuccess:()=>{x.invalidateQueries({queryKey:["chat-agents"]}),h.success(n?"Agent created.":"Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}};n?o.add.mutate(t,r):o.update.mutate({id:s,patch:t},r)},K=()=>{u.reset.mutate(s,{onSuccess:()=>{h.success("Reset to default."),i&&f({name:i.name,description:i.description,systemPrompt:i.systemPrompt,skillIds:k.map(t=>t.id),tools:N.map(t=>t.name)})},onError:t=>h.error(t instanceof _?t.message:"Could not reset agent.")})},M=()=>{o.remove.mutate(s,{onSuccess:()=>{h.success("Agent deleted."),y()},onError:t=>h.error(t instanceof _?t.message:"Could not delete agent.")})};return!n&&!a&&p.isSuccess&&!c?e.jsxs("div",{className:"flex w-full flex-col items-center gap-3 px-8 py-16",children:[e.jsx("p",{className:"text-[14px] text-muted",children:"That agent no longer exists."}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Back to agents"})]}):e.jsxs("div",{className:"flex w-full max-w-4xl flex-col gap-5 px-4 py-6 md:px-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:y,className:"text-faint hover:text-ink",title:"Back to agents",children:e.jsx(ee,{size:18})}),e.jsx("span",{className:"text-[15px] font-medium text-ink",children:n?"New agent":a?l?"Edit agent (modified built-in)":"Edit agent (built-in)":"Edit agent"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a&&e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{j("agents","reset_agent_to_default"),K()},disabled:u.reset.isPending,children:[e.jsx(te,{size:13})," Reset to default"]}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Cancel"}),e.jsx(C,{size:"sm",onClick:()=>{j("agents","save_agent"),F()},disabled:A||!m.name.trim(),children:A?"Saving…":"Save"})]})]}),a&&e.jsx("p",{className:"rounded-md border border-border bg-panel px-3 py-2 text-[12px] text-muted",children:"Built-in agents can be edited in place — Reset to default discards your changes and restores TurboLLM's original prompt and access."}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Name"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"Release Notes Writer",value:m.name,onChange:t=>f(r=>({...r,name:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Description"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"What this agent is for, in one line",value:m.description,onChange:t=>f(r=>({...r,description:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"System prompt"}),e.jsx("textarea",{className:"min-h-[160px] resize-y rounded-md border border-border bg-bg px-3 py-2 font-mono text-[12px] leading-relaxed text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"You are…",value:m.systemPrompt,onChange:t=>f(r=>({...r,systemPrompt:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx("div",{className:"inline-flex w-fit rounded-md border border-border p-0.5",children:["skills","tools"].map(t=>e.jsx("button",{type:"button",onClick:()=>{j("agents","switch_agent_form_tab"),Q(t)},className:q("rounded px-3 py-1.5 text-[13px] font-medium transition-colors",E===t?"bg-accent/12 text-accent":"text-muted hover:text-ink"),children:t==="skills"?`Skills (${m.skillIds.length})`:`Tools (${m.tools.length})`},t))}),E==="skills"?I.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):k.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No skills yet — create one under Customize → Skills."}):e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:k.map(t=>e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:m.skillIds.includes(t.id),onChange:()=>O(t.id)}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"text-ink",children:t.name}),t.description&&e.jsx("span",{className:"text-[12px] text-muted",children:t.description})]})]},t.id))}):w.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):e.jsx(ce,{tools:N,selected:m.tools,onChange:t=>f(r=>({...r,tools:t}))})]}),!n&&!a&&(L?e.jsxs("div",{className:"flex items-center gap-2 self-start rounded-md border border-border bg-panel p-2 text-[12px]",children:[e.jsx("span",{className:"flex-1 text-muted",children:"Delete this agent?"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","delete_agent"),M()},className:"rounded px-2 py-1 text-[color:var(--err)] hover:bg-[color:color-mix(in_srgb,var(--err)_12%,transparent)]",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","cancel_delete_agent"),R(!1)},className:"rounded px-2 py-1 text-faint hover:text-ink",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>R(!0),className:"flex items-center gap-1.5 self-start text-[12px] text-faint hover:text-[color:var(--err)]",children:[e.jsx(se,{size:13})," Delete agent"]}))]})}export{je as AgentEditPage};
|
|
1
|
+
import{j as e}from"./radix-B0YBjihE.js";import{b as W,u as $,r as b}from"./vendor-C1I6euDx.js";import{u as G,d as H,e as Y,f as J,g as U,a as z,B as C,t as j,c as q,b as h,A as _}from"./index-D0Emka7d.js";import{f as V}from"./chat-api-Zyxy4wka.js";import{f as X,a as Z}from"./agent-api-CmhXBBT6.js";import{P as B}from"./personas-CeAQ6niU.js";import{C as ee}from"./chevron-left-CBtdrcDZ.js";import{R as te}from"./rotate-ccw-BpPatpxx.js";import{T as se}from"./trash-2-DbQqCHSH.js";import{C as ne}from"./chevron-right-DRLCoDa8.js";import"./dropdown-menu-DRRO0ftt.js";const ae=()=>({name:"",description:"",systemPrompt:"",skillIds:[],tools:[]});function oe(s){const d=[],x=new Map;for(const n of s){const a=/^mcp__([^_]+(?:_[^_]+)*)__/.exec(n.name);if(!a){d.push(n);continue}const i=a[1],p=/^\[([^\]]+)\]/.exec(n.description),c=p?p[1]:i.replace(/_/g," ");x.has(i)||x.set(i,{key:i,label:c,tools:[]}),x.get(i).tools.push(n)}return{builtin:d,groups:[...x.values()].sort((n,a)=>n.label.localeCompare(a.label))}}function le(s){return s.replace(/^mcp__[^_]+(?:_[^_]+)*__/,"")}function re(s){return s.replace(/^\[[^\]]+\]\s*/,"")}function D({tool:s,checked:d,onToggle:x}){return e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:d,onChange:x}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-ink",children:le(s.name)}),s.description&&e.jsx("span",{className:"text-faint",children:re(s.description)})]})]})}function ie({group:s,selected:d,onToggleAll:x,onToggleOne:n}){const[a,i]=b.useState(!1),p=s.tools.map(l=>l.name),c=p.filter(l=>d.has(l)).length,o=c===p.length,g=c>0&&!o,u=b.useRef(null);return b.useEffect(()=>{u.current&&(u.current.indeterminate=g)},[g]),e.jsxs("div",{className:"rounded-md border border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[e.jsx("input",{ref:u,type:"checkbox",checked:o,onChange:()=>x(p,!o)}),e.jsxs("button",{type:"button",onClick:()=>{j("agents","toggle_agent_tool_group"),i(l=>!l)},className:"flex flex-1 items-center gap-1.5 text-left text-[13px] text-ink",children:[e.jsx(ne,{size:12,className:q("shrink-0 text-faint transition-transform",a&&"rotate-90")}),s.label,e.jsxs("span",{className:"text-[11px] text-faint",children:["(",c,"/",p.length,")"]})]})]}),a&&e.jsx("div",{className:"flex flex-col gap-1.5 border-t border-border px-3 py-2 pl-9",children:s.tools.map(l=>e.jsx(D,{tool:l,checked:d.has(l.name),onToggle:()=>n(l.name)},l.name))})]})}function ce({tools:s,selected:d,onChange:x}){const n=new Set(d),{builtin:a,groups:i}=oe(s),p=o=>x(n.has(o)?d.filter(g=>g!==o):[...d,o]),c=(o,g)=>{const u=d.filter(l=>!o.includes(l));x(g?[...u,...o]:u)};return s.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No tools available yet."}):e.jsxs("div",{className:"flex flex-col gap-2",children:[a.length>0&&e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:a.map(o=>e.jsx(D,{tool:o,checked:n.has(o.name),onToggle:()=>p(o.name)},o.name))}),i.map(o=>e.jsx(ie,{group:o,selected:n,onToggleAll:c,onToggleOne:p},o.key))]})}function je(){const{agentId:s="new"}=W(),d=$(),x=G(),n=s==="new",a=!n&&B.some(t=>t.id===s),i=a?B.find(t=>t.id===s):void 0,p=H(),c=!n&&!a?(p.data??[]).find(t=>t.id===s):void 0,o=Y(),g=J(),u=U(),l=a?g.data?.[s]:void 0,I=z({queryKey:Z.list(),queryFn:X,staleTime:0}),k=I.data??[],w=z({queryKey:["available-tools"],queryFn:V}),N=w.data??[],[m,f]=b.useState(ae()),[S,T]=b.useState(!1),[A,P]=b.useState(!1),[L,R]=b.useState(!1),[E,Q]=b.useState("skills");n&&!S&&(k.length||N.length)&&(f(t=>({...t,skillIds:k.map(r=>r.id),tools:N.map(r=>r.name)})),T(!0)),!n&&!a&&!S&&c&&(f({name:c.name,description:c.description,systemPrompt:c.systemPrompt,skillIds:c.skillIds,tools:c.tools}),T(!0)),a&&!S&&i&&g.isSuccess&&(k.length||N.length)&&(f({name:l?.name??i.name,description:l?.description??i.description,systemPrompt:l?.systemPrompt??i.systemPrompt,skillIds:l?.skillIds??k.map(t=>t.id),tools:l?.tools??N.map(t=>t.name)}),T(!0));const y=()=>{j("agents","back_to_agents"),d("/customize")},O=t=>f(r=>({...r,skillIds:r.skillIds.includes(t)?r.skillIds.filter(v=>v!==t):[...r.skillIds,t]})),F=()=>{if(!m.name.trim()){h.error("Name is required.");return}P(!0);const t={name:m.name.trim(),description:m.description.trim(),systemPrompt:m.systemPrompt,skillIds:m.skillIds,tools:m.tools};if(a){u.save.mutate({id:s,override:t},{onSuccess:()=>{h.success("Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}});return}const r={onSuccess:()=>{x.invalidateQueries({queryKey:["chat-agents"]}),h.success(n?"Agent created.":"Agent saved."),y()},onError:v=>{h.error(v instanceof _?v.message:"Could not save agent."),P(!1)}};n?o.add.mutate(t,r):o.update.mutate({id:s,patch:t},r)},K=()=>{u.reset.mutate(s,{onSuccess:()=>{h.success("Reset to default."),i&&f({name:i.name,description:i.description,systemPrompt:i.systemPrompt,skillIds:k.map(t=>t.id),tools:N.map(t=>t.name)})},onError:t=>h.error(t instanceof _?t.message:"Could not reset agent.")})},M=()=>{o.remove.mutate(s,{onSuccess:()=>{h.success("Agent deleted."),y()},onError:t=>h.error(t instanceof _?t.message:"Could not delete agent.")})};return!n&&!a&&p.isSuccess&&!c?e.jsxs("div",{className:"flex w-full flex-col items-center gap-3 px-8 py-16",children:[e.jsx("p",{className:"text-[14px] text-muted",children:"That agent no longer exists."}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Back to agents"})]}):e.jsxs("div",{className:"flex w-full max-w-4xl flex-col gap-5 px-4 py-6 md:px-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:y,className:"text-faint hover:text-ink",title:"Back to agents",children:e.jsx(ee,{size:18})}),e.jsx("span",{className:"text-[15px] font-medium text-ink",children:n?"New agent":a?l?"Edit agent (modified built-in)":"Edit agent (built-in)":"Edit agent"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a&&e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{j("agents","reset_agent_to_default"),K()},disabled:u.reset.isPending,children:[e.jsx(te,{size:13})," Reset to default"]}),e.jsx(C,{size:"sm",variant:"outline",onClick:y,children:"Cancel"}),e.jsx(C,{size:"sm",onClick:()=>{j("agents","save_agent"),F()},disabled:A||!m.name.trim(),children:A?"Saving…":"Save"})]})]}),a&&e.jsx("p",{className:"rounded-md border border-border bg-panel px-3 py-2 text-[12px] text-muted",children:"Built-in agents can be edited in place — Reset to default discards your changes and restores TurboLLM's original prompt and access."}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Name"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"Release Notes Writer",value:m.name,onChange:t=>f(r=>({...r,name:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"Description"}),e.jsx("input",{className:"rounded-md border border-border bg-bg px-3 py-1.5 text-[13px] text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"What this agent is for, in one line",value:m.description,onChange:t=>f(r=>({...r,description:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[12px] font-medium text-muted",children:"System prompt"}),e.jsx("textarea",{className:"min-h-[160px] resize-y rounded-md border border-border bg-bg px-3 py-2 font-mono text-[12px] leading-relaxed text-ink outline-none focus:border-accent placeholder:text-faint",placeholder:"You are…",value:m.systemPrompt,onChange:t=>f(r=>({...r,systemPrompt:t.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx("div",{className:"inline-flex w-fit rounded-md border border-border p-0.5",children:["skills","tools"].map(t=>e.jsx("button",{type:"button",onClick:()=>{j("agents","switch_agent_form_tab"),Q(t)},className:q("rounded px-3 py-1.5 text-[13px] font-medium transition-colors",E===t?"bg-accent/12 text-accent":"text-muted hover:text-ink"),children:t==="skills"?`Skills (${m.skillIds.length})`:`Tools (${m.tools.length})`},t))}),E==="skills"?I.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):k.length===0?e.jsx("p",{className:"text-[12px] text-faint",children:"No skills yet — create one under Customize → Skills."}):e.jsx("div",{className:"flex flex-col gap-2 rounded-md border border-border bg-panel-2 p-3",children:k.map(t=>e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:m.skillIds.includes(t.id),onChange:()=>O(t.id)}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"text-ink",children:t.name}),t.description&&e.jsx("span",{className:"text-[12px] text-muted",children:t.description})]})]},t.id))}):w.isLoading?e.jsx("p",{className:"text-[12px] text-faint",children:"Loading…"}):e.jsx(ce,{tools:N,selected:m.tools,onChange:t=>f(r=>({...r,tools:t}))})]}),!n&&!a&&(L?e.jsxs("div",{className:"flex items-center gap-2 self-start rounded-md border border-border bg-panel p-2 text-[12px]",children:[e.jsx("span",{className:"flex-1 text-muted",children:"Delete this agent?"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","delete_agent"),M()},className:"rounded px-2 py-1 text-[color:var(--err)] hover:bg-[color:color-mix(in_srgb,var(--err)_12%,transparent)]",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>{j("agents","cancel_delete_agent"),R(!1)},className:"rounded px-2 py-1 text-faint hover:text-ink",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>R(!0),className:"flex items-center gap-1.5 self-start text-[12px] text-faint hover:text-[color:var(--err)]",children:[e.jsx(se,{size:13})," Delete agent"]}))]})}export{je as AgentEditPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Kn=u=>{throw TypeError(u)};var Ri=(u,t,e)=>t.has(u)||Kn("Cannot "+e);var it=(u,t,e)=>(Ri(u,t,"read from private field"),e?e.call(u):t.get(u)),Wt=(u,t,e)=>t.has(u)?Kn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),wt=(u,t,e,s)=>(Ri(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),Xt=(u,t,e)=>(Ri(u,t,"access private method"),e);var qn=(u,t,e,s)=>({set _(i){wt(u,t,i,e)},get _(){return it(u,t,s)}});import{j as C}from"./radix-B0YBjihE.js";import{r as B,b as Oa,c as Ba}from"./vendor-C1I6euDx.js";import{R as ja,D as Ha,p as Qn,l as Ua,q as Ga,t as $a}from"./chat-api-CmDwSCUy.js";import{u as kr,a as za,c as Va}from"./chat-queries-opwsCDIy.js";import{h as on,a as Mr,B as le,Y as Wa,c as $s,t as ut,b as At,A as Le,k as Xa,S as Ya,y as Ka,z as qa,Z as Qa,d as Ja,f as Za,u as to,l as eo,m as so,n as Ds,$ as Jn,a0 as io,X as Ls,a1 as no,a2 as ro,a3 as ao,a4 as oo}from"./index-DDdTmEU4.js";import{b as lo,S as co,A as ho,T as uo,c as fo,u as po}from"./ToolApprovalBar-BdNLuB0r.js";import{u as go,r as mo,S as bo,s as yo,C as Ao,a as vo,P as xo}from"./SidebarResizeHandle-BEjYiHxx.js";import{D as wo,a as So,b as Co,d as Fi,c as Eo}from"./dropdown-menu-CaMJbKX5.js";import{f as Pr,a as Ir}from"./agent-api-Bbbnu920.js";import{f as _o,d as To,M as ko,T as Mo,a as Po,S as Io,s as Do}from"./ModelLoadMenu-DIsk-jZz.js";import{D as Lo,c as No,d as Ro,e as Fo,f as Oo,g as Bo,u as jo,a as Ho,h as Uo}from"./link-queries-DvYdzQm8.js";import{M as Go}from"./ModelDetailDialog-Bf99Dj9I.js";import{S as $o}from"./switch-CJAukDSs.js";import{C as zo,a as Vo,b as Wo}from"./collapsible-BEzntcAR.js";import{C as Xo}from"./chevron-right-Ck02yYBx.js";import{u as Yo}from"./useIsDesktop-BWN1ktaj.js";import{a as Oi,r as Ko,b as qo,c as Qo,g as Jo,d as Zo}from"./personas-B7q-7L3z.js";import{a as tl}from"./sliders-horizontal-GlSfzSwu.js";import"./chevron-down-DiyKHxC-.js";import"./circle-check-CM_EzD0B.js";import"./pencil-D9a-4tCA.js";import"./tool-explain-B8rnv8bW.js";import"./file-text-SkW8GJLf.js";import"./trash-2-BNNKBgll.js";import"./refresh-cw-bRtvR0Iv.js";import"./index-glXD6BQc.js";import"./chevron-left-CwO2nWWZ.js";import"./circle-x-DDCTEjWL.js";import"./alert-dialog-DBTMGpVB.js";import"./skeleton-kNhR6J5G.js";import"./plus-DP3JYEma.js";import"./folder-plus-By4aZIqn.js";import"./folder-input-DdDYio8z.js";import"./triangle-alert-vMymArLW.js";import"./star-BDNzpKYY.js";import"./common-BmIDcygp.js";import"./vram-CyjPY3u5.js";import"./external-link-B73_NSLw.js";import"./rotate-ccw-CTfSFG3x.js";const el=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],sl=on("paperclip",el);const il=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],nl=on("share-2",il);const rl=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],al=on("user-round",rl),Mt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ne=[1/0,1/0,-1/0,-1/0],ve=new Float32Array(ne),Vi=[.001,0,0,.001,0,0],vt="http://www.w3.org/2000/svg",Tt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ce={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Oe="pdfjs_internal_id_",is="pdfjs_internal_editor_",$={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},V={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},ol={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},pt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},zs={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},at={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},Ne={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Zs={ERRORS:0,WARNINGS:1,INFOS:5},Qt={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},Ke={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},ll={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let ti=Zs.WARNINGS;function cl(u){Number.isInteger(u)&&(ti=u)}function hl(){return ti}function ei(u){ti>=Zs.INFOS&&console.info(`Info: ${u}`)}function z(u){ti>=Zs.WARNINGS&&console.warn(`Warning: ${u}`)}function Y(u){throw new Error(u)}function lt(u,t){u||Y(t)}function dl(u){switch(u?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Dr(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"&&(e.addDefaultProtocol&&u.startsWith("www.")&&u.match(/\./g)?.length>=2&&(u=`http://${u}`),e.tryConvertEncoding))try{u=pl(u)}catch{}const s=t?URL.parse(u,t):URL.parse(u);return dl(s)?s:null}function Lr(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&Dr(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Wi(u){return u.substring(u.lastIndexOf("/")+1)}function U(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Te=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Xi extends Te{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Bi extends Te{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Yi extends Te{constructor(t){super(t,"InvalidPDFException")}}class Ys extends Te{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class ul extends Te{constructor(t){super(t,"FormatError")}}class de extends Te{constructor(t){super(t,"AbortException")}}function fl(u){(typeof u!="object"||u?.length===void 0)&&Y("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=u.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function si(u){typeof u!="string"&&Y("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}class Z{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return U(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return U(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return U(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return U(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return U(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return U(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),U(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return U(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",U(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return U(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class P{static get hexNums(){return U(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}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,s=0){const i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){const h=t[s+c],d=t[s+c+1];t[s+c]=h*i+d*r+o,t[s+c+1]=h*n+d*a+l}}static applyInverseTransform(t,e){const s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],c=t[0],h=t[1],d=t[2],f=t[3];let p=i*c+o,g=p,m=i*d+o,b=m,y=a*h+l,A=y,w=a*f+l,x=w;if(n!==0||r!==0){const S=n*c,E=n*d,_=r*h,k=r*f;p+=_,b+=_,m+=k,g+=k,y+=S,x+=S,w+=E,A+=E}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,w,A,x),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,w,A,x)}static inverseTransform(t){const 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){const s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,c=(a+l)/2,h=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+h||1),e[1]=Math.sqrt(c-h||1)}static normalizeRect(t){const 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){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const 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:[s,n,i,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,c){if(l<=0||l>=1)return;const h=1-l,d=l*l,f=d*l,p=h*(h*(h*t+3*l*e)+3*d*s)+f*i,g=h*(h*(h*n+3*l*r)+3*d*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,l,c,h,d){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-h/c,d);return}const f=c**2-4*h*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-c+p)/g,d),this.#t(t,e,s,i,n,r,a,o,(-c-p)/g,d)}static bezierBoundingBox(t,e,s,i,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,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}}function pl(u){return decodeURIComponent(escape(u))}let ji=null,Zn=null;function gl(u){return ji||(ji=/([\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,Zn=new Map([["ſt","ſt"]])),u.replaceAll(ji,(t,e,s)=>e?e.normalize("NFKC"):Zn.get(s))}function Nr(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),fl(u)}function ml(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...n]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const r=n.length;let a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(const o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const cs=()=>[],ln=()=>new Map,Ki=()=>Object.create(null),bl=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(u){return[...this].join(u)});function et(u,t,e){return Math.min(Math.max(u,t),e)}class hs{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,h,d,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,h=0,d=0,f=1;break;case 90:c=0,h=1,d=1,f=0;break;case 270:c=0,h=-1,d=-1,f=0;break;case 0:c=1,h=0,d=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(d=-d,f=-f);let p,g,m,b;c===0?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[c*s,h*s,d*s,f*s,p-c*s*o-d*s*l,g-h*s*o-f*s*l],this.width=m,this.height=b}get rawDims(){const t=this.viewBox;return U(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:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new hs({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];return P.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return P.applyInverseTransform(s,this.transform),s}}class ns{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(ns.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const yl=/url\(|image-set\(/i,Al=/^on/i;class Rr{static get _allowedHtmlElements(){return U(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return U(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return U(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return U(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return U(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,l]of Object.entries(r))if(l!=null&&!Al.test(o)&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){const c=this._allowedRichTextStyles;for(const[h,d]of Object.entries(l))c.has(h)&&!yl.test(d)&&(t.style[h]=d)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===vt&&this._allowedSvgElements.has(t)?document.createElementNS(vt,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const h=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=h}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const h=document.createTextNode(i.value);r.append(h),a&&ns.shouldBuildText(i.name)&&l.push(h)}return{textDivs:l}}const c=[[i,-1,r]];for(;c.length>0;){const[h,d,f]=c.at(-1);if(d+1===h.children.length){c.pop();continue}const p=h.children[++c.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const b=document.createTextNode(p.value);l.push(b),f.append(b);continue}const m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){const b=document.createTextNode(p.value);a&&ns.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(const h of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))h.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style;return new hs({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}class Ge{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function cn(u,t="text"){if(ts(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class hn extends Te{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ii(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function dn(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function vl(u){return[u]=u.split(/[#?]/,1),Wi(u)}function xl(u,t="document.pdf"){if(typeof u!="string")return t;if(ii(u))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(u);if(!s)return t;const i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Wi(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Wi(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){const a=l=>[...l].findLast(c=>n.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){const o=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(o)return i(o[0])}return t}class tr{#t=new Map;times=[];time(t){this.#t.has(t)&&z(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||z(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
|
|
1
|
+
var Kn=u=>{throw TypeError(u)};var Ri=(u,t,e)=>t.has(u)||Kn("Cannot "+e);var it=(u,t,e)=>(Ri(u,t,"read from private field"),e?e.call(u):t.get(u)),Wt=(u,t,e)=>t.has(u)?Kn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),wt=(u,t,e,s)=>(Ri(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),Xt=(u,t,e)=>(Ri(u,t,"access private method"),e);var qn=(u,t,e,s)=>({set _(i){wt(u,t,i,e)},get _(){return it(u,t,s)}});import{j as C}from"./radix-B0YBjihE.js";import{r as B,b as Oa,c as Ba}from"./vendor-C1I6euDx.js";import{R as ja,D as Ha,p as Qn,l as Ua,q as Ga,t as $a}from"./chat-api-Zyxy4wka.js";import{u as kr,a as za,c as Va}from"./chat-queries-DIm_a9NN.js";import{h as on,a as Mr,B as le,Y as Wa,c as $s,t as ut,b as At,A as Le,k as Xa,S as Ya,y as Ka,z as qa,Z as Qa,d as Ja,f as Za,u as to,l as eo,m as so,n as Ds,$ as Jn,a0 as io,X as Ls,a1 as no,a2 as ro,a3 as ao,a4 as oo}from"./index-D0Emka7d.js";import{b as lo,S as co,A as ho,T as uo,c as fo,u as po}from"./ToolApprovalBar-Chx2y-tr.js";import{u as go,r as mo,S as bo,s as yo,C as Ao,a as vo,P as xo}from"./SidebarResizeHandle-Bc3QBs84.js";import{D as wo,a as So,b as Co,d as Fi,c as Eo}from"./dropdown-menu-DRRO0ftt.js";import{f as Pr,a as Ir}from"./agent-api-CmhXBBT6.js";import{f as _o,d as To,M as ko,T as Mo,a as Po,S as Io,s as Do}from"./ModelLoadMenu-BoD8vGEb.js";import{D as Lo,c as No,d as Ro,e as Fo,f as Oo,g as Bo,u as jo,a as Ho,h as Uo}from"./link-queries-DBf0L0p4.js";import{M as Go}from"./ModelDetailDialog-CCmZhT_-.js";import{S as $o}from"./switch-Cs9dlnwb.js";import{C as zo,a as Vo,b as Wo}from"./collapsible-BEzntcAR.js";import{C as Xo}from"./chevron-right-DRLCoDa8.js";import{u as Yo}from"./useIsDesktop-BdbkbmUH.js";import{a as Oi,r as Ko,b as qo,c as Qo,g as Jo,d as Zo}from"./personas-CeAQ6niU.js";import{a as tl}from"./sliders-horizontal-D48--I0k.js";import"./chevron-down-BWfjeD2C.js";import"./circle-check-loUJak9B.js";import"./pencil-CJDKBSrc.js";import"./tool-explain-B8rnv8bW.js";import"./file-text-BJHbdxSm.js";import"./trash-2-DbQqCHSH.js";import"./refresh-cw-Qd40C8Nj.js";import"./index-glXD6BQc.js";import"./chevron-left-CBtdrcDZ.js";import"./circle-x-Bgnj4qQZ.js";import"./alert-dialog-B7ASyTxr.js";import"./skeleton-C1KITEIJ.js";import"./plus-CtCCCtT9.js";import"./folder-plus-Bz7B7UnH.js";import"./folder-input-ubj-7_tQ.js";import"./triangle-alert-Buguln0S.js";import"./star-B2buMvXV.js";import"./common-B5JH_OFR.js";import"./vram-CyjPY3u5.js";import"./external-link-dolckdL9.js";import"./rotate-ccw-BpPatpxx.js";const el=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],sl=on("paperclip",el);const il=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],nl=on("share-2",il);const rl=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],al=on("user-round",rl),Mt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ne=[1/0,1/0,-1/0,-1/0],ve=new Float32Array(ne),Vi=[.001,0,0,.001,0,0],vt="http://www.w3.org/2000/svg",Tt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ce={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Oe="pdfjs_internal_id_",is="pdfjs_internal_editor_",$={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},V={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},ol={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},pt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},zs={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},at={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},Ne={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Zs={ERRORS:0,WARNINGS:1,INFOS:5},Qt={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},Ke={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},ll={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let ti=Zs.WARNINGS;function cl(u){Number.isInteger(u)&&(ti=u)}function hl(){return ti}function ei(u){ti>=Zs.INFOS&&console.info(`Info: ${u}`)}function z(u){ti>=Zs.WARNINGS&&console.warn(`Warning: ${u}`)}function Y(u){throw new Error(u)}function lt(u,t){u||Y(t)}function dl(u){switch(u?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Dr(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"&&(e.addDefaultProtocol&&u.startsWith("www.")&&u.match(/\./g)?.length>=2&&(u=`http://${u}`),e.tryConvertEncoding))try{u=pl(u)}catch{}const s=t?URL.parse(u,t):URL.parse(u);return dl(s)?s:null}function Lr(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&Dr(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Wi(u){return u.substring(u.lastIndexOf("/")+1)}function U(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Te=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Xi extends Te{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Bi extends Te{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Yi extends Te{constructor(t){super(t,"InvalidPDFException")}}class Ys extends Te{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class ul extends Te{constructor(t){super(t,"FormatError")}}class de extends Te{constructor(t){super(t,"AbortException")}}function fl(u){(typeof u!="object"||u?.length===void 0)&&Y("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=u.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function si(u){typeof u!="string"&&Y("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}class Z{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return U(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return U(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return U(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return U(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return U(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return U(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),U(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return U(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",U(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return U(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class P{static get hexNums(){return U(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}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,s=0){const i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){const h=t[s+c],d=t[s+c+1];t[s+c]=h*i+d*r+o,t[s+c+1]=h*n+d*a+l}}static applyInverseTransform(t,e){const s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],c=t[0],h=t[1],d=t[2],f=t[3];let p=i*c+o,g=p,m=i*d+o,b=m,y=a*h+l,A=y,w=a*f+l,x=w;if(n!==0||r!==0){const S=n*c,E=n*d,_=r*h,k=r*f;p+=_,b+=_,m+=k,g+=k,y+=S,x+=S,w+=E,A+=E}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,w,A,x),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,w,A,x)}static inverseTransform(t){const 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){const s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,c=(a+l)/2,h=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+h||1),e[1]=Math.sqrt(c-h||1)}static normalizeRect(t){const 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){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const 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:[s,n,i,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,c){if(l<=0||l>=1)return;const h=1-l,d=l*l,f=d*l,p=h*(h*(h*t+3*l*e)+3*d*s)+f*i,g=h*(h*(h*n+3*l*r)+3*d*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,l,c,h,d){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-h/c,d);return}const f=c**2-4*h*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-c+p)/g,d),this.#t(t,e,s,i,n,r,a,o,(-c-p)/g,d)}static bezierBoundingBox(t,e,s,i,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,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}}function pl(u){return decodeURIComponent(escape(u))}let ji=null,Zn=null;function gl(u){return ji||(ji=/([\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,Zn=new Map([["ſt","ſt"]])),u.replaceAll(ji,(t,e,s)=>e?e.normalize("NFKC"):Zn.get(s))}function Nr(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),fl(u)}function ml(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...n]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const r=n.length;let a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(const o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const cs=()=>[],ln=()=>new Map,Ki=()=>Object.create(null),bl=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(u){return[...this].join(u)});function et(u,t,e){return Math.min(Math.max(u,t),e)}class hs{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,h,d,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,h=0,d=0,f=1;break;case 90:c=0,h=1,d=1,f=0;break;case 270:c=0,h=-1,d=-1,f=0;break;case 0:c=1,h=0,d=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(d=-d,f=-f);let p,g,m,b;c===0?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[c*s,h*s,d*s,f*s,p-c*s*o-d*s*l,g-h*s*o-f*s*l],this.width=m,this.height=b}get rawDims(){const t=this.viewBox;return U(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:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new hs({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];return P.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return P.applyInverseTransform(s,this.transform),s}}class ns{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(ns.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const yl=/url\(|image-set\(/i,Al=/^on/i;class Rr{static get _allowedHtmlElements(){return U(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return U(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return U(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return U(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return U(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,l]of Object.entries(r))if(l!=null&&!Al.test(o)&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){const c=this._allowedRichTextStyles;for(const[h,d]of Object.entries(l))c.has(h)&&!yl.test(d)&&(t.style[h]=d)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===vt&&this._allowedSvgElements.has(t)?document.createElementNS(vt,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const h=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=h}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const h=document.createTextNode(i.value);r.append(h),a&&ns.shouldBuildText(i.name)&&l.push(h)}return{textDivs:l}}const c=[[i,-1,r]];for(;c.length>0;){const[h,d,f]=c.at(-1);if(d+1===h.children.length){c.pop();continue}const p=h.children[++c.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const b=document.createTextNode(p.value);l.push(b),f.append(b);continue}const m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){const b=document.createTextNode(p.value);a&&ns.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(const h of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))h.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style;return new hs({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}class Ge{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function cn(u,t="text"){if(ts(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class hn extends Te{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ii(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function dn(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function vl(u){return[u]=u.split(/[#?]/,1),Wi(u)}function xl(u,t="document.pdf"){if(typeof u!="string")return t;if(ii(u))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(u);if(!s)return t;const i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Wi(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Wi(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){const a=l=>[...l].findLast(c=>n.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){const o=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(o)return i(o[0])}return t}class tr{#t=new Map;times=[];time(t){this.#t.has(t)&&z(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||z(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
|
|
2
2
|
`).join("")}}function ts(u,t){const e=t?URL.parse(u,t):URL.parse(u);return/https?:/.test(e?.protocol??"")}function Ft(u){u.preventDefault()}function ot(u){u.preventDefault(),u.stopPropagation()}class qi{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-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;const l=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(e[9],10)||0;return h=h>=0&&h<=59?h:0,l==="-"?(r+=c,a+=h):l==="+"&&(r-=c,a-=h),new Date(Date.UTC(s,i,n,r,a,o))}}function ds(u){if(u.startsWith("#")){const e=u.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(u.startsWith("rgb(")){const[e,s,i]=u.slice(4,-1).split(",").map(n=>parseInt(n,10));return[e,s,i,1]}if(u.startsWith("rgba(")){const e=u.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=u.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function us(u){const t=ds(u);return t?t.slice(0,3):(z(`Not a valid color format: "${u}"`),[0,0,0])}function wl(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,us(s))}t.remove()}function tt(u){const{a:t,b:e,c:s,d:i,e:n,f:r}=u.getTransform();return[t,e,s,i,n,r]}function Yt(u){const{a:t,b:e,c:s,d:i,e:n,f:r}=u.getTransform().invertSelf();return[t,e,s,i,n,r]}function Ee(u,t,e=!1,s=!0){if(t instanceof hs){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=u,a=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-y))`;!e||t.rotation%180===0?(r.width=a,r.height=o):(r.width=o,r.height=a)}s&&u.setAttribute("data-main-rotation",t.rotation)}class Zt{constructor(){const{pixelRatio:t}=Zt;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let r=1/0,a=1/0,o=1/0;s=Zt.capPixels(s,n),s>0&&(r=Math.sqrt(s/(t*e))),i!==-1&&(a=i/t,o=i/e);const l=Math.min(r,a,o);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const Qi=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Sl{static get isDarkMode(){return U(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class Cl{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),U(this,"commentForegroundColor",us(s))}}function El(u,t){t=et(t??1,0,1);const e=255*(1-t);return u.map(s=>Math.round(s*t+e))}function er(u,t){const e=u[0]/255,s=u[1]/255,i=u[2]/255,n=Math.max(e,s,i),r=Math.min(e,s,i),a=(n+r)/2;if(n===r)t[0]=t[1]=0;else{const o=n-r;switch(t[1]=a<.5?o/(n+r):o/(2-n-r),n){case e:t[0]=((s-i)/o+(s<i?6:0))*60;break;case s:t[0]=((i-e)/o+2)*60;break;case i:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function Ji(u,t){const e=u[0],s=u[1],i=u[2],n=(1-Math.abs(2*i-1))*s,r=n*(1-Math.abs(e/60%2-1)),a=i-n/2;switch(Math.floor(e/60)){case 0:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 1:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 2:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 3:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 4:t[0]=r+a,t[1]=a,t[2]=n+a;break;case 5:case 6:t[0]=n+a,t[1]=a,t[2]=r+a;break}}function sr(u){return u<=.03928?u/12.92:((u+.055)/1.055)**2.4}function ir(u,t,e){Ji(u,e),e.map(sr);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Ji(t,e),e.map(sr);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const nr=new Map;function _l(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=nr.get(e);if(s)return s;const i=new Float32Array(9),n=i.subarray(0,3),r=i.subarray(3,6);er(u,r);const a=i.subarray(6,9);er(t,a);const o=a[2]<.5,l=o?12:4.5;if(r[2]=o?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),ir(r,a,n)<l){let c,h;o?(c=r[2],h=1):(c=0,h=r[2]);const d=.005;for(;h-c>d;){const f=r[2]=(c+h)/2;o===ir(r,a,n)<l?c=f:h=f}r[2]=o?h:c}return Ji(r,n),s=P.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),nr.set(e,s),s}function Fr({html:u,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof u=="string"){const n=document.createElement("p");n.dir=t||"auto";const r=u.split(/\r\n?|\n/);for(let a=0,o=r.length;a<o;++a){const l=r[a];n.append(document.createTextNode(l)),a<o-1&&n.append(document.createElement("br"))}i.append(n)}else Rr.render({xfaHtml:u,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function Or(u){const t=new Path2D;if(!u)return t;for(let e=0,s=u.length;e<s;)switch(u[e++]){case Ke.moveTo:t.moveTo(u[e++],u[e++]);break;case Ke.lineTo:t.lineTo(u[e++],u[e++]);break;case Ke.curveTo:t.bezierCurveTo(u[e++],u[e++],u[e++],u[e++],u[e++],u[e++]);break;case Ke.quadraticCurveTo:t.quadraticCurveTo(u[e++],u[e++],u[e++],u[e++]);break;case Ke.closePath:t.closePath();break;default:z(`Unrecognized drawing path operator: ${u[e-1]}`);break}return t}class es{#t=null;#e=null;#s;#i=null;#n=null;#a=null;#r=null;#o=null;static#h=null;constructor(t){this.#s=t,es.#h||=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(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Ft,{signal:e}),t.addEventListener("pointerdown",es.#l,{signal:e}));const s=this.#i=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#l(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,ot(t)}#d(t){this.#s._focusEventsAllowed=!0,ot(t)}#p(t){const e=this.#s._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ft,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#n?.shown(),this.#a?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",es.#h[t]),this.#p(s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#i.append(s)}get#m(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#i.append(e,this.#m),this.#n=t}addComment(t,e=null){if(this.#a)return;const s=t.renderForToolbar();if(!s)return;this.#p(s);const i=this.#r=this.#m;e?(this.#i.insertBefore(s,e),this.#i.insertBefore(i,e)):this.#i.append(s,i),this.#a=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;const e=t.renderButton();this.#p(e),this.#i.append(e,this.#m)}async addEditSignatureButton(t){const e=this.#o=await t.renderEditButton(this.#s);this.#p(e),this.#i.append(e,this.#m)}removeButton(t){t==="comment"&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const i=this.#i.querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class Tl{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Ft,{signal:e});const s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#s.hasCommentManager()&&this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")}),this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#n(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#n(e,s),{style:r}=this.#e||=this.#i();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#a(t,e,s,i){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);const a=this.#s._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",Ft,{signal:a}),n.addEventListener("click",i,{signal:a})),this.#t.append(n)}}const kl="f63eb798-ea37-4556-98de-f8303ee5a694",Hi=Object.freeze({internal:kl});function Br(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}class q{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(q.#e||=new Set).add(t)}static setPointer(t,e){q.#t||=e,q.#i??=t}static setTimeStamp(t){q.#s=t}static isSamePointerId(t){return q.#t===t}static isSamePointerIdOrRemove(t){return q.#t===t?!0:(q.#e?.delete(t),!1)}static isSamePointerType(t){return q.#i===t}static isInitializedAndDifferentPointerType(t){return q.#i!==null&&!q.isSamePointerType(t)}static isSameTimeStamp(t){return q.#s===t}static isUsingMultiplePointers(){return q.#e?.size>=1}static clearPointerType(){q.#i=null}static clearPointerIds(){q.#t=NaN,q.#e=null}static clearTimeStamp(){q.#s=NaN}}class Ml{#t=0;get id(){return`${is}${this.#t++}`}}class un{#t=Nr();#e=0;#s=null;static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${vt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return U(this,"_isSVGFittingCanvas",n)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await cn(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=un._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{const h=s.svgUrl=r.result;a.src=await n?`${h}#svgView(preserveAspectRatio(none))`:h},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){z(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#i(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){const s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;const e=this.#s.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){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Pl{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(o);return}if(r&&this.#t[this.#i].type===n){a&&(o.undo=this.#t[this.#i].undo),this.#t[this.#i]=o;return}const l=this.#i+1;l===this.#s?this.#t.splice(0,1):(this.#i=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}}class Pt{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;const{isMac:e}=Z.platform;for(const[s,i,n={}]of t){const r=s.some(a=>a.startsWith("mac+"));for(const a of s){let o=a;if(r){const h=a.startsWith("mac+");if(e!==h)continue;h&&(o=a.slice(4))}const[l,c]=Pt.#t(o);l!==null&&this.callbacks.getOrInsertComputed(l,cs).push({callback:i,options:n,modifiers:c})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const n=i.toUpperCase(),r=Pt[n];if(r){s|=r;continue}if(e!==null){z(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":i}return e===null&&z(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]}static#e(t){const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const c=Pt.#e(e.code);if(c===null||c===e.key||(s=this.callbacks.get(c),!s))return}const i=(e.altKey?Pt.ALT:0)|(e.ctrlKey?Pt.CTRL:0)|(e.metaKey?Pt.META:0)|(e.shiftKey?Pt.SHIFT:0),n=s.find(c=>c.modifiers===i);if(!n)return;const{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=n;l&&!l(t,e)||(r.bind(t,...o,e)(),a||ot(e))}}class fn{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return wl(t),U(this,"_colors",t)}convert(t){const e=us(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return fn._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?P.makeHexColor(...e):t}}class ue{#t=new AbortController;#e=null;#s=null;#i=new Map;#n=new Map;#a=null;#r=null;#o=null;#h=null;#l=new Pl;#u=null;#d=null;#p=null;#m=0;#g=new Set;#c=null;#f=null;#y=new Set;_editorUndoBar=null;#A=!1;#b=!1;#w=!1;#C=null;#v=null;#E=null;#S=null;#T=!1;#M=null;#P=new Ml;#k=!1;#L=!1;#N=!1;#D=null;#R=null;#O=null;#j=null;#V=null;#_=$.NONE;#x=new Set;#F=null;#U=null;#$=null;#K=null;#X=null;#Y={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#B=[0,0];#z=null;#W=null;#Z=null;#tt=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ue.prototype,e=r=>r.#W.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return U(this,"_keyboardManager",new Pt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#W.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#W.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,l,c,h,d,f,p,g,m){const b=this._signal=this.#t.signal;this.#W=t,this.#Z=e,this.#tt=s,this.#r=i,this.#u=n,this.#U=r,this.#X=o,this._eventBus=a;const y={signal:b,...Hi};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),y),window.addEventListener("pointerdown",()=>{this.#L=!0},{capture:!0,signal:b}),window.addEventListener("pointerup",()=>{this.#L=!1},{capture:!0,signal:b}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:b}),this.#ot(),this.#ft(),this.#st(),this.#o=o.annotationStorage,this.#C=o.filterFactory,this.#$=l,this.#S=c||null,this.#A=h,this.#b=d,this.#w=f,this.#V=p||null,this.viewParameters={realScale:Ge.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1,n?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#i.clear(),this.#y.clear(),this.#j?.clear(),this.#e=null,this.#x.clear(),this.#l.destroy(),this.#r?.destroy(),this.#u?.destroy(),this.#U?.destroy(),this.#M?.hide(),this.#M=null,this.#O?.destroy(),this.#O=null,this.#s=null,this.#v&&(clearTimeout(this.#v),this.#v=null),this.#z&&(clearTimeout(this.#z),this.#z=null),this._editorUndoBar?.destroy(),this.#X=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#V}get useNewAltTextFlow(){return this.#b}get useNewAltTextWhenAddingImage(){return this.#w}get hcmFilter(){return U(this,"hcmFilter",this.#$?this.#C.addHCMFilter(this.#$.foreground,this.#$.background):"none")}get direction(){return U(this,"direction",getComputedStyle(this.#W).direction)}get _highlightColors(){return U(this,"_highlightColors",this.#S?new Map(this.#S.split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return U(this,"highlightColors",null);const e=new Map,s=!!this.#$;for(const[i,n]of t){const r=i.endsWith("_HCM");if(s&&r){e.set(i.replace("_HCM",""),n);continue}!s&&!r&&e.set(i,n)}return U(this,"highlightColors",e)}get highlightColorNames(){return U(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const 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.#p=t}setMainHighlightColorPicker(t){this.#O=t}editAltText(t,e=!1){this.#r?.editAltText(this,t,e)}hasCommentManager(){return!!this.#u}editComment(t,e,s,i){this.#u?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#n.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#u?.updateComment(t.getData())}updatePopupColor(t){this.#u?.updatePopupColor(t)}removeComment(t){this.#u?.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#u?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#u?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#u?.dialogElement||null}async waitForEditorsRendered(t){if(this.#n.has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=n=>{n.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,Hi),await s}getSignature(t){this.#U?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#U}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Hi}),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}){t==="enableNewAltTextWhenAddingImage"&&(this.#w=e)}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#n.delete(t),this.#m===t&&(this.#m=0)}focusMainContainer(){this.#W.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#Z.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Ge.PDF_TO_CSS_UNITS;for(const e of this.#y)e.onScaleChanging();this.#p?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#J({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#et(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of this.#n.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a}=s,o=s.toString(),c=this.#J(s).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;s.empty();const d=this.#et(c),f=this.#_===$.NONE,p=()=>{const g=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a,text:o});f&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(f){this.switchToMode($.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#rt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#J(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#M||=new Tl(this),this.#M.show(s,i,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#o)return null;const e=`${is}${t}`,s=this.#o.getRawValue(e);return s&&this.#o.remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&this.#o&&!this.#o.has(t.id)&&this.#o.setValue(t.id,t)}a11yAlert(t,e=null){const s=this.#tt;s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}#at(){const t=document.getSelection();if(!t||t.isCollapsed){this.#F&&(this.#M?.hide(),this.#F=null,this.#I({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#F)return;const i=this.#J(t).closest(".textLayer");if(!i){this.#F&&(this.#M?.hide(),this.#F=null,this.#I({hasSelectedText:!1}));return}if(this.#M?.hide(),this.#F=e,this.#I({hasSelectedText:!0}),!(this.#_!==$.HIGHLIGHT&&this.#_!==$.NONE)&&(this.#_===$.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#T=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this.#_===$.HIGHLIGHT?this.#et(i):null;if(n?.toggleDrawing(),this.#L){const r=new AbortController,a=this.combinedSignal(r),o=l=>{l.type==="pointerup"&&l.button!==0||(r.abort(),n?.toggleDrawing(!0),l.type==="pointerup"&&this.#q("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else n?.toggleDrawing(!0),this.#q("main_toolbar")}}#q(t=""){this.#_===$.HIGHLIGHT?this.highlightSelection(t):this.#A&&this.#rt()}#ot(){document.addEventListener("selectionchange",this.#at.bind(this),{signal:this._signal})}#lt(){if(this.#E)return;this.#E=new AbortController;const t=this.combinedSignal(this.#E);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#E?.abort(),this.#E=null}blur(){if(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#q("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#x)if(e.div.contains(t)){this.#R=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#R)return;const[t,e]=this.#R;this.#R=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#st(){if(this.#D)return;this.#D=new AbortController;const t=this.combinedSignal(this.#D);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#ht(){this.#D?.abort(),this.#D=null}#dt(){if(this.#d)return;this.#d=new AbortController;const t=this.combinedSignal(this.#d);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})}#ut(){this.#d?.abort(),this.#d=null}#ft(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#st(),this.setEditingState(!0)}removeEditListeners(){this.#ht(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#f)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#f)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#x){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#f)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){z(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const l=await i.deserialize(o);if(!l)return;n.push(l)}const r=()=>{for(const o of n)this.#it(o);this.#nt(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){z(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#_!==$.NONE&&!this.isEditorHandlingKeyboard&&ue._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#T&&(this.#T=!1,this.#q("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");break}}updatePageIndex(t,e){for(const i of this.getEditors(t))i.pageIndex=e;const s=this.#a.get(t);s&&(s.pageIndex=e,this.#n.set(e,s),this.#k?s.enable():s.disable())}startUpdatePages(){this.#a=new Map(this.#n),this.#n.clear()}endUpdatePages(){this.#a=null}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==$.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#o.setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,n]of this.#o)n.pageIndex===s&&n.isClone&&(this.#o.remove(i),e.push(t.deserialize(n).then(r=>{r&&(r.isClone=!0,t.addOrRebuild(r))})));return Promise.all(e)}#I(t){Object.entries(t).some(([s,i])=>this.#Y[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#Y,t)}),this.#_===$.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#G([[V.HIGHLIGHT_FREE,!0]]))}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#lt(),this.#dt(),this.#I({isEditing:this.#_!==$.NONE,isEmpty:this.#Q(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ct(),this.#ut(),this.#I({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#f){this.#f=t;for(const e of this.#f)this.#G(e.defaultPropertiesToUpdate)}}getId(){return this.#P.id}get currentLayer(){return this.#n.get(this.#m)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#m}addLayer(t){this.#n.set(t.pageIndex,t),this.#k?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1,r=!1){if(this.#_!==t&&!(this.#H&&(await this.#H.promise,!this.#H))){if(this.#H=Promise.withResolvers(),this.#p?.commitOrRemove(),this.#_===$.POPUP&&this.#u?.hideSidebar(),this.#u?.destroyPopup(),this.#_=t,t===$.NONE){this.setEditingState(!1),this.#gt();for(const a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(const a of this.#i.values())a.addStandaloneCommentButton();t===$.SIGNATURE&&await this.#U?.loadSignatures(),s&&q.clearPointerType(),this.setEditingState(!0),await this.#pt(),this.unselectAll();for(const a of this.#n.values())a.updateMode(t);if(t===$.POPUP){this.#s||=await this.#X.getAnnotationsByType(new Set(this.#f.map(l=>l._editorType)));const a=new Set,o=[];for(const l of this.#i.values()){const{annotationElementId:c,hasComment:h,deleted:d}=l;c&&a.add(c),h&&!d&&o.push(l.getData())}for(const l of this.#s){const{id:c,popupRef:h,contentsObj:d}=l;h&&d?.str&&!a.has(c)&&!this.#g.has(c)&&o.push(l)}this.#u?.showSidebar(o)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#H.resolve();return}for(const a of this.#i.values())a.uid===e?(this.setSelected(a),r?a.editComment():n?a.enterInEditMode():a.focus()):a.unselect();this.#H.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#_&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#f){switch(t){case V.CREATE:this.currentLayer.addNewEditor(e);return;case V.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#K||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of this.#x)s.updateParams(t,e);else for(const s of this.#f)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const n of this.#i.values())n.editorType===t&&n.show(e);(this.#K?.get(V.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#G([[V.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#N!==t){this.#N=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#pt(){if(!this.#k){this.#k=!0;const t=[];for(const e of this.#n.values())t.push(e.enable());await Promise.all(t);for(const e of this.#i.values())e.enable()}}#gt(){if(this.unselectAll(),this.#k){this.#k=!1;for(const t of this.#n.values())t.disable();for(const t of this.#i.values())t.disable()}}*getEditors(t){for(const e of this.#i.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.focusMainContainer(),this.#v=null},0)),this.#i.delete(t.id),t.annotationElementId&&this.#j?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#g.has(t.annotationElementId))&&this.#o?.remove(t.id)}addDeletedAnnotationElement(t){this.#g.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#g.has(t)}removeDeletedAnnotationElement(t){this.#g.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#it(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#G(t.propertiesToUpdate))}get#mt(){let t=null;for(t of this.#x);return t}updateUI(t){this.#mt===t&&this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#x.has(t)){this.#x.delete(t),t.unselect(),this.#I({hasSelectedEditor:this.hasSelection});return}this.#x.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#I({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#p?.commitOrRemove();for(const e of this.#x)e!==t&&e.unselect();this.#u?.destroyPopup(),this.#x.clear(),this.#x.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#I({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#x.values().next().value}unselect(t){t.unselect(),this.#x.delete(t),this.#I({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#x.size!==0}get isEnterHandled(){return this.#x.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#I({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Q()}),this._editorUndoBar?.hide()}redo(){this.#l.redo(),this.#I({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#Q()})}addCommands(t){this.#l.add(t),this.#I({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Q()})}cleanUndoStack(t){this.#l.cleanType(t)}#Q(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(const t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#x],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(const n of e)n.remove()},i=()=>{for(const n of e)this.#it(n)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#nt(t){for(const e of this.#x)e.unselect();this.#x.clear();for(const e of t)e.isEmpty()||(this.#x.add(e),e.select());this.#I({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#x)t.commit();this.#nt(this.#i.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#_!==$.NONE))&&!this.#p?.commitOrRemove()&&(this.#u?.destroyPopup(),!!this.hasSelection)){for(const t of this.#x)t.unselect();this.#x.clear(),this.#I({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#B[0]+=t,this.#B[1]+=e;const[i,n]=this.#B,r=[...this.#x],a=1e3;this.#z&&clearTimeout(this.#z),this.#z=setTimeout(()=>{this.#z=null,this.#B[0]=this.#B[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#i.has(o.id)&&(o.translateInPage(i,n),o.translationDone())},undo:()=>{for(const o of r)this.#i.has(o.id)&&(o.translateInPage(-i,-n),o.translationDone())},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#c=new Map;for(const t of this.#x)this.#c.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#c)return!1;this.disableUserSelect(!1);const t=this.#c;this.#c=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#i.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#c)for(const s of this.#c.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const 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()||this.#x.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#_}isEditingMode(){return this.#_!==$.NONE}get imageManager(){return U(this,"imageManager",new un)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,c,h,d)=>({x:(c-i)/r,y:1-(l+h-s)/n,width:d/r,height:h/n});break;case"180":a=(l,c,h,d)=>({x:1-(l+h-s)/n,y:1-(c+d-i)/r,width:h/n,height:d/r});break;case"270":a=(l,c,h,d)=>({x:1-(c+d-i)/r,y:(l-s)/n,width:d/r,height:h/n});break;default:a=(l,c,h,d)=>({x:(l-s)/n,y:(c-i)/r,width:h/n,height:d/r});break}const o=[];for(let l=0,c=e.rangeCount;l<c;l++){const h=e.getRangeAt(l);if(!h.collapsed)for(const{x:d,y:f,width:p,height:g}of h.getClientRects())p===0||g===0||o.push(a(d,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#h||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#h?.delete(t)}renderAnnotationElement(t){const e=this.#h?.get(t.data.id);if(!e)return;const s=this.#o.getRawValue(e);s&&(this.#_===$.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const i=this.#j?.get(t);i&&(i.setCanvas(e,s),this.#j.delete(t))}addMissingCanvas(t,e){(this.#j||=new Map).set(t,e)}}class Jt{#t=null;#e=!1;#s=null;#i=null;#n=null;#a=null;#r=!1;#o=null;#h=null;#l=null;#u=null;#d=!1;static#p=null;static _l10n=null;constructor(t){this.#h=t,this.#d=t._uiManager.useNewAltTextFlow,Jt.#p||=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){Jt._l10n??=t}async render(){const t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#i=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",Jt.#p.missing),e.setAttribute("data-l10n-id",Jt.#p["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#h._uiManager._signal;t.addEventListener("contextmenu",Ft,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#h._uiManager.editAltText(this.#h),this.#d&&this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#m}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#r=!0,i(n))},{signal:s}),await this.#g(),t}get#m(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#s&&(this.#s.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#t===null&&(this.#l=t,this.#u=await Jt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#g())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#h.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#l===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(this.#l=s,this.#u=i),!(this.#t===t&&this.#e===e)&&(n||(this.#t=t,this.#e=e),this.#g())}toggle(t=!1){this.#s&&(!t&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#s.disabled=!t)}shown(){this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#m}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#n=null,this.#o?.remove(),this.#o=null}async#g(){const t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Jt.#p[this.#m]),this.#i?.setAttribute("data-l10n-id",Jt.#p[`${this.#m}-label`]),!this.#t){this.#n?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#h.id}`;const i=100,n=this.#h._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#n.classList.add("show"),this.#h._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n?.classList.remove("show")},{signal:n})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#h.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class Ns{#t=null;#e=null;#s=!1;#i=null;#n=null;#a=null;#r=null;#o=null;#h=!1;#l=null;constructor(t){this.#i=t}renderForToolbar(){const t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){const t=this.#t=document.createElement("button");t.className="annotationCommentButton";const e=this.#i.commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=this.#i.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;const t=this.#i.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#t)return null;const{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/a]}set commentPopupPositionInLayer(t){this.#l=t}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#i._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.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Ft,{signal:s}),e&&(t.addEventListener("focusin",n=>{this.#i._focusEventsAllowed=!1,ot(n)},{capture:!0,signal:s}),t.addEventListener("focusout",n=>{this.#i._focusEventsAllowed=!0,ot(n)},{capture:!0,signal:s})),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),t===this.#e?this.edit():this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#s=!0,i(n))},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;const{width:c,height:h,x:d,y:f}=this.#i;s=d+s*c,i=f+i*h}const n=this.#i.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#i._uiManager.editComment(this.#i,r+s*o,a+i*l,{...t,parentDimensions:n})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#s}),this.#s=!1)}isDeleted(){return this.#h||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#n}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#r&&(this.#a=null),t===null){this.#r="",this.#h=!0;return}this.#r=t,this.#o=new Date,this.#h=!1}restoreData({text:t,richText:e,date:s}){this.#r=t,this.#a=e,this.#o=s,this.#h=!1}setInitialText(t,e=null){this.#n=t,this.data=t,this.#o=null,this.#a=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#r="",this.#a=null,this.#o=null,this.#i=null,this.#s=!1,this.#h=!1}}class ni{#t;#e=!1;#s=null;#i;#n;#a;#r;#o=null;#h;#l=null;#u;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#t=t,this.#s=s,this.#i=e,this.#n=i,this.#a=n,this.#r=r,this.#u=new AbortController,this.#h=AbortSignal.any([a,this.#u.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#h})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Zt.pixelRatio}#p(t){if(this.#i?.())return;if(t.touches.length===1){if(this.#o)return;const i=this.#o=new AbortController,n=AbortSignal.any([this.#h,i.signal]),r=this.#t,a={capture:!0,signal:n,passive:!1},o=l=>{l.pointerType==="touch"&&(this.#o?.abort(),this.#o=null)};r.addEventListener("pointerdown",l=>{l.pointerType==="touch"&&(ot(l),o(l))},a),r.addEventListener("pointerup",o,a),r.addEventListener("pointercancel",o,a);return}if(!this.#d){this.#d=new AbortController;const i=AbortSignal.any([this.#h,this.#d.signal]),n=this.#t,r={signal:i,capture:!1,passive:!1};n.addEventListener("touchmove",this.#m.bind(this),r);const a=this.#g.bind(this);n.addEventListener("touchend",a,r),n.addEventListener("touchcancel",a,r),r.capture=!0,n.addEventListener("pointerdown",ot,r),n.addEventListener("pointermove",ot,r),n.addEventListener("pointercancel",ot,r),n.addEventListener("pointerup",ot,r),this.#n?.()}if(ot(t),t.touches.length!==2||this.#s?.()){this.#l=null;return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),this.#l={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#m(t){if(!this.#l||t.touches.length!==2)return;ot(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:n}=e,{screenX:r,screenY:a}=s,o=this.#l,{touch0X:l,touch0Y:c,touch1X:h,touch1Y:d}=o,f=h-l,p=d-c,g=r-i,m=a-n,b=Math.hypot(g,m)||1,y=Math.hypot(f,p)||1;if(!this.#e&&Math.abs(y-b)<=ni.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=i,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,!this.#e){this.#e=!0;return}const A=[(i+r)/2,(n+a)/2];this.#a?.(A,y,b)}#g(t){t.touches.length>=2||(this.#d&&(this.#d.abort(),this.#d=null,this.#r?.()),this.#l&&(ot(t),this.#l=null,this.#e=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#o?.abort(),this.#o=null}}class F{#t=null;#e=null;#s=null;#i=null;#n=null;#a=!1;#r=null;#o="";#h=null;#l=null;#u=null;#d=null;#p=null;#m="";#g=!1;#c=null;#f=!1;#y=!1;#A=!1;#b=null;#w=0;#C=0;#v=null;#E=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#S=!1;#T=F._zIndex++;static _borderLineWidth=-1;static _colorManager=new fn;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=F.prototype._resizeWithKeyboard,e=ue.TRANSLATE_SMALL,s=ue.TRANSLATE_BIG;return U(this,"_resizerKeyboardManager",new Pt([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],F.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,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],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}updatePageIndex(t){this.pageIndex=t}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 U(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Il({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(F._l10n??=t,F._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),F._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"}),F._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);F._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Y("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(t){this.#S=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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.#T}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#B(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#g?this.#g=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.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,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#M([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#M(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#M(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:d}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,d)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=F,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=et(n,0,s-a),r=et(r,0,i-o);break;case 90:n=et(n,0,s-o),r=et(r,a,i);break;case 180:n=et(n,a,s),r=et(r,o,i);break;case 270:n=et(n,o,s),r=et(r,0,i-a);break}this.x=n/=s,this.y=r/=i;const[l,c]=this.getBaseTranslation();n+=l,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#P(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return F.#P(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return F.#P(t,e,360-this.parentRotation)}#k(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#L(){if(this.#h)return;this.#h=document.createElement("div"),this.#h.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");this.#h.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#N.bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ft,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#h)}#N(t,e){e.preventDefault();const{isMac:s}=Z.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,this.#l=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#O.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",ot,{passive:!1,signal:r}),window.addEventListener("contextmenu",Ft,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const 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;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#R()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#D(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#R(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:this.#D.bind(this,n,r,a,o),undo:this.#D.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#O(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=F.MIN_SIZE/s,c=F.MIN_SIZE/i,h=this.#k(this.rotation),d=(j,O)=>[h[0]*j+h[2]*O,h[1]*j+h[3]*O],f=this.#k(360-this.rotation),p=(j,O)=>[f[0]*j+f[2]*O,f[1]*j+f[3]*O];let g,m,b=!1,y=!1;switch(t){case"topLeft":b=!0,g=(j,O)=>[0,0],m=(j,O)=>[j,O];break;case"topMiddle":g=(j,O)=>[j/2,0],m=(j,O)=>[j/2,O];break;case"topRight":b=!0,g=(j,O)=>[j,0],m=(j,O)=>[0,O];break;case"middleRight":y=!0,g=(j,O)=>[j,O/2],m=(j,O)=>[0,O/2];break;case"bottomRight":b=!0,g=(j,O)=>[j,O],m=(j,O)=>[0,0];break;case"bottomMiddle":g=(j,O)=>[j/2,O],m=(j,O)=>[j/2,0];break;case"bottomLeft":b=!0,g=(j,O)=>[0,O],m=(j,O)=>[j,0];break;case"middleLeft":y=!0,g=(j,O)=>[0,O/2],m=(j,O)=>[j,O/2];break}const A=g(a,o),w=m(a,o);let x=d(...w);const S=F._round(n+x[0]),E=F._round(r+x[1]);let _=1,k=1,D,R;if(e.fromKeyboard)({deltaX:D,deltaY:R}=e);else{const{screenX:j,screenY:O}=e,[ft,gt]=this.#l;[D,R]=this.screenToPageTranslation(j-ft,O-gt),this.#l[0]=j,this.#l[1]=O}if([D,R]=p(D/s,R/i),b){const j=Math.hypot(a,o);_=k=Math.max(Math.min(Math.hypot(w[0]-A[0]-D,w[1]-A[1]-R)/j,1/a,1/o),l/a,c/o)}else y?_=et(Math.abs(w[0]-A[0]-D),l,1)/a:k=et(Math.abs(w[1]-A[1]-R),c,1)/o;const T=F._round(a*_),H=F._round(o*k);x=d(...m(T,H));const W=S-x[0],X=E-x[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=T,this.height=H,this.x=W,this.y=X,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#y)return this._editToolbar;this._editToolbar=new es(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);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.#s?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#s||(Jt.initialize(F._l10n),this.#s=new Jt(this),this.#t&&(this.#s.data=this.#t,this.#t=null)),this.#s}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new Ns(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#n){this._uiManager.isEditingMode()&&this.#n.classList.remove("hidden");return}this.hasComment&&(this.#n=this.#i.renderForStandalone(),this.div.append(this.#n))}}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#n=null}hideStandaloneCommentButton(){this.#n?.classList.add("hidden")}get comment(){if(!this.#i)return null;const{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#i||=new Ns(this),typeof t=="object"&&t!==null?this.#i.restoreData(t):this.#i.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:s}){if(!e||(this.#i||=new Ns(this),this.#i.setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new Ns(this),this.#i.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const 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.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#U();const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Br(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#E||=new ni({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#j.bind(this),onPinching:this.#V.bind(this),onPinchEnd:this.#_.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#j(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#V(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;const r=this.#k(this.rotation),a=(S,E)=>[r[0]*S+r[2]*E,r[1]*S+r[3]*E],[o,l]=this.parentDimensions,c=this.x,h=this.y,d=this.width,f=this.height,p=F.MIN_SIZE/o,g=F.MIN_SIZE/l;n=Math.max(Math.min(n,1/d,1/f),p/d,g/f);const m=F._round(d*n),b=F._round(f*n);if(m===d&&b===f)return;this.#c||=[c,h,d,f];const y=a(d/2,f/2),A=F._round(c+y[0]),w=F._round(h+y[1]),x=a(m/2,b/2);this.x=A-x[0],this.y=w-x[1],this.width=m,this.height=b,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#_(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#R()}pointerdown(t){const{isMac:e}=Z.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#g=!0,this._isDraggable){this.#F(t);return}this.#x(t)}#x(t){const{isMac:e}=Z.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#F(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=l=>{i.abort(),this.#r=null,this.#g=!1,this._uiManager.endDragSession()||this.#x(l),s&&this._onStopDragging()};e&&(this.#w=t.clientX,this.#C=t.clientY,this.#r=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",l=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:h,pointerId:d}=l;if(d!==this.#r){ot(l);return}const[f,p]=this.screenToPageTranslation(c-this.#w,h-this.#C);this.#w=c,this.#C=h,this._uiManager.dragSelectedEditors(f,p)},r),window.addEventListener("touchmove",ot,r),window.addEventListener("pointerdown",l=>{l.pointerType===this.#o&&(this.#E||l.isPrimary)&&a(l),ot(l)},r));const o=l=>{if(!this.#r||this.#r===l.pointerId){a(l);return}ot(l)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,c=e/i,h=this.x*n,d=this.y*r,f=this.width*n,p=this.height*r;switch(s){case 0:return[h+l+a,r-d-c-p+o,h+l+f+a,r-d-c+o];case 90:return[h+c+a,r-d+l+o,h+c+p+a,r-d+l+f+o];case 180:return[h-l-f+a,r-d+c+o,h-l+a,r-d+c+p+o];case 270:return[h-c-p+a,r-d-l-f+o,h-c+a,r-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&F._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:s||c,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#y=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#y=!1,!0):!1}isInEditMode(){return this.#y}shouldGetKeyboardEvents(){return this.#A}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#U(){if(this.#p||!this.div)return;this.#p=new AbortController;const t=this._uiManager.combinedSignal(this.#p);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#U()}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,s){const i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;const[n,r]=i.pageDimensions,[a,o,l,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=l/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#p?.abort(),this.#p=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#B(),this.removeEditToolbar(),this.#v){for(const t of this.#v.values())clearTimeout(t);this.#v=null}this.parent=null,this.#E?.destroy(),this.#E=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#L(),this.#h.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,n,r]=this.getPDFRect();return[F._round(s+(n-s)*t),F._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#h.children;if(!this.#e){this.#e=Array.from(e);const r=this.#$.bind(this),a=this.#K.bind(this),o=this._uiManager._signal;for(const l of this.#e){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#X.bind(this,c),{signal:o}),l.setAttribute("data-l10n-id",F._l10nResizer[c])}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#h.append(this.#h.firstElementChild);else if(n>i)for(let a=0;a<n-i;a++)this.#h.firstElementChild.before(this.#h.lastElementChild);let r=0;for(const a of e){const l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",F._l10nResizer[l])}}this.#Y(0),this.#A=!0,this.#h.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#$(t){F._resizerKeyboardManager.exec(this,t)}#K(t){this.#A&&t.relatedTarget?.parentNode!==this.#h&&this.#B()}#X(t){this.#m=this.#A?t:""}#Y(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#A&&this.#O(this.#m,{deltaX:t,deltaY:e,fromKeyboard:!0})}#B(){this.#A=!1,this.#Y(-1),this.#R()}_stopResizingWithKeyboard(){this.#B(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#h?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#s?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#f}set isEditing(t){this.#f=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.#v||=new Map;const{action:s}=t;let i=this.#v.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#v.delete(s),this.#v.size===0&&(this.#v=null)},F._telemetryTimeout),this.#v.set(s,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.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class Il extends F{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const rr=3285377520,Lt=4294901760,Kt=65535;class Zi{constructor(t){this.h1=t?t&4294967295:rr,this.h2=t?t&4294967295:rr}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,m=t.length;g<m;g++){const b=t.charCodeAt(g);b<=255?e[s++]=b:(e[s++]=b>>>8,e[s++]=b&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,l=this.h1,c=this.h2;const h=3432918353,d=461845907,f=h&Kt,p=d&Kt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*h&Lt|a*f&Kt,a=a<<15|a>>>17,a=a*d&Lt|a*p&Kt,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=r[g],o=o*h&Lt|o*f&Kt,o=o<<15|o>>>17,o=o*d&Lt|o*p&Kt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*h&Lt|a*f&Kt,a=a<<15|a>>>17,a=a*d&Lt|a*p&Kt,i&1?l^=a:c^=a}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Lt|t*36045&Kt,e=e*4283543511&Lt|((e<<16|t>>>16)*2950163797&Lt)>>>16,t^=e>>>1,t=t*444984403&Lt|t*60499&Kt,e=e*3301882366&Lt|((e<<16|t>>>16)*3120437893&Lt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const rs=Object.freeze({map:null,hash:"",transfer:void 0});class pn{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const s=this.#i.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){const e=this.#i.get(t);e!==void 0&&(e instanceof F&&this.#s.delete(e.annotationElementId),this.#i.delete(t),this.#i.size===0&&this.resetModified(),!this.#i.values().some(s=>s instanceof F)&&this.onAnnotationEditor?.(null))}setValue(t,e){const s=this.#i.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#i.set(t,e);i&&this.#n(),e instanceof F&&((this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#i.has(t)}get size(){return this.#i.size}#n(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new jr(this)}get serializable(){if(this.#i.size===0)return rs;const t=new Map,e=new Zi,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#i){const o=a instanceof F?a.serialize(!1,i):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:rs}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const n of this.#i.values()){if(!(n instanceof F)){n.popup&&(n.popup.deleted?i+=1:s+=1);continue}n.isCommentDeleted?i+=1:n.hasEditedComment&&(s+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(n).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[l,c]of Object.entries(r)){if(l==="type")continue;const h=o.getOrInsertComputed(l,ln);h.set(c,(h.get(c)??0)+1)}}if((i>0||s>0)&&(t||=Object.create(null),t.comments={deleted:i,edited:s}),!t)return null;for(const[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){const s=this.#s?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;const t=[];if(this.#s)for(const s of this.#s.values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Zi;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}}class jr extends pn{#t=rs;constructor(t){super();const{serializable:e}=t;if(e===rs)return;const{map:s,hash:i,transfer:n}=e,r=structuredClone(s,n?{transfer:n}:null);this.#t={map:r,hash:i,transfer:[]}}get print(){Y("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return U(this,"modifiedIds",{ids:new Set,hash:""})}}const De="__forcedDependency",{floor:ar,ceil:or}=Math;function lr(u,t,e,s,i,n){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],i),u[t*4+3]=Math.max(u[t*4+3],n)}function Dl(u,t,e,s,i){let n;u?(u<0&&(n=i[0],i[0]=i[2],i[2]=n),i[0]*=u,i[2]*=u,t<0&&(n=i[1],i[1]=i[3],i[3]=n),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const tn=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Ll{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===tn}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}const cr=(u,t)=>u?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class Nl{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(ne);_pendingBBoxIdx=-1;#i;#n;#a;#r;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#n=t.height,this.#o(e)}growOperationsCount(t){t>=this.#r.length&&this.#o(t,this.#r)}#o(t,e){const s=new ArrayBuffer(t*4);this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),e&&e.length>0?(this.#r.set(e),this.#r.fill(tn,e.length)):this.#r.fill(tn)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;const i=this._savesStack.pop();return i!==void 0&&(e?.(i,t),this.#r[t]=this.#r[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}pushBaseTransform(t){return this.#t.push(P.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#s.set(ne,0)),this}recordClipBox(t,e,s,i,n,r){const a=P.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=ne.slice();P.axialAlignedBoundingBox([s,n,i,r],a,o);const l=P.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,s,i,n,r){const a=this.#e;if(a[0]===1/0)return this;const o=P.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return P.axialAlignedBoundingBox([s,n,i,r],o,this.#s),this;const l=ne.slice();return P.axialAlignedBoundingBox([s,n,i,r],o,l),this.#s[0]=et(l[0],a[0],this.#s[0]),this.#s[1]=et(l[1],a[1],this.#s[1]),this.#s[2]=et(l[2],this.#s[2],a[2]),this.#s[3]=et(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#n,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=ar(this.#s[0]*256/this.#i),n=ar(this.#s[1]*256/this.#n),r=or(this.#s[2]*256/this.#i),a=or(this.#s[3]*256/this.#n);if(lr(this.#a,t,i,n,r,a),s)for(const o of s)for(const l of o)l!==t&&lr(this.#a,l,i,n,r,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3])),this}take(){return new Ll(this.#r,this.#a)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Rl{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[De]:[]};#s=new Map;#i=new Set;#n=new Map;#a;#r;#o;constructor(t,e=!1){this.#o=t,e&&(this.#a=new Map,this.#r=(s,i)=>{cr(this.#a,i).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[De]:{__proto__:this.#e[De]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#r);const e=Object.getPrototypeOf(this.#t);return e===null?this:(this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this)}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#r),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#r),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(De,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#i)this.recordFutureForcedDependency(De,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,n,r){return this.#o.recordClipBox(t,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#o.recordBBox(t,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){const o=s.bbox;let l,c;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#n.get(s),l!==!1&&(c=[0,0,0,0],P.axialAlignedBoundingBox(o,s.fontMatrix,c),(i!==1||n!==0||r!==0)&&Dl(i,-i,n,r,c),l)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);const h=a();return o&&c&&l===void 0&&(l=c[0]<=n-h.actualBoundingBoxLeft&&c[2]>=n+h.actualBoundingBoxRight&&c[1]<=r-h.actualBoundingBoxAscent&&c[3]>=r+h.actualBoundingBoxDescent,this.#n.set(s,l),l)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,n-h.actualBoundingBoxLeft,n+h.actualBoundingBoxRight,r-h.actualBoundingBoxAscent,r+h.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){const s=this.#i,i=this.#t,n=this.#e;for(const r of e)r in this.#t?s.add(i[r]):r in n&&n[r].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#s.has(e)&&this.#i.add(this.#s.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[De]),this.#a){const i=cr(this.#a,t),{dependencies:n}=i;this.#i.forEach(n.add,n),this.#o._savesStack.forEach(n.add,n),this.#o._markedContentStack.forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#i.clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(this.#i);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),s&&this.#i.clear(),this}take(){return this.#n.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class as{#t;#e;#s;#i=0;#n=0;constructor(t,e,s){if(t instanceof as&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#n++,this.#t.save(this.#e),this}restore(t){return this.#n>0&&(this.#t.restore(this.#e),this.#n--),this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#s||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,i,n,r){return this.#s||this.#t.recordClipBox(this.#e,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#s||this.#t.recordBBox(this.#e,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i,n,r,a){return this.#s||this.#t.recordCharacterBBox(this.#e,e,s,i,n,r,a),this}recordFullPageBBox(t){return this.#s||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#s||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Nt={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class Ks{#t;#e;#s=4;#i=0;#n=new Ks.#a(this.#s*6);static#a=Z.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;const a=new Ks.#a(this.#s*6);a.set(this.#n),this.#n=a}const n=tt(t);let r;if(i[0]!==1/0){const a=ne.slice();P.axialAlignedBoundingBox([0,-s,e,0],n,a);const o=P.intersect(i,a);if(!o)return;const[l,c,h,d]=o;if(l!==a[0]||c!==a[1]||h!==a[2]||d!==a[3]){const f=Math.atan2(n[1],n[0]),p=Math.abs(Math.sin(f)),g=Math.abs(Math.cos(f));if(p<1e-6||g<1e-6||Math.abs(p-g)<1e-6)r=[l,c,l,d,h,c];else{const m=h-l,b=d-c,y=p*p,A=g*g,w=g*p,x=A-y,S=(b*A-m*w)/x,E=(b*w-m*y)/x;r=[l+E,c,l,c+S,h,d-S]}}}r||(r=[0,-s,0,0,e,-s],P.applyTransform(r,n,0),P.applyTransform(r,n,2),P.applyTransform(r,n,4)),r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#n.set(r,this.#i*6),this.#i++}take(){return this.#n.subarray(0,this.#i*6)}}class Fl{#t=new Set;#e=null;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){const e=this.#s();e.insertRule(t,e.cssRules.length)}#s(){if(this.#e)return this.#e;const t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:e}=this._document;if(e){const s=new t;return e.push(s),this.#e=s}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#e=this.styleElement.sheet}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#t.clear(),this.#e){const{adoptedStyleSheets:t}=this._document;t?.includes(this.#e)&&(this._document.adoptedStyleSheets=t.filter(e=>e!==this.#e)),this.#e=null}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#t.has(t.loadedName))){if(lt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:n,style:r}=t,a=new FontFace(i,n,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(i),s?.(t)}catch{z(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}Y("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw z(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return U(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return U(this,"isSyncFontLoadingSupported",Mt||Z.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(lt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return U(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(x,S){return x.charCodeAt(S)<<24|x.charCodeAt(S+1)<<16|x.charCodeAt(S+2)<<8|x.charCodeAt(S+3)&255}function i(x){return String.fromCharCode(x>>24&255,x>>16&255,x>>8&255,x&255)}function n(x,S,E,_){const k=x.substring(0,S),D=x.substring(S+E);return k+_+D}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function h(x,S){if(++c>30){z("Load test font never loaded."),S();return}if(l.font="30px "+x,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){S();return}setTimeout(h.bind(null,x,S))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=n(f,976,d.length,d);const g=16,m=1482184792;let b=s(f,g);for(r=0,a=d.length-3;r<a;r+=4)b=b-m+s(d,r)|0;r<d.length&&(b=b-m+s(d+"XXX",r)|0),f=n(f,g,4,i(b));const y=`url(data:font/opentype;base64,${btoa(f)});`,A=`@font-face {font-family:"${d}";src:${y}}`;this.insertRule(A);const w=this._document.createElement("div");w.style.visibility="hidden",w.style.width=w.style.height="10px",w.style.position="absolute",w.style.top=w.style.left="0px";for(const x of[t.loadedName,d]){const S=this._document.createElement("span");S.textContent="Hi",S.style.fontFamily=x,w.append(S)}this._document.body.append(w),h(d,()=>{w.remove(),e.complete()})}}class Ol{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,s,i){this.#t=t,this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(r){z(`getPathGenerator - ignoring character: "${r}".`)}const n=Or(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){U(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}class Bl{static strings=["fontFamily","fontWeight","italicAngle"]}class jl{static strings=["css","loadedName","baseFontName","src"]}class Ut{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class be{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class Hl{#t;#e=new TextDecoder;#s;constructor(t){this.#t=t,this.#s=new DataView(t)}#i(t){lt(t<Bl.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#s.getUint32(e)+4;const s=this.#s.getUint32(e);return this.#e.decode(new Uint8Array(this.#t,e+4,s))}get fontFamily(){return this.#i(0)}get fontWeight(){return this.#i(1)}get italicAngle(){return this.#i(2)}}class Ul{#t;#e=new TextDecoder;#s;constructor(t){this.#t=t,this.#s=new DataView(t)}get guessFallback(){return this.#s.getUint8(0)!==0}#i(t){lt(t<jl.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#s.getUint32(e)+4;const s=this.#s.getUint32(e);return this.#e.decode(new Uint8Array(this.#t,e+4,s))}get css(){return this.#i(0)}get loadedName(){return this.#i(1)}get baseFontName(){return this.#i(2)}get src(){return this.#i(3)}get style(){let t=1;t+=4+this.#s.getUint32(t);const e=this.#s.getUint32(t),s=this.#e.decode(new Uint8Array(this.#t,t+4,e));t+=4+e;const i=this.#s.getUint32(t),n=this.#e.decode(new Uint8Array(this.#t,t+4,i));return{style:s,weight:n}}}class Gl{#t;#e=new TextDecoder;#s;constructor({buffer:t,extra:e}){this.#t=t,this.#s=new DataView(t),e&&Object.assign(this,e)}#i(t){lt(t<Ut.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=this.#s.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return this.#i(0)}get bold(){return this.#i(1)}get disableFontFace(){return this.#i(2)}get fontExtraProperties(){return this.#i(3)}get isInvalidPDFjsFont(){return this.#i(4)}get isType3Font(){return this.#i(5)}get italic(){return this.#i(6)}get missingFile(){return this.#i(7)}get remeasure(){return this.#i(8)}get vertical(){return this.#i(9)}#n(t){return lt(t<Ut.numbers.length,"Invalid number index"),this.#s.getFloat64(Ut.OFFSET_NUMBERS+t*8)}get ascent(){return this.#n(0)}get defaultWidth(){return this.#n(1)}get descent(){return this.#n(2)}#a(t,e,s,i){const n=this.#s.getUint8(t);if(n===0)return;lt(n===e,"Invalid array length."),t+=1;const r=new Array(n);for(let a=0;a<n;a++)r[a]=this.#s[s](t,!0),t+=i;return r}get bbox(){return this.#a(Ut.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#a(Ut.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#a(Ut.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#r(t){lt(t<Ut.strings.length,"Invalid string index");let e=Ut.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=this.#s.getUint32(e)+4;const s=this.#s.getUint32(e);return this.#e.decode(new Uint8Array(this.#t,e+4,s))}get fallbackName(){return this.#r(0)}get loadedName(){return this.#r(1)}get mimetype(){return this.#r(2)}get name(){return this.#r(3)}#o(){let t=Ut.OFFSET_STRINGS;const e=this.#s.getUint32(t);t+=4+e;const s=this.#s.getUint32(t);t+=4+s;const i=this.#s.getUint32(t);t+=4+i;const n=this.#s.getUint32(t);return{offset:t,length:n}}get data(){const{offset:t,length:e}=this.#o();return e===0?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){const{offset:t,length:e}=this.#o();e!==0&&(this.#s.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#s=new DataView(this.#t))}get cssFontInfo(){let t=Ut.OFFSET_STRINGS;const e=this.#s.getUint32(t);t+=4+e;const s=this.#s.getUint32(t);t+=4+s;const i=this.#s.getUint32(t);if(i===0)return null;const n=new Uint8Array(i);return n.set(new Uint8Array(this.#t,t+4,i)),new Hl(n.buffer)}get systemFontInfo(){let t=Ut.OFFSET_STRINGS;const e=this.#s.getUint32(t);t+=4+e;const s=this.#s.getUint32(t);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(this.#t,t+4,s)),new Ul(i.buffer)}}class $l{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[be.KIND],s=!!this.data[be.HAS_BBOX],i=!!this.data[be.HAS_BACKGROUND],n=t.getUint32(be.N_COORD,!0),r=t.getUint32(be.N_COLOR,!0),a=t.getUint32(be.N_STOP,!0);let o=20;const l=new Float32Array(this.buffer,o,n*2);o+=n*8;const c=new Uint8Array(this.buffer,o,r*4);o+=r*4;const h=[];for(let p=0;p<a;++p){const g=t.getFloat32(o,!0);o+=4;const m=t.getUint32(o,!0);o+=4,h.push([g,`#${m.toString(16).padStart(6,"0")}`])}let d=null;if(s){d=[];for(let p=0;p<4;++p)d.push(t.getFloat32(o,!0)),o+=4}let f=null;if(i&&(f=new Uint8Array(this.buffer,o,3),o+=3),e===1)return["RadialAxial","axial",d,h,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",d,h,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){const p=this.data[be.SHADING_TYPE];let g=null;if(l.length>0){g=ne.slice();for(let m=0,b=l.length;m<b;m+=2)P.pointBoundingBox(l[m],l[m+1],g)}return["Mesh",p,l,c,n,g,d,f]}throw new Error(`Unsupported pattern kind: ${e}`)}}class zl{#t;constructor(t){this.#t=t}get path(){return Z.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}}function Vl(u){if(u instanceof URL)return u;if(typeof u=="string"){if(Mt){if(/^[a-z][a-z0-9\-+.]+:/i.test(u))return new URL(u);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(u))}const t=URL.parse(u,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Wl(u){if(Mt&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return si(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u?.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Rs(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const en=u=>typeof u=="object"&&Number.isInteger(u?.num)&&u.num>=0&&Number.isInteger(u?.gen)&&u.gen>=0,Xl=u=>typeof u=="object"&&typeof u?.name=="string",Yl=ml.bind(null,en,Xl);class Kl{#t=new Map;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:n}=s;if(n.aborted){z("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}const Fs={DATA:1,ERROR:2},dt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function hr(){}function St(u){if(u instanceof de||u instanceof Yi||u instanceof Xi||u instanceof Ys||u instanceof Bi)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||Y('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new de(u.message);case"InvalidPDFException":return new Yi(u.message);case"PasswordException":return new Xi(u.message,u.code);case"ResponseException":return new Ys(u.message,u.status,u.missing);case"UnknownErrorException":return new Bi(u.message,u.details)}return new Bi(u.message,u.toString())}class Je{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Fs.DATA)i.resolve(t.data);else if(t.callback===Fs.ERROR)i.reject(St(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:Fs.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:Fs.ERROR,callbackId:t.callbackId,reason:St(r)})});return}if(t.streamId){this.#s(t);return}e(t.data)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:l=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},i),c.promise},pull:l=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:dt.PULL,streamId:n,desiredSize:l.desiredSize}),c.promise},cancel:l=>{lt(l instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:dt.CANCEL,streamId:n,reason:St(l)}),c.promise}},s)}#s(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,c=1,h){if(this.isCancelled)return;const d=this.desiredSize;this.desiredSize-=c,d>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:dt.ENQUEUE,streamId:e,chunk:l},h)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:dt.CLOSE,streamId:e}),delete r.streamSinks[e])},error(l){lt(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:dt.ERROR,streamId:e,reason:St(l)}))},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:s,targetName:i,stream:dt.START_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:dt.START_COMPLETE,streamId:e,reason:St(l)})})}#i(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case dt.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(St(t.reason));break;case dt.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(St(t.reason));break;case dt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:dt.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||hr).then(function(){n.postMessage({sourceName:s,targetName:i,stream:dt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:dt.PULL_COMPLETE,streamId:e,reason:St(l)})});break;case dt.ENQUEUE:if(lt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case dt.CLOSE:if(lt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#n(r,e);break;case dt.ERROR:lt(r,"error should have stream controller"),r.controller.error(St(t.reason)),this.#n(r,e);break;case dt.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(St(t.reason)),this.#n(r,e);break;case dt.CANCEL:if(!a)break;const o=St(t.reason);Promise.try(a.onCancel||hr,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:dt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:dt.CANCEL_COMPLETE,streamId:e,reason:St(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#n(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class Hr{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:Y(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(n=>{throw new Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){Y("Abstract method `_fetch` called.")}}class dr extends Hr{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await cn(t,s);return i instanceof Uint8Array?i:si(i)}}class Ur{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Y("Abstract method `_createCanvas` called.")}}class ql extends Ur{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Gr{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class Ql extends Gr{#t;#e;#s;#i;#n;#a;#r=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i=t,this.#n=e}get#o(){return this.#e||=new Map}get#h(){return this.#a||=new Map}get#l(){if(!this.#s){const t=this.#n.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#n.createElementNS(vt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#n.createElementNS(vt,"defs"),t.append(s),s.append(this.#s),this.#n.body.append(t)}return this.#s}#u(t){if(t.length===1){const o=t[0],l=new Array(256);for(let h=0;h<256;h++)l[h]=o[h]/255;const c=l.join(",");return[c,c,c]}const[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";const e=this.#n.URL;e!==this.#n.baseURI&&(ii(e)?z('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=Lr(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;const[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;const a=`g_${this.#i}_transfer_map_${this.#r++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);const l=this.#g(a);return this.#f(s,i,n,l),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#h.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#h.set(i,n)),!t||!e))return n.url;const r=this.#A(t);t=P.makeHexColor(...r);const a=this.#A(e);if(e=P.makeHexColor(...a),this.#w(),t==="#000000"&&e==="#ffffff"||t===e)return n.url;const o=new Array(256);for(let f=0;f<=255;f++){const p=f/255;o[f]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}const l=o.join(","),c=`g_${this.#i}_hcm_filter`,h=n.filter=this.#g(c);this.#f(l,l,l,h),this.#m(h);const d=(f,p)=>{const g=r[f]/255,m=a[f]/255,b=new Array(p+1);for(let y=0;y<=p;y++)b[y]=g+y/p*(m-g);return b.join(",")};return this.#f(d(0,5),d(1,5),d(2,5),h),n.url=this.#d(c),n.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return e==="none"||!Z.platform.isFirefox?null:{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;const[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;const n=`g_${this.#i}_alpha_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);const a=this.#g(n);return this.#y(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;const n=`g_${this.#i}_luminosity_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);const a=this.#g(n);return this.#p(a),t&&this.#y(s,a),r}addKnockoutFilter(t=0){const e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;const n=`g_${this.#i}_knockout_filter_${this.#r++}`,r=this.#d(n);this.#o.set(s,r);const a=this.#g(n),o=this.#n.createElementNS(vt,"feComponentTransfer");a.append(o);const l=this.#n.createElementNS(vt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let a=this.#h.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.#h.set(t,a)),!e||!s))return a.url;const[o,l]=[e,s].map(this.#A.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,f]=[i,n].map(this.#C.bind(this));h<c&&([c,h,d,f]=[h,c,f,d]),this.#w();const p=(b,y,A)=>{const w=new Array(256),x=(h-c)/A,S=b/255,E=(y-b)/(255*A);let _=0;for(let k=0;k<=A;k++){const D=Math.round(c+k*x),R=S+k*E;for(let T=_;T<=D;T++)w[T]=R;_=D+1}for(let k=_;k<256;k++)w[k]=w[_-1];return w.join(",")},g=`g_${this.#i}_hcm_${t}_filter`,m=a.filter=this.#g(g);return this.#m(m),this.#f(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),m),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#a?.size||(this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#a?.clear(),this.#a=null,this.#r=0)}#p(t){const e=this.#n.createElementNS(vt,"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)}#m(t){const e=this.#n.createElementNS(vt,"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)}#g(t){const e=this.#n.createElementNS(vt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#l.append(e),e}#c(t,e,s){const i=this.#n.createElementNS(vt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#f(t,e,s,i){const n=this.#n.createElementNS(vt,"feComponentTransfer");i.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",s)}#y(t,e){const s=this.#n.createElementNS(vt,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#A(t){return this.#l.style.color="CanvasText",this.#l.style.backgroundColor=t,us(getComputedStyle(this.#l).getPropertyValue("background-color"))}#b(t){return this.#l.style.color="CanvasText",this.#l.style.backgroundColor=t,ds(getComputedStyle(this.#l).getPropertyValue("background-color"))}#w(){this.#l.style.color="",this.#l.style.backgroundColor=""}#C(t){const[e,s,i,n]=this.#b(t);if(n===1)return[e,s,i];const[r,a,o]=this.#A("Canvas");return[Ui(e,r,n),Ui(s,a,n),Ui(i,o,n)]}}function Ui(u,t,e){return Math.round(e*u+(1-e)*t)}Mt&&z("Please use the `legacy` build in Node.js environments.");async function Jl(u){const e=await process.getBuiltinModule("fs/promises").readFile(u);return new Uint8Array(e)}class Zl extends Gr{}class tc extends Ur{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class ec extends Hr{async _fetch(t,e){return Jl(t)}}function $r({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=Z.isLittleEndian?4278190080:255,[o,l]=r?[n,a]:[a,n],c=s>>3,h=s&7,d=o^l,f=u.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;++g){for(const b=t+c;t<b;++t,p+=8){const y=u[t];e[p]=o^-(y>>7&1)&d,e[p+1]=o^-(y>>6&1)&d,e[p+2]=o^-(y>>5&1)&d,e[p+3]=o^-(y>>4&1)&d,e[p+4]=o^-(y>>3&1)&d,e[p+5]=o^-(y>>2&1)&d,e[p+6]=o^-(y>>1&1)&d,e[p+7]=o^-(y&1)&d}if(h===0)continue;const m=t<f?u[t++]:255;for(let b=0;b<h;++b,++p)e[p]=o^-(m>>7-b&1)&d}return{srcPos:t,destPos:p}}function sc({src:u,srcPos:t=0,dest:e,destPos:s=0,width:i,height:n}){let r=0;const a=i*n*3,o=a>>2,l=new Uint32Array(u.buffer,t,o),c=Z.isLittleEndian?4278190080:255;if(Z.isLittleEndian){for(;r<o-2;r+=3,s+=4){const h=l[r],d=l[r+1],f=l[r+2];e[s]=h|c,e[s+1]=h>>>24|d<<8|c,e[s+2]=d>>>16|f<<16|c,e[s+3]=f>>>8|c}for(let h=r*4,d=t+a;h<d;h+=3)e[s++]=u[h]|u[h+1]<<8|u[h+2]<<16|c}else{for(;r<o-2;r+=3,s+=4){const h=l[r],d=l[r+1],f=l[r+2];e[s]=h|c,e[s+1]=h<<24|d>>>8|c,e[s+2]=d<<16|f>>>16|c,e[s+3]=f<<8|c}for(let h=r*4,d=t+a;h<d;h+=3)e[s++]=u[h]<<24|u[h+1]<<16|u[h+2]<<8|c}return{srcPos:t+a,destPos:s}}const ic=`
|
|
3
3
|
struct Uniforms {
|
|
4
4
|
offsetX : f32,
|