@hiai-gg/docsmint 0.7.0 → 0.7.3

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 (116) hide show
  1. package/README.md +97 -103
  2. package/dist/backend/index.js +2 -2
  3. package/dist/frontend/CategoryDialog-bQKMpVFD.js +631 -0
  4. package/dist/frontend/ConfirmDialog-DF7kgkyq.js +139 -0
  5. package/dist/frontend/CreateSnapshotDialog-CojnWChs.js +222 -0
  6. package/dist/frontend/{DatePicker-DsoepNdb.js → DatePicker-7FAbIOGg.js} +4 -4
  7. package/dist/frontend/DeleteDialog-BIlqRb1u.js +179 -0
  8. package/dist/frontend/{FolderNode-CNwi0ySr.js → FolderNode-Cf443LBa.js} +2 -2
  9. package/dist/frontend/{HiAiEditor-B1EDGsnA.js → HiAiEditor-CMZ-eL8s.js} +961 -955
  10. package/dist/frontend/SettingsDialog-DatuxOVX.js +980 -0
  11. package/dist/frontend/{ShareDialog-wGTXuXFE.js → ShareDialog-Bwz2y3Le.js} +2 -2
  12. package/dist/frontend/Sidebar-C_t5RrOJ.js +2101 -0
  13. package/dist/frontend/TagCreateDialog-Ch21yuWV.js +266 -0
  14. package/dist/frontend/app-shell.d.ts +3 -1
  15. package/dist/frontend/app-shell.js +155 -152
  16. package/dist/frontend/components/category-dialog.js +1 -1
  17. package/dist/frontend/components/create-snapshot-dialog.js +1 -1
  18. package/dist/frontend/components/delete-dialog.js +1 -1
  19. package/dist/frontend/components/editor/compact-editor.js +1 -1
  20. package/dist/frontend/components/editor/document-editor.js +1 -1
  21. package/dist/frontend/components/editor/document-title.js +1 -1
  22. package/dist/frontend/components/editor/extensions.js +1 -1
  23. package/dist/frontend/components/editor/markdown-toggle.js +2 -2
  24. package/dist/frontend/components/editor/markdown.js +1 -1
  25. package/dist/frontend/components/folder-node.js +1 -1
  26. package/dist/frontend/components/save-as-dialog.js +232 -227
  27. package/dist/frontend/components/settings.js +1 -1
  28. package/dist/frontend/components/share-dialog.js +1 -1
  29. package/dist/frontend/components/sidebar.js +1 -1
  30. package/dist/frontend/components/tag-create-dialog.js +1 -1
  31. package/dist/frontend/components/version-history.js +3 -3
  32. package/dist/frontend/confirm-dialog-8T6vsWL7.js +265 -0
  33. package/dist/frontend/dashboard.js +600 -592
  34. package/dist/frontend/dialog-CiSwD-_v.js +253 -0
  35. package/dist/frontend/{dropdown-menu-BXIl2E26.js → dropdown-menu-Bi5Iipwf.js} +6 -6
  36. package/dist/frontend/editor-content-sanitizer-CC_A8aaI.js +112 -0
  37. package/dist/frontend/{editorExtensions-BmINh76i.js → editorExtensions--HusV819.js} +3356 -3423
  38. package/dist/frontend/frontend.css +1 -1
  39. package/dist/frontend/i18n.js +1 -1
  40. package/dist/frontend/{input-eHFb2qiL.js → input-N9dNSOWF.js} +2 -2
  41. package/dist/frontend/{label-_I1iiaNU.js → label-CK72_fw8.js} +2 -2
  42. package/dist/frontend/{markdown-A5xji16P.js → markdown-H6QB53zu.js} +1 -1
  43. package/dist/frontend/messages-DTRe4U2V.js +1093 -0
  44. package/dist/frontend/search.js +3 -3
  45. package/dist/frontend/{select-value-CtMyrvDJ.js → select-value-BD1DToYs.js} +6 -6
  46. package/dist/frontend/shared-document.js +95 -92
  47. package/dist/frontend/{textarea-2eslfANY.js → textarea-pl_fDBre.js} +2 -2
  48. package/dist/frontend/theme.js +1 -1
  49. package/dist/frontend/theme.svelte-DG3RS7wv.js +101 -0
  50. package/dist/frontend/{utils-CDBqTgoV.js → utils-CMQRlxbx.js} +1 -1
  51. package/dist/frontend-ssr/app-shell.js +9 -5
  52. package/dist/frontend-ssr/assets/CategoryDialog-DsXe54EF.js +608 -0
  53. package/dist/frontend-ssr/assets/ConfirmDialog-DrH653ua.js +136 -0
  54. package/dist/frontend-ssr/assets/{CreateSnapshotDialog-BZ45odvJ.js → CreateSnapshotDialog-D3-PjXVr.js} +93 -88
  55. package/dist/frontend-ssr/assets/{DatePicker-CPtl6W5E.js → DatePicker-C9suIA1S.js} +4 -4
  56. package/dist/frontend-ssr/assets/DeleteDialog-DxtMrS1O.js +159 -0
  57. package/dist/frontend-ssr/assets/{FolderNode-D9kgJG9d.js → FolderNode-ChD10Elp.js} +2 -2
  58. package/dist/frontend-ssr/assets/{HiAiEditor-DOd2MXjD.js → HiAiEditor-2X3Uyg1B.js} +60 -54
  59. package/dist/frontend-ssr/assets/{SettingsDialog-CIVbMKmf.js → SettingsDialog-DDy0hN8x.js} +373 -361
  60. package/dist/frontend-ssr/assets/{ShareDialog-D2UNUbF7.js → ShareDialog-BwW_wF4G.js} +2 -2
  61. package/dist/frontend-ssr/assets/{Sidebar-Bb-k2R-Z.js → Sidebar-Dy-5gXOf.js} +170 -129
  62. package/dist/frontend-ssr/assets/{TagCreateDialog-6Gk7L3D-.js → TagCreateDialog-BPzgOaX8.js} +94 -89
  63. package/dist/frontend-ssr/assets/{confirm-dialog-B9MVS_bF.js → confirm-dialog-wYC07DPx.js} +109 -89
  64. package/dist/frontend-ssr/assets/{dialog-1SB5neow.js → dialog-ClcuF7nD.js} +47 -12
  65. package/dist/frontend-ssr/assets/{dropdown-menu-DqoOkdqB.js → dropdown-menu-BKMGVNLL.js} +6 -6
  66. package/dist/frontend-ssr/assets/editor-content-sanitizer-Gjm93iR-.js +145 -0
  67. package/dist/frontend-ssr/assets/{editorExtensions-BwGeSPuX.js → editorExtensions-qNlZVP98.js} +2 -88
  68. package/dist/frontend-ssr/assets/{input-Df-QP3Km.js → input-DcDR8L8M.js} +2 -2
  69. package/dist/frontend-ssr/assets/{label-CbUOUz6L.js → label-Cz0_svJx.js} +2 -2
  70. package/dist/frontend-ssr/assets/{markdown-CB8DZ-LT.js → markdown-MhPwNWrC.js} +1 -1
  71. package/dist/frontend-ssr/assets/{messages-BAQzILs4.js → messages-B1TjVIH8.js} +2 -2
  72. package/dist/frontend-ssr/assets/{select-value-CXEDWrZg.js → select-value-CaDktvDW.js} +6 -6
  73. package/dist/frontend-ssr/assets/{textarea-CHh8NuSS.js → textarea-BGrjPOgU.js} +2 -2
  74. package/dist/frontend-ssr/assets/theme.svelte-CN3BUhJG.js +136 -0
  75. package/dist/frontend-ssr/assets/{utils-DtX0ta7y.js → utils-Cg_R05dR.js} +1 -1
  76. package/dist/frontend-ssr/components/category-dialog.js +1 -1
  77. package/dist/frontend-ssr/components/create-snapshot-dialog.js +1 -1
  78. package/dist/frontend-ssr/components/delete-dialog.js +1 -1
  79. package/dist/frontend-ssr/components/editor/compact-editor.js +1 -1
  80. package/dist/frontend-ssr/components/editor/document-editor.js +1 -1
  81. package/dist/frontend-ssr/components/editor/document-title.js +1 -1
  82. package/dist/frontend-ssr/components/editor/extensions.js +1 -1
  83. package/dist/frontend-ssr/components/editor/markdown-toggle.js +2 -2
  84. package/dist/frontend-ssr/components/editor/markdown.js +1 -1
  85. package/dist/frontend-ssr/components/folder-node.js +1 -1
  86. package/dist/frontend-ssr/components/save-as-dialog.js +177 -172
  87. package/dist/frontend-ssr/components/settings.js +1 -1
  88. package/dist/frontend-ssr/components/share-dialog.js +1 -1
  89. package/dist/frontend-ssr/components/sidebar.js +1 -1
  90. package/dist/frontend-ssr/components/tag-create-dialog.js +1 -1
  91. package/dist/frontend-ssr/components/version-history.js +3 -3
  92. package/dist/frontend-ssr/dashboard.js +102 -95
  93. package/dist/frontend-ssr/i18n.js +1 -1
  94. package/dist/frontend-ssr/search.js +3 -3
  95. package/dist/frontend-ssr/shared-document.js +3 -0
  96. package/dist/frontend-ssr/theme.js +1 -1
  97. package/dist/mcp-cli.js +1 -1
  98. package/dist/mcp-server.js +1 -1
  99. package/package.json +1 -1
  100. package/packages/cli/src/index.ts +4 -3
  101. package/server.json +43 -6
  102. package/dist/frontend/CategoryDialog-C67_TXf0.js +0 -626
  103. package/dist/frontend/ConfirmDialog-_LlrA--f.js +0 -134
  104. package/dist/frontend/CreateSnapshotDialog-BmCRpOMv.js +0 -217
  105. package/dist/frontend/DeleteDialog-L1A3FhMM.js +0 -174
  106. package/dist/frontend/SettingsDialog-AP42xOGg.js +0 -969
  107. package/dist/frontend/Sidebar-lKQT3dEf.js +0 -2060
  108. package/dist/frontend/TagCreateDialog-su8BhLzS.js +0 -261
  109. package/dist/frontend/confirm-dialog-BG8y2Pum.js +0 -250
  110. package/dist/frontend/dialog-C2iKObEu.js +0 -213
  111. package/dist/frontend/messages-DIovIZrK.js +0 -1093
  112. package/dist/frontend/theme.svelte-DKfCy12k.js +0 -49
  113. package/dist/frontend-ssr/assets/CategoryDialog-BGuHTb3K.js +0 -603
  114. package/dist/frontend-ssr/assets/ConfirmDialog-D1BDXXll.js +0 -131
  115. package/dist/frontend-ssr/assets/DeleteDialog-oHT_p_vG.js +0 -154
  116. package/dist/frontend-ssr/assets/theme.svelte-Co0-ssaD.js +0 -67
@@ -1,49 +0,0 @@
1
- import * as e from "svelte/internal/client";
2
- import { browser as t } from "$app/environment";
3
- //#region src/lib/stores/theme.svelte.ts
4
- var n = "hiai-docs-theme", r = /* @__PURE__ */ new Set();
5
- function i() {
6
- if (!t) return "system";
7
- let e = localStorage.getItem(n);
8
- return e === "light" || e === "dark" || e === "system" ? e : "system";
9
- }
10
- function a() {
11
- return t ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1;
12
- }
13
- function o(e) {
14
- return e === "dark" ? !0 : e === "light" ? !1 : a();
15
- }
16
- function s(e) {
17
- if (!t) return;
18
- let n = o(e);
19
- document.documentElement.classList.toggle("dark", n);
20
- let r = document.querySelector("#app-favicon");
21
- r && (r.href = n ? "/favicon_white.ico" : "/favicon.ico");
22
- }
23
- function c() {
24
- for (let e of r) e();
25
- }
26
- var l = e.state("system"), u = e.state(!1), d = !1;
27
- function f() {
28
- if (!t || d) return;
29
- d = !0, e.set(l, i(), !0), e.set(u, o(e.get(l)), !0), s(e.get(l));
30
- let n = window.matchMedia("(prefers-color-scheme: dark)");
31
- n.addEventListener("change", () => {
32
- e.get(l) === "system" && (e.set(u, n.matches, !0), s("system"), c());
33
- });
34
- }
35
- function p(r) {
36
- e.set(l, r, !0), t && localStorage.setItem(n, r), e.set(u, o(r), !0), s(r), c();
37
- }
38
- var m = {
39
- get value() {
40
- return e.get(l);
41
- },
42
- get isDark() {
43
- return e.get(u);
44
- },
45
- init: f,
46
- set: p
47
- };
48
- //#endregion
49
- export { m as t };
@@ -1,603 +0,0 @@
1
- import { S as categories_create_title, _ as categories_delete_error, _n as action_cancel, b as categories_name_placeholder, g as categories_delete_title, gn as action_delete, h as categories_delete_description, m as categories_delete_success, mn as action_create, p as categories_delete_success_description, v as categories_update_error, vn as action_save, x as categories_edit_title, y as categories_create_error } from "./messages-BAQzILs4.js";
2
- import { t as Copy } from "./copy-DkkCPkBL.js";
3
- import { t as Circle_check } from "./circle-check-CPS9dKEo.js";
4
- import { t as Loader_circle } from "./loader-circle-CIEWGyfP.js";
5
- import { a as getDocsmintRequestAdapter } from "./route-context-BPRerEtZ.js";
6
- import { a as Dialog, i as Dialog_description, n as Dialog_header, o as Button, r as Dialog_footer, t as Dialog_title } from "./dialog-1SB5neow.js";
7
- import { t as Input } from "./input-Df-QP3Km.js";
8
- import { t as Label } from "./label-CbUOUz6L.js";
9
- import { a as listApiKeys, n as categoryIdFromScopes, o as revealCategoryApiKey, r as createCategoryApiKey, s as revokeApiKey, t as apiKeyClipboardValue } from "./api-keys-DIbclwj5.js";
10
- import { a as Select, i as Select_content, n as Select_trigger, r as Select_item, t as Select_value } from "./select-value-CXEDWrZg.js";
11
- import * as $ from "svelte/internal/server";
12
- //#region src/lib/components/sidebar/category-api-key-flow.ts
13
- async function issueCategoryKeyAfterSavingAccess(input) {
14
- if (!input.draft.name.trim()) throw new Error("Name is required");
15
- if (input.draft.apiMode !== "category") throw new Error("Select Category API access");
16
- if (!input.draft.apiPermissionRead && !input.draft.apiPermissionEdit && !input.draft.apiPermissionWrite) throw new Error("Select at least one permission");
17
- const saved = await input.save(input.draft);
18
- if (!saved || saved.id !== input.categoryId) throw new Error("Failed to save Category API access");
19
- return input.issue(input.categoryId);
20
- }
21
- //#endregion
22
- //#region src/lib/components/sidebar/category-dialog-feedback.ts
23
- function categoryDialogErrorMessage(error, fallback) {
24
- if (typeof error === "object" && error !== null && "status" in error && error.status === 409) return "A category with this name already exists.";
25
- if (error instanceof Error && error.message.trim().length > 0) return error.message;
26
- return fallback;
27
- }
28
- //#endregion
29
- //#region src/lib/components/sidebar/CategoryDialog.svelte
30
- function CategoryDialog($$renderer, $$props) {
31
- $$renderer.component(($$renderer) => {
32
- const Select$1 = {
33
- Root: Select,
34
- Content: Select_content,
35
- Item: Select_item,
36
- Trigger: Select_trigger,
37
- Value: Select_value
38
- };
39
- const request = getDocsmintRequestAdapter();
40
- let { open = false, mode, category, onSave, onDelete, onClose } = $$props;
41
- let name = "";
42
- let error = null;
43
- let busy = false;
44
- let apiMode = "unavailable";
45
- let apiPermissionRead = false;
46
- let apiPermissionEdit = false;
47
- let apiPermissionWrite = false;
48
- let categoryKeys = [];
49
- let issuedKeys = {};
50
- let latestIssuedId = null;
51
- let keyBusy = false;
52
- let createdCategoryName = null;
53
- let createdCategoryKey = null;
54
- let deletedCategoryName = null;
55
- const latestIssuedKey = $.derived(() => latestIssuedId ? issuedKeys[latestIssuedId] : void 0);
56
- async function refreshCategoryKeys(categoryId) {
57
- categoryKeys = (await listApiKeys(request.fetch)).keys.filter((key) => categoryIdFromScopes(key.scopes) === categoryId);
58
- }
59
- async function issueCategoryKey() {
60
- if (!category?.id || !onSave) return;
61
- keyBusy = true;
62
- error = null;
63
- try {
64
- const issued = await issueCategoryKeyAfterSavingAccess({
65
- categoryId: category.id,
66
- draft: {
67
- name: trimmedName(),
68
- apiMode: normalizeApiMode(apiMode),
69
- apiPermissionRead,
70
- apiPermissionEdit,
71
- apiPermissionWrite
72
- },
73
- save: async (payload) => onSave(payload),
74
- issue: async (categoryId) => createCategoryApiKey(categoryId, void 0, request.fetch)
75
- });
76
- issuedKeys = {
77
- ...issuedKeys,
78
- [issued.id]: issued.key
79
- };
80
- latestIssuedId = issued.id;
81
- await refreshCategoryKeys(category.id);
82
- } catch (err) {
83
- error = err instanceof Error ? err.message : "Failed to create category API key";
84
- } finally {
85
- keyBusy = false;
86
- }
87
- }
88
- async function revokeCategoryKey(id) {
89
- if (!category?.id) return;
90
- keyBusy = true;
91
- try {
92
- await revokeApiKey(id, request.fetch);
93
- const { [id]: _revoked, ...remainingIssuedKeys } = issuedKeys;
94
- issuedKeys = remainingIssuedKeys;
95
- if (latestIssuedId === id) latestIssuedId = null;
96
- await refreshCategoryKeys(category.id);
97
- } finally {
98
- keyBusy = false;
99
- }
100
- }
101
- async function copyCategoryKey(key) {
102
- const rawKey = issuedKeys[key.id] ?? await revealCategoryApiKey(key.id, request.fetch);
103
- await navigator.clipboard.writeText(apiKeyClipboardValue(key, rawKey));
104
- }
105
- const trimmedName = $.derived(() => name.trim());
106
- const isDeleteMode = $.derived(() => mode === "delete");
107
- const hasAnyPermission = $.derived(() => apiPermissionRead || apiPermissionEdit || apiPermissionWrite);
108
- const title = $.derived(() => deletedCategoryName ? categories_delete_success() : isDeleteMode() ? categories_delete_title() : mode === "edit" ? categories_edit_title() : categories_create_title());
109
- const submitLabel = $.derived(() => isDeleteMode() ? action_delete() : mode === "edit" ? action_save() : action_create());
110
- function normalizeApiMode(value) {
111
- if (value === "category") return "category";
112
- if (value === "global") return "global";
113
- return "unavailable";
114
- }
115
- function applyPermissionPreset(preset) {
116
- if (preset === "read") {
117
- apiPermissionRead = true;
118
- apiPermissionEdit = false;
119
- apiPermissionWrite = false;
120
- return;
121
- }
122
- if (preset === "write") {
123
- apiPermissionRead = false;
124
- apiPermissionEdit = false;
125
- apiPermissionWrite = true;
126
- return;
127
- }
128
- if (preset === "read-write") {
129
- apiPermissionRead = true;
130
- apiPermissionEdit = false;
131
- apiPermissionWrite = true;
132
- return;
133
- }
134
- apiPermissionRead = true;
135
- apiPermissionEdit = true;
136
- apiPermissionWrite = true;
137
- }
138
- async function handleSubmit(e) {
139
- e?.preventDefault();
140
- if (busy) return;
141
- if (isDeleteMode()) {
142
- if (!onDelete) {
143
- close();
144
- return;
145
- }
146
- busy = true;
147
- try {
148
- await onDelete();
149
- deletedCategoryName = category?.name ?? "Category";
150
- } catch (err) {
151
- console.error("CategoryDialog: delete failed", err);
152
- error = err instanceof Error ? err.message : categories_delete_error();
153
- } finally {
154
- busy = false;
155
- }
156
- return;
157
- }
158
- if (trimmedName().length === 0) {
159
- error = "Name is required";
160
- return;
161
- }
162
- if (apiMode !== "unavailable" && !hasAnyPermission()) {
163
- error = "Select at least one permission";
164
- return;
165
- }
166
- if (!onSave) {
167
- close();
168
- return;
169
- }
170
- error = null;
171
- busy = true;
172
- try {
173
- const savedCategory = await onSave({
174
- name: trimmedName(),
175
- apiMode: normalizeApiMode(apiMode),
176
- apiPermissionRead: apiMode === "unavailable" ? false : apiPermissionRead,
177
- apiPermissionEdit: apiMode === "unavailable" ? false : apiPermissionEdit,
178
- apiPermissionWrite: apiMode === "unavailable" ? false : apiPermissionWrite
179
- });
180
- if (mode === "create" && savedCategory) {
181
- createdCategoryName = savedCategory.name;
182
- if (apiMode === "category") try {
183
- createdCategoryKey = (await createCategoryApiKey(savedCategory.id, void 0, request.fetch)).key;
184
- } catch (keyError) {
185
- error = `Category created, but its API key could not be created: ${categoryDialogErrorMessage(keyError, "Unknown error")}`;
186
- }
187
- return;
188
- }
189
- close();
190
- } catch (err) {
191
- console.error("CategoryDialog: save failed", err);
192
- error = categoryDialogErrorMessage(err, mode === "edit" ? categories_update_error() : categories_create_error());
193
- } finally {
194
- busy = false;
195
- }
196
- }
197
- function close() {
198
- if (busy) return;
199
- open = false;
200
- onClose?.();
201
- }
202
- function handleDialogOpenChange(next) {
203
- if (!next && busy) {
204
- open = true;
205
- return;
206
- }
207
- if (!next) close();
208
- }
209
- let $$settled = true;
210
- let $$inner_renderer;
211
- function $$render_inner($$renderer) {
212
- Dialog($$renderer, {
213
- onOpenChange: handleDialogOpenChange,
214
- get open() {
215
- return open;
216
- },
217
- set open($$value) {
218
- open = $$value;
219
- $$settled = false;
220
- },
221
- children: ($$renderer) => {
222
- Dialog_header($$renderer, {
223
- children: ($$renderer) => {
224
- Dialog_title($$renderer, {
225
- children: ($$renderer) => {
226
- $$renderer.push(`<!---->${$.escape(title())}`);
227
- },
228
- $$slots: { default: true }
229
- });
230
- $$renderer.push(`<!----> `);
231
- if (deletedCategoryName) {
232
- $$renderer.push("<!--[0-->");
233
- Dialog_description($$renderer, {
234
- children: ($$renderer) => {
235
- $$renderer.push(`<span class="font-medium text-foreground">“${$.escape(deletedCategoryName)}”</span> ${$.escape(categories_delete_success_description())}`);
236
- },
237
- $$slots: { default: true }
238
- });
239
- } else if (isDeleteMode()) {
240
- $$renderer.push("<!--[1-->");
241
- Dialog_description($$renderer, {
242
- children: ($$renderer) => {
243
- $$renderer.push(`<!---->Delete <span class="font-medium text-foreground">“${$.escape(category?.name ?? "Category")}”</span>?
244
- ${$.escape(categories_delete_description())}`);
245
- },
246
- $$slots: { default: true }
247
- });
248
- } else {
249
- $$renderer.push("<!--[-1-->");
250
- Dialog_description($$renderer, {
251
- children: ($$renderer) => {
252
- $$renderer.push(`<!---->${$.escape(categories_name_placeholder())}`);
253
- },
254
- $$slots: { default: true }
255
- });
256
- }
257
- $$renderer.push(`<!--]-->`);
258
- },
259
- $$slots: { default: true }
260
- });
261
- $$renderer.push(`<!----> `);
262
- if (deletedCategoryName) {
263
- $$renderer.push("<!--[0-->");
264
- $$renderer.push(`<div class="flex items-start gap-3 rounded-lg border border-primary/30 bg-primary/10 p-4" role="status" aria-live="polite">`);
265
- Circle_check($$renderer, { class: "mt-0.5 size-5 shrink-0 text-primary" });
266
- $$renderer.push(`<!----> <div><p class="text-sm font-medium text-foreground">${$.escape(categories_delete_success())}</p> <p class="text-sm text-muted-foreground"><span class="font-medium text-foreground">“${$.escape(deletedCategoryName)}”</span> ${$.escape(categories_delete_success_description())}</p></div></div>`);
267
- } else if (createdCategoryName) {
268
- $$renderer.push("<!--[1-->");
269
- $$renderer.push(`<div class="space-y-3 rounded-lg border border-primary/30 bg-primary/10 p-4" role="status" aria-live="polite"><div class="flex items-start gap-3">`);
270
- Circle_check($$renderer, { class: "mt-0.5 size-5 shrink-0 text-primary" });
271
- $$renderer.push(`<!----> <div><p class="text-sm font-medium text-foreground">Category created</p> <p class="text-sm text-muted-foreground">${$.escape(createdCategoryName)} is ready to use.</p></div></div> `);
272
- if (createdCategoryKey) {
273
- $$renderer.push("<!--[0-->");
274
- $$renderer.push(`<div class="rounded-md border border-primary/20 bg-background/80 p-3"><p class="text-xs font-medium text-foreground">Copy the API key now. It remains available in Settings → API.</p> <code class="mt-2 block break-all rounded bg-muted p-2 text-xs text-foreground">${$.escape(createdCategoryKey)}</code> `);
275
- Button($$renderer, {
276
- type: "button",
277
- size: "sm",
278
- variant: "outline",
279
- class: "mt-2",
280
- onclick: () => navigator.clipboard.writeText(createdCategoryKey ?? ""),
281
- children: ($$renderer) => {
282
- Copy($$renderer, { class: "mr-1 size-3.5" });
283
- $$renderer.push(`<!----> Copy API key`);
284
- },
285
- $$slots: { default: true }
286
- });
287
- $$renderer.push(`<!----></div>`);
288
- } else $$renderer.push("<!--[-1-->");
289
- $$renderer.push(`<!--]--> `);
290
- if (error) {
291
- $$renderer.push("<!--[0-->");
292
- $$renderer.push(`<p class="text-xs text-destructive" role="alert">${$.escape(error)}</p>`);
293
- } else $$renderer.push("<!--[-1-->");
294
- $$renderer.push(`<!--]--></div>`);
295
- } else if (!isDeleteMode()) {
296
- $$renderer.push("<!--[2-->");
297
- $$renderer.push(`<form data-category-dialog-scroll="" class="max-h-[calc(100dvh-12rem)] space-y-4 overflow-y-auto overscroll-contain pr-1"><div class="space-y-2">`);
298
- Label($$renderer, {
299
- for: "category-dialog-name",
300
- children: ($$renderer) => {
301
- $$renderer.push(`<!---->${$.escape(categories_name_placeholder())}`);
302
- },
303
- $$slots: { default: true }
304
- });
305
- $$renderer.push(`<!----> `);
306
- Input($$renderer, {
307
- id: "category-dialog-name",
308
- name: "name",
309
- type: "text",
310
- placeholder: categories_name_placeholder(),
311
- maxlength: 255,
312
- required: true,
313
- disabled: busy,
314
- "aria-invalid": error ? "true" : void 0,
315
- "aria-describedby": error ? "category-dialog-name-error" : void 0,
316
- autocomplete: "off",
317
- get value() {
318
- return name;
319
- },
320
- set value($$value) {
321
- name = $$value;
322
- $$settled = false;
323
- }
324
- });
325
- $$renderer.push(`<!----> `);
326
- if (error) {
327
- $$renderer.push("<!--[0-->");
328
- $$renderer.push(`<p id="category-dialog-name-error" class="text-xs text-destructive" role="alert">${$.escape(error)}</p>`);
329
- } else $$renderer.push("<!--[-1-->");
330
- $$renderer.push(`<!--]--></div> <div class="space-y-2">`);
331
- Label($$renderer, {
332
- for: "category-dialog-api-mode",
333
- children: ($$renderer) => {
334
- $$renderer.push(`<!---->API access`);
335
- },
336
- $$slots: { default: true }
337
- });
338
- $$renderer.push(`<!----> `);
339
- if (Select$1.Root) {
340
- $$renderer.push("<!--[-->");
341
- Select$1.Root($$renderer, {
342
- type: "single",
343
- value: apiMode,
344
- disabled: busy,
345
- onValueChange: (value) => {
346
- if (value === "unavailable" || value === "global" || value === "category") apiMode = value;
347
- },
348
- children: ($$renderer) => {
349
- if (Select$1.Trigger) {
350
- $$renderer.push("<!--[-->");
351
- Select$1.Trigger($$renderer, {
352
- id: "category-dialog-api-mode",
353
- class: "h-10 w-full",
354
- children: ($$renderer) => {
355
- if (Select$1.Value) {
356
- $$renderer.push("<!--[-->");
357
- Select$1.Value($$renderer, {
358
- placeholder: "Select API access",
359
- children: ($$renderer) => {
360
- $$renderer.push(`<!---->${$.escape(apiMode === "unavailable" ? "Unavailable" : apiMode === "global" ? "Global" : "Category API")}`);
361
- },
362
- $$slots: { default: true }
363
- });
364
- $$renderer.push("<!--]-->");
365
- } else {
366
- $$renderer.push("<!--[!-->");
367
- $$renderer.push("<!--]-->");
368
- }
369
- },
370
- $$slots: { default: true }
371
- });
372
- $$renderer.push("<!--]-->");
373
- } else {
374
- $$renderer.push("<!--[!-->");
375
- $$renderer.push("<!--]-->");
376
- }
377
- $$renderer.push(` `);
378
- if (Select$1.Content) {
379
- $$renderer.push("<!--[-->");
380
- Select$1.Content($$renderer, {
381
- children: ($$renderer) => {
382
- if (Select$1.Item) {
383
- $$renderer.push("<!--[-->");
384
- Select$1.Item($$renderer, {
385
- value: "unavailable",
386
- children: ($$renderer) => {
387
- $$renderer.push(`<!---->Unavailable`);
388
- },
389
- $$slots: { default: true }
390
- });
391
- $$renderer.push("<!--]-->");
392
- } else {
393
- $$renderer.push("<!--[!-->");
394
- $$renderer.push("<!--]-->");
395
- }
396
- $$renderer.push(` `);
397
- if (Select$1.Item) {
398
- $$renderer.push("<!--[-->");
399
- Select$1.Item($$renderer, {
400
- value: "global",
401
- children: ($$renderer) => {
402
- $$renderer.push(`<!---->Global`);
403
- },
404
- $$slots: { default: true }
405
- });
406
- $$renderer.push("<!--]-->");
407
- } else {
408
- $$renderer.push("<!--[!-->");
409
- $$renderer.push("<!--]-->");
410
- }
411
- $$renderer.push(` `);
412
- if (Select$1.Item) {
413
- $$renderer.push("<!--[-->");
414
- Select$1.Item($$renderer, {
415
- value: "category",
416
- children: ($$renderer) => {
417
- $$renderer.push(`<!---->Category API`);
418
- },
419
- $$slots: { default: true }
420
- });
421
- $$renderer.push("<!--]-->");
422
- } else {
423
- $$renderer.push("<!--[!-->");
424
- $$renderer.push("<!--]-->");
425
- }
426
- },
427
- $$slots: { default: true }
428
- });
429
- $$renderer.push("<!--]-->");
430
- } else {
431
- $$renderer.push("<!--[!-->");
432
- $$renderer.push("<!--]-->");
433
- }
434
- },
435
- $$slots: { default: true }
436
- });
437
- $$renderer.push("<!--]-->");
438
- } else {
439
- $$renderer.push("<!--[!-->");
440
- $$renderer.push("<!--]-->");
441
- }
442
- $$renderer.push(`</div> `);
443
- if (apiMode !== "unavailable") {
444
- $$renderer.push("<!--[0-->");
445
- $$renderer.push(`<div class="space-y-3 rounded-md border border-border/70 bg-muted/30 p-3"><div class="flex flex-wrap items-center justify-between gap-2">`);
446
- Label($$renderer, {
447
- class: "text-sm",
448
- children: ($$renderer) => {
449
- $$renderer.push(`<!---->Permissions`);
450
- },
451
- $$slots: { default: true }
452
- });
453
- $$renderer.push(`<!----> <div class="flex flex-wrap gap-2">`);
454
- Button($$renderer, {
455
- type: "button",
456
- variant: "outline",
457
- size: "sm",
458
- onclick: () => applyPermissionPreset("read-write"),
459
- children: ($$renderer) => {
460
- $$renderer.push(`<!---->Read / Write`);
461
- },
462
- $$slots: { default: true }
463
- });
464
- $$renderer.push(`<!----> `);
465
- Button($$renderer, {
466
- type: "button",
467
- variant: "outline",
468
- size: "sm",
469
- onclick: () => applyPermissionPreset("read-edit-write"),
470
- children: ($$renderer) => {
471
- $$renderer.push(`<!---->Read / Edit / Write`);
472
- },
473
- $$slots: { default: true }
474
- });
475
- $$renderer.push(`<!----></div></div> <div class="grid gap-2 sm:grid-cols-3"><label class="flex items-center gap-2 rounded-md border border-border/60 bg-background px-3 py-2 text-sm"><input${$.attr("checked", apiPermissionRead, true)}${$.attr("disabled", busy, true)} type="checkbox" class="size-4 rounded border-input"/> <span>Read</span></label> <label class="flex items-center gap-2 rounded-md border border-border/60 bg-background px-3 py-2 text-sm"><input${$.attr("checked", apiPermissionEdit, true)}${$.attr("disabled", busy, true)} type="checkbox" class="size-4 rounded border-input"/> <span>Edit</span></label> <label class="flex items-center gap-2 rounded-md border border-border/60 bg-background px-3 py-2 text-sm"><input${$.attr("checked", apiPermissionWrite, true)}${$.attr("disabled", busy, true)} type="checkbox" class="size-4 rounded border-input"/> <span>Write</span></label></div></div>`);
476
- } else $$renderer.push("<!--[-1-->");
477
- $$renderer.push(`<!--]--> `);
478
- if (mode === "edit" && apiMode === "category" && category?.id) {
479
- $$renderer.push("<!--[0-->");
480
- $$renderer.push(`<div class="space-y-3 rounded-md border border-border/70 p-3"><div class="flex items-center justify-between gap-2 max-sm:flex-col max-sm:items-stretch"><div>`);
481
- Label($$renderer, {
482
- children: ($$renderer) => {
483
- $$renderer.push(`<!---->Category API keys`);
484
- },
485
- $$slots: { default: true }
486
- });
487
- $$renderer.push(`<!----> <p class="text-xs text-muted-foreground">The current permissions are saved before the key is issued.</p></div> `);
488
- Button($$renderer, {
489
- type: "button",
490
- size: "sm",
491
- onclick: issueCategoryKey,
492
- disabled: busy || keyBusy || !trimmedName() || !hasAnyPermission(),
493
- children: ($$renderer) => {
494
- $$renderer.push(`<!---->Create key`);
495
- },
496
- $$slots: { default: true }
497
- });
498
- $$renderer.push(`<!----></div> `);
499
- if (latestIssuedKey()) {
500
- $$renderer.push("<!--[0-->");
501
- $$renderer.push(`<div class="rounded-lg border border-primary/30 bg-primary/10 p-3 text-primary"><p class="text-xs font-medium">Copy now — this raw key is shown once.</p> <code class="mt-1 block break-all rounded bg-background/80 p-2 text-xs text-foreground">${$.escape(latestIssuedKey())}</code> `);
502
- Button($$renderer, {
503
- type: "button",
504
- size: "sm",
505
- variant: "outline",
506
- class: "mt-2",
507
- onclick: () => navigator.clipboard.writeText(latestIssuedKey()),
508
- children: ($$renderer) => {
509
- $$renderer.push(`<!---->Copy key`);
510
- },
511
- $$slots: { default: true }
512
- });
513
- $$renderer.push(`<!----></div>`);
514
- } else $$renderer.push("<!--[-1-->");
515
- $$renderer.push(`<!--]--> <div class="max-h-48 space-y-2 overflow-y-auto pr-1"><!--[-->`);
516
- const each_array = $.ensure_array_like(categoryKeys);
517
- for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
518
- let key = each_array[$$index];
519
- $$renderer.push(`<div class="flex items-center justify-between gap-3 rounded-md bg-muted/40 px-3 py-2 text-xs"><span>${$.escape(key.name)} · ${$.escape(key.prefix)}…</span> <div class="flex shrink-0 gap-2">`);
520
- Button($$renderer, {
521
- type: "button",
522
- size: "sm",
523
- variant: "outline",
524
- onclick: () => copyCategoryKey(key),
525
- disabled: !key.recoverable && !issuedKeys[key.id],
526
- children: ($$renderer) => {
527
- $$renderer.push(`<!---->${$.escape(key.recoverable || issuedKeys[key.id] ? "Copy key" : "Rotate to enable copy")}`);
528
- },
529
- $$slots: { default: true }
530
- });
531
- $$renderer.push(`<!----> `);
532
- Button($$renderer, {
533
- type: "button",
534
- size: "sm",
535
- variant: "destructive",
536
- onclick: () => revokeCategoryKey(key.id),
537
- disabled: keyBusy,
538
- children: ($$renderer) => {
539
- $$renderer.push(`<!---->Revoke`);
540
- },
541
- $$slots: { default: true }
542
- });
543
- $$renderer.push(`<!----></div></div>`);
544
- }
545
- $$renderer.push(`<!--]--></div></div>`);
546
- } else $$renderer.push("<!--[-1-->");
547
- $$renderer.push(`<!--]--></form>`);
548
- } else if (error) {
549
- $$renderer.push("<!--[3-->");
550
- $$renderer.push(`<p class="text-xs text-destructive" role="alert">${$.escape(error)}</p>`);
551
- } else $$renderer.push("<!--[-1-->");
552
- $$renderer.push(`<!--]--> `);
553
- Dialog_footer($$renderer, {
554
- class: "gap-2 max-sm:flex-col max-sm:items-stretch",
555
- children: ($$renderer) => {
556
- if (!createdCategoryName && !deletedCategoryName) {
557
- $$renderer.push("<!--[0-->");
558
- Button($$renderer, {
559
- variant: "outline",
560
- type: "button",
561
- onclick: close,
562
- disabled: busy,
563
- children: ($$renderer) => {
564
- $$renderer.push(`<!---->${$.escape(action_cancel())}`);
565
- },
566
- $$slots: { default: true }
567
- });
568
- } else $$renderer.push("<!--[-1-->");
569
- $$renderer.push(`<!--]--> `);
570
- Button($$renderer, {
571
- type: isDeleteMode() ? "button" : "submit",
572
- variant: isDeleteMode() ? "destructive" : "default",
573
- onclick: createdCategoryName || deletedCategoryName ? close : handleSubmit,
574
- disabled: busy || !isDeleteMode() && !createdCategoryName && !deletedCategoryName && trimmedName().length === 0,
575
- children: ($$renderer) => {
576
- if (busy) {
577
- $$renderer.push("<!--[0-->");
578
- Loader_circle($$renderer, { class: "mr-1 size-4 animate-spin" });
579
- } else $$renderer.push("<!--[-1-->");
580
- $$renderer.push(`<!--]--> ${$.escape(createdCategoryName || deletedCategoryName ? "Done" : submitLabel())}`);
581
- },
582
- $$slots: { default: true }
583
- });
584
- $$renderer.push(`<!---->`);
585
- },
586
- $$slots: { default: true }
587
- });
588
- $$renderer.push(`<!---->`);
589
- },
590
- $$slots: { default: true }
591
- });
592
- }
593
- do {
594
- $$settled = true;
595
- $$inner_renderer = $$renderer.copy();
596
- $$render_inner($$inner_renderer);
597
- } while (!$$settled);
598
- $$renderer.subsume($$inner_renderer);
599
- $.bind_props($$props, { open });
600
- });
601
- }
602
- //#endregion
603
- export { CategoryDialog as t };