archiver-ts 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +961 -955
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import vt from "node:fs";
3
- import p, { join as J } from "node:path";
4
- import y from "node:fs/promises";
5
- import { parse as Ht, printParseErrorCode as qt, modify as Yt, applyEdits as Bt } from "jsonc-parser";
6
- import ht, { homedir as Ut } from "node:os";
7
- import { Command as zt } from "commander";
2
+ import ft from "node:fs";
3
+ import p, { join as G } from "node:path";
4
+ import I from "node:fs/promises";
5
+ import { parse as qt, printParseErrorCode as Bt, modify as Ut, applyEdits as zt } from "jsonc-parser";
6
+ import gt, { homedir as Wt } from "node:os";
7
+ import { Command as Jt } from "commander";
8
8
  import v from "chalk";
9
- import Ie from "node:readline";
10
- import Wt from "node:readline/promises";
11
- import { stdout as Jt, stdin as Gt } from "node:process";
12
- import { execFile as Kt } from "node:child_process";
13
- import { promisify as Xt } from "node:util";
14
- function Zt(e) {
9
+ import be from "node:readline";
10
+ import Gt from "node:readline/promises";
11
+ import { stdout as Kt, stdin as Xt } from "node:process";
12
+ import { execFile as Zt } from "node:child_process";
13
+ import { promisify as Qt } from "node:util";
14
+ function ea(e) {
15
15
  const t = p.join(import.meta.dirname, e);
16
- return vt.existsSync(t) ? t : p.resolve(import.meta.dirname, "..", "..", "public", e);
16
+ return ft.existsSync(t) ? t : p.resolve(import.meta.dirname, "..", "..", "public", e);
17
17
  }
18
- function ft(e) {
19
- return vt.readFileSync(Zt(e), "utf8");
18
+ function pt(e) {
19
+ return ft.readFileSync(ea(e), "utf8");
20
20
  }
21
- const $e = ft("config.default.jsonc"), Te = ft("auto-incr.default.jsonc"), Qt = {
21
+ const De = pt("config.default.jsonc"), Ne = pt("auto-incr.default.jsonc"), ta = {
22
22
  "app.description": "Archive files and folders into ~/.archiver with audit logs",
23
23
  "defaults.vault.remark": "Default vault",
24
24
  "common.action.list": "list",
@@ -328,7 +328,7 @@ const $e = ft("config.default.jsonc"), Te = ft("auto-incr.default.jsonc"), Qt =
328
328
  "terminal.status.log.warn": "WARN",
329
329
  "terminal.status.log.error": "ERROR",
330
330
  "terminal.status.log.fatal": "FATAL"
331
- }, ea = {
331
+ }, aa = {
332
332
  "app.description": "将文件和文件夹归档到 ~/.archiver,并记录审计日志",
333
333
  "defaults.vault.remark": "默认 vault",
334
334
  "common.action.list": "list",
@@ -638,18 +638,18 @@ const $e = ft("config.default.jsonc"), Te = ft("auto-incr.default.jsonc"), Qt =
638
638
  "terminal.status.log.warn": "警告",
639
639
  "terminal.status.log.error": "错误",
640
640
  "terminal.status.log.fatal": "致命"
641
- }, Ue = {
642
- zh: ea,
643
- en: Qt
641
+ }, We = {
642
+ zh: aa,
643
+ en: ta
644
644
  };
645
- let De = "zh";
646
- function ta(e) {
645
+ let Me = "zh";
646
+ function ra(e) {
647
647
  return e === "en" ? "en" : "zh";
648
648
  }
649
- function fe(e) {
650
- return De = ta(e), De;
649
+ function ge(e) {
650
+ return Me = ra(e), Me;
651
651
  }
652
- function aa(e, t) {
652
+ function ia(e, t) {
653
653
  return t ? e.replace(/\{([a-zA-Z0-9_]+)\}/g, (a, r) => {
654
654
  if (!(r in t))
655
655
  return `{${r}}`;
@@ -658,17 +658,17 @@ function aa(e, t) {
658
658
  }) : e;
659
659
  }
660
660
  function n(e, t) {
661
- const a = Ue[De][e] ?? Ue.zh[e] ?? e;
662
- return aa(a, t);
661
+ const a = We[Me][e] ?? We.zh[e] ?? e;
662
+ return ia(a, t);
663
663
  }
664
- function pt(e) {
664
+ function _t(e) {
665
665
  return e.endsWith(`
666
666
  `) ? e : `${e}
667
667
  `;
668
668
  }
669
- async function Fe(e) {
669
+ async function je(e) {
670
670
  try {
671
- return await y.readFile(e, "utf8");
671
+ return await I.readFile(e, "utf8");
672
672
  } catch (t) {
673
673
  if (t.code === "ENOENT")
674
674
  return;
@@ -676,9 +676,9 @@ async function Fe(e) {
676
676
  }
677
677
  }
678
678
  function pe(e, t) {
679
- const a = [], r = Ht(e, a, { allowTrailingComma: !0 });
679
+ const a = [], r = qt(e, a, { allowTrailingComma: !0 });
680
680
  if (a.length > 0) {
681
- const i = a.map((o) => `${qt(o.error)}@${o.offset}`).join(", ");
681
+ const i = a.map((o) => `${Bt(o.error)}@${o.offset}`).join(", ");
682
682
  throw new Error(
683
683
  n("util.jsonc.error.parse_file", {
684
684
  filePath: t,
@@ -688,10 +688,10 @@ function pe(e, t) {
688
688
  }
689
689
  return r;
690
690
  }
691
- function ra(e, t) {
691
+ function na(e, t) {
692
692
  let a = e;
693
693
  for (const [r, i] of Object.entries(t)) {
694
- const o = Yt(a, [r], i, {
694
+ const o = Ut(a, [r], i, {
695
695
  isArrayInsertion: !1,
696
696
  formattingOptions: {
697
697
  insertSpaces: !0,
@@ -700,60 +700,60 @@ function ra(e, t) {
700
700
  `
701
701
  }
702
702
  });
703
- a = Bt(a, o);
703
+ a = zt(a, o);
704
704
  }
705
- return pt(a);
705
+ return _t(a);
706
706
  }
707
- async function Ne(e, t) {
708
- const a = await Fe(e);
707
+ async function Pe(e, t) {
708
+ const a = await je(e);
709
709
  return !a || !a.trim() ? t : pe(a, e);
710
710
  }
711
- async function ze(e, t) {
712
- await Fe(e) === void 0 && await y.writeFile(e, pt(t), "utf8");
711
+ async function Je(e, t) {
712
+ await je(e) === void 0 && await I.writeFile(e, _t(t), "utf8");
713
713
  }
714
- async function We(e, t, a) {
715
- const r = await Fe(e), i = r && r.trim().length > 0 ? r : a;
714
+ async function Ge(e, t, a) {
715
+ const r = await je(e), i = r && r.trim().length > 0 ? r : a;
716
716
  pe(i, e);
717
- const o = ra(i, t);
718
- await y.writeFile(e, o, "utf8");
717
+ const o = na(i, t);
718
+ await I.writeFile(e, o, "utf8");
719
719
  }
720
- var N = /* @__PURE__ */ ((e) => (e.Valid = "Valid", e.Removed = "Removed", e.Protected = "Protected", e))(N || {}), R = /* @__PURE__ */ ((e) => (e.Archived = "Archived", e.Restored = "Restored", e))(R || {}), k = /* @__PURE__ */ ((e) => (e.Info = "Info", e.Warn = "Warn", e.Error = "Error", e))(k || {}), w;
720
+ var M = /* @__PURE__ */ ((e) => (e.Valid = "Valid", e.Removed = "Removed", e.Protected = "Protected", e))(M || {}), S = /* @__PURE__ */ ((e) => (e.Archived = "Archived", e.Restored = "Restored", e))(S || {}), k = /* @__PURE__ */ ((e) => (e.Info = "Info", e.Warn = "Warn", e.Error = "Error", e))(k || {}), w;
721
721
  ((e) => {
722
- e.VaultId = 0, e.VaultName = "@", e.Config = pe($e, "default-files/config.default.jsonc"), e.AutoIncr = pe(
723
- Te,
722
+ e.VaultId = 0, e.VaultName = "@", e.Config = pe(De, "default-files/config.default.jsonc"), e.AutoIncr = pe(
723
+ Ne,
724
724
  "default-files/auto-incr.default.jsonc"
725
725
  ), e.Vault = {
726
726
  id: e.VaultId,
727
727
  name: e.VaultName,
728
728
  remark: "Default vault",
729
729
  createdAt: "system",
730
- status: N.Protected
730
+ status: M.Protected
731
731
  }, e.LogTail = 15;
732
732
  })(w || (w = {}));
733
- const ia = () => process.env.ARCHIVER_PATH ?? J(Ut(), ".archiver"), W = ia();
734
- var I;
733
+ const oa = () => process.env.ARCHIVER_PATH ?? G(Wt(), ".archiver"), J = oa();
734
+ var y;
735
735
  ((e) => {
736
736
  e.Dir = {
737
- root: W,
738
- vaults: J(W, "vaults")
737
+ root: J,
738
+ vaults: G(J, "vaults")
739
739
  }, e.File = {
740
- config: J(W, "config.jsonc"),
741
- autoIncr: J(W, "auto-incr.jsonc"),
742
- list: J(W, "list.jsonl"),
743
- vaults: J(W, "vaults.jsonl"),
744
- log: J(W, "log.jsonl")
740
+ config: G(J, "config.jsonc"),
741
+ autoIncr: G(J, "auto-incr.jsonc"),
742
+ list: G(J, "list.jsonl"),
743
+ vaults: G(J, "vaults.jsonl"),
744
+ log: G(J, "log.jsonl")
745
745
  };
746
- })(I || (I = {}));
747
- var K;
746
+ })(y || (y = {}));
747
+ var X;
748
748
  ((e) => {
749
749
  e.CheckInterval = 1440 * 60 * 1e3, e.Repo = process.env.ARCHIVER_GITHUB_REPO ?? "aldia/archiver", e.Timeout = 1e4;
750
- })(K || (K = {}));
751
- const na = "archiver", ie = (e) => e.toString().padStart(2, "0"), oa = () => (/* @__PURE__ */ new Date()).toISOString();
752
- function Oe(e = /* @__PURE__ */ new Date()) {
753
- const t = e.getFullYear(), a = ie(e.getMonth() + 1), r = ie(e.getDate()), i = ie(e.getHours()), o = ie(e.getMinutes()), c = ie(e.getSeconds());
754
- return `${t}-${a}-${r} ${i}:${o}:${c}`;
750
+ })(X || (X = {}));
751
+ const sa = "archiver", ne = (e) => e.toString().padStart(2, "0"), ca = () => (/* @__PURE__ */ new Date()).toISOString();
752
+ function Ye(e = /* @__PURE__ */ new Date()) {
753
+ const t = e.getFullYear(), a = ne(e.getMonth() + 1), r = ne(e.getDate()), i = ne(e.getHours()), o = ne(e.getMinutes()), s = ne(e.getSeconds());
754
+ return `${t}-${a}-${r} ${i}:${o}:${s}`;
755
755
  }
756
- function Je(e) {
756
+ function Ke(e) {
757
757
  if (e.length === 0)
758
758
  throw new Error(n("util.parse.error.at_least_one_id"));
759
759
  const t = e.map((r) => {
@@ -765,48 +765,48 @@ function Je(e) {
765
765
  throw new Error(n("util.parse.error.duplicate_ids"));
766
766
  return t;
767
767
  }
768
- function be(e, t) {
768
+ function Ce(e, t) {
769
769
  return t === "green" ? v.black.bgGreen(` ${e} `) : t === "cyan" ? v.black.bgCyan(` ${e} `) : t === "yellow" ? v.black.bgYellow(` ${e} `) : v.white.bgRed(` ${e} `);
770
770
  }
771
- function M(e) {
772
- console.log(`${be(n("terminal.badge.ok"), "green")} ${v.green(e)}`);
771
+ function P(e) {
772
+ console.log(`${Ce(n("terminal.badge.ok"), "green")} ${v.green(e)}`);
773
773
  }
774
- function O(e) {
775
- console.log(`${be(n("terminal.badge.info"), "cyan")} ${v.cyan(e)}`);
774
+ function j(e) {
775
+ console.log(`${Ce(n("terminal.badge.info"), "cyan")} ${v.cyan(e)}`);
776
776
  }
777
- function Ce(e) {
778
- console.log(`${be(n("terminal.badge.warn"), "yellow")} ${v.yellow(e)}`);
777
+ function Ae(e) {
778
+ console.log(`${Ce(n("terminal.badge.warn"), "yellow")} ${v.yellow(e)}`);
779
779
  }
780
- function Q(e) {
781
- console.error(`${be(n("terminal.badge.error"), "red")} ${v.red(e)}`);
780
+ function ee(e) {
781
+ console.error(`${Ce(n("terminal.badge.error"), "red")} ${v.red(e)}`);
782
782
  }
783
- function sa(e) {
783
+ function la(e) {
784
784
  const t = e.toLowerCase();
785
785
  return e === "A" || t === "archived" ? e === "A" ? v.green(e) : v.green(n("terminal.status.archive.archived")) : e === "R" || t === "restored" ? e === "R" ? v.gray(e) : v.gray(n("terminal.status.archive.restored")) : e;
786
786
  }
787
- function ca(e) {
787
+ function da(e) {
788
788
  return e === "put" ? n("command.batch.operation.put") : e === "restore" ? n("command.batch.operation.restore") : e === "move" ? n("command.batch.operation.move") : e;
789
789
  }
790
- function me(e, t) {
791
- O(
790
+ function ve(e, t) {
791
+ j(
792
792
  n("command.batch.summary", {
793
- operation: ca(e),
793
+ operation: da(e),
794
794
  ok: t.ok.length,
795
795
  failed: t.failed.length
796
796
  })
797
797
  );
798
798
  }
799
- async function F(e) {
799
+ async function O(e) {
800
800
  const t = await e.configService.getConfig();
801
801
  if (t.updateCheck === "on") {
802
802
  if (t.lastUpdateCheck) {
803
803
  const a = new Date(t.lastUpdateCheck);
804
- if (!Number.isNaN(a.getTime()) && Date.now() - a.getTime() < K.CheckInterval)
804
+ if (!Number.isNaN(a.getTime()) && Date.now() - a.getTime() < X.CheckInterval)
805
805
  return;
806
806
  }
807
807
  try {
808
808
  const a = await e.updateService.checkLatest();
809
- await e.configService.updateLastCheck(oa()), a.hasUpdate && O(
809
+ await e.configService.updateLastCheck(ca()), a.hasUpdate && j(
810
810
  n("command.auto_update.new_available", {
811
811
  latestVersion: a.latestVersion,
812
812
  currentVersion: a.currentVersion
@@ -816,19 +816,19 @@ async function F(e) {
816
816
  }
817
817
  }
818
818
  }
819
- async function P(e) {
819
+ async function F(e) {
820
820
  try {
821
821
  await e();
822
822
  } catch (t) {
823
- Q(t.message), process.exitCode = 1;
823
+ ee(t.message), process.exitCode = 1;
824
824
  }
825
825
  }
826
- function la(e, t) {
826
+ function ua(e, t) {
827
827
  e.command("put").description(n("command.archive.put.description")).argument("<items...>", n("command.archive.put.argument.items")).option("-v, --vault <vault>", n("command.archive.put.option.vault")).option("-m, --message <message>", n("command.archive.put.option.message")).option("-r, --remark <remark>", n("command.archive.put.option.remark")).action(
828
- (a, r) => P(async () => {
828
+ (a, r) => F(async () => {
829
829
  const i = await t.archiveService.put(a, r);
830
830
  for (const o of i.ok)
831
- M(
831
+ P(
832
832
  n("command.archive.result.put.ok", {
833
833
  id: o.id,
834
834
  input: o.input,
@@ -836,84 +836,84 @@ function la(e, t) {
836
836
  })
837
837
  );
838
838
  for (const o of i.failed)
839
- Q(
839
+ ee(
840
840
  n("command.archive.result.put.failed", {
841
841
  id: o.id ?? "-",
842
842
  input: o.input,
843
843
  message: o.message
844
844
  })
845
845
  );
846
- me("put", i), await F(t);
846
+ ve("put", i), await O(t);
847
847
  })
848
848
  ), e.command("restore").description(n("command.archive.restore.description")).argument("<ids...>", n("command.archive.restore.argument.ids")).action(
849
- (a) => P(async () => {
850
- const r = Je(a), i = await t.archiveService.restore(r);
849
+ (a) => F(async () => {
850
+ const r = Ke(a), i = await t.archiveService.restore(r);
851
851
  for (const o of i.ok)
852
- M(
852
+ P(
853
853
  n("command.archive.result.restore.ok", {
854
854
  id: o.id,
855
855
  message: o.message
856
856
  })
857
857
  );
858
858
  for (const o of i.failed)
859
- Q(
859
+ ee(
860
860
  n("command.archive.result.restore.failed", {
861
861
  id: o.id ?? "-",
862
862
  message: o.message
863
863
  })
864
864
  );
865
- me("restore", i), await F(t);
865
+ ve("restore", i), await O(t);
866
866
  })
867
867
  ), e.command("move").description(n("command.archive.move.description")).argument("<ids...>", n("command.archive.move.argument.ids")).requiredOption("--to <vault>", n("command.archive.move.option.to")).action(
868
- (a, r) => P(async () => {
869
- const i = Je(a), o = await t.archiveService.move(i, r.to);
870
- for (const c of o.ok)
871
- M(
868
+ (a, r) => F(async () => {
869
+ const i = Ke(a), o = await t.archiveService.move(i, r.to);
870
+ for (const s of o.ok)
871
+ P(
872
872
  n("command.archive.result.move.ok", {
873
- id: c.id,
874
- message: c.message
873
+ id: s.id,
874
+ message: s.message
875
875
  })
876
876
  );
877
- for (const c of o.failed)
878
- Q(
877
+ for (const s of o.failed)
878
+ ee(
879
879
  n("command.archive.result.move.failed", {
880
- id: c.id ?? "-",
881
- message: c.message
880
+ id: s.id ?? "-",
881
+ message: s.message
882
882
  })
883
883
  );
884
- me("move", o), await F(t);
884
+ ve("move", o), await O(t);
885
885
  })
886
886
  );
887
887
  }
888
- const da = v.level;
889
- function ua(e) {
888
+ const ma = v.level;
889
+ function va(e) {
890
890
  if (typeof e != "string")
891
891
  return;
892
892
  const t = e.trim().toLowerCase();
893
893
  if (t === "on" || t === "off")
894
894
  return t;
895
895
  }
896
- function ma(e, t = process.env) {
897
- return ua(t.ARCHIVER_STYLE) ?? e;
896
+ function ha(e, t = process.env) {
897
+ return va(t.ARCHIVER_STYLE) ?? e;
898
898
  }
899
- function va(e) {
899
+ function fa(e) {
900
900
  if (e === "off") {
901
901
  v.level = 0;
902
902
  return;
903
903
  }
904
- v.level = Math.max(da, 1);
904
+ v.level = Math.max(ma, 1);
905
905
  }
906
- function ge(e, t = process.env) {
907
- const a = ma(e.style, t);
908
- return va(a), a;
906
+ function _e(e, t = process.env) {
907
+ const a = ha(e.style, t);
908
+ return fa(a), a;
909
909
  }
910
- function gt(e, t) {
910
+ function wt(e, t) {
911
911
  return e < 0 ? 0 : e > t.length ? t.length : e;
912
912
  }
913
- function G(e, t) {
914
- return { value: e, cursor: gt(t, e) };
913
+ function K(e, t) {
914
+ return { value: e, cursor: wt(t, e) };
915
915
  }
916
- function ha(e) {
916
+ function ga(e) {
917
917
  if (!e)
918
918
  return !1;
919
919
  for (const t of e) {
@@ -923,13 +923,13 @@ function ha(e) {
923
923
  }
924
924
  return !0;
925
925
  }
926
- function _t(e = "") {
926
+ function It(e = "") {
927
927
  return { value: e, cursor: e.length };
928
928
  }
929
- function Ge(e, t) {
930
- return t === "left" ? G(e.value, e.cursor - 1) : G(e.value, e.cursor + 1);
929
+ function Xe(e, t) {
930
+ return t === "left" ? K(e.value, e.cursor - 1) : K(e.value, e.cursor + 1);
931
931
  }
932
- function _e(e, t, a) {
932
+ function we(e, t, a) {
933
933
  if (a.ctrl && a.name === "c")
934
934
  return { state: e, action: "cancel" };
935
935
  if (a.name === "escape")
@@ -937,89 +937,92 @@ function _e(e, t, a) {
937
937
  if (a.name === "return" || a.name === "enter")
938
938
  return { state: e, action: "submit" };
939
939
  if (a.name === "left")
940
- return { state: Ge(e, "left"), action: "continue" };
940
+ return { state: Xe(e, "left"), action: "continue" };
941
941
  if (a.name === "right")
942
- return { state: Ge(e, "right"), action: "continue" };
942
+ return { state: Xe(e, "right"), action: "continue" };
943
943
  if (a.name === "home")
944
- return { state: G(e.value, 0), action: "continue" };
944
+ return { state: K(e.value, 0), action: "continue" };
945
945
  if (a.name === "end")
946
- return { state: G(e.value, e.value.length), action: "continue" };
946
+ return { state: K(e.value, e.value.length), action: "continue" };
947
947
  if (a.name === "backspace") {
948
948
  if (e.cursor === 0)
949
949
  return { state: e, action: "continue" };
950
950
  const i = `${e.value.slice(0, e.cursor - 1)}${e.value.slice(e.cursor)}`;
951
- return { state: G(i, e.cursor - 1), action: "continue" };
951
+ return { state: K(i, e.cursor - 1), action: "continue" };
952
952
  }
953
953
  if (a.name === "delete") {
954
954
  if (e.cursor >= e.value.length)
955
955
  return { state: e, action: "continue" };
956
956
  const i = `${e.value.slice(0, e.cursor)}${e.value.slice(e.cursor + 1)}`;
957
- return { state: G(i, e.cursor), action: "continue" };
957
+ return { state: K(i, e.cursor), action: "continue" };
958
958
  }
959
- if (!ha(t))
959
+ if (!ga(t))
960
960
  return { state: e, action: "continue" };
961
961
  const r = `${e.value.slice(0, e.cursor)}${t}${e.value.slice(e.cursor)}`;
962
- return { state: G(r, e.cursor + t.length), action: "continue" };
962
+ return { state: K(r, e.cursor + t.length), action: "continue" };
963
963
  }
964
- function wt(e, t = !0, a = "") {
964
+ function yt(e, t = !0, a = "") {
965
965
  if (!t) {
966
- const s = e.value || a;
967
- return v.dim(`[${s}]`);
966
+ const c = e.value || a;
967
+ return v.dim(`[${c}]`);
968
968
  }
969
969
  if (!e.value)
970
970
  return a ? `[${v.dim(a)}]` : `[${v.inverse(" ")}]`;
971
- const r = gt(e.cursor, e.value);
971
+ const r = wt(e.cursor, e.value);
972
972
  if (r >= e.value.length)
973
973
  return `[${e.value}${v.inverse(" ")}]`;
974
- const i = e.value.slice(0, r), o = e.value.slice(r, r + 1), c = e.value.slice(r + 1);
975
- return `[${i}${v.inverse(o)}${c}]`;
974
+ const i = e.value.slice(0, r), o = e.value.slice(r, r + 1), s = e.value.slice(r + 1);
975
+ return `[${i}${v.inverse(o)}${s}]`;
976
+ }
977
+ function ke(e = {}) {
978
+ const t = e.stdinIsTTY ?? !!process.stdin.isTTY, a = e.stdoutIsTTY ?? !!process.stdout.isTTY, r = e.stderrIsTTY ?? !!process.stderr.isTTY, i = e.forceInteractive ?? process.env.ARCHIVER_FORCE_INTERACTIVE === "1", o = e.hasRawMode ?? typeof process.stdin.setRawMode == "function";
979
+ return t && o && (a || i && r);
976
980
  }
977
- function Ke(e, t) {
981
+ function xe() {
982
+ return process.stdout.isTTY ? process.stdout : process.env.ARCHIVER_FORCE_INTERACTIVE === "1" && process.stderr.isTTY ? process.stderr : process.stdout;
983
+ }
984
+ function Ze(e, t) {
978
985
  return typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : t;
979
986
  }
980
- function oe(e = {}) {
987
+ function se(e = {}) {
981
988
  return {
982
- rows: Ke(e.rows, 24),
983
- columns: Ke(e.columns, 80)
989
+ rows: Ze(e.rows, 24),
990
+ columns: Ze(e.columns, 80)
984
991
  };
985
992
  }
986
- function ke(e, t) {
993
+ function Ee(e, t) {
987
994
  return e.rows >= t.rows && e.columns >= t.columns;
988
995
  }
989
- function fa(e) {
990
- const t = e.contentLines.length > 0 ? e.contentLines : [""], a = e.footerLines ?? [], r = oe({ rows: e.rows }).rows, i = Math.max(r - t.length - a.length, 0);
996
+ function pa(e) {
997
+ const t = e.contentLines.length > 0 ? e.contentLines : [""], a = e.footerLines ?? [], r = se({ rows: e.rows }).rows, i = Math.max(r - t.length - a.length, 0);
991
998
  return [...t, ...Array.from({ length: i }, () => ""), ...a];
992
999
  }
993
- function B(e) {
994
- return fa({
1000
+ function U(e) {
1001
+ return pa({
995
1002
  contentLines: e.contentLines,
996
1003
  footerLines: [e.hintLine ?? "", e.statusLine ?? ""],
997
1004
  rows: e.rows
998
1005
  });
999
1006
  }
1000
- function xe(e = {}) {
1001
- const t = e.stdinIsTTY ?? !!process.stdin.isTTY, a = e.stdoutIsTTY ?? !!process.stdout.isTTY, r = e.forceInteractive ?? process.env.ARCHIVER_FORCE_INTERACTIVE === "1", i = e.hasRawMode ?? typeof process.stdin.setRawMode == "function";
1002
- return t && i && (a || r);
1003
- }
1004
- function pa(e) {
1007
+ function _a(e) {
1005
1008
  const t = e.codePointAt(0);
1006
1009
  return t === void 0 || t <= 31 || t >= 127 && t <= 160 ? 0 : t >= 4352 && (t <= 4447 || t === 9001 || t === 9002 || t >= 11904 && t <= 42191 && t !== 12351 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65135 || t >= 65280 && t <= 65376 || t >= 65504 && t <= 65510 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141) ? 2 : 1;
1007
1010
  }
1008
- function ee(e) {
1011
+ function te(e) {
1009
1012
  let t = 0;
1010
1013
  for (const a of e)
1011
- t += pa(a);
1014
+ t += _a(a);
1012
1015
  return t;
1013
1016
  }
1014
- function je(e, t) {
1015
- const a = ee(e), r = Math.max(t - a, 0);
1017
+ function He(e, t) {
1018
+ const a = te(e), r = Math.max(t - a, 0);
1016
1019
  return `${e}${" ".repeat(r)}`;
1017
1020
  }
1018
- const Ee = {
1021
+ const Re = {
1019
1022
  rows: 6,
1020
1023
  columns: 28
1021
1024
  };
1022
- function yt(e, t, a) {
1025
+ function bt(e, t, a) {
1023
1026
  if (e.length === 0)
1024
1027
  return;
1025
1028
  const r = a === "left" ? -1 : 1;
@@ -1029,115 +1032,115 @@ function yt(e, t, a) {
1029
1032
  return o;
1030
1033
  }
1031
1034
  }
1032
- function j(e, t) {
1035
+ function Y(e, t) {
1033
1036
  if (e.length === 0)
1034
1037
  return { options: e, selectedIndex: 0 };
1035
1038
  let a = t === void 0 ? 0 : e.findIndex((r) => Object.is(r.value, t));
1036
1039
  if (a < 0 && (a = 0), e[a]?.disabled) {
1037
- const r = yt(e, a, "right");
1040
+ const r = bt(e, a, "right");
1038
1041
  r !== void 0 && (a = r);
1039
1042
  }
1040
1043
  return { options: e, selectedIndex: a };
1041
1044
  }
1042
- function X(e, t) {
1043
- const a = yt(e.options, e.selectedIndex, t);
1045
+ function Z(e, t) {
1046
+ const a = bt(e.options, e.selectedIndex, t);
1044
1047
  return a === void 0 ? e : { ...e, selectedIndex: a };
1045
1048
  }
1046
- function U(e) {
1049
+ function z(e) {
1047
1050
  return e.options[e.selectedIndex];
1048
1051
  }
1049
- function ga(e) {
1050
- return Math.max(...e.map((t) => ee(t.label)), 1);
1052
+ function wa(e) {
1053
+ return Math.max(...e.map((t) => te(t.label)), 1);
1051
1054
  }
1052
- function _a(e, t, a, r) {
1053
- const o = `${e.disabled ? "x" : t ? ">" : " "} ${je(e.label, r)}`;
1055
+ function Ia(e, t, a, r) {
1056
+ const o = `${e.disabled ? "x" : t ? ">" : " "} ${He(e.label, r)}`;
1054
1057
  return e.disabled ? v.dim(`[${o}]`) : t && a ? v.black.bgGreen(`[${o}]`) : t ? v.green(`[${o}]`) : a ? v.green(`[${o}]`) : v.dim(`[${o}]`);
1055
1058
  }
1056
- function te(e, t = !0) {
1057
- const a = ga(e.options);
1058
- return e.options.map((r, i) => _a(r, i === e.selectedIndex, t, a)).join(" ");
1059
+ function ae(e, t = !0) {
1060
+ const a = wa(e.options);
1061
+ return e.options.map((r, i) => Ia(r, i === e.selectedIndex, t, a)).join(" ");
1059
1062
  }
1060
- function V(e) {
1063
+ function L(e) {
1061
1064
  return v.black.bgWhite(` ${e} `);
1062
1065
  }
1063
- async function wa(e) {
1064
- const t = j(e.options, e.initialValue);
1066
+ async function ya(e) {
1067
+ const t = Y(e.options, e.initialValue);
1065
1068
  if (e.options.length === 0)
1066
1069
  return null;
1067
- if (!xe())
1068
- return U(t)?.value ?? null;
1069
- const a = process.stdin;
1070
- let r = t;
1071
- return Ie.emitKeypressEvents(a), a.setRawMode(!0), a.resume(), new Promise((i) => {
1072
- const o = () => {
1073
- const d = oe({
1074
- rows: process.stdout.rows,
1075
- columns: process.stdout.columns
1070
+ if (!ke())
1071
+ return z(t)?.value ?? null;
1072
+ const a = process.stdin, r = xe();
1073
+ let i = t;
1074
+ return be.emitKeypressEvents(a), a.setRawMode(!0), a.resume(), new Promise((o) => {
1075
+ const s = () => {
1076
+ const u = se({
1077
+ rows: r.rows,
1078
+ columns: r.columns
1076
1079
  });
1077
- if (!ke(d, Ee)) {
1078
- const h = B({
1080
+ if (!Ee(u, Re)) {
1081
+ const h = U({
1079
1082
  contentLines: [
1080
1083
  v.bold(n("ui.screen.too_small.title")),
1081
1084
  n("ui.screen.too_small.required", {
1082
- minColumns: Ee.columns,
1083
- minRows: Ee.rows
1085
+ minColumns: Re.columns,
1086
+ minRows: Re.rows
1084
1087
  }),
1085
1088
  n("ui.screen.too_small.current", {
1086
- columns: d.columns,
1087
- rows: d.rows
1089
+ columns: u.columns,
1090
+ rows: u.rows
1088
1091
  })
1089
1092
  ],
1090
1093
  hintLine: v.dim(n("ui.screen.too_small.hint")),
1091
1094
  statusLine: "",
1092
- rows: d.rows
1095
+ rows: u.rows
1093
1096
  });
1094
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(h.join(`
1097
+ r.write("\x1B[2J\x1B[H\x1B[?25l"), r.write(h.join(`
1095
1098
  `));
1096
1099
  return;
1097
1100
  }
1098
- const u = [e.title];
1099
- e.description && u.push(v.dim(e.description)), u.push("", te(r));
1100
- const m = B({
1101
- contentLines: u,
1101
+ const m = [e.title];
1102
+ e.description && m.push(v.dim(e.description)), m.push("", ae(i));
1103
+ const f = U({
1104
+ contentLines: m,
1102
1105
  hintLine: e.hint,
1103
1106
  statusLine: "",
1104
- rows: d.rows
1107
+ rows: u.rows
1105
1108
  });
1106
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(m.join(`
1109
+ r.write("\x1B[2J\x1B[H\x1B[?25l"), r.write(f.join(`
1107
1110
  `));
1108
- }, c = (d) => {
1109
- a.off("keypress", l), process.stdout.off("resize", s), a.setRawMode(!1), a.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
1110
- `), i(d);
1111
- }, s = () => {
1112
- o();
1113
- }, l = (d, u) => {
1114
- if (u.ctrl && u.name === "c") {
1111
+ }, c = (u) => {
1112
+ a.off("keypress", d), r.off("resize", l), a.setRawMode(!1), a.pause(), r.write(`\x1B[2J\x1B[H\x1B[?25h
1113
+ `), o(u);
1114
+ }, l = () => {
1115
+ s();
1116
+ }, d = (u, m) => {
1117
+ if (m.ctrl && m.name === "c") {
1115
1118
  c(null);
1116
1119
  return;
1117
1120
  }
1118
- if (u.name === "left") {
1119
- r = X(r, "left"), o();
1121
+ if (m.name === "left") {
1122
+ i = Z(i, "left"), s();
1120
1123
  return;
1121
1124
  }
1122
- if (u.name === "right") {
1123
- r = X(r, "right"), o();
1125
+ if (m.name === "right") {
1126
+ i = Z(i, "right"), s();
1124
1127
  return;
1125
1128
  }
1126
- if (u.name === "return" || u.name === "enter") {
1127
- const m = U(r);
1128
- if (!m || m.disabled)
1129
+ if (m.name === "return" || m.name === "enter") {
1130
+ const f = z(i);
1131
+ if (!f || f.disabled)
1129
1132
  return;
1130
- c(m.value);
1133
+ c(f.value);
1131
1134
  }
1132
1135
  };
1133
- a.on("keypress", l), process.stdout.on("resize", s), o();
1136
+ a.on("keypress", d), r.on("resize", l), s();
1134
1137
  });
1135
1138
  }
1136
- const ya = ["updateCheck", "vaultItemSeparator", "style", "language", "noCommandAction"], Ae = {
1139
+ const ba = ["updateCheck", "vaultItemSeparator", "style", "language", "noCommandAction"], Se = {
1137
1140
  rows: 11,
1138
1141
  columns: 52
1139
1142
  };
1140
- function Ia(e) {
1143
+ function Ca(e) {
1141
1144
  return {
1142
1145
  updateCheck: e.updateCheck,
1143
1146
  vaultItemSeparator: e.vaultItemSeparator,
@@ -1146,23 +1149,23 @@ function Ia(e) {
1146
1149
  noCommandAction: e.noCommandAction
1147
1150
  };
1148
1151
  }
1149
- function It(e, t) {
1150
- return ya.every((a) => e[a] === t[a]);
1152
+ function Ct(e, t) {
1153
+ return ba.every((a) => e[a] === t[a]);
1151
1154
  }
1152
- function ba(e) {
1155
+ function ka(e) {
1153
1156
  if (!e.vaultItemSeparator.trim())
1154
1157
  return "command.config.error.vault_item_sep_empty";
1155
1158
  }
1156
- function ka() {
1159
+ function xa() {
1157
1160
  return typeof process.stdin.setRawMode == "function";
1158
1161
  }
1159
- function xa(e) {
1162
+ function Ea(e) {
1160
1163
  return [
1161
1164
  {
1162
1165
  kind: "select",
1163
1166
  key: "updateCheck",
1164
1167
  label: n("command.config.field.update_check"),
1165
- state: j(
1168
+ state: Y(
1166
1169
  [
1167
1170
  { value: "on", label: n("common.state.on") },
1168
1171
  { value: "off", label: n("common.state.off") }
@@ -1174,13 +1177,13 @@ function xa(e) {
1174
1177
  kind: "input",
1175
1178
  key: "vaultItemSeparator",
1176
1179
  label: n("command.config.field.vault_item_sep"),
1177
- state: _t(e.vaultItemSeparator)
1180
+ state: It(e.vaultItemSeparator)
1178
1181
  },
1179
1182
  {
1180
1183
  kind: "select",
1181
1184
  key: "style",
1182
1185
  label: n("command.config.field.style"),
1183
- state: j(
1186
+ state: Y(
1184
1187
  [
1185
1188
  { value: "on", label: n("common.state.on") },
1186
1189
  { value: "off", label: n("common.state.off") }
@@ -1192,7 +1195,7 @@ function xa(e) {
1192
1195
  kind: "select",
1193
1196
  key: "language",
1194
1197
  label: n("command.config.field.language"),
1195
- state: j(
1198
+ state: Y(
1196
1199
  [
1197
1200
  { value: "zh", label: "zh" },
1198
1201
  { value: "en", label: "en" }
@@ -1204,7 +1207,7 @@ function xa(e) {
1204
1207
  kind: "select",
1205
1208
  key: "noCommandAction",
1206
1209
  label: n("command.config.field.no_command_action"),
1207
- state: j(
1210
+ state: Y(
1208
1211
  [
1209
1212
  { value: "list", label: n("common.action.list") },
1210
1213
  { value: "help", label: n("common.action.help") },
@@ -1215,17 +1218,17 @@ function xa(e) {
1215
1218
  }
1216
1219
  ];
1217
1220
  }
1218
- function Xe(e, t, a) {
1221
+ function Qe(e, t, a) {
1219
1222
  return a <= 0 ? 0 : t === "up" ? (e - 1 + a) % a : (e + 1) % a;
1220
1223
  }
1221
- function bt(e, t) {
1224
+ function kt(e, t) {
1222
1225
  const a = { ...t };
1223
1226
  for (const r of e) {
1224
1227
  if (r.kind === "input") {
1225
1228
  a.vaultItemSeparator = r.state.value;
1226
1229
  continue;
1227
1230
  }
1228
- const i = U(r.state)?.value;
1231
+ const i = z(r.state)?.value;
1229
1232
  if (i) {
1230
1233
  if (r.key === "updateCheck") {
1231
1234
  a.updateCheck = i;
@@ -1244,196 +1247,196 @@ function bt(e, t) {
1244
1247
  }
1245
1248
  return a;
1246
1249
  }
1247
- function Ca(e) {
1248
- return Math.max(...e.map((t) => ee(t.label)), 1);
1250
+ function Aa(e) {
1251
+ return Math.max(...e.map((t) => te(t.label)), 1);
1249
1252
  }
1250
- function Y(e, t, a, r, i) {
1251
- const o = oe({
1252
- rows: process.stdout.rows,
1253
- columns: process.stdout.columns
1253
+ function B(e, t, a, r, i, o) {
1254
+ const s = se({
1255
+ rows: o.rows,
1256
+ columns: o.columns
1254
1257
  });
1255
- if (!ke(o, Ae)) {
1256
- const g = B({
1258
+ if (!Ee(s, Se)) {
1259
+ const b = U({
1257
1260
  contentLines: [
1258
1261
  v.bold(n("ui.screen.too_small.title")),
1259
1262
  n("ui.screen.too_small.required", {
1260
- minColumns: Ae.columns,
1261
- minRows: Ae.rows
1263
+ minColumns: Se.columns,
1264
+ minRows: Se.rows
1262
1265
  }),
1263
1266
  n("ui.screen.too_small.current", {
1264
- columns: o.columns,
1265
- rows: o.rows
1267
+ columns: s.columns,
1268
+ rows: s.rows
1266
1269
  })
1267
1270
  ],
1268
1271
  hintLine: v.dim(n("ui.screen.too_small.hint")),
1269
1272
  statusLine: "",
1270
- rows: o.rows
1273
+ rows: s.rows
1271
1274
  });
1272
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(g.join(`
1275
+ o.write("\x1B[2J\x1B[H\x1B[?25l"), o.write(b.join(`
1273
1276
  `));
1274
1277
  return;
1275
1278
  }
1276
- const c = bt(e, a), s = !It(c, a), l = Ca(e), d = e.length, u = t === d, m = n("command.config.hint", {
1277
- upDown: V(n("command.config.key.up_down")),
1278
- leftRight: V(n("command.config.key.left_right")),
1279
- type: V(n("command.config.key.type")),
1280
- enter: V(n("command.config.key.enter")),
1281
- cancel: V(n("command.config.key.cancel"))
1279
+ const c = kt(e, a), l = !Ct(c, a), d = Aa(e), u = e.length, m = t === u, f = n("command.config.hint", {
1280
+ upDown: L(n("command.config.key.up_down")),
1281
+ leftRight: L(n("command.config.key.left_right")),
1282
+ type: L(n("command.config.key.type")),
1283
+ enter: L(n("command.config.key.enter")),
1284
+ cancel: L(n("command.config.key.cancel"))
1282
1285
  }), h = [];
1283
1286
  h.push(v.bold(n("command.config.title"))), h.push("");
1284
- for (let g = 0; g < e.length; g += 1) {
1285
- const L = e[g];
1286
- if (!L)
1287
+ for (let b = 0; b < e.length; b += 1) {
1288
+ const T = e[b];
1289
+ if (!T)
1287
1290
  continue;
1288
- const C = g === t, E = C ? v.cyan(">") : " ", A = je(L.label, l), $ = C ? v.bold(A) : A, D = L.kind === "select" ? te(L.state, C) : wt(L.state, C, n("command.config.input.placeholder"));
1289
- h.push(`${E} ${$} ${D}`);
1291
+ const E = b === t, A = E ? v.cyan(">") : " ", R = He(T.label, d), $ = E ? v.bold(R) : R, N = T.kind === "select" ? ae(T.state, E) : yt(T.state, E, n("command.config.input.placeholder"));
1292
+ h.push(`${A} ${$} ${N}`);
1290
1293
  }
1291
- h.push(""), h.push(`${n("command.config.action_prefix")} ${te(r, u)}`), h.push("");
1292
- const f = i ? v.yellow(i) : v.dim(n(s ? "command.config.state.dirty" : "command.config.state.clean")), _ = B({
1294
+ h.push(""), h.push(`${n("command.config.action_prefix")} ${ae(r, m)}`), h.push("");
1295
+ const g = i ? v.yellow(i) : v.dim(n(l ? "command.config.state.dirty" : "command.config.state.clean")), _ = U({
1293
1296
  contentLines: h,
1294
- hintLine: m,
1295
- statusLine: f,
1296
- rows: o.rows
1297
+ hintLine: f,
1298
+ statusLine: g,
1299
+ rows: s.rows
1297
1300
  });
1298
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(_.join(`
1301
+ o.write("\x1B[2J\x1B[H\x1B[?25l"), o.write(_.join(`
1299
1302
  `));
1300
1303
  }
1301
- async function Ea(e) {
1302
- if (!ka())
1304
+ async function Ra(e) {
1305
+ if (!xa())
1303
1306
  throw new Error(n("command.config.error.no_tty"));
1304
- const t = process.stdin, a = xa(e);
1305
- let r = j([
1307
+ const t = process.stdin, a = xe(), r = Ea(e);
1308
+ let i = Y([
1306
1309
  { value: "save", label: n("command.config.action.save") },
1307
1310
  { value: "cancel", label: n("command.config.action.cancel") },
1308
1311
  { value: "reset-default", label: n("command.config.action.reset_default") }
1309
- ]), i = 0, o = "";
1310
- return Ie.emitKeypressEvents(t), t.setRawMode(!0), t.resume(), new Promise((c) => {
1311
- const s = (m) => {
1312
- t.off("keypress", u), process.stdout.off("resize", l), t.setRawMode(!1), t.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
1313
- `), c(m);
1314
- }, l = () => {
1315
- Y(a, i, e, r, o);
1312
+ ]), o = 0, s = "";
1313
+ return be.emitKeypressEvents(t), t.setRawMode(!0), t.resume(), new Promise((c) => {
1314
+ const l = (f) => {
1315
+ t.off("keypress", m), a.off("resize", d), t.setRawMode(!1), t.pause(), a.write(`\x1B[2J\x1B[H\x1B[?25h
1316
+ `), c(f);
1316
1317
  }, d = () => {
1317
- const m = bt(a, e), h = ba(m);
1318
+ B(r, o, e, i, s, a);
1319
+ }, u = () => {
1320
+ const f = kt(r, e), h = ka(f);
1318
1321
  if (h) {
1319
- o = n(h), Y(a, i, e, r, o);
1322
+ s = n(h), B(r, o, e, i, s, a);
1320
1323
  return;
1321
1324
  }
1322
- s({ action: "save", values: m });
1323
- }, u = (m, h) => {
1325
+ l({ action: "save", values: f });
1326
+ }, m = (f, h) => {
1324
1327
  if (h.ctrl && h.name === "c") {
1325
- s({ action: "cancel" });
1328
+ l({ action: "cancel" });
1326
1329
  return;
1327
1330
  }
1328
1331
  if (h.name === "escape") {
1329
- s({ action: "cancel" });
1332
+ l({ action: "cancel" });
1330
1333
  return;
1331
1334
  }
1332
1335
  if (h.name === "up") {
1333
- i = Xe(i, "up", a.length + 1), o = "", Y(a, i, e, r, o);
1336
+ o = Qe(o, "up", r.length + 1), s = "", B(r, o, e, i, s, a);
1334
1337
  return;
1335
1338
  }
1336
1339
  if (h.name === "down") {
1337
- i = Xe(i, "down", a.length + 1), o = "", Y(a, i, e, r, o);
1340
+ o = Qe(o, "down", r.length + 1), s = "", B(r, o, e, i, s, a);
1338
1341
  return;
1339
1342
  }
1340
- if (i === a.length) {
1343
+ if (o === r.length) {
1341
1344
  if (h.name === "q") {
1342
- s({ action: "cancel" });
1345
+ l({ action: "cancel" });
1343
1346
  return;
1344
1347
  }
1345
1348
  if (h.name === "left" || h.name === "right") {
1346
- r = X(r, h.name), o = "", Y(a, i, e, r, o);
1349
+ i = Z(i, h.name), s = "", B(r, o, e, i, s, a);
1347
1350
  return;
1348
1351
  }
1349
1352
  if (h.name === "return" || h.name === "enter") {
1350
- const _ = U(r)?.value ?? "save";
1353
+ const _ = z(i)?.value ?? "save";
1351
1354
  if (_ === "cancel") {
1352
- s({ action: "cancel" });
1355
+ l({ action: "cancel" });
1353
1356
  return;
1354
1357
  }
1355
1358
  if (_ === "reset-default") {
1356
- s({ action: "reset-default" });
1359
+ l({ action: "reset-default" });
1357
1360
  return;
1358
1361
  }
1359
- d();
1362
+ u();
1360
1363
  }
1361
1364
  return;
1362
1365
  }
1363
- const f = a[i];
1364
- if (!f) {
1365
- s({ action: "cancel" });
1366
+ const g = r[o];
1367
+ if (!g) {
1368
+ l({ action: "cancel" });
1366
1369
  return;
1367
1370
  }
1368
- if (h.name === "q" && f.kind !== "input") {
1369
- s({ action: "cancel" });
1371
+ if (h.name === "q" && g.kind !== "input") {
1372
+ l({ action: "cancel" });
1370
1373
  return;
1371
1374
  }
1372
1375
  if (h.name === "left" || h.name === "right") {
1373
- f.kind === "select" ? f.state = X(f.state, h.name) : f.state = _e(f.state, m, h).state, o = "", Y(a, i, e, r, o);
1376
+ g.kind === "select" ? g.state = Z(g.state, h.name) : g.state = we(g.state, f, h).state, s = "", B(r, o, e, i, s, a);
1374
1377
  return;
1375
1378
  }
1376
- if (f.kind === "input") {
1377
- const _ = _e(f.state, m, h);
1378
- if (f.state = _.state, _.action === "cancel") {
1379
- s({ action: "cancel" });
1379
+ if (g.kind === "input") {
1380
+ const _ = we(g.state, f, h);
1381
+ if (g.state = _.state, _.action === "cancel") {
1382
+ l({ action: "cancel" });
1380
1383
  return;
1381
1384
  }
1382
1385
  if (_.action === "submit") {
1383
- d();
1386
+ u();
1384
1387
  return;
1385
1388
  }
1386
- o = "", Y(a, i, e, r, o);
1389
+ s = "", B(r, o, e, i, s, a);
1387
1390
  return;
1388
1391
  }
1389
- (h.name === "return" || h.name === "enter") && d();
1392
+ (h.name === "return" || h.name === "enter") && u();
1390
1393
  };
1391
- t.on("keypress", u), process.stdout.on("resize", l), Y(a, i, e, r, o);
1394
+ t.on("keypress", m), a.on("resize", d), B(r, o, e, i, s, a);
1392
1395
  });
1393
1396
  }
1394
- async function Aa(e) {
1395
- const t = await e.configService.getConfig(), a = Ia(t), r = await Ea(a);
1397
+ async function Sa(e) {
1398
+ const t = await e.configService.getConfig(), a = Ca(t), r = await Ra(a);
1396
1399
  if (r.action === "cancel") {
1397
- O(n("command.config.cancelled"));
1400
+ j(n("command.config.cancelled"));
1398
1401
  return;
1399
1402
  }
1400
1403
  if (r.action === "reset-default") {
1401
- await e.context.saveConfig({ ...w.Config }), ge(w.Config), M(n("command.config.reset_default.saved")), await e.auditLogger.log(
1404
+ await e.context.saveConfig({ ...w.Config }), _e(w.Config), P(n("command.config.reset_default.saved")), await e.auditLogger.log(
1402
1405
  "INFO",
1403
1406
  { main: "config", sub: "reset-default", source: "u" },
1404
1407
  n("command.config.audit.reset_default")
1405
- ), await F(e);
1408
+ ), await O(e);
1406
1409
  return;
1407
1410
  }
1408
- if (It(a, r.values)) {
1409
- O(n("command.config.no_changes"));
1411
+ if (Ct(a, r.values)) {
1412
+ j(n("command.config.no_changes"));
1410
1413
  return;
1411
1414
  }
1412
1415
  const i = {
1413
1416
  ...t,
1414
1417
  ...r.values
1415
1418
  };
1416
- await e.context.saveConfig(i), ge(i), M(n("command.config.saved")), await e.auditLogger.log(
1419
+ await e.context.saveConfig(i), _e(i), P(n("command.config.saved")), await e.auditLogger.log(
1417
1420
  "INFO",
1418
1421
  { main: "config", sub: "edit", source: "u" },
1419
1422
  n("command.config.audit.saved")
1420
- ), await F(e);
1423
+ ), await O(e);
1421
1424
  }
1422
- function Ra(e, t) {
1425
+ function Va(e, t) {
1423
1426
  e.command("config").description(n("command.config.description")).action(
1424
- () => P(async () => {
1425
- await Aa(t);
1427
+ () => F(async () => {
1428
+ await Sa(t);
1426
1429
  })
1427
1430
  );
1428
1431
  }
1429
- const Re = {
1432
+ const Ve = {
1430
1433
  rows: 7,
1431
1434
  columns: 44
1432
1435
  };
1433
- function Sa(e, t, a) {
1436
+ function La(e, t, a) {
1434
1437
  return a <= 0 ? 0 : t === "up" ? (e - 1 + a) % a : (e + 1) % a;
1435
1438
  }
1436
- function Ze(e, t, a) {
1439
+ function et(e, t, a) {
1437
1440
  if (e.length === 0)
1438
1441
  return 0;
1439
1442
  if (a) {
@@ -1443,23 +1446,23 @@ function Ze(e, t, a) {
1443
1446
  }
1444
1447
  return Math.min(t, e.length - 1);
1445
1448
  }
1446
- function Va(e, t) {
1449
+ function Ta(e, t) {
1447
1450
  return e.localeCompare(t, void 0, {
1448
1451
  numeric: !0,
1449
1452
  sensitivity: "base"
1450
1453
  });
1451
1454
  }
1452
- function La(e) {
1453
- return [...e].sort((t, a) => t.isDirectory !== a.isDirectory ? t.isDirectory ? -1 : 1 : Va(t.name, a.name));
1455
+ function $a(e) {
1456
+ return [...e].sort((t, a) => t.isDirectory !== a.isDirectory ? t.isDirectory ? -1 : 1 : Ta(t.name, a.name));
1454
1457
  }
1455
- async function Qe(e) {
1456
- const t = await y.readdir(e, { withFileTypes: !0 }), a = await Promise.all(
1458
+ async function tt(e) {
1459
+ const t = await I.readdir(e, { withFileTypes: !0 }), a = await Promise.all(
1457
1460
  t.map(async (r) => {
1458
1461
  const i = p.join(e, r.name);
1459
1462
  let o = r.isDirectory();
1460
1463
  if (r.isSymbolicLink())
1461
1464
  try {
1462
- o = (await y.stat(i)).isDirectory();
1465
+ o = (await I.stat(i)).isDirectory();
1463
1466
  } catch {
1464
1467
  o = !1;
1465
1468
  }
@@ -1470,127 +1473,128 @@ async function Qe(e) {
1470
1473
  };
1471
1474
  })
1472
1475
  );
1473
- return La(a);
1476
+ return $a(a);
1474
1477
  }
1475
- function $a(e) {
1476
- const { cwd: t, entries: a, selectedIndex: r, note: i } = e, o = oe({
1477
- rows: process.stdout.rows,
1478
- columns: process.stdout.columns
1478
+ function Da(e) {
1479
+ const { cwd: t, entries: a, selectedIndex: r, note: i, output: o } = e, s = se({
1480
+ rows: o.rows,
1481
+ columns: o.columns
1479
1482
  });
1480
- if (!ke(o, Re)) {
1481
- const f = B({
1483
+ if (!Ee(s, Ve)) {
1484
+ const g = U({
1482
1485
  contentLines: [
1483
1486
  v.bold(n("ui.screen.too_small.title")),
1484
1487
  n("ui.screen.too_small.required", {
1485
- minColumns: Re.columns,
1486
- minRows: Re.rows
1488
+ minColumns: Ve.columns,
1489
+ minRows: Ve.rows
1487
1490
  }),
1488
1491
  n("ui.screen.too_small.current", {
1489
- columns: o.columns,
1490
- rows: o.rows
1492
+ columns: s.columns,
1493
+ rows: s.rows
1491
1494
  })
1492
1495
  ],
1493
1496
  hintLine: v.dim(n("ui.screen.too_small.hint")),
1494
1497
  statusLine: "",
1495
- rows: o.rows
1498
+ rows: s.rows
1496
1499
  });
1497
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(f.join(`
1500
+ o.write("\x1B[2J\x1B[H\x1B[?25l"), o.write(g.join(`
1498
1501
  `));
1499
1502
  return;
1500
1503
  }
1501
- const c = o.rows, s = [v.bold(t), ""], d = Math.max(c - s.length - 2, 1);
1504
+ const c = s.rows, l = [v.bold(t), ""], u = Math.max(c - l.length - 2, 1);
1502
1505
  if (a.length === 0)
1503
- s.push(v.dim(n("command.dot.empty")));
1506
+ l.push(v.dim(n("command.dot.empty")));
1504
1507
  else {
1505
- const f = Math.max(d, 1), _ = Math.floor(f / 2), g = Math.max(a.length - f, 0), L = Math.min(Math.max(r - _, 0), g), C = Math.min(L + f, a.length);
1506
- for (let E = L; E < C; E += 1) {
1507
- const A = a[E];
1508
- if (!A)
1508
+ const g = Math.max(u, 1), _ = Math.floor(g / 2), b = Math.max(a.length - g, 0), T = Math.min(Math.max(r - _, 0), b), E = Math.min(T + g, a.length);
1509
+ for (let A = T; A < E; A += 1) {
1510
+ const R = a[A];
1511
+ if (!R)
1509
1512
  continue;
1510
- const $ = E === r, D = $ ? v.cyan(">") : " ", b = A.isDirectory ? v.cyan("[D]") : v.dim("[ ]"), T = A.isDirectory ? `${A.name}/` : A.name, Z = `${D} ${b} ${T}`;
1511
- s.push($ ? v.bold(Z) : Z);
1513
+ const $ = A === r, N = $ ? v.cyan(">") : " ", C = R.isDirectory ? v.cyan("[D]") : v.dim("[ ]"), D = R.isDirectory ? `${R.name}/` : R.name, Q = `${N} ${C} ${D}`;
1514
+ l.push($ ? v.bold(Q) : Q);
1512
1515
  }
1513
1516
  }
1514
- const u = n("command.dot.hint", {
1515
- upDown: V(n("command.dot.key.up_down")),
1516
- enter: V(n("command.dot.key.enter")),
1517
- cancel: V(n("command.dot.key.cancel"))
1518
- }), m = i ? v.yellow(i) : v.dim(n("command.dot.summary", { total: a.length })), h = B({
1519
- contentLines: s,
1520
- hintLine: u,
1521
- statusLine: m,
1517
+ const m = n("command.dot.hint", {
1518
+ upDown: L(n("command.dot.key.up_down")),
1519
+ enter: L(n("command.dot.key.enter")),
1520
+ cancel: L(n("command.dot.key.cancel"))
1521
+ }), f = i ? v.yellow(i) : v.dim(n("command.dot.summary", { total: a.length })), h = U({
1522
+ contentLines: l,
1523
+ hintLine: m,
1524
+ statusLine: f,
1522
1525
  rows: c
1523
1526
  });
1524
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(h.join(`
1527
+ o.write("\x1B[2J\x1B[H\x1B[?25l"), o.write(h.join(`
1525
1528
  `));
1526
1529
  }
1527
- function kt() {
1528
- return xe();
1530
+ function xt() {
1531
+ return ke();
1529
1532
  }
1530
- async function Ta(e) {
1531
- if (!kt())
1533
+ async function Na(e) {
1534
+ if (!xt())
1532
1535
  throw new Error(n("command.dot.error.no_tty"));
1533
- const t = process.cwd();
1534
- let a = await Qe(t), r = Ze(a, 0), i = !1, o = "";
1535
- const c = async (d) => {
1536
- a = await Qe(t), r = Ze(a, r, d);
1537
- }, s = () => {
1538
- $a({
1536
+ const t = process.cwd(), a = xe();
1537
+ let r = await tt(t), i = et(r, 0), o = !1, s = "";
1538
+ const c = async (u) => {
1539
+ r = await tt(t), i = et(r, i, u);
1540
+ }, l = () => {
1541
+ Da({
1539
1542
  cwd: t,
1540
- entries: a,
1541
- selectedIndex: r,
1542
- note: o
1543
+ entries: r,
1544
+ selectedIndex: i,
1545
+ note: s,
1546
+ output: a
1543
1547
  });
1544
- }, l = process.stdin;
1545
- return Ie.emitKeypressEvents(l), l.setRawMode(!0), l.resume(), new Promise((d) => {
1546
- const u = () => {
1547
- l.off("keypress", h), process.stdout.off("resize", m), l.setRawMode(!1), l.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
1548
- `), d();
1549
- }, m = () => {
1550
- s();
1551
- }, h = (f, _) => {
1552
- if (i)
1548
+ }, d = process.stdin;
1549
+ return be.emitKeypressEvents(d), d.setRawMode(!0), d.resume(), new Promise((u) => {
1550
+ const m = () => {
1551
+ d.off("keypress", h), a.off("resize", f), d.setRawMode(!1), d.pause(), a.write(`\x1B[2J\x1B[H\x1B[?25h
1552
+ `), u();
1553
+ }, f = () => {
1554
+ l();
1555
+ }, h = (g, _) => {
1556
+ if (o)
1553
1557
  return;
1554
1558
  if (_.ctrl && _.name === "c") {
1555
- u();
1559
+ m();
1556
1560
  return;
1557
1561
  }
1558
1562
  if (_.name === "escape" || _.name === "q") {
1559
- u();
1563
+ m();
1560
1564
  return;
1561
1565
  }
1562
1566
  if (_.name === "up" || _.name === "down") {
1563
- r = Sa(r, _.name, a.length), o = "", s();
1567
+ i = La(i, _.name, r.length), s = "", l();
1564
1568
  return;
1565
1569
  }
1566
1570
  if (_.name !== "return" && _.name !== "enter")
1567
1571
  return;
1568
- const g = a[r];
1569
- if (!g) {
1570
- o = n("command.dot.empty"), s();
1572
+ const b = r[i];
1573
+ if (!b) {
1574
+ s = n("command.dot.empty"), l();
1571
1575
  return;
1572
1576
  }
1573
- i = !0, o = n("command.dot.archiving", { name: g.name }), s(), (async () => {
1577
+ o = !0, s = n("command.dot.archiving", { name: b.name }), l(), (async () => {
1574
1578
  try {
1575
- o = (await e(g)).message;
1576
- } catch (L) {
1577
- o = L.message;
1579
+ s = (await e(b)).message;
1580
+ } catch (T) {
1581
+ s = T.message;
1578
1582
  } finally {
1579
- i = !1, await c(g.name), s();
1583
+ o = !1, await c(b.name), l();
1580
1584
  }
1581
1585
  })();
1582
1586
  };
1583
- l.on("keypress", h), process.stdout.on("resize", m), s();
1587
+ d.on("keypress", h), a.on("resize", f), l();
1584
1588
  });
1585
1589
  }
1586
- function Da(e) {
1590
+ function Ma(e) {
1587
1591
  return n("command.archive.result.put.failed", {
1588
1592
  id: "-",
1589
1593
  input: e,
1590
1594
  message: "-"
1591
1595
  });
1592
1596
  }
1593
- async function Na(e, t, a) {
1597
+ async function Pa(e, t, a) {
1594
1598
  try {
1595
1599
  const r = await e.archiveService.put([t], {}), i = r.ok[0];
1596
1600
  if (i)
@@ -1612,7 +1616,7 @@ async function Na(e, t, a) {
1612
1616
  })
1613
1617
  } : {
1614
1618
  ok: !1,
1615
- message: Da(a)
1619
+ message: Ma(a)
1616
1620
  };
1617
1621
  } catch (r) {
1618
1622
  return {
@@ -1621,24 +1625,24 @@ async function Na(e, t, a) {
1621
1625
  };
1622
1626
  }
1623
1627
  }
1624
- async function Ma(e) {
1625
- if (!kt())
1628
+ async function Fa(e) {
1629
+ if (!xt())
1626
1630
  throw new Error(n("command.dot.error.no_tty"));
1627
1631
  let t = 0;
1628
- await Ta(async (a) => {
1629
- const r = await Na(e, a.fullPath, a.name);
1632
+ await Na(async (a) => {
1633
+ const r = await Pa(e, a.fullPath, a.name);
1630
1634
  return r.ok && (t += 1), r;
1631
- }), t > 0 && await F(e);
1635
+ }), t > 0 && await O(e);
1632
1636
  }
1633
- function Pa(e, t) {
1637
+ function Oa(e, t) {
1634
1638
  e.command(".").description(n("command.dot.description")).action(
1635
- () => P(async () => {
1636
- await Ma(t);
1639
+ () => F(async () => {
1640
+ await Fa(t);
1637
1641
  })
1638
1642
  );
1639
1643
  }
1640
- const Fa = "__ARCHIVER_CD__:";
1641
- function Oa(e, t) {
1644
+ const ja = "__ARCHIVER_CD__:";
1645
+ function Ya(e, t) {
1642
1646
  if (e.includes(`
1643
1647
  `) || e.includes("\r"))
1644
1648
  throw new Error(
@@ -1647,33 +1651,33 @@ function Oa(e, t) {
1647
1651
  })
1648
1652
  );
1649
1653
  }
1650
- function ja(e) {
1651
- return Oa(e, n("util.cd.label.archive_slot_path")), `${Fa}${e}`;
1654
+ function Ha(e) {
1655
+ return Ya(e, n("util.cd.label.archive_slot_path")), `${ja}${e}`;
1652
1656
  }
1653
- async function Ha(e) {
1654
- console.log(ja(e));
1657
+ async function qa(e) {
1658
+ console.log(Ha(e));
1655
1659
  }
1656
- const ne = ["status", "vault", "query", "entries", "action"], Se = {
1660
+ const oe = ["status", "vault", "query", "entries", "action"], Le = {
1657
1661
  rows: 12,
1658
1662
  columns: 56
1659
1663
  };
1660
- function et(e) {
1664
+ function at(e) {
1661
1665
  return n(e === "enter" ? "command.list.interactive.action.enter" : "command.list.interactive.action.restore");
1662
1666
  }
1663
- function ve(e) {
1667
+ function he(e) {
1664
1668
  return n(e === "archived" ? "command.list.interactive.filter.status.archived" : e === "restored" ? "command.list.interactive.filter.status.restored" : "command.list.interactive.filter.status.all");
1665
1669
  }
1666
- function xt(e) {
1667
- return j(
1670
+ function Et(e) {
1671
+ return Y(
1668
1672
  [
1669
- { value: "all", label: ve("all") },
1670
- { value: "archived", label: ve("archived") },
1671
- { value: "restored", label: ve("restored") }
1673
+ { value: "all", label: he("all") },
1674
+ { value: "archived", label: he("archived") },
1675
+ { value: "restored", label: he("restored") }
1672
1676
  ],
1673
1677
  e
1674
1678
  );
1675
1679
  }
1676
- function qa(e) {
1680
+ function Ba(e) {
1677
1681
  const t = [{ value: "all", label: n("command.list.interactive.filter.vault.all") }], a = /* @__PURE__ */ new Set(), r = [...e].sort((i, o) => i.vaultId - o.vaultId);
1678
1682
  for (const i of r)
1679
1683
  a.has(i.vaultId) || (a.add(i.vaultId), t.push({
@@ -1682,36 +1686,36 @@ function qa(e) {
1682
1686
  }));
1683
1687
  return t;
1684
1688
  }
1685
- function Ct(e, t) {
1686
- return j(e, t);
1689
+ function At(e, t) {
1690
+ return Y(e, t);
1687
1691
  }
1688
- function Ya(e, t) {
1692
+ function Ua(e, t) {
1689
1693
  return e.find((a) => a.value === t)?.label ?? n("command.list.interactive.filter.vault.all");
1690
1694
  }
1691
- function He(e, t) {
1692
- return j(
1695
+ function qe(e, t) {
1696
+ return Y(
1693
1697
  [
1694
- { value: "enter", label: et("enter"), disabled: !Me(e, "enter") },
1695
- { value: "restore", label: et("restore"), disabled: !Me(e, "restore") }
1698
+ { value: "enter", label: at("enter"), disabled: !Fe(e, "enter") },
1699
+ { value: "restore", label: at("restore"), disabled: !Fe(e, "restore") }
1696
1700
  ],
1697
1701
  t
1698
1702
  );
1699
1703
  }
1700
- function Ve(e, t) {
1701
- return U(He(e, t))?.value ?? t;
1704
+ function Te(e, t) {
1705
+ return z(qe(e, t))?.value ?? t;
1702
1706
  }
1703
- function Ba(e, t, a) {
1704
- const r = He(e, t), i = X(r, a);
1705
- return U(i)?.value ?? t;
1707
+ function za(e, t, a) {
1708
+ const r = qe(e, t), i = Z(r, a);
1709
+ return z(i)?.value ?? t;
1706
1710
  }
1707
- function Ua(e, t) {
1708
- const a = t === "left" ? -1 : 1, r = ne.indexOf(e);
1709
- return r === -1 ? ne[0] : ne[(r + a + ne.length) % ne.length] ?? e;
1711
+ function Wa(e, t) {
1712
+ const a = t === "left" ? -1 : 1, r = oe.indexOf(e);
1713
+ return r === -1 ? oe[0] : oe[(r + a + oe.length) % oe.length] ?? e;
1710
1714
  }
1711
- function za(e, t, a) {
1715
+ function Ja(e, t, a) {
1712
1716
  return a <= 0 ? 0 : t === "up" ? (e - 1 + a) % a : (e + 1) % a;
1713
1717
  }
1714
- function Wa(e, t) {
1718
+ function Ga(e, t) {
1715
1719
  if (!t)
1716
1720
  return !0;
1717
1721
  let a = 0;
@@ -1721,11 +1725,11 @@ function Wa(e, t) {
1721
1725
  return !0;
1722
1726
  return !1;
1723
1727
  }
1724
- function tt(e, t, a, r) {
1728
+ function rt(e, t, a, r) {
1725
1729
  const i = r.trim();
1726
- return e.filter((o) => t === "archived" && o.status !== R.Archived || t === "restored" && o.status !== R.Restored || a !== "all" && o.vaultId !== a ? !1 : Wa(o.title, i));
1730
+ return e.filter((o) => t === "archived" && o.status !== S.Archived || t === "restored" && o.status !== S.Restored || a !== "all" && o.vaultId !== a ? !1 : Ga(o.title, i));
1727
1731
  }
1728
- function at(e, t, a) {
1732
+ function it(e, t, a) {
1729
1733
  if (e.length === 0)
1730
1734
  return 0;
1731
1735
  if (a !== void 0) {
@@ -1735,29 +1739,30 @@ function at(e, t, a) {
1735
1739
  }
1736
1740
  return Math.min(t, e.length - 1);
1737
1741
  }
1738
- function Ja(e) {
1742
+ function Ka(e) {
1739
1743
  const {
1740
1744
  entries: t,
1741
1745
  filteredEntries: a,
1742
1746
  selectedIndex: r,
1743
1747
  statusFilter: i,
1744
1748
  vaultFilter: o,
1745
- vaultOptions: c,
1746
- queryState: s,
1749
+ vaultOptions: s,
1750
+ queryState: c,
1747
1751
  focus: l,
1748
1752
  action: d,
1749
- note: u
1750
- } = e, m = a[r], h = oe({
1751
- rows: process.stdout.rows,
1752
- columns: process.stdout.columns
1753
+ note: u,
1754
+ output: m
1755
+ } = e, f = a[r], h = se({
1756
+ rows: m.rows,
1757
+ columns: m.columns
1753
1758
  });
1754
- if (!ke(h, Se)) {
1755
- const q = B({
1759
+ if (!Ee(h, Le)) {
1760
+ const q = U({
1756
1761
  contentLines: [
1757
1762
  v.bold(n("ui.screen.too_small.title")),
1758
1763
  n("ui.screen.too_small.required", {
1759
- minColumns: Se.columns,
1760
- minRows: Se.rows
1764
+ minColumns: Le.columns,
1765
+ minRows: Le.rows
1761
1766
  }),
1762
1767
  n("ui.screen.too_small.current", {
1763
1768
  columns: h.columns,
@@ -1768,217 +1773,218 @@ function Ja(e) {
1768
1773
  statusLine: "",
1769
1774
  rows: h.rows
1770
1775
  });
1771
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(q.join(`
1776
+ m.write("\x1B[2J\x1B[H\x1B[?25l"), m.write(q.join(`
1772
1777
  `));
1773
1778
  return;
1774
1779
  }
1775
- const f = h.rows, _ = xt(i), g = Ct(c, o), L = He(m, d), C = {
1780
+ const g = h.rows, _ = Et(i), b = At(s, o), T = qe(f, d), E = {
1776
1781
  status: n("command.list.interactive.filter.status.label"),
1777
1782
  vault: n("command.list.interactive.filter.vault.label"),
1778
1783
  query: n("command.list.interactive.filter.query.label")
1779
- }, E = Math.max(
1780
- ee(C.status),
1781
- ee(C.vault),
1782
- ee(C.query)
1783
- ), A = (q, z, se) => {
1784
- const ce = l === q, le = ce ? v.cyan(">") : " ", re = `${je(z, E)}: ${se}`;
1785
- return ce ? `${le} ${v.bold(re)}` : `${le} ${re}`;
1784
+ }, A = Math.max(
1785
+ te(E.status),
1786
+ te(E.vault),
1787
+ te(E.query)
1788
+ ), R = (q, W, ce) => {
1789
+ const le = l === q, de = le ? v.cyan(">") : " ", ie = `${He(W, A)}: ${ce}`;
1790
+ return le ? `${de} ${v.bold(ie)}` : `${de} ${ie}`;
1786
1791
  }, $ = [
1787
- A("status", C.status, te(_, l === "status")),
1788
- A("vault", C.vault, te(g, l === "vault")),
1789
- A(
1792
+ R("status", E.status, ae(_, l === "status")),
1793
+ R("vault", E.vault, ae(b, l === "vault")),
1794
+ R(
1790
1795
  "query",
1791
- C.query,
1792
- wt(s, l === "query", n("command.list.interactive.filter.query.placeholder"))
1796
+ E.query,
1797
+ yt(c, l === "query", n("command.list.interactive.filter.query.placeholder"))
1793
1798
  ),
1794
1799
  ""
1795
- ], T = Math.max(f - $.length - 2 - 2, 2), Z = Math.max(Math.floor(T / 2), 1), Tt = Math.floor(Z / 2), Dt = Math.max(a.length - Z, 0), Ye = Math.min(Math.max(r - Tt, 0), Dt), Nt = Math.min(Ye + Z, a.length), H = [...$];
1800
+ ], D = Math.max(g - $.length - 2 - 2, 2), Q = Math.max(Math.floor(D / 2), 1), Nt = Math.floor(Q / 2), Mt = Math.max(a.length - Q, 0), Ue = Math.min(Math.max(r - Nt, 0), Mt), Pt = Math.min(Ue + Q, a.length), H = [...$];
1796
1801
  if (a.length === 0)
1797
1802
  H.push(v.dim(n("command.list.interactive.empty_filtered")));
1798
1803
  else
1799
- for (let q = Ye; q < Nt; q += 1) {
1800
- const z = a[q];
1801
- if (!z)
1804
+ for (let q = Ue; q < Pt; q += 1) {
1805
+ const W = a[q];
1806
+ if (!W)
1802
1807
  continue;
1803
- const se = q === r, ce = se ? l === "entries" ? v.cyan(">") : v.green(">") : " ", le = z.status === R.Archived ? v.green("A") : v.gray("R"), re = `${ce} [${String(z.id).padStart(4, " ")}] ${le} ${z.title}`, Be = ` ${v.dim(z.path)}`;
1804
- se ? (H.push(v.bold(re)), H.push(v.cyan(Be))) : (H.push(re), H.push(Be));
1808
+ const ce = q === r, le = ce ? l === "entries" ? v.cyan(">") : v.green(">") : " ", de = W.status === S.Archived ? v.green("A") : v.gray("R"), ie = `${le} [${String(W.id).padStart(4, " ")}] ${de} ${W.title}`, ze = ` ${v.dim(W.path)}`;
1809
+ ce ? (H.push(v.bold(ie)), H.push(v.cyan(ze))) : (H.push(ie), H.push(ze));
1805
1810
  }
1806
- H.push(""), H.push(A("action", `${n("command.list.interactive.action_prefix")}:`, te(L, l === "action")));
1807
- const Mt = n("command.list.interactive.hint", {
1808
- tab: V(n("command.list.interactive.key.tab")),
1809
- upDown: V(n("command.list.interactive.key.up_down")),
1810
- leftRight: V(n("command.list.interactive.key.left_right")),
1811
- type: V(n("command.list.interactive.key.type")),
1812
- enter: V(n("command.list.interactive.key.enter")),
1813
- cancel: V(n("command.list.interactive.key.cancel"))
1814
- }), Pt = s.value.trim() || n("command.list.interactive.summary.query_empty"), Ft = n("command.list.interactive.summary", {
1811
+ H.push(""), H.push(R("action", `${n("command.list.interactive.action_prefix")}:`, ae(T, l === "action")));
1812
+ const Ft = n("command.list.interactive.hint", {
1813
+ tab: L(n("command.list.interactive.key.tab")),
1814
+ upDown: L(n("command.list.interactive.key.up_down")),
1815
+ leftRight: L(n("command.list.interactive.key.left_right")),
1816
+ type: L(n("command.list.interactive.key.type")),
1817
+ enter: L(n("command.list.interactive.key.enter")),
1818
+ cancel: L(n("command.list.interactive.key.cancel"))
1819
+ }), Ot = c.value.trim() || n("command.list.interactive.summary.query_empty"), jt = n("command.list.interactive.summary", {
1815
1820
  matched: a.length,
1816
1821
  total: t.length,
1817
- status: ve(i),
1818
- vault: Ya(c, o),
1819
- query: Pt
1820
- }), Ot = u ? v.yellow(u) : v.dim(Ft), jt = B({
1822
+ status: he(i),
1823
+ vault: Ua(s, o),
1824
+ query: Ot
1825
+ }), Yt = u ? v.yellow(u) : v.dim(jt), Ht = U({
1821
1826
  contentLines: H,
1822
- hintLine: Mt,
1823
- statusLine: Ot,
1824
- rows: f
1827
+ hintLine: Ft,
1828
+ statusLine: Yt,
1829
+ rows: g
1825
1830
  });
1826
- process.stdout.write("\x1B[2J\x1B[H\x1B[?25l"), process.stdout.write(jt.join(`
1831
+ m.write("\x1B[2J\x1B[H\x1B[?25l"), m.write(Ht.join(`
1827
1832
  `));
1828
1833
  }
1829
- function Et() {
1830
- return xe();
1834
+ function Rt() {
1835
+ return ke();
1831
1836
  }
1832
- function Me(e, t) {
1833
- return e && (t === "enter" || t === "restore") ? e.status === R.Archived : !1;
1837
+ function Fe(e, t) {
1838
+ return e && (t === "enter" || t === "restore") ? e.status === S.Archived : !1;
1834
1839
  }
1835
- async function Ga(e, t) {
1836
- if (e.length === 0 || !Et())
1840
+ async function Xa(e, t) {
1841
+ if (e.length === 0 || !Rt())
1837
1842
  return null;
1838
- const a = e.map((C) => ({ ...C })), r = process.stdin, i = qa(a);
1839
- let o = "archived", c = "all", s = _t(""), l = "entries", d = tt(a, o, c, s.value), u = at(d, 0), m = Ve(d[u], "enter"), h = !1, f = "";
1843
+ const a = e.map((E) => ({ ...E })), r = xe(), i = process.stdin, o = Ba(a);
1844
+ let s = "archived", c = "all", l = It(""), d = "entries", u = rt(a, s, c, l.value), m = it(u, 0), f = Te(u[m], "enter"), h = !1, g = "";
1840
1845
  const _ = () => {
1841
- const C = d[u]?.id;
1842
- d = tt(a, o, c, s.value), u = at(d, u, C), m = Ve(d[u], m);
1843
- }, g = () => {
1844
- Ja({
1846
+ const E = u[m]?.id;
1847
+ u = rt(a, s, c, l.value), m = it(u, m, E), f = Te(u[m], f);
1848
+ }, b = () => {
1849
+ Ka({
1845
1850
  entries: a,
1846
- filteredEntries: d,
1847
- selectedIndex: u,
1848
- statusFilter: o,
1851
+ filteredEntries: u,
1852
+ selectedIndex: m,
1853
+ statusFilter: s,
1849
1854
  vaultFilter: c,
1850
- vaultOptions: i,
1851
- queryState: s,
1852
- focus: l,
1853
- action: m,
1854
- note: f
1855
+ vaultOptions: o,
1856
+ queryState: l,
1857
+ focus: d,
1858
+ action: f,
1859
+ note: g,
1860
+ output: r
1855
1861
  });
1856
- }, L = (C) => {
1857
- const E = d[u];
1858
- if (!E) {
1859
- f = n("command.list.interactive.empty_filtered"), g();
1862
+ }, T = (E) => {
1863
+ const A = u[m];
1864
+ if (!A) {
1865
+ g = n("command.list.interactive.empty_filtered"), b();
1860
1866
  return;
1861
1867
  }
1862
- const A = Ve(E, m);
1863
- if (!Me(E, A)) {
1864
- f = n("command.list.interactive.note.restored_unavailable"), g();
1868
+ const R = Te(A, f);
1869
+ if (!Fe(A, R)) {
1870
+ g = n("command.list.interactive.note.restored_unavailable"), b();
1865
1871
  return;
1866
1872
  }
1867
- if (A === "restore") {
1873
+ if (R === "restore") {
1868
1874
  h = !0, (async () => {
1869
1875
  try {
1870
- const $ = await t({ entry: E, action: A });
1876
+ const $ = await t({ entry: A, action: R });
1871
1877
  if ($.ok) {
1872
- const D = a.find((b) => b.id === E.id);
1873
- D && (D.status = R.Restored);
1878
+ const N = a.find((C) => C.id === A.id);
1879
+ N && (N.status = S.Restored);
1874
1880
  }
1875
- f = $.message;
1881
+ g = $.message;
1876
1882
  } catch ($) {
1877
- f = $.message;
1883
+ g = $.message;
1878
1884
  } finally {
1879
- h = !1, _(), g();
1885
+ h = !1, _(), b();
1880
1886
  }
1881
1887
  })();
1882
1888
  return;
1883
1889
  }
1884
- C({ entry: E, action: A });
1890
+ E({ entry: A, action: R });
1885
1891
  };
1886
- return Ie.emitKeypressEvents(r), r.setRawMode(!0), r.resume(), new Promise((C) => {
1887
- const E = (D) => {
1888
- r.off("keypress", $), process.stdout.off("resize", A), r.setRawMode(!1), r.pause(), process.stdout.write(`\x1B[2J\x1B[H\x1B[?25h
1889
- `), C(D);
1890
- }, A = () => {
1891
- g();
1892
- }, $ = (D, b) => {
1892
+ return be.emitKeypressEvents(i), i.setRawMode(!0), i.resume(), new Promise((E) => {
1893
+ const A = (N) => {
1894
+ i.off("keypress", $), r.off("resize", R), i.setRawMode(!1), i.pause(), r.write(`\x1B[2J\x1B[H\x1B[?25h
1895
+ `), E(N);
1896
+ }, R = () => {
1897
+ b();
1898
+ }, $ = (N, C) => {
1893
1899
  if (!h) {
1894
- if (b.ctrl && b.name === "c") {
1895
- E(null);
1900
+ if (C.ctrl && C.name === "c") {
1901
+ A(null);
1896
1902
  return;
1897
1903
  }
1898
- if (b.name === "escape") {
1899
- E(null);
1904
+ if (C.name === "escape") {
1905
+ A(null);
1900
1906
  return;
1901
1907
  }
1902
- if (b.name === "q" && l !== "query") {
1903
- E(null);
1908
+ if (C.name === "q" && d !== "query") {
1909
+ A(null);
1904
1910
  return;
1905
1911
  }
1906
- if (b.name === "tab") {
1907
- l = Ua(l, b.shift ? "left" : "right"), f = "", g();
1912
+ if (C.name === "tab") {
1913
+ d = Wa(d, C.shift ? "left" : "right"), g = "", b();
1908
1914
  return;
1909
1915
  }
1910
- if (b.name === "return" || b.name === "enter") {
1911
- L(E);
1916
+ if (C.name === "return" || C.name === "enter") {
1917
+ T(A);
1912
1918
  return;
1913
1919
  }
1914
- if (l === "entries" && (b.name === "up" || b.name === "down")) {
1915
- u = za(u, b.name, d.length), f = "", g();
1920
+ if (d === "entries" && (C.name === "up" || C.name === "down")) {
1921
+ m = Ja(m, C.name, u.length), g = "", b();
1916
1922
  return;
1917
1923
  }
1918
- if (l === "status" && (b.name === "left" || b.name === "right")) {
1919
- const T = X(xt(o), b.name);
1920
- o = U(T)?.value ?? o, _(), f = "", g();
1924
+ if (d === "status" && (C.name === "left" || C.name === "right")) {
1925
+ const D = Z(Et(s), C.name);
1926
+ s = z(D)?.value ?? s, _(), g = "", b();
1921
1927
  return;
1922
1928
  }
1923
- if (l === "vault" && (b.name === "left" || b.name === "right")) {
1924
- const T = X(Ct(i, c), b.name);
1925
- c = U(T)?.value ?? c, _(), f = "", g();
1929
+ if (d === "vault" && (C.name === "left" || C.name === "right")) {
1930
+ const D = Z(At(o, c), C.name);
1931
+ c = z(D)?.value ?? c, _(), g = "", b();
1926
1932
  return;
1927
1933
  }
1928
- if ((l === "action" || l === "entries") && (b.name === "left" || b.name === "right")) {
1929
- m = Ba(d[u], m, b.name), f = "", g();
1934
+ if ((d === "action" || d === "entries") && (C.name === "left" || C.name === "right")) {
1935
+ f = za(u[m], f, C.name), g = "", b();
1930
1936
  return;
1931
1937
  }
1932
- if (l === "query") {
1933
- const T = _e(s, D, b);
1934
- if (s = T.state, T.action === "cancel") {
1935
- E(null);
1938
+ if (d === "query") {
1939
+ const D = we(l, N, C);
1940
+ if (l = D.state, D.action === "cancel") {
1941
+ A(null);
1936
1942
  return;
1937
1943
  }
1938
- _(), f = "", g();
1944
+ _(), g = "", b();
1939
1945
  return;
1940
1946
  }
1941
- if (D) {
1942
- const T = _e(s, D, {});
1943
- (T.state.value !== s.value || T.state.cursor !== s.cursor) && (l = "query", s = T.state, _(), f = "", g());
1947
+ if (N) {
1948
+ const D = we(l, N, {});
1949
+ (D.state.value !== l.value || D.state.cursor !== l.cursor) && (d = "query", l = D.state, _(), g = "", b());
1944
1950
  }
1945
1951
  }
1946
1952
  };
1947
- r.on("keypress", $), process.stdout.on("resize", A), g();
1953
+ i.on("keypress", $), r.on("resize", R), b();
1948
1954
  });
1949
1955
  }
1950
- function qe(e, t) {
1956
+ function Be(e, t) {
1951
1957
  return e.vaultId === w.Vault.id ? e.item : `${e.vaultName}${t}${e.item}`;
1952
1958
  }
1953
- function Ka(e) {
1959
+ function Za(e) {
1954
1960
  return String(e).padStart(4, "0");
1955
1961
  }
1956
- function At(e) {
1957
- return e.status === R.Archived ? "A" : "R";
1962
+ function St(e) {
1963
+ return e.status === S.Archived ? "A" : "R";
1958
1964
  }
1959
- function Xa(e, t) {
1960
- const a = sa(At(e));
1961
- return `[${Ka(e.id)}] ${a} ${qe(e, t)}`;
1965
+ function Qa(e, t) {
1966
+ const a = la(St(e));
1967
+ return `[${Za(e.id)}] ${a} ${Be(e, t)}`;
1962
1968
  }
1963
- function Za(e, t) {
1964
- return e.map((a) => Xa(a, t)).join(`
1969
+ function er(e, t) {
1970
+ return e.map((a) => Qa(a, t)).join(`
1965
1971
  `);
1966
1972
  }
1967
- function Qa(e, t) {
1968
- return e.map((a) => `${a.id} ${At(a)} ${qe(a, t)}`).join(`
1973
+ function tr(e, t) {
1974
+ return e.map((a) => `${a.id} ${St(a)} ${Be(a, t)}`).join(`
1969
1975
  `);
1970
1976
  }
1971
- function er(e, t) {
1977
+ function ar(e, t) {
1972
1978
  return e.map((a) => ({
1973
1979
  id: a.id,
1974
1980
  status: a.status,
1975
- title: qe(a, t),
1981
+ title: Be(a, t),
1976
1982
  path: a.displayPath,
1977
1983
  vaultId: a.vaultId,
1978
1984
  vaultName: a.vaultName
1979
1985
  }));
1980
1986
  }
1981
- async function tr(e, t) {
1987
+ async function rr(e, t) {
1982
1988
  try {
1983
1989
  const a = await e.archiveService.restore([t.id]), r = a.ok[0];
1984
1990
  if (r)
@@ -2010,25 +2016,25 @@ async function tr(e, t) {
2010
2016
  };
2011
2017
  }
2012
2018
  }
2013
- async function ar(e, t) {
2019
+ async function ir(e, t) {
2014
2020
  const a = t.entry.id;
2015
2021
  if (t.action === "restore") {
2016
2022
  const i = await e.archiveService.restore([a]);
2017
2023
  for (const o of i.ok)
2018
- M(
2024
+ P(
2019
2025
  n("command.archive.result.restore.ok", {
2020
2026
  id: o.id,
2021
2027
  message: o.message
2022
2028
  })
2023
2029
  );
2024
2030
  for (const o of i.failed)
2025
- Q(
2031
+ ee(
2026
2032
  n("command.archive.result.restore.failed", {
2027
2033
  id: o.id ?? "-",
2028
2034
  message: o.message
2029
2035
  })
2030
2036
  );
2031
- me("restore", i), await F(e);
2037
+ ve("restore", i), await O(e);
2032
2038
  return;
2033
2039
  }
2034
2040
  const r = await e.archiveService.resolveCdTarget(String(a));
@@ -2045,41 +2051,41 @@ async function ar(e, t) {
2045
2051
  archiveId: r.archiveId
2046
2052
  }),
2047
2053
  { aid: r.archiveId, vid: r.vault.id }
2048
- ), await Ha(r.slotPath);
2054
+ ), await qa(r.slotPath);
2049
2055
  }
2050
- function rr(e, t) {
2056
+ function nr(e, t) {
2051
2057
  e.command("list").description(n("command.list.description")).option("-p, --plain", n("command.list.option.plain")).action(
2052
- (a) => P(async () => {
2058
+ (a) => F(async () => {
2053
2059
  const r = await t.archiveService.listEntries({ all: !0 }), i = await t.archiveService.decorateEntries(r), o = await t.configService.getConfig();
2054
2060
  if (i.length === 0) {
2055
2061
  if (a.plain)
2056
2062
  return;
2057
- O(n("command.list.empty"));
2063
+ j(n("command.list.empty"));
2058
2064
  return;
2059
2065
  }
2060
2066
  if (a.plain) {
2061
- console.log(Qa(i, o.vaultItemSeparator));
2067
+ console.log(tr(i, o.vaultItemSeparator));
2062
2068
  return;
2063
2069
  }
2064
- if (!Et()) {
2065
- console.log(Za(i, o.vaultItemSeparator));
2070
+ if (!Rt()) {
2071
+ console.log(er(i, o.vaultItemSeparator));
2066
2072
  return;
2067
2073
  }
2068
- const c = await Ga(
2069
- er(i, o.vaultItemSeparator),
2070
- async ({ entry: s }) => tr(t, s)
2074
+ const s = await Xa(
2075
+ ar(i, o.vaultItemSeparator),
2076
+ async ({ entry: c }) => rr(t, c)
2071
2077
  );
2072
- if (!c) {
2073
- O(n("command.list.cancelled"));
2078
+ if (!s) {
2079
+ j(n("command.list.cancelled"));
2074
2080
  return;
2075
2081
  }
2076
- await ar(t, c);
2082
+ await ir(t, s);
2077
2083
  })
2078
2084
  );
2079
2085
  }
2080
- function ir(e, t) {
2086
+ function or(e, t) {
2081
2087
  e.command("log").description(n("command.log.description")).action(
2082
- () => P(async () => {
2088
+ () => F(async () => {
2083
2089
  const a = await t.logService.getLogs({ mode: "all" });
2084
2090
  if (a.length === 0)
2085
2091
  return;
@@ -2099,40 +2105,40 @@ function ir(e, t) {
2099
2105
  })
2100
2106
  );
2101
2107
  }
2102
- async function ae(e) {
2103
- await y.mkdir(e, { recursive: !0 });
2108
+ async function re(e) {
2109
+ await I.mkdir(e, { recursive: !0 });
2104
2110
  }
2105
- const S = (e) => y.access(e).then(() => !0).catch(() => !1), rt = (e) => y.realpath(e).catch(() => p.resolve(e)), nr = (e, t) => p.normalize(e) === p.normalize(t);
2106
- function Rt(e, t) {
2111
+ const V = (e) => I.access(e).then(() => !0).catch(() => !1), nt = (e) => I.realpath(e).catch(() => p.resolve(e)), sr = (e, t) => p.normalize(e) === p.normalize(t);
2112
+ function Vt(e, t) {
2107
2113
  const a = p.relative(p.resolve(e), p.resolve(t));
2108
2114
  return a.length > 0 && !a.startsWith("..") && !p.isAbsolute(a);
2109
2115
  }
2110
- function or(e, t) {
2111
- return nr(e, t) || Rt(e, t);
2116
+ function cr(e, t) {
2117
+ return sr(e, t) || Vt(e, t);
2112
2118
  }
2113
- async function he(e) {
2119
+ async function fe(e) {
2114
2120
  const t = p.dirname(e);
2115
- await ae(t), await S(e) || await y.writeFile(e, "", "utf8");
2121
+ await re(t), await V(e) || await I.writeFile(e, "", "utf8");
2116
2122
  }
2117
- async function we(e) {
2123
+ async function Ie(e) {
2118
2124
  try {
2119
- return await y.lstat(e);
2125
+ return await I.lstat(e);
2120
2126
  } catch (t) {
2121
2127
  if (t.code === "ENOENT")
2122
2128
  return;
2123
2129
  throw t;
2124
2130
  }
2125
2131
  }
2126
- async function sr(e) {
2132
+ async function lr(e) {
2127
2133
  try {
2128
- return (await y.readdir(e, { withFileTypes: !0 })).filter((a) => a.isDirectory()).map((a) => a.name);
2134
+ return (await I.readdir(e, { withFileTypes: !0 })).filter((a) => a.isDirectory()).map((a) => a.name);
2129
2135
  } catch (t) {
2130
2136
  if (t.code === "ENOENT")
2131
2137
  return [];
2132
2138
  throw t;
2133
2139
  }
2134
2140
  }
2135
- class St extends Error {
2141
+ class Lt extends Error {
2136
2142
  constructor(t) {
2137
2143
  super(
2138
2144
  n("service.vault.error.removed_exists", {
@@ -2141,7 +2147,7 @@ class St extends Error {
2141
2147
  ), this.name = "VaultRemovedExistsError";
2142
2148
  }
2143
2149
  }
2144
- class cr {
2150
+ class dr {
2145
2151
  constructor(t, a) {
2146
2152
  this.context = t, this.configService = a;
2147
2153
  }
@@ -2158,8 +2164,8 @@ class cr {
2158
2164
  name: w.Vault.name
2159
2165
  })
2160
2166
  );
2161
- const r = await this.context.loadVaults(), i = r.find((s) => s.name === a);
2162
- if (i?.status === N.Valid || i?.status === N.Protected)
2167
+ const r = await this.context.loadVaults(), i = r.find((c) => c.name === a);
2168
+ if (i?.status === M.Valid || i?.status === M.Protected)
2163
2169
  throw new Error(
2164
2170
  n("service.vault.error.exists", {
2165
2171
  name: a
@@ -2167,17 +2173,17 @@ class cr {
2167
2173
  );
2168
2174
  if (i?.status === "Removed") {
2169
2175
  if (!t.recoverRemoved)
2170
- throw new St(a);
2171
- return i.status = N.Valid, await this.context.ensureVaultDir(i.id), await this.context.saveVaults(r), t.activate && await this.configService.setCurrentVault(i.id), { vault: i, recovered: !0 };
2176
+ throw new Lt(a);
2177
+ return i.status = M.Valid, await this.context.ensureVaultDir(i.id), await this.context.saveVaults(r), t.activate && await this.configService.setCurrentVault(i.id), { vault: i, recovered: !0 };
2172
2178
  }
2173
- const c = {
2179
+ const s = {
2174
2180
  id: await this.context.nextAutoIncrement("vaultId"),
2175
2181
  name: a,
2176
2182
  remark: t.remark ?? "",
2177
- createdAt: Oe(),
2178
- status: N.Valid
2183
+ createdAt: Ye(),
2184
+ status: M.Valid
2179
2185
  };
2180
- return r.push(c), await this.context.saveVaults(r), await this.context.ensureVaultDir(c.id), t.activate && await this.configService.setCurrentVault(c.id), { vault: c, recovered: !1 };
2186
+ return r.push(s), await this.context.saveVaults(r), await this.context.ensureVaultDir(s.id), t.activate && await this.configService.setCurrentVault(s.id), { vault: s, recovered: !1 };
2181
2187
  }
2182
2188
  async useVault(t) {
2183
2189
  const a = await this.context.resolveVault(t, { includeRemoved: !1, fallbackCurrent: !1 });
@@ -2209,7 +2215,7 @@ class cr {
2209
2215
  name: r.name
2210
2216
  })
2211
2217
  );
2212
- return r.status = N.Valid, await this.context.ensureVaultDir(r.id), await this.context.saveVaults(a), r;
2218
+ return r.status = M.Valid, await this.context.ensureVaultDir(r.id), await this.context.saveVaults(a), r;
2213
2219
  }
2214
2220
  async renameVault(t, a) {
2215
2221
  const r = a.trim();
@@ -2221,7 +2227,7 @@ class cr {
2221
2227
  name: w.Vault.name
2222
2228
  })
2223
2229
  );
2224
- const i = await this.context.loadVaults(), o = i.find((s) => s.name === t || String(s.id) === t);
2230
+ const i = await this.context.loadVaults(), o = i.find((c) => c.name === t || String(c.id) === t);
2225
2231
  if (!o)
2226
2232
  throw new Error(
2227
2233
  n("service.vault.error.not_found", {
@@ -2234,7 +2240,7 @@ class cr {
2234
2240
  name: o.name
2235
2241
  })
2236
2242
  );
2237
- if (i.find((s) => s.name === r && s.id !== o.id))
2243
+ if (i.find((c) => c.name === r && c.id !== o.id))
2238
2244
  throw new Error(
2239
2245
  n("service.vault.error.name_conflict", {
2240
2246
  name: r
@@ -2253,42 +2259,42 @@ class cr {
2253
2259
  reference: t
2254
2260
  })
2255
2261
  );
2256
- if (a.id === w.Vault.id || a.status === N.Protected)
2262
+ if (a.id === w.Vault.id || a.status === M.Protected)
2257
2263
  throw new Error(n("service.vault.error.default_cannot_remove"));
2258
- if (a.status === N.Removed)
2264
+ if (a.status === M.Removed)
2259
2265
  throw new Error(
2260
2266
  n("service.vault.error.already_removed", {
2261
2267
  name: a.name
2262
2268
  })
2263
2269
  );
2264
- const r = await this.context.loadListEntries(), i = r.filter((d) => d.vaultId === a.id && d.status === R.Archived);
2270
+ const r = await this.context.loadListEntries(), i = r.filter((d) => d.vaultId === a.id && d.status === S.Archived);
2265
2271
  await this.context.ensureVaultDir(w.Vault.id), await this.validateMoveToDefault(i);
2266
2272
  const o = [];
2267
2273
  for (const d of i) {
2268
2274
  const u = this.context.archivePath(a.id, d.id), m = this.context.archivePath(w.Vault.id, d.id);
2269
- await y.rename(u, m), d.vaultId = w.Vault.id, o.push(d.id);
2275
+ await I.rename(u, m), d.vaultId = w.Vault.id, o.push(d.id);
2270
2276
  }
2271
- const c = await this.context.loadVaults(), s = c.find((d) => d.id === a.id);
2272
- if (!s)
2277
+ const s = await this.context.loadVaults(), c = s.find((d) => d.id === a.id);
2278
+ if (!c)
2273
2279
  throw new Error(
2274
2280
  n("service.vault.error.not_found_while_saving", {
2275
2281
  id: a.id
2276
2282
  })
2277
2283
  );
2278
- s.status = N.Removed, await this.context.saveListEntries(r), await this.context.saveVaults(c);
2284
+ c.status = M.Removed, await this.context.saveListEntries(r), await this.context.saveVaults(s);
2279
2285
  const l = await this.context.loadConfig();
2280
- return l.currentVaultId === a.id && (l.currentVaultId = w.Vault.id, await this.context.saveConfig(l)), { vault: s, movedArchiveIds: o };
2286
+ return l.currentVaultId === a.id && (l.currentVaultId = w.Vault.id, await this.context.saveConfig(l)), { vault: c, movedArchiveIds: o };
2281
2287
  }
2282
2288
  async validateMoveToDefault(t) {
2283
2289
  for (const a of t) {
2284
2290
  const r = this.context.archivePath(a.vaultId, a.id), i = this.context.archivePath(w.Vault.id, a.id);
2285
- if (!await S(r))
2291
+ if (!await V(r))
2286
2292
  throw new Error(
2287
2293
  n("service.vault.error.archived_object_missing", {
2288
2294
  path: r
2289
2295
  })
2290
2296
  );
2291
- if (await S(i))
2297
+ if (await V(i))
2292
2298
  throw new Error(
2293
2299
  n("service.vault.error.default_contains_archive_id", {
2294
2300
  id: a.id
@@ -2305,33 +2311,33 @@ class cr {
2305
2311
  }
2306
2312
  async listArchivedIdsInVault(t) {
2307
2313
  const a = this.context.vaultDir(t);
2308
- return await S(a) ? (await y.readdir(a, { withFileTypes: !0 })).filter((o) => o.isFile() || o.isDirectory() || o.isSymbolicLink()).map((o) => o.name).filter((o) => /^\d+$/.test(o)).map((o) => Number(o)).sort((o, c) => o - c) : [];
2314
+ return await V(a) ? (await I.readdir(a, { withFileTypes: !0 })).filter((o) => o.isFile() || o.isDirectory() || o.isSymbolicLink()).map((o) => o.name).filter((o) => /^\d+$/.test(o)).map((o) => Number(o)).sort((o, s) => o - s) : [];
2309
2315
  }
2310
2316
  getVaultDisplay(t) {
2311
2317
  return t.id === w.Vault.id ? `${t.name}(${t.id})` : `${t.name}(${t.id})`;
2312
2318
  }
2313
2319
  vaultRoot(t) {
2314
- return p.join(I.Dir.vaults, String(t.id));
2320
+ return p.join(y.Dir.vaults, String(t.id));
2315
2321
  }
2316
2322
  }
2317
- async function Vt(e) {
2318
- const t = Wt.createInterface({ input: Gt, output: Jt });
2323
+ async function Tt(e) {
2324
+ const t = Gt.createInterface({ input: Xt, output: Kt });
2319
2325
  try {
2320
2326
  return (await t.question(e)).trim();
2321
2327
  } finally {
2322
2328
  t.close();
2323
2329
  }
2324
2330
  }
2325
- async function it(e, t = !0) {
2326
- const a = (await Vt(e)).toLowerCase();
2331
+ async function ot(e, t = !0) {
2332
+ const a = (await Tt(e)).toLowerCase();
2327
2333
  return a ? ["y", "yes"].includes(a) : !t;
2328
2334
  }
2329
- function lr(e, t) {
2335
+ function ur(e, t) {
2330
2336
  const a = e.command("vault").description(n("command.vault.description"));
2331
2337
  a.command("use").description(n("command.vault.use.description")).argument("<name-or-id>", n("command.vault.use.argument")).action(
2332
- (r) => P(async () => {
2338
+ (r) => F(async () => {
2333
2339
  const i = await t.vaultService.useVault(r);
2334
- M(
2340
+ P(
2335
2341
  n("command.vault.use.updated", {
2336
2342
  name: i.name,
2337
2343
  id: i.id
@@ -2344,24 +2350,24 @@ function lr(e, t) {
2344
2350
  id: i.id
2345
2351
  }),
2346
2352
  { vid: i.id }
2347
- ), await F(t);
2353
+ ), await O(t);
2348
2354
  })
2349
2355
  ), a.command("create").description(n("command.vault.create.description")).argument("<name>", n("command.vault.create.argument")).option("-r, --remark <remark>", n("command.vault.create.option.remark")).option("-a, --activate", n("command.vault.create.option.activate")).action(
2350
- (r, i) => P(async () => {
2356
+ (r, i) => F(async () => {
2351
2357
  let o = !1;
2352
- const c = async (s) => {
2358
+ const s = async (c) => {
2353
2359
  const l = await t.vaultService.createVault({
2354
2360
  name: r,
2355
2361
  remark: i.remark,
2356
2362
  activate: i.activate,
2357
- recoverRemoved: s
2363
+ recoverRemoved: c
2358
2364
  });
2359
- o = l.recovered, M(
2365
+ o = l.recovered, P(
2360
2366
  n(o ? "command.vault.create.recovered" : "command.vault.create.created", {
2361
2367
  name: l.vault.name,
2362
2368
  id: l.vault.id
2363
2369
  })
2364
- ), i.activate && M(
2370
+ ), i.activate && P(
2365
2371
  n("command.vault.create.activated", {
2366
2372
  name: l.vault.name,
2367
2373
  id: l.vault.id
@@ -2385,51 +2391,51 @@ function lr(e, t) {
2385
2391
  );
2386
2392
  };
2387
2393
  try {
2388
- await c(!1);
2389
- } catch (s) {
2390
- if (s instanceof St) {
2391
- if (!await it(
2394
+ await s(!1);
2395
+ } catch (c) {
2396
+ if (c instanceof Lt) {
2397
+ if (!await ot(
2392
2398
  n("command.vault.create.confirm_recover", {
2393
2399
  name: r
2394
2400
  })
2395
2401
  )) {
2396
- Ce(n("command.vault.operation.cancelled"));
2402
+ Ae(n("command.vault.operation.cancelled"));
2397
2403
  return;
2398
2404
  }
2399
- await c(!0);
2405
+ await s(!0);
2400
2406
  } else
2401
- throw s;
2407
+ throw c;
2402
2408
  }
2403
- await F(t);
2409
+ await O(t);
2404
2410
  })
2405
2411
  ), a.command("remove").description(n("command.vault.remove.description")).argument("<name-or-id>", n("command.vault.remove.argument")).action(
2406
- (r) => P(async () => {
2407
- if (!await it(
2412
+ (r) => F(async () => {
2413
+ if (!await ot(
2408
2414
  n("command.vault.remove.confirm", {
2409
2415
  nameOrId: r
2410
2416
  })
2411
2417
  )) {
2412
- Ce(n("command.vault.operation.cancelled"));
2418
+ Ae(n("command.vault.operation.cancelled"));
2413
2419
  return;
2414
2420
  }
2415
2421
  const o = Math.random().toString(36).slice(2, 8).toUpperCase();
2416
- if (await Vt(
2422
+ if (await Tt(
2417
2423
  n("command.vault.remove.verify_prompt", {
2418
2424
  verifyCode: o
2419
2425
  })
2420
2426
  ) !== o) {
2421
- Ce(n("command.vault.remove.verify_mismatch"));
2427
+ Ae(n("command.vault.remove.verify_mismatch"));
2422
2428
  return;
2423
2429
  }
2424
- const s = await t.vaultService.removeVault(r);
2425
- M(
2430
+ const c = await t.vaultService.removeVault(r);
2431
+ P(
2426
2432
  n("command.vault.remove.done", {
2427
- name: s.vault.name,
2428
- id: s.vault.id
2433
+ name: c.vault.name,
2434
+ id: c.vault.id
2429
2435
  })
2430
- ), s.movedArchiveIds.length > 0 && O(
2436
+ ), c.movedArchiveIds.length > 0 && j(
2431
2437
  n("command.vault.remove.moved_to_default", {
2432
- count: s.movedArchiveIds.length,
2438
+ count: c.movedArchiveIds.length,
2433
2439
  name: w.Vault.name
2434
2440
  })
2435
2441
  ), await t.auditLogger.log(
@@ -2441,16 +2447,16 @@ function lr(e, t) {
2441
2447
  source: "u"
2442
2448
  },
2443
2449
  n("command.vault.remove.done", {
2444
- name: s.vault.name,
2445
- id: s.vault.id
2450
+ name: c.vault.name,
2451
+ id: c.vault.id
2446
2452
  }),
2447
- { vid: s.vault.id }
2448
- ), await F(t);
2453
+ { vid: c.vault.id }
2454
+ ), await O(t);
2449
2455
  })
2450
2456
  ), a.command("recover").description(n("command.vault.recover.description")).argument("<name-or-id>", n("command.vault.recover.argument")).action(
2451
- (r) => P(async () => {
2457
+ (r) => F(async () => {
2452
2458
  const i = await t.vaultService.recoverVault(r);
2453
- M(
2459
+ P(
2454
2460
  n("command.vault.recover.done", {
2455
2461
  name: i.name,
2456
2462
  id: i.id
@@ -2468,12 +2474,12 @@ function lr(e, t) {
2468
2474
  id: i.id
2469
2475
  }),
2470
2476
  { vid: i.id }
2471
- ), await F(t);
2477
+ ), await O(t);
2472
2478
  })
2473
2479
  ), a.command("rename").description(n("command.vault.rename.description")).argument("<old>", n("command.vault.rename.argument.old")).argument("<new>", n("command.vault.rename.argument.new")).action(
2474
- (r, i) => P(async () => {
2480
+ (r, i) => F(async () => {
2475
2481
  const o = await t.vaultService.renameVault(r, i);
2476
- M(
2482
+ P(
2477
2483
  n("command.vault.rename.done", {
2478
2484
  name: o.name,
2479
2485
  id: o.id
@@ -2491,26 +2497,26 @@ function lr(e, t) {
2491
2497
  id: o.id
2492
2498
  }),
2493
2499
  { vid: o.id }
2494
- ), await F(t);
2500
+ ), await O(t);
2495
2501
  })
2496
2502
  ), a.command("list").description(n("command.vault.list.description")).option("-a, --all", n("command.vault.list.option.all")).action(
2497
- (r) => P(async () => {
2503
+ (r) => F(async () => {
2498
2504
  const i = await t.vaultService.listVaults(!!r.all);
2499
2505
  if (i.length === 0) {
2500
- O(n("command.vault.list.empty"));
2506
+ j(n("command.vault.list.empty"));
2501
2507
  return;
2502
2508
  }
2503
- const o = i.map((c) => `${String(c.id).padStart(3, " ")} ${c.name}`).join(`
2509
+ const o = i.map((s) => `${String(s.id).padStart(3, " ")} ${s.name}`).join(`
2504
2510
  `);
2505
2511
  console.log(o);
2506
2512
  })
2507
2513
  );
2508
2514
  }
2509
- function dr(e) {
2510
- const t = new zt();
2511
- return t.name(na).description(n("app.description")).version(e.version), la(t, e), lr(t, e), rr(t, e), Pa(t, e), ir(t, e), Ra(t, e), t;
2515
+ function mr(e) {
2516
+ const t = new Jt();
2517
+ return t.name(sa).description(n("app.description")).version(e.version), ua(t, e), ur(t, e), nr(t, e), Oa(t, e), or(t, e), Va(t, e), t;
2512
2518
  }
2513
- const nt = {
2519
+ const st = {
2514
2520
  startMarker: "# >>> archiver arv wrapper >>>",
2515
2521
  endMarker: "# <<< archiver arv wrapper <<<",
2516
2522
  functionPattern: /(^|\n)\s*(function\s+)?arv\s*(\(\))?\s*\{/m,
@@ -2540,7 +2546,7 @@ const nt = {
2540
2546
  fi
2541
2547
  return $status
2542
2548
  }`
2543
- }, ur = {
2549
+ }, vr = {
2544
2550
  startMarker: "# >>> archiver arv wrapper >>>",
2545
2551
  endMarker: "# <<< archiver arv wrapper <<<",
2546
2552
  functionPattern: /(^|\n)\s*function\s+arv\b/m,
@@ -2575,7 +2581,7 @@ const nt = {
2575
2581
  rm -f $target_tmp
2576
2582
  return $status
2577
2583
  end`
2578
- }, mr = {
2584
+ }, hr = {
2579
2585
  startMarker: "# >>> archiver arv wrapper >>>",
2580
2586
  endMarker: "# <<< archiver arv wrapper <<<",
2581
2587
  functionPattern: /(^|\r?\n)\s*function\s+arv\b/im,
@@ -2622,7 +2628,7 @@ end`
2622
2628
  $global:LASTEXITCODE = $status
2623
2629
  }`
2624
2630
  };
2625
- function vr(e) {
2631
+ function fr(e) {
2626
2632
  const t = p.basename(e).toLowerCase();
2627
2633
  if (t.includes("bash"))
2628
2634
  return "bash";
@@ -2633,17 +2639,17 @@ function vr(e) {
2633
2639
  if (t.includes("pwsh") || t.includes("powershell"))
2634
2640
  return "powershell";
2635
2641
  }
2636
- function ot(e) {
2642
+ function ct(e) {
2637
2643
  return e.endsWith(`
2638
2644
  `) ? e : `${e}
2639
2645
  `;
2640
2646
  }
2641
- function Lt(e) {
2647
+ function $t(e) {
2642
2648
  return `${e.startMarker}
2643
2649
  ${e.body}
2644
2650
  ${e.endMarker}`;
2645
2651
  }
2646
- function hr(e, t) {
2652
+ function gr(e, t) {
2647
2653
  const a = e.indexOf(t.startMarker);
2648
2654
  if (a === -1)
2649
2655
  return;
@@ -2654,8 +2660,8 @@ function hr(e, t) {
2654
2660
  end: r + t.endMarker.length
2655
2661
  };
2656
2662
  }
2657
- function fr(e, t) {
2658
- const a = Lt(t);
2663
+ function pr(e, t) {
2664
+ const a = $t(t);
2659
2665
  if (e.trim().length === 0)
2660
2666
  return `${a}
2661
2667
  `;
@@ -2667,107 +2673,107 @@ function fr(e, t) {
2667
2673
  return `${e}${r}${a}
2668
2674
  `;
2669
2675
  }
2670
- async function pr(e, t) {
2676
+ async function _r(e, t) {
2671
2677
  for (const a of t) {
2672
2678
  const r = p.join(e, a);
2673
- if (await S(r))
2679
+ if (await V(r))
2674
2680
  return r;
2675
2681
  }
2676
2682
  return p.join(e, t[0] ?? ".bashrc");
2677
2683
  }
2678
- async function de(e, t) {
2679
- await he(e);
2680
- const a = await y.readFile(e, "utf8"), r = hr(a, t);
2684
+ async function ue(e, t) {
2685
+ await fe(e);
2686
+ const a = await I.readFile(e, "utf8"), r = gr(a, t);
2681
2687
  if (r) {
2682
- const o = a.slice(r.start, r.end), c = Lt(t);
2683
- if (o === c)
2688
+ const o = a.slice(r.start, r.end), s = $t(t);
2689
+ if (o === s)
2684
2690
  return !1;
2685
- const s = `${a.slice(0, r.start)}${c}${a.slice(r.end)}`;
2686
- return await y.writeFile(e, ot(s), "utf8"), !0;
2691
+ const c = `${a.slice(0, r.start)}${s}${a.slice(r.end)}`;
2692
+ return await I.writeFile(e, ct(c), "utf8"), !0;
2687
2693
  }
2688
2694
  if (t.functionPattern.test(a))
2689
2695
  return !1;
2690
- const i = ot(fr(a, t));
2691
- return await y.writeFile(e, i, "utf8"), !0;
2696
+ const i = ct(pr(a, t));
2697
+ return await I.writeFile(e, i, "utf8"), !0;
2692
2698
  }
2693
- function gr(e, t) {
2699
+ function wr(e, t) {
2694
2700
  const a = p.resolve(t), r = p.resolve(e);
2695
2701
  if (r === a)
2696
2702
  return "~";
2697
2703
  const i = `${a}${p.sep}`;
2698
2704
  return r.startsWith(i) ? `~${r.slice(a.length)}` : e;
2699
2705
  }
2700
- function _r(e) {
2706
+ function Ir(e) {
2701
2707
  return `'${e.replaceAll("'", "'\\''")}'`;
2702
2708
  }
2703
- function wr(e) {
2709
+ function yr(e) {
2704
2710
  return `'${e.replaceAll("'", "''")}'`;
2705
2711
  }
2706
- async function yr(e) {
2712
+ async function br(e) {
2707
2713
  if (process.platform === "win32") {
2708
2714
  const t = [
2709
2715
  p.join(e, "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1"),
2710
2716
  p.join(e, "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1")
2711
2717
  ];
2712
2718
  for (const a of t)
2713
- if (await S(a))
2719
+ if (await V(a))
2714
2720
  return a;
2715
2721
  return t[0];
2716
2722
  }
2717
2723
  return p.join(e, ".config", "powershell", "Microsoft.PowerShell_profile.ps1");
2718
2724
  }
2719
- function ue(e, t, a, r) {
2720
- const i = gr(t, a);
2725
+ function me(e, t, a, r) {
2726
+ const i = wr(t, a);
2721
2727
  return e === "powershell" ? {
2722
2728
  installed: r,
2723
2729
  shell: e,
2724
2730
  profilePath: i,
2725
- reloadCommand: `. ${wr(t)}`
2731
+ reloadCommand: `. ${yr(t)}`
2726
2732
  } : {
2727
2733
  installed: r,
2728
2734
  shell: e,
2729
2735
  profilePath: i,
2730
- reloadCommand: `source ${_r(t)}`
2736
+ reloadCommand: `source ${Ir(t)}`
2731
2737
  };
2732
2738
  }
2733
- async function Ir(e = {}) {
2739
+ async function Cr(e = {}) {
2734
2740
  const t = e.env ?? process.env;
2735
2741
  if (t.ARCHIVER_DISABLE_SHELL_INIT === "1")
2736
2742
  return { installed: !1 };
2737
2743
  if (!(e.stdinIsTTY ?? !!process.stdin.isTTY))
2738
2744
  return { installed: !1 };
2739
- const r = e.homeDir ?? t.HOME ?? t.USERPROFILE ?? ht.homedir();
2745
+ const r = e.homeDir ?? t.HOME ?? t.USERPROFILE ?? gt.homedir();
2740
2746
  if (!r)
2741
2747
  return { installed: !1 };
2742
- const i = e.shellPath ?? t.SHELL ?? "", o = vr(i);
2748
+ const i = e.shellPath ?? t.SHELL ?? "", o = fr(i);
2743
2749
  if (!o)
2744
2750
  return { installed: !1 };
2745
2751
  try {
2746
2752
  if (o === "bash") {
2747
- const l = await pr(r, [".bashrc", ".bash_profile", ".profile"]), d = await de(l, nt);
2748
- return ue(o, l, r, d);
2753
+ const l = await _r(r, [".bashrc", ".bash_profile", ".profile"]), d = await ue(l, st);
2754
+ return me(o, l, r, d);
2749
2755
  }
2750
2756
  if (o === "zsh") {
2751
- const l = p.join(r, ".zshrc"), d = await de(l, nt);
2752
- return ue(o, l, r, d);
2757
+ const l = p.join(r, ".zshrc"), d = await ue(l, st);
2758
+ return me(o, l, r, d);
2753
2759
  }
2754
2760
  if (o === "fish") {
2755
2761
  const l = p.join(r, ".config", "fish", "functions", "arv.fish");
2756
- await ae(p.dirname(l));
2757
- const d = await de(l, ur);
2758
- return ue(o, l, r, d);
2762
+ await re(p.dirname(l));
2763
+ const d = await ue(l, vr);
2764
+ return me(o, l, r, d);
2759
2765
  }
2760
- const c = await yr(r);
2761
- await ae(p.dirname(c));
2762
- const s = await de(c, mr);
2763
- return ue(o, c, r, s);
2766
+ const s = await br(r);
2767
+ await re(p.dirname(s));
2768
+ const c = await ue(s, hr);
2769
+ return me(o, s, r, c);
2764
2770
  } catch {
2765
2771
  return { installed: !1 };
2766
2772
  }
2767
2773
  }
2768
2774
  async function ye(e) {
2769
2775
  try {
2770
- const t = await y.readFile(e, "utf8");
2776
+ const t = await I.readFile(e, "utf8");
2771
2777
  return t.trim() ? t.split(/\r?\n/).map((r) => r.trim()).filter((r) => r.length > 0).map((r, i) => {
2772
2778
  try {
2773
2779
  return JSON.parse(r);
@@ -2786,17 +2792,17 @@ async function ye(e) {
2786
2792
  throw t;
2787
2793
  }
2788
2794
  }
2789
- async function st(e, t) {
2795
+ async function lt(e, t) {
2790
2796
  const a = t.map((r) => JSON.stringify(r)).join(`
2791
2797
  `);
2792
- await y.writeFile(e, a.length > 0 ? `${a}
2798
+ await I.writeFile(e, a.length > 0 ? `${a}
2793
2799
  ` : "", "utf8");
2794
2800
  }
2795
- async function $t(e, t) {
2796
- await y.appendFile(e, `${JSON.stringify(t)}
2801
+ async function Dt(e, t) {
2802
+ await I.appendFile(e, `${JSON.stringify(t)}
2797
2803
  `, "utf8");
2798
2804
  }
2799
- function ct(e) {
2805
+ function dt(e) {
2800
2806
  return {
2801
2807
  currentVaultId: Number.isInteger(e.currentVaultId) && e.currentVaultId >= 0 ? e.currentVaultId : w.Config.currentVaultId,
2802
2808
  updateCheck: e.updateCheck === "off" ? "off" : "on",
@@ -2807,15 +2813,15 @@ function ct(e) {
2807
2813
  noCommandAction: e.noCommandAction === "help" || e.noCommandAction === "list" ? e.noCommandAction : "unknown"
2808
2814
  };
2809
2815
  }
2810
- function lt(e) {
2816
+ function ut(e) {
2811
2817
  return {
2812
2818
  logId: Number.isInteger(e.logId) && e.logId >= 0 ? e.logId : 0,
2813
2819
  vaultId: Number.isInteger(e.vaultId) && e.vaultId >= 0 ? e.vaultId : 0,
2814
2820
  archiveId: Number.isInteger(e.archiveId) && e.archiveId >= 0 ? e.archiveId : 0
2815
2821
  };
2816
2822
  }
2817
- function dt(e) {
2818
- const t = e.isDirectory === 1 ? 1 : 0, a = e.status === R.Restored ? R.Restored : R.Archived;
2823
+ function mt(e) {
2824
+ const t = e.isDirectory === 1 ? 1 : 0, a = e.status === S.Restored ? S.Restored : S.Archived;
2819
2825
  return {
2820
2826
  archivedAt: String(e.archivedAt ?? ""),
2821
2827
  status: a,
@@ -2828,8 +2834,8 @@ function dt(e) {
2828
2834
  remark: String(e.remark ?? "")
2829
2835
  };
2830
2836
  }
2831
- function ut(e) {
2832
- const t = N[e.status] ?? N.Valid;
2837
+ function vt(e) {
2838
+ const t = M[e.status] ?? M.Valid;
2833
2839
  return {
2834
2840
  id: e.id,
2835
2841
  name: e.name ?? "",
@@ -2838,35 +2844,35 @@ function ut(e) {
2838
2844
  status: t
2839
2845
  };
2840
2846
  }
2841
- class br {
2847
+ class kr {
2842
2848
  configCache;
2843
2849
  autoIncrCache;
2844
2850
  listCache;
2845
2851
  vaultCache;
2846
2852
  async init() {
2847
- for (const a of Object.values(I.Dir))
2848
- await ae(a);
2849
- await ae(this.vaultDir(w.Vault.id)), await ze(I.File.config, $e), await ze(I.File.autoIncr, Te), await he(I.File.list), await he(I.File.vaults), await he(I.File.log);
2853
+ for (const a of Object.values(y.Dir))
2854
+ await re(a);
2855
+ await re(this.vaultDir(w.Vault.id)), await Je(y.File.config, De), await Je(y.File.autoIncr, Ne), await fe(y.File.list), await fe(y.File.vaults), await fe(y.File.log);
2850
2856
  const t = await this.loadConfig();
2851
- t.currentVaultId === 0 || await S(this.vaultDir(t.currentVaultId)) || (t.currentVaultId = w.Vault.id, await this.saveConfig(t));
2857
+ t.currentVaultId === 0 || await V(this.vaultDir(t.currentVaultId)) || (t.currentVaultId = w.Vault.id, await this.saveConfig(t));
2852
2858
  }
2853
2859
  async loadConfig(t = !1) {
2854
2860
  if (this.configCache && !t)
2855
2861
  return this.configCache;
2856
- const a = await Ne(I.File.config, w.Config), r = ct({ ...w.Config, ...a });
2857
- return fe(r.language), this.configCache = r, r;
2862
+ const a = await Pe(y.File.config, w.Config), r = dt({ ...w.Config, ...a });
2863
+ return ge(r.language), this.configCache = r, r;
2858
2864
  }
2859
2865
  async saveConfig(t) {
2860
- this.configCache = ct(t), fe(this.configCache.language), await We(I.File.config, this.configCache, $e);
2866
+ this.configCache = dt(t), ge(this.configCache.language), await Ge(y.File.config, this.configCache, De);
2861
2867
  }
2862
2868
  async loadAutoIncr(t = !1) {
2863
2869
  if (this.autoIncrCache && !t)
2864
2870
  return this.autoIncrCache;
2865
- const a = await Ne(I.File.autoIncr, w.AutoIncr), r = lt({ ...w.AutoIncr, ...a });
2871
+ const a = await Pe(y.File.autoIncr, w.AutoIncr), r = ut({ ...w.AutoIncr, ...a });
2866
2872
  return this.autoIncrCache = r, r;
2867
2873
  }
2868
2874
  async saveAutoIncr(t) {
2869
- this.autoIncrCache = lt(t), await We(I.File.autoIncr, this.autoIncrCache, Te);
2875
+ this.autoIncrCache = ut(t), await Ge(y.File.autoIncr, this.autoIncrCache, Ne);
2870
2876
  }
2871
2877
  async nextAutoIncrement(t) {
2872
2878
  const a = await this.loadAutoIncr();
@@ -2875,28 +2881,28 @@ class br {
2875
2881
  async loadListEntries(t = !1) {
2876
2882
  if (this.listCache && !t)
2877
2883
  return this.listCache;
2878
- const a = await ye(I.File.list);
2879
- return this.listCache = a.map((r) => dt(r)).filter((r) => Number.isInteger(r.id) && r.id > 0), this.listCache.sort((r, i) => r.id - i.id), this.listCache;
2884
+ const a = await ye(y.File.list);
2885
+ return this.listCache = a.map((r) => mt(r)).filter((r) => Number.isInteger(r.id) && r.id > 0), this.listCache.sort((r, i) => r.id - i.id), this.listCache;
2880
2886
  }
2881
2887
  async saveListEntries(t) {
2882
- this.listCache = [...t].sort((a, r) => a.id - r.id), await st(I.File.list, this.listCache);
2888
+ this.listCache = [...t].sort((a, r) => a.id - r.id), await lt(y.File.list, this.listCache);
2883
2889
  }
2884
2890
  async appendListEntry(t) {
2885
- const a = dt(t);
2886
- this.listCache || (this.listCache = await this.loadListEntries()), this.listCache.push(a), this.listCache.sort((r, i) => r.id - i.id), await $t(I.File.list, a);
2891
+ const a = mt(t);
2892
+ this.listCache || (this.listCache = await this.loadListEntries()), this.listCache.push(a), this.listCache.sort((r, i) => r.id - i.id), await Dt(y.File.list, a);
2887
2893
  }
2888
2894
  async loadVaults(t = !1) {
2889
2895
  if (this.vaultCache && !t)
2890
2896
  return this.vaultCache;
2891
- const a = await ye(I.File.vaults);
2892
- return this.vaultCache = a.map((r) => ut(r)).filter((r) => Number.isInteger(r.id) && r.id > 0).sort((r, i) => r.id - i.id), this.vaultCache;
2897
+ const a = await ye(y.File.vaults);
2898
+ return this.vaultCache = a.map((r) => vt(r)).filter((r) => Number.isInteger(r.id) && r.id > 0).sort((r, i) => r.id - i.id), this.vaultCache;
2893
2899
  }
2894
2900
  async saveVaults(t) {
2895
- const a = t.map((r) => ut(r)).filter((r) => r.id > 0).sort((r, i) => r.id - i.id);
2896
- this.vaultCache = a, await st(I.File.vaults, a);
2901
+ const a = t.map((r) => vt(r)).filter((r) => r.id > 0).sort((r, i) => r.id - i.id);
2902
+ this.vaultCache = a, await lt(y.File.vaults, a);
2897
2903
  }
2898
2904
  async getVaults(t) {
2899
- const a = t?.includeRemoved ?? !1, r = t?.withDefault ?? !0, i = await this.loadVaults(), o = a ? i : i.filter((c) => c.status === "Valid");
2905
+ const a = t?.includeRemoved ?? !1, r = t?.withDefault ?? !0, i = await this.loadVaults(), o = a ? i : i.filter((s) => s.status === "Valid");
2900
2906
  return r ? [
2901
2907
  {
2902
2908
  ...w.Vault,
@@ -2907,22 +2913,22 @@ class br {
2907
2913
  }
2908
2914
  async resolveVault(t, a) {
2909
2915
  const r = a?.includeRemoved ?? !1, i = a?.fallbackCurrent ?? !0, o = await this.getVaults({ includeRemoved: !0, withDefault: !0 });
2910
- let c = t;
2911
- if ((c == null || c === "") && i && (c = (await this.loadConfig()).currentVaultId), c == null || c === "")
2916
+ let s = t;
2917
+ if ((s == null || s === "") && i && (s = (await this.loadConfig()).currentVaultId), s == null || s === "")
2912
2918
  return;
2913
- let s;
2914
- if (typeof c == "number")
2915
- s = o.find((l) => l.id === c);
2916
- else if (/^\d+$/.test(c)) {
2917
- const l = Number(c);
2918
- s = o.find((d) => d.id === l);
2919
+ let c;
2920
+ if (typeof s == "number")
2921
+ c = o.find((l) => l.id === s);
2922
+ else if (/^\d+$/.test(s)) {
2923
+ const l = Number(s);
2924
+ c = o.find((d) => d.id === l);
2919
2925
  } else
2920
- s = o.find((l) => l.name === c);
2921
- if (s && !(!r && s.status === "Removed"))
2922
- return s;
2926
+ c = o.find((l) => l.name === s);
2927
+ if (c && !(!r && c.status === "Removed"))
2928
+ return c;
2923
2929
  }
2924
2930
  vaultDir(t) {
2925
- return p.join(I.Dir.vaults, String(t));
2931
+ return p.join(y.Dir.vaults, String(t));
2926
2932
  }
2927
2933
  archivePath(t, a) {
2928
2934
  return p.join(this.vaultDir(t), String(a));
@@ -2931,24 +2937,24 @@ class br {
2931
2937
  return p.join(this.archivePath(t, a), r);
2932
2938
  }
2933
2939
  async resolveArchiveStorageLocation(t) {
2934
- const a = this.archivePath(t.vaultId, t.id), r = await we(a);
2940
+ const a = this.archivePath(t.vaultId, t.id), r = await Ie(a);
2935
2941
  if (!r || !r.isDirectory())
2936
2942
  return;
2937
2943
  const i = this.archiveObjectPath(t.vaultId, t.id, t.item);
2938
- if (await S(i))
2944
+ if (await V(i))
2939
2945
  return {
2940
2946
  slotPath: a,
2941
2947
  objectPath: i
2942
2948
  };
2943
2949
  }
2944
2950
  async ensureVaultDir(t) {
2945
- await ae(this.vaultDir(t));
2951
+ await re(this.vaultDir(t));
2946
2952
  }
2947
2953
  async removeVaultDir(t) {
2948
- t !== w.Vault.id && await y.rm(this.vaultDir(t), { recursive: !0, force: !0 });
2954
+ t !== w.Vault.id && await I.rm(this.vaultDir(t), { recursive: !0, force: !0 });
2949
2955
  }
2950
2956
  }
2951
- class kr {
2957
+ class xr {
2952
2958
  constructor(t, a) {
2953
2959
  this.context = t, this.logger = a;
2954
2960
  }
@@ -2960,50 +2966,50 @@ class kr {
2960
2966
  const i = await this.preValidatePutItems(t);
2961
2967
  await this.preValidatePutSlots(r.id, i.length);
2962
2968
  const o = { ok: [], failed: [] };
2963
- for (const c of i) {
2964
- const s = await this.context.nextAutoIncrement("archiveId"), l = this.context.archivePath(r.id, s), d = {
2965
- archivedAt: Oe(),
2966
- status: R.Archived,
2967
- isDirectory: c.stats.isDirectory() ? 1 : 0,
2969
+ for (const s of i) {
2970
+ const c = await this.context.nextAutoIncrement("archiveId"), l = this.context.archivePath(r.id, c), d = {
2971
+ archivedAt: Ye(),
2972
+ status: S.Archived,
2973
+ isDirectory: s.stats.isDirectory() ? 1 : 0,
2968
2974
  vaultId: r.id,
2969
- id: s,
2970
- item: p.basename(c.resolvedPath),
2971
- directory: p.dirname(c.resolvedPath),
2975
+ id: c,
2976
+ item: p.basename(s.resolvedPath),
2977
+ directory: p.dirname(s.resolvedPath),
2972
2978
  message: a.message ?? "",
2973
2979
  remark: a.remark ?? ""
2974
2980
  };
2975
2981
  try {
2976
- if (await S(l))
2982
+ if (await V(l))
2977
2983
  throw new Error(
2978
2984
  n("service.archive.error.slot_exists", {
2979
2985
  path: l
2980
2986
  })
2981
2987
  );
2982
- await y.mkdir(l, { recursive: !1 });
2983
- const u = this.context.archiveObjectPath(r.id, s, d.item);
2988
+ await I.mkdir(l, { recursive: !1 });
2989
+ const u = this.context.archiveObjectPath(r.id, c, d.item);
2984
2990
  try {
2985
- await y.rename(c.resolvedPath, u);
2991
+ await I.rename(s.resolvedPath, u);
2986
2992
  } catch (m) {
2987
- throw await y.rmdir(l).catch(() => {
2993
+ throw await I.rmdir(l).catch(() => {
2988
2994
  }), m;
2989
2995
  }
2990
2996
  await this.context.appendListEntry(d), await this.logger.log(
2991
2997
  "INFO",
2992
2998
  {
2993
2999
  main: "put",
2994
- args: [c.input],
3000
+ args: [s.input],
2995
3001
  opts: {
2996
3002
  vault: a.vault ?? r.id
2997
3003
  },
2998
3004
  source: a.source ?? "u"
2999
3005
  },
3000
3006
  n("service.archive.log.archived", {
3001
- input: c.input
3007
+ input: s.input
3002
3008
  }),
3003
- { aid: s, vid: r.id }
3009
+ { aid: c, vid: r.id }
3004
3010
  ), o.ok.push({
3005
- id: s,
3006
- input: c.input,
3011
+ id: c,
3012
+ input: s.input,
3007
3013
  success: !0,
3008
3014
  message: n("service.archive.result.archived_to_vault", {
3009
3015
  name: r.name,
@@ -3016,19 +3022,19 @@ class kr {
3016
3022
  "ERROR",
3017
3023
  {
3018
3024
  main: "put",
3019
- args: [c.input],
3025
+ args: [s.input],
3020
3026
  opts: {
3021
3027
  vault: a.vault ?? r.id
3022
3028
  },
3023
3029
  source: a.source ?? "u"
3024
3030
  },
3025
3031
  n("service.archive.log.archive_failed", {
3026
- input: c.input,
3032
+ input: s.input,
3027
3033
  message: m
3028
3034
  })
3029
3035
  ), o.failed.push({
3030
- id: s,
3031
- input: c.input,
3036
+ id: c,
3037
+ input: s.input,
3032
3038
  success: !1,
3033
3039
  message: m
3034
3040
  });
@@ -3039,63 +3045,63 @@ class kr {
3039
3045
  async restore(t) {
3040
3046
  if (t.length === 0)
3041
3047
  throw new Error(n("service.archive.error.at_least_one_id"));
3042
- const a = await this.context.loadListEntries(), r = new Map(a.map((c) => [c.id, c]));
3043
- for (const c of t) {
3044
- const s = r.get(c);
3045
- if (!s)
3048
+ const a = await this.context.loadListEntries(), r = new Map(a.map((s) => [s.id, s]));
3049
+ for (const s of t) {
3050
+ const c = r.get(s);
3051
+ if (!c)
3046
3052
  throw new Error(
3047
3053
  n("service.archive.error.id_not_exists", {
3048
- id: c
3054
+ id: s
3049
3055
  })
3050
3056
  );
3051
- if (s.status !== R.Archived)
3057
+ if (c.status !== S.Archived)
3052
3058
  throw new Error(
3053
3059
  n("service.archive.error.id_already_restored", {
3054
- id: c
3060
+ id: s
3055
3061
  })
3056
3062
  );
3057
3063
  }
3058
3064
  const i = { ok: [], failed: [] };
3059
3065
  let o = !1;
3060
- for (const c of t) {
3061
- const s = r.get(c);
3062
- if (!s) {
3066
+ for (const s of t) {
3067
+ const c = r.get(s);
3068
+ if (!c) {
3063
3069
  i.failed.push({
3064
- input: String(c),
3070
+ input: String(s),
3065
3071
  success: !1,
3066
3072
  message: n("service.archive.error.id_not_found_short")
3067
3073
  });
3068
3074
  continue;
3069
3075
  }
3070
- const l = await this.context.resolveArchiveStorageLocation(s), d = p.join(s.directory, s.item);
3076
+ const l = await this.context.resolveArchiveStorageLocation(c), d = p.join(c.directory, c.item);
3071
3077
  try {
3072
3078
  if (!l)
3073
3079
  throw new Error(
3074
3080
  n("service.archive.error.object_missing", {
3075
- path: this.context.archivePath(s.vaultId, s.id)
3081
+ path: this.context.archivePath(c.vaultId, c.id)
3076
3082
  })
3077
3083
  );
3078
- if (await S(d))
3084
+ if (await V(d))
3079
3085
  throw new Error(
3080
3086
  n("service.archive.error.restore_target_exists", {
3081
3087
  path: d
3082
3088
  })
3083
3089
  );
3084
- await y.mkdir(s.directory, { recursive: !0 }), await y.rename(l.objectPath, d), await y.rmdir(l.slotPath).catch((u) => {
3090
+ await I.mkdir(c.directory, { recursive: !0 }), await I.rename(l.objectPath, d), await I.rmdir(l.slotPath).catch((u) => {
3085
3091
  if (u.code !== "ENOENT")
3086
3092
  throw u;
3087
- }), s.status = R.Restored, o = !0, await this.logger.log(
3093
+ }), c.status = S.Restored, o = !0, await this.logger.log(
3088
3094
  "INFO",
3089
3095
  {
3090
3096
  main: "restore",
3091
- args: [String(c)],
3097
+ args: [String(s)],
3092
3098
  source: "u"
3093
3099
  },
3094
- n("service.archive.log.restored", { id: c }),
3095
- { aid: c, vid: s.vaultId }
3100
+ n("service.archive.log.restored", { id: s }),
3101
+ { aid: s, vid: c.vaultId }
3096
3102
  ), i.ok.push({
3097
- id: c,
3098
- input: String(c),
3103
+ id: s,
3104
+ input: String(s),
3099
3105
  success: !0,
3100
3106
  message: n("service.archive.result.restored_to", { path: d })
3101
3107
  });
@@ -3105,14 +3111,14 @@ class kr {
3105
3111
  "ERROR",
3106
3112
  {
3107
3113
  main: "restore",
3108
- args: [String(c)],
3114
+ args: [String(s)],
3109
3115
  source: "u"
3110
3116
  },
3111
- n("service.archive.log.restore_failed", { id: c, message: m }),
3112
- { aid: c, vid: s.vaultId }
3117
+ n("service.archive.log.restore_failed", { id: s, message: m }),
3118
+ { aid: s, vid: c.vaultId }
3113
3119
  ), i.failed.push({
3114
- id: c,
3115
- input: String(c),
3120
+ id: s,
3121
+ input: String(s),
3116
3122
  success: !1,
3117
3123
  message: m
3118
3124
  });
@@ -3134,7 +3140,7 @@ class kr {
3134
3140
  })
3135
3141
  );
3136
3142
  await this.context.ensureVaultDir(r.id);
3137
- const i = await this.context.loadListEntries(), o = new Map(i.map((d) => [d.id, d])), c = /* @__PURE__ */ new Map();
3143
+ const i = await this.context.loadListEntries(), o = new Map(i.map((d) => [d.id, d])), s = /* @__PURE__ */ new Map();
3138
3144
  for (const d of t) {
3139
3145
  const u = o.get(d);
3140
3146
  if (!u)
@@ -3143,7 +3149,7 @@ class kr {
3143
3149
  id: d
3144
3150
  })
3145
3151
  );
3146
- if (u.status !== R.Archived)
3152
+ if (u.status !== S.Archived)
3147
3153
  throw new Error(
3148
3154
  n("service.archive.error.id_restored_cannot_move", {
3149
3155
  id: d
@@ -3156,30 +3162,30 @@ class kr {
3156
3162
  vault: r.name
3157
3163
  })
3158
3164
  );
3159
- const m = await this.context.resolveArchiveStorageLocation(u), h = this.context.archivePath(u.vaultId, u.id), f = this.context.archivePath(r.id, u.id);
3165
+ const m = await this.context.resolveArchiveStorageLocation(u), f = this.context.archivePath(u.vaultId, u.id), h = this.context.archivePath(r.id, u.id);
3160
3166
  if (!m)
3161
3167
  throw new Error(
3162
3168
  n("service.archive.error.object_missing", {
3163
- path: h
3169
+ path: f
3164
3170
  })
3165
3171
  );
3166
- if (await S(f))
3172
+ if (await V(h))
3167
3173
  throw new Error(
3168
3174
  n("service.archive.error.target_slot_exists", {
3169
- path: f
3175
+ path: h
3170
3176
  })
3171
3177
  );
3172
- c.set(d, m);
3178
+ s.set(d, m);
3173
3179
  }
3174
- const s = { ok: [], failed: [] };
3180
+ const c = { ok: [], failed: [] };
3175
3181
  let l = !1;
3176
3182
  for (const d of t) {
3177
3183
  const u = o.get(d);
3178
3184
  if (!u)
3179
3185
  continue;
3180
- const m = c.get(d);
3186
+ const m = s.get(d);
3181
3187
  if (!m) {
3182
- s.failed.push({
3188
+ c.failed.push({
3183
3189
  id: d,
3184
3190
  input: String(d),
3185
3191
  success: !1,
@@ -3187,9 +3193,9 @@ class kr {
3187
3193
  });
3188
3194
  continue;
3189
3195
  }
3190
- const h = this.context.archivePath(r.id, u.id), f = u.vaultId;
3196
+ const f = this.context.archivePath(r.id, u.id), h = u.vaultId;
3191
3197
  try {
3192
- await y.rename(m.slotPath, h), u.vaultId = r.id, l = !0, await this.logger.log(
3198
+ await I.rename(m.slotPath, f), u.vaultId = r.id, l = !0, await this.logger.log(
3193
3199
  "INFO",
3194
3200
  {
3195
3201
  main: "move",
@@ -3199,11 +3205,11 @@ class kr {
3199
3205
  },
3200
3206
  n("service.archive.log.moved", {
3201
3207
  id: d,
3202
- fromVaultId: f,
3208
+ fromVaultId: h,
3203
3209
  toVaultId: r.id
3204
3210
  }),
3205
3211
  { aid: d, vid: r.id }
3206
- ), s.ok.push({
3212
+ ), c.ok.push({
3207
3213
  id: d,
3208
3214
  input: String(d),
3209
3215
  success: !0,
@@ -3212,8 +3218,8 @@ class kr {
3212
3218
  id: r.id
3213
3219
  })
3214
3220
  });
3215
- } catch (_) {
3216
- const g = _.message;
3221
+ } catch (g) {
3222
+ const _ = g.message;
3217
3223
  await this.logger.log(
3218
3224
  "ERROR",
3219
3225
  {
@@ -3224,31 +3230,31 @@ class kr {
3224
3230
  },
3225
3231
  n("service.archive.log.move_failed", {
3226
3232
  id: d,
3227
- message: g
3233
+ message: _
3228
3234
  }),
3229
- { aid: d, vid: f }
3230
- ), s.failed.push({
3235
+ { aid: d, vid: h }
3236
+ ), c.failed.push({
3231
3237
  id: d,
3232
3238
  input: String(d),
3233
3239
  success: !1,
3234
- message: g
3240
+ message: _
3235
3241
  });
3236
3242
  }
3237
3243
  }
3238
- return l && await this.context.saveListEntries(i), s;
3244
+ return l && await this.context.saveListEntries(i), c;
3239
3245
  }
3240
3246
  async resolveCdTarget(t) {
3241
3247
  const a = t.trim();
3242
3248
  if (!a)
3243
3249
  throw new Error(n("service.archive.error.target_empty"));
3244
- const { vaultRef: r, archiveId: i } = this.parseCdTarget(a), c = (await this.context.loadListEntries()).find((d) => d.id === i);
3245
- if (!c)
3250
+ const { vaultRef: r, archiveId: i } = this.parseCdTarget(a), s = (await this.context.loadListEntries()).find((d) => d.id === i);
3251
+ if (!s)
3246
3252
  throw new Error(
3247
3253
  n("service.archive.error.id_not_exists", {
3248
3254
  id: i
3249
3255
  })
3250
3256
  );
3251
- if (c.status !== R.Archived)
3257
+ if (s.status !== S.Archived)
3252
3258
  throw new Error(
3253
3259
  n("service.archive.error.id_restored_no_slot", {
3254
3260
  id: i
@@ -3265,42 +3271,42 @@ class kr {
3265
3271
  vault: r
3266
3272
  })
3267
3273
  );
3268
- if (d.id !== c.vaultId)
3274
+ if (d.id !== s.vaultId)
3269
3275
  throw new Error(
3270
3276
  n("service.archive.error.id_vault_mismatch", {
3271
3277
  id: i,
3272
- actualVaultId: c.vaultId,
3278
+ actualVaultId: s.vaultId,
3273
3279
  requestedVaultId: d.id
3274
3280
  })
3275
3281
  );
3276
3282
  }
3277
- const s = await this.context.resolveVault(c.vaultId, {
3283
+ const c = await this.context.resolveVault(s.vaultId, {
3278
3284
  includeRemoved: !0,
3279
3285
  fallbackCurrent: !1
3280
3286
  });
3281
- if (!s)
3287
+ if (!c)
3282
3288
  throw new Error(
3283
3289
  n("service.archive.error.vault_for_archive_not_found", {
3284
3290
  id: i,
3285
- vaultId: c.vaultId
3291
+ vaultId: s.vaultId
3286
3292
  })
3287
3293
  );
3288
- const l = await this.context.resolveArchiveStorageLocation(c);
3294
+ const l = await this.context.resolveArchiveStorageLocation(s);
3289
3295
  if (!l)
3290
3296
  throw new Error(
3291
3297
  n("service.archive.error.slot_missing_invalid", {
3292
- path: this.context.archivePath(c.vaultId, c.id)
3298
+ path: this.context.archivePath(s.vaultId, s.id)
3293
3299
  })
3294
3300
  );
3295
3301
  return {
3296
- vault: s,
3302
+ vault: c,
3297
3303
  archiveId: i,
3298
3304
  slotPath: l.slotPath
3299
3305
  };
3300
3306
  }
3301
3307
  async listEntries(t) {
3302
3308
  let r = await this.context.loadListEntries();
3303
- if (t.all || (t.restored ? r = r.filter((i) => i.status === R.Restored) : r = r.filter((i) => i.status === R.Archived)), t.vault !== void 0) {
3309
+ if (t.all || (t.restored ? r = r.filter((i) => i.status === S.Restored) : r = r.filter((i) => i.status === S.Archived)), t.vault !== void 0) {
3304
3310
  const i = await this.context.resolveVault(t.vault, {
3305
3311
  includeRemoved: !0,
3306
3312
  fallbackCurrent: !1
@@ -3318,13 +3324,13 @@ class kr {
3318
3324
  async decorateEntries(t) {
3319
3325
  const a = await this.context.getVaults({ includeRemoved: !0, withDefault: !0 }), r = new Map(a.map((i) => [i.id, i]));
3320
3326
  return t.map((i) => {
3321
- const o = r.get(i.vaultId), c = p.join(i.directory, i.item);
3327
+ const o = r.get(i.vaultId), s = p.join(i.directory, i.item);
3322
3328
  return {
3323
3329
  ...i,
3324
3330
  vaultName: o ? `${o.name}(${o.id})` : n("service.archive.decorated.unknown_vault", {
3325
3331
  vaultId: i.vaultId
3326
3332
  }),
3327
- displayPath: c
3333
+ displayPath: s
3328
3334
  };
3329
3335
  });
3330
3336
  }
@@ -3377,17 +3383,17 @@ class kr {
3377
3383
  };
3378
3384
  }
3379
3385
  async preValidatePutItems(t) {
3380
- const a = [], r = /* @__PURE__ */ new Set(), i = await rt(I.Dir.root);
3386
+ const a = [], r = /* @__PURE__ */ new Set(), i = await nt(y.Dir.root);
3381
3387
  for (const o of t) {
3382
- const c = p.resolve(o), s = await we(c);
3383
- if (!s)
3388
+ const s = p.resolve(o), c = await Ie(s);
3389
+ if (!c)
3384
3390
  throw new Error(
3385
3391
  n("service.archive.error.path_not_exists", {
3386
3392
  path: o
3387
3393
  })
3388
3394
  );
3389
- const l = await rt(c);
3390
- if (or(l, i) || Rt(i, l))
3395
+ const l = await nt(s);
3396
+ if (cr(l, i) || Vt(i, l))
3391
3397
  throw new Error(
3392
3398
  n("service.archive.error.path_forbidden_archiver_scope", {
3393
3399
  path: o
@@ -3401,9 +3407,9 @@ class kr {
3401
3407
  );
3402
3408
  r.add(l), a.push({
3403
3409
  input: o,
3404
- resolvedPath: c,
3410
+ resolvedPath: s,
3405
3411
  canonicalPath: l,
3406
- stats: s
3412
+ stats: c
3407
3413
  });
3408
3414
  }
3409
3415
  return a;
@@ -3411,34 +3417,34 @@ class kr {
3411
3417
  async preValidatePutSlots(t, a) {
3412
3418
  const r = await this.context.loadAutoIncr();
3413
3419
  for (let i = 1; i <= a; i += 1) {
3414
- const o = r.archiveId + i, c = this.context.archivePath(t, o);
3415
- if (await S(c))
3420
+ const o = r.archiveId + i, s = this.context.archivePath(t, o);
3421
+ if (await V(s))
3416
3422
  throw new Error(
3417
3423
  n("service.archive.error.slot_already_occupied", {
3418
- path: c
3424
+ path: s
3419
3425
  })
3420
3426
  );
3421
3427
  }
3422
3428
  }
3423
3429
  }
3424
- class xr {
3430
+ class Er {
3425
3431
  constructor(t) {
3426
3432
  this.context = t;
3427
3433
  }
3428
3434
  async log(t, a, r, i) {
3429
- const s = {
3435
+ const c = {
3430
3436
  id: await this.context.nextAutoIncrement("logId"),
3431
- operedAt: Oe(/* @__PURE__ */ new Date()),
3437
+ operedAt: Ye(/* @__PURE__ */ new Date()),
3432
3438
  level: t,
3433
3439
  oper: a,
3434
3440
  message: r,
3435
3441
  ...i?.aid !== void 0 ? { archiveIds: i.aid } : {},
3436
3442
  ...i?.vid !== void 0 ? { vaultIds: i.vid } : {}
3437
3443
  };
3438
- return await $t(I.File.log, s), s;
3444
+ return await Dt(y.File.log, c), c;
3439
3445
  }
3440
3446
  }
3441
- function Le(e) {
3447
+ function $e(e) {
3442
3448
  const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
3443
3449
  for (const r of e)
3444
3450
  t.has(r) ? a.add(r) : t.add(r);
@@ -3447,7 +3453,7 @@ function Le(e) {
3447
3453
  function x(e, t, a, r) {
3448
3454
  e.push({ level: t, code: a, message: r });
3449
3455
  }
3450
- class Cr {
3456
+ class Ar {
3451
3457
  constructor(t) {
3452
3458
  this.context = t;
3453
3459
  }
@@ -3470,12 +3476,12 @@ class Cr {
3470
3476
  }
3471
3477
  async checkRequiredPaths(t) {
3472
3478
  const a = [
3473
- ...Object.values(I.Dir),
3474
- ...Object.values(I.File),
3479
+ ...Object.values(y.Dir),
3480
+ ...Object.values(y.File),
3475
3481
  this.context.vaultDir(w.Vault.id)
3476
3482
  ];
3477
3483
  for (const r of a)
3478
- await S(r) || x(
3484
+ await V(r) || x(
3479
3485
  t.issues,
3480
3486
  k.Error,
3481
3487
  "MISSING_PATH",
@@ -3485,7 +3491,7 @@ class Cr {
3485
3491
  );
3486
3492
  }
3487
3493
  checkConfigVaultReference(t, a, r) {
3488
- r.find((o) => o.id === a && o.status !== N.Removed) || x(
3494
+ r.find((o) => o.id === a && o.status !== M.Removed) || x(
3489
3495
  t.issues,
3490
3496
  k.Error,
3491
3497
  "INVALID_CURRENT_VAULT",
@@ -3495,7 +3501,7 @@ class Cr {
3495
3501
  );
3496
3502
  }
3497
3503
  checkListIds(t, a, r) {
3498
- const i = a.map((s) => s.id), o = Le(i);
3504
+ const i = a.map((c) => c.id), o = $e(i);
3499
3505
  o.length > 0 && x(
3500
3506
  t.issues,
3501
3507
  k.Error,
@@ -3504,28 +3510,28 @@ class Cr {
3504
3510
  ids: o.join(", ")
3505
3511
  })
3506
3512
  );
3507
- const c = i.length > 0 ? Math.max(...i) : 0;
3508
- r < c && x(
3513
+ const s = i.length > 0 ? Math.max(...i) : 0;
3514
+ r < s && x(
3509
3515
  t.issues,
3510
3516
  k.Error,
3511
3517
  "ARCHIVE_AUTO_INCR_TOO_SMALL",
3512
3518
  n("service.check.issue.archive_auto_incr_too_small", {
3513
3519
  autoIncr: r,
3514
- maxId: c
3520
+ maxId: s
3515
3521
  })
3516
3522
  );
3517
3523
  }
3518
3524
  checkVaultIds(t, a, r) {
3519
- const i = a.filter((u) => u.id !== w.Vault.id), o = i.map((u) => u.id), c = Le(o);
3520
- c.length > 0 && x(
3525
+ const i = a.filter((u) => u.id !== w.Vault.id), o = i.map((u) => u.id), s = $e(o);
3526
+ s.length > 0 && x(
3521
3527
  t.issues,
3522
3528
  k.Error,
3523
3529
  "DUPLICATE_VAULT_ID",
3524
3530
  n("service.check.issue.duplicate_vault_id", {
3525
- ids: c.join(", ")
3531
+ ids: s.join(", ")
3526
3532
  })
3527
3533
  );
3528
- const s = i.map((u) => u.name), l = s.filter((u, m) => s.indexOf(u) !== m);
3534
+ const c = i.map((u) => u.name), l = c.filter((u, m) => c.indexOf(u) !== m);
3529
3535
  l.length > 0 && x(
3530
3536
  t.issues,
3531
3537
  k.Error,
@@ -3560,8 +3566,8 @@ class Cr {
3560
3566
  );
3561
3567
  continue;
3562
3568
  }
3563
- const s = this.context.archivePath(o.vaultId, o.id), l = p.join(o.directory, o.item);
3564
- if (o.status === R.Archived) {
3569
+ const c = this.context.archivePath(o.vaultId, o.id), l = p.join(o.directory, o.item);
3570
+ if (o.status === S.Archived) {
3565
3571
  const d = await this.context.resolveArchiveStorageLocation(o);
3566
3572
  if (!d)
3567
3573
  x(
@@ -3570,26 +3576,26 @@ class Cr {
3570
3576
  "MISSING_ARCHIVE_OBJECT",
3571
3577
  n("service.check.issue.missing_archive_object", {
3572
3578
  archiveId: o.id,
3573
- archivePath: s
3579
+ archivePath: c
3574
3580
  })
3575
3581
  );
3576
3582
  else {
3577
- const u = await we(d.objectPath);
3583
+ const u = await Ie(d.objectPath);
3578
3584
  if (u) {
3579
- const m = u.isDirectory(), h = o.isDirectory === 1;
3580
- m !== h && x(
3585
+ const m = u.isDirectory(), f = o.isDirectory === 1;
3586
+ m !== f && x(
3581
3587
  t.issues,
3582
3588
  k.Error,
3583
3589
  "TYPE_MISMATCH_ARCHIVED",
3584
3590
  n("service.check.issue.type_mismatch_archived", {
3585
3591
  archiveId: o.id,
3586
- expectedIsDir: h,
3592
+ expectedIsDir: f,
3587
3593
  actualIsDir: m
3588
3594
  })
3589
3595
  );
3590
3596
  }
3591
3597
  }
3592
- await S(l) && x(
3598
+ await V(l) && x(
3593
3599
  t.issues,
3594
3600
  k.Warn,
3595
3601
  "RESTORE_TARGET_ALREADY_EXISTS",
@@ -3598,17 +3604,17 @@ class Cr {
3598
3604
  restorePath: l
3599
3605
  })
3600
3606
  );
3601
- } else if (o.status === R.Restored)
3602
- if (await S(s) && x(
3607
+ } else if (o.status === S.Restored)
3608
+ if (await V(c) && x(
3603
3609
  t.issues,
3604
3610
  k.Warn,
3605
3611
  "RESTORED_BUT_ARCHIVE_EXISTS",
3606
3612
  n("service.check.issue.restored_but_archive_exists", {
3607
3613
  archiveId: o.id,
3608
- archivePath: s
3614
+ archivePath: c
3609
3615
  })
3610
- ), await S(l)) {
3611
- const d = await we(l);
3616
+ ), await V(l)) {
3617
+ const d = await Ie(l);
3612
3618
  if (d) {
3613
3619
  const u = d.isDirectory(), m = o.isDirectory === 1;
3614
3620
  u !== m && x(
@@ -3645,31 +3651,31 @@ class Cr {
3645
3651
  }
3646
3652
  }
3647
3653
  async checkVaultDirectoryConsistency(t, a, r) {
3648
- const i = new Set(r.map((s) => s.id)), o = new Set(
3649
- a.filter((s) => s.status === R.Archived).map((s) => `${s.vaultId}/${s.id}`)
3650
- ), c = await sr(I.Dir.vaults);
3651
- for (const s of c) {
3652
- if (!/^\d+$/.test(s)) {
3654
+ const i = new Set(r.map((c) => c.id)), o = new Set(
3655
+ a.filter((c) => c.status === S.Archived).map((c) => `${c.vaultId}/${c.id}`)
3656
+ ), s = await lr(y.Dir.vaults);
3657
+ for (const c of s) {
3658
+ if (!/^\d+$/.test(c)) {
3653
3659
  x(
3654
3660
  t.issues,
3655
3661
  k.Warn,
3656
3662
  "NON_NUMERIC_VAULT_DIR",
3657
3663
  n("service.check.issue.non_numeric_vault_dir", {
3658
- path: p.join(I.Dir.vaults, s)
3664
+ path: p.join(y.Dir.vaults, c)
3659
3665
  })
3660
3666
  );
3661
3667
  continue;
3662
3668
  }
3663
- const l = Number(s);
3669
+ const l = Number(c);
3664
3670
  i.has(l) || x(
3665
3671
  t.issues,
3666
3672
  k.Warn,
3667
3673
  "ORPHAN_VAULT_DIR",
3668
3674
  n("service.check.issue.orphan_vault_dir", {
3669
- path: p.join(I.Dir.vaults, s)
3675
+ path: p.join(y.Dir.vaults, c)
3670
3676
  })
3671
3677
  );
3672
- const d = this.context.vaultDir(l), u = await y.readdir(d, { withFileTypes: !0 });
3678
+ const d = this.context.vaultDir(l), u = await I.readdir(d, { withFileTypes: !0 });
3673
3679
  for (const m of u) {
3674
3680
  if (!/^[0-9]+$/.test(m.name)) {
3675
3681
  x(
@@ -3695,35 +3701,35 @@ class Cr {
3695
3701
  );
3696
3702
  continue;
3697
3703
  }
3698
- const h = `${l}/${Number(m.name)}`;
3699
- o.has(h) || x(
3704
+ const f = `${l}/${Number(m.name)}`;
3705
+ o.has(f) || x(
3700
3706
  t.issues,
3701
3707
  k.Warn,
3702
3708
  "ORPHAN_ARCHIVE_OBJECT",
3703
3709
  n("service.check.issue.orphan_archive_object", {
3704
- pairKey: h
3710
+ pairKey: f
3705
3711
  })
3706
3712
  );
3707
3713
  }
3708
3714
  }
3709
- for (const s of r) {
3710
- if (s.status !== "Valid" && s.status !== "Protected")
3715
+ for (const c of r) {
3716
+ if (c.status !== "Valid" && c.status !== "Protected")
3711
3717
  continue;
3712
- const l = this.context.vaultDir(s.id);
3713
- await S(l) || x(
3718
+ const l = this.context.vaultDir(c.id);
3719
+ await V(l) || x(
3714
3720
  t.issues,
3715
3721
  k.Error,
3716
3722
  "MISSING_VAULT_DIR",
3717
3723
  n("service.check.issue.missing_vault_dir", {
3718
- vaultName: s.name,
3719
- vaultId: s.id,
3724
+ vaultName: c.name,
3725
+ vaultId: c.id,
3720
3726
  path: l
3721
3727
  })
3722
3728
  );
3723
3729
  }
3724
3730
  }
3725
3731
  async checkLogConsistency(t, a) {
3726
- const i = (await ye(I.File.log)).map((s) => Number(s.id)).filter((s) => Number.isInteger(s)), o = Le(i);
3732
+ const i = (await ye(y.File.log)).map((c) => Number(c.id)).filter((c) => Number.isInteger(c)), o = $e(i);
3727
3733
  o.length > 0 && x(
3728
3734
  t.issues,
3729
3735
  k.Error,
@@ -3732,19 +3738,19 @@ class Cr {
3732
3738
  ids: o.join(", ")
3733
3739
  })
3734
3740
  );
3735
- const c = i.length > 0 ? Math.max(...i) : 0;
3736
- a < c && x(
3741
+ const s = i.length > 0 ? Math.max(...i) : 0;
3742
+ a < s && x(
3737
3743
  t.issues,
3738
3744
  k.Error,
3739
3745
  "LOG_AUTO_INCR_TOO_SMALL",
3740
3746
  n("service.check.issue.log_auto_incr_too_small", {
3741
3747
  autoIncr: a,
3742
- maxId: c
3748
+ maxId: s
3743
3749
  })
3744
3750
  );
3745
3751
  }
3746
3752
  }
3747
- class Er {
3753
+ class Rr {
3748
3754
  constructor(t) {
3749
3755
  this.context = t;
3750
3756
  }
@@ -3780,7 +3786,7 @@ class Er {
3780
3786
  a.lastUpdateCheck = t, await this.context.saveConfig(a);
3781
3787
  }
3782
3788
  }
3783
- function Ar(e) {
3789
+ function Sr(e) {
3784
3790
  return {
3785
3791
  id: Number(e.id),
3786
3792
  operedAt: String(e.operedAt ?? ""),
@@ -3791,17 +3797,17 @@ function Ar(e) {
3791
3797
  ...e.vaultIds !== void 0 ? { vaultIds: Number(e.vaultIds) } : {}
3792
3798
  };
3793
3799
  }
3794
- function Rr(e) {
3800
+ function Vr(e) {
3795
3801
  return e.operedAt.replace(/[-:\sT]/g, "").slice(0, 6);
3796
3802
  }
3797
- class Sr {
3803
+ class Lr {
3798
3804
  constructor(t) {
3799
3805
  this.context = t;
3800
3806
  }
3801
3807
  async getLogs(t) {
3802
3808
  const a = await this.loadAllLogs();
3803
3809
  return t.mode === "all" ? a : a.filter((r) => {
3804
- const i = Rr(r);
3810
+ const i = Vr(r);
3805
3811
  return !i || i.length !== 6 ? !1 : i >= t.from && i <= t.to;
3806
3812
  });
3807
3813
  }
@@ -3812,61 +3818,61 @@ class Sr {
3812
3818
  const i = { log: r };
3813
3819
  if (r.archiveIds !== void 0) {
3814
3820
  const o = await this.context.loadListEntries();
3815
- i.archive = o.find((c) => c.id === r.archiveIds);
3821
+ i.archive = o.find((s) => s.id === r.archiveIds);
3816
3822
  }
3817
3823
  if (r.vaultIds !== void 0) {
3818
3824
  const o = await this.context.getVaults({ includeRemoved: !0, withDefault: !0 });
3819
- i.vault = o.find((c) => c.id === r.vaultIds);
3825
+ i.vault = o.find((s) => s.id === r.vaultIds);
3820
3826
  }
3821
3827
  return i;
3822
3828
  }
3823
3829
  async loadAllLogs() {
3824
- const a = (await ye(I.File.log)).map((r) => Ar(r));
3830
+ const a = (await ye(y.File.log)).map((r) => Sr(r));
3825
3831
  return a.sort((r, i) => r.id - i.id), a;
3826
3832
  }
3827
3833
  }
3828
- const Vr = Xt(Kt);
3829
- function Pe(e) {
3834
+ const Tr = Qt(Zt);
3835
+ function Oe(e) {
3830
3836
  return e.trim().replace(/^v/i, "");
3831
3837
  }
3832
- function mt(e) {
3833
- return Pe(e).split(".").map((t) => Number(t.replace(/[^0-9].*$/, ""))).map((t) => Number.isFinite(t) ? t : 0);
3838
+ function ht(e) {
3839
+ return Oe(e).split(".").map((t) => Number(t.replace(/[^0-9].*$/, ""))).map((t) => Number.isFinite(t) ? t : 0);
3834
3840
  }
3835
- function Lr(e, t) {
3836
- const a = mt(e), r = mt(t), i = Math.max(a.length, r.length);
3841
+ function $r(e, t) {
3842
+ const a = ht(e), r = ht(t), i = Math.max(a.length, r.length);
3837
3843
  for (let o = 0; o < i; o += 1) {
3838
- const c = a[o] ?? 0, s = r[o] ?? 0;
3839
- if (s > c)
3844
+ const s = a[o] ?? 0, c = r[o] ?? 0;
3845
+ if (c > s)
3840
3846
  return !0;
3841
- if (s < c)
3847
+ if (c < s)
3842
3848
  return !1;
3843
3849
  }
3844
3850
  return !1;
3845
3851
  }
3846
- class $r {
3852
+ class Dr {
3847
3853
  currentVersion;
3848
3854
  constructor(t) {
3849
- this.currentVersion = Pe(t);
3855
+ this.currentVersion = Oe(t);
3850
3856
  }
3851
- async checkLatest(t = K.Repo) {
3852
- const a = await this.fetchLatestRelease(t), r = Pe(a.tag_name);
3857
+ async checkLatest(t = X.Repo) {
3858
+ const a = await this.fetchLatestRelease(t), r = Oe(a.tag_name);
3853
3859
  return {
3854
3860
  currentVersion: this.currentVersion,
3855
3861
  latestVersion: r,
3856
- hasUpdate: Lr(this.currentVersion, r),
3862
+ hasUpdate: $r(this.currentVersion, r),
3857
3863
  htmlUrl: a.html_url,
3858
3864
  publishedAt: a.published_at
3859
3865
  };
3860
3866
  }
3861
- async installLatest(t = K.Repo) {
3862
- const r = (await this.fetchLatestRelease(t)).assets?.find((s) => /install.*\.sh$/i.test(s.name));
3867
+ async installLatest(t = X.Repo) {
3868
+ const r = (await this.fetchLatestRelease(t)).assets?.find((c) => /install.*\.sh$/i.test(c.name));
3863
3869
  if (!r)
3864
3870
  throw new Error(n("service.update.error.no_install_asset"));
3865
3871
  const i = await fetch(r.browser_download_url, {
3866
3872
  headers: {
3867
3873
  "user-agent": "archiver-ts"
3868
3874
  },
3869
- signal: AbortSignal.timeout(K.Timeout)
3875
+ signal: AbortSignal.timeout(X.Timeout)
3870
3876
  });
3871
3877
  if (!i.ok)
3872
3878
  throw new Error(
@@ -3874,14 +3880,14 @@ class $r {
3874
3880
  status: i.status
3875
3881
  })
3876
3882
  );
3877
- const o = await i.text(), c = p.join(ht.tmpdir(), `archiver-update-${Date.now()}.sh`);
3878
- await y.writeFile(c, o, { encoding: "utf8", mode: 493 });
3883
+ const o = await i.text(), s = p.join(gt.tmpdir(), `archiver-update-${Date.now()}.sh`);
3884
+ await I.writeFile(s, o, { encoding: "utf8", mode: 493 });
3879
3885
  try {
3880
- const s = await Vr("bash", [c], { maxBuffer: 4194304 });
3881
- return [s.stdout, s.stderr].filter(Boolean).join(`
3886
+ const c = await Tr("bash", [s], { maxBuffer: 4194304 });
3887
+ return [c.stdout, c.stderr].filter(Boolean).join(`
3882
3888
  `).trim();
3883
3889
  } finally {
3884
- await y.rm(c, { force: !0 });
3890
+ await I.rm(s, { force: !0 });
3885
3891
  }
3886
3892
  }
3887
3893
  async fetchLatestRelease(t) {
@@ -3890,7 +3896,7 @@ class $r {
3890
3896
  accept: "application/vnd.github+json",
3891
3897
  "user-agent": "archiver-ts"
3892
3898
  },
3893
- signal: AbortSignal.timeout(K.Timeout)
3899
+ signal: AbortSignal.timeout(X.Timeout)
3894
3900
  });
3895
3901
  if (!r.ok)
3896
3902
  throw new Error(
@@ -3909,27 +3915,27 @@ class $r {
3909
3915
  return i;
3910
3916
  }
3911
3917
  }
3912
- async function Tr() {
3913
- const e = new br();
3918
+ async function Nr() {
3919
+ const e = new kr();
3914
3920
  await e.init();
3915
- const t = new Er(e), a = new xr(e), r = new kr(e, a), i = new cr(e, t), o = new Sr(e), c = new Cr(e), s = "0.5.1", l = new $r(s);
3921
+ const t = new Rr(e), a = new Er(e), r = new xr(e, a), i = new dr(e, t), o = new Lr(e), s = new Ar(e), c = "0.5.2", l = new Dr(c);
3916
3922
  return {
3917
3923
  context: e,
3918
3924
  archiveService: r,
3919
3925
  vaultService: i,
3920
3926
  configService: t,
3921
3927
  logService: o,
3922
- checkService: c,
3928
+ checkService: s,
3923
3929
  auditLogger: a,
3924
3930
  updateService: l,
3925
- version: s
3931
+ version: c
3926
3932
  };
3927
3933
  }
3928
- async function Dr(e) {
3929
- if (!xe())
3934
+ async function Mr(e) {
3935
+ if (!ke())
3930
3936
  return "help";
3931
- O(n("index.no_command_action.unknown"));
3932
- const t = await wa({
3937
+ j(n("index.no_command_action.unknown"));
3938
+ const t = await ya({
3933
3939
  title: n("index.no_command_action.question"),
3934
3940
  description: n("index.no_command_action.note"),
3935
3941
  options: [
@@ -3938,32 +3944,32 @@ async function Dr(e) {
3938
3944
  ],
3939
3945
  initialValue: "list",
3940
3946
  hint: n("index.no_command_action.hint", {
3941
- leftRight: V(n("index.no_command_action.key.left_right")),
3942
- enter: V(n("index.no_command_action.key.enter"))
3947
+ leftRight: L(n("index.no_command_action.key.left_right")),
3948
+ enter: L(n("index.no_command_action.key.enter"))
3943
3949
  })
3944
3950
  });
3945
- return t || process.exit(130), await e.configService.setNoCommandAction(t), M(n("index.no_command_action.updated", { action: t })), t;
3951
+ return t || process.exit(130), await e.configService.setNoCommandAction(t), P(n("index.no_command_action.updated", { action: t })), t;
3946
3952
  }
3947
- async function Nr() {
3948
- const e = await Ne(I.File.config, w.Config);
3949
- fe(e.language), ge({
3953
+ async function Pr() {
3954
+ const e = await Pe(y.File.config, w.Config);
3955
+ ge(e.language), _e({
3950
3956
  style: e.style === "off" ? "off" : "on"
3951
3957
  });
3952
- const t = await Ir();
3958
+ const t = await Cr();
3953
3959
  if (t.installed) {
3954
3960
  const o = t.profilePath ? ` ${t.profilePath}` : "";
3955
- O(n("index.shell_wrapper.installed", { where: o })), t.reloadCommand && O(
3961
+ j(n("index.shell_wrapper.installed", { where: o })), t.reloadCommand && j(
3956
3962
  n("index.shell_wrapper.reload_hint", {
3957
3963
  reloadCommand: t.reloadCommand
3958
3964
  })
3959
3965
  );
3960
3966
  return;
3961
3967
  }
3962
- const a = await Tr(), r = await a.configService.getConfig();
3963
- fe(r.language), ge(r);
3964
- const i = dr(a);
3968
+ const a = await Nr(), r = await a.configService.getConfig();
3969
+ ge(r.language), _e(r);
3970
+ const i = mr(a);
3965
3971
  if (process.argv.length <= 2) {
3966
- if ((r.noCommandAction === "unknown" ? await Dr(a) : r.noCommandAction) === "list") {
3972
+ if ((r.noCommandAction === "unknown" ? await Mr(a) : r.noCommandAction) === "list") {
3967
3973
  await i.parseAsync([...process.argv, "list"]);
3968
3974
  return;
3969
3975
  }
@@ -3972,6 +3978,6 @@ async function Nr() {
3972
3978
  }
3973
3979
  await i.parseAsync(process.argv);
3974
3980
  }
3975
- Nr().catch((e) => {
3976
- Q(e.message), process.exit(1);
3981
+ Pr().catch((e) => {
3982
+ ee(e.message), process.exit(1);
3977
3983
  });