@kyro-cms/admin 0.5.3 → 0.5.5

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 (38) hide show
  1. package/dist/{EditorClient-YLCGVDXY.cjs → EditorClient-Q23UXR37.cjs} +14 -14
  2. package/dist/{EditorClient-XEUOVAAC.js → EditorClient-T5PASFNR.js} +2 -2
  3. package/dist/chunk-3BGDYKTD.cjs +348 -0
  4. package/dist/chunk-3BGDYKTD.cjs.map +1 -0
  5. package/dist/chunk-EEFXLQVT.js +3 -0
  6. package/dist/chunk-EEFXLQVT.js.map +1 -0
  7. package/dist/index.cjs +462 -1020
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.css +13 -0
  10. package/dist/index.css.map +1 -1
  11. package/dist/index.js +271 -829
  12. package/dist/index.js.map +1 -1
  13. package/package.json +7 -3
  14. package/src/components/AuditLogsPage.tsx +4 -8
  15. package/src/components/Dashboard.tsx +2 -1
  16. package/src/components/DetailView.tsx +9 -2
  17. package/src/components/ListView.tsx +3 -2
  18. package/src/components/MediaGallery.tsx +13 -6
  19. package/src/components/Sidebar.astro +1 -1
  20. package/src/components/ui/Shimmer.tsx +28 -0
  21. package/src/components/users/UserDetail.tsx +1 -1
  22. package/src/components/users/UserForm.tsx +1 -1
  23. package/src/components/users/UsersList.tsx +1 -1
  24. package/src/hooks/useAutoFormState.ts +19 -3
  25. package/src/integration.ts +77 -25
  26. package/src/layouts/AdminLayout.astro +70 -48
  27. package/src/lib/config.ts +6 -1
  28. package/src/lib/globals.ts +56 -20
  29. package/src/pages/index.astro +1 -1
  30. package/src/pages/roles/index.astro +1 -1
  31. package/src/pages/users/[id].astro +2 -2
  32. package/src/styles/main.css +17 -0
  33. package/dist/chunk-7KPIUCGT.js +0 -384
  34. package/dist/chunk-7KPIUCGT.js.map +0 -1
  35. package/dist/chunk-GOACG6R7.cjs +0 -473
  36. package/dist/chunk-GOACG6R7.cjs.map +0 -1
  37. /package/dist/{EditorClient-XEUOVAAC.js.map → EditorClient-Q23UXR37.cjs.map} +0 -0
  38. /package/dist/{EditorClient-YLCGVDXY.cjs.map → EditorClient-T5PASFNR.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { LuPlus, LuGripVertical, LuX, LuCircleCheck, LuShieldAlert, LuTriangleAlert, LuInfo, LuFileText, LuSettings, LuImage, LuClock, LuFile, LuShield, LuDatabase, LuHexagon, LuNetwork, LuSun, LuMoon, LuLogOut, LuLoaderCircle, LuSearch, LuArrowRight, LuUsers, LuActivity, LuLayoutDashboard, LuArrowUpRight, LuUserPlus, LuLockOpen, LuLock, LuTrash2, LuEllipsisVertical, LuRefreshCcw, LuCheck, LuSave, LuTag, LuPalette, LuSparkles, LuCodeXml, LuKey, LuEyeOff, LuEye, LuCopy, LuTerminal, LuExternalLink, LuCirclePlay, LuChevronRight, LuWebhook, LuZap, LuSend, LuPause, LuPlay, LuRefreshCw, LuGrid3X3, LuMaximize2, LuFolderPlus, LuFolderInput, LuFolder, LuFilm, LuMusic, LuArchive, LuLink, LuDownload, LuCrop, LuAlignLeft, LuChevronUp, LuChevronDown, LuColumns3, LuHeading1, LuMinus, LuVideo, LuList, LuCode, LuArrowDown, LuMousePointerClick, LuStar, LuListOrdered, LuLink2, LuBox } from './chunk-7KPIUCGT.js';
1
+ import { LuPlus, LuGripVertical, LuX, LuCircleCheck, LuShieldAlert, LuTriangleAlert, LuInfo, LuFileText, LuSettings, LuImage, LuClock, LuFile, LuShield, LuDatabase, LuHexagon, LuNetwork, LuSun, LuMoon, LuLogOut, LuLoaderCircle, LuSearch, LuArrowRight, LuUsers, LuActivity, LuLayoutDashboard, LuArrowUpRight, LuUserPlus, LuLockOpen, LuLock, LuTrash2, LuEllipsisVertical, LuRefreshCcw, LuCheck, LuSave, LuTag, LuPalette, LuSparkles, LuCodeXml, LuKey, LuEyeOff, LuEye, LuCopy, LuTerminal, LuExternalLink, LuCirclePlay, LuChevronRight, LuWebhook, LuZap, LuSend, LuPause, LuPlay, LuRefreshCw, LuGrid3X3, LuFile2, LuMaximize2, LuFolderPlus, LuFolderInput, LuFolder, LuFilm, LuMusic, LuArchive, LuLink, LuDownload, LuCrop, LuAlignLeft, LuChevronUp, LuChevronDown, LuColumns3, LuHeading1, LuMinus, LuVideo, LuList, LuCode, LuArrowDown, LuMousePointerClick, LuStar, LuListOrdered, LuLink2, LuBox } from './chunk-EEFXLQVT.js';
2
2
  import React17, { lazy, createContext, useState, useMemo, useCallback, useEffect, useRef, useContext, Suspense } from 'react';
3
3
  import { create, useStore } from 'zustand';
4
4
  import { persist, createJSONStorage } from 'zustand/middleware';
5
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import projectConfig from 'kyro:config';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
6
  import { mediaCollections, authCollections, minimalCollections, blogCollections, ecommerceCollections, kitchenSinkCollections, allSettingsGlobals, coreSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';
8
- import { createStore, get, set, del, keys, clear } from 'idb-keyval';
7
+ import { createStorage } from 'unstorage';
8
+ import indexedbDriver from 'unstorage/drivers/indexedb';
9
9
  import { createPortal } from 'react-dom';
10
10
  import '@portabletext/react';
11
11
  import { githubLight } from '@uiw/codemirror-theme-github';
12
12
  import { aura } from '@uiw/codemirror-theme-aura';
13
- import { createStore as createStore$1 } from 'zustand/vanilla';
13
+ import { createStore } from 'zustand/vanilla';
14
14
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, DragOverlay, useDraggable } from '@dnd-kit/core';
15
15
  import { useSortable, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
16
16
  import { CSS } from '@dnd-kit/utilities';
@@ -21,6 +21,9 @@ import 'react-image-crop/dist/ReactCrop.css';
21
21
  import '@kyro-cms/core';
22
22
  import path from 'path';
23
23
  import fs from 'fs';
24
+ import { execSync } from 'child_process';
25
+ import { config } from 'dotenv';
26
+ import { transform } from 'esbuild';
24
27
 
25
28
  // src/lib/paths.ts
26
29
  var adminPath = typeof __KYRO_ADMIN_PATH__ !== "undefined" ? __KYRO_ADMIN_PATH__ : "/admin";
@@ -60,28 +63,28 @@ var paths = {
60
63
  resolveAdmin,
61
64
  resolveMedia
62
65
  };
63
- var useAuthStore = create((set2) => ({
66
+ var useAuthStore = create((set) => ({
64
67
  user: null,
65
68
  permissions: null,
66
69
  isAuthenticated: false,
67
70
  isLoading: true,
68
71
  error: null,
69
- setUser: (user, permissions = null) => set2({
72
+ setUser: (user, permissions = null) => set({
70
73
  user,
71
74
  permissions,
72
75
  isAuthenticated: !!user,
73
76
  isLoading: false,
74
77
  error: null
75
78
  }),
76
- setLoading: (isLoading) => set2({ isLoading }),
77
- setError: (error) => set2({
79
+ setLoading: (isLoading) => set({ isLoading }),
80
+ setError: (error) => set({
78
81
  error,
79
82
  isLoading: false,
80
83
  isAuthenticated: false,
81
84
  user: null,
82
85
  permissions: null
83
86
  }),
84
- logout: () => set2({
87
+ logout: () => set({
85
88
  user: null,
86
89
  permissions: null,
87
90
  isAuthenticated: false,
@@ -89,18 +92,18 @@ var useAuthStore = create((set2) => ({
89
92
  error: null
90
93
  })
91
94
  }));
92
- var useToastStore = create((set2) => ({
95
+ var useToastStore = create((set) => ({
93
96
  toasts: [],
94
97
  addToast: (type, message) => {
95
98
  const id = Math.random().toString(36).substring(7);
96
- set2((state) => ({
99
+ set((state) => ({
97
100
  toasts: [...state.toasts, { id, type, message }]
98
101
  }));
99
102
  },
100
- removeToast: (id) => set2((state) => ({
103
+ removeToast: (id) => set((state) => ({
101
104
  toasts: state.toasts.filter((t) => t.id !== id)
102
105
  })),
103
- clearToasts: () => set2({ toasts: [] })
106
+ clearToasts: () => set({ toasts: [] })
104
107
  }));
105
108
  var toast = {
106
109
  success: (message) => useToastStore.getState().addToast("success", message),
@@ -110,89 +113,89 @@ var toast = {
110
113
  };
111
114
  create()(
112
115
  persist(
113
- (set2) => ({
116
+ (set) => ({
114
117
  mode: "light",
115
- setMode: (mode) => set2({ mode }),
116
- toggleMode: () => set2((state) => ({ mode: state.mode === "light" ? "dark" : "light" }))
118
+ setMode: (mode) => set({ mode }),
119
+ toggleMode: () => set((state) => ({ mode: state.mode === "light" ? "dark" : "light" }))
117
120
  }),
118
121
  {
119
122
  name: "kyro-theme"
120
123
  }
121
124
  )
122
125
  );
123
- var useUIStore = create((set2) => ({
126
+ var useUIStore = create((set) => ({
124
127
  sidebarOpen: true,
125
- toggleSidebar: () => set2((state) => ({ sidebarOpen: !state.sidebarOpen })),
126
- setSidebarOpen: (open) => set2({ sidebarOpen: open }),
128
+ toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
129
+ setSidebarOpen: (open) => set({ sidebarOpen: open }),
127
130
  modal: {
128
131
  open: false,
129
132
  config: null
130
133
  },
131
- confirm: (config) => set2({
134
+ confirm: (config) => set({
132
135
  modal: {
133
136
  open: true,
134
137
  config: { ...config, variant: config.variant || "default" }
135
138
  }
136
139
  }),
137
- alert: (config) => set2({
140
+ alert: (config) => set({
138
141
  modal: {
139
142
  open: true,
140
143
  config: {
141
144
  ...config,
142
145
  variant: config.variant || "default",
143
146
  confirmLabel: config.confirmLabel || "OK",
144
- onConfirm: () => set2((s) => ({ modal: { ...s.modal, open: false } }))
147
+ onConfirm: () => set((s) => ({ modal: { ...s.modal, open: false } }))
145
148
  }
146
149
  }
147
150
  }),
148
- closeModal: () => set2((state) => ({
151
+ closeModal: () => set((state) => ({
149
152
  modal: { ...state.modal, open: false },
150
153
  activeModal: null
151
154
  })),
152
155
  activeModal: null,
153
- openModal: (modal) => set2({ activeModal: modal })
156
+ openModal: (modal) => set({ activeModal: modal })
154
157
  }));
155
- create((set2) => ({
158
+ create((set) => ({
156
159
  editor: null,
157
- setEditor: (editor) => set2({ editor }),
160
+ setEditor: (editor) => set({ editor }),
158
161
  blockDrawerOpen: false,
159
- openBlockDrawer: (options) => set2({
162
+ openBlockDrawer: (options) => set({
160
163
  blockDrawerOpen: true,
161
164
  pendingInsert: { pos: null, column: options?.targetColumn ?? null }
162
165
  }),
163
- closeBlockDrawer: () => set2({
166
+ closeBlockDrawer: () => set({
164
167
  blockDrawerOpen: false,
165
168
  pendingInsert: { pos: null, column: null }
166
169
  }),
167
- toggleBlockDrawer: () => set2((state) => ({ blockDrawerOpen: !state.blockDrawerOpen })),
170
+ toggleBlockDrawer: () => set((state) => ({ blockDrawerOpen: !state.blockDrawerOpen })),
168
171
  selectedBlock: null,
169
- setSelectedBlock: (block3) => set2({ selectedBlock: block3 }),
172
+ setSelectedBlock: (block3) => set({ selectedBlock: block3 }),
170
173
  pendingInsert: { pos: null, column: null },
171
- setPendingInsert: (pos, column) => set2({ pendingInsert: { pos, column: column ?? null } }),
172
- clearPendingInsert: () => set2({ pendingInsert: { pos: null, column: null } })
174
+ setPendingInsert: (pos, column) => set({ pendingInsert: { pos, column: column ?? null } }),
175
+ clearPendingInsert: () => set({ pendingInsert: { pos: null, column: null } })
173
176
  }));
174
- create((set2, get2) => ({
177
+ create((set, get) => ({
175
178
  cache: {},
176
- setCache: (key, data) => set2((state) => ({
179
+ setCache: (key, data) => set((state) => ({
177
180
  cache: {
178
181
  ...state.cache,
179
182
  [key]: { data, loading: false, error: null, lastFetch: Date.now() }
180
183
  }
181
184
  })),
182
- setLoading: (key, loading) => set2((state) => ({
185
+ setLoading: (key, loading) => set((state) => ({
183
186
  cache: {
184
187
  ...state.cache,
185
188
  [key]: { ...state.cache[key], loading, error: null }
186
189
  }
187
190
  })),
188
- setError: (key, error) => set2((state) => ({
191
+ setError: (key, error) => set((state) => ({
189
192
  cache: {
190
193
  ...state.cache,
191
194
  [key]: { data: null, loading: false, error, lastFetch: null }
192
195
  }
193
196
  })),
194
- getCache: (key) => get2().cache[key] || null,
195
- invalidateCache: (key) => set2((state) => {
197
+ getCache: (key) => get().cache[key] || null,
198
+ invalidateCache: (key) => set((state) => {
196
199
  if (key) {
197
200
  const { [key]: _, ...rest } = state.cache;
198
201
  return { cache: rest };
@@ -393,27 +396,23 @@ async function apiUpload(url, body, onProgress) {
393
396
  xhr.send(body);
394
397
  });
395
398
  }
396
- function Spinner({ size = "md", className = "" }) {
397
- return /* @__PURE__ */ jsx(
398
- "svg",
399
+ function Shimmer({ variant, count = 1, className = "" }) {
400
+ const variants = {
401
+ text: "h-3 rounded-md",
402
+ circle: "size-10 rounded-full",
403
+ rect: "h-10 rounded-xl",
404
+ card: "h-32 rounded-2xl",
405
+ "table-row": "h-14 rounded-xl",
406
+ "media-card": "aspect-square rounded-2xl",
407
+ "stat-card": "h-24 rounded-2xl"
408
+ };
409
+ return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: count }).map((_, i) => /* @__PURE__ */ jsx(
410
+ "div",
399
411
  {
400
- className: `kyro-spinner kyro-spinner-${size} ${className}`,
401
- viewBox: "0 0 24 24",
402
- fill: "none",
403
- children: /* @__PURE__ */ jsx(
404
- "circle",
405
- {
406
- cx: "12",
407
- cy: "12",
408
- r: "10",
409
- stroke: "currentColor",
410
- strokeWidth: "3",
411
- strokeLinecap: "round",
412
- strokeDasharray: "40 20"
413
- }
414
- )
415
- }
416
- );
412
+ className: `kyro-shimmer ${variants[variant]} ${className}`
413
+ },
414
+ i
415
+ )) });
417
416
  }
418
417
  function PageHeader({
419
418
  title,
@@ -1051,7 +1050,7 @@ function ListView({
1051
1050
  )
1052
1051
  ] })
1053
1052
  ] }),
1054
- /* @__PURE__ */ jsx("div", { className: "surface-tile overflow-hidden", children: loading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-20", children: /* @__PURE__ */ jsx(Spinner, {}) }) : docs.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-16 px-8", children: [
1053
+ /* @__PURE__ */ jsx("div", { className: "surface-tile overflow-hidden", children: loading ? /* @__PURE__ */ jsx("div", { className: "space-y-2 p-4", children: /* @__PURE__ */ jsx(Shimmer, { variant: "table-row", count: 8 }) }) : docs.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-16 px-8", children: [
1055
1054
  /* @__PURE__ */ jsx("div", { className: "w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4", children: /* @__PURE__ */ jsx(
1056
1055
  "svg",
1057
1056
  {
@@ -1425,6 +1424,8 @@ function createProjectAdminConfig(config) {
1425
1424
  globals: toGlobalMap(projectGlobals)
1426
1425
  };
1427
1426
  }
1427
+ var global = globalThis;
1428
+ var projectConfig = global.__KYRO_ADMIN_PROJECT_CONFIG__ || {};
1428
1429
  var adminConfig = createProjectAdminConfig(projectConfig);
1429
1430
  var collections = adminConfig.collections;
1430
1431
  var globals = adminConfig.globals;
@@ -1432,659 +1433,6 @@ var authCollectionSlugs = ["users", "audit_logs"];
1432
1433
  Object.values(collections).filter(
1433
1434
  (c) => !authCollectionSlugs.includes(c.slug)
1434
1435
  );
1435
-
1436
- // ../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
1437
- var suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
1438
- var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
1439
- var JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
1440
- function jsonParseTransform(key, value) {
1441
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
1442
- warnKeyDropped(key);
1443
- return;
1444
- }
1445
- return value;
1446
- }
1447
- function warnKeyDropped(key) {
1448
- console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
1449
- }
1450
- function destr(value, options = {}) {
1451
- if (typeof value !== "string") {
1452
- return value;
1453
- }
1454
- if (value[0] === '"' && value[value.length - 1] === '"' && value.indexOf("\\") === -1) {
1455
- return value.slice(1, -1);
1456
- }
1457
- const _value = value.trim();
1458
- if (_value.length <= 9) {
1459
- switch (_value.toLowerCase()) {
1460
- case "true": {
1461
- return true;
1462
- }
1463
- case "false": {
1464
- return false;
1465
- }
1466
- case "undefined": {
1467
- return void 0;
1468
- }
1469
- case "null": {
1470
- return null;
1471
- }
1472
- case "nan": {
1473
- return Number.NaN;
1474
- }
1475
- case "infinity": {
1476
- return Number.POSITIVE_INFINITY;
1477
- }
1478
- case "-infinity": {
1479
- return Number.NEGATIVE_INFINITY;
1480
- }
1481
- }
1482
- }
1483
- if (!JsonSigRx.test(value)) {
1484
- if (options.strict) {
1485
- throw new SyntaxError("[destr] Invalid JSON");
1486
- }
1487
- return value;
1488
- }
1489
- try {
1490
- if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
1491
- if (options.strict) {
1492
- throw new Error("[destr] Possible prototype pollution");
1493
- }
1494
- return JSON.parse(value, jsonParseTransform);
1495
- }
1496
- return JSON.parse(value);
1497
- } catch (error) {
1498
- if (options.strict) {
1499
- throw error;
1500
- }
1501
- return value;
1502
- }
1503
- }
1504
-
1505
- // ../node_modules/.pnpm/unstorage@1.17.5_idb-keyval@6.2.2_ioredis@5.10.1/node_modules/unstorage/dist/shared/unstorage.zVDD2mZo.mjs
1506
- function wrapToPromise(value) {
1507
- if (!value || typeof value.then !== "function") {
1508
- return Promise.resolve(value);
1509
- }
1510
- return value;
1511
- }
1512
- function asyncCall(function_, ...arguments_) {
1513
- try {
1514
- return wrapToPromise(function_(...arguments_));
1515
- } catch (error) {
1516
- return Promise.reject(error);
1517
- }
1518
- }
1519
- function isPrimitive(value) {
1520
- const type = typeof value;
1521
- return value === null || type !== "object" && type !== "function";
1522
- }
1523
- function isPureObject(value) {
1524
- const proto = Object.getPrototypeOf(value);
1525
- return !proto || proto.isPrototypeOf(Object);
1526
- }
1527
- function stringify(value) {
1528
- if (isPrimitive(value)) {
1529
- return String(value);
1530
- }
1531
- if (isPureObject(value) || Array.isArray(value)) {
1532
- return JSON.stringify(value);
1533
- }
1534
- if (typeof value.toJSON === "function") {
1535
- return stringify(value.toJSON());
1536
- }
1537
- throw new Error("[unstorage] Cannot stringify value!");
1538
- }
1539
- var BASE64_PREFIX = "base64:";
1540
- function serializeRaw(value) {
1541
- if (typeof value === "string") {
1542
- return value;
1543
- }
1544
- return BASE64_PREFIX + base64Encode(value);
1545
- }
1546
- function deserializeRaw(value) {
1547
- if (typeof value !== "string") {
1548
- return value;
1549
- }
1550
- if (!value.startsWith(BASE64_PREFIX)) {
1551
- return value;
1552
- }
1553
- return base64Decode(value.slice(BASE64_PREFIX.length));
1554
- }
1555
- function base64Decode(input) {
1556
- if (globalThis.Buffer) {
1557
- return Buffer.from(input, "base64");
1558
- }
1559
- return Uint8Array.from(
1560
- globalThis.atob(input),
1561
- (c) => c.codePointAt(0)
1562
- );
1563
- }
1564
- function base64Encode(input) {
1565
- if (globalThis.Buffer) {
1566
- return Buffer.from(input).toString("base64");
1567
- }
1568
- return globalThis.btoa(String.fromCodePoint(...input));
1569
- }
1570
- function normalizeKey(key) {
1571
- if (!key) {
1572
- return "";
1573
- }
1574
- return key.split("?")[0]?.replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") || "";
1575
- }
1576
- function joinKeys(...keys2) {
1577
- return normalizeKey(keys2.join(":"));
1578
- }
1579
- function normalizeBaseKey(base) {
1580
- base = normalizeKey(base);
1581
- return base ? base + ":" : "";
1582
- }
1583
- function filterKeyByDepth(key, depth) {
1584
- if (depth === void 0) {
1585
- return true;
1586
- }
1587
- let substrCount = 0;
1588
- let index = key.indexOf(":");
1589
- while (index > -1) {
1590
- substrCount++;
1591
- index = key.indexOf(":", index + 1);
1592
- }
1593
- return substrCount <= depth;
1594
- }
1595
- function filterKeyByBase(key, base) {
1596
- if (base) {
1597
- return key.startsWith(base) && key[key.length - 1] !== "$";
1598
- }
1599
- return key[key.length - 1] !== "$";
1600
- }
1601
-
1602
- // ../node_modules/.pnpm/unstorage@1.17.5_idb-keyval@6.2.2_ioredis@5.10.1/node_modules/unstorage/dist/index.mjs
1603
- function defineDriver(factory) {
1604
- return factory;
1605
- }
1606
- var DRIVER_NAME = "memory";
1607
- var memory = defineDriver(() => {
1608
- const data = /* @__PURE__ */ new Map();
1609
- return {
1610
- name: DRIVER_NAME,
1611
- getInstance: () => data,
1612
- hasItem(key) {
1613
- return data.has(key);
1614
- },
1615
- getItem(key) {
1616
- return data.get(key) ?? null;
1617
- },
1618
- getItemRaw(key) {
1619
- return data.get(key) ?? null;
1620
- },
1621
- setItem(key, value) {
1622
- data.set(key, value);
1623
- },
1624
- setItemRaw(key, value) {
1625
- data.set(key, value);
1626
- },
1627
- removeItem(key) {
1628
- data.delete(key);
1629
- },
1630
- getKeys() {
1631
- return [...data.keys()];
1632
- },
1633
- clear() {
1634
- data.clear();
1635
- },
1636
- dispose() {
1637
- data.clear();
1638
- }
1639
- };
1640
- });
1641
- function createStorage(options = {}) {
1642
- const context = {
1643
- mounts: { "": options.driver || memory() },
1644
- mountpoints: [""],
1645
- watching: false,
1646
- watchListeners: [],
1647
- unwatch: {}
1648
- };
1649
- const getMount = (key) => {
1650
- for (const base of context.mountpoints) {
1651
- if (key.startsWith(base)) {
1652
- return {
1653
- base,
1654
- relativeKey: key.slice(base.length),
1655
- driver: context.mounts[base]
1656
- };
1657
- }
1658
- }
1659
- return {
1660
- base: "",
1661
- relativeKey: key,
1662
- driver: context.mounts[""]
1663
- };
1664
- };
1665
- const getMounts = (base, includeParent) => {
1666
- return context.mountpoints.filter(
1667
- (mountpoint) => mountpoint.startsWith(base) || includeParent && base.startsWith(mountpoint)
1668
- ).map((mountpoint) => ({
1669
- relativeBase: base.length > mountpoint.length ? base.slice(mountpoint.length) : void 0,
1670
- mountpoint,
1671
- driver: context.mounts[mountpoint]
1672
- }));
1673
- };
1674
- const onChange = (event, key) => {
1675
- if (!context.watching) {
1676
- return;
1677
- }
1678
- key = normalizeKey(key);
1679
- for (const listener of context.watchListeners) {
1680
- listener(event, key);
1681
- }
1682
- };
1683
- const startWatch = async () => {
1684
- if (context.watching) {
1685
- return;
1686
- }
1687
- context.watching = true;
1688
- for (const mountpoint in context.mounts) {
1689
- context.unwatch[mountpoint] = await watch(
1690
- context.mounts[mountpoint],
1691
- onChange,
1692
- mountpoint
1693
- );
1694
- }
1695
- };
1696
- const stopWatch = async () => {
1697
- if (!context.watching) {
1698
- return;
1699
- }
1700
- for (const mountpoint in context.unwatch) {
1701
- await context.unwatch[mountpoint]();
1702
- }
1703
- context.unwatch = {};
1704
- context.watching = false;
1705
- };
1706
- const runBatch = (items, commonOptions, cb) => {
1707
- const batches = /* @__PURE__ */ new Map();
1708
- const getBatch = (mount) => {
1709
- let batch = batches.get(mount.base);
1710
- if (!batch) {
1711
- batch = {
1712
- driver: mount.driver,
1713
- base: mount.base,
1714
- items: []
1715
- };
1716
- batches.set(mount.base, batch);
1717
- }
1718
- return batch;
1719
- };
1720
- for (const item of items) {
1721
- const isStringItem = typeof item === "string";
1722
- const key = normalizeKey(isStringItem ? item : item.key);
1723
- const value = isStringItem ? void 0 : item.value;
1724
- const options2 = isStringItem || !item.options ? commonOptions : { ...commonOptions, ...item.options };
1725
- const mount = getMount(key);
1726
- getBatch(mount).items.push({
1727
- key,
1728
- value,
1729
- relativeKey: mount.relativeKey,
1730
- options: options2
1731
- });
1732
- }
1733
- return Promise.all([...batches.values()].map((batch) => cb(batch))).then(
1734
- (r) => r.flat()
1735
- );
1736
- };
1737
- const storage = {
1738
- // Item
1739
- hasItem(key, opts = {}) {
1740
- key = normalizeKey(key);
1741
- const { relativeKey, driver } = getMount(key);
1742
- return asyncCall(driver.hasItem, relativeKey, opts);
1743
- },
1744
- getItem(key, opts = {}) {
1745
- key = normalizeKey(key);
1746
- const { relativeKey, driver } = getMount(key);
1747
- return asyncCall(driver.getItem, relativeKey, opts).then(
1748
- (value) => destr(value)
1749
- );
1750
- },
1751
- getItems(items, commonOptions = {}) {
1752
- return runBatch(items, commonOptions, (batch) => {
1753
- if (batch.driver.getItems) {
1754
- return asyncCall(
1755
- batch.driver.getItems,
1756
- batch.items.map((item) => ({
1757
- key: item.relativeKey,
1758
- options: item.options
1759
- })),
1760
- commonOptions
1761
- ).then(
1762
- (r) => r.map((item) => ({
1763
- key: joinKeys(batch.base, item.key),
1764
- value: destr(item.value)
1765
- }))
1766
- );
1767
- }
1768
- return Promise.all(
1769
- batch.items.map((item) => {
1770
- return asyncCall(
1771
- batch.driver.getItem,
1772
- item.relativeKey,
1773
- item.options
1774
- ).then((value) => ({
1775
- key: item.key,
1776
- value: destr(value)
1777
- }));
1778
- })
1779
- );
1780
- });
1781
- },
1782
- getItemRaw(key, opts = {}) {
1783
- key = normalizeKey(key);
1784
- const { relativeKey, driver } = getMount(key);
1785
- if (driver.getItemRaw) {
1786
- return asyncCall(driver.getItemRaw, relativeKey, opts);
1787
- }
1788
- return asyncCall(driver.getItem, relativeKey, opts).then(
1789
- (value) => deserializeRaw(value)
1790
- );
1791
- },
1792
- async setItem(key, value, opts = {}) {
1793
- if (value === void 0) {
1794
- return storage.removeItem(key);
1795
- }
1796
- key = normalizeKey(key);
1797
- const { relativeKey, driver } = getMount(key);
1798
- if (!driver.setItem) {
1799
- return;
1800
- }
1801
- await asyncCall(driver.setItem, relativeKey, stringify(value), opts);
1802
- if (!driver.watch) {
1803
- onChange("update", key);
1804
- }
1805
- },
1806
- async setItems(items, commonOptions) {
1807
- await runBatch(items, commonOptions, async (batch) => {
1808
- if (batch.driver.setItems) {
1809
- return asyncCall(
1810
- batch.driver.setItems,
1811
- batch.items.map((item) => ({
1812
- key: item.relativeKey,
1813
- value: stringify(item.value),
1814
- options: item.options
1815
- })),
1816
- commonOptions
1817
- );
1818
- }
1819
- if (!batch.driver.setItem) {
1820
- return;
1821
- }
1822
- await Promise.all(
1823
- batch.items.map((item) => {
1824
- return asyncCall(
1825
- batch.driver.setItem,
1826
- item.relativeKey,
1827
- stringify(item.value),
1828
- item.options
1829
- );
1830
- })
1831
- );
1832
- });
1833
- },
1834
- async setItemRaw(key, value, opts = {}) {
1835
- if (value === void 0) {
1836
- return storage.removeItem(key, opts);
1837
- }
1838
- key = normalizeKey(key);
1839
- const { relativeKey, driver } = getMount(key);
1840
- if (driver.setItemRaw) {
1841
- await asyncCall(driver.setItemRaw, relativeKey, value, opts);
1842
- } else if (driver.setItem) {
1843
- await asyncCall(driver.setItem, relativeKey, serializeRaw(value), opts);
1844
- } else {
1845
- return;
1846
- }
1847
- if (!driver.watch) {
1848
- onChange("update", key);
1849
- }
1850
- },
1851
- async removeItem(key, opts = {}) {
1852
- if (typeof opts === "boolean") {
1853
- opts = { removeMeta: opts };
1854
- }
1855
- key = normalizeKey(key);
1856
- const { relativeKey, driver } = getMount(key);
1857
- if (!driver.removeItem) {
1858
- return;
1859
- }
1860
- await asyncCall(driver.removeItem, relativeKey, opts);
1861
- if (opts.removeMeta || opts.removeMata) {
1862
- await asyncCall(driver.removeItem, relativeKey + "$", opts);
1863
- }
1864
- if (!driver.watch) {
1865
- onChange("remove", key);
1866
- }
1867
- },
1868
- // Meta
1869
- async getMeta(key, opts = {}) {
1870
- if (typeof opts === "boolean") {
1871
- opts = { nativeOnly: opts };
1872
- }
1873
- key = normalizeKey(key);
1874
- const { relativeKey, driver } = getMount(key);
1875
- const meta = /* @__PURE__ */ Object.create(null);
1876
- if (driver.getMeta) {
1877
- Object.assign(meta, await asyncCall(driver.getMeta, relativeKey, opts));
1878
- }
1879
- if (!opts.nativeOnly) {
1880
- const value = await asyncCall(
1881
- driver.getItem,
1882
- relativeKey + "$",
1883
- opts
1884
- ).then((value_) => destr(value_));
1885
- if (value && typeof value === "object") {
1886
- if (typeof value.atime === "string") {
1887
- value.atime = new Date(value.atime);
1888
- }
1889
- if (typeof value.mtime === "string") {
1890
- value.mtime = new Date(value.mtime);
1891
- }
1892
- Object.assign(meta, value);
1893
- }
1894
- }
1895
- return meta;
1896
- },
1897
- setMeta(key, value, opts = {}) {
1898
- return this.setItem(key + "$", value, opts);
1899
- },
1900
- removeMeta(key, opts = {}) {
1901
- return this.removeItem(key + "$", opts);
1902
- },
1903
- // Keys
1904
- async getKeys(base, opts = {}) {
1905
- base = normalizeBaseKey(base);
1906
- const mounts = getMounts(base, true);
1907
- let maskedMounts = [];
1908
- const allKeys = [];
1909
- let allMountsSupportMaxDepth = true;
1910
- for (const mount of mounts) {
1911
- if (!mount.driver.flags?.maxDepth) {
1912
- allMountsSupportMaxDepth = false;
1913
- }
1914
- const rawKeys = await asyncCall(
1915
- mount.driver.getKeys,
1916
- mount.relativeBase,
1917
- opts
1918
- );
1919
- for (const key of rawKeys) {
1920
- const fullKey = mount.mountpoint + normalizeKey(key);
1921
- if (!maskedMounts.some((p) => fullKey.startsWith(p))) {
1922
- allKeys.push(fullKey);
1923
- }
1924
- }
1925
- maskedMounts = [
1926
- mount.mountpoint,
1927
- ...maskedMounts.filter((p) => !p.startsWith(mount.mountpoint))
1928
- ];
1929
- }
1930
- const shouldFilterByDepth = opts.maxDepth !== void 0 && !allMountsSupportMaxDepth;
1931
- return allKeys.filter(
1932
- (key) => (!shouldFilterByDepth || filterKeyByDepth(key, opts.maxDepth)) && filterKeyByBase(key, base)
1933
- );
1934
- },
1935
- // Utils
1936
- async clear(base, opts = {}) {
1937
- base = normalizeBaseKey(base);
1938
- await Promise.all(
1939
- getMounts(base, false).map(async (m) => {
1940
- if (m.driver.clear) {
1941
- return asyncCall(m.driver.clear, m.relativeBase, opts);
1942
- }
1943
- if (m.driver.removeItem) {
1944
- const keys2 = await m.driver.getKeys(m.relativeBase || "", opts);
1945
- return Promise.all(
1946
- keys2.map((key) => m.driver.removeItem(key, opts))
1947
- );
1948
- }
1949
- })
1950
- );
1951
- },
1952
- async dispose() {
1953
- await Promise.all(
1954
- Object.values(context.mounts).map((driver) => dispose(driver))
1955
- );
1956
- },
1957
- async watch(callback) {
1958
- await startWatch();
1959
- context.watchListeners.push(callback);
1960
- return async () => {
1961
- context.watchListeners = context.watchListeners.filter(
1962
- (listener) => listener !== callback
1963
- );
1964
- if (context.watchListeners.length === 0) {
1965
- await stopWatch();
1966
- }
1967
- };
1968
- },
1969
- async unwatch() {
1970
- context.watchListeners = [];
1971
- await stopWatch();
1972
- },
1973
- // Mount
1974
- mount(base, driver) {
1975
- base = normalizeBaseKey(base);
1976
- if (base && context.mounts[base]) {
1977
- throw new Error(`already mounted at ${base}`);
1978
- }
1979
- if (base) {
1980
- context.mountpoints.push(base);
1981
- context.mountpoints.sort((a, b) => b.length - a.length);
1982
- }
1983
- context.mounts[base] = driver;
1984
- if (context.watching) {
1985
- Promise.resolve(watch(driver, onChange, base)).then((unwatcher) => {
1986
- context.unwatch[base] = unwatcher;
1987
- }).catch(console.error);
1988
- }
1989
- return storage;
1990
- },
1991
- async unmount(base, _dispose = true) {
1992
- base = normalizeBaseKey(base);
1993
- if (!base || !context.mounts[base]) {
1994
- return;
1995
- }
1996
- if (context.watching && base in context.unwatch) {
1997
- context.unwatch[base]?.();
1998
- delete context.unwatch[base];
1999
- }
2000
- if (_dispose) {
2001
- await dispose(context.mounts[base]);
2002
- }
2003
- context.mountpoints = context.mountpoints.filter((key) => key !== base);
2004
- delete context.mounts[base];
2005
- },
2006
- getMount(key = "") {
2007
- key = normalizeKey(key) + ":";
2008
- const m = getMount(key);
2009
- return {
2010
- driver: m.driver,
2011
- base: m.base
2012
- };
2013
- },
2014
- getMounts(base = "", opts = {}) {
2015
- base = normalizeKey(base);
2016
- const mounts = getMounts(base, opts.parents);
2017
- return mounts.map((m) => ({
2018
- driver: m.driver,
2019
- base: m.mountpoint
2020
- }));
2021
- },
2022
- // Aliases
2023
- keys: (base, opts = {}) => storage.getKeys(base, opts),
2024
- get: (key, opts = {}) => storage.getItem(key, opts),
2025
- set: (key, value, opts = {}) => storage.setItem(key, value, opts),
2026
- has: (key, opts = {}) => storage.hasItem(key, opts),
2027
- del: (key, opts = {}) => storage.removeItem(key, opts),
2028
- remove: (key, opts = {}) => storage.removeItem(key, opts)
2029
- };
2030
- return storage;
2031
- }
2032
- function watch(driver, onChange, base) {
2033
- return driver.watch ? driver.watch((event, key) => onChange(event, base + key)) : () => {
2034
- };
2035
- }
2036
- async function dispose(driver) {
2037
- if (typeof driver.dispose === "function") {
2038
- await asyncCall(driver.dispose);
2039
- }
2040
- }
2041
-
2042
- // ../node_modules/.pnpm/unstorage@1.17.5_idb-keyval@6.2.2_ioredis@5.10.1/node_modules/unstorage/drivers/utils/index.mjs
2043
- function defineDriver2(factory) {
2044
- return factory;
2045
- }
2046
- var DRIVER_NAME2 = "idb-keyval";
2047
- var indexedb_default = defineDriver2((opts = {}) => {
2048
- const base = opts.base && opts.base.length > 0 ? `${opts.base}:` : "";
2049
- const makeKey = (key) => base + key;
2050
- let customStore;
2051
- if (opts.dbName && opts.storeName) {
2052
- customStore = createStore(opts.dbName, opts.storeName);
2053
- }
2054
- return {
2055
- name: DRIVER_NAME2,
2056
- options: opts,
2057
- async hasItem(key) {
2058
- const item = await get(makeKey(key), customStore);
2059
- return item === void 0 ? false : true;
2060
- },
2061
- async getItem(key) {
2062
- const item = await get(makeKey(key), customStore);
2063
- return item ?? null;
2064
- },
2065
- async getItemRaw(key) {
2066
- const item = await get(makeKey(key), customStore);
2067
- return item ?? null;
2068
- },
2069
- setItem(key, value) {
2070
- return set(makeKey(key), value, customStore);
2071
- },
2072
- setItemRaw(key, value) {
2073
- return set(makeKey(key), value, customStore);
2074
- },
2075
- removeItem(key) {
2076
- return del(makeKey(key), customStore);
2077
- },
2078
- getKeys() {
2079
- return keys(customStore);
2080
- },
2081
- clear() {
2082
- return clear(customStore);
2083
- }
2084
- };
2085
- });
2086
-
2087
- // src/lib/autoform-store.ts
2088
1436
  var storageInstance = null;
2089
1437
  var storageReady = false;
2090
1438
  var getStorage = async () => {
@@ -2092,7 +1440,7 @@ var getStorage = async () => {
2092
1440
  return storageInstance;
2093
1441
  }
2094
1442
  storageInstance = createStorage({
2095
- driver: indexedb_default({
1443
+ driver: indexedbDriver({
2096
1444
  dbName: "kyro-autosave",
2097
1445
  storeName: "autosave"
2098
1446
  })
@@ -2143,7 +1491,7 @@ var createAutoFormStorage = () => {
2143
1491
  };
2144
1492
  var useAutoFormStore = create()(
2145
1493
  persist(
2146
- (set2, get2) => ({
1494
+ (set, get) => ({
2147
1495
  // Initial persisted state
2148
1496
  formData: {},
2149
1497
  lastSavedData: {},
@@ -2175,7 +1523,7 @@ var useAutoFormStore = create()(
2175
1523
  if (field3 === "blocks") {
2176
1524
  console.log("autoform setField blocks: value=", value);
2177
1525
  }
2178
- set2((state) => ({
1526
+ set((state) => ({
2179
1527
  formData: {
2180
1528
  ...state.formData,
2181
1529
  [field3]: value
@@ -2183,85 +1531,85 @@ var useAutoFormStore = create()(
2183
1531
  }));
2184
1532
  },
2185
1533
  setFormData: (data) => {
2186
- set2({ formData: data });
1534
+ set({ formData: data });
2187
1535
  },
2188
1536
  setNestedField: (path2, value) => {
2189
- set2((state) => {
2190
- const keys2 = path2.split(".");
1537
+ set((state) => {
1538
+ const keys = path2.split(".");
2191
1539
  const newFormData = { ...state.formData };
2192
1540
  let current = newFormData;
2193
- for (let i = 0; i < keys2.length - 1; i++) {
2194
- if (current[keys2[i]] === void 0) {
2195
- current[keys2[i]] = {};
1541
+ for (let i = 0; i < keys.length - 1; i++) {
1542
+ if (current[keys[i]] === void 0) {
1543
+ current[keys[i]] = {};
2196
1544
  }
2197
- current[keys2[i]] = { ...current[keys2[i]] };
2198
- current = current[keys2[i]];
1545
+ current[keys[i]] = { ...current[keys[i]] };
1546
+ current = current[keys[i]];
2199
1547
  }
2200
- current[keys2[keys2.length - 1]] = value;
1548
+ current[keys[keys.length - 1]] = value;
2201
1549
  return { formData: newFormData };
2202
1550
  });
2203
1551
  },
2204
1552
  // UI state actions
2205
- setActiveTab: (tab) => set2({ activeTab: tab }),
2206
- setIsSlugLocked: (locked) => set2((state) => ({
1553
+ setActiveTab: (tab) => set({ activeTab: tab }),
1554
+ setIsSlugLocked: (locked) => set((state) => ({
2207
1555
  isSlugLocked: typeof locked === "function" ? locked(state.isSlugLocked) : locked
2208
1556
  })),
2209
- setView: (view) => set2({ view }),
2210
- setIsDropdownOpen: (open) => set2((state) => ({
1557
+ setView: (view) => set({ view }),
1558
+ setIsDropdownOpen: (open) => set((state) => ({
2211
1559
  isDropdownOpen: typeof open === "function" ? open(state.isDropdownOpen) : open
2212
1560
  })),
2213
- setVersions: (versions) => set2({ versions }),
2214
- setLoadingVersions: (loading) => set2({ loadingVersions: loading }),
2215
- setShowPreview: (show) => set2((state) => ({
1561
+ setVersions: (versions) => set({ versions }),
1562
+ setLoadingVersions: (loading) => set({ loadingVersions: loading }),
1563
+ setShowPreview: (show) => set((state) => ({
2216
1564
  showPreview: typeof show === "function" ? show(state.showPreview) : show
2217
1565
  })),
2218
- setIsMenuOpen: (open) => set2((state) => ({
1566
+ setIsMenuOpen: (open) => set((state) => ({
2219
1567
  isMenuOpen: typeof open === "function" ? open(state.isMenuOpen) : open
2220
1568
  })),
2221
- setHasUnsavedChanges: (hasChanges) => set2({ hasUnsavedChanges: hasChanges }),
2222
- setLoadingFields: (fields2) => set2((state) => ({
1569
+ setHasUnsavedChanges: (hasChanges) => set({ hasUnsavedChanges: hasChanges }),
1570
+ setLoadingFields: (fields2) => set((state) => ({
2223
1571
  loadingFields: typeof fields2 === "function" ? fields2(state.loadingFields) : fields2
2224
1572
  })),
2225
- updateLoadingField: (field3, loading) => set2((state) => ({
1573
+ updateLoadingField: (field3, loading) => set((state) => ({
2226
1574
  loadingFields: { ...state.loadingFields, [field3]: loading }
2227
1575
  })),
2228
- setCompareMode: (mode) => set2({ compareMode: mode }),
2229
- setCompareSelected: (selected) => set2((state) => ({
1576
+ setCompareMode: (mode) => set({ compareMode: mode }),
1577
+ setCompareSelected: (selected) => set((state) => ({
2230
1578
  compareSelected: typeof selected === "function" ? selected(state.compareSelected) : selected
2231
1579
  })),
2232
- setCompareDiffs: (diffs) => set2({ compareDiffs: diffs }),
2233
- setLoadingDiffs: (loading) => set2({ loadingDiffs: loading }),
2234
- setIsAutoSaving: (saving) => set2({ isAutoSaving: saving }),
2235
- setAutoSaveStatus: (status) => set2({ autoSaveStatus: status }),
2236
- setSidebarCollapsed: (collapsed) => set2({ sidebarCollapsed: collapsed }),
1580
+ setCompareDiffs: (diffs) => set({ compareDiffs: diffs }),
1581
+ setLoadingDiffs: (loading) => set({ loadingDiffs: loading }),
1582
+ setIsAutoSaving: (saving) => set({ isAutoSaving: saving }),
1583
+ setAutoSaveStatus: (status) => set({ autoSaveStatus: status }),
1584
+ setSidebarCollapsed: (collapsed) => set({ sidebarCollapsed: collapsed }),
2237
1585
  // Auto-save actions
2238
- setAutoSaveSkip: (skip) => set2({ autoSaveSkip: skip }),
2239
- setLastAutoSaveTime: (time) => set2({ lastAutoSaveTime: time }),
1586
+ setAutoSaveSkip: (skip) => set({ autoSaveSkip: skip }),
1587
+ setLastAutoSaveTime: (time) => set({ lastAutoSaveTime: time }),
2240
1588
  startAutoSaveTimer: (callback, delay) => {
2241
- const { autoSaveTimer } = get2();
1589
+ const { autoSaveTimer } = get();
2242
1590
  if (autoSaveTimer) {
2243
1591
  clearTimeout(autoSaveTimer);
2244
1592
  }
2245
1593
  const timer = setTimeout(callback, delay);
2246
- set2({ autoSaveTimer: timer });
1594
+ set({ autoSaveTimer: timer });
2247
1595
  },
2248
1596
  clearAutoSaveTimer: () => {
2249
- const { autoSaveTimer } = get2();
1597
+ const { autoSaveTimer } = get();
2250
1598
  if (autoSaveTimer) {
2251
1599
  clearTimeout(autoSaveTimer);
2252
- set2({ autoSaveTimer: null });
1600
+ set({ autoSaveTimer: null });
2253
1601
  }
2254
1602
  },
2255
1603
  // Data management
2256
1604
  markSaved: () => {
2257
- const { formData } = get2();
2258
- set2({ lastSavedData: formData, hasUnsavedChanges: false });
1605
+ const { formData } = get();
1606
+ set({ lastSavedData: formData, hasUnsavedChanges: false });
2259
1607
  },
2260
1608
  setLastSavedData: (data) => {
2261
- set2({ lastSavedData: data });
1609
+ set({ lastSavedData: data });
2262
1610
  },
2263
1611
  resetForm: () => {
2264
- set2({
1612
+ set({
2265
1613
  formData: {},
2266
1614
  lastSavedData: {},
2267
1615
  hasUnsavedChanges: false,
@@ -2269,14 +1617,14 @@ var useAutoFormStore = create()(
2269
1617
  });
2270
1618
  },
2271
1619
  loadDocument: (data, lastSaved) => {
2272
- set2({
1620
+ set({
2273
1621
  formData: data,
2274
1622
  lastSavedData: lastSaved || data,
2275
1623
  hasUnsavedChanges: false
2276
1624
  });
2277
1625
  },
2278
1626
  updateTabData: (tabName, newTabData) => {
2279
- const { formData } = get2();
1627
+ const { formData } = get();
2280
1628
  const tabData = formData[tabName] || {};
2281
1629
  let updatedTab;
2282
1630
  if (Array.isArray(newTabData)) {
@@ -2286,7 +1634,7 @@ var useAutoFormStore = create()(
2286
1634
  } else {
2287
1635
  updatedTab = newTabData;
2288
1636
  }
2289
- set2((state) => ({
1637
+ set((state) => ({
2290
1638
  formData: {
2291
1639
  ...state.formData,
2292
1640
  [tabName]: updatedTab
@@ -2295,12 +1643,12 @@ var useAutoFormStore = create()(
2295
1643
  },
2296
1644
  // Computed values
2297
1645
  getField: (field3) => {
2298
- return get2().formData[field3];
1646
+ return get().formData[field3];
2299
1647
  },
2300
1648
  getNestedField: (path2) => {
2301
- const keys2 = path2.split(".");
2302
- let current = get2().formData;
2303
- for (const key of keys2) {
1649
+ const keys = path2.split(".");
1650
+ let current = get().formData;
1651
+ for (const key of keys) {
2304
1652
  if (current === void 0 || current === null)
2305
1653
  return void 0;
2306
1654
  current = current[key];
@@ -2308,17 +1656,17 @@ var useAutoFormStore = create()(
2308
1656
  return current;
2309
1657
  },
2310
1658
  getHasChanges: () => {
2311
- const { formData, lastSavedData } = get2();
1659
+ const { formData, lastSavedData } = get();
2312
1660
  return JSON.stringify(formData) !== JSON.stringify(lastSavedData);
2313
1661
  },
2314
- setDraftCache: (documentKey, draft) => set2((state) => ({
1662
+ setDraftCache: (documentKey, draft) => set((state) => ({
2315
1663
  draftCache: {
2316
1664
  ...state.draftCache,
2317
1665
  [documentKey]: draft
2318
1666
  }
2319
1667
  })),
2320
- getDraftCache: (documentKey) => get2().draftCache[documentKey] || null,
2321
- clearDraftCache: (documentKey) => set2((state) => {
1668
+ getDraftCache: (documentKey) => get().draftCache[documentKey] || null,
1669
+ clearDraftCache: (documentKey) => set((state) => {
2322
1670
  const next = { ...state.draftCache };
2323
1671
  delete next[documentKey];
2324
1672
  return { draftCache: next };
@@ -2659,10 +2007,27 @@ function useAutoFormState({
2659
2007
  onActionSuccess,
2660
2008
  setFormData
2661
2009
  ]);
2010
+ function findFieldDeep(fields2, name) {
2011
+ for (const f of fields2) {
2012
+ if (f.name === name && f.admin?.autoGenerate === "title")
2013
+ return f;
2014
+ if (f.type === "tabs" && "tabs" in f) {
2015
+ for (const tab of f.tabs) {
2016
+ const found = findFieldDeep(tab.fields, name);
2017
+ if (found)
2018
+ return found;
2019
+ }
2020
+ }
2021
+ if ((f.type === "group" || f.type === "collapsible") && "fields" in f) {
2022
+ const found = findFieldDeep(f.fields, name);
2023
+ if (found)
2024
+ return found;
2025
+ }
2026
+ }
2027
+ return void 0;
2028
+ }
2662
2029
  useEffect(() => {
2663
- const metaTitleField = config.fields.find(
2664
- (f) => f.name === "metaTitle" && f.admin?.autoGenerate === "title"
2665
- );
2030
+ const metaTitleField = findFieldDeep(config.fields, "metaTitle");
2666
2031
  if (!metaTitleField)
2667
2032
  return;
2668
2033
  let titleValue = "";
@@ -3487,7 +2852,7 @@ function MediaPickerContent({
3487
2852
  }
3488
2853
  );
3489
2854
  }
3490
- var EditorLazy = lazy(() => import('./EditorClient-XEUOVAAC.js'));
2855
+ var EditorLazy = lazy(() => import('./EditorClient-T5PASFNR.js'));
3491
2856
  function toPortableTextArray(value) {
3492
2857
  if (Array.isArray(value)) {
3493
2858
  if (value.length > 0 && value[0] && typeof value[0] === "object" && "_type" in value[0]) {
@@ -4703,30 +4068,30 @@ function RelationshipField({
4703
4068
  var RelationshipField_default = RelationshipField;
4704
4069
  var BlocksContext = createContext(null);
4705
4070
  function createBlocksStore() {
4706
- return createStore$1((set2, get2) => ({
4071
+ return createStore((set, get) => ({
4707
4072
  blocks: [],
4708
4073
  setBlocks: (blocks2) => {
4709
4074
  const ensuredBlocks = ensureIds(blocks2 || []);
4710
- set2({ blocks: ensuredBlocks });
4075
+ set({ blocks: ensuredBlocks });
4711
4076
  },
4712
4077
  onBlocksChange: null,
4713
- setOnBlocksChange: (cb) => set2({ onBlocksChange: cb }),
4078
+ setOnBlocksChange: (cb) => set({ onBlocksChange: cb }),
4714
4079
  addBlock: (type, index) => {
4715
4080
  const newBlock = createNewBlock(type);
4716
- const { blocks: blocks2 } = get2();
4081
+ const { blocks: blocks2 } = get();
4717
4082
  const newBlocks = [...blocks2];
4718
4083
  if (index !== void 0) {
4719
4084
  newBlocks.splice(index, 0, newBlock);
4720
4085
  } else {
4721
4086
  newBlocks.push(newBlock);
4722
4087
  }
4723
- set2({ blocks: newBlocks });
4724
- const { onBlocksChange } = get2();
4088
+ set({ blocks: newBlocks });
4089
+ const { onBlocksChange } = get();
4725
4090
  if (onBlocksChange)
4726
4091
  onBlocksChange();
4727
4092
  },
4728
4093
  updateBlock: (id, data) => {
4729
- const { blocks: blocks2 } = get2();
4094
+ const { blocks: blocks2 } = get();
4730
4095
  const newBlocks = traverseBlocks(blocks2, (blocksList) => {
4731
4096
  const index = blocksList.findIndex((b) => b.id === id);
4732
4097
  if (index !== -1) {
@@ -4737,8 +4102,8 @@ function createBlocksStore() {
4737
4102
  return { newList: blocksList, found: false };
4738
4103
  });
4739
4104
  if (newBlocks !== blocks2) {
4740
- set2({ blocks: newBlocks });
4741
- const { onBlocksChange } = get2();
4105
+ set({ blocks: newBlocks });
4106
+ const { onBlocksChange } = get();
4742
4107
  if (onBlocksChange)
4743
4108
  onBlocksChange();
4744
4109
  }
@@ -4746,7 +4111,7 @@ function createBlocksStore() {
4746
4111
  removeBlock: (id) => {
4747
4112
  if (!id)
4748
4113
  return;
4749
- const { blocks: blocks2 } = get2();
4114
+ const { blocks: blocks2 } = get();
4750
4115
  const newBlocks = traverseBlocks(blocks2, (blocksList) => {
4751
4116
  const filtered = blocksList.filter((b) => b.id !== id);
4752
4117
  if (filtered.length !== blocksList.length) {
@@ -4755,14 +4120,14 @@ function createBlocksStore() {
4755
4120
  return { newList: blocksList, found: false };
4756
4121
  });
4757
4122
  if (newBlocks !== blocks2) {
4758
- set2({ blocks: newBlocks });
4759
- const { onBlocksChange } = get2();
4123
+ set({ blocks: newBlocks });
4124
+ const { onBlocksChange } = get();
4760
4125
  if (onBlocksChange)
4761
4126
  onBlocksChange();
4762
4127
  }
4763
4128
  },
4764
4129
  moveBlock: (id, direction) => {
4765
- const { blocks: blocks2 } = get2();
4130
+ const { blocks: blocks2 } = get();
4766
4131
  const newBlocks = traverseBlocks(blocks2, (blocksList) => {
4767
4132
  const index = blocksList.findIndex((b) => b.id === id);
4768
4133
  if (index !== -1) {
@@ -4779,8 +4144,8 @@ function createBlocksStore() {
4779
4144
  return { newList: blocksList, found: false };
4780
4145
  });
4781
4146
  if (newBlocks !== blocks2) {
4782
- set2({ blocks: newBlocks });
4783
- const { onBlocksChange } = get2();
4147
+ set({ blocks: newBlocks });
4148
+ const { onBlocksChange } = get();
4784
4149
  if (onBlocksChange)
4785
4150
  onBlocksChange();
4786
4151
  }
@@ -7845,12 +7210,12 @@ var SortableBlockComponent = ({
7845
7210
  attributes,
7846
7211
  listeners,
7847
7212
  setNodeRef,
7848
- transform,
7213
+ transform: transform2,
7849
7214
  transition,
7850
7215
  isDragging
7851
7216
  } = useSortable({ id: block3.id });
7852
7217
  const style = {
7853
- transform: CSS.Transform.toString(transform),
7218
+ transform: CSS.Transform.toString(transform2),
7854
7219
  transition,
7855
7220
  zIndex: isDragging ? 10 : 1,
7856
7221
  opacity: isDragging ? 0.8 : 1
@@ -9772,6 +9137,28 @@ function DropdownItem({
9772
9137
  function DropdownSeparator() {
9773
9138
  return /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-[var(--kyro-border)] opacity-50" });
9774
9139
  }
9140
+ function Spinner({ size = "md", className = "" }) {
9141
+ return /* @__PURE__ */ jsx(
9142
+ "svg",
9143
+ {
9144
+ className: `kyro-spinner kyro-spinner-${size} ${className}`,
9145
+ viewBox: "0 0 24 24",
9146
+ fill: "none",
9147
+ children: /* @__PURE__ */ jsx(
9148
+ "circle",
9149
+ {
9150
+ cx: "12",
9151
+ cy: "12",
9152
+ r: "10",
9153
+ stroke: "currentColor",
9154
+ strokeWidth: "3",
9155
+ strokeLinecap: "round",
9156
+ strokeDasharray: "40 20"
9157
+ }
9158
+ )
9159
+ }
9160
+ );
9161
+ }
9775
9162
  function ActionBar({
9776
9163
  status,
9777
9164
  saveStatus,
@@ -10178,7 +9565,7 @@ function CountBadge({ count, max = 99 }) {
10178
9565
  function DetailView({
10179
9566
  config,
10180
9567
  collection,
10181
- global,
9568
+ global: global2,
10182
9569
  documentId,
10183
9570
  onBack,
10184
9571
  onSave,
@@ -10199,9 +9586,9 @@ function DetailView({
10199
9586
  const [updatedAt, setUpdatedAt] = useState(null);
10200
9587
  const [publishedAt, setPublishedAt] = useState(null);
10201
9588
  const [justSaved, setJustSaved] = useState(false);
10202
- const fields2 = global?.fields || collection?.fields || [];
10203
- const label = global?.label || collection?.label || "Document";
10204
- const slug = global?.slug || collection?.slug || "";
9589
+ const fields2 = global2?.fields || collection?.fields || [];
9590
+ const label = global2?.label || collection?.label || "Document";
9591
+ const slug = global2?.slug || collection?.slug || "";
10205
9592
  const hasChanges = JSON.stringify(data) !== JSON.stringify(originalData);
10206
9593
  useEffect(() => {
10207
9594
  if (hasChanges && status === "published") {
@@ -10344,7 +9731,13 @@ function DetailView({
10344
9731
  });
10345
9732
  };
10346
9733
  if (loading) {
10347
- return /* @__PURE__ */ jsx("div", { className: "kyro-detail", children: /* @__PURE__ */ jsx("div", { className: "kyro-loading", children: /* @__PURE__ */ jsx(Spinner, {}) }) });
9734
+ return /* @__PURE__ */ jsx("div", { className: "kyro-detail", children: /* @__PURE__ */ jsxs("div", { className: "space-y-6 p-4", children: [
9735
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
9736
+ /* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-1/3" }),
9737
+ /* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-2/3" })
9738
+ ] }),
9739
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsx(Shimmer, { variant: "rect", count: 4 }) })
9740
+ ] }) });
10348
9741
  }
10349
9742
  const isSingleLayout = mode === "global" || collection?.admin?.layout === "single";
10350
9743
  return /* @__PURE__ */ jsxs("div", { className: "kyro-detail", children: [
@@ -10848,7 +10241,7 @@ function Dashboard({ collections: collections2, onNavigate, user }) {
10848
10241
  children: [
10849
10242
  /* @__PURE__ */ jsxs("div", { children: [
10850
10243
  /* @__PURE__ */ jsx("p", { className: "text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1", children: stat.label }),
10851
- /* @__PURE__ */ jsx("h3", { className: "text-3xl font-bold tracking-tighter", children: loading ? "..." : stat.value })
10244
+ /* @__PURE__ */ jsx("h3", { className: "text-3xl font-bold tracking-tighter", children: loading ? /* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-16" }) : stat.value })
10852
10245
  ] }),
10853
10246
  /* @__PURE__ */ jsx(
10854
10247
  "div",
@@ -11553,7 +10946,7 @@ function ConfirmModal({
11553
10946
  }
11554
10947
  var API_BASE2 = typeof __KYRO_API_PATH__ !== "undefined" ? __KYRO_API_PATH__ : "/api";
11555
10948
  function DeveloperCenter({ collections: collections2 }) {
11556
- const [keys2, setKeys] = useState([]);
10949
+ const [keys, setKeys] = useState([]);
11557
10950
  useState(false);
11558
10951
  const [showKey, setShowKey] = useState(null);
11559
10952
  const [testEndpoint, setTestEndpoint] = useState("");
@@ -11644,10 +11037,10 @@ function DeveloperCenter({ collections: collections2 }) {
11644
11037
  /* @__PURE__ */ jsx("div", { className: "w-1 h-4 bg-[var(--kyro-primary)] rounded-full" }),
11645
11038
  /* @__PURE__ */ jsx("h2", { className: "text-sm font-medium tracking-[0.2em] opacity-40 uppercase", children: "Access Credentials" })
11646
11039
  ] }),
11647
- /* @__PURE__ */ jsx("div", { className: "space-y-4", children: keys2.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30", children: [
11040
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: keys.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30", children: [
11648
11041
  /* @__PURE__ */ jsx(LuLock, { className: "w-10 h-10 mx-auto mb-4 opacity-20" }),
11649
11042
  /* @__PURE__ */ jsx("p", { className: "text-sm text-[var(--kyro-text-secondary)] opacity-50", children: "No API keys found. Generate one to get started." })
11650
- ] }) : keys2.map((key) => /* @__PURE__ */ jsx(
11043
+ ] }) : keys.map((key) => /* @__PURE__ */ jsx(
11651
11044
  "div",
11652
11045
  {
11653
11046
  className: "group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",
@@ -12589,9 +11982,8 @@ function MediaGallery({
12589
11982
  {}
12590
11983
  );
12591
11984
  const [showNewFolderModal, setShowNewFolderModal] = useState(false);
12592
- const [storageConfigured, setStorageConfigured] = useState(
12593
- null
12594
- );
11985
+ const [storageConfigured, setStorageConfigured] = useState(null);
11986
+ const [storageChecked, setStorageChecked] = useState(false);
12595
11987
  const [showStorageConfigModal, setShowStorageConfigModal] = useState(false);
12596
11988
  const [page, setPage] = useState(1);
12597
11989
  const [total, setTotal] = useState(0);
@@ -12649,6 +12041,12 @@ function MediaGallery({
12649
12041
  useEffect(() => {
12650
12042
  checkStorage();
12651
12043
  }, [checkStorage]);
12044
+ useEffect(() => {
12045
+ if (storageConfigured === false && !storageChecked) {
12046
+ setStorageChecked(true);
12047
+ setShowStorageConfigModal(true);
12048
+ }
12049
+ }, [storageConfigured, storageChecked]);
12652
12050
  useEffect(() => {
12653
12051
  loadMedia();
12654
12052
  }, [loadMedia]);
@@ -12901,7 +12299,7 @@ function MediaGallery({
12901
12299
  {
12902
12300
  onClick: () => setView("list"),
12903
12301
  className: `p-2 rounded-lg transition-all ${view === "list" ? "bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]" : "text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,
12904
- children: /* @__PURE__ */ jsx(LuFile, { className: "w-4 h-4" })
12302
+ children: /* @__PURE__ */ jsx(LuFile2, { className: "w-4 h-4" })
12905
12303
  }
12906
12304
  )
12907
12305
  ] }),
@@ -12999,7 +12397,7 @@ function MediaGallery({
12999
12397
  ] })
13000
12398
  ] }) }),
13001
12399
  /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col min-h-0 bg-[var(--kyro-bg)]", children: [
13002
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto py-8 px-4 custom-scrollbar", children: loading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-64", children: /* @__PURE__ */ jsx(Spinner, {}) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-32 text-center", children: [
12400
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto py-8 px-4 custom-scrollbar", children: loading ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5", children: /* @__PURE__ */ jsx(Shimmer, { variant: "media-card", count: 12 }) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-32 text-center", children: [
13003
12401
  /* @__PURE__ */ jsx("div", { className: "w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500", children: /* @__PURE__ */ jsx(LuGrid3X3, { className: "w-10 h-10 text-[var(--kyro-text-muted)] opacity-30" }) }),
13004
12402
  /* @__PURE__ */ jsx("h3", { className: "text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight", children: "No assets found" }),
13005
12403
  /* @__PURE__ */ jsx("p", { className: "text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed", children: "Upload your first file or create a folder to organize your media assets." }),
@@ -13030,7 +12428,7 @@ function MediaGallery({
13030
12428
  loading: "lazy"
13031
12429
  }
13032
12430
  ) : /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex flex-col items-center justify-center p-6 gap-4", children: [
13033
- /* @__PURE__ */ jsx("div", { className: "p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500", children: item.type === "video" ? /* @__PURE__ */ jsx(LuFilm, { className: "w-8 h-8" }) : item.type === "audio" ? /* @__PURE__ */ jsx(LuMusic, { className: "w-8 h-8" }) : item.type === "document" ? /* @__PURE__ */ jsx(LuFileText, { className: "w-8 h-8" }) : item.type === "archive" ? /* @__PURE__ */ jsx(LuArchive, { className: "w-8 h-8" }) : /* @__PURE__ */ jsx(LuFile, { className: "w-8 h-8" }) }),
12431
+ /* @__PURE__ */ jsx("div", { className: "p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500", children: item.type === "video" ? /* @__PURE__ */ jsx(LuFilm, { className: "w-8 h-8" }) : item.type === "audio" ? /* @__PURE__ */ jsx(LuMusic, { className: "w-8 h-8" }) : item.type === "document" ? /* @__PURE__ */ jsx(LuFileText, { className: "w-8 h-8" }) : item.type === "archive" ? /* @__PURE__ */ jsx(LuArchive, { className: "w-8 h-8" }) : /* @__PURE__ */ jsx(LuFile2, { className: "w-8 h-8" }) }),
13034
12432
  /* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2", children: item.title })
13035
12433
  ] }),
13036
12434
  /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
@@ -13134,7 +12532,7 @@ function MediaGallery({
13134
12532
  alt: "",
13135
12533
  className: "w-full h-full object-cover"
13136
12534
  }
13137
- ) : /* @__PURE__ */ jsx(LuFile, { className: "w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50" }) }),
12535
+ ) : /* @__PURE__ */ jsx(LuFile2, { className: "w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50" }) }),
13138
12536
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
13139
12537
  /* @__PURE__ */ jsx("span", { className: "font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]", children: item.title || item.filename }),
13140
12538
  /* @__PURE__ */ jsx("span", { className: "text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate", children: item.filename })
@@ -13218,7 +12616,7 @@ function MediaGallery({
13218
12616
  ] }, name)) })
13219
12617
  ] }) }),
13220
12618
  selectedIds.size > 0 && /* @__PURE__ */ jsxs("div", { className: "fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-full shadow-2xl px-2 py-2 flex items-center gap-12 animate-in slide-in-from-bottom-12 duration-700 ring-1 ring-white/10 backdrop-blur-xl", children: [
13221
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-5 border-r border-[var(--kyro-border)] pr-12", children: [
12619
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-5 border-r border-[var(--kyro-border)] ", children: [
13222
12620
  /* @__PURE__ */ jsx("div", { className: "w-12 h-12 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center text-lg font-bold shadow-inner", children: selectedIds.size }),
13223
12621
  /* @__PURE__ */ jsxs("div", { children: [
13224
12622
  /* @__PURE__ */ jsx("p", { className: "text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]", children: "Selected" }),
@@ -13278,7 +12676,7 @@ function MediaGallery({
13278
12676
  className: "w-full h-full"
13279
12677
  }
13280
12678
  ) : /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex flex-col items-center justify-center p-12 gap-6", children: [
13281
- /* @__PURE__ */ jsx("div", { className: "w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center", children: /* @__PURE__ */ jsx(LuFile, { className: "w-10 h-10 text-[var(--kyro-text-secondary)]" }) }),
12679
+ /* @__PURE__ */ jsx("div", { className: "w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center", children: /* @__PURE__ */ jsx(LuFile2, { className: "w-10 h-10 text-[var(--kyro-text-secondary)]" }) }),
13282
12680
  /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-xs font-bold", children: panelItem.mimeType })
13283
12681
  ] }),
13284
12682
  /* @__PURE__ */ jsx("div", { className: "absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ jsx(
@@ -13448,7 +12846,7 @@ function MediaGallery({
13448
12846
  className: "max-h-full max-w-full rounded-lg shadow-2xl"
13449
12847
  }
13450
12848
  ) : /* @__PURE__ */ jsxs("div", { className: "text-white text-center", children: [
13451
- /* @__PURE__ */ jsx(LuFile, { className: "w-24 h-24 mx-auto mb-6 opacity-20" }),
12849
+ /* @__PURE__ */ jsx(LuFile2, { className: "w-24 h-24 mx-auto mb-6 opacity-20" }),
13452
12850
  /* @__PURE__ */ jsx("p", { className: "text-xl font-bold opacity-50", children: "Preview not available for this file type" })
13453
12851
  ] }) })
13454
12852
  ] }),
@@ -14686,31 +14084,88 @@ function kyroAdmin(options = {}) {
14686
14084
  return {
14687
14085
  name: "@kyro-cms/admin",
14688
14086
  hooks: {
14689
- "astro:config:setup": ({ config, updateConfig, injectRoute, logger }) => {
14087
+ "astro:config:setup": async ({ config: config$1, updateConfig, injectRoute, logger }) => {
14690
14088
  logger.info(`Kyro Admin mounted at ${basePath} (API: ${apiPath2})`);
14691
14089
  const fallbackConfig = path.resolve(
14692
14090
  new URL(".", import.meta.url).pathname,
14693
14091
  "lib/default-kyro-config.ts"
14694
14092
  );
14695
- const rootConfig = path.resolve(config.root.pathname, "..", configPath);
14696
- const localConfig = path.resolve(config.root.pathname, configPath);
14093
+ const rootConfig = path.resolve(config$1.root.pathname, "..", configPath);
14094
+ const localConfig = path.resolve(config$1.root.pathname, configPath);
14697
14095
  const resolvedConfig = fs.existsSync(rootConfig) ? rootConfig : fs.existsSync(localConfig) ? localConfig : fallbackConfig;
14698
14096
  if (resolvedConfig !== fallbackConfig) {
14699
14097
  logger.info(`Loaded config from ${resolvedConfig}`);
14700
14098
  } else {
14701
14099
  logger.warn(`Config file not found. Using defaults.`);
14702
14100
  }
14703
- if (apiPath2) {
14704
- const apiHandlerPath = path.resolve(
14705
- config.root.pathname,
14706
- "..",
14707
- "src/api-handler.ts"
14708
- );
14709
- injectRoute({
14710
- pattern: `${apiPath2}/[...path]`,
14711
- entrypoint: apiHandlerPath
14101
+ let tmpFile = "";
14102
+ try {
14103
+ const envPath = path.join(path.dirname(resolvedConfig), ".env");
14104
+ if (fs.existsSync(envPath)) {
14105
+ config({ path: envPath });
14106
+ }
14107
+ const configContent = fs.readFileSync(resolvedConfig, "utf8");
14108
+ const result = await transform(configContent, {
14109
+ loader: "ts",
14110
+ format: "esm",
14111
+ target: "es2022",
14112
+ sourcemap: false
14712
14113
  });
14114
+ tmpFile = resolvedConfig.replace(/\.ts$/, ".admin.mjs");
14115
+ fs.writeFileSync(tmpFile, result.code, "utf8");
14116
+ const entryFile = tmpFile.replace(/\.admin\.mjs$/, ".admin-entry.mjs");
14117
+ const resultFile = tmpFile.replace(/\.admin\.mjs$/, ".admin-result.json");
14118
+ fs.writeFileSync(entryFile, `
14119
+ import cfg from './${path.basename(tmpFile)}';
14120
+ import fs from 'fs';
14121
+ const data = { collections: cfg.default?.collections || cfg?.collections || [], globals: cfg.default?.globals || cfg?.globals || [] };
14122
+ fs.writeFileSync('${path.basename(resultFile)}', JSON.stringify(data));
14123
+ `, "utf8");
14124
+ execSync(
14125
+ `npx tsx "${entryFile}"`,
14126
+ { cwd: path.dirname(resolvedConfig), encoding: "utf8", timeout: 15e3, stdio: "pipe" }
14127
+ );
14128
+ const resultContent = fs.readFileSync(resultFile, "utf8");
14129
+ const configModule = JSON.parse(resultContent);
14130
+ try {
14131
+ fs.unlinkSync(resultFile);
14132
+ } catch {
14133
+ }
14134
+ if (configModule.error) {
14135
+ throw new Error(configModule.error);
14136
+ }
14137
+ globalThis.__KYRO_ADMIN_PROJECT_CONFIG__ = {
14138
+ collections: configModule.collections,
14139
+ globals: configModule.globals,
14140
+ adapter: configModule.adapter || null
14141
+ };
14142
+ logger.info("Project config loaded for admin");
14143
+ } catch (e) {
14144
+ logger.warn(`Could not load project config: ${e.message}`);
14145
+ } finally {
14146
+ for (const suffix of [".admin.mjs", ".admin-entry.mjs", ".admin-result.json"]) {
14147
+ const f = resolvedConfig.replace(/\.ts$/, suffix);
14148
+ if (fs.existsSync(f)) {
14149
+ try {
14150
+ fs.unlinkSync(f);
14151
+ } catch {
14152
+ }
14153
+ }
14154
+ }
14713
14155
  }
14156
+ updateConfig({
14157
+ vite: {
14158
+ resolve: {
14159
+ alias: {
14160
+ "kyro:config": resolvedConfig
14161
+ }
14162
+ },
14163
+ define: {
14164
+ __KYRO_ADMIN_PATH__: JSON.stringify(basePath),
14165
+ __KYRO_API_PATH__: JSON.stringify(apiPath2)
14166
+ }
14167
+ }
14168
+ });
14714
14169
  const pages = [
14715
14170
  { pattern: "", entrypoint: "./pages/index.astro" },
14716
14171
  { pattern: "/login", entrypoint: "./pages/auth/login.astro" },
@@ -14758,19 +14213,6 @@ function kyroAdmin(options = {}) {
14758
14213
  )
14759
14214
  });
14760
14215
  }
14761
- updateConfig({
14762
- vite: {
14763
- resolve: {
14764
- alias: {
14765
- "kyro:config": resolvedConfig
14766
- }
14767
- },
14768
- define: {
14769
- __KYRO_ADMIN_PATH__: JSON.stringify(basePath),
14770
- __KYRO_API_PATH__: JSON.stringify(apiPath2)
14771
- }
14772
- }
14773
- });
14774
14216
  },
14775
14217
  "astro:build:done": ({ logger }) => {
14776
14218
  logger.info("Kyro Admin build complete");