@nivaro/react 0.3.18 → 0.3.20

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.
@@ -1,120 +1,138 @@
1
- import { jsx as t, jsxs as r } from "react/jsx-runtime";
2
- import { useQueryClient as De } from "@tanstack/react-query";
3
- import { Search as Te, Upload as _e, Plus as le, History as ne, Pencil as Pe, Archive as Ae, Trash2 as Ee } from "lucide-react";
4
- import { useId as Re, useState as d, useRef as y, useEffect as V } from "react";
5
- import { toast as I } from "sonner";
6
- import { useNivaroClient as Ve, useApiFetchConfig as Ie, useItemEditAuth as Le } from "../../../context.js";
7
- import { Button as u } from "../../ui/button.js";
8
- import { Input as Oe } from "../../ui/input.js";
9
- import { modalHostOf as He } from "../../ui/popover.js";
10
- import { useHelpVideoLibrary as Ue, helpVideoApi as L, helpVideoKeys as N, helpVideoError as de } from "../api.js";
11
- import { HelpVideoEditor as qe } from "../editor/HelpVideoEditor.js";
12
- import { canRecord as ze } from "../recorder/HelpVideoRecorder.js";
13
- import { useHelpVideoRecording as Fe, RECORDING_BUSY as Be } from "../recorder/HelpVideoRecordingProvider.js";
14
- import { useHelpVideoUpload as Ke } from "../upload/HelpVideoUpload.js";
15
- import { emptyCopy as ce, progressLabel as Qe, isGettingReady as je, formatDuration as Ge, showingLabel as ue } from "../viewer/format.js";
16
- import { HelpVideoSheet as Me } from "../viewer/HelpVideoSheet.js";
17
- import { momentFromParams as Ye } from "../viewer/moments.js";
18
- import { LearningPathsPanel as Je } from "./LearningPathsPanel.js";
19
- import { PurgeVideoDialog as Xe } from "./PurgeVideoDialog.js";
20
- import { RECORD_UNSUPPORTED as Ze } from "../recorder/RecorderStatus.js";
21
- const We = {
1
+ import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
+ import { useQueryClient as _e } from "@tanstack/react-query";
3
+ import { Search as Pe, Upload as Te, Plus as ne, History as de, Pencil as Ee, EyeOff as Ae, Send as Re, Archive as Ve, Trash2 as Ie } from "lucide-react";
4
+ import { useId as Le, useState as c, useRef as k, useEffect as U } from "react";
5
+ import { toast as E } from "sonner";
6
+ import { useNivaroClient as Oe, useApiFetchConfig as Ue, useItemEditAuth as He } from "../../../context.js";
7
+ import { Button as n } from "../../ui/button.js";
8
+ import { Input as qe } from "../../ui/input.js";
9
+ import { modalHostOf as ze } from "../../ui/popover.js";
10
+ import { useHelpVideoLibrary as Be, helpVideoApi as C, helpVideoKeys as y, helpVideoError as ce } from "../api.js";
11
+ import { HelpVideoEditor as Fe } from "../editor/HelpVideoEditor.js";
12
+ import { canRecord as Ke } from "../recorder/HelpVideoRecorder.js";
13
+ import { useHelpVideoRecording as Qe, RECORDING_BUSY as je } from "../recorder/HelpVideoRecordingProvider.js";
14
+ import { useHelpVideoUpload as Ge } from "../upload/HelpVideoUpload.js";
15
+ import { emptyCopy as ue, progressLabel as Me, isGettingReady as Ye, formatDuration as Je, showingLabel as he } from "../viewer/format.js";
16
+ import { HelpVideoSheet as Xe } from "../viewer/HelpVideoSheet.js";
17
+ import { momentFromParams as Ze } from "../viewer/moments.js";
18
+ import { LearningPathsPanel as We } from "./LearningPathsPanel.js";
19
+ import { PurgeVideoDialog as et } from "./PurgeVideoDialog.js";
20
+ import { RECORD_UNSUPPORTED as tt } from "../recorder/RecorderStatus.js";
21
+ const at = {
22
22
  published: "Published",
23
23
  draft: "Drafts",
24
24
  archived: "Archived",
25
25
  paths: "Paths"
26
- }, O = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan motion-reduce:transition-none";
27
- function Nt({
28
- watchId: H,
29
- editId: U,
30
- onWatch: q,
31
- onEdit: h,
26
+ }, H = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan motion-reduce:transition-none";
27
+ function kt({
28
+ watchId: q,
29
+ editId: z,
30
+ onWatch: B,
31
+ onEdit: f,
32
32
  headerExtra: me,
33
- watchAt: he = null,
34
- watchChapter: pe = null
33
+ watchAt: pe = null,
34
+ watchChapter: fe = null
35
35
  }) {
36
- var ee, te, re, ae, se, ie, oe;
37
- const D = Ve(), x = De(), { apiBase: fe } = Ie(), xe = fe.replace(/\/api$/, ""), v = ze(), z = Ye(he, pe), F = Re(), [T, ge] = d(""), [w, be] = d(""), [p, ye] = d(), [g, Ne] = d("published"), k = Fe(), _ = Ke({ onDone: (e) => h(e.id) }), [ve, B] = d(!1), [K, b] = d(null), [Q, j] = d(() => /* @__PURE__ */ new Set()), { isAdmin: we } = Le(), [P, A] = d(null), [G, M] = d(() => /* @__PURE__ */ new Set()), C = y(null), f = y(null), Y = y(null), J = y(null), m = y(null);
38
- V(() => {
39
- const e = window.setTimeout(() => be(T.trim()), 300);
36
+ var te, ae, re, se, ie, le, oe;
37
+ const N = Oe(), b = _e(), { apiBase: be } = Ue(), ge = be.replace(/\/api$/, ""), $ = Ke(), F = Ze(pe, fe), K = Le(), [A, xe] = c(""), [S, ye] = c(""), [g, Ne] = c(), [w, we] = c("published"), D = Qe(), R = Ge({ onDone: (e) => f(e.id) }), [ve, Q] = c(!1), [j, h] = c(null), [v, _] = c(() => /* @__PURE__ */ new Set()), { isAdmin: ke } = He(), [V, I] = c(null), [G, M] = c(() => /* @__PURE__ */ new Set()), P = k(null), x = k(null), Y = k(null), J = k(null), m = k(null);
38
+ U(() => {
39
+ const e = window.setTimeout(() => ye(A.trim()), 300);
40
40
  return () => window.clearTimeout(e);
41
- }, [T]);
42
- const $ = g === "paths", E = $ ? "published" : g, a = Ue({ search: w || void 0, category: p, status: E }), c = !!((ee = a.data) != null && ee.can_author), X = ((te = a.data) == null ? void 0 : te.data.length) ?? 0, Z = ((re = a.data) == null ? void 0 : re.total) ?? 0, ke = (((ae = a.data) == null ? void 0 : ae.data) ?? []).map((e) => e.id).join(",");
43
- if (V(() => {
41
+ }, [A]);
42
+ const T = w === "paths", L = T ? "published" : w, i = Be({ search: S || void 0, category: g, status: L }), u = !!((te = i.data) != null && te.can_author), X = ((ae = i.data) == null ? void 0 : ae.data.length) ?? 0, Z = ((re = i.data) == null ? void 0 : re.total) ?? 0, Ce = (((se = i.data) == null ? void 0 : se.data) ?? []).map((e) => e.id).join(",");
43
+ if (U(() => {
44
44
  W();
45
- }, [ke]), V(() => {
46
- b(null);
47
- }, [w, p, g]), U)
48
- return /* @__PURE__ */ t("div", { className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ t(qe, { videoId: U, onClose: () => h(null) }) });
45
+ }, [Ce]), U(() => {
46
+ h(null);
47
+ }, [S, g, w]), z)
48
+ return /* @__PURE__ */ t("div", { className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ t(Fe, { videoId: z, onClose: () => f(null) }) });
49
49
  function W() {
50
- var s;
51
- const e = f.current;
50
+ var r;
51
+ const e = x.current;
52
52
  if (!e || !m.current || m.current.querySelector(`[data-hv-card="${e.gone}"]`)) return;
53
- f.current = null, (s = (e.next ? m.current.querySelector(`[data-hv-purge="${e.next}"]`) : null) ?? Y.current) == null || s.focus();
53
+ x.current = null, (r = (e.next ? m.current.querySelector(`[data-hv-purge="${e.next}"]`) : null) ?? Y.current) == null || r.focus();
54
54
  }
55
- const Ce = async (e) => {
56
- var S;
57
- const i = ((S = a.data) == null ? void 0 : S.data) ?? [], s = i.findIndex((n) => n.id === e.id), l = i[s + 1] ?? i[s - 1];
55
+ const $e = async (e) => {
56
+ var p;
57
+ const s = ((p = i.data) == null ? void 0 : p.data) ?? [], r = s.findIndex((d) => d.id === e.id), l = s[r + 1] ?? s[r - 1];
58
58
  try {
59
- await L(D).purge(e.id), I.success(`"${e.title}" deleted`);
60
- } catch (n) {
61
- const o = de(n);
59
+ await C(N).purge(e.id), E.success(`"${e.title}" deleted`);
60
+ } catch (d) {
61
+ const o = ce(d);
62
62
  if (!((o == null ? void 0 : o.status) === 404 && o.code === "HELP_VIDEO_NOT_FOUND"))
63
- return (o == null ? void 0 : o.code) === "HELP_VIDEO_NOT_ARCHIVED" && x.invalidateQueries({ queryKey: N.all }), { ok: !1, message: `It could not be deleted. ${n.message}` };
63
+ return (o == null ? void 0 : o.code) === "HELP_VIDEO_NOT_ARCHIVED" && b.invalidateQueries({ queryKey: y.all }), { ok: !1, message: `It could not be deleted. ${d.message}` };
64
64
  }
65
- return f.current = { gone: e.id, next: (l == null ? void 0 : l.id) ?? null }, A(null), x.invalidateQueries({ queryKey: N.all }).then(
65
+ return x.current = { gone: e.id, next: (l == null ? void 0 : l.id) ?? null }, I(null), b.invalidateQueries({ queryKey: y.all }).then(
66
66
  () => window.setTimeout(() => {
67
- var n;
68
- f.current && (f.current = null, (n = C.current) != null && n.isConnected && C.current.focus());
67
+ var d;
68
+ x.current && (x.current = null, (d = P.current) != null && d.isConnected && P.current.focus());
69
69
  }, 0)
70
70
  ), { ok: !0 };
71
- }, $e = async (e) => {
72
- var i;
71
+ }, Se = async (e) => {
72
+ var s;
73
73
  if (!G.has(e.id)) {
74
- b(null), M((s) => new Set(s).add(e.id));
74
+ h(null), M((r) => new Set(r).add(e.id));
75
75
  try {
76
- await L(D).dismissStale(e.id), I.success(`The note on "${e.title}" was dismissed`), x.invalidateQueries({ queryKey: N.all });
77
- } catch (s) {
78
- ((i = de(s)) == null ? void 0 : i.code) === "HELP_VIDEO_NOT_STALE" ? x.invalidateQueries({ queryKey: N.all }) : b(`The note on "${e.title}" could not be dismissed. ${s.message}`);
76
+ await C(N).dismissStale(e.id), E.success(`The note on "${e.title}" was dismissed`), b.invalidateQueries({ queryKey: y.all });
77
+ } catch (r) {
78
+ ((s = ce(r)) == null ? void 0 : s.code) === "HELP_VIDEO_NOT_STALE" ? b.invalidateQueries({ queryKey: y.all }) : h(`The note on "${e.title}" could not be dismissed. ${r.message}`);
79
79
  } finally {
80
- M((s) => {
81
- const l = new Set(s);
80
+ M((r) => {
81
+ const l = new Set(r);
82
82
  return l.delete(e.id), l;
83
83
  });
84
84
  }
85
85
  }
86
- }, Se = async (e) => {
87
- if (!Q.has(e.id)) {
88
- b(null), j((i) => new Set(i).add(e.id));
86
+ }, ee = async (e, s) => {
87
+ if (v.has(e.id)) return;
88
+ h(null), _((l) => new Set(l).add(e.id));
89
+ const r = e.title || "Untitled video";
90
+ try {
91
+ s === "draft" ? await C(N).unpublish(e.id) : await C(N).publish(e.id, !1), E.success(
92
+ s === "draft" ? `"${r}" is back in Drafts — viewers no longer see it` : `"${r}" is published again`
93
+ ), b.invalidateQueries({ queryKey: y.all });
94
+ } catch (l) {
95
+ h(
96
+ `"${r}" could not be ${s === "draft" ? "unpublished" : "published again"}. ${l.message}`
97
+ );
98
+ } finally {
99
+ _((l) => {
100
+ const p = new Set(l);
101
+ return p.delete(e.id), p;
102
+ });
103
+ }
104
+ }, De = async (e) => {
105
+ if (!v.has(e.id)) {
106
+ h(null), _((s) => new Set(s).add(e.id));
89
107
  try {
90
- await L(D).archive(e.id), I.success(`"${e.title}" archived`), x.invalidateQueries({ queryKey: N.all });
91
- } catch (i) {
92
- b(`"${e.title}" could not be archived. ${i.message}`);
108
+ await C(N).archive(e.id), E.success(`"${e.title}" archived`), b.invalidateQueries({ queryKey: y.all });
109
+ } catch (s) {
110
+ h(`"${e.title}" could not be archived. ${s.message}`);
93
111
  } finally {
94
- j((i) => {
95
- const s = new Set(i);
96
- return s.delete(e.id), s;
112
+ _((s) => {
113
+ const r = new Set(s);
114
+ return r.delete(e.id), r;
97
115
  });
98
116
  }
99
117
  }
100
118
  };
101
- return /* @__PURE__ */ r("div", { ref: m, className: "flex min-h-0 flex-1 flex-col", "data-hv-library": !0, children: [
102
- /* @__PURE__ */ r("header", { className: "flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-5 py-3", children: [
119
+ return /* @__PURE__ */ a("div", { ref: m, className: "flex min-h-0 flex-1 flex-col", "data-hv-library": !0, children: [
120
+ /* @__PURE__ */ a("header", { className: "flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-5 py-3", children: [
103
121
  /* @__PURE__ */ t("h1", { className: "text-[16px] font-semibold", children: "Videos" }),
104
- /* @__PURE__ */ r("div", { className: "relative min-w-[180px] flex-1 basis-full sm:basis-auto sm:max-w-[320px]", children: [
122
+ /* @__PURE__ */ a("div", { className: "relative min-w-[180px] flex-1 basis-full sm:basis-auto sm:max-w-[320px]", children: [
105
123
  /* @__PURE__ */ t(
106
- Te,
124
+ Pe,
107
125
  {
108
126
  "aria-hidden": "true",
109
127
  className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"
110
128
  }
111
129
  ),
112
130
  /* @__PURE__ */ t(
113
- Oe,
131
+ qe,
114
132
  {
115
133
  type: "search",
116
- value: T,
117
- onChange: (e) => ge(e.target.value),
134
+ value: A,
135
+ onChange: (e) => xe(e.target.value),
118
136
  placeholder: "Search videos",
119
137
  "aria-label": "Search videos",
120
138
  className: "h-8 pl-8 text-[13px]",
@@ -122,51 +140,51 @@ function Nt({
122
140
  }
123
141
  )
124
142
  ] }),
125
- c && /* @__PURE__ */ r("fieldset", { className: "m-0 flex min-w-0 gap-1 border-0 p-0", children: [
143
+ u && /* @__PURE__ */ a("fieldset", { className: "m-0 flex min-w-0 gap-1 border-0 p-0", children: [
126
144
  /* @__PURE__ */ t("legend", { className: "sr-only", children: "Show" }),
127
145
  ["published", "draft", "archived", "paths"].map((e) => /* @__PURE__ */ t(
128
146
  "button",
129
147
  {
130
148
  type: "button",
131
- "aria-pressed": g === e,
132
- onClick: () => Ne(e),
133
- className: `rounded-md px-2.5 py-1 text-[12.5px] transition-colors ${O} ${g === e ? "bg-nvr-cyan/10 font-medium" : "hover:bg-muted"}`,
149
+ "aria-pressed": w === e,
150
+ onClick: () => we(e),
151
+ className: `rounded-md px-2.5 py-1 text-[12.5px] transition-colors ${H} ${w === e ? "bg-nvr-cyan/10 font-medium" : "hover:bg-muted"}`,
134
152
  "data-hv-status-tab": e,
135
- children: We[e]
153
+ children: at[e]
136
154
  },
137
155
  e
138
156
  ))
139
157
  ] }),
140
- /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-2", children: [
158
+ /* @__PURE__ */ a("div", { className: "ml-auto flex items-center gap-2", children: [
141
159
  me,
142
- c && /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
143
- !v && /* @__PURE__ */ t("p", { id: F, className: "max-w-[260px] text-[12px] text-muted-foreground", children: Ze }),
144
- /* @__PURE__ */ r(
145
- u,
160
+ u && /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
161
+ !$ && /* @__PURE__ */ t("p", { id: K, className: "max-w-[260px] text-[12px] text-muted-foreground", children: tt }),
162
+ /* @__PURE__ */ a(
163
+ n,
146
164
  {
147
165
  size: "sm",
148
166
  variant: "outline",
149
- onClick: _.pick,
150
- disabled: _.busy,
167
+ onClick: R.pick,
168
+ disabled: R.busy,
151
169
  "data-hv-upload": !0,
152
170
  children: [
153
- /* @__PURE__ */ t(_e, { className: "h-4 w-4" }),
171
+ /* @__PURE__ */ t(Te, { className: "h-4 w-4" }),
154
172
  " Upload a video"
155
173
  ]
156
174
  }
157
175
  ),
158
- /* @__PURE__ */ r(
159
- u,
176
+ /* @__PURE__ */ a(
177
+ n,
160
178
  {
161
179
  size: "sm",
162
- onClick: () => B(
163
- !k.start({ onDone: (e) => h(e.id), from: m.current })
180
+ onClick: () => Q(
181
+ !D.start({ onDone: (e) => f(e.id), from: m.current })
164
182
  ),
165
- disabled: !v,
166
- "aria-describedby": v ? void 0 : F,
183
+ disabled: !$,
184
+ "aria-describedby": $ ? void 0 : K,
167
185
  "data-hv-record": !0,
168
186
  children: [
169
- /* @__PURE__ */ t(le, { className: "h-4 w-4" }),
187
+ /* @__PURE__ */ t(ne, { className: "h-4 w-4" }),
170
188
  " Record a video"
171
189
  ]
172
190
  }
@@ -174,90 +192,90 @@ function Nt({
174
192
  ] })
175
193
  ] })
176
194
  ] }),
177
- !$ && !!((se = a.data) != null && se.categories.length) && /* @__PURE__ */ t("div", { className: "flex shrink-0 flex-wrap gap-1 px-5 pt-3", children: [void 0, ...a.data.categories].map((e) => /* @__PURE__ */ t(
195
+ !T && !!((ie = i.data) != null && ie.categories.length) && /* @__PURE__ */ t("div", { className: "flex shrink-0 flex-wrap gap-1 px-5 pt-3", children: [void 0, ...i.data.categories].map((e) => /* @__PURE__ */ t(
178
196
  "button",
179
197
  {
180
198
  type: "button",
181
- "aria-pressed": p === e,
182
- onClick: () => ye(e),
183
- className: `rounded-full border px-2.5 py-0.5 text-[12px] transition-colors ${O} ${p === e ? "border-nvr-cyan bg-nvr-cyan/10" : "border-border hover:bg-muted"}`,
199
+ "aria-pressed": g === e,
200
+ onClick: () => Ne(e),
201
+ className: `rounded-full border px-2.5 py-0.5 text-[12px] transition-colors ${H} ${g === e ? "border-nvr-cyan bg-nvr-cyan/10" : "border-border hover:bg-muted"}`,
184
202
  children: e ?? "All"
185
203
  },
186
204
  e ?? "all"
187
205
  )) }),
188
- ve && k.active && /* @__PURE__ */ t("p", { role: "status", className: "mx-5 mt-3 text-[13px] text-rose-700 dark:text-rose-300", children: Be }),
189
- K && /* @__PURE__ */ t(
206
+ ve && D.active && /* @__PURE__ */ t("p", { role: "status", className: "mx-5 mt-3 text-[13px] text-rose-700 dark:text-rose-300", children: je }),
207
+ j && /* @__PURE__ */ t(
190
208
  "p",
191
209
  {
192
210
  role: "alert",
193
211
  className: "mx-5 mt-3 rounded-md border border-rose-200 bg-rose-50 px-3 py-2 text-[13px] text-rose-800 dark:border-rose-500/30 dark:bg-rose-500/10 dark:text-rose-200",
194
212
  "data-hv-archive-error": !0,
195
- children: K
213
+ children: j
196
214
  }
197
215
  ),
198
- $ && c && /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-y-auto p-5", children: /* @__PURE__ */ t(Je, {}) }),
199
- /* @__PURE__ */ r(
216
+ T && u && /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-y-auto p-5", children: /* @__PURE__ */ t(We, {}) }),
217
+ /* @__PURE__ */ a(
200
218
  "div",
201
219
  {
202
220
  ref: Y,
203
221
  tabIndex: -1,
204
222
  className: "min-h-0 flex-1 overflow-y-auto p-5 focus:outline-none",
205
223
  "data-hv-list": !0,
206
- hidden: $ && c,
224
+ hidden: T && u,
207
225
  children: [
208
- a.isLoading && /* @__PURE__ */ t("p", { className: "text-[13px] text-muted-foreground", children: "Loading…" }),
209
- a.isError && /* @__PURE__ */ t("p", { role: "alert", className: "mb-3 text-[13px] text-rose-700 dark:text-rose-300", children: "Videos could not be loaded. Try again in a moment." }),
210
- a.data && !a.data.data.length && !a.isError && /* @__PURE__ */ r("div", { className: "space-y-2", "data-hv-empty": !0, children: [
211
- /* @__PURE__ */ t("p", { className: "text-[13px] text-muted-foreground", children: ce({ search: w, category: p, status: E, canAuthor: c }).text }),
212
- ce({ search: w, category: p, status: E, canAuthor: c }).offerRecord && v && /* @__PURE__ */ r(
213
- u,
226
+ i.isLoading && /* @__PURE__ */ t("p", { className: "text-[13px] text-muted-foreground", children: "Loading…" }),
227
+ i.isError && /* @__PURE__ */ t("p", { role: "alert", className: "mb-3 text-[13px] text-rose-700 dark:text-rose-300", children: "Videos could not be loaded. Try again in a moment." }),
228
+ i.data && !i.data.data.length && !i.isError && /* @__PURE__ */ a("div", { className: "space-y-2", "data-hv-empty": !0, children: [
229
+ /* @__PURE__ */ t("p", { className: "text-[13px] text-muted-foreground", children: ue({ search: S, category: g, status: L, canAuthor: u }).text }),
230
+ ue({ search: S, category: g, status: L, canAuthor: u }).offerRecord && $ && /* @__PURE__ */ a(
231
+ n,
214
232
  {
215
233
  size: "sm",
216
234
  variant: "outline",
217
- onClick: () => B(
218
- !k.start({ onDone: (e) => h(e.id), from: m.current })
235
+ onClick: () => Q(
236
+ !D.start({ onDone: (e) => f(e.id), from: m.current })
219
237
  ),
220
238
  children: [
221
- /* @__PURE__ */ t(le, { className: "h-4 w-4" }),
239
+ /* @__PURE__ */ t(ne, { className: "h-4 w-4" }),
222
240
  " Record one"
223
241
  ]
224
242
  }
225
243
  )
226
244
  ] }),
227
- /* @__PURE__ */ t("ul", { className: "grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(240px,1fr))]", children: (((ie = a.data) == null ? void 0 : ie.data) ?? []).map((e) => {
245
+ /* @__PURE__ */ t("ul", { className: "grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(240px,1fr))]", children: (((le = i.data) == null ? void 0 : le.data) ?? []).map((e) => {
228
246
  var o;
229
- const i = Qe(e), s = je(e), l = ((o = e.published) == null ? void 0 : o.edits.chapters.length) ?? 0, S = !!e.published && e.required && !i.done && !s, n = [
247
+ const s = Me(e), r = Ye(e), l = ((o = e.published) == null ? void 0 : o.edits.chapters.length) ?? 0, p = !!e.published && e.required && !s.done && !r, d = [
230
248
  e.category,
231
249
  l > 1 ? `${l} chapters` : null,
232
- e.published ? s ? "Getting ready" : i.text : "Draft"
250
+ e.published ? e.status === "draft" ? "Unpublished" : r ? "Getting ready" : s.text : "Draft"
233
251
  ].filter(Boolean).join(" · ");
234
- return /* @__PURE__ */ r(
252
+ return /* @__PURE__ */ a(
235
253
  "li",
236
254
  {
237
255
  className: "group overflow-hidden rounded-lg border border-border bg-card",
238
256
  "data-hv-card": e.id,
239
257
  children: [
240
- /* @__PURE__ */ r(
258
+ /* @__PURE__ */ a(
241
259
  "button",
242
260
  {
243
261
  type: "button",
244
- className: `block w-full text-left ${O}`,
245
- onClick: (R) => {
246
- J.current = R.currentTarget, e.published ? q(e.id) : h(e.id);
262
+ className: `block w-full text-left ${H}`,
263
+ onClick: (O) => {
264
+ J.current = O.currentTarget, e.published ? B(e.id) : f(e.id);
247
265
  },
248
266
  children: [
249
- /* @__PURE__ */ r("div", { className: "relative aspect-video bg-slate-100 dark:bg-slate-800", children: [
267
+ /* @__PURE__ */ a("div", { className: "relative aspect-video bg-slate-100 dark:bg-slate-800", children: [
250
268
  e.poster_url && /* @__PURE__ */ t(
251
269
  "img",
252
270
  {
253
- src: `${xe}${e.poster_url}`,
271
+ src: `${ge}${e.poster_url}`,
254
272
  alt: "",
255
273
  className: "h-full w-full object-cover",
256
274
  loading: "lazy"
257
275
  }
258
276
  ),
259
- !s && e.published && /* @__PURE__ */ t("span", { className: "absolute bottom-1.5 right-1.5 rounded bg-[#0f172a]/80 px-1.5 py-0.5 text-[11px] tabular-nums text-white", children: Ge(e.duration_ms) }),
260
- e.my_progress && !i.done && e.my_progress.percent > 0 && /* @__PURE__ */ t("span", { className: "absolute inset-x-0 bottom-0 h-1 bg-black/20", children: /* @__PURE__ */ t(
277
+ !r && e.published && /* @__PURE__ */ t("span", { className: "absolute bottom-1.5 right-1.5 rounded bg-[#0f172a]/80 px-1.5 py-0.5 text-[11px] tabular-nums text-white", children: Je(e.duration_ms) }),
278
+ e.my_progress && !s.done && e.my_progress.percent > 0 && /* @__PURE__ */ t("span", { className: "absolute inset-x-0 bottom-0 h-1 bg-black/20", children: /* @__PURE__ */ t(
261
279
  "span",
262
280
  {
263
281
  className: "block h-full bg-[#2563eb]",
@@ -265,26 +283,26 @@ function Nt({
265
283
  }
266
284
  ) })
267
285
  ] }),
268
- /* @__PURE__ */ r("div", { className: "space-y-0.5 p-2.5", children: [
286
+ /* @__PURE__ */ a("div", { className: "space-y-0.5 p-2.5", children: [
269
287
  /* @__PURE__ */ t("p", { className: "line-clamp-2 text-[13px] font-medium", children: e.title || "Untitled video" }),
270
288
  /* @__PURE__ */ t(
271
289
  "p",
272
290
  {
273
- className: `text-[12px] ${S ? "text-rose-700 dark:text-rose-300" : "text-muted-foreground"}`,
274
- children: n
291
+ className: `text-[12px] ${p ? "text-rose-700 dark:text-rose-300" : "text-muted-foreground"}`,
292
+ children: d
275
293
  }
276
294
  ),
277
- e.stale && /* @__PURE__ */ r(
295
+ e.stale && /* @__PURE__ */ a(
278
296
  "p",
279
297
  {
280
298
  className: "flex items-start gap-1 text-[12px] text-amber-800 dark:text-amber-200",
281
299
  title: e.stale.detail,
282
300
  "data-hv-stale": e.stale.kind,
283
301
  children: [
284
- /* @__PURE__ */ t(ne, { className: "mt-px h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
285
- /* @__PURE__ */ r("span", { className: "line-clamp-2", children: [
302
+ /* @__PURE__ */ t(de, { className: "mt-px h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
303
+ /* @__PURE__ */ a("span", { className: "line-clamp-2", children: [
286
304
  "May be out of date",
287
- c ? `: ${e.stale.detail}` : ""
305
+ u ? `: ${e.stale.detail}` : ""
288
306
  ] })
289
307
  ]
290
308
  }
@@ -293,62 +311,92 @@ function Nt({
293
311
  ]
294
312
  }
295
313
  ),
296
- c && /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1 border-t border-border px-1.5 py-1", children: [
297
- e.stale && /* @__PURE__ */ r(
298
- u,
314
+ u && /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-1 border-t border-border px-1.5 py-1", children: [
315
+ e.stale && /* @__PURE__ */ a(
316
+ n,
299
317
  {
300
318
  size: "sm",
301
319
  variant: "ghost",
302
- onClick: () => void $e(e),
320
+ onClick: () => void Se(e),
303
321
  disabled: G.has(e.id),
304
322
  "aria-label": `Dismiss the out-of-date note on ${e.title || "Untitled video"}`,
305
323
  "data-hv-stale-dismiss": e.id,
306
324
  children: [
307
- /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5" }),
325
+ /* @__PURE__ */ t(de, { className: "h-3.5 w-3.5" }),
308
326
  " Dismiss"
309
327
  ]
310
328
  }
311
329
  ),
312
- /* @__PURE__ */ r(
313
- u,
330
+ /* @__PURE__ */ a(
331
+ n,
314
332
  {
315
333
  size: "sm",
316
334
  variant: "ghost",
317
- onClick: () => h(e.id),
335
+ onClick: () => f(e.id),
318
336
  "data-hv-edit": e.id,
319
337
  children: [
320
- /* @__PURE__ */ t(Pe, { className: "h-3.5 w-3.5" }),
338
+ /* @__PURE__ */ t(Ee, { className: "h-3.5 w-3.5" }),
321
339
  " Edit"
322
340
  ]
323
341
  }
324
342
  ),
325
- e.status !== "archived" && /* @__PURE__ */ r(
326
- u,
343
+ e.status === "published" && /* @__PURE__ */ a(
344
+ n,
327
345
  {
328
346
  size: "sm",
329
347
  variant: "ghost",
330
- onClick: () => void Se(e),
331
- disabled: Q.has(e.id),
332
- "data-hv-archive": e.id,
348
+ onClick: () => void ee(e, "draft"),
349
+ disabled: v.has(e.id),
350
+ "data-tip": "Back to Drafts: viewers stop seeing it until you publish it again",
351
+ "data-hv-unpublish": e.id,
333
352
  children: [
334
353
  /* @__PURE__ */ t(Ae, { className: "h-3.5 w-3.5" }),
354
+ " Unpublish"
355
+ ]
356
+ }
357
+ ),
358
+ e.status === "draft" && !!e.published && (!e.draft || e.draft_matches_published) && /* @__PURE__ */ a(
359
+ n,
360
+ {
361
+ size: "sm",
362
+ variant: "ghost",
363
+ onClick: () => void ee(e, "published"),
364
+ disabled: v.has(e.id),
365
+ "data-tip": "Put the last published version back for viewers",
366
+ "data-hv-republish": e.id,
367
+ children: [
368
+ /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }),
369
+ " Publish again"
370
+ ]
371
+ }
372
+ ),
373
+ e.status !== "archived" && /* @__PURE__ */ a(
374
+ n,
375
+ {
376
+ size: "sm",
377
+ variant: "ghost",
378
+ onClick: () => void De(e),
379
+ disabled: v.has(e.id),
380
+ "data-hv-archive": e.id,
381
+ children: [
382
+ /* @__PURE__ */ t(Ve, { className: "h-3.5 w-3.5" }),
335
383
  " Archive"
336
384
  ]
337
385
  }
338
386
  ),
339
- we && e.status === "archived" && /* @__PURE__ */ r(
340
- u,
387
+ ke && e.status === "archived" && /* @__PURE__ */ a(
388
+ n,
341
389
  {
342
390
  size: "sm",
343
391
  variant: "ghost",
344
392
  className: "text-rose-700 hover:text-rose-800 dark:text-rose-300 dark:hover:text-rose-200",
345
- onClick: (R) => {
346
- C.current = R.currentTarget, A(e);
393
+ onClick: (O) => {
394
+ P.current = O.currentTarget, I(e);
347
395
  },
348
396
  "aria-label": `Delete permanently: ${e.title || "Untitled video"}`,
349
397
  "data-hv-purge": e.id,
350
398
  children: [
351
- /* @__PURE__ */ t(Ee, { className: "h-3.5 w-3.5" }),
399
+ /* @__PURE__ */ t(Ie, { className: "h-3.5 w-3.5" }),
352
400
  " Delete permanently"
353
401
  ]
354
402
  }
@@ -359,51 +407,51 @@ function Nt({
359
407
  e.id
360
408
  );
361
409
  }) }),
362
- a.data && a.data.data.length > 0 && /* @__PURE__ */ r("div", { className: "mt-5 flex items-center gap-3", "data-hv-more": !0, children: [
363
- a.hasNextPage && /* @__PURE__ */ t(
364
- u,
410
+ i.data && i.data.data.length > 0 && /* @__PURE__ */ a("div", { className: "mt-5 flex items-center gap-3", "data-hv-more": !0, children: [
411
+ i.hasNextPage && /* @__PURE__ */ t(
412
+ n,
365
413
  {
366
414
  size: "sm",
367
415
  variant: "outline",
368
- onClick: () => void a.fetchNextPage(),
369
- disabled: a.isFetchingNextPage,
416
+ onClick: () => void i.fetchNextPage(),
417
+ disabled: i.isFetchingNextPage,
370
418
  "data-hv-show-more": !0,
371
- children: a.isFetchingNextPage ? "Loading…" : "Show more"
419
+ children: i.isFetchingNextPage ? "Loading…" : "Show more"
372
420
  }
373
421
  ),
374
- ue(X, Z) && /* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", "aria-live": "polite", children: ue(X, Z) })
422
+ he(X, Z) && /* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", "aria-live": "polite", children: he(X, Z) })
375
423
  ] })
376
424
  ]
377
425
  }
378
426
  ),
379
- P && /* @__PURE__ */ t(
380
- Xe,
427
+ V && /* @__PURE__ */ t(
428
+ et,
381
429
  {
382
- title: P.title || "Untitled video",
383
- container: He((oe = m.current) == null ? void 0 : oe.firstElementChild),
384
- onConfirm: () => Ce(P),
385
- onClose: () => A(null),
430
+ title: V.title || "Untitled video",
431
+ container: ze((oe = m.current) == null ? void 0 : oe.firstElementChild),
432
+ onConfirm: () => $e(V),
433
+ onClose: () => I(null),
386
434
  restoreFocus: () => {
387
435
  var e;
388
- f.current ? W() : (e = C.current) == null || e.focus();
436
+ x.current ? W() : (e = P.current) == null || e.focus();
389
437
  }
390
438
  }
391
439
  ),
392
440
  /* @__PURE__ */ t(
393
- Me,
441
+ Xe,
394
442
  {
395
- videoId: H,
396
- open: !!H,
397
- onOpenChange: (e) => !e && q(null),
443
+ videoId: q,
444
+ open: !!q,
445
+ onOpenChange: (e) => !e && B(null),
398
446
  returnFocusRef: J,
399
- startAtMs: z.atMs,
400
- startChapterId: z.chapterId
447
+ startAtMs: F.atMs,
448
+ startChapterId: F.chapterId
401
449
  }
402
450
  ),
403
- k.fallback,
404
- _.ui
451
+ D.fallback,
452
+ R.ui
405
453
  ] });
406
454
  }
407
455
  export {
408
- Nt as HelpVideoLibrary
456
+ kt as HelpVideoLibrary
409
457
  };