@openrails/contentkit-ui 0.83.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/README.md +18 -7
  2. package/dist/client/beacons.d.ts +18 -6
  3. package/dist/client/beacons.js +26 -11
  4. package/dist/client/beacons.js.map +1 -1
  5. package/dist/client/client.d.ts +3 -0
  6. package/dist/client/client.js +29 -27
  7. package/dist/client/client.js.map +1 -1
  8. package/dist/client/codes.d.ts +6 -1
  9. package/dist/client/codes.js +4 -1
  10. package/dist/client/codes.js.map +1 -1
  11. package/dist/client/content/moderation.d.ts +14 -2
  12. package/dist/client/content/moderation.js +34 -0
  13. package/dist/client/content/moderation.js.map +1 -1
  14. package/dist/client/content/types.d.ts +13 -0
  15. package/dist/client/content/types.js.map +1 -1
  16. package/dist/client/discovery.d.ts +6 -0
  17. package/dist/client/discovery.js.map +1 -1
  18. package/dist/client/generated/error-codes.d.ts +1 -1
  19. package/dist/client/generated/error-codes.js +9 -1
  20. package/dist/client/generated/error-codes.js.map +1 -1
  21. package/dist/client/generated/routes.d.ts +91 -13
  22. package/dist/client/generated/routes.js +123 -2
  23. package/dist/client/generated/routes.js.map +1 -1
  24. package/dist/client/generated/wire.d.ts +81 -0
  25. package/dist/client/generated/wire.js.map +1 -1
  26. package/dist/client/index.d.ts +4 -2
  27. package/dist/client/media/queue.d.ts +4 -2
  28. package/dist/client/media/queue.js +18 -12
  29. package/dist/client/media/queue.js.map +1 -1
  30. package/dist/client/media/rules.d.ts +7 -1
  31. package/dist/client/media/rules.js +27 -21
  32. package/dist/client/media/rules.js.map +1 -1
  33. package/dist/client/reader-meta.d.ts +27 -0
  34. package/dist/client/reader-meta.js +99 -0
  35. package/dist/client/reader-meta.js.map +1 -0
  36. package/dist/client/stats.d.ts +32 -0
  37. package/dist/client/stats.js +35 -0
  38. package/dist/client/stats.js.map +1 -0
  39. package/dist/client/versions.d.ts +1 -1
  40. package/dist/client/versions.js +7 -2
  41. package/dist/client/versions.js.map +1 -1
  42. package/dist/client.js +30 -28
  43. package/dist/components/admin/content-manager.js +206 -206
  44. package/dist/components/admin/content-manager.js.map +1 -1
  45. package/dist/components/admin/group-manager.js +71 -70
  46. package/dist/components/admin/group-manager.js.map +1 -1
  47. package/dist/components/admin/media-item-panel.d.ts +24 -7
  48. package/dist/components/admin/media-item-panel.js +209 -197
  49. package/dist/components/admin/media-item-panel.js.map +1 -1
  50. package/dist/components/admin/poll-manager.js +25 -25
  51. package/dist/components/admin/reader-manifest.d.ts +18 -0
  52. package/dist/components/admin/reader-manifest.js +490 -0
  53. package/dist/components/admin/reader-manifest.js.map +1 -0
  54. package/dist/components/admin/stats-dashboard.d.ts +22 -0
  55. package/dist/components/admin/stats-dashboard.js +257 -0
  56. package/dist/components/admin/stats-dashboard.js.map +1 -0
  57. package/dist/components/content/card.js +43 -43
  58. package/dist/components/content/card.js.map +1 -1
  59. package/dist/components/content/editors.d.ts +2 -1
  60. package/dist/components/content/editors.js +479 -416
  61. package/dist/components/content/editors.js.map +1 -1
  62. package/dist/components/content/grid.js +47 -47
  63. package/dist/components/content/index.d.ts +2 -1
  64. package/dist/components/content/listing.js +34 -34
  65. package/dist/components/content/listing.js.map +1 -1
  66. package/dist/components/content/paywall.d.ts +17 -5
  67. package/dist/components/content/paywall.js +115 -100
  68. package/dist/components/content/paywall.js.map +1 -1
  69. package/dist/components/content/reader-stats.d.ts +12 -0
  70. package/dist/components/content/reader-stats.js +47 -0
  71. package/dist/components/content/reader-stats.js.map +1 -0
  72. package/dist/components/groups/banner.d.ts +1 -1
  73. package/dist/components/groups/banner.js +34 -34
  74. package/dist/components/groups/banner.js.map +1 -1
  75. package/dist/components/groups/directory.js +11 -11
  76. package/dist/components/groups/editor.js +294 -294
  77. package/dist/components/groups/editor.js.map +1 -1
  78. package/dist/components/groups/header.js +27 -27
  79. package/dist/components/groups/header.js.map +1 -1
  80. package/dist/components/groups/memberships.js +180 -180
  81. package/dist/components/groups/parts.d.ts +2 -4
  82. package/dist/components/groups/parts.js +69 -88
  83. package/dist/components/groups/parts.js.map +1 -1
  84. package/dist/components/media-folder-editor.js +239 -189
  85. package/dist/components/media-folder-editor.js.map +1 -1
  86. package/dist/components/notifications.js +17 -17
  87. package/dist/components/slot-upload.d.ts +2 -2
  88. package/dist/components/slot-upload.js +84 -79
  89. package/dist/components/slot-upload.js.map +1 -1
  90. package/dist/components/social/bans.js +34 -34
  91. package/dist/components/social/comments.js +59 -45
  92. package/dist/components/social/comments.js.map +1 -1
  93. package/dist/components/social/index.d.ts +1 -0
  94. package/dist/components/social/moderation.d.ts +5 -4
  95. package/dist/components/social/moderation.js +177 -160
  96. package/dist/components/social/moderation.js.map +1 -1
  97. package/dist/components/social/parts.js +22 -14
  98. package/dist/components/social/parts.js.map +1 -1
  99. package/dist/components/social/rules.d.ts +23 -0
  100. package/dist/components/social/rules.js +261 -0
  101. package/dist/components/social/rules.js.map +1 -0
  102. package/dist/components/video-player.d.ts +2 -0
  103. package/dist/components/video-player.js +318 -314
  104. package/dist/components/video-player.js.map +1 -1
  105. package/dist/i18n/context.d.ts +2 -0
  106. package/dist/i18n/context.js +23 -5
  107. package/dist/i18n/context.js.map +1 -1
  108. package/dist/index.d.ts +3 -1
  109. package/dist/index.js +28 -24
  110. package/dist/locales/admin/de.js +105 -0
  111. package/dist/locales/admin/de.js.map +1 -1
  112. package/dist/locales/admin/en.d.ts +105 -0
  113. package/dist/locales/admin/en.js +105 -0
  114. package/dist/locales/admin/en.js.map +1 -1
  115. package/dist/locales/admin/es.js +105 -0
  116. package/dist/locales/admin/es.js.map +1 -1
  117. package/dist/locales/admin/ja.js +105 -0
  118. package/dist/locales/admin/ja.js.map +1 -1
  119. package/dist/locales/admin/ko.js +105 -0
  120. package/dist/locales/admin/ko.js.map +1 -1
  121. package/dist/locales/admin/zh.js +105 -0
  122. package/dist/locales/admin/zh.js.map +1 -1
  123. package/dist/locales/content/de.js +6 -0
  124. package/dist/locales/content/de.js.map +1 -1
  125. package/dist/locales/content/en.d.ts +6 -0
  126. package/dist/locales/content/en.js +6 -0
  127. package/dist/locales/content/en.js.map +1 -1
  128. package/dist/locales/content/es.js +6 -0
  129. package/dist/locales/content/es.js.map +1 -1
  130. package/dist/locales/content/ja.js +6 -0
  131. package/dist/locales/content/ja.js.map +1 -1
  132. package/dist/locales/content/ko.js +6 -0
  133. package/dist/locales/content/ko.js.map +1 -1
  134. package/dist/locales/content/zh.js +6 -0
  135. package/dist/locales/content/zh.js.map +1 -1
  136. package/dist/locales/de.js +4 -1
  137. package/dist/locales/de.js.map +1 -1
  138. package/dist/locales/discovery/de.js +1 -0
  139. package/dist/locales/discovery/de.js.map +1 -1
  140. package/dist/locales/discovery/en.d.ts +1 -0
  141. package/dist/locales/discovery/en.js +1 -0
  142. package/dist/locales/discovery/en.js.map +1 -1
  143. package/dist/locales/discovery/es.js +1 -0
  144. package/dist/locales/discovery/es.js.map +1 -1
  145. package/dist/locales/discovery/ja.js +1 -0
  146. package/dist/locales/discovery/ja.js.map +1 -1
  147. package/dist/locales/discovery/ko.js +1 -0
  148. package/dist/locales/discovery/ko.js.map +1 -1
  149. package/dist/locales/discovery/zh.js +1 -0
  150. package/dist/locales/discovery/zh.js.map +1 -1
  151. package/dist/locales/en.d.ts +118 -0
  152. package/dist/locales/en.js +4 -1
  153. package/dist/locales/en.js.map +1 -1
  154. package/dist/locales/es.js +4 -1
  155. package/dist/locales/es.js.map +1 -1
  156. package/dist/locales/ja.js +4 -1
  157. package/dist/locales/ja.js.map +1 -1
  158. package/dist/locales/ko.js +4 -1
  159. package/dist/locales/ko.js.map +1 -1
  160. package/dist/locales/social/de.js +3 -0
  161. package/dist/locales/social/de.js.map +1 -1
  162. package/dist/locales/social/en.d.ts +3 -0
  163. package/dist/locales/social/en.js +3 -0
  164. package/dist/locales/social/en.js.map +1 -1
  165. package/dist/locales/social/es.js +3 -0
  166. package/dist/locales/social/es.js.map +1 -1
  167. package/dist/locales/social/ja.js +3 -0
  168. package/dist/locales/social/ja.js.map +1 -1
  169. package/dist/locales/social/ko.js +3 -0
  170. package/dist/locales/social/ko.js.map +1 -1
  171. package/dist/locales/social/zh.js +3 -0
  172. package/dist/locales/social/zh.js.map +1 -1
  173. package/dist/locales/zh.js +4 -1
  174. package/dist/locales/zh.js.map +1 -1
  175. package/dist/react/admin.d.ts +1 -1
  176. package/dist/react/admin.js +24 -23
  177. package/dist/react/admin.js.map +1 -1
  178. package/dist/react/canonical.d.ts +4 -3
  179. package/dist/react/canonical.js +34 -33
  180. package/dist/react/canonical.js.map +1 -1
  181. package/dist/react/comments.d.ts +29 -1
  182. package/dist/react/comments.js +30 -2
  183. package/dist/react/comments.js.map +1 -1
  184. package/dist/react/contents.js +144 -144
  185. package/dist/react/contents.js.map +1 -1
  186. package/dist/react/context.d.ts +1 -1
  187. package/dist/react/context.js.map +1 -1
  188. package/dist/react/detail.d.ts +12 -6
  189. package/dist/react/detail.js +31 -24
  190. package/dist/react/detail.js.map +1 -1
  191. package/dist/react/discovery.js +1 -1
  192. package/dist/react/discovery.js.map +1 -1
  193. package/dist/react/folder.d.ts +7 -2
  194. package/dist/react/folder.js +165 -147
  195. package/dist/react/folder.js.map +1 -1
  196. package/dist/react/groups.d.ts +0 -1
  197. package/dist/react/groups.js +13 -12
  198. package/dist/react/groups.js.map +1 -1
  199. package/dist/react/index.d.ts +5 -3
  200. package/dist/react/location.d.ts +11 -0
  201. package/dist/react/location.js +18 -0
  202. package/dist/react/location.js.map +1 -0
  203. package/dist/react/public.d.ts +8 -0
  204. package/dist/react/public.js +32 -27
  205. package/dist/react/public.js.map +1 -1
  206. package/dist/react/resources.js +6 -0
  207. package/dist/react/resources.js.map +1 -1
  208. package/dist/react/stats.d.ts +24 -0
  209. package/dist/react/stats.js +28 -0
  210. package/dist/react/stats.js.map +1 -0
  211. package/dist/react/use-resource.js +8 -7
  212. package/dist/react/use-resource.js.map +1 -1
  213. package/dist/react/versions.js +20 -20
  214. package/dist/react.js +26 -24
  215. package/dist/styles.css +1 -1
  216. package/dist/urls/index.d.ts +35 -10
  217. package/dist/urls.js +100 -70
  218. package/dist/urls.js.map +1 -1
  219. package/package.json +1 -1
@@ -1,269 +1,277 @@
1
- import { useMessages as e } from "../../i18n/context.js";
2
- import { useContentKitClient as t } from "../../react/context.js";
3
- import { Button as n } from "../../ui/button.js";
4
- import { SortableList as r } from "../sortable-list.js";
5
- import { MediaFolderEditor as i } from "../media-folder-editor.js";
6
- import { Badge as a } from "../../ui/badge.js";
7
- import { Input as o } from "../../ui/input.js";
8
- import { Label as s } from "../../ui/label.js";
9
- import { Select as c, SelectContent as l, SelectItem as u, SelectTrigger as d, SelectValue as f } from "../../ui/select.js";
10
- import { ErrorLine as p, useAction as m } from "../social/parts.js";
11
- import { Switch as h } from "../../ui/switch.js";
12
- import { fromLocalInput as g, parseAttributes as _, toLocalInput as v } from "../../client/group-fields.js";
13
- import { useKinds as y } from "../../react/groups.js";
14
- import { GroupPicker as b, labelOf as x, useGroupNames as S, useLanguageName as C } from "../groups/parts.js";
15
- import { OfferFields as w } from "./offer-fields.js";
16
- import { AttributeFields as T, formOf as E } from "../groups/fields.js";
17
- import { MembershipEditor as D } from "../groups/memberships.js";
18
- import { useEffect as O, useId as k, useMemo as A, useState as j } from "react";
19
- import { jsx as M, jsxs as N } from "react/jsx-runtime";
20
- import { cn as P } from "cn";
1
+ import { useLanguageName as e, useMessages as t } from "../../i18n/context.js";
2
+ import { useContentKitClient as n } from "../../react/context.js";
3
+ import { useKinds as r } from "../../react/groups.js";
4
+ import { useMediaRead as i } from "../../react/read.js";
5
+ import { Button as a } from "../../ui/button.js";
6
+ import { SortableList as o } from "../sortable-list.js";
7
+ import { MediaFolderEditor as s } from "../media-folder-editor.js";
8
+ import { Badge as c } from "../../ui/badge.js";
9
+ import { Input as l } from "../../ui/input.js";
10
+ import { Label as u } from "../../ui/label.js";
11
+ import { Select as d, SelectContent as f, SelectItem as p, SelectTrigger as m, SelectValue as h } from "../../ui/select.js";
12
+ import { Skeleton as g } from "../../ui/skeleton.js";
13
+ import { ErrorLine as _, useAction as v } from "../social/parts.js";
14
+ import { Switch as y } from "../../ui/switch.js";
15
+ import { fromLocalInput as b, parseAttributes as x, toLocalInput as S } from "../../client/group-fields.js";
16
+ import { GroupPicker as C, labelOf as w, useGroupNames as T } from "../groups/parts.js";
17
+ import { OfferFields as E } from "./offer-fields.js";
18
+ import { AttributeFields as D, formOf as O } from "../groups/fields.js";
19
+ import { MembershipEditor as k } from "../groups/memberships.js";
20
+ import { ReaderManifestEditor as A } from "../admin/reader-manifest.js";
21
+ import { VideoMediaEditor as j, videoPaths as M } from "../admin/media-item-panel.js";
22
+ import { useEffect as N, useId as P, useMemo as F, useState as I } from "react";
23
+ import { jsx as L, jsxs as R } from "react/jsx-runtime";
24
+ import { cn as z } from "cn";
21
25
  //#region src/components/content/editors.tsx
22
- var F = "__none__", I = [
26
+ var B = "__none__", V = [
23
27
  "listed",
24
28
  "members",
25
29
  "unlisted"
26
- ], L = [
30
+ ], H = [
27
31
  "open",
28
32
  "closed",
29
33
  "hidden"
30
- ], R = [
34
+ ], U = [
31
35
  "public",
32
36
  "tier",
33
37
  "ppv",
34
38
  "group",
35
39
  "group_ppv"
36
- ];
37
- function z({ title: e, ckui: t, children: n }) {
38
- return /* @__PURE__ */ N("section", {
40
+ ], W = (e) => e === "group" || e === "group_ppv";
41
+ function G({ title: e, ckui: t, children: n }) {
42
+ return /* @__PURE__ */ R("section", {
39
43
  className: "grid gap-3 border-t border-border pt-4",
40
44
  "data-ckui": t,
41
- children: [/* @__PURE__ */ M("h3", {
45
+ children: [/* @__PURE__ */ L("h3", {
42
46
  className: "font-medium",
43
47
  children: e
44
48
  }), n]
45
49
  });
46
50
  }
47
- function B({ show: t }) {
48
- let { t: n } = e();
49
- return t ? /* @__PURE__ */ M("span", {
51
+ function K({ show: e }) {
52
+ let { t: n } = t();
53
+ return e ? /* @__PURE__ */ L("span", {
50
54
  role: "status",
51
55
  className: "text-muted-foreground",
52
56
  children: n("contentEditor.saved")
53
57
  }) : null;
54
58
  }
55
- function V(e, t) {
56
- let { kinds: n } = y({ client: t });
59
+ function q(e, t) {
60
+ let { kinds: n } = r({ client: t });
57
61
  return {
58
62
  model: n,
59
63
  spec: n?.kinds[e]
60
64
  };
61
65
  }
62
- function H({ content: r, ...i }) {
63
- let { t: a } = e(), o = t(i.client), { spec: h } = V(r.kind, i.client), g = A(() => h?.attributes ?? {}, [h]), [v, y] = j(r.listing), [b, x] = j(r.comments), [S, C] = j({});
64
- O(() => {
65
- y(r.listing), x(r.comments), C(E(g, r.attributes));
66
+ function J({ content: e, ...r }) {
67
+ let { t: i } = t(), o = n(r.client), { spec: s } = q(e.kind, r.client), c = F(() => s?.attributes ?? {}, [s]), [l, g] = I(e.listing), [y, b] = I(e.comments), [S, C] = I({});
68
+ N(() => {
69
+ g(e.listing), b(e.comments), C(O(c, e.attributes));
66
70
  }, [
67
- r.revision,
68
- r.listing,
69
- r.comments,
70
- r.attributes,
71
- g
71
+ e.revision,
72
+ e.listing,
73
+ e.comments,
74
+ e.attributes,
75
+ c
72
76
  ]);
73
- let [w, D] = j(null), [k, P] = j(!1), F = m("content.save", i.onError);
74
- return /* @__PURE__ */ M(z, {
75
- title: a("contentEditor.details"),
77
+ let [w, T] = I(null), [E, k] = I(!1), A = v("content.save", r.onError);
78
+ return /* @__PURE__ */ L(G, {
79
+ title: i("contentEditor.details"),
76
80
  ckui: "content-details",
77
- children: /* @__PURE__ */ N("form", {
81
+ children: /* @__PURE__ */ R("form", {
78
82
  className: "grid gap-3",
79
- onSubmit: (e) => {
80
- e.preventDefault(), D(null), P(!1);
81
- let t;
83
+ onSubmit: (t) => {
84
+ t.preventDefault(), T(null), k(!1);
85
+ let n;
82
86
  try {
83
- t = _(g, S);
87
+ n = x(c, S);
84
88
  } catch (e) {
85
- return D(e.message);
89
+ return T(e.message);
86
90
  }
87
- F.run(() => o.contents.update(r.id, {
88
- listing: v,
89
- comments: b,
90
- attributes: t,
91
- revision: r.revision
92
- })).then((e) => e && P(!0));
91
+ A.run(() => o.contents.update(e.id, {
92
+ listing: l,
93
+ comments: y,
94
+ attributes: n,
95
+ revision: e.revision
96
+ })).then((e) => e && k(!0));
93
97
  },
94
98
  children: [
95
- /* @__PURE__ */ N("div", {
99
+ /* @__PURE__ */ R("div", {
96
100
  className: "grid gap-1.5 sm:max-w-xs",
97
- children: [/* @__PURE__ */ M(s, { children: a("contentEditor.listing") }), /* @__PURE__ */ N(c, {
98
- value: v,
99
- onValueChange: (e) => y(e),
100
- children: [/* @__PURE__ */ M(d, {
101
+ children: [/* @__PURE__ */ L(u, { children: i("contentEditor.listing") }), /* @__PURE__ */ R(d, {
102
+ value: l,
103
+ onValueChange: (e) => g(e),
104
+ children: [/* @__PURE__ */ L(m, {
101
105
  size: "sm",
102
- "aria-label": a("contentEditor.listing"),
103
- children: /* @__PURE__ */ M(f, { children: (e) => a(`contentEditor.listing_${e}`) })
104
- }), /* @__PURE__ */ M(l, { children: I.map((e) => /* @__PURE__ */ M(u, {
106
+ "aria-label": i("contentEditor.listing"),
107
+ children: /* @__PURE__ */ L(h, { children: (e) => i(`contentEditor.listing_${e}`) })
108
+ }), /* @__PURE__ */ L(f, { children: V.map((e) => /* @__PURE__ */ L(p, {
105
109
  value: e,
106
- children: a(`contentEditor.listing_${e}`)
110
+ children: i(`contentEditor.listing_${e}`)
107
111
  }, e)) })]
108
112
  })]
109
113
  }),
110
- /* @__PURE__ */ N("div", {
114
+ /* @__PURE__ */ R("div", {
111
115
  className: "grid gap-1.5 sm:max-w-xs",
112
- children: [/* @__PURE__ */ M(s, { children: a("contentEditor.comments") }), /* @__PURE__ */ N(c, {
113
- value: b,
114
- onValueChange: (e) => x(e),
115
- children: [/* @__PURE__ */ M(d, {
116
+ children: [/* @__PURE__ */ L(u, { children: i("contentEditor.comments") }), /* @__PURE__ */ R(d, {
117
+ value: y,
118
+ onValueChange: (e) => b(e),
119
+ children: [/* @__PURE__ */ L(m, {
116
120
  size: "sm",
117
- "aria-label": a("contentEditor.comments"),
118
- children: /* @__PURE__ */ M(f, { children: (e) => a(`contentEditor.comments_${e}`) })
119
- }), /* @__PURE__ */ M(l, { children: L.map((e) => /* @__PURE__ */ M(u, {
121
+ "aria-label": i("contentEditor.comments"),
122
+ children: /* @__PURE__ */ L(h, { children: (e) => i(`contentEditor.comments_${e}`) })
123
+ }), /* @__PURE__ */ L(f, { children: H.map((e) => /* @__PURE__ */ L(p, {
120
124
  value: e,
121
- children: a(`contentEditor.comments_${e}`)
125
+ children: i(`contentEditor.comments_${e}`)
122
126
  }, e)) })]
123
127
  })]
124
128
  }),
125
- /* @__PURE__ */ M(T, {
126
- declared: g,
129
+ /* @__PURE__ */ L(D, {
130
+ declared: c,
127
131
  form: S,
128
132
  onChange: (e, t) => C((n) => ({
129
133
  ...n,
130
134
  [e]: t
131
135
  })),
132
- labels: i.labels
136
+ labels: r.labels
133
137
  }),
134
- w && /* @__PURE__ */ M(p, { children: w }),
135
- /* @__PURE__ */ M(p, { error: F.error }),
136
- /* @__PURE__ */ N("div", {
138
+ w && /* @__PURE__ */ L(_, { children: w }),
139
+ /* @__PURE__ */ L(_, { error: A.error }),
140
+ /* @__PURE__ */ R("div", {
137
141
  className: "flex items-center gap-3",
138
- children: [/* @__PURE__ */ M(n, {
142
+ children: [/* @__PURE__ */ L(a, {
139
143
  type: "submit",
140
144
  size: "sm",
141
- disabled: F.pending,
142
- children: F.pending ? a("common.saving") : a("common.save")
143
- }), /* @__PURE__ */ M(B, { show: k })]
145
+ disabled: A.pending,
146
+ children: A.pending ? i("common.saving") : i("common.save")
147
+ }), /* @__PURE__ */ L(K, { show: E })]
144
148
  })
145
149
  ]
146
150
  })
147
151
  });
148
152
  }
149
- function U({ value: t, onChange: n, model: r, labels: i, client: a }) {
150
- let { t: p } = e(), m = k(), _ = r?.tiers ?? [], y = Object.entries(r?.group_kinds ?? {}).filter(([, e]) => e.sellable || e.auth_scope).map(([e]) => e), [C, w] = j(y[0] ?? ""), T = S(t.group_id ? [t.group_id] : [], { client: a }), E = t.group_id ? T.get(t.group_id) : void 0, D = (e) => n({
151
- ...t,
152
- ...e
153
- });
154
- return /* @__PURE__ */ N("div", {
153
+ function Y({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, client: s }) {
154
+ let { t: c } = t(), g = P(), _ = r?.tiers ?? [], v = r?.kinds[i], x = Object.entries(r?.group_kinds ?? {}).filter(([, e]) => e.sellable || e.auth_scope).map(([e]) => e), [E, D] = I(), O = E ?? x[0] ?? "", k = T(e.group_id ? [e.group_id] : [], { client: s }), A = e.group_id ? k.get(e.group_id) : void 0, j = (t) => n({
155
+ ...e,
156
+ ...t
157
+ }), M = v?.presentation === "reader", N = !!v?.segments;
158
+ return /* @__PURE__ */ R("div", {
155
159
  className: "grid gap-3",
156
160
  "data-ckui": "rule-fields",
157
161
  children: [
158
- /* @__PURE__ */ N("div", {
162
+ /* @__PURE__ */ R("div", {
159
163
  className: "grid gap-1.5 sm:max-w-xs",
160
- children: [/* @__PURE__ */ M(s, { children: p("contentEditor.access") }), /* @__PURE__ */ N(c, {
161
- value: t.level,
162
- onValueChange: (e) => n({
163
- level: e,
164
- preview: t.preview,
165
- free_after: t.free_after
166
- }),
167
- children: [/* @__PURE__ */ M(d, {
164
+ children: [/* @__PURE__ */ L(u, { children: c("contentEditor.access") }), /* @__PURE__ */ R(d, {
165
+ value: e.level,
166
+ onValueChange: (t) => {
167
+ let r = t;
168
+ n({
169
+ level: r,
170
+ group_id: W(r) ? e.group_id || a : void 0,
171
+ preview: e.preview,
172
+ free_after: e.free_after
173
+ });
174
+ },
175
+ children: [/* @__PURE__ */ L(m, {
168
176
  size: "sm",
169
- "aria-label": p("contentEditor.access"),
170
- children: /* @__PURE__ */ M(f, { children: (e) => p(`contentEditor.level_${e}`) })
171
- }), /* @__PURE__ */ M(l, { children: R.filter((e) => (e !== "tier" || _.length) && (!e.startsWith("group") || y.length)).map((e) => /* @__PURE__ */ M(u, {
177
+ "aria-label": c("contentEditor.access"),
178
+ children: /* @__PURE__ */ L(h, { children: (e) => c(`contentEditor.level_${e}`) })
179
+ }), /* @__PURE__ */ L(f, { children: U.filter((e) => (e !== "tier" || _.length) && (!e.startsWith("group") || x.length)).map((e) => /* @__PURE__ */ L(p, {
172
180
  value: e,
173
- children: p(`contentEditor.level_${e}`)
181
+ children: c(`contentEditor.level_${e}`)
174
182
  }, e)) })]
175
183
  })]
176
184
  }),
177
- t.level === "tier" && /* @__PURE__ */ N("fieldset", {
185
+ e.level === "tier" && /* @__PURE__ */ R("fieldset", {
178
186
  className: "flex flex-wrap gap-3",
179
- children: [/* @__PURE__ */ M("legend", {
187
+ children: [/* @__PURE__ */ L("legend", {
180
188
  className: "sr-only",
181
- children: p("contentEditor.tiers")
182
- }), _.map((e) => /* @__PURE__ */ N("label", {
189
+ children: c("contentEditor.tiers")
190
+ }), _.map((t) => /* @__PURE__ */ R("label", {
183
191
  className: "flex items-center gap-2",
184
- children: [/* @__PURE__ */ M(h, {
185
- checked: t.tiers?.includes(e) ?? !1,
186
- onCheckedChange: (n) => D({ tiers: n ? [...t.tiers ?? [], e] : (t.tiers ?? []).filter((t) => t !== e) }),
187
- "aria-label": x(i, e)
188
- }), x(i, e)]
189
- }, e))]
192
+ children: [/* @__PURE__ */ L(y, {
193
+ checked: e.tiers?.includes(t) ?? !1,
194
+ onCheckedChange: (n) => j({ tiers: n ? [...e.tiers ?? [], t] : (e.tiers ?? []).filter((e) => e !== t) }),
195
+ "aria-label": w(o, t)
196
+ }), w(o, t)]
197
+ }, t))]
190
198
  }),
191
- (t.level === "group" || t.level === "group_ppv") && /* @__PURE__ */ N("div", {
199
+ W(e.level) && /* @__PURE__ */ R("div", {
192
200
  className: "flex flex-wrap items-end gap-2",
193
201
  children: [
194
- E || t.group_id ? /* @__PURE__ */ M("span", {
202
+ A || e.group_id ? /* @__PURE__ */ L("span", {
195
203
  className: "rounded-md border border-border px-2 py-0.5",
196
204
  "data-ckui": "rule-group",
197
- children: E ? E.name || E.slug : t.group_id
205
+ children: A ? A.name || A.slug : e.group_id
198
206
  }) : null,
199
- y.length > 1 && /* @__PURE__ */ N(c, {
200
- value: C,
201
- onValueChange: (e) => w(String(e)),
202
- children: [/* @__PURE__ */ M(d, {
207
+ x.length > 1 && /* @__PURE__ */ R(d, {
208
+ value: O,
209
+ onValueChange: (e) => D(String(e)),
210
+ children: [/* @__PURE__ */ L(m, {
203
211
  size: "sm",
204
- "aria-label": p("groupEditor.edgeKind"),
205
- children: /* @__PURE__ */ M(f, { children: (e) => x(i, e) })
206
- }), /* @__PURE__ */ M(l, { children: y.map((e) => /* @__PURE__ */ M(u, {
212
+ "aria-label": c("groupEditor.edgeKind"),
213
+ children: /* @__PURE__ */ L(h, { children: (e) => w(o, e) })
214
+ }), /* @__PURE__ */ L(f, { children: x.map((e) => /* @__PURE__ */ L(p, {
207
215
  value: e,
208
- children: x(i, e)
216
+ children: w(o, e)
209
217
  }, e)) })]
210
218
  }),
211
- C && /* @__PURE__ */ M(b, {
212
- kind: C,
213
- label: p("contentEditor.group"),
214
- client: a,
215
- onPick: (e) => D({ group_id: e.id })
216
- }, C)
219
+ O && /* @__PURE__ */ L(C, {
220
+ kind: O,
221
+ label: c("contentEditor.group"),
222
+ client: s,
223
+ onPick: (e) => j({ group_id: e.id })
224
+ }, O)
217
225
  ]
218
226
  }),
219
- t.level !== "public" && /* @__PURE__ */ N("div", {
227
+ e.level !== "public" && /* @__PURE__ */ R("div", {
220
228
  className: "grid gap-3 sm:grid-cols-3",
221
229
  children: [
222
- /* @__PURE__ */ N("div", {
230
+ M && /* @__PURE__ */ R("div", {
223
231
  className: "grid gap-1.5",
224
- children: [/* @__PURE__ */ M(s, {
225
- htmlFor: `${m}-pages`,
226
- children: p("contentEditor.previewPages")
227
- }), /* @__PURE__ */ M(o, {
228
- id: `${m}-pages`,
232
+ children: [/* @__PURE__ */ L(u, {
233
+ htmlFor: `${g}-pages`,
234
+ children: c("contentEditor.previewPages")
235
+ }), /* @__PURE__ */ L(l, {
236
+ id: `${g}-pages`,
229
237
  className: "h-8",
230
238
  type: "number",
231
239
  min: 0,
232
- value: t.preview?.pages ?? "",
233
- onChange: (e) => D({ preview: {
234
- ...t.preview,
235
- pages: e.target.value ? Math.max(0, Math.trunc(Number(e.target.value))) : void 0
240
+ value: e.preview?.pages ?? "",
241
+ onChange: (t) => j({ preview: {
242
+ ...e.preview,
243
+ pages: t.target.value ? Math.max(0, Math.trunc(Number(t.target.value))) : void 0
236
244
  } })
237
245
  })]
238
246
  }),
239
- /* @__PURE__ */ N("div", {
247
+ N && /* @__PURE__ */ R("div", {
240
248
  className: "grid gap-1.5",
241
- children: [/* @__PURE__ */ M(s, {
242
- htmlFor: `${m}-segments`,
243
- children: p("contentEditor.previewSegments")
244
- }), /* @__PURE__ */ M(o, {
245
- id: `${m}-segments`,
249
+ children: [/* @__PURE__ */ L(u, {
250
+ htmlFor: `${g}-segments`,
251
+ children: c("contentEditor.previewSegments")
252
+ }), /* @__PURE__ */ L(l, {
253
+ id: `${g}-segments`,
246
254
  className: "h-8",
247
255
  type: "number",
248
256
  min: 0,
249
- value: t.preview?.segments ?? "",
250
- onChange: (e) => D({ preview: {
251
- ...t.preview,
252
- segments: e.target.value ? Math.max(0, Math.trunc(Number(e.target.value))) : void 0
257
+ value: e.preview?.segments ?? "",
258
+ onChange: (t) => j({ preview: {
259
+ ...e.preview,
260
+ segments: t.target.value ? Math.max(0, Math.trunc(Number(t.target.value))) : void 0
253
261
  } })
254
262
  })]
255
263
  }),
256
- /* @__PURE__ */ N("div", {
264
+ /* @__PURE__ */ R("div", {
257
265
  className: "grid gap-1.5",
258
- children: [/* @__PURE__ */ M(s, {
259
- htmlFor: `${m}-free`,
260
- children: p("contentEditor.freeAfter")
261
- }), /* @__PURE__ */ M(o, {
262
- id: `${m}-free`,
266
+ children: [/* @__PURE__ */ L(u, {
267
+ htmlFor: `${g}-free`,
268
+ children: c("contentEditor.freeAfter")
269
+ }), /* @__PURE__ */ L(l, {
270
+ id: `${g}-free`,
263
271
  className: "h-8",
264
272
  type: "datetime-local",
265
- value: v(t.free_after),
266
- onChange: (e) => D({ free_after: g(e.target.value) })
273
+ value: S(e.free_after),
274
+ onChange: (e) => j({ free_after: b(e.target.value) })
267
275
  })]
268
276
  })
269
277
  ]
@@ -271,7 +279,8 @@ function U({ value: t, onChange: n, model: r, labels: i, client: a }) {
271
279
  ]
272
280
  });
273
281
  }
274
- function W(e) {
282
+ var X = (e) => !W(e.level) || !!e.group_id;
283
+ function Z(e) {
275
284
  let t = e.preview && (e.preview.pages || e.preview.segments) ? {
276
285
  pages: e.preview.pages || void 0,
277
286
  segments: e.preview.segments || void 0
@@ -284,401 +293,455 @@ function W(e) {
284
293
  free_after: e.level === "public" ? void 0 : e.free_after
285
294
  };
286
295
  }
287
- function G({ content: r, ...i }) {
288
- let { t: a } = e(), o = t(i.client), { model: s } = V(r.kind, i.client), [c, l] = j(r.access);
289
- O(() => l(r.access), [r.revision, r.access]);
290
- let [u, d] = j(!1), f = m("content.save", i.onError), h = m("offer.save", i.onError);
291
- return /* @__PURE__ */ N(z, {
292
- title: a("contentEditor.accessTitle"),
296
+ function ee({ content: e, ...r }) {
297
+ let { t: i } = t(), o = n(r.client), { model: s } = q(e.kind, r.client), [c, l] = I(e.access);
298
+ N(() => l(e.access), [e.revision, e.access]);
299
+ let [u, d] = I(!1), f = v("content.save", r.onError), p = v("offer.save", r.onError);
300
+ return /* @__PURE__ */ R(G, {
301
+ title: i("contentEditor.accessTitle"),
293
302
  ckui: "access-editor",
294
303
  children: [
295
- /* @__PURE__ */ N("form", {
304
+ /* @__PURE__ */ R("form", {
296
305
  className: "grid gap-3",
297
- onSubmit: (e) => {
298
- e.preventDefault(), d(!1), f.run(() => o.contents.update(r.id, {
299
- access: W(c),
300
- revision: r.revision
306
+ onSubmit: (t) => {
307
+ t.preventDefault(), d(!1), f.run(() => o.contents.update(e.id, {
308
+ access: Z(c),
309
+ revision: e.revision
301
310
  })).then((e) => e && d(!0));
302
311
  },
303
312
  children: [
304
- /* @__PURE__ */ M(U, {
313
+ /* @__PURE__ */ L(Y, {
305
314
  value: c,
306
315
  onChange: l,
307
316
  model: s,
308
- labels: i.labels,
317
+ kind: e.kind,
318
+ owner: e.owner_group_id,
319
+ labels: r.labels,
309
320
  client: o
310
321
  }),
311
- /* @__PURE__ */ M(p, { error: f.error }),
312
- /* @__PURE__ */ N("div", {
322
+ /* @__PURE__ */ L(_, { error: f.error }),
323
+ /* @__PURE__ */ R("div", {
313
324
  className: "flex items-center gap-3",
314
- children: [/* @__PURE__ */ M(n, {
325
+ children: [/* @__PURE__ */ L(a, {
315
326
  type: "submit",
316
327
  size: "sm",
317
- disabled: f.pending,
318
- children: f.pending ? a("common.saving") : a("common.save")
319
- }), /* @__PURE__ */ M(B, { show: u })]
328
+ disabled: f.pending || !X(c),
329
+ children: f.pending ? i("common.saving") : i("common.save")
330
+ }), /* @__PURE__ */ L(K, { show: u })]
320
331
  })
321
332
  ]
322
333
  }),
323
- /* @__PURE__ */ M(w, {
324
- offer: r.offer,
325
- pending: h.pending,
326
- onSell: (e) => void h.run(() => o.offers.sell({ content: r.id }, e)),
327
- onWithdraw: () => void h.run(() => o.offers.withdraw({ content: r.id }))
334
+ /* @__PURE__ */ L(E, {
335
+ offer: e.offer,
336
+ pending: p.pending,
337
+ onSell: (t) => void p.run(() => o.offers.sell({ content: e.id }, t)),
338
+ onWithdraw: () => void p.run(() => o.offers.withdraw({ content: e.id }))
328
339
  }),
329
- /* @__PURE__ */ M(p, { error: h.error })
340
+ /* @__PURE__ */ L(_, { error: p.error })
330
341
  ]
331
342
  });
332
343
  }
333
- function K(e, t, n) {
334
- return e.label || [...e.languages.map(t), ...e.traits.map((e) => x(n, e))].join(" · ");
344
+ function Q(e, t, n) {
345
+ return e.label || [...e.languages.map(t), ...e.traits.map((e) => w(n, e))].join(" · ");
335
346
  }
336
- function q({ content: i, media: o = !0, ...s }) {
337
- let { t: c } = e(), l = t(s.client), u = C(), { model: d, spec: f } = V(i.kind, s.client), h = m("content.save", s.onError), g = m("content.save", s.onError), [_, v] = j(null), y = A(() => [...i.versions].sort((e, t) => e.position - t.position), [i.versions]);
338
- if (f?.versions.hidden) return null;
339
- let b = d?.languages ?? [];
340
- return /* @__PURE__ */ N(z, {
341
- title: c("contentEditor.versions"),
347
+ function te({ content: r, media: i = !0, ...s }) {
348
+ let { t: l } = t(), u = n(s.client), d = e(), { model: f, spec: p } = q(r.kind, s.client), m = v("content.save", s.onError), h = v("content.save", s.onError), [g, y] = I(null), b = F(() => [...r.versions].sort((e, t) => e.position - t.position), [r.versions]);
349
+ if (!p) return null;
350
+ if (p.versions.hidden) {
351
+ let e = b[0];
352
+ return !e || !i && !p.segments ? null : /* @__PURE__ */ R(G, {
353
+ title: l("contentEditor.media"),
354
+ ckui: "version-media",
355
+ children: [p.segments && /* @__PURE__ */ L($, {
356
+ content: r,
357
+ version: e,
358
+ ...s
359
+ }), i && /* @__PURE__ */ L(ae, {
360
+ content: r,
361
+ version: e,
362
+ model: f,
363
+ ...s
364
+ })]
365
+ });
366
+ }
367
+ let x = f?.languages ?? [];
368
+ return /* @__PURE__ */ R(G, {
369
+ title: l("contentEditor.versions"),
342
370
  ckui: "versions-editor",
343
371
  children: [
344
- /* @__PURE__ */ M(r, {
345
- items: y,
372
+ /* @__PURE__ */ L(o, {
373
+ items: b,
346
374
  id: (e) => e.id,
347
- name: (e) => K(e, u, s.labels),
348
- label: c("contentEditor.versions"),
349
- disabled: h.pending || y.length < 2,
375
+ name: (e) => Q(e, d, s.labels),
376
+ label: l("contentEditor.versions"),
377
+ disabled: m.pending || b.length < 2,
350
378
  onMove: (e, t) => {
351
- let n = y.map((e) => e.id), [r] = n.splice(e, 1);
352
- n.splice(t, 0, r), h.run(() => l.contents.orderVersions(i.id, n));
379
+ let n = b.map((e) => e.id), [i] = n.splice(e, 1);
380
+ n.splice(t, 0, i), m.run(() => u.contents.orderVersions(r.id, n));
353
381
  },
354
- children: (e, t) => /* @__PURE__ */ N("div", {
382
+ children: (e, t) => /* @__PURE__ */ R("div", {
355
383
  className: "grid gap-2 rounded-md border border-border p-2",
356
384
  "data-ckui": "version-row",
357
385
  "data-version": e.id,
358
- children: [/* @__PURE__ */ N("div", {
386
+ children: [/* @__PURE__ */ R("div", {
359
387
  className: "flex flex-wrap items-center gap-2",
360
388
  children: [
361
- y.length > 1 && t,
362
- /* @__PURE__ */ M("span", {
389
+ b.length > 1 && t,
390
+ /* @__PURE__ */ L("span", {
363
391
  className: "min-w-0 flex-1 font-medium break-words",
364
- children: K(e, u, s.labels)
392
+ children: Q(e, d, s.labels)
365
393
  }),
366
- /* @__PURE__ */ M(a, {
394
+ /* @__PURE__ */ L(c, {
367
395
  variant: e.live ? "default" : "outline",
368
- children: c(e.live ? "contentEditor.live" : e.state === "draft" ? "contentManager.draft" : "contentManager.scheduled")
396
+ children: l(e.live ? "contentEditor.live" : e.state === "draft" ? "contentManager.draft" : "contentManager.scheduled")
369
397
  }),
370
- e.access && /* @__PURE__ */ M(a, {
398
+ e.access && /* @__PURE__ */ L(c, {
371
399
  variant: "secondary",
372
- children: c(`contentEditor.level_${e.access.level}`)
400
+ children: l(`contentEditor.level_${e.access.level}`)
373
401
  }),
374
- e.pages ? /* @__PURE__ */ M("span", {
402
+ e.pages ? /* @__PURE__ */ L("span", {
375
403
  className: "text-xs text-muted-foreground",
376
- children: c("contentEditor.pageCount", { count: e.pages })
404
+ children: l("contentEditor.pageCount", { count: e.pages })
377
405
  }) : null,
378
- /* @__PURE__ */ M(n, {
406
+ /* @__PURE__ */ L(a, {
379
407
  type: "button",
380
408
  size: "xs",
381
409
  variant: "ghost",
382
- "aria-expanded": _ === e.id,
383
- onClick: () => v(_ === e.id ? null : e.id),
384
- children: c(_ === e.id ? "contentEditor.close" : "contentEditor.edit")
410
+ "aria-expanded": g === e.id,
411
+ onClick: () => y(g === e.id ? null : e.id),
412
+ children: l(g === e.id ? "contentEditor.close" : "contentEditor.edit")
385
413
  })
386
414
  ]
387
- }), _ === e.id && /* @__PURE__ */ M(X, {
388
- content: i,
415
+ }), g === e.id && /* @__PURE__ */ L(ie, {
416
+ content: r,
389
417
  version: e,
390
- model: d,
391
- media: o,
418
+ model: f,
419
+ media: i,
392
420
  ...s
393
421
  })]
394
422
  })
395
423
  }),
396
- /* @__PURE__ */ M(p, { error: h.error }),
397
- /* @__PURE__ */ M(Y, {
398
- languages: b,
399
- many: f?.versions.languages === "many",
400
- pending: g.pending,
401
- onAdd: (e) => void g.run(() => l.contents.addVersion(i.id, e))
424
+ /* @__PURE__ */ L(_, { error: m.error }),
425
+ /* @__PURE__ */ L(re, {
426
+ languages: x,
427
+ many: p?.versions.languages === "many",
428
+ pending: h.pending,
429
+ onAdd: (e) => void h.run(() => u.contents.addVersion(r.id, e)).then((e) => e && y(e.id))
402
430
  }),
403
- /* @__PURE__ */ M(p, { error: g.error })
431
+ /* @__PURE__ */ L(_, { error: h.error })
404
432
  ]
405
433
  });
406
434
  }
407
- function J({ languages: t, value: n, many: r, onChange: i }) {
408
- let { t: a } = e(), o = C();
409
- return r ? /* @__PURE__ */ N("fieldset", {
435
+ function ne({ languages: n, value: r, many: i, onChange: a }) {
436
+ let { t: o } = t(), s = e();
437
+ return i ? /* @__PURE__ */ R("fieldset", {
410
438
  className: "flex flex-wrap gap-3",
411
- children: [/* @__PURE__ */ M("legend", {
439
+ children: [/* @__PURE__ */ L("legend", {
412
440
  className: "sr-only",
413
- children: a("contentEditor.versionLanguages")
414
- }), t.map((e) => /* @__PURE__ */ N("label", {
441
+ children: o("contentEditor.versionLanguages")
442
+ }), n.map((e) => /* @__PURE__ */ R("label", {
415
443
  className: "flex items-center gap-1.5",
416
- children: [/* @__PURE__ */ M(h, {
444
+ children: [/* @__PURE__ */ L(y, {
417
445
  size: "sm",
418
- checked: n.includes(e),
419
- onCheckedChange: (t) => i(t ? [...n, e] : n.filter((t) => t !== e)),
420
- "aria-label": o(e)
421
- }), o(e)]
446
+ checked: r.includes(e),
447
+ onCheckedChange: (t) => a(t ? [...r, e] : r.filter((t) => t !== e)),
448
+ "aria-label": s(e)
449
+ }), s(e)]
422
450
  }, e))]
423
- }) : /* @__PURE__ */ N(c, {
424
- value: n[0] ?? F,
425
- onValueChange: (e) => i(e === F ? [] : [String(e)]),
426
- children: [/* @__PURE__ */ M(d, {
451
+ }) : /* @__PURE__ */ R(d, {
452
+ value: r[0] ?? B,
453
+ onValueChange: (e) => a(e === B ? [] : [String(e)]),
454
+ children: [/* @__PURE__ */ L(m, {
427
455
  size: "sm",
428
- "aria-label": a("contentEditor.versionLanguage"),
429
- children: /* @__PURE__ */ M(f, { children: (e) => e === F ? a("contentEditor.chooseLanguage") : o(e) })
430
- }), /* @__PURE__ */ M(l, { children: t.map((e) => /* @__PURE__ */ M(u, {
456
+ "aria-label": o("contentEditor.versionLanguage"),
457
+ children: /* @__PURE__ */ L(h, { children: (e) => e === B ? o("contentEditor.chooseLanguage") : s(e) })
458
+ }), /* @__PURE__ */ L(f, { children: n.map((e) => /* @__PURE__ */ L(p, {
431
459
  value: e,
432
- children: o(e)
460
+ children: s(e)
433
461
  }, e)) })]
434
462
  });
435
463
  }
436
- function Y({ languages: t, many: r, pending: i, onAdd: a }) {
437
- let { t: o } = e(), [s, c] = j([]);
438
- return /* @__PURE__ */ N("div", {
464
+ function re({ languages: e, many: n, pending: r, onAdd: i }) {
465
+ let { t: o } = t(), [s, c] = I([]);
466
+ return /* @__PURE__ */ R("div", {
439
467
  className: "flex flex-wrap items-center gap-2",
440
468
  "data-ckui": "add-version",
441
- children: [/* @__PURE__ */ M(J, {
442
- languages: t,
469
+ children: [/* @__PURE__ */ L(ne, {
470
+ languages: e,
443
471
  value: s,
444
- many: r,
472
+ many: n,
445
473
  onChange: c
446
- }), /* @__PURE__ */ M(n, {
474
+ }), /* @__PURE__ */ L(a, {
447
475
  type: "button",
448
476
  size: "sm",
449
477
  variant: "outline",
450
- disabled: i || !s.length,
478
+ disabled: r || !s.length,
451
479
  onClick: () => {
452
- a({ languages: s }), c([]);
480
+ i({ languages: s }), c([]);
453
481
  },
454
482
  children: o("contentEditor.addVersion")
455
483
  })]
456
484
  });
457
485
  }
458
- function X({ content: r, version: a, model: c, media: l, ...u }) {
459
- let { t: d } = e(), f = k(), _ = t(u.client), y = c?.kinds[r.kind], [b, S] = j(a.languages), [C, T] = j(a.traits), [E, D] = j(a.label ?? ""), [O, A] = j(a.state === "draft"), [P, F] = j(v(a.publish_at)), [I, L] = j(!!a.access), [R, z] = j(a.access ?? r.access), [V, H] = j(!1), G = m("content.save", u.onError), K = m("content.save", u.onError), q = m("offer.save", u.onError);
460
- return /* @__PURE__ */ N("div", {
486
+ function ie({ content: e, version: r, model: i, media: o, ...s }) {
487
+ let { t: c } = t(), d = P(), f = n(s.client), p = i?.kinds[e.kind], [m, h] = I(r.languages), [g, x] = I(r.traits), [C, T] = I(r.label ?? ""), [D, O] = I(r.state === "draft"), [k, j] = I(S(r.publish_at)), [M, N] = I(!!r.access), [F, z] = I(r.access ?? e.access), [B, V] = I(!1), H = v("content.save", s.onError), U = v("content.save", s.onError), W = v("offer.save", s.onError);
488
+ return /* @__PURE__ */ R("div", {
461
489
  className: "grid gap-4 pt-2",
462
490
  children: [
463
- /* @__PURE__ */ N("form", {
491
+ /* @__PURE__ */ R("form", {
464
492
  className: "grid gap-3",
465
- onSubmit: (e) => {
466
- e.preventDefault(), H(!1), G.run(() => _.contents.updateVersion(r.id, a.id, {
467
- languages: b,
468
- traits: C,
469
- label: E.trim(),
470
- state: O ? "draft" : "published",
471
- publish_at: g(P),
472
- ...I ? { access: W(R) } : { clear_access: !!a.access }
473
- })).then((e) => e && H(!0));
493
+ onSubmit: (t) => {
494
+ t.preventDefault(), V(!1), H.run(() => f.contents.updateVersion(e.id, r.id, {
495
+ languages: m,
496
+ traits: g,
497
+ label: C.trim(),
498
+ state: D ? "draft" : "published",
499
+ publish_at: b(k),
500
+ ...M ? { access: Z(F) } : { clear_access: !!r.access }
501
+ })).then((e) => e && V(!0));
474
502
  },
475
503
  children: [
476
- /* @__PURE__ */ M(J, {
477
- languages: c?.languages ?? [],
478
- value: b,
479
- many: y?.versions.languages === "many",
480
- onChange: S
504
+ /* @__PURE__ */ L(ne, {
505
+ languages: i?.languages ?? [],
506
+ value: m,
507
+ many: p?.versions.languages === "many",
508
+ onChange: h
481
509
  }),
482
- !!y?.versions.traits?.length && /* @__PURE__ */ N("fieldset", {
510
+ !!p?.versions.traits?.length && /* @__PURE__ */ R("fieldset", {
483
511
  className: "flex flex-wrap gap-3",
484
- children: [/* @__PURE__ */ M("legend", {
512
+ children: [/* @__PURE__ */ L("legend", {
485
513
  className: "sr-only",
486
- children: d("contentEditor.traits")
487
- }), y.versions.traits.map((e) => /* @__PURE__ */ N("label", {
514
+ children: c("contentEditor.traits")
515
+ }), p.versions.traits.map((e) => /* @__PURE__ */ R("label", {
488
516
  className: "flex items-center gap-1.5",
489
- children: [/* @__PURE__ */ M(h, {
517
+ children: [/* @__PURE__ */ L(y, {
490
518
  size: "sm",
491
- checked: C.includes(e),
492
- onCheckedChange: (t) => T(t ? [...C, e] : C.filter((t) => t !== e)),
493
- "aria-label": x(u.labels, e)
494
- }), x(u.labels, e)]
519
+ checked: g.includes(e),
520
+ onCheckedChange: (t) => x(t ? [...g, e] : g.filter((t) => t !== e)),
521
+ "aria-label": w(s.labels, e)
522
+ }), w(s.labels, e)]
495
523
  }, e))]
496
524
  }),
497
- /* @__PURE__ */ N("div", {
525
+ /* @__PURE__ */ R("div", {
498
526
  className: "grid gap-3 sm:grid-cols-2",
499
- children: [/* @__PURE__ */ N("div", {
527
+ children: [/* @__PURE__ */ R("div", {
500
528
  className: "grid gap-1.5",
501
- children: [/* @__PURE__ */ M(s, {
502
- htmlFor: `${f}-label`,
503
- children: d("contentEditor.versionLabel")
504
- }), /* @__PURE__ */ M(o, {
505
- id: `${f}-label`,
529
+ children: [/* @__PURE__ */ L(u, {
530
+ htmlFor: `${d}-label`,
531
+ children: c("contentEditor.versionLabel")
532
+ }), /* @__PURE__ */ L(l, {
533
+ id: `${d}-label`,
506
534
  className: "h-8",
507
- value: E,
508
- onChange: (e) => D(e.target.value)
535
+ value: C,
536
+ onChange: (e) => T(e.target.value)
509
537
  })]
510
- }), /* @__PURE__ */ N("div", {
538
+ }), /* @__PURE__ */ R("div", {
511
539
  className: "grid gap-1.5",
512
- children: [/* @__PURE__ */ M(s, {
513
- htmlFor: `${f}-at`,
514
- children: d("contentEditor.versionPublishAt")
515
- }), /* @__PURE__ */ M(o, {
516
- id: `${f}-at`,
540
+ children: [/* @__PURE__ */ L(u, {
541
+ htmlFor: `${d}-at`,
542
+ children: c("contentEditor.versionPublishAt")
543
+ }), /* @__PURE__ */ L(l, {
544
+ id: `${d}-at`,
517
545
  className: "h-8",
518
546
  type: "datetime-local",
519
- value: P,
520
- onChange: (e) => F(e.target.value)
547
+ value: k,
548
+ onChange: (e) => j(e.target.value)
521
549
  })]
522
550
  })]
523
551
  }),
524
- /* @__PURE__ */ N("label", {
552
+ /* @__PURE__ */ R("label", {
525
553
  className: "flex items-center gap-2",
526
- children: [/* @__PURE__ */ M(h, {
554
+ children: [/* @__PURE__ */ L(y, {
527
555
  size: "sm",
528
- checked: O,
529
- onCheckedChange: A
530
- }), d("contentEditor.versionDraft")]
556
+ checked: D,
557
+ onCheckedChange: O
558
+ }), c("contentEditor.versionDraft")]
531
559
  }),
532
- /* @__PURE__ */ N("label", {
560
+ /* @__PURE__ */ R("label", {
533
561
  className: "flex items-center gap-2",
534
- children: [/* @__PURE__ */ M(h, {
562
+ children: [/* @__PURE__ */ L(y, {
535
563
  size: "sm",
536
- checked: I,
537
- onCheckedChange: L
538
- }), d("contentEditor.ownAccess")]
564
+ checked: M,
565
+ onCheckedChange: N
566
+ }), c("contentEditor.ownAccess")]
539
567
  }),
540
- I && /* @__PURE__ */ M(U, {
541
- value: R,
568
+ M && /* @__PURE__ */ L(Y, {
569
+ value: F,
542
570
  onChange: z,
543
- model: c,
544
- labels: u.labels,
545
- client: _
571
+ model: i,
572
+ kind: e.kind,
573
+ owner: e.owner_group_id,
574
+ labels: s.labels,
575
+ client: f
546
576
  }),
547
- /* @__PURE__ */ M(p, { error: G.error }),
548
- /* @__PURE__ */ N("div", {
577
+ /* @__PURE__ */ L(_, { error: H.error }),
578
+ /* @__PURE__ */ R("div", {
549
579
  className: "flex flex-wrap items-center gap-3",
550
580
  children: [
551
- /* @__PURE__ */ M(n, {
581
+ /* @__PURE__ */ L(a, {
552
582
  type: "submit",
553
583
  size: "sm",
554
- disabled: G.pending || !b.length,
555
- children: G.pending ? d("common.saving") : d("common.save")
584
+ disabled: H.pending || !m.length || M && !X(F),
585
+ children: H.pending ? c("common.saving") : c("common.save")
556
586
  }),
557
- /* @__PURE__ */ M(B, { show: V }),
558
- /* @__PURE__ */ M(n, {
587
+ /* @__PURE__ */ L(K, { show: B }),
588
+ /* @__PURE__ */ L(a, {
559
589
  type: "button",
560
590
  size: "sm",
561
591
  variant: "destructive",
562
592
  className: "ms-auto",
563
- disabled: K.pending,
564
- onClick: () => void K.run(() => _.contents.removeVersion(r.id, a.id)),
565
- children: d("contentEditor.deleteVersion")
593
+ disabled: U.pending,
594
+ onClick: () => void U.run(() => f.contents.removeVersion(e.id, r.id)),
595
+ children: c("contentEditor.deleteVersion")
566
596
  })
567
597
  ]
568
598
  }),
569
- /* @__PURE__ */ M(p, { error: K.error })
599
+ /* @__PURE__ */ L(_, { error: U.error })
570
600
  ]
571
601
  }),
572
- /* @__PURE__ */ M(w, {
573
- offer: a.offer,
574
- pending: q.pending,
575
- onSell: (e) => void q.run(() => _.offers.sell({
576
- content: r.id,
577
- version: a.id
578
- }, e)),
579
- onWithdraw: () => void q.run(() => _.offers.withdraw({
580
- content: r.id,
581
- version: a.id
602
+ /* @__PURE__ */ L(E, {
603
+ offer: r.offer,
604
+ pending: W.pending,
605
+ onSell: (t) => void W.run(() => f.offers.sell({
606
+ content: e.id,
607
+ version: r.id
608
+ }, t)),
609
+ onWithdraw: () => void W.run(() => f.offers.withdraw({
610
+ content: e.id,
611
+ version: r.id
582
612
  }))
583
613
  }),
584
- /* @__PURE__ */ M(p, { error: q.error }),
585
- y?.segments && /* @__PURE__ */ M(Z, {
586
- content: r,
587
- version: a,
588
- ...u
614
+ /* @__PURE__ */ L(_, { error: W.error }),
615
+ p?.segments && /* @__PURE__ */ L($, {
616
+ content: e,
617
+ version: r,
618
+ ...s
589
619
  }),
590
- l && /* @__PURE__ */ M(i, {
591
- item: {
592
- kind: r.kind,
593
- id: r.id,
594
- version: a.id
595
- },
596
- label: d("contentEditor.media")
620
+ o && /* @__PURE__ */ L(ae, {
621
+ content: e,
622
+ version: r,
623
+ model: i,
624
+ ...s
625
+ }),
626
+ o && p?.presentation === "reader" && /* @__PURE__ */ L(A, {
627
+ content: e.id,
628
+ version: r.id,
629
+ client: s.client,
630
+ onError: s.onError
597
631
  })
598
632
  ]
599
633
  });
600
634
  }
601
- function Z({ content: r, version: i, ...a }) {
602
- let { t: s } = e(), c = t(a.client), l = () => i.segments.map((e) => ({
635
+ function ae({ content: n, version: r, model: a, ...o }) {
636
+ let { t: c } = t(), l = e(), u = F(() => ({
637
+ kind: n.kind,
638
+ id: n.id,
639
+ version: r.id
640
+ }), [
641
+ n.kind,
642
+ n.id,
643
+ r.id
644
+ ]), d = i(u, {
645
+ editor: !0,
646
+ client: o.client
647
+ }), f = F(() => (a?.languages ?? []).map((e) => ({
648
+ value: e,
649
+ label: l(e)
650
+ })), [a, l]);
651
+ return !d.read && d.loading ? /* @__PURE__ */ L(g, { className: "h-24 w-full" }) : d.read?.uploads && M(d.read.uploads).source ? /* @__PURE__ */ L(j, {
652
+ item: u,
653
+ languages: f,
654
+ client: o.client,
655
+ onError: o.onError
656
+ }) : /* @__PURE__ */ L(s, {
657
+ item: u,
658
+ commit: r.live ? "manual" : "auto",
659
+ label: c("contentEditor.media"),
660
+ client: o.client,
661
+ onError: o.onError
662
+ });
663
+ }
664
+ function $({ content: e, version: r, ...i }) {
665
+ let { t: o } = t(), s = n(i.client), c = () => r.segments.map((e) => ({
603
666
  title: e.title ?? "",
604
667
  start: String(e.start),
605
668
  end: String(e.end),
606
- release: v(e.release_at)
607
- })), [u, d] = j(l);
608
- O(() => d(l()), [JSON.stringify(i.segments)]);
609
- let [f, h] = j(!1), _ = m("content.save", a.onError), y = (e, t) => {
610
- h(!1), d((n) => n.map((n, r) => r === e ? {
669
+ release: S(e.release_at)
670
+ })), [u, d] = I(c);
671
+ N(() => d(c()), [JSON.stringify(r.segments)]);
672
+ let [f, p] = I(!1), m = v("content.save", i.onError), h = (e, t) => {
673
+ p(!1), d((n) => n.map((n, r) => r === e ? {
611
674
  ...n,
612
675
  ...t
613
676
  } : n));
614
- }, b = u.every((e) => /^\d+$/.test(e.start) && /^\d+$/.test(e.end) && Number(e.end) > Number(e.start));
615
- return /* @__PURE__ */ N("div", {
677
+ }, g = u.every((e) => /^\d+$/.test(e.start) && /^\d+$/.test(e.end) && Number(e.end) > Number(e.start));
678
+ return /* @__PURE__ */ R("div", {
616
679
  className: "grid gap-2",
617
680
  "data-ckui": "segments-editor",
618
681
  children: [
619
- /* @__PURE__ */ M("h4", {
682
+ /* @__PURE__ */ L("h4", {
620
683
  className: "text-sm font-medium",
621
- children: s("contentEditor.segments")
684
+ children: o("contentEditor.segments")
622
685
  }),
623
- u.length === 0 && /* @__PURE__ */ M("p", {
686
+ u.length === 0 && /* @__PURE__ */ L("p", {
624
687
  className: "text-muted-foreground",
625
- children: s("contentEditor.noSegments")
688
+ children: o("contentEditor.noSegments")
626
689
  }),
627
- u.map((e, t) => /* @__PURE__ */ N("div", {
690
+ u.map((e, t) => /* @__PURE__ */ R("div", {
628
691
  className: "flex flex-wrap items-center gap-2",
629
692
  "data-ckui": "segment-row",
630
693
  children: [
631
- /* @__PURE__ */ M("span", {
694
+ /* @__PURE__ */ L("span", {
632
695
  className: "w-6 text-xs text-muted-foreground tabular-nums",
633
696
  children: t + 1
634
697
  }),
635
- /* @__PURE__ */ M(o, {
698
+ /* @__PURE__ */ L(l, {
636
699
  className: "h-8 w-40",
637
- "aria-label": s("contentEditor.segmentTitle", { n: t + 1 }),
638
- placeholder: s("contentEditor.segmentTitlePlaceholder"),
700
+ "aria-label": o("contentEditor.segmentTitle", { n: t + 1 }),
701
+ placeholder: o("contentEditor.segmentTitlePlaceholder"),
639
702
  value: e.title,
640
- onChange: (e) => y(t, { title: e.target.value })
703
+ onChange: (e) => h(t, { title: e.target.value })
641
704
  }),
642
- /* @__PURE__ */ M(o, {
705
+ /* @__PURE__ */ L(l, {
643
706
  className: "h-8 w-20",
644
707
  type: "number",
645
708
  min: 0,
646
- "aria-label": s("contentEditor.segmentStart", { n: t + 1 }),
709
+ "aria-label": o("contentEditor.segmentStart", { n: t + 1 }),
647
710
  value: e.start,
648
- onChange: (e) => y(t, { start: e.target.value })
711
+ onChange: (e) => h(t, { start: e.target.value })
649
712
  }),
650
- /* @__PURE__ */ M("span", {
713
+ /* @__PURE__ */ L("span", {
651
714
  "aria-hidden": !0,
652
715
  children: "–"
653
716
  }),
654
- /* @__PURE__ */ M(o, {
717
+ /* @__PURE__ */ L(l, {
655
718
  className: "h-8 w-20",
656
719
  type: "number",
657
720
  min: 1,
658
- "aria-label": s("contentEditor.segmentEnd", { n: t + 1 }),
721
+ "aria-label": o("contentEditor.segmentEnd", { n: t + 1 }),
659
722
  value: e.end,
660
- onChange: (e) => y(t, { end: e.target.value })
723
+ onChange: (e) => h(t, { end: e.target.value })
661
724
  }),
662
- /* @__PURE__ */ M(o, {
725
+ /* @__PURE__ */ L(l, {
663
726
  className: "h-8 w-48",
664
727
  type: "datetime-local",
665
- "aria-label": s("contentEditor.segmentRelease", { n: t + 1 }),
728
+ "aria-label": o("contentEditor.segmentRelease", { n: t + 1 }),
666
729
  value: e.release,
667
- onChange: (e) => y(t, { release: e.target.value })
730
+ onChange: (e) => h(t, { release: e.target.value })
668
731
  }),
669
- /* @__PURE__ */ M(n, {
732
+ /* @__PURE__ */ L(a, {
670
733
  type: "button",
671
734
  size: "xs",
672
735
  variant: "ghost",
673
736
  onClick: () => d((e) => e.filter((e, n) => n !== t)),
674
- children: s("common.remove")
737
+ children: o("common.remove")
675
738
  })
676
739
  ]
677
740
  }, t)),
678
- /* @__PURE__ */ N("div", {
741
+ /* @__PURE__ */ R("div", {
679
742
  className: "flex flex-wrap items-center gap-2",
680
743
  children: [
681
- /* @__PURE__ */ M(n, {
744
+ /* @__PURE__ */ L(a, {
682
745
  type: "button",
683
746
  size: "sm",
684
747
  variant: "outline",
@@ -691,74 +754,74 @@ function Z({ content: r, version: i, ...a }) {
691
754
  release: ""
692
755
  }]);
693
756
  },
694
- children: s("contentEditor.addSegment")
757
+ children: o("contentEditor.addSegment")
695
758
  }),
696
- /* @__PURE__ */ M(n, {
759
+ /* @__PURE__ */ L(a, {
697
760
  type: "button",
698
761
  size: "sm",
699
- disabled: _.pending || !b,
762
+ disabled: m.pending || !g,
700
763
  onClick: () => {
701
- h(!1);
702
- let e = u.map((e, t) => ({
764
+ p(!1);
765
+ let t = u.map((e, t) => ({
703
766
  position: t + 1,
704
767
  title: e.title.trim() || void 0,
705
768
  start: Number(e.start),
706
769
  end: Number(e.end),
707
- release_at: g(e.release),
770
+ release_at: b(e.release),
708
771
  released: !1
709
772
  }));
710
- _.run(() => c.contents.setSegments(r.id, i.id, e)).then((e) => e && h(!0));
773
+ m.run(() => s.contents.setSegments(e.id, r.id, t)).then((e) => e && p(!0));
711
774
  },
712
- children: s("contentEditor.saveSegments")
775
+ children: o("contentEditor.saveSegments")
713
776
  }),
714
- /* @__PURE__ */ M(B, { show: f })
777
+ /* @__PURE__ */ L(K, { show: f })
715
778
  ]
716
779
  }),
717
- /* @__PURE__ */ M(p, { error: _.error })
780
+ /* @__PURE__ */ L(_, { error: m.error })
718
781
  ]
719
782
  });
720
783
  }
721
- function Q({ content: e, ...t }) {
722
- let n = C(), r = A(() => e.versions.map((e) => ({
784
+ function oe({ content: t, ...n }) {
785
+ let r = e(), i = F(() => t.versions.map((e) => ({
723
786
  id: e.id,
724
- label: K(e, n, t.labels)
787
+ label: Q(e, r, n.labels)
725
788
  })), [
726
- e.versions,
727
- n,
728
- t.labels
729
- ]), { spec: i } = V(e.kind, t.client);
730
- return /* @__PURE__ */ N("div", {
731
- className: P("grid gap-6", t.className),
789
+ t.versions,
790
+ r,
791
+ n.labels
792
+ ]), { spec: a } = q(t.kind, n.client);
793
+ return /* @__PURE__ */ R("div", {
794
+ className: z("grid gap-6", n.className),
732
795
  "data-ckui": "content-sections",
733
796
  children: [
734
- /* @__PURE__ */ M(H, {
735
- content: e,
736
- ...t
797
+ /* @__PURE__ */ L(J, {
798
+ content: t,
799
+ ...n
737
800
  }),
738
- /* @__PURE__ */ M(G, {
739
- content: e,
740
- ...t
801
+ /* @__PURE__ */ L(ee, {
802
+ content: t,
803
+ ...n
741
804
  }),
742
- /* @__PURE__ */ M(q, {
743
- content: e,
744
- ...t
805
+ /* @__PURE__ */ L(te, {
806
+ content: t,
807
+ ...n
745
808
  }),
746
- !!i?.groups?.length && /* @__PURE__ */ M("section", {
809
+ !!a?.groups?.length && /* @__PURE__ */ L("section", {
747
810
  className: "grid gap-3 border-t border-border pt-4",
748
811
  "data-ckui": "content-groups",
749
- children: /* @__PURE__ */ M(D, {
750
- content: e.id,
751
- contentKind: e.kind,
752
- versions: i.versions.hidden ? void 0 : r,
753
- labels: t.labels,
754
- client: t.client,
755
- onError: t.onError
812
+ children: /* @__PURE__ */ L(k, {
813
+ content: t.id,
814
+ contentKind: t.kind,
815
+ versions: a.versions.hidden ? void 0 : i,
816
+ labels: n.labels,
817
+ client: n.client,
818
+ onError: n.onError
756
819
  })
757
820
  })
758
821
  ]
759
822
  });
760
823
  }
761
824
  //#endregion
762
- export { G as AccessEditor, H as ContentDetailsEditor, Q as ContentSections, Z as SegmentsEditor, q as VersionsEditor, K as versionLabel };
825
+ export { ee as AccessEditor, J as ContentDetailsEditor, oe as ContentSections, $ as SegmentsEditor, te as VersionsEditor, Q as versionLabel };
763
826
 
764
827
  //# sourceMappingURL=editors.js.map