@declarion/react 0.1.91 → 0.1.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/{DraggableChildrenTable-BNjHMCeC.js → DraggableChildrenTable-IfspXSFA.js} +41 -41
- package/dist-lib/{DraggableChildrenTable-BNjHMCeC.js.map → DraggableChildrenTable-IfspXSFA.js.map} +1 -1
- package/dist-lib/Grid-C69-4exi.js +405 -0
- package/dist-lib/Grid-C69-4exi.js.map +1 -0
- package/dist-lib/api/data.d.ts +1 -0
- package/dist-lib/api/events.d.ts +14 -0
- package/dist-lib/components/detail-layout/AssociatedBlock.d.ts +4 -1
- package/dist-lib/components/file-widgets/helpers.d.ts +2 -0
- package/dist-lib/components/file-widgets/useEmbedFileSrc.d.ts +42 -0
- package/dist-lib/declarion-react.css +1 -1
- package/dist-lib/embed/EmbedAuthBootstrap.d.ts +8 -0
- package/dist-lib/embed/EmbedContext.d.ts +50 -0
- package/dist-lib/embed/EmbedDirtyReporter.d.ts +10 -0
- package/dist-lib/embed/EmbedLocationReporter.d.ts +8 -0
- package/dist-lib/embed/EmbedResizeReporter.d.ts +6 -0
- package/dist-lib/embed/EmbedUnsavedGuard.d.ts +7 -0
- package/dist-lib/embed/embed-dirty.d.ts +24 -0
- package/dist-lib/embed/embed-nav-guard.d.ts +20 -0
- package/dist-lib/embed/file-src.d.ts +63 -0
- package/dist-lib/embed/handshake.d.ts +57 -0
- package/dist-lib/embed/index.d.ts +15 -0
- package/dist-lib/embed/params.d.ts +75 -0
- package/dist-lib/embed/protocol.d.ts +138 -0
- package/dist-lib/embed/screen-location.d.ts +20 -0
- package/dist-lib/embed/theme.d.ts +34 -0
- package/dist-lib/embed/token.d.ts +57 -0
- package/dist-lib/embed/useEmbedNavigate.d.ts +27 -0
- package/dist-lib/index.js +4678 -4261
- package/dist-lib/index.js.map +1 -1
- package/dist-lib/{useUserLocale-DyXRSWj9.js → useUserLocale-GBIXbEE6.js} +1656 -1659
- package/dist-lib/useUserLocale-GBIXbEE6.js.map +1 -0
- package/dist-lib/value-DFpIiSZ-.js +739 -0
- package/dist-lib/value-DFpIiSZ-.js.map +1 -0
- package/package.json +1 -1
- package/dist-lib/Grid-BJAiAeHo.js +0 -405
- package/dist-lib/Grid-BJAiAeHo.js.map +0 -1
- package/dist-lib/useUserLocale-DyXRSWj9.js.map +0 -1
- package/dist-lib/value-Bhy_PJo2.js +0 -535
- package/dist-lib/value-Bhy_PJo2.js.map +0 -1
|
@@ -1,535 +0,0 @@
|
|
|
1
|
-
import { createContext as e, useCallback as t, useContext as n, useMemo as r, useRef as i } from "react";
|
|
2
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
3
|
-
//#region src/types/api.ts
|
|
4
|
-
var o = class extends Error {
|
|
5
|
-
status;
|
|
6
|
-
code;
|
|
7
|
-
index;
|
|
8
|
-
raw;
|
|
9
|
-
constructor(e, t, n, r, i) {
|
|
10
|
-
super(t), this.name = "ApiError", this.status = e, this.code = n, this.index = r, this.raw = i;
|
|
11
|
-
}
|
|
12
|
-
}, s = "/", c = "/login", l = "/signup", u = "https://declarion.local";
|
|
13
|
-
function ee(e) {
|
|
14
|
-
let t = e.split(/[?#]/, 1)[0];
|
|
15
|
-
return t === c || t.startsWith(`${c}/`) || t === l || t.startsWith(`${l}/`);
|
|
16
|
-
}
|
|
17
|
-
function d(e) {
|
|
18
|
-
if (!e) return s;
|
|
19
|
-
let t = e.toLowerCase();
|
|
20
|
-
if (!e.startsWith("/") || e.startsWith("//") || e.includes("\\") || t.includes("%5c")) return s;
|
|
21
|
-
try {
|
|
22
|
-
let t = new URL(e, u);
|
|
23
|
-
if (t.origin !== u) return s;
|
|
24
|
-
let n = `${t.pathname}${t.search}${t.hash}`;
|
|
25
|
-
return !n.startsWith("/") || n.startsWith("//") || n.includes("\\") ? s : n || s;
|
|
26
|
-
} catch {
|
|
27
|
-
return s;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function f(e) {
|
|
31
|
-
let t = d(e);
|
|
32
|
-
return t === s || ee(t) ? c : `${c}?next=${encodeURIComponent(t)}`;
|
|
33
|
-
}
|
|
34
|
-
function p() {
|
|
35
|
-
if (typeof window > "u") return c;
|
|
36
|
-
let { pathname: e, search: t, hash: n } = window.location;
|
|
37
|
-
return f(`${e}${t}${n}`);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/lib/versionTracker.ts
|
|
41
|
-
var m = "X-Declarion-Version", h = "declarion-version";
|
|
42
|
-
function g() {
|
|
43
|
-
if (typeof BroadcastChannel > "u") return null;
|
|
44
|
-
try {
|
|
45
|
-
return new BroadcastChannel(h);
|
|
46
|
-
} catch {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
var _ = {
|
|
51
|
-
firstSeen: null,
|
|
52
|
-
firstComponents: null,
|
|
53
|
-
hasReportedDrift: !1,
|
|
54
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
55
|
-
channel: null
|
|
56
|
-
};
|
|
57
|
-
function v() {
|
|
58
|
-
_.channel || typeof BroadcastChannel > "u" || (_.channel = g(), _.channel && _.channel.addEventListener("message", (e) => {
|
|
59
|
-
let t = e.data;
|
|
60
|
-
if (!(!t || t.type !== "drift" || !t.delta) && !_.hasReportedDrift) {
|
|
61
|
-
_.hasReportedDrift = !0;
|
|
62
|
-
for (let e of _.listeners) e(t.delta);
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
function y(e) {
|
|
67
|
-
if (v(), !e) return;
|
|
68
|
-
let t = e.get(m);
|
|
69
|
-
if (t) {
|
|
70
|
-
if (!_.firstSeen) {
|
|
71
|
-
_.firstSeen = t;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
t !== _.firstSeen && (_.hasReportedDrift || b().catch(() => {
|
|
75
|
-
S({
|
|
76
|
-
kind: "unknown",
|
|
77
|
-
observed: t
|
|
78
|
-
});
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async function b() {
|
|
83
|
-
v();
|
|
84
|
-
let e;
|
|
85
|
-
try {
|
|
86
|
-
let t = {};
|
|
87
|
-
_.firstSeen && (t["If-None-Match"] = `"${_.firstSeen}"`), e = await fetch("/api/version", {
|
|
88
|
-
method: "GET",
|
|
89
|
-
credentials: "include",
|
|
90
|
-
headers: t
|
|
91
|
-
});
|
|
92
|
-
} catch {
|
|
93
|
-
throw Error("version probe network error");
|
|
94
|
-
}
|
|
95
|
-
if (e.status === 304) return;
|
|
96
|
-
if (!e.ok) throw Error(`version probe ${e.status}`);
|
|
97
|
-
let t;
|
|
98
|
-
try {
|
|
99
|
-
t = await e.json();
|
|
100
|
-
} catch {
|
|
101
|
-
throw Error("version probe malformed body");
|
|
102
|
-
}
|
|
103
|
-
let n = t.fingerprint;
|
|
104
|
-
if (typeof n != "string" || n === "") throw Error("version probe missing fingerprint");
|
|
105
|
-
let r = typeof t.schema_fingerprint == "string" && typeof t.asset_fingerprint == "string" && typeof t.binary_fingerprint == "string" ? {
|
|
106
|
-
schema: t.schema_fingerprint,
|
|
107
|
-
asset: t.asset_fingerprint,
|
|
108
|
-
binary: t.binary_fingerprint
|
|
109
|
-
} : void 0;
|
|
110
|
-
_.firstSeen ||= n, !_.firstComponents && r && n === _.firstSeen && (_.firstComponents = r), n !== _.firstSeen && S({
|
|
111
|
-
kind: x(_.firstComponents, r),
|
|
112
|
-
observed: n,
|
|
113
|
-
components: r
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function x(e, t) {
|
|
117
|
-
if (!e || !t) return "unknown";
|
|
118
|
-
let n = e.schema !== t.schema, r = e.asset !== t.asset, i = e.binary !== t.binary;
|
|
119
|
-
return n && !r && !i ? "schema-only" : r || i ? "asset-or-binary" : "unknown";
|
|
120
|
-
}
|
|
121
|
-
function S(e) {
|
|
122
|
-
if (!_.hasReportedDrift) {
|
|
123
|
-
_.hasReportedDrift = !0;
|
|
124
|
-
for (let t of _.listeners) t(e);
|
|
125
|
-
if (_.channel) try {
|
|
126
|
-
_.channel.postMessage({
|
|
127
|
-
type: "drift",
|
|
128
|
-
delta: e
|
|
129
|
-
});
|
|
130
|
-
} catch {}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function C(e) {
|
|
134
|
-
return _.listeners.add(e), () => {
|
|
135
|
-
_.listeners.delete(e);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/api/client.ts
|
|
140
|
-
var w = (e) => JSON.stringify(e ?? {}), T = null, E = class extends Error {
|
|
141
|
-
status;
|
|
142
|
-
constructor(e) {
|
|
143
|
-
super(`refresh failed terminally (${e})`), this.status = e, this.name = "RefreshDeadError";
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
async function te() {
|
|
147
|
-
let e = {
|
|
148
|
-
method: "POST",
|
|
149
|
-
credentials: "include",
|
|
150
|
-
headers: { "Content-Type": "application/json" },
|
|
151
|
-
body: w({})
|
|
152
|
-
}, t = await fetch("/api/actions/auth.refresh", e);
|
|
153
|
-
if (t.status === 429) {
|
|
154
|
-
let n = parseInt(t.headers.get("Retry-After") || "1", 10);
|
|
155
|
-
await new Promise((e) => setTimeout(e, n * 1e3));
|
|
156
|
-
let r = await fetch("/api/actions/auth.refresh", e);
|
|
157
|
-
if (!r.ok) throw new E(r.status);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (!t.ok) throw new E(t.status);
|
|
161
|
-
}
|
|
162
|
-
async function D() {
|
|
163
|
-
return T || (T = te().finally(() => {
|
|
164
|
-
T = null;
|
|
165
|
-
}), T);
|
|
166
|
-
}
|
|
167
|
-
var O = () => {
|
|
168
|
-
if (typeof window > "u") return;
|
|
169
|
-
let { pathname: e } = window.location;
|
|
170
|
-
e.startsWith("/login") || e.startsWith("/signup") || e === "/reset" || e === "/forgot" || (window.location.href = p());
|
|
171
|
-
};
|
|
172
|
-
function k() {
|
|
173
|
-
return O;
|
|
174
|
-
}
|
|
175
|
-
var A = ({ status: e, code: t, message: n }) => {
|
|
176
|
-
console.error(`[API ${e}] ${t}: ${n}`);
|
|
177
|
-
};
|
|
178
|
-
function j(e, t, n) {
|
|
179
|
-
let r = new Headers(e);
|
|
180
|
-
return !r.has("Content-Type") && t && r.set("Content-Type", "application/json"), n.setAccept && !r.has("Accept") && r.set("Accept", "*/*"), r;
|
|
181
|
-
}
|
|
182
|
-
async function M(e, t, n, r) {
|
|
183
|
-
let i = j(t.headers, !!t.body, n), a = await fetch(e, {
|
|
184
|
-
...t,
|
|
185
|
-
headers: i,
|
|
186
|
-
credentials: "include"
|
|
187
|
-
});
|
|
188
|
-
if (y(a.headers), !a.ok) {
|
|
189
|
-
let i = "Request failed", s = "UNKNOWN", c, l;
|
|
190
|
-
try {
|
|
191
|
-
l = await a.json();
|
|
192
|
-
let e = l;
|
|
193
|
-
e && e.error && (i = e.error.message, s = e.error.code, e.index != null && (c = e.index));
|
|
194
|
-
} catch {}
|
|
195
|
-
if (a.status === 401 && (s === "TOKEN_REFRESH_NEEDED" || s === "UNAUTHORIZED")) try {
|
|
196
|
-
await D();
|
|
197
|
-
let i = j(t.headers, !!t.body, n), a = await fetch(e, {
|
|
198
|
-
...t,
|
|
199
|
-
headers: i,
|
|
200
|
-
credentials: "include"
|
|
201
|
-
});
|
|
202
|
-
if (!a.ok) {
|
|
203
|
-
O();
|
|
204
|
-
let e = await a.json().catch(() => ({ error: {
|
|
205
|
-
message: "Request failed",
|
|
206
|
-
code: "UNKNOWN"
|
|
207
|
-
} }));
|
|
208
|
-
throw new o(a.status, e.error.message, e.error.code, e.index);
|
|
209
|
-
}
|
|
210
|
-
return r(a);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
throw e instanceof o ? e : (O(), new o(401, i, s, c));
|
|
213
|
-
}
|
|
214
|
-
throw a.status === 401 && O(), A({
|
|
215
|
-
status: a.status,
|
|
216
|
-
code: s,
|
|
217
|
-
message: i
|
|
218
|
-
}), new o(a.status, i, s, c, l);
|
|
219
|
-
}
|
|
220
|
-
return r(a);
|
|
221
|
-
}
|
|
222
|
-
function ne(e) {
|
|
223
|
-
return e.status === 204 ? Promise.resolve(void 0) : e.json();
|
|
224
|
-
}
|
|
225
|
-
async function N(e, t = {}) {
|
|
226
|
-
return M(e, t, { setAccept: !1 }, ne);
|
|
227
|
-
}
|
|
228
|
-
async function P(e) {
|
|
229
|
-
return {
|
|
230
|
-
blob: await e.blob(),
|
|
231
|
-
filename: I(e.headers),
|
|
232
|
-
headers: e.headers
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
async function F(e, t = {}) {
|
|
236
|
-
return M(e, t, { setAccept: !0 }, P);
|
|
237
|
-
}
|
|
238
|
-
function I(e) {
|
|
239
|
-
let t = e.get("Content-Disposition");
|
|
240
|
-
if (!t) return "";
|
|
241
|
-
let n = t.match(/filename\*\s*=\s*([^']*)'([^']*)'([^;]+)/i);
|
|
242
|
-
if (n) try {
|
|
243
|
-
return decodeURIComponent(n[3].trim());
|
|
244
|
-
} catch {}
|
|
245
|
-
let r = t.match(/filename\s*=\s*("([^"]+)"|([^;]+))/i);
|
|
246
|
-
return r ? (r[2] ?? r[3] ?? "").trim() : "";
|
|
247
|
-
}
|
|
248
|
-
async function L(e, t = {}) {
|
|
249
|
-
return (await N(`/api/actions/${encodeURIComponent(e)}`, {
|
|
250
|
-
method: "POST",
|
|
251
|
-
body: w(t)
|
|
252
|
-
})).result;
|
|
253
|
-
}
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/components/file-widgets/upload.ts
|
|
256
|
-
var R = class extends Error {
|
|
257
|
-
code;
|
|
258
|
-
status;
|
|
259
|
-
constructor(e, t, n) {
|
|
260
|
-
super(n), this.code = t, this.status = e;
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
async function z(e) {
|
|
264
|
-
try {
|
|
265
|
-
return await B(e);
|
|
266
|
-
} catch (t) {
|
|
267
|
-
if (!(t instanceof R && t.status === 401 && (t.code === "TOKEN_REFRESH_NEEDED" || t.code === "UNAUTHORIZED"))) throw t;
|
|
268
|
-
try {
|
|
269
|
-
await D();
|
|
270
|
-
} catch {
|
|
271
|
-
throw k()(), t;
|
|
272
|
-
}
|
|
273
|
-
try {
|
|
274
|
-
return await B(e);
|
|
275
|
-
} catch (e) {
|
|
276
|
-
throw e instanceof R && e.status === 401 && k()(), e;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function B(e) {
|
|
281
|
-
let { file: t, entityCode: n, fieldCode: r, slotCode: i, onProgress: a, signal: o } = e;
|
|
282
|
-
return new Promise((e, s) => {
|
|
283
|
-
let c = new XMLHttpRequest();
|
|
284
|
-
if (c.open("POST", V(n, r, i)), c.withCredentials = !0, c.upload.onprogress = (e) => {
|
|
285
|
-
if (!a) return;
|
|
286
|
-
let n = e.lengthComputable ? e.total : t.size, r = n > 0 ? Math.min(100, Math.round(e.loaded / n * 100)) : 0;
|
|
287
|
-
a({
|
|
288
|
-
loaded: e.loaded,
|
|
289
|
-
total: n,
|
|
290
|
-
pct: r
|
|
291
|
-
});
|
|
292
|
-
}, c.onload = () => {
|
|
293
|
-
let t = c.responseText || "", n = null;
|
|
294
|
-
try {
|
|
295
|
-
n = t ? JSON.parse(t) : null;
|
|
296
|
-
} catch {}
|
|
297
|
-
if (c.status >= 200 && c.status < 300) {
|
|
298
|
-
let t = H(n);
|
|
299
|
-
if (!t || !t.id) {
|
|
300
|
-
s(new R(c.status, "BAD_RESPONSE", "Upload returned no file id"));
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
e(t);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
let r = n, i = r?.error?.code ?? "UPLOAD_FAILED", a = r?.error?.message ?? `Upload failed (${c.status})`;
|
|
307
|
-
s(new R(c.status, i, a));
|
|
308
|
-
}, c.onerror = () => {
|
|
309
|
-
s(new R(0, "NETWORK_ERROR", "Network error during upload"));
|
|
310
|
-
}, c.onabort = () => {
|
|
311
|
-
s(new R(0, "ABORTED", "Upload aborted"));
|
|
312
|
-
}, o) {
|
|
313
|
-
if (o.aborted) {
|
|
314
|
-
c.abort(), s(new R(0, "ABORTED", "Upload aborted"));
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
o.addEventListener("abort", () => c.abort(), { once: !0 });
|
|
318
|
-
}
|
|
319
|
-
let l = new FormData();
|
|
320
|
-
l.append("file", t, t.name), c.send(l);
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
function V(e, t, n) {
|
|
324
|
-
let r = new URLSearchParams();
|
|
325
|
-
e && t && (r.set("entity_code", e), r.set("field_code", t), n && r.set("slot_code", n));
|
|
326
|
-
let i = r.toString();
|
|
327
|
-
return i ? `/api/files/upload?${i}` : "/api/files/upload";
|
|
328
|
-
}
|
|
329
|
-
function H(e) {
|
|
330
|
-
return W(e) ? W(e.result) ? H(e.result) : W(e.file) ? U(e.file) : typeof e.id == "string" ? e : null : null;
|
|
331
|
-
}
|
|
332
|
-
function U(e) {
|
|
333
|
-
let t = G(e.file_id);
|
|
334
|
-
return t ? {
|
|
335
|
-
id: t,
|
|
336
|
-
filename: G(e.filename_original) ?? G(e.filename_normalized) ?? t,
|
|
337
|
-
content_type: G(e.content_type) ?? "application/octet-stream",
|
|
338
|
-
size_bytes: K(e.size_bytes) ?? 0,
|
|
339
|
-
sha256: G(e.sha256) ?? "",
|
|
340
|
-
dedup: q(e.dedup)
|
|
341
|
-
} : null;
|
|
342
|
-
}
|
|
343
|
-
function W(e) {
|
|
344
|
-
return typeof e == "object" && !!e;
|
|
345
|
-
}
|
|
346
|
-
function G(e) {
|
|
347
|
-
return typeof e == "string" ? e : void 0;
|
|
348
|
-
}
|
|
349
|
-
function K(e) {
|
|
350
|
-
return typeof e == "number" ? e : void 0;
|
|
351
|
-
}
|
|
352
|
-
function q(e) {
|
|
353
|
-
return typeof e == "boolean" ? e : void 0;
|
|
354
|
-
}
|
|
355
|
-
async function J(e) {
|
|
356
|
-
await L("files.discard", { file_id: e });
|
|
357
|
-
}
|
|
358
|
-
function Y(e, t, n) {
|
|
359
|
-
if (n && e.size > n) return {
|
|
360
|
-
code: "FILE_TOO_LARGE",
|
|
361
|
-
message: `File is ${X(e.size)}, max ${X(n)}`
|
|
362
|
-
};
|
|
363
|
-
if (t && t.length > 0) {
|
|
364
|
-
let n = e.type || "application/octet-stream";
|
|
365
|
-
if (!t.some((e) => re(e, n))) return {
|
|
366
|
-
code: "MIME_NOT_ACCEPTED",
|
|
367
|
-
message: `File type ${n} is not accepted`
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
function re(e, t) {
|
|
373
|
-
if (e === "*/*" || e === "*") return !0;
|
|
374
|
-
if (e.endsWith("/*")) {
|
|
375
|
-
let n = e.slice(0, e.length - 1);
|
|
376
|
-
return t.startsWith(n);
|
|
377
|
-
}
|
|
378
|
-
return e === t;
|
|
379
|
-
}
|
|
380
|
-
function X(e) {
|
|
381
|
-
if (e < 1024) return `${e} B`;
|
|
382
|
-
let t = [
|
|
383
|
-
"KB",
|
|
384
|
-
"MB",
|
|
385
|
-
"GB"
|
|
386
|
-
], n = e / 1024, r = 0;
|
|
387
|
-
for (; n >= 1024 && r < t.length - 1;) n /= 1024, r++;
|
|
388
|
-
return `${n.toFixed(n >= 10 ? 0 : 1)} ${t[r]}`;
|
|
389
|
-
}
|
|
390
|
-
//#endregion
|
|
391
|
-
//#region src/components/file-widgets/helpers.ts
|
|
392
|
-
function ie() {
|
|
393
|
-
return typeof navigator > "u" ? ["en"] : (navigator.languages?.length ? navigator.languages : [navigator.language]).filter((e) => typeof e == "string" && e.length > 0);
|
|
394
|
-
}
|
|
395
|
-
function ae(e, t) {
|
|
396
|
-
for (let n of t) {
|
|
397
|
-
if (e[n]) return e[n];
|
|
398
|
-
let t = n.split("-")[0];
|
|
399
|
-
if (t && e[t]) return e[t];
|
|
400
|
-
}
|
|
401
|
-
for (let t of Object.values(e)) if (typeof t == "string" && t.length > 0) return t;
|
|
402
|
-
}
|
|
403
|
-
function oe(e, t, n) {
|
|
404
|
-
if (t) return t;
|
|
405
|
-
let r = e?.metadata?.alt_text;
|
|
406
|
-
if (typeof r == "string" && r.length > 0) return r;
|
|
407
|
-
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
408
|
-
let e = ae(Object.fromEntries(Object.entries(r).filter((e) => e[0].length > 0 && typeof e[1] == "string")), ie());
|
|
409
|
-
if (e) return e;
|
|
410
|
-
}
|
|
411
|
-
return n;
|
|
412
|
-
}
|
|
413
|
-
var se = new Set([
|
|
414
|
-
"image/png",
|
|
415
|
-
"image/jpeg",
|
|
416
|
-
"image/webp",
|
|
417
|
-
"image/gif",
|
|
418
|
-
"image/avif",
|
|
419
|
-
"application/pdf"
|
|
420
|
-
]);
|
|
421
|
-
function ce(e) {
|
|
422
|
-
let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
423
|
-
return se.has(t);
|
|
424
|
-
}
|
|
425
|
-
function le(e) {
|
|
426
|
-
return e.url ?? e.presigned_url;
|
|
427
|
-
}
|
|
428
|
-
function ue(e) {
|
|
429
|
-
return e.url ? fe(e.url, "attachment") : e.presigned_url;
|
|
430
|
-
}
|
|
431
|
-
function de(e, t) {
|
|
432
|
-
if (!e) return;
|
|
433
|
-
let n = e.derivations ?? {};
|
|
434
|
-
return t && n[t] ? n[t] : n.thumb_200 ?? n.thumb_300 ?? e.url ?? e.presigned_url;
|
|
435
|
-
}
|
|
436
|
-
function fe(e, t) {
|
|
437
|
-
try {
|
|
438
|
-
let n = new URL(e, typeof window < "u" ? window.location.origin : "http://localhost");
|
|
439
|
-
return n.searchParams.set("disposition", t), /^https?:\/\//i.test(e) ? n.toString() : `${n.pathname}${n.search}${n.hash}`;
|
|
440
|
-
} catch {
|
|
441
|
-
return `${e}${e.includes("?") ? "&" : "?"}disposition=${t}`;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
function pe(e) {
|
|
445
|
-
let t = e?.metadata?.focal_point;
|
|
446
|
-
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
447
|
-
let n = t, r = typeof n.x == "number" ? n.x : NaN, i = typeof n.y == "number" ? n.y : NaN;
|
|
448
|
-
return !Number.isFinite(r) || !Number.isFinite(i) || r < 0 || r > 1 || i < 0 || i > 1 ? null : {
|
|
449
|
-
x: r,
|
|
450
|
-
y: i
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
function me(e) {
|
|
454
|
-
if (e) return `${e.x * 100}% ${e.y * 100}%`;
|
|
455
|
-
}
|
|
456
|
-
function he(e, t) {
|
|
457
|
-
return {
|
|
458
|
-
...e,
|
|
459
|
-
metadata: {
|
|
460
|
-
...e.metadata ?? {},
|
|
461
|
-
focal_point: t
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
//#endregion
|
|
466
|
-
//#region src/components/file-widgets/draft-scope.tsx
|
|
467
|
-
var Z = e({
|
|
468
|
-
registerDraft() {},
|
|
469
|
-
unregisterDraft() {},
|
|
470
|
-
hasDraft() {
|
|
471
|
-
return !1;
|
|
472
|
-
},
|
|
473
|
-
flushAllDrafts: async () => {},
|
|
474
|
-
markCommitted() {}
|
|
475
|
-
});
|
|
476
|
-
function ge({ children: e }) {
|
|
477
|
-
let t = i(/* @__PURE__ */ new Map()), n = r(() => ({
|
|
478
|
-
registerDraft(e) {
|
|
479
|
-
t.current.set(e.fileId, e);
|
|
480
|
-
},
|
|
481
|
-
unregisterDraft(e) {
|
|
482
|
-
t.current.delete(e);
|
|
483
|
-
},
|
|
484
|
-
hasDraft(e) {
|
|
485
|
-
return t.current.has(e);
|
|
486
|
-
},
|
|
487
|
-
markCommitted(e) {
|
|
488
|
-
t.current.delete(e);
|
|
489
|
-
},
|
|
490
|
-
async flushAllDrafts() {
|
|
491
|
-
let e = Array.from(t.current.values());
|
|
492
|
-
t.current.clear(), await Promise.allSettled(e.map((e) => Promise.resolve(e.discard())));
|
|
493
|
-
}
|
|
494
|
-
}), []);
|
|
495
|
-
return /* @__PURE__ */ a(Z.Provider, {
|
|
496
|
-
value: n,
|
|
497
|
-
children: e
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
function Q() {
|
|
501
|
-
return n(Z);
|
|
502
|
-
}
|
|
503
|
-
function _e() {
|
|
504
|
-
let e = Q();
|
|
505
|
-
return {
|
|
506
|
-
register: t((t, n) => {
|
|
507
|
-
e.registerDraft({
|
|
508
|
-
fileId: t,
|
|
509
|
-
discard: n
|
|
510
|
-
});
|
|
511
|
-
}, [e]),
|
|
512
|
-
unregister: t((t) => {
|
|
513
|
-
e.unregisterDraft(t);
|
|
514
|
-
}, [e]),
|
|
515
|
-
markCommitted: t((t) => {
|
|
516
|
-
e.markCommitted(t);
|
|
517
|
-
}, [e]),
|
|
518
|
-
isDraft: t((t) => e.hasDraft(t), [e])
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
//#endregion
|
|
522
|
-
//#region src/components/file-widgets/value.ts
|
|
523
|
-
function $(e) {
|
|
524
|
-
return typeof e == "object" && !!e && typeof e.id == "string";
|
|
525
|
-
}
|
|
526
|
-
function ve(e) {
|
|
527
|
-
return e ? Array.isArray(e) ? e.find($) ?? null : $(e) ? e : null : null;
|
|
528
|
-
}
|
|
529
|
-
function ye(e) {
|
|
530
|
-
return e ? Array.isArray(e) ? e.filter($) : $(e) ? [e] : [] : [];
|
|
531
|
-
}
|
|
532
|
-
//#endregion
|
|
533
|
-
export { D as C, f as D, C as E, d as O, L as S, b as T, z as _, Q as a, N as b, me as c, pe as d, oe as f, X as g, J as h, _e as i, o as k, de as l, R as m, ve as n, ce as o, he as p, ge as r, ue as s, ye as t, le as u, Y as v, k as w, F as x, E as y };
|
|
534
|
-
|
|
535
|
-
//# sourceMappingURL=value-Bhy_PJo2.js.map
|