@openrails/contentkit-ui 0.103.0 → 0.103.2

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 (65) hide show
  1. package/README.md +6 -4
  2. package/dist/components/admin/content-manager.d.ts +1 -1
  3. package/dist/components/admin/content-manager.js +346 -304
  4. package/dist/components/admin/content-manager.js.map +1 -1
  5. package/dist/components/admin/page-review.js +106 -97
  6. package/dist/components/admin/page-review.js.map +1 -1
  7. package/dist/components/admin/reader-content-editor.d.ts +6 -0
  8. package/dist/components/admin/reader-content-editor.js +709 -0
  9. package/dist/components/admin/reader-content-editor.js.map +1 -0
  10. package/dist/components/admin/reader-manifest.js +120 -105
  11. package/dist/components/admin/reader-manifest.js.map +1 -1
  12. package/dist/components/content/editor-save.d.ts +32 -0
  13. package/dist/components/content/editor-save.js +51 -0
  14. package/dist/components/content/editor-save.js.map +1 -0
  15. package/dist/components/content/editors.d.ts +17 -2
  16. package/dist/components/content/editors.js +359 -328
  17. package/dist/components/content/editors.js.map +1 -1
  18. package/dist/components/content/offer-fields.d.ts +1 -1
  19. package/dist/components/content/offer-fields.js +86 -64
  20. package/dist/components/content/offer-fields.js.map +1 -1
  21. package/dist/components/content/release-date-picker.d.ts +4 -4
  22. package/dist/components/content/release-date-picker.js +106 -48
  23. package/dist/components/content/release-date-picker.js.map +1 -1
  24. package/dist/components/groups/memberships.d.ts +11 -1
  25. package/dist/components/groups/memberships.js +1 -1
  26. package/dist/components/groups/memberships.js.map +1 -1
  27. package/dist/components/media-folder-editor.d.ts +4 -0
  28. package/dist/components/media-folder-editor.js +177 -167
  29. package/dist/components/media-folder-editor.js.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/locales/admin/de.js +25 -0
  32. package/dist/locales/admin/de.js.map +1 -1
  33. package/dist/locales/admin/en.d.ts +25 -0
  34. package/dist/locales/admin/en.js +25 -0
  35. package/dist/locales/admin/en.js.map +1 -1
  36. package/dist/locales/admin/es.js +25 -0
  37. package/dist/locales/admin/es.js.map +1 -1
  38. package/dist/locales/admin/ja.js +25 -0
  39. package/dist/locales/admin/ja.js.map +1 -1
  40. package/dist/locales/admin/ko.js +25 -0
  41. package/dist/locales/admin/ko.js.map +1 -1
  42. package/dist/locales/admin/zh.js +25 -0
  43. package/dist/locales/admin/zh.js.map +1 -1
  44. package/dist/locales/discovery/de.js +1 -2
  45. package/dist/locales/discovery/de.js.map +1 -1
  46. package/dist/locales/discovery/en.d.ts +1 -2
  47. package/dist/locales/discovery/en.js +1 -2
  48. package/dist/locales/discovery/en.js.map +1 -1
  49. package/dist/locales/discovery/es.js +1 -2
  50. package/dist/locales/discovery/es.js.map +1 -1
  51. package/dist/locales/discovery/ja.js +1 -2
  52. package/dist/locales/discovery/ja.js.map +1 -1
  53. package/dist/locales/discovery/ko.js +1 -2
  54. package/dist/locales/discovery/ko.js.map +1 -1
  55. package/dist/locales/discovery/zh.js +1 -2
  56. package/dist/locales/discovery/zh.js.map +1 -1
  57. package/dist/locales/en.d.ts +26 -2
  58. package/dist/react/page-review.d.ts +1 -1
  59. package/dist/react/page-review.js +6 -5
  60. package/dist/react/page-review.js.map +1 -1
  61. package/dist/react/use-draft.d.ts +8 -0
  62. package/dist/react/use-draft.js +35 -0
  63. package/dist/react/use-draft.js.map +1 -0
  64. package/dist/styles.css +1 -1
  65. package/package.json +2 -1
@@ -0,0 +1,709 @@
1
+ import { toContentKitError as e } from "../../client/errors.js";
2
+ import { stem as t } from "../../client/media/client.js";
3
+ import { useMessages as n } from "../../i18n/context.js";
4
+ import { useErrorReporter as r, useGuarded as i } from "../../react/context.js";
5
+ import { useContentScope as ee } from "../../react/use-resource.js";
6
+ import { useContentGroups as te } from "../../react/groups.js";
7
+ import { isProcessing as ne } from "../../client/media/windows.js";
8
+ import { Button as a } from "../../ui/button.js";
9
+ import { useMediaFolder as re } from "../../react/folder.js";
10
+ import { MediaFolderEditor as ie } from "../media-folder-editor.js";
11
+ import { Badge as ae } from "../../ui/badge.js";
12
+ import { Input as o } from "../../ui/input.js";
13
+ import { Label as s } from "../../ui/label.js";
14
+ import { Select as c, SelectContent as l, SelectItem as oe, SelectTrigger as u, SelectValue as d } from "../../ui/select.js";
15
+ import { Textarea as se } from "../../ui/textarea.js";
16
+ import { ErrorLine as f, contentError as ce, useAction as le } from "../social/parts.js";
17
+ import { LoadFailed as ue, Rows as de, useConfirm as fe } from "./shell.js";
18
+ import { localInput as pe } from "../social/bans.js";
19
+ import { imageRefs as me } from "../../client/contents.js";
20
+ import { parseAttributes as he } from "../../client/group-fields.js";
21
+ import { GroupPicker as ge, labelOf as _e } from "../groups/parts.js";
22
+ import { useDraft as p } from "../../react/use-draft.js";
23
+ import { EditorSaveContext as ve, readerMediaReady as ye, useEditorSaveCoordinator as be } from "../content/editor-save.js";
24
+ import { OfferFields as xe } from "../content/offer-fields.js";
25
+ import { AttributeFields as Se, formOf as Ce } from "../groups/fields.js";
26
+ import { MembershipRow as we } from "../groups/memberships.js";
27
+ import { ReaderManifestEditor as Te } from "./reader-manifest.js";
28
+ import { usePageReview as Ee } from "../../react/page-review.js";
29
+ import { PageReview as De } from "./page-review.js";
30
+ import { RuleFields as Oe, VersionsEditor as ke, cleanRule as Ae, complete as je, versionLabel as Me } from "../content/editors.js";
31
+ import { useContent as Ne } from "../../react/contents.js";
32
+ import { contentStatus as Pe } from "./content-manager.js";
33
+ import { useEffect as Fe, useId as Ie, useMemo as m, useRef as Le, useState as h } from "react";
34
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
35
+ import { StarIcon as Re } from "@hugeicons/core-free-icons";
36
+ import { HugeiconsIcon as ze } from "@hugeicons/react";
37
+ //#region src/components/admin/reader-content-editor.tsx
38
+ var v = () => ({
39
+ title: "",
40
+ slug: "",
41
+ description: "",
42
+ body: ""
43
+ }), Be = (e, t) => e?.text?.[t] ?? (e?.language === t ? {
44
+ title: e.title,
45
+ slug: e.slug,
46
+ description: e.description,
47
+ body: e.body
48
+ } : v()), Ve = (e) => e.replace(/\.[^.]+$/, "").replace(/[_-]+/g, " ").trim().slice(0, 300), He = (e) => ({
49
+ ...e,
50
+ title: e.title.trim(),
51
+ slug: e.slug?.trim() || void 0,
52
+ description: e.description?.trim()
53
+ }), y = class extends Error {};
54
+ function b({ title: e, children: t, className: n = "" }) {
55
+ return /* @__PURE__ */ _("section", {
56
+ className: `grid min-w-0 content-start gap-4 rounded-xl border border-border bg-card p-4 ${n}`,
57
+ children: [/* @__PURE__ */ g("h2", {
58
+ className: "text-base font-semibold",
59
+ children: e
60
+ }), t]
61
+ });
62
+ }
63
+ function x(x) {
64
+ let { client: S, scope: Ue } = ee(x.client), We = n(), { t: C } = We, w = Ie(), Ge = i(), Ke = r(x.onError), T = x.model, E = T.kinds[x.kind], qe = x.languages?.map((e) => typeof e == "string" ? {
65
+ value: e,
66
+ label: e
67
+ } : e), D = qe?.length ? qe : T.languages.map((e) => ({
68
+ value: e,
69
+ label: e
70
+ })), Je = D.map((e) => e.value).join("|"), [O, Ye] = h(D[0]?.value ?? "en"), [Xe, Ze] = h(""), k = Ne(x.id, x.kind, O, {
71
+ client: S,
72
+ version: Xe || void 0
73
+ }), [Qe, $e] = h(null), A = k.content ?? Qe, j = Le({
74
+ item: A,
75
+ scope: Ue,
76
+ alive: !0
77
+ });
78
+ j.current.item = A, Fe(() => {
79
+ let e = j.current;
80
+ return e.alive = !0, () => {
81
+ e.alive = !1;
82
+ };
83
+ }, []);
84
+ let M = () => j.current.alive && j.current.scope === Ue, N = Le(null), [et, tt] = h(!1), [P, nt] = h(!1), [rt, F] = h(), [it, at] = h(""), I = p(m(() => ({ at: A?.publish_at ? pe(new Date(A.publish_at)) : "" }), [A?.publish_at])), L = I.value.at, ot = (e) => I.edit({ at: e }), [st, ct] = h(!1), [lt, ut] = h([]), [dt, ft] = h(!1), [pt, mt] = h(!1), R = m(() => [...A?.versions ?? []].sort((e, t) => e.position - t.position), [A?.versions]), z = R.find((e) => e.id === Xe) ?? R[0];
85
+ Fe(() => {
86
+ dt && z && ut((e) => e.includes(z.id) ? e : [...e, z.id]);
87
+ }, [dt, z]);
88
+ let B = te(A?.id, {
89
+ language: O,
90
+ client: S
91
+ }), ht = m(() => new Map(B.entities), [B.entities]), [gt, _t] = h(/* @__PURE__ */ new Map()), vt = m(() => new Map([...gt, ...ht]), [ht, gt]), V = m(() => E.entities ?? [], [E.entities]), H = p(m(() => Object.fromEntries(Je.split("|").map((e) => [e, Be(A, e)])), [A, Je])), U = p(m(() => ({
92
+ listing: A?.listing ?? "listed",
93
+ comments: A?.comments ?? "open",
94
+ attributes: Ce(E.attributes ?? {}, A?.attributes ?? {}),
95
+ access: A?.access ?? { level: "public" }
96
+ }), [
97
+ A?.listing,
98
+ A?.comments,
99
+ A?.attributes,
100
+ A?.access,
101
+ E.attributes
102
+ ])), W = p(m(() => ({ memberships: B.memberships.filter((e) => V.includes(B.entities.get(e.group_id ?? "")?.kind ?? "")) }), [
103
+ B.memberships,
104
+ B.entities,
105
+ V
106
+ ])), G = be(), K = Le({
107
+ texts: H,
108
+ details: U,
109
+ associations: W,
110
+ language: O
111
+ });
112
+ K.current = {
113
+ texts: H,
114
+ details: U,
115
+ associations: W,
116
+ language: O
117
+ };
118
+ let q = H.value[O] ?? v(), yt = (q.body ?? "").replace(me(), (e, t) => k.imageSrc(t) ?? e), J = (e) => H.edit((t) => ({
119
+ ...t,
120
+ [O]: {
121
+ ...t[O] ?? v(),
122
+ ...e
123
+ }
124
+ })), bt = (t) => {
125
+ M() && (F(t instanceof y ? t.message : t), t instanceof y || Ke(e(t), "content.save"));
126
+ }, xt = async (e) => {
127
+ if (j.current.item) return j.current.item;
128
+ if (N.current) return N.current;
129
+ tt(!0);
130
+ let t = K.current.language, n = K.current.texts.get()[t] ?? v(), r = n.title.trim() || Ve(e ?? "") || C("readerEditor.untitled");
131
+ n.title.trim() || K.current.texts.edit((e) => ({
132
+ ...e,
133
+ [t]: {
134
+ ...e[t] ?? v(),
135
+ title: r
136
+ }
137
+ }));
138
+ let i = {
139
+ kind: x.kind,
140
+ text: { [t]: {
141
+ ...n,
142
+ title: r
143
+ } },
144
+ owner_group_id: x.ownerGroup
145
+ };
146
+ return N.current = k.create(i).then((e) => (j.current.item = e, M() && ($e(e), x.onCreated?.(e)), e)).finally(() => {
147
+ N.current = null, M() && tt(!1);
148
+ }), N.current;
149
+ }, Y = m(() => A && z ? {
150
+ kind: x.kind,
151
+ id: A.id,
152
+ version: z.id
153
+ } : null, [
154
+ x.kind,
155
+ A,
156
+ z
157
+ ]), X = le("content.save", x.onError), Z = le("offer.save", x.onError), Q = le("content.save", x.onError), $ = re(Y, {
158
+ commit: z?.live ? "manual" : "auto",
159
+ client: S,
160
+ onError: x.onError
161
+ }), St = Le($);
162
+ St.current = $;
163
+ let Ct = $.read.read?.files ?? [], wt = Ee(A?.id, z?.id, { client: S }), Tt = !!$.error || $.queue.items.some((e) => e.status === "failed") || Ct.some((e) => e.failed), Et = Ct.some(ne), Dt = wt.review?.selected ?? 0, Ot = $.busy || et || Et || Tt || wt.loading || !!wt.error || Dt === 0 || G.pending || X.pending || Z.pending, kt = (e) => {
164
+ let t = [...e];
165
+ t.length && ($.add(t), xt(t.find((e) => /\.zip$/i.test(e.name))?.name ?? t[0]?.name).catch(bt));
166
+ }, At = I.dirty.length > 0 || H.dirty.length > 0 || U.dirty.length > 0 || W.dirty.length > 0 || G.dirty;
167
+ Fe(() => {
168
+ if (!At && !$.busy) return;
169
+ let e = (e) => {
170
+ e.preventDefault(), e.returnValue = "";
171
+ };
172
+ return addEventListener("beforeunload", e), () => removeEventListener("beforeunload", e);
173
+ }, [At, $.busy]);
174
+ let jt = async (e) => {
175
+ if (P) return;
176
+ F(void 0), at("");
177
+ let t = K.current;
178
+ if (!t.texts.get()[t.language]?.title.trim()) return F(C("contentManager.titleRequired"));
179
+ let n = G.problem();
180
+ if (n) return F(C("readerEditor.fixSection", { section: n }));
181
+ if (!je(t.details.get().access) || t.details.get().access.level === "tier" && !t.details.get().access.tiers?.length) return F(C("readerEditor.accessRequired"));
182
+ let r;
183
+ try {
184
+ r = he(E.attributes ?? {}, t.details.get().attributes);
185
+ } catch (e) {
186
+ return bt(e);
187
+ }
188
+ if (e && Ot) return F(C("readerEditor.filesNotReady"));
189
+ nt(!0);
190
+ let i = t.texts.checkpoint(), ee = t.details.checkpoint(), te = t.associations.checkpoint(), ne = t.texts.dirty.slice(), a = { ...t.texts.get() }, re = t.details.get(), ie = t.associations.get().memberships.slice(), ae = !0;
191
+ try {
192
+ let n = await xt();
193
+ if (!M()) return;
194
+ if (B.error) throw B.error;
195
+ if (await Ge(async () => {
196
+ for (let e of ne) {
197
+ let t = String(e), r = a[t];
198
+ if (!r?.title.trim()) throw new y(C("contentManager.titleRequired"));
199
+ if (n = await S.contents.putText(n.id, t, He(r)), !M()) return;
200
+ }
201
+ if (n = await S.contents.get(n.id, O), M() && (n = await S.contents.update(n.id, {
202
+ listing: re.listing,
203
+ comments: re.comments,
204
+ attributes: r,
205
+ access: Ae(re.access),
206
+ revision: n.revision
207
+ }), M() && t.associations.dirty.length)) {
208
+ let e = n.versions.find((e) => e.id === z?.id) ?? n.versions[0], t = ie.map((t) => {
209
+ let n = vt.get(t.group_id ?? "")?.kind;
210
+ return n && T.entity_kinds[n]?.version_level && !t.version_id ? {
211
+ ...t,
212
+ version_id: e?.id
213
+ } : t;
214
+ }), r = await S.entities.setOfContent(n.id, {
215
+ kinds: [...V],
216
+ memberships: t
217
+ }, O);
218
+ ae = te({ memberships: r.memberships.filter((e) => V.includes(r.entities.find((t) => t.id === e.group_id)?.kind ?? "")) });
219
+ }
220
+ }), !M()) return;
221
+ let o = St.current;
222
+ !o.busy && (o.pending.length || o.queue.items.some((e) => e.status === "uploaded")) && await o.commit();
223
+ let s = await G.save(M);
224
+ if (s) throw new y(C("readerEditor.fixSection", { section: s }));
225
+ if (!M()) return;
226
+ let c = i(Object.fromEntries(D.map((e) => [e.value, n.text?.[e.value] ?? a[e.value] ?? v()]))), l = ee({
227
+ listing: n.listing,
228
+ comments: n.comments,
229
+ attributes: Ce(E.attributes ?? {}, n.attributes),
230
+ access: n.access
231
+ });
232
+ if (e) {
233
+ if (!c || !l || !ae) throw new y(C("readerEditor.changedDuringSave"));
234
+ let e = St.current;
235
+ if (!Y || e.busy || e.error || e.queue.items.some((e) => e.status === "failed") || !await ye(S, Y)) throw new y(C("readerEditor.filesNotReady"));
236
+ if ((z ? await S.contents.version(n.id, z.id, O) : null)?.state !== "published") throw new y(C("readerEditor.versionDraft"));
237
+ if (!M()) return;
238
+ let t = I.checkpoint(), r = await Ge(() => S.contents.publish(n.id, L ? new Date(L).toISOString() : void 0));
239
+ t({ at: r.publish_at ? pe(new Date(r.publish_at)) : "" }), at(C("contentManager.publishedNotice"));
240
+ } else at(C("pollEditor.saved"));
241
+ } catch (e) {
242
+ bt(e);
243
+ } finally {
244
+ M() && nt(!1);
245
+ }
246
+ }, Mt = async (e) => {
247
+ let t = await xt(e.name), n = t.versions.find((e) => e.id === z?.id) ?? t.versions[0];
248
+ if (!n || !M()) return;
249
+ let r = {
250
+ kind: x.kind,
251
+ id: t.id,
252
+ version: n.id
253
+ }, i = await S.media.uploadNamed(r, e, { path: await S.media.presetPath(x.kind, "cover", e) });
254
+ M() && await S.contents.setCover(t.id, n.id, i.name);
255
+ }, Nt = async (e) => {
256
+ if (!Y || !A || !z) return;
257
+ let n = await S.media.presetPath(x.kind, "cover", new File([], e.path.split("/").at(-1) ?? "cover", { type: e.type }));
258
+ await S.media.commit(Y, [{
259
+ op: "copy",
260
+ from: {
261
+ id: A.id,
262
+ version: z.id,
263
+ path: e.path
264
+ },
265
+ to: n
266
+ }]), M() && await S.contents.setCover(A.id, z.id, t(n).split("/").at(-1));
267
+ }, { confirm: Pt, dialog: Ft } = fe(), It = async () => {
268
+ A && await Pt({
269
+ title: C("contentManager.deleteTitle", { title: A.title }),
270
+ description: C("contentManager.deleteBody"),
271
+ confirm: C("contentManager.delete")
272
+ }) && await Q.run(async () => {
273
+ $.discard(), await S.contents.remove(A.id), M() && x.onDeleted?.(A);
274
+ });
275
+ };
276
+ if (x.id && !A) return k.error ? /* @__PURE__ */ g(ue, {
277
+ error: k.error,
278
+ message: C("contentManager.loadFailed"),
279
+ retry: k.reload
280
+ }) : /* @__PURE__ */ g(de, {});
281
+ let Lt = A ? Pe(A) : "draft", Rt = z?.id, zt = (e) => U.edit((t) => ({
282
+ ...t,
283
+ ...e
284
+ })), Bt = R.map((e) => ({
285
+ id: e.id,
286
+ label: Me(e, (e) => D.find((t) => t.value === e)?.label ?? e, x.labels)
287
+ }));
288
+ return /* @__PURE__ */ g(ve.Provider, {
289
+ value: G.context,
290
+ children: /* @__PURE__ */ _("div", {
291
+ className: "grid gap-5 text-base",
292
+ "data-ckui": "reader-content-editor",
293
+ children: [
294
+ /* @__PURE__ */ _("div", {
295
+ className: "sticky top-0 z-10 flex flex-wrap items-center gap-3 rounded-xl border border-border bg-background/95 p-4 shadow-sm",
296
+ children: [
297
+ /* @__PURE__ */ _("div", {
298
+ className: "min-w-0 flex-1",
299
+ children: [/* @__PURE__ */ g("h1", {
300
+ className: "truncate text-xl font-semibold",
301
+ children: q.title || C("readerEditor.new")
302
+ }), /* @__PURE__ */ _("div", {
303
+ className: "mt-1 flex items-center gap-2 text-sm text-muted-foreground",
304
+ children: [
305
+ /* @__PURE__ */ g(ae, {
306
+ variant: A?.live ? "default" : "outline",
307
+ children: C(`contentManager.${Lt}`)
308
+ }),
309
+ z && /* @__PURE__ */ g("span", { children: C("contentEditor.pageCount", { count: z.pages ?? Dt }) }),
310
+ et && /* @__PURE__ */ g("span", {
311
+ role: "status",
312
+ children: C("common.saving")
313
+ })
314
+ ]
315
+ })]
316
+ }),
317
+ A?.live && x.contentHref?.(A) && /* @__PURE__ */ g("a", {
318
+ href: x.contentHref(A),
319
+ className: "text-sm underline",
320
+ children: C("contentManager.view")
321
+ }),
322
+ /* @__PURE__ */ g(a, {
323
+ disabled: P || et,
324
+ onClick: () => void jt(!1),
325
+ children: C(P ? "common.saving" : A?.live ? "common.save" : "readerEditor.saveDraft")
326
+ }),
327
+ !A?.live && /* @__PURE__ */ g(a, {
328
+ variant: "outline",
329
+ disabled: P || Ot,
330
+ onClick: () => void jt(!0),
331
+ children: C(L ? "readerEditor.schedule" : "contentManager.publish")
332
+ })
333
+ ]
334
+ }),
335
+ rt != null && /* @__PURE__ */ g(f, { children: typeof rt == "string" ? rt : ce(We, e(rt)) }),
336
+ it && /* @__PURE__ */ g("p", {
337
+ role: "status",
338
+ className: "text-sm text-muted-foreground",
339
+ children: it
340
+ }),
341
+ /* @__PURE__ */ _("fieldset", {
342
+ disabled: P,
343
+ className: "grid min-w-0 items-start gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]",
344
+ children: [/* @__PURE__ */ _("div", {
345
+ className: "grid min-w-0 gap-5",
346
+ children: [
347
+ /* @__PURE__ */ _(b, {
348
+ title: C("readerEditor.details"),
349
+ children: [
350
+ /* @__PURE__ */ _("div", {
351
+ className: "grid gap-4 sm:grid-cols-[minmax(0,1fr)_10rem]",
352
+ children: [/* @__PURE__ */ _("div", {
353
+ className: "grid gap-1.5",
354
+ children: [/* @__PURE__ */ g(s, {
355
+ htmlFor: `${w}-title`,
356
+ children: C("contentManager.itemTitle")
357
+ }), /* @__PURE__ */ g(o, {
358
+ id: `${w}-title`,
359
+ required: !0,
360
+ maxLength: 300,
361
+ value: q.title,
362
+ onChange: (e) => J({ title: e.target.value })
363
+ })]
364
+ }), /* @__PURE__ */ _("div", {
365
+ className: "grid gap-1.5",
366
+ children: [/* @__PURE__ */ g(s, {
367
+ htmlFor: `${w}-language`,
368
+ children: C("contentManager.language")
369
+ }), /* @__PURE__ */ _(c, {
370
+ value: O,
371
+ onValueChange: (e) => e && Ye(e),
372
+ children: [/* @__PURE__ */ g(u, {
373
+ id: `${w}-language`,
374
+ children: /* @__PURE__ */ g(d, { children: D.find((e) => e.value === O)?.label ?? O })
375
+ }), /* @__PURE__ */ g(l, { children: D.map((e) => /* @__PURE__ */ g(oe, {
376
+ value: e.value,
377
+ children: e.label
378
+ }, e.value)) })]
379
+ })]
380
+ })]
381
+ }),
382
+ /* @__PURE__ */ _("div", {
383
+ className: "grid gap-1.5",
384
+ children: [/* @__PURE__ */ g(s, {
385
+ htmlFor: `${w}-description`,
386
+ children: C("contentManager.description")
387
+ }), /* @__PURE__ */ g(se, {
388
+ id: `${w}-description`,
389
+ rows: 3,
390
+ value: q.description ?? "",
391
+ onChange: (e) => J({ description: e.target.value })
392
+ })]
393
+ }),
394
+ /* @__PURE__ */ g(Se, {
395
+ declared: E.attributes ?? {},
396
+ form: U.value.attributes,
397
+ onChange: (e, t) => zt({ attributes: {
398
+ ...U.value.attributes,
399
+ [e]: t
400
+ } }),
401
+ labels: x.labels
402
+ }),
403
+ /* @__PURE__ */ _("details", {
404
+ className: "grid gap-3",
405
+ children: [/* @__PURE__ */ g("summary", {
406
+ className: "cursor-pointer text-sm text-muted-foreground",
407
+ children: C("readerEditor.additionalText")
408
+ }), /* @__PURE__ */ _("div", {
409
+ className: "mt-3 grid gap-3",
410
+ children: [
411
+ /* @__PURE__ */ _("div", {
412
+ className: "grid gap-1.5",
413
+ children: [/* @__PURE__ */ g(s, {
414
+ htmlFor: `${w}-slug`,
415
+ children: C("contentManager.slug")
416
+ }), /* @__PURE__ */ g(o, {
417
+ id: `${w}-slug`,
418
+ value: q.slug ?? "",
419
+ placeholder: C("contentManager.slugAuto"),
420
+ onChange: (e) => J({ slug: e.target.value })
421
+ })]
422
+ }),
423
+ /* @__PURE__ */ g(s, {
424
+ htmlFor: `${w}-body`,
425
+ children: C("contentManager.body")
426
+ }),
427
+ x.renderEditor ? x.renderEditor({
428
+ value: yt,
429
+ onChange: (e) => J({ body: k.storedBody(e) }),
430
+ uploadImage: A ? (e) => k.uploadImage(e) : void 0,
431
+ disabled: P,
432
+ "aria-label": C("contentManager.body")
433
+ }) : /* @__PURE__ */ g(se, {
434
+ id: `${w}-body`,
435
+ value: q.body ?? "",
436
+ onChange: (e) => J({ body: e.target.value })
437
+ })
438
+ ]
439
+ })]
440
+ })
441
+ ]
442
+ }),
443
+ /* @__PURE__ */ _(b, {
444
+ title: C("readerEditor.files"),
445
+ children: [
446
+ R.length > 1 && /* @__PURE__ */ _(c, {
447
+ value: Rt ?? "",
448
+ onValueChange: (e) => e && Ze(e),
449
+ disabled: $.busy || $.pending.length > 0,
450
+ children: [/* @__PURE__ */ g(u, {
451
+ "aria-label": C("contentEditor.versions"),
452
+ children: /* @__PURE__ */ g(d, { children: Bt.find((e) => e.id === Rt)?.label })
453
+ }), /* @__PURE__ */ g(l, { children: Bt.map((e) => /* @__PURE__ */ g(oe, {
454
+ value: e.id,
455
+ children: e.label
456
+ }, e.id)) })]
457
+ }),
458
+ /* @__PURE__ */ g("p", {
459
+ className: "text-sm text-muted-foreground",
460
+ children: C("readerEditor.fileHelp")
461
+ }),
462
+ /* @__PURE__ */ g(ie, {
463
+ folder: {
464
+ ...$,
465
+ add: kt
466
+ },
467
+ label: C("readerEditor.files"),
468
+ layout: "grid",
469
+ disabled: P,
470
+ inputLabel: C("readerEditor.files"),
471
+ rowActions: (e) => e.type.startsWith("image/") && $.groups.some((t) => t.rule?.page && t.files.some((t) => t.path === e.path)) ? /* @__PURE__ */ g(a, {
472
+ size: "icon-sm",
473
+ variant: "ghost",
474
+ title: C("readerEditor.useCover"),
475
+ "aria-label": C("readerEditor.useCoverFor", { name: e.path.split("/").at(-1) ?? e.path }),
476
+ disabled: X.pending || P,
477
+ onClick: () => void X.run(() => Nt(e)),
478
+ children: /* @__PURE__ */ g(ze, { icon: Re })
479
+ }) : null
480
+ }),
481
+ Ot && /* @__PURE__ */ g("p", {
482
+ role: "status",
483
+ className: "text-sm text-muted-foreground",
484
+ children: Tt ? C("readerEditor.filesFailed") : Et || $.busy ? C("readerEditor.processing") : C("readerEditor.addPages")
485
+ }),
486
+ A && z && /* @__PURE__ */ _("details", {
487
+ onToggle: (e) => e.currentTarget.open && mt(!0),
488
+ children: [/* @__PURE__ */ g("summary", {
489
+ className: "cursor-pointer font-medium",
490
+ children: C("pageReview.title")
491
+ }), pt && /* @__PURE__ */ g(De, {
492
+ content: A.id,
493
+ version: z.id,
494
+ client: S,
495
+ onError: x.onError
496
+ }, z.id)]
497
+ })
498
+ ]
499
+ }),
500
+ A && /* @__PURE__ */ _("details", {
501
+ className: "rounded-xl border border-border bg-card p-4",
502
+ onToggle: (e) => e.currentTarget.open && ct(!0),
503
+ children: [/* @__PURE__ */ g("summary", {
504
+ className: "cursor-pointer font-medium",
505
+ children: C("readerEditor.versions")
506
+ }), st && /* @__PURE__ */ g(ke, {
507
+ content: A,
508
+ media: !1,
509
+ activeVersion: Rt,
510
+ client: S,
511
+ labels: x.labels,
512
+ onError: x.onError
513
+ })]
514
+ }),
515
+ A && z && /* @__PURE__ */ _("details", {
516
+ className: "rounded-xl border border-border bg-card p-4",
517
+ onToggle: (e) => ft(e.currentTarget.open),
518
+ children: [/* @__PURE__ */ g("summary", {
519
+ className: "cursor-pointer font-medium",
520
+ children: C("readerEditor.readerTools")
521
+ }), lt.filter((e) => R.some((t) => t.id === e)).map((e) => /* @__PURE__ */ g("div", {
522
+ hidden: e !== z.id,
523
+ children: /* @__PURE__ */ g(Te, {
524
+ content: A.id,
525
+ version: e,
526
+ client: S,
527
+ onError: x.onError
528
+ })
529
+ }, e))]
530
+ })
531
+ ]
532
+ }), /* @__PURE__ */ _("aside", {
533
+ className: "grid min-w-0 gap-5",
534
+ children: [
535
+ /* @__PURE__ */ _(b, {
536
+ title: C("readerEditor.entities"),
537
+ children: [B.error && /* @__PURE__ */ g(f, { error: B.error }), V.map((e) => {
538
+ let t = W.value.memberships.map((e, t) => ({
539
+ a: e,
540
+ index: t
541
+ })).filter(({ a: t }) => vt.get(t.group_id ?? "")?.kind === e);
542
+ return /* @__PURE__ */ _("fieldset", {
543
+ disabled: !!A && B.loading,
544
+ className: "grid min-w-0 gap-2",
545
+ children: [
546
+ /* @__PURE__ */ g("legend", {
547
+ className: "mb-2 font-semibold",
548
+ children: _e(x.labels, e)
549
+ }),
550
+ t.map(({ a: t, index: n }) => /* @__PURE__ */ g(we, {
551
+ m: t,
552
+ card: vt.get(t.group_id ?? ""),
553
+ spec: T.entity_kinds[e] ?? {},
554
+ labels: x.labels,
555
+ versions: Bt,
556
+ versionLabel: (e) => Bt.find((t) => t.id === e)?.label ?? e,
557
+ onChange: (e) => W.edit((t) => ({ memberships: t.memberships.map((t, r) => r === n ? {
558
+ ...t,
559
+ ...e
560
+ } : t) })),
561
+ onRemove: () => W.edit((e) => ({ memberships: e.memberships.filter((e, t) => t !== n) }))
562
+ }, `${t.group_id}:${n}`)),
563
+ /* @__PURE__ */ g(ge, {
564
+ kind: e,
565
+ management: x.management,
566
+ language: O,
567
+ exclude: t.filter(({ a: e }) => !e.version_id && !e.role).map(({ a: e }) => e.group_id),
568
+ label: C("memberships.add", { kind: _e(x.labels, e) }),
569
+ client: S,
570
+ onPick: (t) => {
571
+ _t((e) => new Map(e).set(t.id, t)), W.edit((n) => ({ memberships: [...n.memberships, {
572
+ group_id: t.id,
573
+ ...T.entity_kinds[e]?.version_level && z ? { version_id: z.id } : {}
574
+ }] }));
575
+ }
576
+ })
577
+ ]
578
+ }, e);
579
+ })]
580
+ }),
581
+ /* @__PURE__ */ _(b, {
582
+ title: C("contentManager.cover"),
583
+ children: [
584
+ z?.cover?.url ? /* @__PURE__ */ g("img", {
585
+ src: z.cover.url,
586
+ alt: "",
587
+ className: "mx-auto max-h-64 rounded-lg object-contain"
588
+ }) : /* @__PURE__ */ g("p", {
589
+ className: "text-sm text-muted-foreground",
590
+ children: C("readerEditor.firstPageCover")
591
+ }),
592
+ /* @__PURE__ */ _("label", {
593
+ className: "inline-flex cursor-pointer justify-center rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-muted",
594
+ children: [C("contentManager.addCover"), /* @__PURE__ */ g("input", {
595
+ type: "file",
596
+ accept: "image/*",
597
+ className: "sr-only",
598
+ "aria-label": C("contentManager.cover"),
599
+ disabled: X.pending || P,
600
+ onChange: (e) => {
601
+ let t = e.target.files?.[0];
602
+ e.target.value = "", t && X.run(() => Mt(t));
603
+ }
604
+ })]
605
+ }),
606
+ /* @__PURE__ */ g(f, { error: X.error })
607
+ ]
608
+ }),
609
+ /* @__PURE__ */ _(b, {
610
+ title: C("contentEditor.accessTitle"),
611
+ children: [
612
+ /* @__PURE__ */ g(Oe, {
613
+ value: U.value.access,
614
+ onChange: (e) => zt({ access: e }),
615
+ model: T,
616
+ kind: x.kind,
617
+ owner: A?.owner_group_id ?? x.ownerGroup,
618
+ labels: x.labels,
619
+ client: S
620
+ }),
621
+ A && (U.value.access.level === "ppv" || U.value.access.level === "group_ppv" || A.offer) && /* @__PURE__ */ g(xe, {
622
+ offer: A.offer,
623
+ pending: Z.pending,
624
+ onSell: (e) => Z.run(() => S.offers.sell({ content: A.id }, e)),
625
+ onWithdraw: () => void Z.run(() => S.offers.withdraw({ content: A.id }))
626
+ }),
627
+ /* @__PURE__ */ g(f, { error: Z.error })
628
+ ]
629
+ }),
630
+ /* @__PURE__ */ _(b, {
631
+ title: C("readerEditor.publication"),
632
+ children: [
633
+ !A?.live && /* @__PURE__ */ _("div", {
634
+ className: "grid gap-1.5",
635
+ children: [/* @__PURE__ */ g(s, {
636
+ htmlFor: `${w}-publish`,
637
+ children: C("contentManager.publishAt")
638
+ }), /* @__PURE__ */ g(o, {
639
+ id: `${w}-publish`,
640
+ type: "datetime-local",
641
+ value: L,
642
+ onChange: (e) => ot(e.target.value)
643
+ })]
644
+ }),
645
+ /* @__PURE__ */ g(s, {
646
+ htmlFor: `${w}-listing`,
647
+ children: C("contentEditor.listing")
648
+ }),
649
+ /* @__PURE__ */ _(c, {
650
+ value: U.value.listing,
651
+ onValueChange: (e) => e && zt({ listing: e }),
652
+ children: [/* @__PURE__ */ g(u, {
653
+ id: `${w}-listing`,
654
+ children: /* @__PURE__ */ g(d, { children: C(`contentEditor.listing_${U.value.listing}`) })
655
+ }), /* @__PURE__ */ g(l, { children: [
656
+ "listed",
657
+ "members",
658
+ "unlisted"
659
+ ].map((e) => /* @__PURE__ */ g(oe, {
660
+ value: e,
661
+ children: C(`contentEditor.listing_${e}`)
662
+ }, e)) })]
663
+ }),
664
+ /* @__PURE__ */ g(s, {
665
+ htmlFor: `${w}-comments`,
666
+ children: C("contentEditor.comments")
667
+ }),
668
+ /* @__PURE__ */ _(c, {
669
+ value: U.value.comments,
670
+ onValueChange: (e) => e && zt({ comments: e }),
671
+ children: [/* @__PURE__ */ g(u, {
672
+ id: `${w}-comments`,
673
+ children: /* @__PURE__ */ g(d, { children: C(`contentEditor.comments_${U.value.comments}`) })
674
+ }), /* @__PURE__ */ g(l, { children: [
675
+ "open",
676
+ "closed",
677
+ "hidden"
678
+ ].map((e) => /* @__PURE__ */ g(oe, {
679
+ value: e,
680
+ children: C(`contentEditor.comments_${e}`)
681
+ }, e)) })]
682
+ }),
683
+ A?.state === "published" && /* @__PURE__ */ g(a, {
684
+ variant: "outline",
685
+ disabled: Q.pending,
686
+ onClick: () => void Q.run(() => S.contents.unpublish(A.id)),
687
+ children: C("contentManager.unpublish")
688
+ }),
689
+ A && /* @__PURE__ */ g(a, {
690
+ variant: "destructive",
691
+ disabled: Q.pending,
692
+ onClick: () => void It(),
693
+ children: C("contentManager.delete")
694
+ }),
695
+ /* @__PURE__ */ g(f, { error: Q.error })
696
+ ]
697
+ })
698
+ ]
699
+ })]
700
+ }),
701
+ Ft
702
+ ]
703
+ })
704
+ });
705
+ }
706
+ //#endregion
707
+ export { x as ReaderContentEditor };
708
+
709
+ //# sourceMappingURL=reader-content-editor.js.map