@openrails/contentkit-ui 0.103.2 → 0.104.0-rc.1

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