@genispace/geniapp 0.1.0

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 (258) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -0
  3. package/dist/CrossAppRecordPicker-BXchXcK5.js +624 -0
  4. package/dist/CrossAppRecordPicker-BXchXcK5.js.map +1 -0
  5. package/dist/Page-wHZrMN17.js +24 -0
  6. package/dist/Page-wHZrMN17.js.map +1 -0
  7. package/dist/ai/adopt/AiSuggestionPanel.d.ts +30 -0
  8. package/dist/ai/adopt/BusinessGuidancePanel.d.ts +31 -0
  9. package/dist/ai/adopt/DetailPageAiLayout.d.ts +7 -0
  10. package/dist/ai/adopt/adoptPresets.d.ts +11 -0
  11. package/dist/ai/adopt/guidanceContent.d.ts +27 -0
  12. package/dist/ai/adopt/parseAiSummary.d.ts +7 -0
  13. package/dist/ai/components/AgentJobProgress.d.ts +124 -0
  14. package/dist/ai/components/AsyncCombobox.d.ts +44 -0
  15. package/dist/ai/components/BulkActionBar.d.ts +44 -0
  16. package/dist/ai/components/EntityRef.d.ts +39 -0
  17. package/dist/ai/components/JobProgress.d.ts +64 -0
  18. package/dist/ai/components/ServerDataTable.d.ts +89 -0
  19. package/dist/ai/components/Timeline.d.ts +35 -0
  20. package/dist/ai/components/useInfiniteRows.d.ts +25 -0
  21. package/dist/ai/errors/userFacingError.d.ts +14 -0
  22. package/dist/ai/errors/userFacingError.js +48 -0
  23. package/dist/ai/errors/userFacingError.js.map +1 -0
  24. package/dist/ai/index.d.ts +34 -0
  25. package/dist/ai/integrations/partner/createPartnerRecordPickerHook.d.ts +15 -0
  26. package/dist/ai/integrations/partner/partnerRecordPicker.d.ts +20 -0
  27. package/dist/ai/layout/ModalWithAiLayout.d.ts +11 -0
  28. package/dist/ai/layout/aiUi.d.ts +16 -0
  29. package/dist/ai/layout/layoutConstants.d.ts +19 -0
  30. package/dist/ai/layout/modalSizeForAi.d.ts +5 -0
  31. package/dist/ai/locales/sharedAiCopy.d.ts +6 -0
  32. package/dist/ai/managed-data/DatasourceReadonlyTable.d.ts +11 -0
  33. package/dist/ai/managed-data/createTableClient.d.ts +7 -0
  34. package/dist/ai/managed-data/emitManagedEvent.d.ts +18 -0
  35. package/dist/ai/managed-data/executeManagedDatasource.d.ts +21 -0
  36. package/dist/ai/managed-data/queryManagedDatasource.d.ts +28 -0
  37. package/dist/ai/providers/AppUiProviders.d.ts +6 -0
  38. package/dist/ai/types/app-ai.types.d.ts +29 -0
  39. package/dist/ai/types/index.d.ts +1 -0
  40. package/dist/ai.d.ts +1 -0
  41. package/dist/ai.js +1817 -0
  42. package/dist/ai.js.map +1 -0
  43. package/dist/case-workspace/domain.d.ts +41 -0
  44. package/dist/case-workspace/domain.js +24 -0
  45. package/dist/case-workspace/domain.js.map +1 -0
  46. package/dist/case-workspace/index.d.ts +91 -0
  47. package/dist/case-workspace.d.ts +1 -0
  48. package/dist/case-workspace.js +392 -0
  49. package/dist/case-workspace.js.map +1 -0
  50. package/dist/cn-B6yFEsav.js +9 -0
  51. package/dist/cn-B6yFEsav.js.map +1 -0
  52. package/dist/components/ui/calendar.css +7 -0
  53. package/dist/cookieSettings-D_v3KS02.js +97 -0
  54. package/dist/cookieSettings-D_v3KS02.js.map +1 -0
  55. package/dist/dashboard/index.d.ts +16 -0
  56. package/dist/dashboard/src/ChartFrame.d.ts +18 -0
  57. package/dist/dashboard/src/ChartTooltip.d.ts +38 -0
  58. package/dist/dashboard/src/FilterBar.d.ts +23 -0
  59. package/dist/dashboard/src/KpiStatCard.d.ts +29 -0
  60. package/dist/dashboard/src/StatGrid.d.ts +15 -0
  61. package/dist/dashboard/src/TimeRangePicker.d.ts +14 -0
  62. package/dist/dashboard/src/chart.d.ts +10 -0
  63. package/dist/dashboard/src/format.d.ts +16 -0
  64. package/dist/dashboard/src/links.d.ts +2 -0
  65. package/dist/dashboard/src/useDashboardRange.d.ts +27 -0
  66. package/dist/dashboard.d.ts +1 -0
  67. package/dist/dashboard.js +361 -0
  68. package/dist/dashboard.js.map +1 -0
  69. package/dist/fonts.css +15 -0
  70. package/dist/hooks/access/AppAccessGate.d.ts +20 -0
  71. package/dist/hooks/access/AppAccessNotice.d.ts +8 -0
  72. package/dist/hooks/access/useAppAccess.d.ts +26 -0
  73. package/dist/hooks/config/businessLocale.d.ts +12 -0
  74. package/dist/hooks/config/currencies.d.ts +9 -0
  75. package/dist/hooks/index.d.ts +17 -0
  76. package/dist/hooks/picker/CrossAppRecordPicker.d.ts +37 -0
  77. package/dist/hooks/picker/managedAppPicker.d.ts +21 -0
  78. package/dist/hooks/picker/partnerPayload.d.ts +6 -0
  79. package/dist/hooks/routing/draftEntityId.d.ts +5 -0
  80. package/dist/hooks/routing/useRefetchOnRouteMatch.d.ts +6 -0
  81. package/dist/hooks/shell/resolveApiRoot.d.ts +13 -0
  82. package/dist/hooks/shell/shell.d.ts +4 -0
  83. package/dist/hooks/shell/useGenispacePlatformClient.d.ts +7 -0
  84. package/dist/hooks.d.ts +1 -0
  85. package/dist/hooks.js +42 -0
  86. package/dist/hooks.js.map +1 -0
  87. package/dist/index.d.ts +3 -0
  88. package/dist/index.js +77 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/kit.d.ts +50 -0
  91. package/dist/kit.js +2067 -0
  92. package/dist/kit.js.map +1 -0
  93. package/dist/page.d.ts +1 -0
  94. package/dist/page.js +5 -0
  95. package/dist/page.js.map +1 -0
  96. package/dist/shell-DIHnXIUb.js +6 -0
  97. package/dist/shell-DIHnXIUb.js.map +1 -0
  98. package/dist/shell.d.ts +30 -0
  99. package/dist/shell.js +104 -0
  100. package/dist/shell.js.map +1 -0
  101. package/dist/storage/assetPreview.d.ts +12 -0
  102. package/dist/storage/components/AssetThumbnail.d.ts +15 -0
  103. package/dist/storage/components/CopyStorageLinkButton.d.ts +13 -0
  104. package/dist/storage/components/StorageImage.d.ts +9 -0
  105. package/dist/storage/components/StoragePreviewContent.d.ts +22 -0
  106. package/dist/storage/components/StorageVideo.d.ts +9 -0
  107. package/dist/storage/copyTextToClipboard.d.ts +5 -0
  108. package/dist/storage/hooks/useAuthenticatedStorageBlobs.d.ts +3 -0
  109. package/dist/storage/hooks/useImageThumbnailBlobs.d.ts +4 -0
  110. package/dist/storage/hooks/useShareableStorageLink.d.ts +7 -0
  111. package/dist/storage/index.d.ts +12 -0
  112. package/dist/storage/openUrlInNewTab.d.ts +6 -0
  113. package/dist/storage/platformStorage.d.ts +43 -0
  114. package/dist/storage.d.ts +1 -0
  115. package/dist/storage.js +605 -0
  116. package/dist/storage.js.map +1 -0
  117. package/dist/style.css +1 -0
  118. package/dist/styles/base.css +616 -0
  119. package/dist/styles/reduced-motion.css +14 -0
  120. package/dist/styles/tailwind-preset.js +269 -0
  121. package/dist/task-workspace/domain.d.ts +35 -0
  122. package/dist/task-workspace/domain.js +45 -0
  123. package/dist/task-workspace/domain.js.map +1 -0
  124. package/dist/task-workspace/experience.d.ts +50 -0
  125. package/dist/task-workspace/index.d.ts +172 -0
  126. package/dist/task-workspace.d.ts +1 -0
  127. package/dist/task-workspace.js +626 -0
  128. package/dist/task-workspace.js.map +1 -0
  129. package/dist/ui/components/features/app/AppCheckboxInput.d.ts +9 -0
  130. package/dist/ui/components/features/app/AppConfirmDialog.d.ts +12 -0
  131. package/dist/ui/components/features/app/AppDashboardSkeleton.d.ts +9 -0
  132. package/dist/ui/components/features/app/AppDatePicker.d.ts +69 -0
  133. package/dist/ui/components/features/app/AppModal.d.ts +27 -0
  134. package/dist/ui/components/features/app/AppPageStates.d.ts +17 -0
  135. package/dist/ui/components/features/app/AppSelectInput.d.ts +10 -0
  136. package/dist/ui/components/features/app/AppTemporalInput.d.ts +19 -0
  137. package/dist/ui/components/features/app/Page.d.ts +14 -0
  138. package/dist/ui/components/features/app/QueryErrorAlert.d.ts +7 -0
  139. package/dist/ui/components/features/app/Sidebar.d.ts +47 -0
  140. package/dist/ui/components/features/app/index.d.ts +17 -0
  141. package/dist/ui/components/features/user/UserAvatar.d.ts +17 -0
  142. package/dist/ui/components/features/user/UserDisplay.d.ts +10 -0
  143. package/dist/ui/components/features/user/UserSelect.d.ts +14 -0
  144. package/dist/ui/components/features/user/useUserDirectory.d.ts +13 -0
  145. package/dist/ui/components/features/user/userDirectoryTypes.d.ts +18 -0
  146. package/dist/ui/components/patterns/form-section.d.ts +11 -0
  147. package/dist/ui/components/primitives/feedback/index.d.ts +2 -0
  148. package/dist/ui/components/primitives/feedback/toaster.d.ts +1 -0
  149. package/dist/ui/components/primitives/feedback/use-toast.d.ts +46 -0
  150. package/dist/ui/components/primitives/page-skeleton/ChartAreaSkeleton.d.ts +13 -0
  151. package/dist/ui/components/primitives/page-skeleton/ChartEmptyState.d.ts +14 -0
  152. package/dist/ui/components/primitives/page-skeleton/ComponentSkeletonShell.d.ts +16 -0
  153. package/dist/ui/components/primitives/page-skeleton/ConfigEditorSkeleton.d.ts +5 -0
  154. package/dist/ui/components/primitives/page-skeleton/DetailTabsSkeleton.d.ts +6 -0
  155. package/dist/ui/components/primitives/page-skeleton/EmptyStateBadge.d.ts +13 -0
  156. package/dist/ui/components/primitives/page-skeleton/FormCardSkeleton.d.ts +7 -0
  157. package/dist/ui/components/primitives/page-skeleton/FormFieldSkeleton.d.ts +6 -0
  158. package/dist/ui/components/primitives/page-skeleton/FormPageSkeleton.d.ts +6 -0
  159. package/dist/ui/components/primitives/page-skeleton/GridCardsSkeleton.d.ts +6 -0
  160. package/dist/ui/components/primitives/page-skeleton/ListSkeleton.d.ts +26 -0
  161. package/dist/ui/components/primitives/page-skeleton/PageHeaderSkeleton.d.ts +6 -0
  162. package/dist/ui/components/primitives/page-skeleton/SplitPaneSkeleton.d.ts +4 -0
  163. package/dist/ui/components/primitives/page-skeleton/StatsRowSkeleton.d.ts +5 -0
  164. package/dist/ui/components/primitives/page-skeleton/TableEmptyState.d.ts +27 -0
  165. package/dist/ui/components/primitives/page-skeleton/TablePageSkeleton.d.ts +8 -0
  166. package/dist/ui/components/primitives/page-skeleton/TabsBarSkeleton.d.ts +6 -0
  167. package/dist/ui/components/primitives/page-skeleton/index.d.ts +24 -0
  168. package/dist/ui/components/primitives/page-skeleton/skeletonMetrics.d.ts +9 -0
  169. package/dist/ui/components/primitives/page-skeleton/useVisibleCenter.d.ts +34 -0
  170. package/dist/ui/components/ui/accordion.d.ts +7 -0
  171. package/dist/ui/components/ui/ai-draft-banner.d.ts +21 -0
  172. package/dist/ui/components/ui/alert-dialog.d.ts +48 -0
  173. package/dist/ui/components/ui/alert.d.ts +8 -0
  174. package/dist/ui/components/ui/avatar.d.ts +6 -0
  175. package/dist/ui/components/ui/badge.d.ts +9 -0
  176. package/dist/ui/components/ui/breadcrumb.d.ts +19 -0
  177. package/dist/ui/components/ui/button.d.ts +11 -0
  178. package/dist/ui/components/ui/calendar.d.ts +8 -0
  179. package/dist/ui/components/ui/card.d.ts +8 -0
  180. package/dist/ui/components/ui/chart.d.ts +16 -0
  181. package/dist/ui/components/ui/checkbox.d.ts +4 -0
  182. package/dist/ui/components/ui/collapsible.d.ts +5 -0
  183. package/dist/ui/components/ui/column-config.d.ts +42 -0
  184. package/dist/ui/components/ui/date-picker.d.ts +9 -0
  185. package/dist/ui/components/ui/date-range-filter.d.ts +32 -0
  186. package/dist/ui/components/ui/date-range-picker.d.ts +11 -0
  187. package/dist/ui/components/ui/dialog-input.d.ts +17 -0
  188. package/dist/ui/components/ui/dialog-safe-select.d.ts +13 -0
  189. package/dist/ui/components/ui/dialog.d.ts +25 -0
  190. package/dist/ui/components/ui/dropdown-menu.d.ts +27 -0
  191. package/dist/ui/components/ui/feature-guide.d.ts +43 -0
  192. package/dist/ui/components/ui/form.d.ts +25 -0
  193. package/dist/ui/components/ui/help-tip.d.ts +29 -0
  194. package/dist/ui/components/ui/hint-notice.d.ts +22 -0
  195. package/dist/ui/components/ui/index.d.ts +6 -0
  196. package/dist/ui/components/ui/input.d.ts +3 -0
  197. package/dist/ui/components/ui/label.d.ts +5 -0
  198. package/dist/ui/components/ui/modal-container.d.ts +56 -0
  199. package/dist/ui/components/ui/modal-templates.d.ts +46 -0
  200. package/dist/ui/components/ui/multi-select.d.ts +20 -0
  201. package/dist/ui/components/ui/pagination.d.ts +28 -0
  202. package/dist/ui/components/ui/popover.d.ts +7 -0
  203. package/dist/ui/components/ui/progress.d.ts +7 -0
  204. package/dist/ui/components/ui/radio-button-group.d.ts +18 -0
  205. package/dist/ui/components/ui/radio-group.d.ts +5 -0
  206. package/dist/ui/components/ui/scroll-area.d.ts +5 -0
  207. package/dist/ui/components/ui/select.d.ts +16 -0
  208. package/dist/ui/components/ui/separator.d.ts +7 -0
  209. package/dist/ui/components/ui/sheet.d.ts +25 -0
  210. package/dist/ui/components/ui/sidebar-rail.d.ts +9 -0
  211. package/dist/ui/components/ui/skeleton.d.ts +2 -0
  212. package/dist/ui/components/ui/slider.d.ts +13 -0
  213. package/dist/ui/components/ui/switch.d.ts +4 -0
  214. package/dist/ui/components/ui/table.d.ts +10 -0
  215. package/dist/ui/components/ui/tabs.d.ts +10 -0
  216. package/dist/ui/components/ui/textarea.d.ts +3 -0
  217. package/dist/ui/components/ui/toast.d.ts +21 -0
  218. package/dist/ui/components/ui/toggle-group.d.ts +12 -0
  219. package/dist/ui/components/ui/toggle.d.ts +12 -0
  220. package/dist/ui/components/ui/tooltip.d.ts +7 -0
  221. package/dist/ui/components/ui/typography.d.ts +15 -0
  222. package/dist/ui/components/ui/underline-tabs.d.ts +13 -0
  223. package/dist/ui/components/ui/view-mode-toggle.d.ts +9 -0
  224. package/dist/ui/hooks/useIsMobile.d.ts +16 -0
  225. package/dist/ui/styles/design-tokens.d.ts +189 -0
  226. package/dist/ui/styles/z-index-layers.d.ts +46 -0
  227. package/dist/ui.d.ts +2 -0
  228. package/dist/ui.js +35 -0
  229. package/dist/ui.js.map +1 -0
  230. package/dist/useUserDirectory-CqkyCQoR.js +2377 -0
  231. package/dist/useUserDirectory-CqkyCQoR.js.map +1 -0
  232. package/dist/utils/cookieSettings.d.ts +12 -0
  233. package/dist/utils/data/countryCodes.d.ts +26 -0
  234. package/dist/utils/index.d.ts +18 -0
  235. package/dist/utils/utils/appPath.d.ts +5 -0
  236. package/dist/utils/utils/chunkLoadRecovery.d.ts +7 -0
  237. package/dist/utils/utils/cn.d.ts +3 -0
  238. package/dist/utils/utils/crossApp.d.ts +71 -0
  239. package/dist/utils/utils/debounce.d.ts +1 -0
  240. package/dist/utils/utils/formatUserLabel.d.ts +8 -0
  241. package/dist/utils/utils/formatting.d.ts +18 -0
  242. package/dist/utils/utils/logoutNotification.d.ts +28 -0
  243. package/dist/utils/utils/operatorLocale.d.ts +32 -0
  244. package/dist/utils/utils/routeLocalePrefetch.d.ts +5 -0
  245. package/dist/utils/utils/shellIframeUrl.d.ts +20 -0
  246. package/dist/utils/utils/spaceSettings.d.ts +20 -0
  247. package/dist/utils/utils/sso.d.ts +42 -0
  248. package/dist/utils/utils/throttle.d.ts +1 -0
  249. package/dist/utils/utils/timezones.d.ts +14 -0
  250. package/dist/utils/utils/toDateInputValue.d.ts +5 -0
  251. package/dist/utils/utils/watermark.d.ts +1 -0
  252. package/dist/utils.d.ts +1 -0
  253. package/dist/utils.js +1334 -0
  254. package/dist/utils.js.map +1 -0
  255. package/dist/vite.d.ts +22 -0
  256. package/dist/vite.js +74 -0
  257. package/dist/vite.js.map +1 -0
  258. package/package.json +191 -0
@@ -0,0 +1,605 @@
1
+ import { jsx as a, jsxs as f } from "react/jsx-runtime";
2
+ import { Film as te, Play as re, Music as ne, FileText as Y, Download as oe, Check as ie, Copy as ae, ExternalLink as le } from "lucide-react";
3
+ import { useMemo as q, useState as p, useEffect as P, useCallback as M, useRef as ce } from "react";
4
+ function G(e) {
5
+ if (!e || typeof e != "object")
6
+ throw new Error("Invalid storage file response");
7
+ const t = e;
8
+ if (t.data && typeof t.data == "object" && t.data.id)
9
+ return t.data;
10
+ if (t.id)
11
+ return t;
12
+ throw new Error("Invalid storage file response");
13
+ }
14
+ const N = /* @__PURE__ */ new Map();
15
+ function se(e) {
16
+ if (e instanceof ArrayBuffer)
17
+ return e.slice(0);
18
+ const t = new Uint8Array(e.byteLength);
19
+ return t.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)), t;
20
+ }
21
+ function W(e) {
22
+ return e?.trim() ? /\/storage\/files\/[^/?#]+\/content(?:[/?#]|$)/i.test(e.trim()) : !1;
23
+ }
24
+ async function B(e, t, r) {
25
+ const n = N.get(t);
26
+ if (n)
27
+ return n.refCount += 1, {
28
+ blobUrl: n.blobUrl,
29
+ revoke: () => R(t)
30
+ };
31
+ const l = G(await e.storage.getFile(t)), c = await e.storage.getFileContent(t), o = r || l.mimeType || "application/octet-stream", i = new Blob([se(c)], { type: o }), s = URL.createObjectURL(i);
32
+ return N.set(t, { blobUrl: s, refCount: 1 }), {
33
+ blobUrl: s,
34
+ revoke: () => R(t)
35
+ };
36
+ }
37
+ function R(e) {
38
+ const t = N.get(e);
39
+ t && (t.refCount -= 1, t.refCount <= 0 && (URL.revokeObjectURL(t.blobUrl), N.delete(e)));
40
+ }
41
+ async function L(e, t, r = 4) {
42
+ const n = [...new Set(t.filter(Boolean))], l = {};
43
+ if (n.length === 0) return l;
44
+ let c = 0;
45
+ async function o() {
46
+ for (; c < n.length; ) {
47
+ const i = n[c++];
48
+ try {
49
+ const { blobUrl: s } = await B(e, i);
50
+ l[i] = s;
51
+ } catch {
52
+ }
53
+ }
54
+ }
55
+ return await Promise.all(Array.from({ length: Math.min(r, n.length) }, () => o())), l;
56
+ }
57
+ async function U(e, t) {
58
+ const r = G(await e.storage.getFile(t));
59
+ if (!r.publicUrl?.trim())
60
+ throw new Error("Shareable public URL is not available for this file.");
61
+ return r.publicUrl;
62
+ }
63
+ async function ue(e, t) {
64
+ const r = [...new Set(t.filter(Boolean))], n = {};
65
+ return await Promise.all(
66
+ r.map(async (l) => {
67
+ try {
68
+ n[l] = await U(e, l);
69
+ } catch {
70
+ }
71
+ })
72
+ ), n;
73
+ }
74
+ function D(e, t, r) {
75
+ if (e && r[e]) return r[e];
76
+ const n = t?.trim();
77
+ return n && !W(n) ? n : null;
78
+ }
79
+ function _e(e) {
80
+ return e.url;
81
+ }
82
+ function Te(e) {
83
+ return {
84
+ fetchAuthenticatedBlobUrl: (t, r) => B(e, t, r),
85
+ resolveAuthenticatedBlobUrls: (t) => L(e, t),
86
+ resolveShareablePublicUrl: (t) => U(e, t),
87
+ resolveShareablePublicUrls: (t) => ue(e, t)
88
+ };
89
+ }
90
+ function de(e) {
91
+ const t = document.createElement("textarea");
92
+ t.value = e, t.style.position = "fixed", t.style.left = "-9999px", t.style.opacity = "0", document.body.appendChild(t), t.focus(), t.select();
93
+ try {
94
+ return document.execCommand("copy");
95
+ } finally {
96
+ document.body.removeChild(t);
97
+ }
98
+ }
99
+ function fe() {
100
+ return typeof navigator < "u" && typeof navigator.clipboard?.write == "function" && typeof ClipboardItem < "u";
101
+ }
102
+ async function me(e) {
103
+ if (typeof e == "string") {
104
+ await F(e);
105
+ return;
106
+ }
107
+ const t = e;
108
+ if (fe())
109
+ try {
110
+ const n = new ClipboardItem({
111
+ "text/plain": t.then((l) => new Blob([l], { type: "text/plain" }))
112
+ });
113
+ await navigator.clipboard.write([n]), await t;
114
+ return;
115
+ } catch {
116
+ }
117
+ const r = await t;
118
+ await F(r);
119
+ }
120
+ async function F(e) {
121
+ if (navigator.clipboard?.writeText)
122
+ try {
123
+ await navigator.clipboard.writeText(e);
124
+ return;
125
+ } catch {
126
+ }
127
+ if (!de(e))
128
+ throw new Error("Failed to copy to clipboard");
129
+ }
130
+ function pe(e) {
131
+ if (window.open(e, "_blank", "noopener,noreferrer")) return;
132
+ const r = document.createElement("a");
133
+ r.href = e, r.target = "_blank", r.rel = "noopener noreferrer", document.body.appendChild(r), r.click(), document.body.removeChild(r);
134
+ }
135
+ async function he(e) {
136
+ if (typeof e == "string")
137
+ return pe(e), e;
138
+ const t = window.open("about:blank", "_blank");
139
+ if (!t)
140
+ throw new Error("Popup blocked. Allow popups for this site and try again.");
141
+ try {
142
+ const r = await e;
143
+ return t.location.replace(r), t.opener = null, r;
144
+ } catch (r) {
145
+ throw t.close(), r;
146
+ }
147
+ }
148
+ const k = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg"]), S = /* @__PURE__ */ new Set(["mp4", "webm", "ogg", "mov", "avi", "mkv"]), T = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "flac", "ogg"]), j = /* @__PURE__ */ new Set(["txt", "md", "markdown", "json", "log", "csv", "xml"]), H = /* @__PURE__ */ new Set(["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "zip"]), O = /* @__PURE__ */ new Set(["image", "thumbnail", "reference"]), ge = /* @__PURE__ */ new Set(["video_clip", "final_video"]), we = /* @__PURE__ */ new Set(["script", "subtitle"]);
149
+ function J(e) {
150
+ return e?.trim() ? e.trim().toLowerCase().replace(/^\./, "").split(/[?#]/)[0] ?? "" : "";
151
+ }
152
+ function A(e) {
153
+ if (!e?.trim()) return "";
154
+ const t = e.trim().split("/").pop() ?? "", r = t.lastIndexOf(".");
155
+ return r < 0 ? "" : J(t.slice(r + 1));
156
+ }
157
+ function be(e) {
158
+ if (!e?.trim()) return "";
159
+ try {
160
+ const t = new URL(e, "https://placeholder.local").pathname;
161
+ return A(t);
162
+ } catch {
163
+ return A(e);
164
+ }
165
+ }
166
+ function Z(e) {
167
+ return J(e.format) || A(e.name) || be(e.url);
168
+ }
169
+ function ve(e) {
170
+ return !!e.storage_file_id?.trim() || !!e.url?.trim();
171
+ }
172
+ const X = {
173
+ jpg: "image/jpeg",
174
+ jpeg: "image/jpeg",
175
+ png: "image/png",
176
+ gif: "image/gif",
177
+ webp: "image/webp",
178
+ bmp: "image/bmp",
179
+ svg: "image/svg+xml",
180
+ mp4: "video/mp4",
181
+ webm: "video/webm",
182
+ mov: "video/quicktime",
183
+ avi: "video/x-msvideo",
184
+ mkv: "video/x-matroska",
185
+ mp3: "audio/mpeg",
186
+ wav: "audio/wav",
187
+ m4a: "audio/mp4",
188
+ aac: "audio/aac",
189
+ flac: "audio/flac",
190
+ txt: "text/plain",
191
+ md: "text/markdown",
192
+ markdown: "text/markdown",
193
+ json: "application/json",
194
+ csv: "text/csv",
195
+ xml: "application/xml",
196
+ pdf: "application/pdf"
197
+ };
198
+ function C(e) {
199
+ if (!ve(e)) return "unknown";
200
+ const t = String(e.type ?? "").trim().toLowerCase(), r = Z(e);
201
+ return ge.has(t) || S.has(r) ? "video" : t === "audio" || T.has(r) ? "audio" : j.has(r) || we.has(t) && !S.has(r) && !k.has(r) ? "text" : H.has(r) ? "download" : O.has(t) && r && !S.has(r) && !T.has(r) && !j.has(r) ? k.has(r) || r === "" ? "image" : K(r) : k.has(r) ? "image" : t === "other" && r ? K(r) : O.has(t) ? "image" : "download";
202
+ }
203
+ function K(e) {
204
+ return k.has(e) ? "image" : S.has(e) ? "video" : T.has(e) ? "audio" : j.has(e) ? "text" : (H.has(e), "download");
205
+ }
206
+ function ye(e) {
207
+ const t = Z(e);
208
+ if (t && X[t]) return X[t];
209
+ switch (C(e)) {
210
+ case "image":
211
+ return "image/jpeg";
212
+ case "video":
213
+ return "video/mp4";
214
+ case "audio":
215
+ return "audio/mpeg";
216
+ case "text":
217
+ return "text/plain";
218
+ default:
219
+ return "application/octet-stream";
220
+ }
221
+ }
222
+ function xe(e) {
223
+ return e === "image";
224
+ }
225
+ function je(e, t) {
226
+ const r = q(
227
+ () => [...new Set(t.filter((c) => !!c?.trim()))],
228
+ [t]
229
+ ), [n, l] = p({});
230
+ return P(() => {
231
+ if (!e || r.length === 0) {
232
+ l({});
233
+ return;
234
+ }
235
+ let c = !1;
236
+ return L(e, r).then((o) => {
237
+ c || l(o);
238
+ }), () => {
239
+ c = !0;
240
+ };
241
+ }, [e, r.join("|")]), n;
242
+ }
243
+ function Ae(e, t) {
244
+ const r = q(() => {
245
+ const o = /* @__PURE__ */ new Set();
246
+ for (const i of t) {
247
+ const s = i.storage_file_id?.trim();
248
+ s && xe(C(i)) && o.add(s);
249
+ }
250
+ return [...o];
251
+ }, [t]), n = r.join("|"), [l, c] = p({});
252
+ return P(() => {
253
+ if (!e || r.length === 0) {
254
+ c({});
255
+ return;
256
+ }
257
+ let o = !1;
258
+ return L(e, r).then((i) => {
259
+ o || c(i);
260
+ }), () => {
261
+ o = !0;
262
+ };
263
+ }, [e, n]), l;
264
+ }
265
+ function ke(e, t) {
266
+ const [r, n] = p(!1), l = M(
267
+ async (o) => {
268
+ if (!e || !o.trim()) return null;
269
+ n(!0);
270
+ try {
271
+ const i = U(e, o);
272
+ return await me(i), await i;
273
+ } catch (i) {
274
+ const s = i instanceof Error ? i.message : String(i);
275
+ return t?.(s), null;
276
+ } finally {
277
+ n(!1);
278
+ }
279
+ },
280
+ [e, t]
281
+ ), c = M(
282
+ async (o) => {
283
+ if (!e || !o.trim()) return null;
284
+ n(!0);
285
+ try {
286
+ const i = U(e, o);
287
+ return await he(i);
288
+ } catch (i) {
289
+ const s = i instanceof Error ? i.message : String(i);
290
+ return t?.(s), null;
291
+ } finally {
292
+ n(!1);
293
+ }
294
+ },
295
+ [e, t]
296
+ );
297
+ return { copyLink: l, openShareTab: c, loading: r };
298
+ }
299
+ function Se({
300
+ storageFileId: e,
301
+ fallbackUrl: t,
302
+ blobUrls: r,
303
+ src: n,
304
+ alt: l = "",
305
+ ...c
306
+ }) {
307
+ const o = D(e, t ?? (typeof n == "string" ? n : null), r) ?? void 0;
308
+ return o ? /* @__PURE__ */ a("img", { src: o, alt: l, ...c }) : null;
309
+ }
310
+ function Pe({
311
+ storageFileId: e,
312
+ fallbackUrl: t,
313
+ blobUrls: r,
314
+ src: n,
315
+ ...l
316
+ }) {
317
+ const c = D(e, t ?? (typeof n == "string" ? n : null), r) ?? void 0;
318
+ return c ? /* @__PURE__ */ a("video", { src: c, ...l }) : null;
319
+ }
320
+ const Q = {
321
+ sm: "h-8 w-8",
322
+ md: "h-32 w-full",
323
+ lg: "h-40 w-full"
324
+ }, V = {
325
+ video_clip: "🎬",
326
+ final_video: "🎥",
327
+ image: "🖼️",
328
+ audio: "🎵",
329
+ script: "📄",
330
+ subtitle: "💬",
331
+ thumbnail: "🖼️",
332
+ reference: "📎",
333
+ other: "📁"
334
+ };
335
+ function x({
336
+ children: e,
337
+ size: t,
338
+ className: r,
339
+ onClick: n,
340
+ interactive: l,
341
+ label: c
342
+ }) {
343
+ const o = !!(n && l !== !1);
344
+ return /* @__PURE__ */ a(
345
+ "div",
346
+ {
347
+ role: o ? "button" : void 0,
348
+ tabIndex: o ? 0 : void 0,
349
+ "aria-label": o ? c : void 0,
350
+ onClick: n,
351
+ onKeyDown: o ? (i) => {
352
+ (i.key === "Enter" || i.key === " ") && (i.preventDefault(), n?.());
353
+ } : void 0,
354
+ className: `flex items-center justify-center bg-muted text-muted-foreground ${Q[t]} ${o ? "cursor-pointer hover:opacity-90" : ""} ${r ?? ""}`,
355
+ children: e
356
+ }
357
+ );
358
+ }
359
+ function Be({
360
+ asset: e,
361
+ blobUrls: t = {},
362
+ size: r = "md",
363
+ onClick: n,
364
+ className: l = "",
365
+ interactive: c = !0
366
+ }) {
367
+ const o = C(e), i = e.name?.trim() || "Asset preview", s = (u) => {
368
+ n && n();
369
+ };
370
+ if (o === "image") {
371
+ const u = e.storage_file_id ? t[e.storage_file_id] : void 0, m = e.url?.trim() && !W(e.url) ? e.url.trim() : null, g = u || m, d = !!(n && c !== !1);
372
+ return /* @__PURE__ */ a(
373
+ "div",
374
+ {
375
+ role: d ? "button" : void 0,
376
+ tabIndex: d ? 0 : void 0,
377
+ "aria-label": d ? i : void 0,
378
+ onClick: () => s(),
379
+ onKeyDown: d ? (h) => {
380
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), n?.());
381
+ } : void 0,
382
+ className: `relative overflow-hidden bg-muted ${Q[r]} ${d ? "cursor-pointer" : ""} ${l}`,
383
+ children: g ? /* @__PURE__ */ a(
384
+ Se,
385
+ {
386
+ storageFileId: e.storage_file_id,
387
+ fallbackUrl: e.url,
388
+ blobUrls: t,
389
+ alt: i,
390
+ className: `h-full w-full object-cover ${r === "sm" ? "rounded" : ""}`
391
+ }
392
+ ) : /* @__PURE__ */ a("div", { className: "flex h-full w-full items-center justify-center text-2xl", children: V[e.type ?? ""] ?? "🖼️" })
393
+ }
394
+ );
395
+ }
396
+ return o === "video" ? /* @__PURE__ */ f(
397
+ x,
398
+ {
399
+ size: r,
400
+ className: `relative bg-neutral-900 text-white ${l}`,
401
+ onClick: () => s(),
402
+ interactive: c,
403
+ label: i,
404
+ children: [
405
+ /* @__PURE__ */ a(te, { className: r === "sm" ? "h-4 w-4 opacity-70" : "h-8 w-8 opacity-50" }),
406
+ r !== "sm" && /* @__PURE__ */ a("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ a(re, { className: "h-10 w-10 fill-white/90 text-white/90" }) })
407
+ ]
408
+ }
409
+ ) : o === "audio" ? /* @__PURE__ */ a(
410
+ x,
411
+ {
412
+ size: r,
413
+ className: l,
414
+ onClick: () => s(),
415
+ interactive: c,
416
+ label: i,
417
+ children: /* @__PURE__ */ a(ne, { className: r === "sm" ? "h-4 w-4" : "h-8 w-8" })
418
+ }
419
+ ) : o === "text" ? /* @__PURE__ */ a(
420
+ x,
421
+ {
422
+ size: r,
423
+ className: l,
424
+ onClick: () => s(),
425
+ interactive: c,
426
+ label: i,
427
+ children: /* @__PURE__ */ f("div", { className: "flex flex-col items-center gap-1", children: [
428
+ /* @__PURE__ */ a(Y, { className: r === "sm" ? "h-4 w-4" : "h-8 w-8" }),
429
+ r !== "sm" && e.format && /* @__PURE__ */ a("span", { className: "text-[10px] uppercase tracking-wide", children: e.format })
430
+ ] })
431
+ }
432
+ ) : /* @__PURE__ */ a(
433
+ x,
434
+ {
435
+ size: r,
436
+ className: l,
437
+ onClick: () => s(),
438
+ interactive: c,
439
+ label: i,
440
+ children: /* @__PURE__ */ a("span", { className: r === "sm" ? "text-base" : "text-4xl", children: V[e.type ?? ""] ?? "📁" })
441
+ }
442
+ );
443
+ }
444
+ async function Ne(e, t, r, n) {
445
+ if (n)
446
+ return { url: n };
447
+ const l = t.storage_file_id?.trim();
448
+ if (l && e) {
449
+ const { blobUrl: o, revoke: i } = await B(e, l, r);
450
+ return { url: o, revoke: i };
451
+ }
452
+ const c = t.url?.trim();
453
+ if (c && !c.startsWith("blob:"))
454
+ return { url: c };
455
+ throw new Error("Preview source unavailable");
456
+ }
457
+ function Le({
458
+ open: e,
459
+ asset: t,
460
+ client: r,
461
+ blobUrls: n = {},
462
+ onDownload: l,
463
+ labels: c = {}
464
+ }) {
465
+ const o = C(t), i = ye(t), s = t.name?.trim() || "file", [u, m] = p(null), [g, d] = p(""), [h, y] = p(!1), [$, E] = p(null), w = ce(null);
466
+ return P(() => {
467
+ if (!e) {
468
+ w.current?.(), w.current = null, m(null), d(""), y(!1), E(null);
469
+ return;
470
+ }
471
+ let b = !1;
472
+ y(!0), E(null);
473
+ const z = D(t.storage_file_id, t.url, n);
474
+ return (async () => {
475
+ try {
476
+ if (o === "download") {
477
+ b || (m(null), y(!1));
478
+ return;
479
+ }
480
+ const { url: v, revoke: I } = await Ne(r, t, i, z);
481
+ if (b) {
482
+ I?.();
483
+ return;
484
+ }
485
+ if (w.current?.(), w.current = I ?? null, m(v), o === "text") {
486
+ const _ = await fetch(v);
487
+ if (!_.ok) throw new Error(`HTTP ${_.status}`);
488
+ const ee = await _.text();
489
+ b || d(ee);
490
+ }
491
+ } catch (v) {
492
+ b || E(v instanceof Error ? v.message : String(v));
493
+ } finally {
494
+ b || y(!1);
495
+ }
496
+ })(), () => {
497
+ b = !0, w.current?.(), w.current = null;
498
+ };
499
+ }, [e, t.storage_file_id, t.url, o, i, n, r]), h ? /* @__PURE__ */ f("div", { className: "min-h-[240px] animate-pulse space-y-4 p-6", role: "status", "aria-busy": "true", children: [
500
+ /* @__PURE__ */ a("div", { className: "h-6 w-48 rounded bg-muted" }),
501
+ /* @__PURE__ */ a("div", { className: "h-40 w-full rounded-xl bg-muted" }),
502
+ /* @__PURE__ */ f("div", { className: "space-y-2", children: [
503
+ /* @__PURE__ */ a("div", { className: "h-4 w-4/5 rounded bg-muted" }),
504
+ /* @__PURE__ */ a("div", { className: "h-4 w-2/3 rounded bg-muted" })
505
+ ] })
506
+ ] }) : $ ? /* @__PURE__ */ f("div", { className: "flex min-h-[240px] flex-col items-center justify-center gap-3 p-8 text-center text-muted-foreground", children: [
507
+ /* @__PURE__ */ a("p", { children: c.loadFailed ?? "Failed to load preview" }),
508
+ /* @__PURE__ */ a("p", { className: "text-sm", children: $ })
509
+ ] }) : o === "image" && u ? /* @__PURE__ */ a("div", { className: "flex min-h-[240px] items-center justify-center bg-neutral-950/5 p-4 dark:bg-neutral-950", children: /* @__PURE__ */ a(
510
+ "img",
511
+ {
512
+ src: u,
513
+ alt: s,
514
+ className: "max-h-[70vh] max-w-full rounded-lg object-contain shadow-lg"
515
+ }
516
+ ) }) : o === "video" && u ? /* @__PURE__ */ a("div", { className: "flex min-h-[240px] items-center justify-center bg-neutral-950 p-4", children: /* @__PURE__ */ a("video", { controls: !0, className: "max-h-[70vh] max-w-full rounded-lg shadow-lg", src: u, children: "Video" }) }) : o === "audio" && u ? /* @__PURE__ */ f("div", { className: "flex min-h-[200px] flex-col items-center justify-center gap-4 p-8", children: [
517
+ /* @__PURE__ */ a("p", { className: "text-sm font-medium", children: s }),
518
+ /* @__PURE__ */ a("audio", { controls: !0, className: "w-full max-w-md", src: u, children: "Audio" })
519
+ ] }) : o === "text" ? /* @__PURE__ */ a("div", { className: "max-h-[70vh] overflow-auto p-4", children: /* @__PURE__ */ a("pre", { className: "whitespace-pre-wrap rounded-lg bg-muted p-4 font-mono text-sm", children: g || c.emptyText || "(empty)" }) }) : /* @__PURE__ */ f("div", { className: "flex min-h-[240px] flex-col items-center justify-center gap-4 p-8 text-center", children: [
520
+ /* @__PURE__ */ a(Y, { className: "h-12 w-12 text-muted-foreground" }),
521
+ /* @__PURE__ */ f("div", { children: [
522
+ /* @__PURE__ */ a("p", { className: "font-medium", children: s }),
523
+ /* @__PURE__ */ a("p", { className: "mt-1 text-sm text-muted-foreground", children: c.downloadOnly ?? "Preview is not available for this file type." })
524
+ ] }),
525
+ l && /* @__PURE__ */ f(
526
+ "button",
527
+ {
528
+ type: "button",
529
+ onClick: () => void l(),
530
+ className: "inline-flex items-center gap-2 rounded-lg bg-rose-600 px-4 py-2 text-sm font-medium text-white hover:bg-rose-700",
531
+ children: [
532
+ /* @__PURE__ */ a(oe, { className: "h-4 w-4" }),
533
+ c.download ?? "Download"
534
+ ]
535
+ }
536
+ )
537
+ ] });
538
+ }
539
+ function De({
540
+ client: e,
541
+ storageFileId: t,
542
+ copyLabel: r = "Copy link",
543
+ openLabel: n = "Open share link",
544
+ expiryHint: l = "Link valid ~1 hour",
545
+ className: c = "",
546
+ onError: o
547
+ }) {
548
+ const { copyLink: i, openShareTab: s, loading: u } = ke(e, o), [m, g] = p(!1);
549
+ if (!t?.trim()) return null;
550
+ const d = u || !e;
551
+ async function h() {
552
+ await i(t) && (g(!0), window.setTimeout(() => g(!1), 2e3));
553
+ }
554
+ return /* @__PURE__ */ f("div", { className: `flex items-center gap-1 ${c}`, children: [
555
+ /* @__PURE__ */ a(
556
+ "button",
557
+ {
558
+ type: "button",
559
+ disabled: d,
560
+ title: m ? "Copied" : e ? l : "Session not ready",
561
+ onClick: () => void h(),
562
+ className: "rounded-lg border border-border p-2 text-muted-foreground hover:bg-accent disabled:opacity-60",
563
+ "aria-label": r,
564
+ children: m ? /* @__PURE__ */ a(ie, { className: "h-4 w-4 text-emerald-600" }) : /* @__PURE__ */ a(ae, { className: "h-4 w-4" })
565
+ }
566
+ ),
567
+ /* @__PURE__ */ a(
568
+ "button",
569
+ {
570
+ type: "button",
571
+ disabled: d,
572
+ title: e ? l : "Session not ready",
573
+ onClick: () => void s(t),
574
+ className: "rounded-lg border border-border p-2 text-muted-foreground hover:bg-accent disabled:opacity-60",
575
+ "aria-label": n,
576
+ children: /* @__PURE__ */ a(le, { className: "h-4 w-4" })
577
+ }
578
+ )
579
+ ] });
580
+ }
581
+ export {
582
+ Be as AssetThumbnail,
583
+ De as CopyStorageLinkButton,
584
+ Se as StorageImage,
585
+ Le as StoragePreviewContent,
586
+ Pe as StorageVideo,
587
+ _e as contentUrlFromUpload,
588
+ me as copyTextToClipboard,
589
+ Te as createPlatformStorageHelpers,
590
+ B as fetchAuthenticatedBlobUrl,
591
+ C as inferAssetPreviewKind,
592
+ ye as inferMimeType,
593
+ W as isAuthenticatedStorageContentUrl,
594
+ xe as isImagePreviewKind,
595
+ he as openUrlInNewTab,
596
+ D as pickStorageDisplayUrl,
597
+ L as resolveAuthenticatedBlobUrls,
598
+ U as resolveShareablePublicUrl,
599
+ ue as resolveShareablePublicUrls,
600
+ G as unwrapStorageFileRecord,
601
+ je as useAuthenticatedStorageBlobs,
602
+ Ae as useImageThumbnailBlobs,
603
+ ke as useShareableStorageLink
604
+ };
605
+ //# sourceMappingURL=storage.js.map