@keepkit/ui 0.27.3 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ function useKeepUrlSync({
51
51
  ...decoded.tags ? { tags: decoded.tags } : { tags: void 0 },
52
52
  ...decoded.sort ? { sort: decoded.sort } : {},
53
53
  ...decoded.pagination ? { pagination: { ...previousQuery.pagination, ...decoded.pagination } } : {},
54
+ ...decoded.activity ? { activity: decoded.activity } : {},
54
55
  ...decoded.archiveScope !== void 0 ? { archived: decoded.archived, archiveScope: decoded.archiveScope } : decoded.archived !== void 0 ? { archived: decoded.archived, archiveScope: void 0 } : { archived: void 0, archiveScope: void 0 }
55
56
  }));
56
57
  };
@@ -2217,160 +2218,6 @@ function KeepPinButton({
2217
2218
  );
2218
2219
  }
2219
2220
 
2220
- // src/features/actions/hooks/useKeepBackup.ts
2221
- import { useKeepContext } from "@keepkit/core/react";
2222
- import { useRef as useRef2, useState } from "react";
2223
- function useKeepBackup({ filename, onExport, onImported }) {
2224
- const context = useKeepContext();
2225
- const inputRef = useRef2(null);
2226
- const [mode, setMode] = useState("merge");
2227
- const [result, setResult] = useState();
2228
- const [error, setError] = useState();
2229
- async function exportBackup() {
2230
- setError(void 0);
2231
- try {
2232
- const data = await context.exportBackup();
2233
- onExport?.(data);
2234
- if (typeof document === "undefined") return;
2235
- const url = URL.createObjectURL(new Blob([data], { type: "application/json" }));
2236
- const anchor = document.createElement("a");
2237
- anchor.href = url;
2238
- anchor.download = filename;
2239
- anchor.click();
2240
- URL.revokeObjectURL(url);
2241
- } catch (cause) {
2242
- setError(cause);
2243
- }
2244
- }
2245
- async function importBackup(event) {
2246
- const file = event.currentTarget.files?.[0];
2247
- event.currentTarget.value = "";
2248
- if (!file) return;
2249
- setError(void 0);
2250
- setResult(void 0);
2251
- try {
2252
- const imported = await context.importBackup(await file.text(), { mode });
2253
- setResult(imported);
2254
- onImported?.(imported);
2255
- } catch (cause) {
2256
- setError(cause);
2257
- }
2258
- }
2259
- return {
2260
- inputRef,
2261
- mode,
2262
- setMode,
2263
- result,
2264
- error,
2265
- isMutating: context.isMutating,
2266
- exportBackup,
2267
- importBackup,
2268
- openFilePicker: () => inputRef.current?.click(),
2269
- labels: {
2270
- export: useUiLabel("exportData"),
2271
- import: useUiLabel("importData"),
2272
- importMode: useUiLabel("importMode"),
2273
- merge: useUiLabel("merge"),
2274
- replace: useUiLabel("replace"),
2275
- importedCount: useUiLabel("importedCount"),
2276
- failedCount: useUiLabel("failedCount"),
2277
- quotaError: useUiLabel("storageQuotaError")
2278
- }
2279
- };
2280
- }
2281
-
2282
- // src/features/actions/KeepBackup.tsx
2283
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2284
- function KeepBackup({
2285
- filename = "keepkit-backup.json",
2286
- onExport,
2287
- onImported,
2288
- ...props
2289
- }) {
2290
- const view = useKeepBackup({ filename, onExport, onImported });
2291
- const showExportLabel = useUiLabelVisibility("exportData");
2292
- const showImportModeLabel = useUiLabelVisibility("importMode");
2293
- const showImportLabel = useUiLabelVisibility("importData");
2294
- return /* @__PURE__ */ jsxs2(
2295
- "section",
2296
- {
2297
- ...props,
2298
- "data-keepkit": "backup",
2299
- "data-state": view.error ? "error" : view.result ? "complete" : "idle",
2300
- "data-loading": view.isMutating ? "true" : void 0,
2301
- children: [
2302
- /* @__PURE__ */ jsx2(
2303
- "button",
2304
- {
2305
- type: "button",
2306
- "data-keep-action": "export-backup",
2307
- onClick: () => void view.exportBackup(),
2308
- disabled: view.isMutating,
2309
- "aria-label": showExportLabel ? void 0 : view.labels.export,
2310
- children: showExportLabel ? view.labels.export : null
2311
- }
2312
- ),
2313
- /* @__PURE__ */ jsxs2("label", { children: [
2314
- showImportModeLabel ? view.labels.importMode : null,
2315
- /* @__PURE__ */ jsxs2(
2316
- "select",
2317
- {
2318
- "data-keep-action": "select-import-mode",
2319
- value: view.mode,
2320
- "aria-label": showImportModeLabel ? void 0 : view.labels.importMode,
2321
- onChange: (event) => view.setMode(event.currentTarget.value),
2322
- children: [
2323
- /* @__PURE__ */ jsx2("option", { value: "merge", children: view.labels.merge }),
2324
- /* @__PURE__ */ jsx2("option", { value: "replace", children: view.labels.replace })
2325
- ]
2326
- }
2327
- )
2328
- ] }),
2329
- /* @__PURE__ */ jsx2(
2330
- "button",
2331
- {
2332
- type: "button",
2333
- "data-keep-action": "import-backup",
2334
- onClick: view.openFilePicker,
2335
- disabled: view.isMutating,
2336
- "aria-label": showImportLabel ? void 0 : view.labels.import,
2337
- children: showImportLabel ? view.labels.import : null
2338
- }
2339
- ),
2340
- /* @__PURE__ */ jsx2(
2341
- "input",
2342
- {
2343
- ref: view.inputRef,
2344
- type: "file",
2345
- "data-keep-action": "select-backup-file",
2346
- accept: "application/json,.json",
2347
- "aria-label": view.labels.import,
2348
- onChange: (event) => void view.importBackup(event)
2349
- }
2350
- ),
2351
- view.result ? /* @__PURE__ */ jsxs2("p", { role: "status", children: [
2352
- view.result.imported,
2353
- " ",
2354
- view.labels.importedCount,
2355
- "; ",
2356
- view.result.failed,
2357
- " ",
2358
- view.labels.failedCount
2359
- ] }) : null,
2360
- view.error ? /* @__PURE__ */ jsx2("p", { role: "alert", children: isQuotaError(view.error) ? view.labels.quotaError : getErrorMessage(view.error) }) : null
2361
- ]
2362
- }
2363
- );
2364
- }
2365
- function isQuotaError(error) {
2366
- if (error instanceof Error && error.name === "KeepStorageQuotaError") return true;
2367
- if (error && typeof error === "object" && "cause" in error) return isQuotaError(error.cause);
2368
- return false;
2369
- }
2370
- function getErrorMessage(error) {
2371
- return error instanceof Error ? error.message : "Something went wrong.";
2372
- }
2373
-
2374
2221
  // src/foundation/shared.tsx
2375
2222
  import {
2376
2223
  cloneElement,
@@ -2380,10 +2227,10 @@ import {
2380
2227
  useContext as useContext2,
2381
2228
  useMemo as useMemo2
2382
2229
  } from "react";
2383
- import { Fragment as Fragment2, jsx as jsx3 } from "react/jsx-runtime";
2230
+ import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
2384
2231
  var KeepSearchQueryContext = createContext2(void 0);
2385
2232
  function KeepSearchQueryProvider({ query, children }) {
2386
- return /* @__PURE__ */ jsx3(KeepSearchQueryContext.Provider, { value: query, children });
2233
+ return /* @__PURE__ */ jsx2(KeepSearchQueryContext.Provider, { value: query, children });
2387
2234
  }
2388
2235
  function useKeepSearchQuery() {
2389
2236
  return useContext2(KeepSearchQueryContext);
@@ -2410,14 +2257,14 @@ function highlightText(text, query) {
2410
2257
  const index = match.index;
2411
2258
  if (index > lastIndex) parts.push(text.slice(lastIndex, index));
2412
2259
  parts.push(
2413
- /* @__PURE__ */ jsx3("mark", { className: "keep-highlight", "data-highlight": "true", children: match[0] }, `highlight-${matchIndex}`)
2260
+ /* @__PURE__ */ jsx2("mark", { className: "keep-highlight", "data-highlight": "true", children: match[0] }, `highlight-${matchIndex}`)
2414
2261
  );
2415
2262
  lastIndex = index + match[0].length;
2416
2263
  matchIndex += 1;
2417
2264
  }
2418
2265
  if (lastIndex === 0) return text;
2419
2266
  if (lastIndex < text.length) parts.push(text.slice(lastIndex));
2420
- return /* @__PURE__ */ jsx3(Fragment2, { children: parts });
2267
+ return /* @__PURE__ */ jsx2(Fragment2, { children: parts });
2421
2268
  }
2422
2269
  function escapeRegExp(value) {
2423
2270
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -2439,6 +2286,9 @@ function getMetaTitle(meta) {
2439
2286
  const title = meta.title;
2440
2287
  return typeof title === "string" && title.trim() ? title.trim() : void 0;
2441
2288
  }
2289
+ function getErrorMessage(error, fallback) {
2290
+ return error instanceof Error ? error.message : fallback;
2291
+ }
2442
2292
  function normalizeUiTags(tags) {
2443
2293
  return [...new Set(tags.map((tag) => tag.trim()).filter(Boolean))];
2444
2294
  }
@@ -2531,7 +2381,158 @@ function renderRoot(asChild, child, props, body, componentName) {
2531
2381
  if (!isValidElement(child)) throw new Error(`${componentName} with asChild requires a single React element child.`);
2532
2382
  return createSlot(child, props, body);
2533
2383
  }
2534
- return /* @__PURE__ */ jsx3("div", { ...props, children: body });
2384
+ return /* @__PURE__ */ jsx2("div", { ...props, children: body });
2385
+ }
2386
+
2387
+ // src/features/actions/hooks/useKeepBackup.ts
2388
+ import { useKeepContext } from "@keepkit/core/react";
2389
+ import { useRef as useRef2, useState } from "react";
2390
+ function useKeepBackup({ filename, onExport, onImported }) {
2391
+ const context = useKeepContext();
2392
+ const inputRef = useRef2(null);
2393
+ const [mode, setMode] = useState("merge");
2394
+ const [result, setResult] = useState();
2395
+ const [error, setError] = useState();
2396
+ async function exportBackup() {
2397
+ setError(void 0);
2398
+ try {
2399
+ const data = await context.exportBackup();
2400
+ onExport?.(data);
2401
+ if (typeof document === "undefined") return;
2402
+ const url = URL.createObjectURL(new Blob([data], { type: "application/json" }));
2403
+ const anchor = document.createElement("a");
2404
+ anchor.href = url;
2405
+ anchor.download = filename;
2406
+ anchor.click();
2407
+ URL.revokeObjectURL(url);
2408
+ } catch (cause) {
2409
+ setError(cause);
2410
+ }
2411
+ }
2412
+ async function importBackup(event) {
2413
+ const file = event.currentTarget.files?.[0];
2414
+ event.currentTarget.value = "";
2415
+ if (!file) return;
2416
+ setError(void 0);
2417
+ setResult(void 0);
2418
+ try {
2419
+ const imported = await context.importBackup(await file.text(), { mode });
2420
+ setResult(imported);
2421
+ onImported?.(imported);
2422
+ } catch (cause) {
2423
+ setError(cause);
2424
+ }
2425
+ }
2426
+ return {
2427
+ inputRef,
2428
+ mode,
2429
+ setMode,
2430
+ result,
2431
+ error,
2432
+ isMutating: context.isMutating,
2433
+ exportBackup,
2434
+ importBackup,
2435
+ openFilePicker: () => inputRef.current?.click(),
2436
+ labels: {
2437
+ export: useUiLabel("exportData"),
2438
+ import: useUiLabel("importData"),
2439
+ importMode: useUiLabel("importMode"),
2440
+ merge: useUiLabel("merge"),
2441
+ replace: useUiLabel("replace"),
2442
+ importedCount: useUiLabel("importedCount"),
2443
+ failedCount: useUiLabel("failedCount"),
2444
+ quotaError: useUiLabel("storageQuotaError")
2445
+ }
2446
+ };
2447
+ }
2448
+
2449
+ // src/features/actions/KeepBackup.tsx
2450
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2451
+ function KeepBackup({
2452
+ filename = "keepkit-backup.json",
2453
+ onExport,
2454
+ onImported,
2455
+ ...props
2456
+ }) {
2457
+ const view = useKeepBackup({ filename, onExport, onImported });
2458
+ const showExportLabel = useUiLabelVisibility("exportData");
2459
+ const showImportModeLabel = useUiLabelVisibility("importMode");
2460
+ const showImportLabel = useUiLabelVisibility("importData");
2461
+ return /* @__PURE__ */ jsxs2(
2462
+ "section",
2463
+ {
2464
+ ...props,
2465
+ "data-keepkit": "backup",
2466
+ "data-state": view.error ? "error" : view.result ? "complete" : "idle",
2467
+ "data-loading": view.isMutating ? "true" : void 0,
2468
+ children: [
2469
+ /* @__PURE__ */ jsx3(
2470
+ "button",
2471
+ {
2472
+ type: "button",
2473
+ "data-keep-action": "export-backup",
2474
+ onClick: () => void view.exportBackup(),
2475
+ disabled: view.isMutating,
2476
+ "aria-label": showExportLabel ? void 0 : view.labels.export,
2477
+ children: showExportLabel ? view.labels.export : null
2478
+ }
2479
+ ),
2480
+ /* @__PURE__ */ jsxs2("label", { children: [
2481
+ showImportModeLabel ? view.labels.importMode : null,
2482
+ /* @__PURE__ */ jsxs2(
2483
+ "select",
2484
+ {
2485
+ "data-keep-action": "select-import-mode",
2486
+ value: view.mode,
2487
+ "aria-label": showImportModeLabel ? void 0 : view.labels.importMode,
2488
+ onChange: (event) => view.setMode(event.currentTarget.value),
2489
+ children: [
2490
+ /* @__PURE__ */ jsx3("option", { value: "merge", children: view.labels.merge }),
2491
+ /* @__PURE__ */ jsx3("option", { value: "replace", children: view.labels.replace })
2492
+ ]
2493
+ }
2494
+ )
2495
+ ] }),
2496
+ /* @__PURE__ */ jsx3(
2497
+ "button",
2498
+ {
2499
+ type: "button",
2500
+ "data-keep-action": "import-backup",
2501
+ onClick: view.openFilePicker,
2502
+ disabled: view.isMutating,
2503
+ "aria-label": showImportLabel ? void 0 : view.labels.import,
2504
+ children: showImportLabel ? view.labels.import : null
2505
+ }
2506
+ ),
2507
+ /* @__PURE__ */ jsx3(
2508
+ "input",
2509
+ {
2510
+ ref: view.inputRef,
2511
+ type: "file",
2512
+ "data-keep-action": "select-backup-file",
2513
+ accept: "application/json,.json",
2514
+ "aria-label": view.labels.import,
2515
+ onChange: (event) => void view.importBackup(event)
2516
+ }
2517
+ ),
2518
+ view.result ? /* @__PURE__ */ jsxs2("p", { role: "status", children: [
2519
+ view.result.imported,
2520
+ " ",
2521
+ view.labels.importedCount,
2522
+ "; ",
2523
+ view.result.failed,
2524
+ " ",
2525
+ view.labels.failedCount
2526
+ ] }) : null,
2527
+ view.error ? /* @__PURE__ */ jsx3("p", { role: "alert", children: isQuotaError(view.error) ? view.labels.quotaError : getErrorMessage(view.error, "Something went wrong.") }) : null
2528
+ ]
2529
+ }
2530
+ );
2531
+ }
2532
+ function isQuotaError(error) {
2533
+ if (error instanceof Error && error.name === "KeepStorageQuotaError") return true;
2534
+ if (error && typeof error === "object" && "cause" in error) return isQuotaError(error.cause);
2535
+ return false;
2535
2536
  }
2536
2537
 
2537
2538
  // src/features/actions/hooks/useKeepBulkActions.ts
@@ -3091,7 +3092,7 @@ function KeepQuickEditorView({
3091
3092
  }
3092
3093
  if (event.key === "Tab") trapFocus(event, focusScopeRef?.current ?? rootRef.current);
3093
3094
  };
3094
- const statusMessage = state.saveStatus === "dirty" ? unsavedChangesLabel : state.saveStatus === "saving" ? savingLabel : state.saveStatus === "saved" ? savedLabel : state.saveStatus === "error" ? getErrorMessage2(state.error, errorLabel) : null;
3095
+ const statusMessage = state.saveStatus === "dirty" ? unsavedChangesLabel : state.saveStatus === "saving" ? savingLabel : state.saveStatus === "saved" ? savedLabel : state.saveStatus === "error" ? getErrorMessage(state.error, errorLabel) : null;
3095
3096
  const body = typeof children === "function" ? children(state) : children ?? /* @__PURE__ */ jsxs5(Fragment5, { children: [
3096
3097
  enabled.note ? /* @__PURE__ */ jsxs5("label", { "data-keep-field": "note", children: [
3097
3098
  showNoteLabel ? /* @__PURE__ */ jsx7("span", { "data-keep-field-icon": true, children: noteLabel }) : null,
@@ -3185,9 +3186,6 @@ function KeepQuickEditorView({
3185
3186
  function sameDraft(left, right) {
3186
3187
  return left.note === right.note && sameTags(left.tags, right.tags) && left.collectionId === right.collectionId;
3187
3188
  }
3188
- function getErrorMessage2(error, fallback) {
3189
- return error instanceof Error ? error.message : fallback;
3190
- }
3191
3189
  function sameTags(left, right) {
3192
3190
  return left.length === right.length && left.every((tag, index) => tag === right[index]);
3193
3191
  }
@@ -3440,7 +3438,7 @@ function KeepUndo({ children, label, ...props }) {
3440
3438
 
3441
3439
  // src/features/collection/KeepCollection.tsx
3442
3440
  import { KeepErrorBoundary as KeepErrorBoundary2 } from "@keepkit/core/react";
3443
- import { useEffect as useEffect10, useId as useId4, useState as useState15 } from "react";
3441
+ import { useEffect as useEffect10, useId as useId4, useRef as useRef9, useState as useState15 } from "react";
3444
3442
 
3445
3443
  // src/features/query/KeepActiveFiltersSummary.tsx
3446
3444
  import {
@@ -3461,7 +3459,7 @@ function KeepActiveFiltersSummary({
3461
3459
  ...rootProps
3462
3460
  }) {
3463
3461
  const search = (providedSearch ?? query?.search?.query ?? "").trim();
3464
- const tags = normalizeTags(providedTags ?? query?.tags ?? []);
3462
+ const tags = normalizeUiTags(providedTags ?? query?.tags ?? []);
3465
3463
  const hasFilters = Boolean(search) || tags.length > 0;
3466
3464
  const activeFiltersLabel = useUiLabel("activeFilters");
3467
3465
  const showActiveFiltersLabel = useUiLabelVisibility("activeFilters");
@@ -3564,9 +3562,6 @@ function KeepActiveFiltersSummary({
3564
3562
  "KeepActiveFiltersSummary"
3565
3563
  );
3566
3564
  }
3567
- function normalizeTags(tags) {
3568
- return [...new Set(tags.map((tag) => tag.trim()).filter(Boolean))];
3569
- }
3570
3565
  function isElement(value) {
3571
3566
  return isValidElement2(value);
3572
3567
  }
@@ -4014,7 +4009,7 @@ function KeepPagination({
4014
4009
 
4015
4010
  // src/features/collection/hooks/useKeepCollection.ts
4016
4011
  import { useKeepList as useKeepList3 } from "@keepkit/core/react";
4017
- import { useEffect as useEffect7, useMemo as useMemo4, useState as useState10 } from "react";
4012
+ import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo4, useState as useState10 } from "react";
4018
4013
  function useKeepCollection({
4019
4014
  query,
4020
4015
  pageSize,
@@ -4040,6 +4035,7 @@ function useKeepCollection({
4040
4035
  const [sort, setSort] = useState10(query.sort ?? { by: "updatedAt", direction: "desc" });
4041
4036
  const [activeTags, setActiveTags] = useState10(query.tags ?? []);
4042
4037
  const [activeCollection, setActiveCollection] = useState10(query.collectionId);
4038
+ const [activeActivity, setActiveActivity] = useState10(query.activity);
4043
4039
  const [page, setPage] = useState10(query.pagination?.page ?? 1);
4044
4040
  const [activeArchiveScope, setActiveArchiveScope] = useState10(
4045
4041
  archiveScope ?? query.archiveScope ?? scopeFromArchived(query.archived)
@@ -4051,6 +4047,7 @@ function useKeepCollection({
4051
4047
  const resolvedQuery = useMemo4(
4052
4048
  () => ({
4053
4049
  ...query,
4050
+ activity: activeActivity,
4054
4051
  archiveScope: activeArchiveScope,
4055
4052
  archived: activeArchiveScope === "active" ? false : activeArchiveScope === "archived" ? true : void 0,
4056
4053
  search: enabled.search ? { ...query.search, query: searchValue } : query.search,
@@ -4062,6 +4059,7 @@ function useKeepCollection({
4062
4059
  }),
4063
4060
  [
4064
4061
  activeCollection,
4062
+ activeActivity,
4065
4063
  activeTags,
4066
4064
  enabled.pagination,
4067
4065
  enabled.search,
@@ -4083,6 +4081,7 @@ function useKeepCollection({
4083
4081
  setSort(next.sort ?? { by: "updatedAt", direction: "desc" });
4084
4082
  setActiveTags(next.tags ?? []);
4085
4083
  setActiveCollection(next.collectionId);
4084
+ setActiveActivity(next.activity);
4086
4085
  setActiveArchiveScope(next.archiveScope ?? scopeFromArchived(next.archived));
4087
4086
  setPage(next.pagination?.page ?? 1);
4088
4087
  },
@@ -4091,6 +4090,26 @@ function useKeepCollection({
4091
4090
  });
4092
4091
  const list = useKeepList3(resolvedQuery);
4093
4092
  const allState = useKeepList3({ archiveScope: "all" });
4093
+ const reveal = useCallback5(
4094
+ (itemId) => {
4095
+ const target = allState.items.find((item) => item.id === itemId);
4096
+ if (!target) return "not-found";
4097
+ if (query.targetType !== void 0 && target.targetType !== query.targetType) return "excluded";
4098
+ if (query.filter && !query.filter(target)) return "excluded";
4099
+ const candidates = allState.items.filter(
4100
+ (item) => (query.targetType === void 0 || item.targetType === query.targetType) && (!query.filter || query.filter(item))
4101
+ ).filter((item) => target.archived === true ? item.archived === true : item.archived !== true).sort((a, b) => compareItems(a, b, sort, query.pinnedFirst));
4102
+ const index = candidates.findIndex((item) => item.id === itemId);
4103
+ if (index < 0) return "excluded";
4104
+ setSearchValue("");
4105
+ setActiveTags([]);
4106
+ setActiveCollection(void 0);
4107
+ setActiveArchiveScope(target.archived === true ? "archived" : "active");
4108
+ setPage(Math.floor(index / resolvedPageSize) + 1);
4109
+ return "visible";
4110
+ },
4111
+ [allState.items, query, resolvedPageSize, sort]
4112
+ );
4094
4113
  return {
4095
4114
  enabled,
4096
4115
  searchValue,
@@ -4132,9 +4151,20 @@ function useKeepCollection({
4132
4151
  setActiveCollection(void 0);
4133
4152
  setPage(1);
4134
4153
  },
4135
- setPage
4154
+ setPage,
4155
+ reveal
4136
4156
  };
4137
4157
  }
4158
+ function compareItems(a, b, sort, pinnedFirst) {
4159
+ if (pinnedFirst && a.pinned !== b.pinned) return a.pinned === true ? -1 : 1;
4160
+ const aValue = sort.by === "savedAt" ? a.savedAt : sort.by === "updatedAt" ? a.updatedAt : a.lastOpenedAt;
4161
+ const bValue = sort.by === "savedAt" ? b.savedAt : sort.by === "updatedAt" ? b.updatedAt : b.lastOpenedAt;
4162
+ const direction = sort.direction === "asc" ? 1 : -1;
4163
+ if (aValue === void 0 && bValue === void 0) return 0;
4164
+ if (aValue === void 0) return 1;
4165
+ if (bValue === void 0) return -1;
4166
+ return (aValue - bValue) * direction;
4167
+ }
4138
4168
  function scopeFromArchived(archived) {
4139
4169
  return archived === true ? "archived" : "active";
4140
4170
  }
@@ -4184,7 +4214,7 @@ function KeepCollectionCreate({
4184
4214
  setName("");
4185
4215
  onCreated?.(normalizedId);
4186
4216
  } catch (cause) {
4187
- const message = cause instanceof Error ? cause.message : "Failed to create collection.";
4217
+ const message = getErrorMessage(cause, "Failed to create collection.");
4188
4218
  setError(message);
4189
4219
  onError?.(cause);
4190
4220
  } finally {
@@ -4476,7 +4506,7 @@ function KeepStaleNotice({
4476
4506
  }
4477
4507
  )
4478
4508
  ] }),
4479
- view.error ? /* @__PURE__ */ jsx17("p", { role: "alert", children: view.error instanceof Error ? view.error.message : view.labels.error }) : null
4509
+ view.error ? /* @__PURE__ */ jsx17("p", { role: "alert", children: getErrorMessage(view.error, view.labels.error) }) : null
4480
4510
  ] });
4481
4511
  }
4482
4512
  function KeepPruneStaleButton({
@@ -4640,6 +4670,7 @@ function KeepItemCardRoot({
4640
4670
  asChild = false,
4641
4671
  href: hrefOption,
4642
4672
  onOpen,
4673
+ trackOpen = false,
4643
4674
  linkTarget = "title",
4644
4675
  linkComponent: LinkComponent,
4645
4676
  linkTargetAttribute,
@@ -4679,7 +4710,10 @@ function KeepItemCardRoot({
4679
4710
  href: view.href,
4680
4711
  target: view.resolvedLinkTarget,
4681
4712
  rel: view.resolvedLinkRel,
4682
- onClick: (event) => onOpen?.(item, event),
4713
+ onClick: (event) => {
4714
+ if (trackOpen) void view.itemState.recordOpen();
4715
+ onOpen?.(item, event);
4716
+ },
4683
4717
  children: content
4684
4718
  };
4685
4719
  return LinkComponent ? /* @__PURE__ */ jsx18(LinkComponent, { ...linkProps }) : /* @__PURE__ */ jsx18("a", { ...linkProps });
@@ -4722,7 +4756,7 @@ function KeepItemCardRoot({
4722
4756
  showSavedAtLabel ? " " : null,
4723
4757
  /* @__PURE__ */ jsx18("time", { dateTime: new Date(item.savedAt).toISOString(), children: formatSavedAt(item.savedAt) })
4724
4758
  ] }) : null;
4725
- const error = view.itemState.error ? /* @__PURE__ */ jsx18("p", { role: "alert", children: getErrorMessage3(view.itemState.error, view.labels.error) }) : null;
4759
+ const error = view.itemState.error ? /* @__PURE__ */ jsx18("p", { role: "alert", children: getErrorMessage(view.itemState.error, view.labels.error) }) : null;
4726
4760
  const actions = view.statusLabel ? /* @__PURE__ */ jsx18(KeepStaleNotice, { item, onRetry, onRemoved }) : /* @__PURE__ */ jsxs16(Fragment9, { children: [
4727
4761
  showEditButton ? isEditOpen ? /* @__PURE__ */ jsx18("div", { id: editPanelId, role: "dialog", "aria-label": editLabel, "data-keepkit": "item-edit-dialog", children: editSlot ? editSlot(item, closeEdit) : /* @__PURE__ */ jsx18(KeepQuickEditor, { item: view.itemState.item ?? item, onClose: closeEdit, features: editFeatures }) }) : /* @__PURE__ */ jsx18(
4728
4762
  "button",
@@ -4917,9 +4951,6 @@ function KeepItemCardSkeleton({ layout = "list", ...props }) {
4917
4951
  function formatSavedAt(timestamp) {
4918
4952
  return new Date(timestamp).toISOString().slice(0, 10);
4919
4953
  }
4920
- function getErrorMessage3(error, fallback) {
4921
- return error instanceof Error ? error.message : fallback;
4922
- }
4923
4954
 
4924
4955
  // src/features/status/KeepEmptyState.tsx
4925
4956
  import { isValidElement as isValidElement5 } from "react";
@@ -4971,17 +5002,17 @@ function useKeepListView(query) {
4971
5002
  }
4972
5003
 
4973
5004
  // src/features/collection/hooks/useRovingTabIndex.ts
4974
- import { useCallback as useCallback5, useEffect as useEffect9, useRef as useRef8 } from "react";
5005
+ import { useCallback as useCallback6, useEffect as useEffect9, useRef as useRef8 } from "react";
4975
5006
  function useRovingTabIndex() {
4976
5007
  const ref = useRef8(null);
4977
- const getItems = useCallback5(() => {
5008
+ const getItems = useCallback6(() => {
4978
5009
  const root = ref.current;
4979
5010
  if (!root) return [];
4980
5011
  return Array.from(root.querySelectorAll('[data-keepkit="card"]')).filter(
4981
5012
  (item) => item.getAttribute("aria-hidden") !== "true" && item.getAttribute("data-roving-disabled") !== "true"
4982
5013
  );
4983
5014
  }, []);
4984
- const syncTabIndices = useCallback5(() => {
5015
+ const syncTabIndices = useCallback6(() => {
4985
5016
  const items = getItems();
4986
5017
  if (items.length === 0) return;
4987
5018
  const activeElement = document.activeElement;
@@ -4999,7 +5030,7 @@ function useRovingTabIndex() {
4999
5030
  observer.observe(root, { childList: true, subtree: true });
5000
5031
  return () => observer.disconnect();
5001
5032
  }, [syncTabIndices]);
5002
- const onFocusCapture = useCallback5(
5033
+ const onFocusCapture = useCallback6(
5003
5034
  (event) => {
5004
5035
  if (!(event.target instanceof HTMLElement)) return;
5005
5036
  const item = event.target.closest('[data-keepkit="card"]');
@@ -5010,7 +5041,7 @@ function useRovingTabIndex() {
5010
5041
  },
5011
5042
  [getItems]
5012
5043
  );
5013
- const onKeyDown = useCallback5(
5044
+ const onKeyDown = useCallback6(
5014
5045
  (event) => {
5015
5046
  if (event.defaultPrevented) return;
5016
5047
  const items = getItems();
@@ -5276,7 +5307,7 @@ function getListBody(state, options) {
5276
5307
  function hasActiveQueryFilters(query) {
5277
5308
  if (!query) return false;
5278
5309
  return Boolean(
5279
- query.search?.query?.trim() || query.tags?.some((tag) => tag.trim()) || query.targetType || query.savedBetween || query.archiveScope !== void 0 && query.archiveScope !== "active" || query.collectionId || query.filter
5310
+ query.search?.query?.trim() || query.tags?.some((tag) => tag.trim()) || query.targetType || query.savedBetween || query.archiveScope !== void 0 && query.archiveScope !== "active" || query.collectionId || query.activity || query.filter
5280
5311
  );
5281
5312
  }
5282
5313
 
@@ -5312,10 +5343,19 @@ function KeepCollectionContent({
5312
5343
  activeFilters,
5313
5344
  empty,
5314
5345
  error,
5346
+ revealRequest,
5347
+ onRevealResult,
5315
5348
  className,
5316
5349
  ...rootProps
5317
5350
  }) {
5318
5351
  const view = useKeepCollection({ query, pageSize, urlSync, urlAdapter, features, archiveScope });
5352
+ const revealRequestId = useRef9(void 0);
5353
+ useEffect10(() => {
5354
+ if (!revealRequest || revealRequestId.current === revealRequest.requestId) return;
5355
+ revealRequestId.current = revealRequest.requestId;
5356
+ const status = view.reveal(revealRequest.itemId);
5357
+ onRevealResult?.({ ...revealRequest, status });
5358
+ }, [onRevealResult, revealRequest, view.reveal]);
5319
5359
  const [reorderUndoIds, setReorderUndoIds] = useState15(null);
5320
5360
  const reorderUndoLabel = useUiLabel("undoReorder");
5321
5361
  const handleReorder = async (orderedIds) => {
@@ -5479,7 +5519,7 @@ import { useId as useId5 } from "react";
5479
5519
 
5480
5520
  // src/features/collection/hooks/useKeepCollectionManager.ts
5481
5521
  import { useKeepCollections as useKeepCollections4, useKeepContext as useKeepContext6 } from "@keepkit/core/react";
5482
- import { useCallback as useCallback6, useState as useState16 } from "react";
5522
+ import { useCallback as useCallback7, useState as useState16 } from "react";
5483
5523
  function useKeepCollectionManager({
5484
5524
  onError,
5485
5525
  onRenamed,
@@ -5499,7 +5539,7 @@ function useKeepCollectionManager({
5499
5539
  const [pendingDeleteId, setPendingDeleteId] = useState16(null);
5500
5540
  const [error, setError] = useState16(null);
5501
5541
  const [isMutating, setIsMutating] = useState16(false);
5502
- const reportError = useCallback6(
5542
+ const reportError = useCallback7(
5503
5543
  (cause, fallback) => {
5504
5544
  const message = cause instanceof Error ? cause.message : fallback;
5505
5545
  setError(message);
@@ -5507,7 +5547,7 @@ function useKeepCollectionManager({
5507
5547
  },
5508
5548
  [onError]
5509
5549
  );
5510
- const runMutation = useCallback6(
5550
+ const runMutation = useCallback7(
5511
5551
  async (operation) => {
5512
5552
  setError(null);
5513
5553
  setIsMutating(true);
@@ -5521,7 +5561,7 @@ function useKeepCollectionManager({
5521
5561
  },
5522
5562
  [reportError]
5523
5563
  );
5524
- const beginRename = useCallback6(
5564
+ const beginRename = useCallback7(
5525
5565
  (id) => {
5526
5566
  const collection = collections.find((entry) => entry.id === id);
5527
5567
  if (!collection) return;
@@ -5532,11 +5572,11 @@ function useKeepCollectionManager({
5532
5572
  },
5533
5573
  [collections]
5534
5574
  );
5535
- const cancelRename = useCallback6(() => {
5575
+ const cancelRename = useCallback7(() => {
5536
5576
  setEditingId(null);
5537
5577
  setEditingName("");
5538
5578
  }, []);
5539
- const rename = useCallback6(
5579
+ const rename = useCallback7(
5540
5580
  async (id) => {
5541
5581
  const name = editingName.trim();
5542
5582
  if (!name) return;
@@ -5568,13 +5608,13 @@ function useKeepCollectionManager({
5568
5608
  runMutation
5569
5609
  ]
5570
5610
  );
5571
- const requestDelete = useCallback6((id) => {
5611
+ const requestDelete = useCallback7((id) => {
5572
5612
  setError(null);
5573
5613
  setEditingId(null);
5574
5614
  setPendingDeleteId(id);
5575
5615
  }, []);
5576
- const cancelDelete = useCallback6(() => setPendingDeleteId(null), []);
5577
- const confirmDelete = useCallback6(async () => {
5616
+ const cancelDelete = useCallback7(() => setPendingDeleteId(null), []);
5617
+ const confirmDelete = useCallback7(async () => {
5578
5618
  if (!pendingDeleteId) return;
5579
5619
  const id = pendingDeleteId;
5580
5620
  await runMutation(async () => {
@@ -5812,16 +5852,16 @@ function KeepShortcutHint({ shortcut, separator = "+", ...props }) {
5812
5852
 
5813
5853
  // src/features/editor/hooks/useKeepNoteEditor.ts
5814
5854
  import { useKeepItem as useKeepItem6 } from "@keepkit/core/react";
5815
- import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef9, useState as useState17 } from "react";
5855
+ import { useCallback as useCallback8, useEffect as useEffect11, useRef as useRef10, useState as useState17 } from "react";
5816
5856
  function useKeepNoteEditor({ item, debounceMs, onSaved, onSaveError }) {
5817
5857
  const itemState = useKeepItem6(item);
5818
5858
  const { error, isMutating, item: savedItem, updateNote } = itemState;
5819
5859
  const [note, setNote] = useState17(item.note ?? "");
5820
5860
  const baselineNote = savedItem?.note ?? item.note ?? "";
5821
5861
  const isDirty = note !== baselineNote;
5822
- const lastSavedNoteRef = useRef9(void 0);
5862
+ const lastSavedNoteRef = useRef10(void 0);
5823
5863
  useEffect11(() => setNote(baselineNote), [baselineNote]);
5824
- const save = useCallback7(async () => {
5864
+ const save = useCallback8(async () => {
5825
5865
  const nextNote = note.trim() || void 0;
5826
5866
  try {
5827
5867
  await updateNote(nextNote);
@@ -5935,7 +5975,7 @@ function KeepNoteEditor({
5935
5975
  "data-disabled": isSaving ? "true" : void 0,
5936
5976
  children: [
5937
5977
  body,
5938
- error ? /* @__PURE__ */ jsx26("p", { role: "alert", children: getErrorMessage4(error, view.labels.error) }) : null
5978
+ error ? /* @__PURE__ */ jsx26("p", { role: "alert", children: getErrorMessage(error, view.labels.error) }) : null
5939
5979
  ]
5940
5980
  }
5941
5981
  );
@@ -5957,19 +5997,16 @@ function KeepNoteEditor({
5957
5997
  "KeepNoteEditor"
5958
5998
  );
5959
5999
  }
5960
- function getErrorMessage4(error, fallback) {
5961
- return error instanceof Error ? error.message : fallback;
5962
- }
5963
6000
 
5964
6001
  // src/features/editor/hooks/useKeepTagEditor.ts
5965
6002
  import { useKeepItem as useKeepItem7 } from "@keepkit/core/react";
5966
- import { useCallback as useCallback8, useEffect as useEffect12, useState as useState18 } from "react";
6003
+ import { useCallback as useCallback9, useEffect as useEffect12, useState as useState18 } from "react";
5967
6004
  function useKeepTagEditor({ item, onSaved, onSaveError }) {
5968
6005
  const itemState = useKeepItem7(item);
5969
6006
  const [tags, setTags] = useState18(item.tags ?? []);
5970
6007
  const [input, setInput] = useState18("");
5971
6008
  useEffect12(() => setTags(itemState.item?.tags ?? item.tags ?? []), [item.tags, itemState.item?.tags]);
5972
- const save = useCallback8(async () => {
6009
+ const save = useCallback9(async () => {
5973
6010
  const nextTags = normalizeUiTags(tags);
5974
6011
  try {
5975
6012
  await itemState.updateTags(nextTags);
@@ -6083,19 +6120,16 @@ function KeepTagEditor({
6083
6120
  "data-disabled": isSaving ? "true" : void 0,
6084
6121
  children: [
6085
6122
  body,
6086
- view.error ? /* @__PURE__ */ jsx27("p", { role: "alert", children: getErrorMessage5(view.error, view.labels.error) }) : null
6123
+ view.error ? /* @__PURE__ */ jsx27("p", { role: "alert", children: getErrorMessage(view.error, view.labels.error) }) : null
6087
6124
  ]
6088
6125
  }
6089
6126
  );
6090
6127
  }
6091
- function getErrorMessage5(error, fallback) {
6092
- return error instanceof Error ? error.message : fallback;
6093
- }
6094
6128
 
6095
6129
  // src/features/feedback/useKeepToastFeedback.ts
6096
- import { useCallback as useCallback9 } from "react";
6130
+ import { useCallback as useCallback10 } from "react";
6097
6131
  function useKeepToastFeedback(showToast) {
6098
- return useCallback9(
6132
+ return useCallback10(
6099
6133
  (event) => {
6100
6134
  if (!("undo" in event)) {
6101
6135
  showToast(event.message);
@@ -6112,6 +6146,89 @@ function useKeepToastFeedback(showToast) {
6112
6146
  );
6113
6147
  }
6114
6148
 
6149
+ // src/features/navigation/KeepFloatingTour.tsx
6150
+ import { useKeepList as useKeepList6 } from "@keepkit/core/react";
6151
+ import { useEffect as useEffect15, useMemo as useMemo6, useRef as useRef11, useState as useState20 } from "react";
6152
+ import { createPortal } from "react-dom";
6153
+
6154
+ // src/foundation/theme.tsx
6155
+ import {
6156
+ createContext as createContext4,
6157
+ isValidElement as isValidElement8,
6158
+ useContext as useContext4
6159
+ } from "react";
6160
+ import { jsx as jsx28 } from "react/jsx-runtime";
6161
+ var keepThemeNames = [
6162
+ "default",
6163
+ "ocean",
6164
+ "forest",
6165
+ "sunset",
6166
+ "lavender",
6167
+ "compact",
6168
+ "minimal",
6169
+ "rounded",
6170
+ "high-contrast",
6171
+ "dark"
6172
+ ];
6173
+ var KeepThemeContext = createContext4({});
6174
+ function useKeepTheme() {
6175
+ return useContext4(KeepThemeContext);
6176
+ }
6177
+ function KeepThemeProvider({
6178
+ children,
6179
+ theme = "default",
6180
+ mode = "system",
6181
+ density = "comfortable",
6182
+ radius = "medium",
6183
+ accentColor,
6184
+ highContrast = false,
6185
+ reducedMotion = false,
6186
+ variables,
6187
+ style,
6188
+ className,
6189
+ asChild = false,
6190
+ ...props
6191
+ }) {
6192
+ const themeClassName = [
6193
+ "keep-theme",
6194
+ `keep-theme--${theme}`,
6195
+ `keep-theme--${mode}`,
6196
+ `keep-theme--density-${density}`,
6197
+ `keep-theme--radius-${radius}`,
6198
+ className
6199
+ ].filter(Boolean).join(" ");
6200
+ const themeStyle = {
6201
+ ...style,
6202
+ ...accentColor && !highContrast ? { "--keep-accent": accentColor, "--keep-primary": accentColor } : {},
6203
+ ...variables
6204
+ };
6205
+ const rootProps = {
6206
+ ...props,
6207
+ className: themeClassName,
6208
+ style: themeStyle,
6209
+ "data-keep-theme": theme,
6210
+ "data-theme": theme,
6211
+ "data-mode": mode,
6212
+ "data-density": density,
6213
+ "data-radius": radius,
6214
+ "data-accent-color": accentColor,
6215
+ "data-high-contrast": highContrast ? "true" : void 0,
6216
+ "data-reduced-motion": reducedMotion ? "true" : void 0
6217
+ };
6218
+ const content = asChild ? (() => {
6219
+ if (!isValidElement8(children))
6220
+ throw new Error("KeepThemeProvider with asChild requires a single React element child.");
6221
+ return createSlot(children, rootProps);
6222
+ })() : /* @__PURE__ */ jsx28("div", { ...rootProps, children });
6223
+ return /* @__PURE__ */ jsx28(
6224
+ KeepThemeContext.Provider,
6225
+ {
6226
+ value: { theme, mode, density, radius, accentColor, highContrast, reducedMotion, variables, style },
6227
+ children: content
6228
+ }
6229
+ );
6230
+ }
6231
+
6115
6232
  // src/features/navigation/KeepTourBar.tsx
6116
6233
  import { useKeepNavigator } from "@keepkit/core/react";
6117
6234
  import { useId as useId6 } from "react";
@@ -6149,7 +6266,7 @@ function isEditableTarget(target) {
6149
6266
  }
6150
6267
 
6151
6268
  // src/features/navigation/KeepTourBar.tsx
6152
- import { Fragment as Fragment16, jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
6269
+ import { Fragment as Fragment16, jsx as jsx29, jsxs as jsxs24 } from "react/jsx-runtime";
6153
6270
  function KeepTourBar({
6154
6271
  navigation: providedNavigation,
6155
6272
  currentId,
@@ -6220,8 +6337,8 @@ function KeepTourBar({
6220
6337
  }
6221
6338
  });
6222
6339
  const body = /* @__PURE__ */ jsxs24(Fragment16, { children: [
6223
- showProgress ? /* @__PURE__ */ jsx28("span", { "data-keepkit": "tour-progress", "aria-live": "polite", children: progress ?? `${navigation.currentPosition ?? 0} / ${navigation.items.length}` }) : null,
6224
- /* @__PURE__ */ jsx28(
6340
+ showProgress ? /* @__PURE__ */ jsx29("span", { "data-keepkit": "tour-progress", "aria-live": "polite", children: progress ?? `${navigation.currentPosition ?? 0} / ${navigation.items.length}` }) : null,
6341
+ /* @__PURE__ */ jsx29(
6225
6342
  TourAction,
6226
6343
  {
6227
6344
  href: resolvedPrevHref,
@@ -6237,7 +6354,7 @@ function KeepTourBar({
6237
6354
  children: previousLabel
6238
6355
  }
6239
6356
  ),
6240
- /* @__PURE__ */ jsx28(
6357
+ /* @__PURE__ */ jsx29(
6241
6358
  TourAction,
6242
6359
  {
6243
6360
  href: resolvedNextHref,
@@ -6253,7 +6370,7 @@ function KeepTourBar({
6253
6370
  children: nextItemLabel
6254
6371
  }
6255
6372
  ),
6256
- resolvedBackHref || onBack ? /* @__PURE__ */ jsx28(TourAction, { href: resolvedBackHref, onClick: onBack, "data-keep-action": "tour-back", children: listLabel }) : null
6373
+ resolvedBackHref || onBack ? /* @__PURE__ */ jsx29(TourAction, { href: resolvedBackHref, onClick: onBack, "data-keep-action": "tour-back", children: listLabel }) : null
6257
6374
  ] });
6258
6375
  return renderRoot(
6259
6376
  asChild,
@@ -6266,12 +6383,12 @@ function KeepTourBar({
6266
6383
  function TourAction({ href, disabled = false, onClick, children, preview, shortcut, ...props }) {
6267
6384
  const previewId = useId6();
6268
6385
  const content = /* @__PURE__ */ jsxs24(Fragment16, { children: [
6269
- /* @__PURE__ */ jsx28("span", { "data-tour-label": "true", children }),
6270
- shortcut ? /* @__PURE__ */ jsx28(KeepShortcutHint, { shortcut }) : null,
6271
- preview ? /* @__PURE__ */ jsx28("small", { id: previewId, "data-tour-preview": "true", children: preview }) : null
6386
+ /* @__PURE__ */ jsx29("span", { "data-tour-label": "true", children }),
6387
+ shortcut ? /* @__PURE__ */ jsx29(KeepShortcutHint, { shortcut }) : null,
6388
+ preview ? /* @__PURE__ */ jsx29("small", { id: previewId, "data-tour-preview": "true", children: preview }) : null
6272
6389
  ] });
6273
6390
  if (href && !disabled) {
6274
- return /* @__PURE__ */ jsx28(
6391
+ return /* @__PURE__ */ jsx29(
6275
6392
  "a",
6276
6393
  {
6277
6394
  ...props,
@@ -6283,7 +6400,7 @@ function TourAction({ href, disabled = false, onClick, children, preview, shortc
6283
6400
  }
6284
6401
  );
6285
6402
  }
6286
- return /* @__PURE__ */ jsx28(
6403
+ return /* @__PURE__ */ jsx29(
6287
6404
  "button",
6288
6405
  {
6289
6406
  ...props,
@@ -6302,12 +6419,325 @@ function navigateTo(item, href) {
6302
6419
  window.location.assign(href);
6303
6420
  }
6304
6421
 
6422
+ // src/features/navigation/tour-context.tsx
6423
+ import { useKeepList as useKeepList5 } from "@keepkit/core/react";
6424
+ import { createContext as createContext5, useCallback as useCallback11, useContext as useContext5, useEffect as useEffect14, useMemo as useMemo5, useState as useState19 } from "react";
6425
+ import { jsx as jsx30 } from "react/jsx-runtime";
6426
+ var SESSION_VERSION = 1;
6427
+ var KeepTourContext = createContext5(null);
6428
+ function KeepTourProvider({
6429
+ children,
6430
+ sessionKey = "keepkit:tour",
6431
+ getItemHref,
6432
+ getBackHref,
6433
+ onNavigate
6434
+ }) {
6435
+ const list = useKeepList5();
6436
+ const [tour, setTour] = useState19(
6437
+ null
6438
+ );
6439
+ const [persistenceStatus, setPersistenceStatus] = useState19("persistent");
6440
+ const itemsById = useMemo5(() => new Map(list.items.map((item) => [item.id, item])), [list.items]);
6441
+ const readStorage = useCallback11(() => {
6442
+ try {
6443
+ const raw = window.sessionStorage.getItem(sessionKey);
6444
+ if (!raw) return null;
6445
+ const parsed = JSON.parse(raw);
6446
+ if (!parsed || typeof parsed !== "object") return null;
6447
+ const value2 = parsed;
6448
+ if (value2.version !== SESSION_VERSION || !Array.isArray(value2.itemIds) || typeof value2.currentId !== "string")
6449
+ return null;
6450
+ const ids = value2.itemIds.filter((id) => typeof id === "string");
6451
+ if (!ids.length || new Set(ids).size !== ids.length) return null;
6452
+ return {
6453
+ version: SESSION_VERSION,
6454
+ itemIds: ids,
6455
+ currentId: value2.currentId,
6456
+ collapsed: value2.collapsed === true
6457
+ };
6458
+ } catch {
6459
+ setPersistenceStatus("memory");
6460
+ return null;
6461
+ }
6462
+ }, [sessionKey]);
6463
+ const writeStorage = useCallback11(
6464
+ (value2) => {
6465
+ try {
6466
+ if (value2) window.sessionStorage.setItem(sessionKey, JSON.stringify({ version: SESSION_VERSION, ...value2 }));
6467
+ else window.sessionStorage.removeItem(sessionKey);
6468
+ setPersistenceStatus("persistent");
6469
+ } catch {
6470
+ setPersistenceStatus("memory");
6471
+ }
6472
+ },
6473
+ [sessionKey]
6474
+ );
6475
+ useEffect14(() => {
6476
+ if (!list.isHydrated || list.error || tour) return;
6477
+ const stored = typeof window === "undefined" ? null : readStorage();
6478
+ if (!stored) return;
6479
+ const ids = stored.itemIds.filter((id) => itemsById.has(id));
6480
+ if (!ids.length) {
6481
+ writeStorage(null);
6482
+ return;
6483
+ }
6484
+ const currentId = ids.includes(stored.currentId) ? stored.currentId : ids[0];
6485
+ setTour({ itemIds: ids, currentId, collapsed: stored.collapsed });
6486
+ }, [itemsById, list.error, list.isHydrated, readStorage, tour, writeStorage]);
6487
+ useEffect14(() => {
6488
+ if (!tour || list.isLoading || list.error) return;
6489
+ const ids = tour.itemIds.filter((id) => itemsById.has(id));
6490
+ if (!ids.length) {
6491
+ setTour(null);
6492
+ writeStorage(null);
6493
+ return;
6494
+ }
6495
+ const currentId = tour.currentId && ids.includes(tour.currentId) ? tour.currentId : ids[0];
6496
+ if (ids.length !== tour.itemIds.length || currentId !== tour.currentId) {
6497
+ const next = { ...tour, itemIds: ids, currentId };
6498
+ setTour(next);
6499
+ writeStorage(next);
6500
+ }
6501
+ }, [itemsById, list.error, list.isLoading, tour, writeStorage]);
6502
+ const start = useCallback11(
6503
+ (options) => {
6504
+ const ids = [...options.itemIds];
6505
+ if (!ids.length || new Set(ids).size !== ids.length || ids.some((id) => !itemsById.has(id))) return false;
6506
+ const currentId = options.currentId ?? ids[0];
6507
+ if (!ids.includes(currentId)) return false;
6508
+ const next = { itemIds: ids, currentId, collapsed: false };
6509
+ setTour(next);
6510
+ writeStorage(next);
6511
+ return true;
6512
+ },
6513
+ [itemsById, writeStorage]
6514
+ );
6515
+ const end = useCallback11(() => {
6516
+ setTour(null);
6517
+ writeStorage(null);
6518
+ }, [writeStorage]);
6519
+ const setCurrentId = useCallback11(
6520
+ (id) => {
6521
+ setTour((current) => {
6522
+ if (!current?.currentId || current.currentId === id || !current.itemIds.includes(id)) return current;
6523
+ const next = { ...current, currentId: id };
6524
+ writeStorage(next);
6525
+ return next;
6526
+ });
6527
+ },
6528
+ [writeStorage]
6529
+ );
6530
+ const move = useCallback11(
6531
+ (delta) => {
6532
+ if (!tour?.currentId) return null;
6533
+ const currentId = tour.currentId;
6534
+ const index = tour.itemIds.indexOf(currentId);
6535
+ const id = tour.itemIds[index + delta];
6536
+ if (!id) return null;
6537
+ setCurrentId(id);
6538
+ return itemsById.get(id) ?? null;
6539
+ },
6540
+ [itemsById, setCurrentId, tour]
6541
+ );
6542
+ const value = useMemo5(
6543
+ () => ({
6544
+ active: tour !== null,
6545
+ itemIds: tour?.itemIds ?? [],
6546
+ currentId: tour?.currentId ?? null,
6547
+ collapsed: tour?.collapsed ?? false,
6548
+ persistenceStatus,
6549
+ getItemHref,
6550
+ getBackHref,
6551
+ onNavigate,
6552
+ start,
6553
+ end,
6554
+ collapse: () => setTour((current) => current ? { ...current, collapsed: true } : current),
6555
+ expand: () => setTour((current) => current ? { ...current, collapsed: false } : current),
6556
+ goNext: () => move(1),
6557
+ goPrev: () => move(-1),
6558
+ setCurrentId
6559
+ }),
6560
+ [end, getBackHref, getItemHref, move, onNavigate, persistenceStatus, setCurrentId, start, tour]
6561
+ );
6562
+ useEffect14(() => {
6563
+ if (!tour) return;
6564
+ if (tour.currentId) writeStorage(tour);
6565
+ }, [tour, writeStorage]);
6566
+ return /* @__PURE__ */ jsx30(KeepTourContext.Provider, { value, children });
6567
+ }
6568
+ function useKeepTour(options = {}) {
6569
+ const context = useContext5(KeepTourContext);
6570
+ if (!context) throw new Error("useKeepTour must be used within KeepTourProvider.");
6571
+ useEffect14(() => {
6572
+ if (options.currentId && context.active) context.setCurrentId(options.currentId);
6573
+ }, [context, options.currentId]);
6574
+ return context;
6575
+ }
6576
+
6577
+ // src/features/navigation/KeepFloatingTour.tsx
6578
+ import { Fragment as Fragment17, jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
6579
+ function KeepFloatingTour({
6580
+ currentId,
6581
+ getItemHref,
6582
+ getBackHref,
6583
+ onNavigate,
6584
+ onBack,
6585
+ position = "bottom-center",
6586
+ offset = 16,
6587
+ zIndex = 1e3,
6588
+ className,
6589
+ style,
6590
+ keyboardShortcuts = false,
6591
+ showShortcutHint = false
6592
+ }) {
6593
+ const tour = useKeepTour({ currentId });
6594
+ const { items } = useKeepList6();
6595
+ const theme = useKeepTheme();
6596
+ const [mounted, setMounted] = useState20(false);
6597
+ const { labels } = useKeepUiLabels();
6598
+ const collapseLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u6298\u308A\u305F\u305F\u3080" : "Collapse tour";
6599
+ const expandLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u5C55\u958B" : "Expand tour";
6600
+ const endLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u7D42\u4E86" : "End tour";
6601
+ const expandRef = useRef11(null);
6602
+ const collapseRef = useRef11(null);
6603
+ useEffect15(() => setMounted(true), []);
6604
+ useEffect15(() => {
6605
+ if (!mounted || !tour.active) return;
6606
+ const button = tour.collapsed ? expandRef.current : collapseRef.current;
6607
+ if (button) button.focus();
6608
+ }, [mounted, tour.active, tour.collapsed]);
6609
+ const activeId = currentId ?? tour.currentId;
6610
+ const navigation = useMemo6(() => {
6611
+ const tourItems = tour.itemIds.map((id) => items.find((item) => item.id === id)).filter((item) => item !== void 0);
6612
+ const currentIndex = activeId ? tourItems.findIndex((item) => item.id === activeId) : -1;
6613
+ const currentItem = currentIndex >= 0 ? tourItems[currentIndex] ?? null : null;
6614
+ return {
6615
+ items: tourItems,
6616
+ currentIndex,
6617
+ currentPosition: currentIndex >= 0 ? currentIndex + 1 : null,
6618
+ currentItem,
6619
+ hasNext: currentIndex >= 0 && currentIndex < tourItems.length - 1,
6620
+ hasPrev: currentIndex > 0,
6621
+ nextItem: currentIndex >= 0 ? tourItems[currentIndex + 1] ?? null : null,
6622
+ prevItem: currentIndex > 0 ? tourItems[currentIndex - 1] ?? null : null,
6623
+ goToNext: tour.goNext,
6624
+ goToPrev: tour.goPrev,
6625
+ goToIndex: (index) => {
6626
+ const item = tourItems[index];
6627
+ if (!item) return null;
6628
+ tour.setCurrentId(item.id);
6629
+ return item;
6630
+ },
6631
+ goToItem: (id) => tourItems.find((item) => item.id === id) ?? null
6632
+ };
6633
+ }, [activeId, items, tour]);
6634
+ if (!mounted || !tour.active || typeof document === "undefined" || !activeId) return null;
6635
+ const placementStyle = {
6636
+ "--keep-tour-offset": typeof offset === "number" ? `${offset}px` : offset,
6637
+ "--keep-tour-z-index": zIndex,
6638
+ ...style
6639
+ };
6640
+ const content = tour.collapsed ? /* @__PURE__ */ jsxs25(
6641
+ "button",
6642
+ {
6643
+ ref: expandRef,
6644
+ type: "button",
6645
+ className: "keep-floating-tour__expand",
6646
+ "data-keep-action": "tour-expand",
6647
+ "aria-label": `${expandLabel} (${tour.itemIds.indexOf(activeId) + 1} / ${tour.itemIds.length})`,
6648
+ onClick: () => tour.expand(),
6649
+ children: [
6650
+ tour.itemIds.indexOf(activeId) + 1,
6651
+ " / ",
6652
+ tour.itemIds.length
6653
+ ]
6654
+ }
6655
+ ) : /* @__PURE__ */ jsxs25(Fragment17, { children: [
6656
+ /* @__PURE__ */ jsx31(
6657
+ KeepTourBar,
6658
+ {
6659
+ className: "keep-floating-tour__bar",
6660
+ navigation,
6661
+ currentId: activeId,
6662
+ getItemHref: getItemHref ?? tour.getItemHref,
6663
+ getBackHref: getBackHref ?? tour.getBackHref,
6664
+ onNavigate: onNavigate ?? tour.onNavigate,
6665
+ onBack: () => {
6666
+ tour.end();
6667
+ return onBack?.();
6668
+ },
6669
+ keyboardShortcuts,
6670
+ showShortcutHint
6671
+ }
6672
+ ),
6673
+ /* @__PURE__ */ jsx31(
6674
+ "button",
6675
+ {
6676
+ ref: collapseRef,
6677
+ type: "button",
6678
+ className: "keep-floating-tour__control",
6679
+ "data-keep-action": "tour-collapse",
6680
+ "aria-label": collapseLabel,
6681
+ onClick: () => tour.collapse(),
6682
+ children: "\u2212"
6683
+ }
6684
+ ),
6685
+ /* @__PURE__ */ jsx31(
6686
+ "button",
6687
+ {
6688
+ type: "button",
6689
+ className: "keep-floating-tour__control",
6690
+ "data-keep-action": "tour-end",
6691
+ "aria-label": endLabel,
6692
+ onClick: () => tour.end(),
6693
+ children: "\xD7"
6694
+ }
6695
+ )
6696
+ ] });
6697
+ return createPortal(
6698
+ /* @__PURE__ */ jsx31(KeepThemeProvider, { ...theme, children: /* @__PURE__ */ jsx31(
6699
+ "aside",
6700
+ {
6701
+ className: ["keep-floating-tour", `keep-floating-tour--${position}`, className].filter(Boolean).join(" "),
6702
+ style: placementStyle,
6703
+ "data-keepkit": "floating-tour",
6704
+ "data-state": tour.collapsed ? "collapsed" : "expanded",
6705
+ "data-persistence": tour.persistenceStatus,
6706
+ "aria-label": "KeepKit tour",
6707
+ children: content
6708
+ }
6709
+ ) }),
6710
+ document.body
6711
+ );
6712
+ }
6713
+
6714
+ // src/features/rediscovery/KeepRediscovery.tsx
6715
+ import { createRediscoveryQuery } from "@keepkit/core/core";
6716
+ import { useMemo as useMemo7 } from "react";
6717
+ import { jsx as jsx32 } from "react/jsx-runtime";
6718
+ function KeepRediscovery({
6719
+ strategy,
6720
+ inactiveForMs,
6721
+ limit = 5,
6722
+ itemCardProps,
6723
+ ...props
6724
+ }) {
6725
+ const query = useMemo7(
6726
+ () => ({
6727
+ ...createRediscoveryQuery({ strategy, inactiveForMs }),
6728
+ pagination: { page: 1, pageSize: Math.max(1, limit) }
6729
+ }),
6730
+ [inactiveForMs, limit, strategy]
6731
+ );
6732
+ return /* @__PURE__ */ jsx32(KeepList, { ...props, query, itemCardProps: { trackOpen: true, ...itemCardProps } });
6733
+ }
6734
+
6305
6735
  // src/features/status/status.tsx
6306
- import { isValidElement as isValidElement8 } from "react";
6736
+ import { isValidElement as isValidElement9 } from "react";
6307
6737
 
6308
6738
  // src/features/status/hooks/useStatusViews.ts
6309
6739
  import { useKeepContext as useKeepContext7 } from "@keepkit/core/react";
6310
- import { useEffect as useEffect14, useRef as useRef10, useState as useState19 } from "react";
6740
+ import { useEffect as useEffect16, useRef as useRef12, useState as useState21 } from "react";
6311
6741
  function useKeepStatus(status) {
6312
6742
  const context = useKeepContext7();
6313
6743
  const resolvedStatus = status ?? getDerivedStatus(context);
@@ -6324,9 +6754,9 @@ function useKeepAnnouncements(messages) {
6324
6754
  const savedMessage = useUiLabel("savedMessage", messages?.save);
6325
6755
  const removedMessage = useUiLabel("removedMessage", messages?.remove);
6326
6756
  const noteSavedMessage = useUiLabel("noteSavedMessage", messages?.note);
6327
- const [message, setMessage] = useState19("");
6328
- const lastChangeRef = useRef10(void 0);
6329
- useEffect14(() => {
6757
+ const [message, setMessage] = useState21("");
6758
+ const lastChangeRef = useRef12(void 0);
6759
+ useEffect16(() => {
6330
6760
  const change = context.lastChange;
6331
6761
  if (!change || change === lastChangeRef.current) return;
6332
6762
  lastChangeRef.current = change;
@@ -6354,7 +6784,7 @@ function getStatusLabelKey3(status) {
6354
6784
  }
6355
6785
 
6356
6786
  // src/features/status/status.tsx
6357
- import { jsx as jsx29 } from "react/jsx-runtime";
6787
+ import { jsx as jsx33 } from "react/jsx-runtime";
6358
6788
  function KeepStatus({
6359
6789
  status,
6360
6790
  labels,
@@ -6365,12 +6795,12 @@ function KeepStatus({
6365
6795
  ...rootProps
6366
6796
  }) {
6367
6797
  const view = useKeepStatus(status);
6368
- const contentChildren = asChild && isValidElement8(children) ? void 0 : children;
6798
+ const contentChildren = asChild && isValidElement9(children) ? void 0 : children;
6369
6799
  const body = render ? render(view.state) : typeof contentChildren === "function" ? contentChildren(view.state) : contentChildren ?? labels?.[view.state.status] ?? view.defaultLabel;
6370
6800
  const role = rootProps.role ?? (view.state.status === "error" ? "alert" : "status");
6371
6801
  return renderRoot(
6372
6802
  asChild,
6373
- isValidElement8(children) ? children : void 0,
6803
+ isValidElement9(children) ? children : void 0,
6374
6804
  {
6375
6805
  ...rootProps,
6376
6806
  className,
@@ -6386,7 +6816,7 @@ function KeepStatus({
6386
6816
  }
6387
6817
  function KeepAnnouncements({ messages, ...props }) {
6388
6818
  const message = useKeepAnnouncements(messages);
6389
- return /* @__PURE__ */ jsx29(
6819
+ return /* @__PURE__ */ jsx33(
6390
6820
  "div",
6391
6821
  {
6392
6822
  ...props,
@@ -6403,14 +6833,14 @@ var KeepAnnouncer = KeepAnnouncements;
6403
6833
 
6404
6834
  // src/features/sync/hooks/useKeepSyncFeedback.ts
6405
6835
  import { useKeepContext as useKeepContext8 } from "@keepkit/core/react";
6406
- import { useEffect as useEffect15, useRef as useRef11 } from "react";
6836
+ import { useEffect as useEffect17, useRef as useRef13 } from "react";
6407
6837
  function useKeepSyncFeedback() {
6408
6838
  const { syncState } = useKeepContext8();
6409
6839
  const emitFeedback = useKeepUiFeedback();
6410
6840
  const completedMessage = useUiLabel("syncSynced");
6411
6841
  const failedMessage = useUiLabel("syncFailedMessage");
6412
- const previousStatus = useRef11("idle");
6413
- useEffect15(() => {
6842
+ const previousStatus = useRef13("idle");
6843
+ useEffect17(() => {
6414
6844
  const previous = previousStatus.current;
6415
6845
  previousStatus.current = syncState.status;
6416
6846
  if (syncState.status === "error" && previous !== "error") {
@@ -6431,16 +6861,16 @@ function KeepSyncFeedbackObserver() {
6431
6861
 
6432
6862
  // src/features/sync/hooks/useKeepSyncRecoveryDialog.ts
6433
6863
  import { useKeepContext as useKeepContext9 } from "@keepkit/core/react";
6434
- import { useEffect as useEffect16, useState as useState20 } from "react";
6864
+ import { useEffect as useEffect18, useState as useState22 } from "react";
6435
6865
  function useKeepSyncRecoveryDialog(options) {
6436
6866
  const { open, onOpenChange, conflicts, onManualMerge } = options;
6437
6867
  const context = useKeepContext9();
6438
6868
  const conflictList = conflicts ?? context.syncState.conflicts ?? [];
6439
6869
  const hasRecovery = conflictList.length > 0 || context.syncState.status === "error" || Boolean(context.error);
6440
- const [dismissed, setDismissed] = useState20(false);
6441
- const [busyId, setBusyId] = useState20();
6442
- const [error, setError] = useState20();
6443
- useEffect16(() => {
6870
+ const [dismissed, setDismissed] = useState22(false);
6871
+ const [busyId, setBusyId] = useState22();
6872
+ const [error, setError] = useState22();
6873
+ useEffect18(() => {
6444
6874
  if (hasRecovery) setDismissed(false);
6445
6875
  }, [hasRecovery]);
6446
6876
  return {
@@ -6485,7 +6915,7 @@ function useKeepSyncRecoveryDialog(options) {
6485
6915
  }
6486
6916
 
6487
6917
  // src/features/sync/KeepSyncRecoveryDialog.tsx
6488
- import { jsx as jsx30, jsxs as jsxs25 } from "react/jsx-runtime";
6918
+ import { jsx as jsx34, jsxs as jsxs26 } from "react/jsx-runtime";
6489
6919
  function KeepSyncRecoveryDialog({
6490
6920
  open,
6491
6921
  onOpenChange,
@@ -6500,7 +6930,7 @@ function KeepSyncRecoveryDialog({
6500
6930
  }) {
6501
6931
  const view = useKeepSyncRecoveryDialog({ open, onOpenChange, conflicts, onManualMerge });
6502
6932
  if (!view.isOpen) return null;
6503
- return /* @__PURE__ */ jsxs25(
6933
+ return /* @__PURE__ */ jsxs26(
6504
6934
  "section",
6505
6935
  {
6506
6936
  ...props,
@@ -6514,17 +6944,17 @@ function KeepSyncRecoveryDialog({
6514
6944
  "data-state": view.conflictList.length > 0 ? "conflict" : "error",
6515
6945
  "data-loading": view.busyId !== void 0 ? "true" : void 0,
6516
6946
  children: [
6517
- /* @__PURE__ */ jsxs25("header", { children: [
6518
- /* @__PURE__ */ jsx30("h2", { id: "keepkit-sync-recovery-title", children: title ?? view.labels.title }),
6519
- /* @__PURE__ */ jsx30("button", { type: "button", "data-keep-action": "close-dialog", onClick: view.close, "aria-label": view.labels.close, children: view.labels.close })
6947
+ /* @__PURE__ */ jsxs26("header", { children: [
6948
+ /* @__PURE__ */ jsx34("h2", { id: "keepkit-sync-recovery-title", children: title ?? view.labels.title }),
6949
+ /* @__PURE__ */ jsx34("button", { type: "button", "data-keep-action": "close-dialog", onClick: view.close, "aria-label": view.labels.close, children: view.labels.close })
6520
6950
  ] }),
6521
6951
  children,
6522
- view.conflictList.length > 0 ? /* @__PURE__ */ jsxs25("div", { children: [
6523
- /* @__PURE__ */ jsx30("p", { children: view.labels.conflict }),
6524
- view.conflictList.map((conflict) => /* @__PURE__ */ jsxs25("article", { "data-conflict-id": conflict.id, children: [
6525
- /* @__PURE__ */ jsx30("h3", { children: getMetaTitle(conflict.operation.item?.meta) ?? conflict.id }),
6526
- /* @__PURE__ */ jsxs25("div", { "data-conflict-preview": true, children: [
6527
- /* @__PURE__ */ jsx30(
6952
+ view.conflictList.length > 0 ? /* @__PURE__ */ jsxs26("div", { children: [
6953
+ /* @__PURE__ */ jsx34("p", { children: view.labels.conflict }),
6954
+ view.conflictList.map((conflict) => /* @__PURE__ */ jsxs26("article", { "data-conflict-id": conflict.id, children: [
6955
+ /* @__PURE__ */ jsx34("h3", { children: getMetaTitle(conflict.operation.item?.meta) ?? conflict.id }),
6956
+ /* @__PURE__ */ jsxs26("div", { "data-conflict-preview": true, children: [
6957
+ /* @__PURE__ */ jsx34(
6528
6958
  ConflictPreview,
6529
6959
  {
6530
6960
  item: conflict.operation.item,
@@ -6534,7 +6964,7 @@ function KeepSyncRecoveryDialog({
6534
6964
  side: "local"
6535
6965
  }
6536
6966
  ),
6537
- /* @__PURE__ */ jsx30(
6967
+ /* @__PURE__ */ jsx34(
6538
6968
  ConflictPreview,
6539
6969
  {
6540
6970
  item: conflict.remote,
@@ -6545,8 +6975,8 @@ function KeepSyncRecoveryDialog({
6545
6975
  }
6546
6976
  )
6547
6977
  ] }),
6548
- /* @__PURE__ */ jsxs25("div", { children: [
6549
- /* @__PURE__ */ jsx30(
6978
+ /* @__PURE__ */ jsxs26("div", { children: [
6979
+ /* @__PURE__ */ jsx34(
6550
6980
  "button",
6551
6981
  {
6552
6982
  type: "button",
@@ -6556,7 +6986,7 @@ function KeepSyncRecoveryDialog({
6556
6986
  children: view.labels.keepLocal
6557
6987
  }
6558
6988
  ),
6559
- /* @__PURE__ */ jsx30(
6989
+ /* @__PURE__ */ jsx34(
6560
6990
  "button",
6561
6991
  {
6562
6992
  type: "button",
@@ -6566,7 +6996,7 @@ function KeepSyncRecoveryDialog({
6566
6996
  children: view.labels.useServer
6567
6997
  }
6568
6998
  ),
6569
- /* @__PURE__ */ jsx30(
6999
+ /* @__PURE__ */ jsx34(
6570
7000
  "button",
6571
7001
  {
6572
7002
  type: "button",
@@ -6579,12 +7009,12 @@ function KeepSyncRecoveryDialog({
6579
7009
  ] })
6580
7010
  ] }, conflict.id))
6581
7011
  ] }) : null,
6582
- view.showBackupRecovery ? /* @__PURE__ */ jsxs25("section", { "data-recovery": "backup", children: [
6583
- /* @__PURE__ */ jsx30("h3", { children: view.labels.backupRecovery }),
6584
- /* @__PURE__ */ jsx30("p", { children: view.labels.backupRecoveryDescription }),
6585
- backup ?? (showBackupControls ? /* @__PURE__ */ jsx30(KeepBackup, {}) : null)
7012
+ view.showBackupRecovery ? /* @__PURE__ */ jsxs26("section", { "data-recovery": "backup", children: [
7013
+ /* @__PURE__ */ jsx34("h3", { children: view.labels.backupRecovery }),
7014
+ /* @__PURE__ */ jsx34("p", { children: view.labels.backupRecoveryDescription }),
7015
+ backup ?? (showBackupControls ? /* @__PURE__ */ jsx34(KeepBackup, {}) : null)
6586
7016
  ] }) : null,
6587
- view.error ? /* @__PURE__ */ jsx30("p", { id: "keepkit-sync-recovery-error", role: "alert", "aria-live": "assertive", children: view.error instanceof Error ? view.error.message : view.labels.error }) : null
7017
+ view.error ? /* @__PURE__ */ jsx34("p", { id: "keepkit-sync-recovery-error", role: "alert", "aria-live": "assertive", children: getErrorMessage(view.error, view.labels.error) }) : null
6588
7018
  ]
6589
7019
  }
6590
7020
  );
@@ -6596,16 +7026,16 @@ function ConflictPreview({
6596
7026
  noteLabel,
6597
7027
  side
6598
7028
  }) {
6599
- return /* @__PURE__ */ jsxs25("article", { "data-conflict-version": side, "aria-label": heading, children: [
6600
- /* @__PURE__ */ jsx30("h4", { children: heading }),
6601
- /* @__PURE__ */ jsxs25("dl", { children: [
6602
- /* @__PURE__ */ jsxs25("div", { children: [
6603
- /* @__PURE__ */ jsx30("dt", { children: updatedAtLabel }),
6604
- /* @__PURE__ */ jsx30("dd", { children: item ? /* @__PURE__ */ jsx30("time", { dateTime: new Date(item.updatedAt).toISOString(), children: formatConflictDate(item.updatedAt) }) : "\u2014" })
7029
+ return /* @__PURE__ */ jsxs26("article", { "data-conflict-version": side, "aria-label": heading, children: [
7030
+ /* @__PURE__ */ jsx34("h4", { children: heading }),
7031
+ /* @__PURE__ */ jsxs26("dl", { children: [
7032
+ /* @__PURE__ */ jsxs26("div", { children: [
7033
+ /* @__PURE__ */ jsx34("dt", { children: updatedAtLabel }),
7034
+ /* @__PURE__ */ jsx34("dd", { children: item ? /* @__PURE__ */ jsx34("time", { dateTime: new Date(item.updatedAt).toISOString(), children: formatConflictDate(item.updatedAt) }) : "\u2014" })
6605
7035
  ] }),
6606
- /* @__PURE__ */ jsxs25("div", { children: [
6607
- /* @__PURE__ */ jsx30("dt", { children: noteLabel }),
6608
- /* @__PURE__ */ jsx30("dd", { children: item?.note || "\u2014" })
7036
+ /* @__PURE__ */ jsxs26("div", { children: [
7037
+ /* @__PURE__ */ jsx34("dt", { children: noteLabel }),
7038
+ /* @__PURE__ */ jsx34("dd", { children: item?.note || "\u2014" })
6609
7039
  ] })
6610
7040
  ] })
6611
7041
  ] });
@@ -6623,9 +7053,10 @@ function useKeepSyncStatusBanner({ onRetry, children }) {
6623
7053
  const conflictLabel = useUiLabel("syncConflict");
6624
7054
  const pendingLabel = useUiLabel("syncPending");
6625
7055
  const syncedLabel = useUiLabel("syncSynced");
7056
+ const failedLabel = useUiLabel("syncFailedMessage");
6626
7057
  const status = context.syncState.status;
6627
7058
  const hasConflicts = (context.syncState.conflicts?.length ?? 0) > 0 || context.syncState.conflictIds.length > 0;
6628
- const message = children ?? (status === "error" ? getErrorMessage6(context.syncState.error) : status === "conflict" || hasConflicts ? conflictLabel : status === "pending" || status === "syncing" ? pendingLabel : syncedLabel);
7059
+ const message = children ?? (status === "error" ? getErrorMessage(context.syncState.error, failedLabel) : status === "conflict" || hasConflicts ? conflictLabel : status === "pending" || status === "syncing" ? pendingLabel : syncedLabel);
6629
7060
  return {
6630
7061
  status,
6631
7062
  hasConflicts,
@@ -6644,12 +7075,9 @@ function useKeepSyncStatusBanner({ onRetry, children }) {
6644
7075
  }
6645
7076
  };
6646
7077
  }
6647
- function getErrorMessage6(error) {
6648
- return error instanceof Error ? error.message : "Sync failed.";
6649
- }
6650
7078
 
6651
7079
  // src/features/sync/KeepSyncStatusBanner.tsx
6652
- import { jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
7080
+ import { jsx as jsx35, jsxs as jsxs27 } from "react/jsx-runtime";
6653
7081
  function KeepSyncStatusBanner({
6654
7082
  onRetry,
6655
7083
  onResolveConflicts,
@@ -6661,7 +7089,7 @@ function KeepSyncStatusBanner({
6661
7089
  const showRetryLabel = useUiLabelVisibility("retrySync");
6662
7090
  const showResolveLabel = useUiLabelVisibility("resolveSync");
6663
7091
  if (view.status === "idle" && !view.hasConflicts) return null;
6664
- return /* @__PURE__ */ jsxs26(
7092
+ return /* @__PURE__ */ jsxs27(
6665
7093
  "aside",
6666
7094
  {
6667
7095
  ...props,
@@ -6671,8 +7099,8 @@ function KeepSyncStatusBanner({
6671
7099
  "data-keepkit": "sync-status",
6672
7100
  "data-state": view.status,
6673
7101
  children: [
6674
- /* @__PURE__ */ jsx31("p", { children: view.message }),
6675
- view.showRetry ? /* @__PURE__ */ jsx31(
7102
+ /* @__PURE__ */ jsx35("p", { children: view.message }),
7103
+ view.showRetry ? /* @__PURE__ */ jsx35(
6676
7104
  "button",
6677
7105
  {
6678
7106
  type: "button",
@@ -6683,7 +7111,7 @@ function KeepSyncStatusBanner({
6683
7111
  children: showRetryLabel ? view.retryLabel : null
6684
7112
  }
6685
7113
  ) : null,
6686
- view.hasConflicts ? /* @__PURE__ */ jsx31(
7114
+ view.hasConflicts ? /* @__PURE__ */ jsx35(
6687
7115
  "button",
6688
7116
  {
6689
7117
  type: "button",
@@ -6700,7 +7128,7 @@ function KeepSyncStatusBanner({
6700
7128
  }
6701
7129
 
6702
7130
  // src/features/workspace/hooks/useKeepWorkspace.ts
6703
- import { useCallback as useCallback10, useState as useState21 } from "react";
7131
+ import { useCallback as useCallback12, useState as useState23 } from "react";
6704
7132
  var PRESET_MODULES = {
6705
7133
  basic: { syncStatus: false, undo: false, recovery: false, backup: false, stalePrune: false },
6706
7134
  standard: { syncStatus: false, undo: true, recovery: false, backup: false, stalePrune: false },
@@ -6720,16 +7148,16 @@ function useKeepWorkspace({
6720
7148
  onRecoveryOpenChange,
6721
7149
  onResolveConflicts
6722
7150
  }) {
6723
- const [internalRecoveryOpen, setInternalRecoveryOpen] = useState21(false);
7151
+ const [internalRecoveryOpen, setInternalRecoveryOpen] = useState23(false);
6724
7152
  const resolvedModules = { ...PRESET_MODULES[preset], ...modules };
6725
- const setRecoveryOpen = useCallback10(
7153
+ const setRecoveryOpen = useCallback12(
6726
7154
  (open) => {
6727
7155
  if (recoveryOpen === void 0) setInternalRecoveryOpen(open);
6728
7156
  onRecoveryOpenChange?.(open);
6729
7157
  },
6730
7158
  [onRecoveryOpenChange, recoveryOpen]
6731
7159
  );
6732
- const openRecovery = useCallback10(() => {
7160
+ const openRecovery = useCallback12(() => {
6733
7161
  onResolveConflicts?.();
6734
7162
  setRecoveryOpen(true);
6735
7163
  }, [onResolveConflicts, setRecoveryOpen]);
@@ -6744,7 +7172,7 @@ function useKeepWorkspace({
6744
7172
  }
6745
7173
 
6746
7174
  // src/features/workspace/KeepWorkspace.tsx
6747
- import { jsx as jsx32, jsxs as jsxs27 } from "react/jsx-runtime";
7175
+ import { jsx as jsx36, jsxs as jsxs28 } from "react/jsx-runtime";
6748
7176
  function KeepWorkspace({
6749
7177
  preset = "standard",
6750
7178
  modules,
@@ -6783,27 +7211,27 @@ function KeepWorkspace({
6783
7211
  if (!structuredRegions) return content;
6784
7212
  if (!hasRenderableContent(content)) return null;
6785
7213
  const resolvedSurface = typeof surface === "string" ? surface : surface[name] ?? "plain";
6786
- return /* @__PURE__ */ jsx32("div", { "data-keepkit": "workspace-region", "data-region": name, "data-surface": resolvedSurface, children: content });
7214
+ return /* @__PURE__ */ jsx36("div", { "data-keepkit": "workspace-region", "data-region": name, "data-surface": resolvedSurface, children: content });
6787
7215
  };
6788
7216
  const before = resolveOptionalSlot(slots?.before, state);
6789
7217
  const syncStatus = view.modules.syncStatus ? resolveSlot(
6790
7218
  slots?.syncStatus,
6791
- /* @__PURE__ */ jsx32(KeepSyncStatusBanner, { ...syncStatusProps, onResolveConflicts: view.openRecovery }),
7219
+ /* @__PURE__ */ jsx36(KeepSyncStatusBanner, { ...syncStatusProps, onResolveConflicts: view.openRecovery }),
6792
7220
  state
6793
7221
  ) : null;
6794
- const collection = resolveSlot(slots?.collection, /* @__PURE__ */ jsx32(KeepCollection, { ...resolvedCollectionProps }), state);
7222
+ const collection = resolveSlot(slots?.collection, /* @__PURE__ */ jsx36(KeepCollection, { ...resolvedCollectionProps }), state);
6795
7223
  const actions = view.modules.backup || view.modules.stalePrune ? resolveSlot(
6796
7224
  slots?.actions,
6797
- /* @__PURE__ */ jsxs27("div", { "data-keepkit": "workspace-actions", children: [
6798
- view.modules.stalePrune ? /* @__PURE__ */ jsx32(KeepPruneStaleButton, { ...stalePruneProps }) : null,
6799
- view.modules.backup ? /* @__PURE__ */ jsx32(KeepBackup, { ...backupProps }) : null
7225
+ /* @__PURE__ */ jsxs28("div", { "data-keepkit": "workspace-actions", children: [
7226
+ view.modules.stalePrune ? /* @__PURE__ */ jsx36(KeepPruneStaleButton, { ...stalePruneProps }) : null,
7227
+ view.modules.backup ? /* @__PURE__ */ jsx36(KeepBackup, { ...backupProps }) : null
6800
7228
  ] }),
6801
7229
  state
6802
7230
  ) : null;
6803
- const undo = view.modules.undo ? resolveSlot(slots?.undo, /* @__PURE__ */ jsx32(KeepUndo, { ...undoProps }), state) : null;
7231
+ const undo = view.modules.undo ? resolveSlot(slots?.undo, /* @__PURE__ */ jsx36(KeepUndo, { ...undoProps }), state) : null;
6804
7232
  const recovery = view.modules.recovery ? resolveSlot(
6805
7233
  slots?.recovery,
6806
- /* @__PURE__ */ jsx32(
7234
+ /* @__PURE__ */ jsx36(
6807
7235
  KeepSyncRecoveryDialog,
6808
7236
  {
6809
7237
  ...recoveryProps,
@@ -6815,7 +7243,7 @@ function KeepWorkspace({
6815
7243
  ) : null;
6816
7244
  const additionalContent = resolveOptionalSlot(children, state);
6817
7245
  const after = resolveOptionalSlot(slots?.after, state);
6818
- return /* @__PURE__ */ jsxs27(
7246
+ return /* @__PURE__ */ jsxs28(
6819
7247
  "section",
6820
7248
  {
6821
7249
  ...props,
@@ -6846,70 +7274,6 @@ function resolveOptionalSlot(slot, state) {
6846
7274
  return resolveContent(slot, state);
6847
7275
  }
6848
7276
 
6849
- // src/foundation/theme.tsx
6850
- import { isValidElement as isValidElement9 } from "react";
6851
- import { jsx as jsx33 } from "react/jsx-runtime";
6852
- var keepThemeNames = [
6853
- "default",
6854
- "ocean",
6855
- "forest",
6856
- "sunset",
6857
- "lavender",
6858
- "compact",
6859
- "minimal",
6860
- "rounded",
6861
- "high-contrast",
6862
- "dark"
6863
- ];
6864
- function KeepThemeProvider({
6865
- children,
6866
- theme = "default",
6867
- mode = "system",
6868
- density = "comfortable",
6869
- radius = "medium",
6870
- accentColor,
6871
- highContrast = false,
6872
- reducedMotion = false,
6873
- variables,
6874
- style,
6875
- className,
6876
- asChild = false,
6877
- ...props
6878
- }) {
6879
- const themeClassName = [
6880
- "keep-theme",
6881
- `keep-theme--${theme}`,
6882
- `keep-theme--${mode}`,
6883
- `keep-theme--density-${density}`,
6884
- `keep-theme--radius-${radius}`,
6885
- className
6886
- ].filter(Boolean).join(" ");
6887
- const themeStyle = {
6888
- ...style,
6889
- ...accentColor && !highContrast ? { "--keep-accent": accentColor, "--keep-primary": accentColor } : {},
6890
- ...variables
6891
- };
6892
- const rootProps = {
6893
- ...props,
6894
- className: themeClassName,
6895
- style: themeStyle,
6896
- "data-keep-theme": theme,
6897
- "data-theme": theme,
6898
- "data-mode": mode,
6899
- "data-density": density,
6900
- "data-radius": radius,
6901
- "data-accent-color": accentColor,
6902
- "data-high-contrast": highContrast ? "true" : void 0,
6903
- "data-reduced-motion": reducedMotion ? "true" : void 0
6904
- };
6905
- if (asChild) {
6906
- if (!isValidElement9(children))
6907
- throw new Error("KeepThemeProvider with asChild requires a single React element child.");
6908
- return createSlot(children, rootProps);
6909
- }
6910
- return /* @__PURE__ */ jsx33("div", { ...rootProps, children });
6911
- }
6912
-
6913
7277
  // src/index.tsx
6914
7278
  import { createAuthenticatedSyncKit } from "@keepkit/core/core";
6915
7279
  import {
@@ -6918,8 +7282,9 @@ import {
6918
7282
  useKeepCollections as useKeepCollections5,
6919
7283
  useKeepContext as useKeepContext11,
6920
7284
  useKeepItem as useKeepItem8,
6921
- useKeepList as useKeepList5,
7285
+ useKeepList as useKeepList7,
6922
7286
  useKeepNavigator as useKeepNavigator2,
7287
+ useKeepRediscovery,
6923
7288
  useKeepShortcut
6924
7289
  } from "@keepkit/core/react";
6925
7290
  import {
@@ -6932,7 +7297,7 @@ import {
6932
7297
  LocalStorageSyncQueueAdapter,
6933
7298
  SyncStorageAdapter
6934
7299
  } from "@keepkit/core/storage";
6935
- import { jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
7300
+ import { jsx as jsx37, jsxs as jsxs29 } from "react/jsx-runtime";
6936
7301
  function KeepKitProvider({
6937
7302
  labels,
6938
7303
  labelOptions,
@@ -6950,10 +7315,11 @@ function KeepKitProvider({
6950
7315
  className: themeClassName,
6951
7316
  style: themeStyle,
6952
7317
  asChild: themeAsChild,
7318
+ tour,
6953
7319
  children,
6954
7320
  ...providerProps
6955
7321
  }) {
6956
- return /* @__PURE__ */ jsx34(
7322
+ return /* @__PURE__ */ jsx37(
6957
7323
  KeepUiProvider,
6958
7324
  {
6959
7325
  labels,
@@ -6961,7 +7327,7 @@ function KeepKitProvider({
6961
7327
  locale,
6962
7328
  labelResolver,
6963
7329
  onFeedback,
6964
- children: /* @__PURE__ */ jsx34(
7330
+ children: /* @__PURE__ */ jsx37(
6965
7331
  KeepThemeProvider,
6966
7332
  {
6967
7333
  theme,
@@ -6975,10 +7341,10 @@ function KeepKitProvider({
6975
7341
  className: themeClassName,
6976
7342
  style: themeStyle,
6977
7343
  asChild: themeAsChild,
6978
- children: /* @__PURE__ */ jsxs28(CoreKeepProvider, { ...providerProps, children: [
6979
- /* @__PURE__ */ jsx34(KeepSyncFeedbackObserver, {}),
6980
- children,
6981
- /* @__PURE__ */ jsx34(KeepAnnouncements, {})
7344
+ children: /* @__PURE__ */ jsxs29(CoreKeepProvider, { ...providerProps, children: [
7345
+ /* @__PURE__ */ jsx37(KeepSyncFeedbackObserver, {}),
7346
+ /* @__PURE__ */ jsx37(KeepTourProvider, { ...tour, children }),
7347
+ /* @__PURE__ */ jsx37(KeepAnnouncements, {})
6982
7348
  ] })
6983
7349
  }
6984
7350
  )
@@ -7002,13 +7368,14 @@ function createKeepKit(options = {}) {
7002
7368
  variables,
7003
7369
  themeClassName,
7004
7370
  themeStyle,
7371
+ tour,
7005
7372
  getTitle,
7006
7373
  getImageProps,
7007
7374
  ...coreOptions
7008
7375
  } = options;
7009
7376
  const coreKit = createCoreKeepKit(coreOptions);
7010
7377
  return {
7011
- Provider: (props) => /* @__PURE__ */ jsx34(
7378
+ Provider: (props) => /* @__PURE__ */ jsx37(
7012
7379
  KeepKitProvider,
7013
7380
  {
7014
7381
  ...coreOptions,
@@ -7027,12 +7394,13 @@ function createKeepKit(options = {}) {
7027
7394
  variables,
7028
7395
  className: themeClassName,
7029
7396
  style: themeStyle,
7397
+ tour,
7030
7398
  ...props
7031
7399
  }
7032
7400
  ),
7033
- Button: (props) => /* @__PURE__ */ jsx34(KeepButton, { ...props }),
7034
- Backup: (props) => /* @__PURE__ */ jsx34(KeepBackup, { ...props }),
7035
- Collection: (props) => /* @__PURE__ */ jsx34(
7401
+ Button: (props) => /* @__PURE__ */ jsx37(KeepButton, { ...props }),
7402
+ Backup: (props) => /* @__PURE__ */ jsx37(KeepBackup, { ...props }),
7403
+ Collection: (props) => /* @__PURE__ */ jsx37(
7036
7404
  KeepCollection,
7037
7405
  {
7038
7406
  ...props,
@@ -7043,8 +7411,8 @@ function createKeepKit(options = {}) {
7043
7411
  }
7044
7412
  }
7045
7413
  ),
7046
- CollectionManager: (props) => /* @__PURE__ */ jsx34(KeepCollectionManager, { ...props }),
7047
- Workspace: (props) => /* @__PURE__ */ jsx34(
7414
+ CollectionManager: (props) => /* @__PURE__ */ jsx37(KeepCollectionManager, { ...props }),
7415
+ Workspace: (props) => /* @__PURE__ */ jsx37(
7048
7416
  KeepWorkspace,
7049
7417
  {
7050
7418
  ...props,
@@ -7061,9 +7429,13 @@ function createKeepKit(options = {}) {
7061
7429
  useContext: () => coreKit.useContext(),
7062
7430
  useItem: (item) => coreKit.useItem(item),
7063
7431
  useList: (query) => coreKit.useList(query),
7432
+ useRediscovery: (rediscoveryOptions) => coreKit.useRediscovery(rediscoveryOptions),
7064
7433
  useCollections: (collectionsOptions) => coreKit.useCollections(collectionsOptions),
7065
7434
  useNavigator: (navigatorOptions) => coreKit.useNavigator(navigatorOptions),
7066
- useShortcut: (shortcutOptions) => coreKit.useShortcut(shortcutOptions)
7435
+ useShortcut: (shortcutOptions) => coreKit.useShortcut(shortcutOptions),
7436
+ FloatingTour: (props) => /* @__PURE__ */ jsx37(KeepFloatingTour, { ...props }),
7437
+ TourProvider: (props) => /* @__PURE__ */ jsx37(KeepTourProvider, { ...props }),
7438
+ useTour: (tourOptions) => useKeepTour(tourOptions)
7067
7439
  };
7068
7440
  }
7069
7441
  export {
@@ -7085,6 +7457,7 @@ export {
7085
7457
  KeepCollectionSelect,
7086
7458
  KeepEmptyState,
7087
7459
  KeepErrorBoundary3 as KeepErrorBoundary,
7460
+ KeepFloatingTour,
7088
7461
  KeepHighlight,
7089
7462
  KeepItemCard,
7090
7463
  KeepItemCardSkeleton,
@@ -7100,6 +7473,7 @@ export {
7100
7473
  KeepProvider,
7101
7474
  KeepPruneStaleButton,
7102
7475
  KeepQuickEditor,
7476
+ KeepRediscovery,
7103
7477
  KeepReorderableList,
7104
7478
  KeepSavePopover,
7105
7479
  KeepSearchInput,
@@ -7113,6 +7487,7 @@ export {
7113
7487
  KeepTagFilter,
7114
7488
  KeepThemeProvider,
7115
7489
  KeepTourBar,
7490
+ KeepTourProvider,
7116
7491
  KeepUiProvider,
7117
7492
  KeepUndo,
7118
7493
  KeepWorkspace,
@@ -7136,11 +7511,13 @@ export {
7136
7511
  useKeepCollections5 as useKeepCollections,
7137
7512
  useKeepContext11 as useKeepContext,
7138
7513
  useKeepItem8 as useKeepItem,
7139
- useKeepList5 as useKeepList,
7514
+ useKeepList7 as useKeepList,
7140
7515
  useKeepNavigator2 as useKeepNavigator,
7141
7516
  useKeepQuickEditor,
7517
+ useKeepRediscovery,
7142
7518
  useKeepShortcut,
7143
7519
  useKeepToastFeedback,
7520
+ useKeepTour,
7144
7521
  useKeepTourShortcuts,
7145
7522
  useKeepUiLabels,
7146
7523
  useKeepUrlSync,