@anantagnanam/lms 0.0.0-stage → 0.1.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -2
  3. package/astro/client.ts +433 -0
  4. package/astro/components/CertificateCard.astro +83 -0
  5. package/astro/components/CourseCard.astro +61 -0
  6. package/astro/components/CourseCatalog.astro +96 -0
  7. package/astro/components/CourseOverview.astro +286 -0
  8. package/astro/components/LearnerDashboard.astro +121 -0
  9. package/astro/components/LearningShell.astro +28 -0
  10. package/astro/components/LessonPlayer.astro +323 -0
  11. package/astro/components/MediaPlayer.astro +60 -0
  12. package/astro/components/index.ts +7 -0
  13. package/astro/layouts/AcademyLayout.astro +84 -0
  14. package/astro/pages/certificate.astro +57 -0
  15. package/astro/pages/cohort.astro +102 -0
  16. package/astro/pages/course.astro +80 -0
  17. package/astro/pages/dashboard.astro +34 -0
  18. package/astro/pages/index.astro +40 -0
  19. package/astro/pages/lesson.astro +100 -0
  20. package/astro/pages/teach.astro +15 -0
  21. package/astro/styles.css +1288 -0
  22. package/dist/admin.d.ts +32 -0
  23. package/dist/admin.js +2762 -0
  24. package/dist/admin.js.map +1 -0
  25. package/dist/astro.d.ts +11 -0
  26. package/dist/astro.js +49 -0
  27. package/dist/astro.js.map +1 -0
  28. package/dist/commerce.d.ts +72 -0
  29. package/dist/commerce.js +0 -0
  30. package/dist/config-BX3beTpM.js +15 -0
  31. package/dist/config-BX3beTpM.js.map +1 -0
  32. package/dist/constants-C0kT94tc.js +139 -0
  33. package/dist/constants-C0kT94tc.js.map +1 -0
  34. package/dist/csv-DKq_4OWU.js +55 -0
  35. package/dist/csv-DKq_4OWU.js.map +1 -0
  36. package/dist/errors-ChzJS9al.js +16 -0
  37. package/dist/errors-ChzJS9al.js.map +1 -0
  38. package/dist/index.d.ts +13 -0
  39. package/dist/index.js +19 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/runtime.d.ts +681 -0
  42. package/dist/runtime.js +2060 -0
  43. package/dist/runtime.js.map +1 -0
  44. package/dist/schemas.d.ts +584 -0
  45. package/dist/schemas.js +315 -0
  46. package/dist/schemas.js.map +1 -0
  47. package/dist/server.d.ts +30 -0
  48. package/dist/server.js +54 -0
  49. package/dist/server.js.map +1 -0
  50. package/dist/types.d.ts +284 -0
  51. package/dist/types.js +0 -0
  52. package/package.json +83 -4
package/dist/admin.js ADDED
@@ -0,0 +1,2762 @@
1
+ import { r as PLUGIN_ID, t as API_BASE } from "./constants-C0kT94tc.js";
2
+ import { assignmentSchema, courseDataSchema, lessonSchema, moduleSchema, questionSchema, quizSchema, settingsSchema } from "./schemas.js";
3
+ import { n as enrollmentCsvLines, t as enrollmentCsvHeader } from "./csv-DKq_4OWU.js";
4
+ import { useEffect, useState } from "react";
5
+ import { apiFetch } from "emdash/plugin-utils";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+
8
+ //#region src/admin.tsx
9
+ const ADMIN_BASE = `/_emdash/admin/plugins/${PLUGIN_ID}`;
10
+ async function api(route, input = {}, method = "GET", signal) {
11
+ let url = `${API_BASE}/${route}`;
12
+ if (method === "GET") {
13
+ const params = new URLSearchParams();
14
+ for (const [key, value] of Object.entries(input)) if (value !== void 0 && value !== "" && value !== null) params.set(key, String(value));
15
+ url += `?${params}`;
16
+ }
17
+ const response = await apiFetch(url, {
18
+ method,
19
+ signal,
20
+ credentials: "same-origin",
21
+ ...method !== "GET" ? {
22
+ headers: { "Content-Type": "application/json" },
23
+ body: JSON.stringify(input)
24
+ } : {}
25
+ });
26
+ const result = await response.json();
27
+ if (!response.ok || !result.success) throw new Error(result.error?.message ?? "The request could not be completed.");
28
+ return result.data;
29
+ }
30
+ function useLoad(route, input = {}, enabled = true) {
31
+ const key = JSON.stringify(input);
32
+ const [generation, setGeneration] = useState(0);
33
+ const [state, setState] = useState({ loading: enabled });
34
+ useEffect(() => {
35
+ if (!enabled) {
36
+ setState({ loading: false });
37
+ return;
38
+ }
39
+ const controller = new AbortController();
40
+ setState((old) => ({
41
+ ...old,
42
+ loading: true,
43
+ error: void 0
44
+ }));
45
+ api(route, JSON.parse(key), "GET", controller.signal).then((data) => {
46
+ if (!controller.signal.aborted) setState({
47
+ loading: false,
48
+ data
49
+ });
50
+ }).catch((error) => {
51
+ if (!controller.signal.aborted) setState({
52
+ loading: false,
53
+ error: error.message
54
+ });
55
+ });
56
+ return () => controller.abort();
57
+ }, [
58
+ route,
59
+ key,
60
+ enabled,
61
+ generation
62
+ ]);
63
+ return {
64
+ ...state,
65
+ reload: () => setGeneration((value) => value + 1)
66
+ };
67
+ }
68
+ function useAction() {
69
+ const [busy, setBusy] = useState(false);
70
+ const [error, setError] = useState("");
71
+ const [message, setMessage] = useState("");
72
+ const run = async (action, success = "Saved.") => {
73
+ if (busy) return;
74
+ setBusy(true);
75
+ setError("");
76
+ setMessage("");
77
+ try {
78
+ await action();
79
+ setMessage(success);
80
+ } catch (cause) {
81
+ setError(cause instanceof Error ? cause.message : "The request failed.");
82
+ } finally {
83
+ setBusy(false);
84
+ }
85
+ };
86
+ return {
87
+ busy,
88
+ error,
89
+ message,
90
+ run
91
+ };
92
+ }
93
+ function useChoices(route) {
94
+ const [cursor, setCursor] = useState();
95
+ const [items, setItems] = useState([]);
96
+ const list = useLoad(route, {
97
+ cursor,
98
+ limit: 100
99
+ });
100
+ useEffect(() => {
101
+ if (list.data) setItems((old) => [...new Map([...old, ...list.data.items].map((item) => [item.id, item])).values()]);
102
+ }, [list.data]);
103
+ return {
104
+ ...list,
105
+ items,
106
+ more: () => setCursor(list.data?.cursor)
107
+ };
108
+ }
109
+ function ChoicesField({ label, value, choices, onChange }) {
110
+ const all = [...choices, ...value.filter((id) => !choices.some((choice) => choice.id === id)).map((id) => ({
111
+ id,
112
+ label: `Saved selection · ${id.slice(0, 8)}`
113
+ }))];
114
+ return /* @__PURE__ */ jsxs("fieldset", {
115
+ className: "lms-choices",
116
+ children: [
117
+ /* @__PURE__ */ jsx("legend", { children: label }),
118
+ all.map((choice) => /* @__PURE__ */ jsxs("label", {
119
+ className: "lms-check",
120
+ children: [/* @__PURE__ */ jsx("input", {
121
+ type: "checkbox",
122
+ checked: value.includes(choice.id),
123
+ onChange: (event) => onChange(event.target.checked ? [...value, choice.id] : value.filter((id) => id !== choice.id))
124
+ }), choice.label]
125
+ }, choice.id)),
126
+ !all.length && /* @__PURE__ */ jsx("p", { children: "No choices loaded yet." })
127
+ ]
128
+ });
129
+ }
130
+ function Notice({ error, message }) {
131
+ return /* @__PURE__ */ jsxs(Fragment, { children: [error && /* @__PURE__ */ jsx("p", {
132
+ role: "alert",
133
+ className: "lms-notice lms-error",
134
+ children: error
135
+ }), message && /* @__PURE__ */ jsx("p", {
136
+ role: "status",
137
+ className: "lms-notice",
138
+ children: message
139
+ })] });
140
+ }
141
+ function Field({ label, children, help }) {
142
+ return /* @__PURE__ */ jsxs("label", {
143
+ className: "lms-field",
144
+ children: [
145
+ /* @__PURE__ */ jsx("span", { children: label }),
146
+ children,
147
+ help && /* @__PURE__ */ jsx("small", { children: help })
148
+ ]
149
+ });
150
+ }
151
+ function Button({ children, busy, danger, ...props }) {
152
+ return /* @__PURE__ */ jsx("button", {
153
+ type: "button",
154
+ ...props,
155
+ className: `lms-button${danger ? " lms-danger" : ""}`,
156
+ disabled: props.disabled || busy,
157
+ children: busy ? "Working…" : children
158
+ });
159
+ }
160
+ function Panel({ title, children }) {
161
+ return /* @__PURE__ */ jsxs("section", {
162
+ className: "lms-panel",
163
+ children: [title && /* @__PURE__ */ jsx("h2", { children: title }), children]
164
+ });
165
+ }
166
+ function Pager({ page, next, reset }) {
167
+ return /* @__PURE__ */ jsxs("div", {
168
+ className: "lms-actions",
169
+ children: [/* @__PURE__ */ jsx(Button, {
170
+ onClick: reset,
171
+ children: "First page"
172
+ }), page?.hasMore && page.cursor && /* @__PURE__ */ jsx(Button, {
173
+ onClick: () => next(page.cursor),
174
+ children: "Next page"
175
+ })]
176
+ });
177
+ }
178
+ function PageFrame({ title, description, children }) {
179
+ const academy = useLoad("academy");
180
+ return /* @__PURE__ */ jsxs("main", {
181
+ className: "ag-lms-admin",
182
+ children: [
183
+ /* @__PURE__ */ jsx("style", { children: css }),
184
+ /* @__PURE__ */ jsxs("header", {
185
+ className: "lms-page-header",
186
+ children: [/* @__PURE__ */ jsxs("div", { children: [
187
+ /* @__PURE__ */ jsx("p", {
188
+ className: "lms-eyebrow",
189
+ children: "ANANTA GNANAM · LEARNING"
190
+ }),
191
+ /* @__PURE__ */ jsx("h1", { children: title }),
192
+ description && /* @__PURE__ */ jsx("p", { children: description })
193
+ ] }), /* @__PURE__ */ jsx("a", {
194
+ href: academy.data?.basePath ?? "/academy",
195
+ className: "lms-button",
196
+ target: "_blank",
197
+ rel: "noopener noreferrer",
198
+ children: "Open academy ↗"
199
+ })]
200
+ }),
201
+ /* @__PURE__ */ jsx("nav", {
202
+ className: "lms-tabs",
203
+ "aria-label": "Learning administration",
204
+ children: [
205
+ ["/", "Overview"],
206
+ ["/courses", "Courses"],
207
+ ["/learners", "Enrollments"],
208
+ ["/assignments", "Assignments"],
209
+ ["/community", "Community"],
210
+ ["/cohorts", "Cohorts"],
211
+ ["/reports", "Reports"],
212
+ ["/notifications", "Notifications"],
213
+ ["/audit", "Audit history"],
214
+ ["/settings", "Settings"]
215
+ ].map(([path, label]) => /* @__PURE__ */ jsx("a", {
216
+ href: `${ADMIN_BASE}${path === "/" ? "" : path}`,
217
+ children: label
218
+ }, path))
219
+ }),
220
+ children
221
+ ]
222
+ });
223
+ }
224
+ function Metrics({ report }) {
225
+ return /* @__PURE__ */ jsx("div", {
226
+ className: "lms-metrics",
227
+ children: [
228
+ ["Courses", report?.courseCount],
229
+ ["Active enrollments", report?.active],
230
+ ["Course completions", report?.completedEver],
231
+ ["Awaiting approval", report?.pending],
232
+ ["Completion rate", report ? `${report.completionRate}%` : void 0]
233
+ ].map(([label, value]) => /* @__PURE__ */ jsxs("div", {
234
+ className: "lms-panel",
235
+ children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx("strong", { children: value ?? "—" })]
236
+ }, label))
237
+ });
238
+ }
239
+ function CoursePicker({ value, onChange, allowAll = false }) {
240
+ const [cursor, setCursor] = useState();
241
+ const [choices, setChoices] = useState([]);
242
+ const list = useLoad("admin/courses", {
243
+ limit: 100,
244
+ cursor
245
+ });
246
+ useEffect(() => {
247
+ if (list.data) setChoices((old) => [...new Map([...old, ...list.data.items].map((course) => [course.id, course])).values()]);
248
+ }, [list.data]);
249
+ return /* @__PURE__ */ jsxs("div", { children: [
250
+ /* @__PURE__ */ jsx(Field, {
251
+ label: "Course",
252
+ children: /* @__PURE__ */ jsxs("select", {
253
+ value,
254
+ onChange: (event) => onChange(event.target.value),
255
+ children: [/* @__PURE__ */ jsx("option", {
256
+ value: "",
257
+ children: allowAll ? "All courses" : "Choose a course"
258
+ }), choices.map((course) => /* @__PURE__ */ jsxs("option", {
259
+ value: course.id,
260
+ children: [
261
+ course.title,
262
+ " · ",
263
+ course.status
264
+ ]
265
+ }, course.id))]
266
+ })
267
+ }),
268
+ list.data?.hasMore && /* @__PURE__ */ jsx(Button, {
269
+ onClick: () => setCursor(list.data?.cursor),
270
+ children: "Load more courses"
271
+ }),
272
+ /* @__PURE__ */ jsx(Notice, { error: list.error })
273
+ ] });
274
+ }
275
+ function OverviewPage() {
276
+ const report = useLoad("admin/report");
277
+ return /* @__PURE__ */ jsxs(PageFrame, {
278
+ title: "Learning overview",
279
+ description: "Create learning paths, support your learners, and see their progress.",
280
+ children: [
281
+ /* @__PURE__ */ jsx(Notice, { error: report.error }),
282
+ /* @__PURE__ */ jsx(Metrics, { report: report.data }),
283
+ /* @__PURE__ */ jsxs("div", {
284
+ className: "lms-grid",
285
+ children: [/* @__PURE__ */ jsxs(Panel, {
286
+ title: "Course studio",
287
+ children: [/* @__PURE__ */ jsx("p", { children: "Build modules with reading, video, audio, quizzes, assignments, and live sessions." }), /* @__PURE__ */ jsx("a", {
288
+ className: "lms-button",
289
+ href: `${ADMIN_BASE}/courses`,
290
+ children: "Manage courses"
291
+ })]
292
+ }), /* @__PURE__ */ jsxs(Panel, {
293
+ title: "Support learners",
294
+ children: [/* @__PURE__ */ jsx("p", { children: "Review enrollment requests and give feedback on submitted work." }), /* @__PURE__ */ jsxs("div", {
295
+ className: "lms-actions",
296
+ children: [/* @__PURE__ */ jsx("a", {
297
+ className: "lms-button",
298
+ href: `${ADMIN_BASE}/learners`,
299
+ children: "Enrollments"
300
+ }), /* @__PURE__ */ jsx("a", {
301
+ className: "lms-button",
302
+ href: `${ADMIN_BASE}/assignments`,
303
+ children: "Grade assignments"
304
+ })]
305
+ })]
306
+ })]
307
+ })
308
+ ]
309
+ });
310
+ }
311
+ function CoursesPage() {
312
+ const [cursor, setCursor] = useState();
313
+ const [status, setStatus] = useState("");
314
+ const [edit, setEdit] = useState();
315
+ const list = useLoad("admin/courses", {
316
+ cursor,
317
+ status
318
+ });
319
+ const action = useAction();
320
+ const open = (id) => void action.run(async () => {
321
+ const result = await api("admin/course", { id });
322
+ setEdit({
323
+ course: result.course,
324
+ revision: result.revision
325
+ });
326
+ }, "");
327
+ const importFile = async (file) => {
328
+ if (file.size > 95e4) throw new Error("This course file is too large.");
329
+ const bundle = JSON.parse(await file.text());
330
+ if (bundle.format !== "anantagnanam-lms-course" || bundle.version !== 1 || !bundle.course) throw new Error("Choose an Ananta Gnanam course export.");
331
+ setEdit({
332
+ course: courseDataSchema.parse({
333
+ ...bundle.course,
334
+ status: "draft"
335
+ }),
336
+ revision: null
337
+ });
338
+ };
339
+ if (edit) return /* @__PURE__ */ jsx(CourseEditor, {
340
+ initial: edit.course,
341
+ initialRevision: edit.revision,
342
+ onClose: () => {
343
+ setEdit(void 0);
344
+ list.reload();
345
+ }
346
+ });
347
+ return /* @__PURE__ */ jsxs(PageFrame, {
348
+ title: "Courses",
349
+ description: "Author, publish, and update your courses.",
350
+ children: [
351
+ /* @__PURE__ */ jsx(Notice, {
352
+ error: list.error || action.error,
353
+ message: action.message
354
+ }),
355
+ /* @__PURE__ */ jsxs("div", {
356
+ className: "lms-toolbar",
357
+ children: [
358
+ /* @__PURE__ */ jsx(Button, {
359
+ onClick: () => setEdit({
360
+ course: courseDataSchema.parse({
361
+ title: "New course",
362
+ slug: "new-course"
363
+ }),
364
+ revision: null
365
+ }),
366
+ children: "Create course"
367
+ }),
368
+ /* @__PURE__ */ jsxs("label", {
369
+ className: "lms-button",
370
+ children: ["Import course", /* @__PURE__ */ jsx("input", {
371
+ className: "lms-file",
372
+ type: "file",
373
+ accept: "application/json,.json",
374
+ onChange: (event) => {
375
+ const file = event.target.files?.[0];
376
+ if (file) action.run(() => importFile(file), "");
377
+ event.target.value = "";
378
+ }
379
+ })]
380
+ }),
381
+ /* @__PURE__ */ jsx(Field, {
382
+ label: "Status",
383
+ children: /* @__PURE__ */ jsxs("select", {
384
+ value: status,
385
+ onChange: (event) => {
386
+ setStatus(event.target.value);
387
+ setCursor(void 0);
388
+ },
389
+ children: [/* @__PURE__ */ jsx("option", {
390
+ value: "",
391
+ children: "All statuses"
392
+ }), [
393
+ "draft",
394
+ "published",
395
+ "archived"
396
+ ].map((value) => /* @__PURE__ */ jsx("option", { children: value }, value))]
397
+ })
398
+ })
399
+ ]
400
+ }),
401
+ list.loading && /* @__PURE__ */ jsx("p", {
402
+ role: "status",
403
+ children: "Loading courses…"
404
+ }),
405
+ /* @__PURE__ */ jsx("div", {
406
+ className: "lms-course-grid",
407
+ children: list.data?.items.map((course) => /* @__PURE__ */ jsxs(Panel, { children: [
408
+ /* @__PURE__ */ jsx("span", {
409
+ className: "lms-badge",
410
+ children: course.status
411
+ }),
412
+ /* @__PURE__ */ jsx("h2", { children: course.title }),
413
+ /* @__PURE__ */ jsx("p", { children: course.summary || "Add a summary to introduce this course." }),
414
+ /* @__PURE__ */ jsxs("p", {
415
+ className: "lms-muted",
416
+ children: [
417
+ course.modules.length,
418
+ " modules ·",
419
+ " ",
420
+ course.modules.reduce((sum, module) => sum + module.lessons.length, 0),
421
+ " lessons"
422
+ ]
423
+ }),
424
+ /* @__PURE__ */ jsxs("div", {
425
+ className: "lms-actions",
426
+ children: [/* @__PURE__ */ jsx(Button, {
427
+ busy: action.busy,
428
+ onClick: () => open(course.id),
429
+ children: "Edit course"
430
+ }), /* @__PURE__ */ jsx(Button, {
431
+ onClick: () => void action.run(async () => download(`${course.slug}.json`, JSON.stringify(await api("admin/course/export", { id: course.id }), null, 2), "application/json"), "Course exported."),
432
+ children: "Export"
433
+ })]
434
+ })
435
+ ] }, course.id))
436
+ }),
437
+ list.data && !list.data.items.length && /* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsx("p", { children: "No courses yet. Create your first course above." }) }),
438
+ /* @__PURE__ */ jsx(Pager, {
439
+ page: list.data,
440
+ next: setCursor,
441
+ reset: () => setCursor(void 0)
442
+ })
443
+ ]
444
+ });
445
+ }
446
+ function CourseEditor({ initial, initialRevision, onClose }) {
447
+ const [course, setCourse] = useState(initial);
448
+ const [revision, setRevision] = useState(initialRevision);
449
+ const [saved, setSaved] = useState(JSON.stringify(initial));
450
+ const [selected, setSelected] = useState(initial.modules[0]?.lessons[0]?.id ?? null);
451
+ const [tab, setTab] = useState("details");
452
+ const action = useAction();
453
+ const dirty = !course.id || JSON.stringify(course) !== saved;
454
+ const prerequisiteChoices = useChoices("catalog");
455
+ const instructorChoices = useChoices("admin/instructors");
456
+ useEffect(() => {
457
+ if (!dirty) return;
458
+ const handler = (event) => {
459
+ event.preventDefault();
460
+ };
461
+ window.addEventListener("beforeunload", handler);
462
+ return () => window.removeEventListener("beforeunload", handler);
463
+ }, [dirty]);
464
+ const patch = (data) => setCourse((old) => ({
465
+ ...old,
466
+ ...data
467
+ }));
468
+ const updateModule = (index, data) => setCourse((old) => ({
469
+ ...old,
470
+ modules: old.modules.map((module, i) => i === index ? {
471
+ ...module,
472
+ ...data
473
+ } : module)
474
+ }));
475
+ const updateLesson = (id, data) => setCourse((old) => ({
476
+ ...old,
477
+ modules: old.modules.map((module) => ({
478
+ ...module,
479
+ lessons: module.lessons.map((lesson) => lesson.id === id ? {
480
+ ...lesson,
481
+ ...data
482
+ } : lesson)
483
+ }))
484
+ }));
485
+ const selectedLesson = course.modules.flatMap((module) => module.lessons).find((lesson) => lesson.id === selected);
486
+ const save = (status = course.status) => void action.run(async () => {
487
+ const parsed = courseDataSchema.safeParse({
488
+ ...course,
489
+ status
490
+ });
491
+ if (!parsed.success) throw new Error(parsed.error.issues.slice(0, 5).map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(" "));
492
+ const result = await api("admin/course/save", {
493
+ id: course.id,
494
+ expectedRevision: revision,
495
+ data: parsed.data
496
+ }, "POST");
497
+ setCourse(result.course);
498
+ setRevision(result.revision);
499
+ setSaved(JSON.stringify(result.course));
500
+ }, status === "published" ? "Course published." : "Course saved.");
501
+ const reorderLesson = (moduleIndex, index, delta) => {
502
+ const items = [...course.modules[moduleIndex].lessons];
503
+ const to = index + delta;
504
+ if (to < 0 || to >= items.length) return;
505
+ [items[index], items[to]] = [items[to], items[index]];
506
+ updateModule(moduleIndex, { lessons: items });
507
+ };
508
+ return /* @__PURE__ */ jsxs(PageFrame, {
509
+ title: course.title,
510
+ description: dirty ? "You have unsaved changes." : "All changes saved.",
511
+ children: [
512
+ /* @__PURE__ */ jsx(Notice, {
513
+ error: action.error,
514
+ message: action.message
515
+ }),
516
+ /* @__PURE__ */ jsxs("div", {
517
+ className: "lms-toolbar",
518
+ children: [
519
+ /* @__PURE__ */ jsx(Button, {
520
+ onClick: () => {
521
+ if (!dirty || window.confirm("Discard unsaved changes?")) onClose();
522
+ },
523
+ children: "Back to courses"
524
+ }),
525
+ /* @__PURE__ */ jsxs(Button, {
526
+ busy: action.busy,
527
+ onClick: () => save(),
528
+ children: ["Save ", course.status]
529
+ }),
530
+ course.status !== "published" && /* @__PURE__ */ jsx(Button, {
531
+ busy: action.busy,
532
+ onClick: () => save("published"),
533
+ children: "Publish"
534
+ }),
535
+ course.status === "published" && /* @__PURE__ */ jsx(Button, {
536
+ busy: action.busy,
537
+ onClick: () => save("archived"),
538
+ children: "Archive"
539
+ }),
540
+ course.id && course.status === "draft" && /* @__PURE__ */ jsx(Button, {
541
+ danger: true,
542
+ busy: action.busy,
543
+ onClick: () => {
544
+ if (window.confirm(`Delete the draft “${course.title}”?`)) action.run(async () => {
545
+ await api("admin/course/delete", {
546
+ id: course.id,
547
+ expectedRevision: revision
548
+ }, "POST");
549
+ onClose();
550
+ }, "");
551
+ },
552
+ children: "Delete draft"
553
+ })
554
+ ]
555
+ }),
556
+ /* @__PURE__ */ jsx("div", {
557
+ className: "lms-tabs",
558
+ role: "tablist",
559
+ "aria-label": "Course editor",
560
+ children: [
561
+ "details",
562
+ "curriculum",
563
+ "access"
564
+ ].map((value) => /* @__PURE__ */ jsx(Button, {
565
+ role: "tab",
566
+ "aria-selected": tab === value,
567
+ onClick: () => setTab(value),
568
+ children: value === "access" ? "Enrollment & completion" : value === "details" ? "Course details" : "Curriculum"
569
+ }, value))
570
+ }),
571
+ tab === "details" && /* @__PURE__ */ jsxs(Panel, { children: [
572
+ /* @__PURE__ */ jsxs("div", {
573
+ className: "lms-grid",
574
+ children: [
575
+ /* @__PURE__ */ jsx(Field, {
576
+ label: "Course title",
577
+ children: /* @__PURE__ */ jsx("input", {
578
+ value: course.title,
579
+ maxLength: 200,
580
+ onChange: (event) => patch({ title: event.target.value })
581
+ })
582
+ }),
583
+ /* @__PURE__ */ jsx(Field, {
584
+ label: "Course URL",
585
+ children: /* @__PURE__ */ jsx("input", {
586
+ value: course.slug,
587
+ onChange: (event) => patch({ slug: event.target.value }),
588
+ pattern: "[a-z0-9]+(-[a-z0-9]+)*"
589
+ })
590
+ }),
591
+ /* @__PURE__ */ jsx(Field, {
592
+ label: "Category",
593
+ children: /* @__PURE__ */ jsx("input", {
594
+ value: course.category,
595
+ onChange: (event) => patch({ category: event.target.value })
596
+ })
597
+ }),
598
+ /* @__PURE__ */ jsx(Field, {
599
+ label: "Level",
600
+ children: /* @__PURE__ */ jsx("select", {
601
+ value: course.level,
602
+ onChange: (event) => patch({ level: event.target.value }),
603
+ children: [
604
+ "all",
605
+ "beginner",
606
+ "intermediate",
607
+ "advanced"
608
+ ].map((level) => /* @__PURE__ */ jsx("option", { children: level }, level))
609
+ })
610
+ }),
611
+ /* @__PURE__ */ jsx(Field, {
612
+ label: "Language",
613
+ children: /* @__PURE__ */ jsx("input", {
614
+ value: course.language,
615
+ onChange: (event) => patch({ language: event.target.value }),
616
+ placeholder: "en, ta, hi…"
617
+ })
618
+ }),
619
+ /* @__PURE__ */ jsx(Field, {
620
+ label: "Instructor name",
621
+ children: /* @__PURE__ */ jsx("input", {
622
+ value: course.instructorName,
623
+ onChange: (event) => patch({ instructorName: event.target.value })
624
+ })
625
+ })
626
+ ]
627
+ }),
628
+ /* @__PURE__ */ jsx(Field, {
629
+ label: "Summary",
630
+ children: /* @__PURE__ */ jsx("textarea", {
631
+ rows: 3,
632
+ value: course.summary,
633
+ onChange: (event) => patch({ summary: event.target.value }),
634
+ maxLength: 1e3
635
+ })
636
+ }),
637
+ /* @__PURE__ */ jsx(Field, {
638
+ label: "Course description",
639
+ children: /* @__PURE__ */ jsx("textarea", {
640
+ rows: 7,
641
+ value: course.description,
642
+ onChange: (event) => patch({ description: event.target.value })
643
+ })
644
+ }),
645
+ /* @__PURE__ */ jsxs("div", {
646
+ className: "lms-grid",
647
+ children: [
648
+ /* @__PURE__ */ jsx(Field, {
649
+ label: "Learning outcomes",
650
+ help: "One outcome per line.",
651
+ children: /* @__PURE__ */ jsx("textarea", {
652
+ rows: 5,
653
+ value: course.outcomes.join("\n"),
654
+ onChange: (event) => patch({ outcomes: event.target.value.split("\n").filter(Boolean) })
655
+ })
656
+ }),
657
+ /* @__PURE__ */ jsx(Field, {
658
+ label: "Requirements",
659
+ help: "One requirement per line.",
660
+ children: /* @__PURE__ */ jsx("textarea", {
661
+ rows: 5,
662
+ value: course.requirements.join("\n"),
663
+ onChange: (event) => patch({ requirements: event.target.value.split("\n").filter(Boolean) })
664
+ })
665
+ }),
666
+ /* @__PURE__ */ jsx(Field, {
667
+ label: "Tags",
668
+ help: "Separate tags with commas.",
669
+ children: /* @__PURE__ */ jsx("input", {
670
+ value: course.tags.join(", "),
671
+ onChange: (event) => patch({ tags: event.target.value.split(",").map((tag) => tag.trim()).filter(Boolean) })
672
+ })
673
+ }),
674
+ /* @__PURE__ */ jsx(Field, {
675
+ label: "Course image URL",
676
+ children: /* @__PURE__ */ jsx("input", {
677
+ type: "url",
678
+ value: course.featuredImage?.src ?? "",
679
+ onChange: (event) => patch({ featuredImage: event.target.value ? {
680
+ id: course.featuredImage?.id ?? "",
681
+ src: event.target.value,
682
+ alt: course.featuredImage?.alt ?? ""
683
+ } : null })
684
+ })
685
+ }),
686
+ /* @__PURE__ */ jsx(Field, {
687
+ label: "Image description",
688
+ children: /* @__PURE__ */ jsx("input", {
689
+ value: course.featuredImage?.alt ?? "",
690
+ onChange: (event) => course.featuredImage && patch({ featuredImage: {
691
+ ...course.featuredImage,
692
+ alt: event.target.value
693
+ } })
694
+ })
695
+ }),
696
+ /* @__PURE__ */ jsxs("div", { children: [
697
+ /* @__PURE__ */ jsx(ChoicesField, {
698
+ label: "Additional instructors",
699
+ value: course.instructorIds,
700
+ choices: instructorChoices.items.map((account) => ({
701
+ id: account.id,
702
+ label: account.name || account.email
703
+ })),
704
+ onChange: (instructorIds) => patch({ instructorIds })
705
+ }),
706
+ instructorChoices.data?.hasMore && /* @__PURE__ */ jsx(Button, {
707
+ onClick: instructorChoices.more,
708
+ children: "Load more instructors"
709
+ }),
710
+ /* @__PURE__ */ jsx(Notice, { error: instructorChoices.error })
711
+ ] })
712
+ ]
713
+ })
714
+ ] }),
715
+ tab === "access" && /* @__PURE__ */ jsxs(Panel, { children: [
716
+ /* @__PURE__ */ jsxs("div", {
717
+ className: "lms-grid",
718
+ children: [
719
+ /* @__PURE__ */ jsx(Field, {
720
+ label: "Enrollment",
721
+ children: /* @__PURE__ */ jsxs("select", {
722
+ value: course.enrollmentMode,
723
+ onChange: (event) => patch({ enrollmentMode: event.target.value }),
724
+ children: [
725
+ /* @__PURE__ */ jsx("option", {
726
+ value: "open",
727
+ children: "Free · open enrollment"
728
+ }),
729
+ /* @__PURE__ */ jsx("option", {
730
+ value: "approval",
731
+ children: "Administrator approval"
732
+ }),
733
+ /* @__PURE__ */ jsx("option", {
734
+ value: "invite",
735
+ children: "Invitation only"
736
+ })
737
+ ]
738
+ })
739
+ }),
740
+ /* @__PURE__ */ jsx(Field, {
741
+ label: "Access duration in days",
742
+ help: "0 gives unlimited access.",
743
+ children: /* @__PURE__ */ jsx("input", {
744
+ type: "number",
745
+ min: 0,
746
+ max: 3650,
747
+ value: course.accessDays,
748
+ onChange: (event) => patch({ accessDays: Number(event.target.value) })
749
+ })
750
+ }),
751
+ /* @__PURE__ */ jsx(Field, {
752
+ label: "Enrollment closes",
753
+ children: /* @__PURE__ */ jsx("input", {
754
+ type: "datetime-local",
755
+ value: localDate(course.enrollmentClosesAt),
756
+ onChange: (event) => patch({ enrollmentClosesAt: isoDate(event.target.value) })
757
+ })
758
+ }),
759
+ /* @__PURE__ */ jsxs("div", { children: [
760
+ /* @__PURE__ */ jsx(ChoicesField, {
761
+ label: "Prerequisite courses",
762
+ value: course.prerequisiteCourseIds,
763
+ choices: prerequisiteChoices.items.filter((value) => value.id !== course.id).map((value) => ({
764
+ id: value.id,
765
+ label: value.title
766
+ })),
767
+ onChange: (prerequisiteCourseIds) => patch({ prerequisiteCourseIds })
768
+ }),
769
+ prerequisiteChoices.data?.hasMore && /* @__PURE__ */ jsx(Button, {
770
+ onClick: prerequisiteChoices.more,
771
+ children: "Load more courses"
772
+ }),
773
+ /* @__PURE__ */ jsx(Notice, { error: prerequisiteChoices.error })
774
+ ] })
775
+ ]
776
+ }),
777
+ /* @__PURE__ */ jsxs("label", {
778
+ className: "lms-check",
779
+ children: [/* @__PURE__ */ jsx("input", {
780
+ type: "checkbox",
781
+ checked: course.sequential,
782
+ onChange: (event) => patch({ sequential: event.target.checked })
783
+ }), "Require lessons in order"]
784
+ }),
785
+ /* @__PURE__ */ jsxs("label", {
786
+ className: "lms-check",
787
+ children: [/* @__PURE__ */ jsx("input", {
788
+ type: "checkbox",
789
+ checked: course.certificateEnabled,
790
+ onChange: (event) => patch({ certificateEnabled: event.target.checked })
791
+ }), "Issue a certificate after all required lessons are passed"]
792
+ })
793
+ ] }),
794
+ tab === "curriculum" && /* @__PURE__ */ jsxs("div", {
795
+ className: "lms-studio",
796
+ children: [/* @__PURE__ */ jsxs("aside", {
797
+ className: "lms-panel",
798
+ children: [
799
+ /* @__PURE__ */ jsx("h2", { children: "Modules & lessons" }),
800
+ course.modules.map((module, moduleIndex) => /* @__PURE__ */ jsxs("section", {
801
+ className: "lms-module",
802
+ children: [
803
+ /* @__PURE__ */ jsx(Field, {
804
+ label: `Module ${moduleIndex + 1}`,
805
+ children: /* @__PURE__ */ jsx("input", {
806
+ value: module.title,
807
+ onChange: (event) => updateModule(moduleIndex, { title: event.target.value })
808
+ })
809
+ }),
810
+ /* @__PURE__ */ jsxs("div", {
811
+ className: "lms-grid",
812
+ children: [/* @__PURE__ */ jsx(Field, {
813
+ label: "Release after days",
814
+ children: /* @__PURE__ */ jsx("input", {
815
+ type: "number",
816
+ min: 0,
817
+ value: module.releaseDays,
818
+ onChange: (event) => updateModule(moduleIndex, { releaseDays: Number(event.target.value) })
819
+ })
820
+ }), /* @__PURE__ */ jsx(Field, {
821
+ label: "Release date",
822
+ children: /* @__PURE__ */ jsx("input", {
823
+ type: "datetime-local",
824
+ value: localDate(module.unlockAt),
825
+ onChange: (event) => updateModule(moduleIndex, { unlockAt: isoDate(event.target.value) })
826
+ })
827
+ })]
828
+ }),
829
+ /* @__PURE__ */ jsx("ol", {
830
+ className: "lms-lesson-list",
831
+ children: module.lessons.map((lesson, lessonIndex) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("button", {
832
+ className: "lms-select-lesson",
833
+ "aria-current": selected === lesson.id,
834
+ onClick: () => setSelected(lesson.id),
835
+ children: [lesson.title, /* @__PURE__ */ jsxs("small", { children: [lesson.kind, lesson.required ? " · required" : " · optional"] })]
836
+ }), /* @__PURE__ */ jsxs("div", {
837
+ className: "lms-actions",
838
+ children: [/* @__PURE__ */ jsx(Button, {
839
+ "aria-label": `Move ${lesson.title} up`,
840
+ disabled: lessonIndex === 0,
841
+ onClick: () => reorderLesson(moduleIndex, lessonIndex, -1),
842
+ children: "↑"
843
+ }), /* @__PURE__ */ jsx(Button, {
844
+ "aria-label": `Move ${lesson.title} down`,
845
+ disabled: lessonIndex === module.lessons.length - 1,
846
+ onClick: () => reorderLesson(moduleIndex, lessonIndex, 1),
847
+ children: "↓"
848
+ })]
849
+ })] }, lesson.id))
850
+ }),
851
+ /* @__PURE__ */ jsx(Button, {
852
+ onClick: () => {
853
+ const lesson = lessonSchema.parse({
854
+ id: crypto.randomUUID(),
855
+ title: "New lesson"
856
+ });
857
+ updateModule(moduleIndex, { lessons: [...module.lessons, lesson] });
858
+ setSelected(lesson.id);
859
+ },
860
+ children: "Add lesson"
861
+ }),
862
+ module.lessons.length === 0 && /* @__PURE__ */ jsx(Button, {
863
+ danger: true,
864
+ onClick: () => patch({ modules: course.modules.filter((item) => item.id !== module.id) }),
865
+ children: "Remove empty module"
866
+ }),
867
+ /* @__PURE__ */ jsx("div", {
868
+ className: "lms-actions",
869
+ children: /* @__PURE__ */ jsx(Button, {
870
+ disabled: moduleIndex === 0,
871
+ "aria-label": `Move module ${module.title} up`,
872
+ onClick: () => {
873
+ const next = [...course.modules];
874
+ [next[moduleIndex], next[moduleIndex - 1]] = [next[moduleIndex - 1], next[moduleIndex]];
875
+ patch({ modules: next });
876
+ },
877
+ children: "Move module up"
878
+ })
879
+ })
880
+ ]
881
+ }, module.id)),
882
+ /* @__PURE__ */ jsx(Button, {
883
+ onClick: () => patch({ modules: [...course.modules, moduleSchema.parse({
884
+ id: crypto.randomUUID(),
885
+ title: `Module ${course.modules.length + 1}`
886
+ })] }),
887
+ children: "Add module"
888
+ })
889
+ ]
890
+ }), /* @__PURE__ */ jsx(Panel, {
891
+ title: selectedLesson?.title ?? "Choose a lesson",
892
+ children: selectedLesson ? /* @__PURE__ */ jsx(LessonEditor, {
893
+ lesson: selectedLesson,
894
+ update: (data) => updateLesson(selectedLesson.id, data),
895
+ remove: () => {
896
+ if (window.confirm(`Remove “${selectedLesson.title}” from the draft?`)) {
897
+ patch({ modules: course.modules.map((module) => ({
898
+ ...module,
899
+ lessons: module.lessons.filter((lesson) => lesson.id !== selectedLesson.id)
900
+ })) });
901
+ setSelected(null);
902
+ }
903
+ }
904
+ }) : /* @__PURE__ */ jsx("p", { children: "Add a module and a lesson to begin." })
905
+ })]
906
+ })
907
+ ]
908
+ });
909
+ }
910
+ function ContentPicker({ value, onChange }) {
911
+ const schema = useLoad("admin/content/collections");
912
+ const [collection, setCollection] = useState(value?.collection ?? "");
913
+ const [cursor, setCursor] = useState();
914
+ const [entries, setEntries] = useState([]);
915
+ const list = useLoad("admin/content/entries", {
916
+ collection,
917
+ cursor,
918
+ limit: 100
919
+ }, !!collection);
920
+ useEffect(() => {
921
+ if (list.data) setEntries((old) => [...new Map([...old, ...list.data.items].map((entry) => [entry.id, entry])).values()]);
922
+ }, [list.data]);
923
+ const fields = schema.data?.find((entry) => entry.slug === collection)?.fields ?? [];
924
+ return /* @__PURE__ */ jsxs("details", { children: [
925
+ /* @__PURE__ */ jsx("summary", { children: "Use published EmDash content" }),
926
+ /* @__PURE__ */ jsx("p", { children: "Choose a published entry and its text field to reuse formatted lesson content." }),
927
+ /* @__PURE__ */ jsx(Notice, { error: schema.error || list.error }),
928
+ /* @__PURE__ */ jsxs("div", {
929
+ className: "lms-grid",
930
+ children: [/* @__PURE__ */ jsx(Field, {
931
+ label: "Collection",
932
+ children: /* @__PURE__ */ jsxs("select", {
933
+ value: collection,
934
+ onChange: (event) => {
935
+ setCollection(event.target.value);
936
+ setCursor(void 0);
937
+ setEntries([]);
938
+ onChange(null);
939
+ },
940
+ children: [/* @__PURE__ */ jsx("option", {
941
+ value: "",
942
+ children: "Use this lesson's own content"
943
+ }), schema.data?.map((entry) => /* @__PURE__ */ jsx("option", {
944
+ value: entry.slug,
945
+ children: entry.label
946
+ }, entry.slug))]
947
+ })
948
+ }), collection && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Field, {
949
+ label: "Published entry",
950
+ children: /* @__PURE__ */ jsxs("select", {
951
+ value: value?.id ?? "",
952
+ onChange: (event) => onChange(event.target.value ? {
953
+ collection,
954
+ id: event.target.value,
955
+ field: value?.field ?? fields.find((field) => field.type === "portableText")?.slug ?? fields[0]?.slug ?? "content"
956
+ } : null),
957
+ children: [
958
+ /* @__PURE__ */ jsx("option", {
959
+ value: "",
960
+ children: "Choose an entry"
961
+ }),
962
+ value && !entries.some((entry) => entry.id === value.id) && /* @__PURE__ */ jsx("option", {
963
+ value: value.id,
964
+ children: "Current linked entry"
965
+ }),
966
+ entries.map((entry) => /* @__PURE__ */ jsx("option", {
967
+ value: entry.id,
968
+ children: entry.title
969
+ }, entry.id))
970
+ ]
971
+ })
972
+ }), /* @__PURE__ */ jsx(Field, {
973
+ label: "Content field",
974
+ children: /* @__PURE__ */ jsxs("select", {
975
+ value: value?.field ?? "",
976
+ disabled: !value,
977
+ onChange: (event) => value && onChange({
978
+ ...value,
979
+ field: event.target.value
980
+ }),
981
+ children: [/* @__PURE__ */ jsx("option", {
982
+ value: "",
983
+ children: "Choose a field"
984
+ }), fields.map((field) => /* @__PURE__ */ jsx("option", {
985
+ value: field.slug,
986
+ children: field.label
987
+ }, field.slug))]
988
+ })
989
+ })] })]
990
+ }),
991
+ list.data?.hasMore && /* @__PURE__ */ jsx(Button, {
992
+ onClick: () => setCursor(list.data?.cursor),
993
+ children: "Load more entries"
994
+ })
995
+ ] });
996
+ }
997
+ function LessonEditor({ lesson, update, remove }) {
998
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
999
+ /* @__PURE__ */ jsxs("div", {
1000
+ className: "lms-grid",
1001
+ children: [
1002
+ /* @__PURE__ */ jsx(Field, {
1003
+ label: "Lesson title",
1004
+ children: /* @__PURE__ */ jsx("input", {
1005
+ value: lesson.title,
1006
+ onChange: (event) => update({ title: event.target.value })
1007
+ })
1008
+ }),
1009
+ /* @__PURE__ */ jsx(Field, {
1010
+ label: "Lesson type",
1011
+ children: /* @__PURE__ */ jsx("select", {
1012
+ value: lesson.kind,
1013
+ onChange: (event) => {
1014
+ const kind = event.target.value;
1015
+ update({
1016
+ kind,
1017
+ preview: [
1018
+ "quiz",
1019
+ "assignment",
1020
+ "live"
1021
+ ].includes(kind) ? false : lesson.preview,
1022
+ quiz: kind === "quiz" ? lesson.quiz ?? quizSchema.parse({ questions: [defaultQuestion()] }) : null,
1023
+ assignment: kind === "assignment" ? lesson.assignment ?? assignmentSchema.parse({ instructions: "Submit your work here." }) : null
1024
+ });
1025
+ },
1026
+ children: [
1027
+ "text",
1028
+ "video",
1029
+ "audio",
1030
+ "quiz",
1031
+ "assignment",
1032
+ "live"
1033
+ ].map((kind) => /* @__PURE__ */ jsx("option", { children: kind }, kind))
1034
+ })
1035
+ }),
1036
+ /* @__PURE__ */ jsx(Field, {
1037
+ label: "Estimated minutes",
1038
+ children: /* @__PURE__ */ jsx("input", {
1039
+ type: "number",
1040
+ min: 0,
1041
+ value: lesson.durationMinutes,
1042
+ onChange: (event) => update({ durationMinutes: Number(event.target.value) })
1043
+ })
1044
+ }),
1045
+ /* @__PURE__ */ jsx(Field, {
1046
+ label: "Minimum study seconds",
1047
+ children: /* @__PURE__ */ jsx("input", {
1048
+ type: "number",
1049
+ min: 0,
1050
+ value: lesson.minStudySeconds,
1051
+ onChange: (event) => update({ minStudySeconds: Number(event.target.value) })
1052
+ })
1053
+ })
1054
+ ]
1055
+ }),
1056
+ /* @__PURE__ */ jsx(Field, {
1057
+ label: "Summary",
1058
+ children: /* @__PURE__ */ jsx("textarea", {
1059
+ rows: 2,
1060
+ value: lesson.summary,
1061
+ onChange: (event) => update({ summary: event.target.value })
1062
+ })
1063
+ }),
1064
+ /* @__PURE__ */ jsx(Field, {
1065
+ label: "Lesson text",
1066
+ children: /* @__PURE__ */ jsx("textarea", {
1067
+ rows: 12,
1068
+ value: lesson.body,
1069
+ onChange: (event) => update({ body: event.target.value })
1070
+ })
1071
+ }),
1072
+ [
1073
+ "video",
1074
+ "audio",
1075
+ "live"
1076
+ ].includes(lesson.kind) && /* @__PURE__ */ jsx(Field, {
1077
+ label: lesson.kind === "live" ? "Meeting link" : "Media URL",
1078
+ help: "Use a direct media file, YouTube link, or Vimeo link.",
1079
+ children: /* @__PURE__ */ jsx("input", {
1080
+ type: "url",
1081
+ value: lesson.mediaUrl ?? "",
1082
+ onChange: (event) => update({ mediaUrl: event.target.value || null })
1083
+ })
1084
+ }),
1085
+ lesson.kind === "live" && /* @__PURE__ */ jsx(Field, {
1086
+ label: "Session starts",
1087
+ children: /* @__PURE__ */ jsx("input", {
1088
+ type: "datetime-local",
1089
+ value: localDate(lesson.liveStartsAt),
1090
+ onChange: (event) => update({ liveStartsAt: isoDate(event.target.value) })
1091
+ })
1092
+ }),
1093
+ /* @__PURE__ */ jsxs("div", {
1094
+ className: "lms-actions",
1095
+ children: [/* @__PURE__ */ jsxs("label", {
1096
+ className: "lms-check",
1097
+ children: [/* @__PURE__ */ jsx("input", {
1098
+ type: "checkbox",
1099
+ checked: lesson.required,
1100
+ onChange: (event) => update({ required: event.target.checked })
1101
+ }), "Required for completion"]
1102
+ }), ![
1103
+ "quiz",
1104
+ "assignment",
1105
+ "live"
1106
+ ].includes(lesson.kind) && /* @__PURE__ */ jsxs("label", {
1107
+ className: "lms-check",
1108
+ children: [/* @__PURE__ */ jsx("input", {
1109
+ type: "checkbox",
1110
+ checked: lesson.preview,
1111
+ onChange: (event) => update({ preview: event.target.checked })
1112
+ }), "Free preview"]
1113
+ })]
1114
+ }),
1115
+ /* @__PURE__ */ jsx(ContentPicker, {
1116
+ value: lesson.contentSource,
1117
+ onChange: (contentSource) => update({ contentSource })
1118
+ }, lesson.id),
1119
+ lesson.kind === "quiz" && lesson.quiz && /* @__PURE__ */ jsx(QuizEditor, {
1120
+ quiz: lesson.quiz,
1121
+ update: (quiz) => update({ quiz })
1122
+ }),
1123
+ lesson.kind === "assignment" && lesson.assignment && /* @__PURE__ */ jsxs(Panel, {
1124
+ title: "Assignment",
1125
+ children: [
1126
+ /* @__PURE__ */ jsx(Field, {
1127
+ label: "Instructions",
1128
+ children: /* @__PURE__ */ jsx("textarea", {
1129
+ rows: 6,
1130
+ value: lesson.assignment.instructions,
1131
+ onChange: (event) => update({ assignment: {
1132
+ ...lesson.assignment,
1133
+ instructions: event.target.value
1134
+ } })
1135
+ })
1136
+ }),
1137
+ /* @__PURE__ */ jsxs("div", {
1138
+ className: "lms-grid",
1139
+ children: [
1140
+ /* @__PURE__ */ jsx(Field, {
1141
+ label: "Maximum points",
1142
+ children: /* @__PURE__ */ jsx("input", {
1143
+ type: "number",
1144
+ min: 1,
1145
+ value: lesson.assignment.maxPoints,
1146
+ onChange: (event) => update({ assignment: {
1147
+ ...lesson.assignment,
1148
+ maxPoints: Number(event.target.value)
1149
+ } })
1150
+ })
1151
+ }),
1152
+ /* @__PURE__ */ jsx(Field, {
1153
+ label: "Passing points",
1154
+ children: /* @__PURE__ */ jsx("input", {
1155
+ type: "number",
1156
+ min: 1,
1157
+ value: lesson.assignment.passingPoints,
1158
+ onChange: (event) => update({ assignment: {
1159
+ ...lesson.assignment,
1160
+ passingPoints: Number(event.target.value)
1161
+ } })
1162
+ })
1163
+ }),
1164
+ /* @__PURE__ */ jsx(Field, {
1165
+ label: "Due date",
1166
+ children: /* @__PURE__ */ jsx("input", {
1167
+ type: "datetime-local",
1168
+ value: localDate(lesson.assignment.dueAt),
1169
+ onChange: (event) => update({ assignment: {
1170
+ ...lesson.assignment,
1171
+ dueAt: isoDate(event.target.value)
1172
+ } })
1173
+ })
1174
+ })
1175
+ ]
1176
+ }),
1177
+ /* @__PURE__ */ jsxs("label", {
1178
+ className: "lms-check",
1179
+ children: [/* @__PURE__ */ jsx("input", {
1180
+ type: "checkbox",
1181
+ checked: lesson.assignment.allowResubmission,
1182
+ onChange: (event) => update({ assignment: {
1183
+ ...lesson.assignment,
1184
+ allowResubmission: event.target.checked
1185
+ } })
1186
+ }), "Allow another submission after a failing grade"]
1187
+ })
1188
+ ]
1189
+ }),
1190
+ /* @__PURE__ */ jsxs(Panel, {
1191
+ title: "Lesson resources",
1192
+ children: [lesson.resources.map((resource, index) => /* @__PURE__ */ jsxs("div", {
1193
+ className: "lms-resource",
1194
+ children: [
1195
+ /* @__PURE__ */ jsx(Field, {
1196
+ label: `Resource ${index + 1}`,
1197
+ children: /* @__PURE__ */ jsx("input", {
1198
+ value: resource.title,
1199
+ onChange: (event) => update({ resources: lesson.resources.map((item) => item.id === resource.id ? {
1200
+ ...item,
1201
+ title: event.target.value
1202
+ } : item) })
1203
+ })
1204
+ }),
1205
+ /* @__PURE__ */ jsx(Field, {
1206
+ label: "URL",
1207
+ children: /* @__PURE__ */ jsx("input", {
1208
+ value: resource.url,
1209
+ onChange: (event) => update({ resources: lesson.resources.map((item) => item.id === resource.id ? {
1210
+ ...item,
1211
+ url: event.target.value
1212
+ } : item) })
1213
+ })
1214
+ }),
1215
+ /* @__PURE__ */ jsx(Button, {
1216
+ danger: true,
1217
+ onClick: () => update({ resources: lesson.resources.filter((item) => item.id !== resource.id) }),
1218
+ children: "Remove resource"
1219
+ })
1220
+ ]
1221
+ }, resource.id)), /* @__PURE__ */ jsx(Button, {
1222
+ onClick: () => update({ resources: [...lesson.resources, {
1223
+ id: crypto.randomUUID(),
1224
+ title: "New resource",
1225
+ url: "/",
1226
+ description: ""
1227
+ }] }),
1228
+ children: "Add resource"
1229
+ })]
1230
+ }),
1231
+ /* @__PURE__ */ jsx(Button, {
1232
+ danger: true,
1233
+ onClick: remove,
1234
+ children: "Remove lesson"
1235
+ })
1236
+ ] });
1237
+ }
1238
+ function defaultQuestion() {
1239
+ return questionSchema.parse({
1240
+ id: crypto.randomUUID(),
1241
+ type: "single",
1242
+ prompt: "New question",
1243
+ options: [{
1244
+ id: "a",
1245
+ text: "First option"
1246
+ }, {
1247
+ id: "b",
1248
+ text: "Second option"
1249
+ }],
1250
+ correctAnswers: ["a"]
1251
+ });
1252
+ }
1253
+ function QuizEditor({ quiz, update }) {
1254
+ const patchQuestion = (id, data) => update({
1255
+ ...quiz,
1256
+ questions: quiz.questions.map((question) => question.id === id ? {
1257
+ ...question,
1258
+ ...data
1259
+ } : question)
1260
+ });
1261
+ return /* @__PURE__ */ jsxs(Panel, {
1262
+ title: "Quiz",
1263
+ children: [
1264
+ /* @__PURE__ */ jsxs("div", {
1265
+ className: "lms-grid",
1266
+ children: [
1267
+ /* @__PURE__ */ jsx(Field, {
1268
+ label: "Passing percentage",
1269
+ children: /* @__PURE__ */ jsx("input", {
1270
+ type: "number",
1271
+ min: 1,
1272
+ max: 100,
1273
+ value: quiz.passingPercent,
1274
+ onChange: (event) => update({
1275
+ ...quiz,
1276
+ passingPercent: Number(event.target.value)
1277
+ })
1278
+ })
1279
+ }),
1280
+ /* @__PURE__ */ jsx(Field, {
1281
+ label: "Maximum attempts",
1282
+ children: /* @__PURE__ */ jsx("input", {
1283
+ type: "number",
1284
+ min: 1,
1285
+ max: 20,
1286
+ value: quiz.maxAttempts,
1287
+ onChange: (event) => update({
1288
+ ...quiz,
1289
+ maxAttempts: Number(event.target.value)
1290
+ })
1291
+ })
1292
+ }),
1293
+ /* @__PURE__ */ jsx(Field, {
1294
+ label: "Time limit in minutes",
1295
+ help: "0 gives an untimed quiz.",
1296
+ children: /* @__PURE__ */ jsx("input", {
1297
+ type: "number",
1298
+ min: 0,
1299
+ max: 180,
1300
+ value: quiz.timeLimitMinutes,
1301
+ onChange: (event) => update({
1302
+ ...quiz,
1303
+ timeLimitMinutes: Number(event.target.value)
1304
+ })
1305
+ })
1306
+ }),
1307
+ /* @__PURE__ */ jsx(Field, {
1308
+ label: "Show explanations",
1309
+ children: /* @__PURE__ */ jsxs("select", {
1310
+ value: quiz.showFeedback,
1311
+ onChange: (event) => update({
1312
+ ...quiz,
1313
+ showFeedback: event.target.value
1314
+ }),
1315
+ children: [
1316
+ /* @__PURE__ */ jsx("option", {
1317
+ value: "after_pass",
1318
+ children: "After passing"
1319
+ }),
1320
+ /* @__PURE__ */ jsx("option", {
1321
+ value: "after_submit",
1322
+ children: "After each submission"
1323
+ }),
1324
+ /* @__PURE__ */ jsx("option", {
1325
+ value: "never",
1326
+ children: "Never"
1327
+ })
1328
+ ]
1329
+ })
1330
+ })
1331
+ ]
1332
+ }),
1333
+ /* @__PURE__ */ jsxs("div", {
1334
+ className: "lms-actions",
1335
+ children: [/* @__PURE__ */ jsxs("label", {
1336
+ className: "lms-check",
1337
+ children: [/* @__PURE__ */ jsx("input", {
1338
+ type: "checkbox",
1339
+ checked: quiz.randomizeQuestions,
1340
+ onChange: (event) => update({
1341
+ ...quiz,
1342
+ randomizeQuestions: event.target.checked
1343
+ })
1344
+ }), "Shuffle questions"]
1345
+ }), /* @__PURE__ */ jsxs("label", {
1346
+ className: "lms-check",
1347
+ children: [/* @__PURE__ */ jsx("input", {
1348
+ type: "checkbox",
1349
+ checked: quiz.randomizeOptions,
1350
+ onChange: (event) => update({
1351
+ ...quiz,
1352
+ randomizeOptions: event.target.checked
1353
+ })
1354
+ }), "Shuffle choices"]
1355
+ })]
1356
+ }),
1357
+ quiz.questions.map((question, index) => /* @__PURE__ */ jsxs("section", {
1358
+ className: "lms-question",
1359
+ children: [
1360
+ /* @__PURE__ */ jsxs("h3", { children: ["Question ", index + 1] }),
1361
+ /* @__PURE__ */ jsxs("div", {
1362
+ className: "lms-grid",
1363
+ children: [/* @__PURE__ */ jsx(Field, {
1364
+ label: "Type",
1365
+ children: /* @__PURE__ */ jsx("select", {
1366
+ value: question.type,
1367
+ onChange: (event) => {
1368
+ const type = event.target.value;
1369
+ const options = type === "true_false" ? [{
1370
+ id: "true",
1371
+ text: "True"
1372
+ }, {
1373
+ id: "false",
1374
+ text: "False"
1375
+ }] : type === "short" ? [] : question.options.length ? question.options : [{
1376
+ id: "a",
1377
+ text: "First option"
1378
+ }, {
1379
+ id: "b",
1380
+ text: "Second option"
1381
+ }];
1382
+ patchQuestion(question.id, {
1383
+ type,
1384
+ options,
1385
+ correctAnswers: type === "short" ? ["Accepted answer"] : [options[0].id]
1386
+ });
1387
+ },
1388
+ children: [
1389
+ ["single", "Single choice"],
1390
+ ["multiple", "Multiple choices"],
1391
+ ["true_false", "True or false"],
1392
+ ["short", "Short answer"]
1393
+ ].map(([value, label]) => /* @__PURE__ */ jsx("option", {
1394
+ value,
1395
+ children: label
1396
+ }, value))
1397
+ })
1398
+ }), /* @__PURE__ */ jsx(Field, {
1399
+ label: "Points",
1400
+ children: /* @__PURE__ */ jsx("input", {
1401
+ type: "number",
1402
+ min: 1,
1403
+ max: 100,
1404
+ value: question.points,
1405
+ onChange: (event) => patchQuestion(question.id, { points: Number(event.target.value) })
1406
+ })
1407
+ })]
1408
+ }),
1409
+ /* @__PURE__ */ jsx(Field, {
1410
+ label: "Question",
1411
+ children: /* @__PURE__ */ jsx("textarea", {
1412
+ rows: 3,
1413
+ value: question.prompt,
1414
+ onChange: (event) => patchQuestion(question.id, { prompt: event.target.value })
1415
+ })
1416
+ }),
1417
+ question.type === "short" ? /* @__PURE__ */ jsx(Field, {
1418
+ label: "Accepted answers",
1419
+ help: "One answer per line. Matching ignores case and extra spaces.",
1420
+ children: /* @__PURE__ */ jsx("textarea", {
1421
+ value: question.correctAnswers.join("\n"),
1422
+ onChange: (event) => patchQuestion(question.id, { correctAnswers: event.target.value.split("\n").filter(Boolean) })
1423
+ })
1424
+ }) : /* @__PURE__ */ jsxs("fieldset", { children: [
1425
+ /* @__PURE__ */ jsx("legend", { children: "Answer choices · select the correct answers" }),
1426
+ question.options.map((option) => /* @__PURE__ */ jsxs("div", {
1427
+ className: "lms-option",
1428
+ children: [
1429
+ /* @__PURE__ */ jsx("input", {
1430
+ "aria-label": `Mark ${option.text} correct`,
1431
+ type: question.type === "multiple" ? "checkbox" : "radio",
1432
+ name: `correct-${question.id}`,
1433
+ checked: question.correctAnswers.includes(option.id),
1434
+ onChange: (event) => patchQuestion(question.id, { correctAnswers: question.type === "multiple" ? event.target.checked ? [...question.correctAnswers, option.id] : question.correctAnswers.filter((id) => id !== option.id) : [option.id] })
1435
+ }),
1436
+ /* @__PURE__ */ jsx("input", {
1437
+ "aria-label": "Answer text",
1438
+ value: option.text,
1439
+ onChange: (event) => patchQuestion(question.id, { options: question.options.map((item) => item.id === option.id ? {
1440
+ ...item,
1441
+ text: event.target.value
1442
+ } : item) })
1443
+ }),
1444
+ question.type !== "true_false" && question.options.length > 2 && /* @__PURE__ */ jsx(Button, {
1445
+ "aria-label": `Remove answer ${option.text}`,
1446
+ onClick: () => patchQuestion(question.id, {
1447
+ options: question.options.filter((item) => item.id !== option.id),
1448
+ correctAnswers: question.correctAnswers.filter((id) => id !== option.id)
1449
+ }),
1450
+ children: "×"
1451
+ })
1452
+ ]
1453
+ }, option.id)),
1454
+ question.type !== "true_false" && question.options.length < 10 && /* @__PURE__ */ jsx(Button, {
1455
+ onClick: () => patchQuestion(question.id, { options: [...question.options, {
1456
+ id: crypto.randomUUID(),
1457
+ text: "New option"
1458
+ }] }),
1459
+ children: "Add answer choice"
1460
+ })
1461
+ ] }),
1462
+ /* @__PURE__ */ jsx(Field, {
1463
+ label: "Explanation",
1464
+ children: /* @__PURE__ */ jsx("textarea", {
1465
+ rows: 2,
1466
+ value: question.explanation,
1467
+ onChange: (event) => patchQuestion(question.id, { explanation: event.target.value })
1468
+ })
1469
+ }),
1470
+ /* @__PURE__ */ jsxs("div", {
1471
+ className: "lms-actions",
1472
+ children: [/* @__PURE__ */ jsx(Button, {
1473
+ disabled: index === 0,
1474
+ "aria-label": `Move question ${index + 1} up`,
1475
+ onClick: () => {
1476
+ const next = [...quiz.questions];
1477
+ [next[index], next[index - 1]] = [next[index - 1], next[index]];
1478
+ update({
1479
+ ...quiz,
1480
+ questions: next
1481
+ });
1482
+ },
1483
+ children: "Move up"
1484
+ }), /* @__PURE__ */ jsx(Button, {
1485
+ danger: true,
1486
+ disabled: quiz.questions.length < 2,
1487
+ onClick: () => update({
1488
+ ...quiz,
1489
+ questions: quiz.questions.filter((item) => item.id !== question.id)
1490
+ }),
1491
+ children: "Remove question"
1492
+ })]
1493
+ })
1494
+ ]
1495
+ }, question.id)),
1496
+ quiz.questions.length < 50 && /* @__PURE__ */ jsx(Button, {
1497
+ onClick: () => update({
1498
+ ...quiz,
1499
+ questions: [...quiz.questions, defaultQuestion()]
1500
+ }),
1501
+ children: "Add question"
1502
+ })
1503
+ ]
1504
+ });
1505
+ }
1506
+ function localDate(value) {
1507
+ if (!value) return "";
1508
+ const date = new Date(value);
1509
+ const offset = date.getTimezoneOffset() * 6e4;
1510
+ return new Date(date.getTime() - offset).toISOString().slice(0, 16);
1511
+ }
1512
+ function isoDate(value) {
1513
+ return value ? new Date(value).toISOString() : null;
1514
+ }
1515
+ function download(name, body, type) {
1516
+ const url = URL.createObjectURL(new Blob([body], { type }));
1517
+ const anchor = document.createElement("a");
1518
+ anchor.href = url;
1519
+ anchor.download = name;
1520
+ anchor.click();
1521
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
1522
+ }
1523
+ function EnrollmentAccessEditor({ row, close, saved }) {
1524
+ const [status, setStatus] = useState(row.status === "pending" || row.status === "completed" ? "active" : row.status);
1525
+ const [reason, setReason] = useState(row.decisionReason ?? "");
1526
+ const [startsAt, setStartsAt] = useState(row.accessStartsAt);
1527
+ const [expiresAt, setExpiresAt] = useState(row.accessExpiresAt);
1528
+ const action = useAction();
1529
+ return /* @__PURE__ */ jsxs(Panel, {
1530
+ title: `Manage ${row.learnerName}'s access`,
1531
+ children: [
1532
+ /* @__PURE__ */ jsx("p", { children: row.courseTitle }),
1533
+ /* @__PURE__ */ jsx(Notice, { error: action.error }),
1534
+ /* @__PURE__ */ jsxs("form", {
1535
+ onSubmit: (event) => {
1536
+ event.preventDefault();
1537
+ action.run(async () => {
1538
+ await api("admin/enrollment/save", {
1539
+ courseId: row.courseId,
1540
+ userId: row.userId,
1541
+ status,
1542
+ reason,
1543
+ accessStartsAt: startsAt,
1544
+ accessExpiresAt: expiresAt
1545
+ }, "POST");
1546
+ saved();
1547
+ });
1548
+ },
1549
+ children: [
1550
+ /* @__PURE__ */ jsxs("div", {
1551
+ className: "lms-grid",
1552
+ children: [
1553
+ /* @__PURE__ */ jsx(Field, {
1554
+ label: "Enrollment decision",
1555
+ children: /* @__PURE__ */ jsx("select", {
1556
+ value: status,
1557
+ onChange: (event) => setStatus(event.target.value),
1558
+ children: [
1559
+ "active",
1560
+ "rejected",
1561
+ "suspended",
1562
+ "cancelled"
1563
+ ].map((value) => /* @__PURE__ */ jsx("option", {
1564
+ value,
1565
+ children: value === "active" ? "Approve / restore access" : value
1566
+ }, value))
1567
+ })
1568
+ }),
1569
+ /* @__PURE__ */ jsx(Field, {
1570
+ label: "Access starts",
1571
+ children: /* @__PURE__ */ jsx("input", {
1572
+ type: "datetime-local",
1573
+ value: localDate(startsAt),
1574
+ onChange: (event) => setStartsAt(isoDate(event.target.value))
1575
+ })
1576
+ }),
1577
+ /* @__PURE__ */ jsx(Field, {
1578
+ label: "Access expires",
1579
+ children: /* @__PURE__ */ jsx("input", {
1580
+ type: "datetime-local",
1581
+ value: localDate(expiresAt),
1582
+ onChange: (event) => setExpiresAt(isoDate(event.target.value))
1583
+ })
1584
+ }),
1585
+ /* @__PURE__ */ jsx(Field, {
1586
+ label: "Decision note",
1587
+ children: /* @__PURE__ */ jsx("textarea", {
1588
+ maxLength: 1e3,
1589
+ value: reason,
1590
+ onChange: (event) => setReason(event.target.value)
1591
+ })
1592
+ })
1593
+ ]
1594
+ }),
1595
+ /* @__PURE__ */ jsx("p", { children: "These access dates apply to this learner's course enrollment. Leave blank for no additional date restriction." }),
1596
+ /* @__PURE__ */ jsxs("div", {
1597
+ className: "lms-actions",
1598
+ children: [/* @__PURE__ */ jsx(Button, {
1599
+ type: "submit",
1600
+ busy: action.busy,
1601
+ children: "Save access"
1602
+ }), /* @__PURE__ */ jsx(Button, {
1603
+ onClick: close,
1604
+ children: "Close"
1605
+ })]
1606
+ })
1607
+ ]
1608
+ })
1609
+ ]
1610
+ });
1611
+ }
1612
+ function LearnersPage() {
1613
+ const [courseId, setCourseId] = useState("");
1614
+ const [status, setStatus] = useState("");
1615
+ const [cursor, setCursor] = useState();
1616
+ const [email, setEmail] = useState("");
1617
+ const [managing, setManaging] = useState();
1618
+ const list = useLoad("admin/enrollments", {
1619
+ courseId,
1620
+ status,
1621
+ cursor
1622
+ });
1623
+ const action = useAction();
1624
+ const update = (row, next) => void action.run(async () => {
1625
+ await api("admin/enrollment/save", {
1626
+ courseId: row.courseId,
1627
+ userId: row.userId,
1628
+ status: next
1629
+ }, "POST");
1630
+ list.reload();
1631
+ }, "Enrollment updated.");
1632
+ const add = (event) => {
1633
+ event.preventDefault();
1634
+ action.run(async () => {
1635
+ if (!courseId) throw new Error("Choose a course first.");
1636
+ await api("admin/enrollment/save", {
1637
+ courseId,
1638
+ userId: (await api("admin/learner/find", {
1639
+ courseId,
1640
+ email
1641
+ }, "POST")).id,
1642
+ status: "active"
1643
+ }, "POST");
1644
+ setEmail("");
1645
+ list.reload();
1646
+ }, "Learner enrolled.");
1647
+ };
1648
+ return /* @__PURE__ */ jsxs(PageFrame, {
1649
+ title: "Enrollments",
1650
+ description: "Approve requests, enroll learners, and manage access.",
1651
+ children: [
1652
+ /* @__PURE__ */ jsx(Notice, {
1653
+ error: list.error || action.error,
1654
+ message: action.message
1655
+ }),
1656
+ managing && /* @__PURE__ */ jsx(EnrollmentAccessEditor, {
1657
+ row: managing,
1658
+ close: () => setManaging(void 0),
1659
+ saved: () => {
1660
+ setManaging(void 0);
1661
+ list.reload();
1662
+ }
1663
+ }, managing.id),
1664
+ /* @__PURE__ */ jsxs("div", {
1665
+ className: "lms-grid",
1666
+ children: [/* @__PURE__ */ jsx(CoursePicker, {
1667
+ value: courseId,
1668
+ allowAll: true,
1669
+ onChange: (id) => {
1670
+ setCourseId(id);
1671
+ setCursor(void 0);
1672
+ }
1673
+ }), /* @__PURE__ */ jsx(Field, {
1674
+ label: "Status",
1675
+ children: /* @__PURE__ */ jsxs("select", {
1676
+ value: status,
1677
+ onChange: (event) => {
1678
+ setStatus(event.target.value);
1679
+ setCursor(void 0);
1680
+ },
1681
+ children: [/* @__PURE__ */ jsx("option", {
1682
+ value: "",
1683
+ children: "All statuses"
1684
+ }), [
1685
+ "pending",
1686
+ "active",
1687
+ "completed",
1688
+ "rejected",
1689
+ "suspended",
1690
+ "cancelled"
1691
+ ].map((value) => /* @__PURE__ */ jsx("option", { children: value }, value))]
1692
+ })
1693
+ })]
1694
+ }),
1695
+ courseId && /* @__PURE__ */ jsx(Panel, {
1696
+ title: "Enroll an existing account",
1697
+ children: /* @__PURE__ */ jsxs("form", {
1698
+ onSubmit: add,
1699
+ className: "lms-toolbar",
1700
+ children: [/* @__PURE__ */ jsx(Field, {
1701
+ label: "Learner email",
1702
+ children: /* @__PURE__ */ jsx("input", {
1703
+ type: "email",
1704
+ required: true,
1705
+ value: email,
1706
+ onChange: (event) => setEmail(event.target.value)
1707
+ })
1708
+ }), /* @__PURE__ */ jsx(Button, {
1709
+ type: "submit",
1710
+ busy: action.busy,
1711
+ children: "Enroll learner"
1712
+ })]
1713
+ })
1714
+ }),
1715
+ /* @__PURE__ */ jsxs(Panel, { children: [/* @__PURE__ */ jsx("div", {
1716
+ className: "lms-table-wrap",
1717
+ children: /* @__PURE__ */ jsxs("table", {
1718
+ className: "lms-table",
1719
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
1720
+ /* @__PURE__ */ jsx("th", { children: "Learner" }),
1721
+ /* @__PURE__ */ jsx("th", { children: "Course" }),
1722
+ /* @__PURE__ */ jsx("th", { children: "Progress" }),
1723
+ /* @__PURE__ */ jsx("th", { children: "Status" }),
1724
+ /* @__PURE__ */ jsx("th", { children: "Actions" })
1725
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: list.data?.items.map((row) => /* @__PURE__ */ jsxs("tr", { children: [
1726
+ /* @__PURE__ */ jsxs("td", { children: [row.learnerName, /* @__PURE__ */ jsx("small", { children: row.learnerEmail })] }),
1727
+ /* @__PURE__ */ jsx("td", { children: row.courseTitle }),
1728
+ /* @__PURE__ */ jsxs("td", { children: [
1729
+ row.progressSummary?.percent ?? 0,
1730
+ "%",
1731
+ /* @__PURE__ */ jsx("small", { children: row.completedAt ? new Date(row.completedAt).toLocaleDateString() : "In progress" })
1732
+ ] }),
1733
+ /* @__PURE__ */ jsxs("td", { children: [
1734
+ row.status,
1735
+ /* @__PURE__ */ jsxs("small", { children: ["Access: ", row.effectiveAccess] }),
1736
+ /* @__PURE__ */ jsxs("small", { children: ["Source: ", row.accessSource] })
1737
+ ] }),
1738
+ /* @__PURE__ */ jsxs("td", { children: [/* @__PURE__ */ jsxs("div", {
1739
+ className: "lms-actions",
1740
+ children: [
1741
+ /* @__PURE__ */ jsx(Button, {
1742
+ onClick: () => setManaging(row),
1743
+ children: "Manage access"
1744
+ }),
1745
+ row.status === "pending" && /* @__PURE__ */ jsx(Button, {
1746
+ danger: true,
1747
+ busy: action.busy,
1748
+ onClick: () => update(row, "rejected"),
1749
+ children: "Reject"
1750
+ }),
1751
+ [
1752
+ "pending",
1753
+ "rejected",
1754
+ "suspended",
1755
+ "cancelled"
1756
+ ].includes(row.status) && /* @__PURE__ */ jsx(Button, {
1757
+ busy: action.busy,
1758
+ onClick: () => update(row, "active"),
1759
+ children: row.status === "pending" ? "Approve" : "Restore"
1760
+ }),
1761
+ ["active", "completed"].includes(row.status) && /* @__PURE__ */ jsx(Button, {
1762
+ busy: action.busy,
1763
+ onClick: () => update(row, "suspended"),
1764
+ children: "Suspend"
1765
+ }),
1766
+ row.status !== "cancelled" && /* @__PURE__ */ jsx(Button, {
1767
+ danger: true,
1768
+ busy: action.busy,
1769
+ onClick: () => {
1770
+ if (window.confirm(`Cancel ${row.learnerName}'s access to this course?`)) update(row, "cancelled");
1771
+ },
1772
+ children: "Cancel"
1773
+ }),
1774
+ row.certificate && !row.certificate.revokedAt && /* @__PURE__ */ jsx(Button, {
1775
+ danger: true,
1776
+ busy: action.busy,
1777
+ onClick: () => {
1778
+ const reason = window.prompt("Reason for revoking this certificate:");
1779
+ if (reason?.trim()) action.run(async () => {
1780
+ await api("admin/certificate/revoke", {
1781
+ courseId: row.courseId,
1782
+ userId: row.userId,
1783
+ reason
1784
+ }, "POST");
1785
+ list.reload();
1786
+ }, "Certificate revoked.");
1787
+ },
1788
+ children: "Revoke certificate"
1789
+ })
1790
+ ]
1791
+ }), /* @__PURE__ */ jsxs("details", { children: [/* @__PURE__ */ jsx("summary", { children: "Learning record" }), Object.entries(row.progress).map(([id, progress]) => /* @__PURE__ */ jsxs("p", { children: [
1792
+ row.lessonTitles[id] ?? "Lesson",
1793
+ " ·",
1794
+ " ",
1795
+ progress.completedAt ? "Complete" : "Started",
1796
+ " ·",
1797
+ " ",
1798
+ progress.quizAttempts.length,
1799
+ " quiz attempts ·",
1800
+ " ",
1801
+ progress.assignments.length,
1802
+ " submissions"
1803
+ ] }, id))] })] })
1804
+ ] }, row.id)) })]
1805
+ })
1806
+ }), list.data && !list.data.items.length && /* @__PURE__ */ jsx("p", { children: "No enrollments match this filter." })] }),
1807
+ /* @__PURE__ */ jsx(Pager, {
1808
+ page: list.data,
1809
+ next: setCursor,
1810
+ reset: () => setCursor(void 0)
1811
+ })
1812
+ ]
1813
+ });
1814
+ }
1815
+ function AssignmentsPage() {
1816
+ const [courseId, setCourseId] = useState("");
1817
+ const [cursor, setCursor] = useState();
1818
+ const list = useLoad("admin/assignments", {
1819
+ courseId,
1820
+ cursor
1821
+ }, !!courseId);
1822
+ const [selected, setSelected] = useState();
1823
+ const [points, setPoints] = useState(0);
1824
+ const [feedback, setFeedback] = useState("");
1825
+ const action = useAction();
1826
+ const grade = (event) => {
1827
+ event.preventDefault();
1828
+ if (!selected) return;
1829
+ action.run(async () => {
1830
+ await api("admin/assignment/grade", {
1831
+ courseId: selected.courseId,
1832
+ lessonId: selected.lessonId,
1833
+ userId: selected.userId,
1834
+ submissionId: selected.id,
1835
+ points,
1836
+ feedback
1837
+ }, "POST");
1838
+ setSelected(void 0);
1839
+ list.reload();
1840
+ }, "Grade saved and learner notified.");
1841
+ };
1842
+ return /* @__PURE__ */ jsxs(PageFrame, {
1843
+ title: "Assignments",
1844
+ description: "Read submissions and provide clear, useful feedback.",
1845
+ children: [
1846
+ /* @__PURE__ */ jsx(Notice, {
1847
+ error: list.error || action.error,
1848
+ message: action.message
1849
+ }),
1850
+ /* @__PURE__ */ jsx(CoursePicker, {
1851
+ value: courseId,
1852
+ onChange: (id) => {
1853
+ setCourseId(id);
1854
+ setCursor(void 0);
1855
+ setSelected(void 0);
1856
+ }
1857
+ }),
1858
+ !courseId && /* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsx("p", { children: "Choose a course to view its submissions." }) }),
1859
+ selected && /* @__PURE__ */ jsxs(Panel, {
1860
+ title: `Grade ${selected.learnerName}'s submission`,
1861
+ children: [
1862
+ /* @__PURE__ */ jsx("p", {
1863
+ className: "lms-body",
1864
+ children: selected.body
1865
+ }),
1866
+ selected.attachmentUrl && /* @__PURE__ */ jsx("a", {
1867
+ href: selected.attachmentUrl,
1868
+ target: "_blank",
1869
+ rel: "noopener noreferrer",
1870
+ children: "Open attachment ↗"
1871
+ }),
1872
+ /* @__PURE__ */ jsxs("form", {
1873
+ onSubmit: grade,
1874
+ children: [
1875
+ /* @__PURE__ */ jsx(Field, {
1876
+ label: `Points out of ${selected.maxPoints}`,
1877
+ help: `Passing grade: ${selected.passingPoints}`,
1878
+ children: /* @__PURE__ */ jsx("input", {
1879
+ type: "number",
1880
+ required: true,
1881
+ min: 0,
1882
+ max: selected.maxPoints,
1883
+ value: points,
1884
+ onChange: (event) => setPoints(Number(event.target.value))
1885
+ })
1886
+ }),
1887
+ /* @__PURE__ */ jsx(Field, {
1888
+ label: "Feedback",
1889
+ children: /* @__PURE__ */ jsx("textarea", {
1890
+ rows: 6,
1891
+ value: feedback,
1892
+ onChange: (event) => setFeedback(event.target.value)
1893
+ })
1894
+ }),
1895
+ /* @__PURE__ */ jsxs("div", {
1896
+ className: "lms-actions",
1897
+ children: [/* @__PURE__ */ jsx(Button, {
1898
+ type: "submit",
1899
+ busy: action.busy,
1900
+ children: "Save grade"
1901
+ }), /* @__PURE__ */ jsx(Button, {
1902
+ onClick: () => setSelected(void 0),
1903
+ children: "Close"
1904
+ })]
1905
+ })
1906
+ ]
1907
+ })
1908
+ ]
1909
+ }),
1910
+ list.data?.items.map((item) => /* @__PURE__ */ jsxs(Panel, { children: [
1911
+ /* @__PURE__ */ jsxs("div", {
1912
+ className: "lms-toolbar",
1913
+ children: [
1914
+ /* @__PURE__ */ jsx("h2", { children: item.learnerName }),
1915
+ /* @__PURE__ */ jsx("span", {
1916
+ className: "lms-badge",
1917
+ children: item.status
1918
+ }),
1919
+ /* @__PURE__ */ jsx("small", { children: new Date(item.submittedAt).toLocaleString() })
1920
+ ]
1921
+ }),
1922
+ /* @__PURE__ */ jsx("p", {
1923
+ className: "lms-body",
1924
+ children: item.body
1925
+ }),
1926
+ item.attachmentUrl && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("a", {
1927
+ href: item.attachmentUrl,
1928
+ target: "_blank",
1929
+ rel: "noopener noreferrer",
1930
+ children: "Open attachment ↗"
1931
+ }) }),
1932
+ item.status === "graded" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", { children: [
1933
+ item.points,
1934
+ "/",
1935
+ item.maxPoints,
1936
+ " points"
1937
+ ] }), /* @__PURE__ */ jsx("p", {
1938
+ className: "lms-body",
1939
+ children: item.feedback
1940
+ })] }) : /* @__PURE__ */ jsx(Button, {
1941
+ onClick: () => {
1942
+ setSelected(item);
1943
+ setPoints(0);
1944
+ setFeedback("");
1945
+ },
1946
+ children: "Review & grade"
1947
+ })
1948
+ ] }, item.id)),
1949
+ list.data && !list.data.items.length && /* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsx("p", { children: "No submissions on this page." }) }),
1950
+ /* @__PURE__ */ jsx(Pager, {
1951
+ page: list.data,
1952
+ next: setCursor,
1953
+ reset: () => setCursor(void 0)
1954
+ })
1955
+ ]
1956
+ });
1957
+ }
1958
+ function CommunityPage() {
1959
+ const [courseId, setCourseId] = useState("");
1960
+ const [kind, setKind] = useState("discussions");
1961
+ const [status, setStatus] = useState("pending");
1962
+ const [cursor, setCursor] = useState();
1963
+ const list = useLoad(`admin/${kind}`, {
1964
+ courseId,
1965
+ status,
1966
+ cursor
1967
+ });
1968
+ const action = useAction();
1969
+ const moderate = (item, next) => void action.run(async () => {
1970
+ await api(`admin/${kind === "reviews" ? "review" : "discussion"}/moderate`, {
1971
+ id: item.id,
1972
+ expectedRevision: item.revision,
1973
+ status: next
1974
+ }, "POST");
1975
+ list.reload();
1976
+ }, "Moderation saved.");
1977
+ return /* @__PURE__ */ jsxs(PageFrame, {
1978
+ title: "Learning community",
1979
+ description: "Moderate lesson discussions and course reviews.",
1980
+ children: [
1981
+ /* @__PURE__ */ jsx(Notice, {
1982
+ error: list.error || action.error,
1983
+ message: action.message
1984
+ }),
1985
+ /* @__PURE__ */ jsxs("div", {
1986
+ className: "lms-grid",
1987
+ children: [
1988
+ /* @__PURE__ */ jsx(CoursePicker, {
1989
+ value: courseId,
1990
+ allowAll: true,
1991
+ onChange: (id) => {
1992
+ setCourseId(id);
1993
+ setCursor(void 0);
1994
+ }
1995
+ }),
1996
+ /* @__PURE__ */ jsx(Field, {
1997
+ label: "Content",
1998
+ children: /* @__PURE__ */ jsxs("select", {
1999
+ value: kind,
2000
+ onChange: (event) => {
2001
+ setKind(event.target.value);
2002
+ setCursor(void 0);
2003
+ },
2004
+ children: [/* @__PURE__ */ jsx("option", {
2005
+ value: "discussions",
2006
+ children: "Discussions"
2007
+ }), /* @__PURE__ */ jsx("option", {
2008
+ value: "reviews",
2009
+ children: "Reviews"
2010
+ })]
2011
+ })
2012
+ }),
2013
+ /* @__PURE__ */ jsx(Field, {
2014
+ label: "Status",
2015
+ children: /* @__PURE__ */ jsx("select", {
2016
+ value: status,
2017
+ onChange: (event) => {
2018
+ setStatus(event.target.value);
2019
+ setCursor(void 0);
2020
+ },
2021
+ children: [
2022
+ "pending",
2023
+ "published",
2024
+ "hidden"
2025
+ ].map((value) => /* @__PURE__ */ jsx("option", { children: value }, value))
2026
+ })
2027
+ })
2028
+ ]
2029
+ }),
2030
+ list.data?.items.map((item) => /* @__PURE__ */ jsxs(Panel, { children: [
2031
+ /* @__PURE__ */ jsxs("h2", { children: [item.authorName, "rating" in item ? ` · ${item.rating}/5` : ""] }),
2032
+ /* @__PURE__ */ jsx("p", {
2033
+ className: "lms-body",
2034
+ children: item.body
2035
+ }),
2036
+ /* @__PURE__ */ jsxs("p", {
2037
+ className: "lms-muted",
2038
+ children: [
2039
+ new Date(item.createdAt).toLocaleString(),
2040
+ " · ",
2041
+ item.status
2042
+ ]
2043
+ }),
2044
+ /* @__PURE__ */ jsxs("div", {
2045
+ className: "lms-actions",
2046
+ children: [item.status !== "published" && /* @__PURE__ */ jsx(Button, {
2047
+ busy: action.busy,
2048
+ onClick: () => moderate(item, "published"),
2049
+ children: "Publish"
2050
+ }), item.status !== "hidden" && /* @__PURE__ */ jsx(Button, {
2051
+ danger: true,
2052
+ busy: action.busy,
2053
+ onClick: () => moderate(item, "hidden"),
2054
+ children: "Hide"
2055
+ })]
2056
+ })
2057
+ ] }, item.id)),
2058
+ list.data && !list.data.items.length && /* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsx("p", { children: "No community posts match this filter." }) }),
2059
+ /* @__PURE__ */ jsx(Pager, {
2060
+ page: list.data,
2061
+ next: setCursor,
2062
+ reset: () => setCursor(void 0)
2063
+ })
2064
+ ]
2065
+ });
2066
+ }
2067
+ function CohortMembershipQueue() {
2068
+ const cohorts = useChoices("admin/cohorts");
2069
+ const [cohortId, setCohortId] = useState("");
2070
+ const [status, setStatus] = useState("pending");
2071
+ const [cursor, setCursor] = useState();
2072
+ const [reason, setReason] = useState("");
2073
+ const list = useLoad("admin/cohort/memberships", {
2074
+ cohortId,
2075
+ status,
2076
+ cursor
2077
+ });
2078
+ const action = useAction();
2079
+ const decide = (membership, next) => void action.run(async () => {
2080
+ const result = await api("admin/cohort/decision", {
2081
+ cohortId: membership.cohortId,
2082
+ userId: membership.userId,
2083
+ status: next,
2084
+ reason
2085
+ }, "POST");
2086
+ list.reload();
2087
+ const failures = result.results.filter((item) => !item.success);
2088
+ if (failures.length) throw new Error(`Membership saved; ${failures.length} course access updates need attention. ${failures.map((item) => item.error).join(" ")} Review the learner's course enrollment and retry access.`);
2089
+ }, "Cohort membership updated.");
2090
+ return /* @__PURE__ */ jsxs(Panel, {
2091
+ title: "Cohort membership requests",
2092
+ children: [
2093
+ /* @__PURE__ */ jsx(Notice, {
2094
+ error: list.error || action.error,
2095
+ message: action.message
2096
+ }),
2097
+ /* @__PURE__ */ jsxs("div", {
2098
+ className: "lms-grid",
2099
+ children: [
2100
+ /* @__PURE__ */ jsxs(Field, {
2101
+ label: "Cohort",
2102
+ children: [/* @__PURE__ */ jsxs("select", {
2103
+ value: cohortId,
2104
+ onChange: (event) => {
2105
+ setCohortId(event.target.value);
2106
+ setCursor(void 0);
2107
+ },
2108
+ children: [/* @__PURE__ */ jsx("option", {
2109
+ value: "",
2110
+ children: "All cohorts"
2111
+ }), cohorts.items.map((cohort) => /* @__PURE__ */ jsx("option", {
2112
+ value: cohort.id,
2113
+ children: cohort.title
2114
+ }, cohort.id))]
2115
+ }), cohorts.data?.hasMore && /* @__PURE__ */ jsx(Button, {
2116
+ onClick: cohorts.more,
2117
+ children: "Load more cohorts"
2118
+ })]
2119
+ }),
2120
+ /* @__PURE__ */ jsx(Field, {
2121
+ label: "Membership status",
2122
+ children: /* @__PURE__ */ jsxs("select", {
2123
+ value: status,
2124
+ onChange: (event) => {
2125
+ setStatus(event.target.value);
2126
+ setCursor(void 0);
2127
+ },
2128
+ children: [/* @__PURE__ */ jsx("option", {
2129
+ value: "",
2130
+ children: "All statuses"
2131
+ }), [
2132
+ "pending",
2133
+ "active",
2134
+ "rejected",
2135
+ "suspended",
2136
+ "cancelled"
2137
+ ].map((value) => /* @__PURE__ */ jsx("option", { children: value }, value))]
2138
+ })
2139
+ }),
2140
+ /* @__PURE__ */ jsx(Field, {
2141
+ label: "Decision note (optional)",
2142
+ children: /* @__PURE__ */ jsx("input", {
2143
+ value: reason,
2144
+ maxLength: 1e3,
2145
+ onChange: (event) => setReason(event.target.value)
2146
+ })
2147
+ })
2148
+ ]
2149
+ }),
2150
+ /* @__PURE__ */ jsx("div", {
2151
+ className: "lms-table-wrap",
2152
+ children: /* @__PURE__ */ jsxs("table", {
2153
+ className: "lms-table",
2154
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2155
+ /* @__PURE__ */ jsx("th", { children: "Learner" }),
2156
+ /* @__PURE__ */ jsx("th", { children: "Cohort" }),
2157
+ /* @__PURE__ */ jsx("th", { children: "Membership" }),
2158
+ /* @__PURE__ */ jsx("th", { children: "Actions" })
2159
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: list.data?.items.map((membership) => /* @__PURE__ */ jsxs("tr", { children: [
2160
+ /* @__PURE__ */ jsxs("td", { children: [membership.learnerName, /* @__PURE__ */ jsx("small", { children: membership.learnerEmail })] }),
2161
+ /* @__PURE__ */ jsx("td", { children: cohorts.items.find((cohort) => cohort.id === membership.cohortId)?.title ?? "Cohort" }),
2162
+ /* @__PURE__ */ jsxs("td", { children: [membership.status, membership.reason && /* @__PURE__ */ jsx("small", { children: membership.reason })] }),
2163
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("div", {
2164
+ className: "lms-actions",
2165
+ children: [
2166
+ /* @__PURE__ */ jsx(Button, {
2167
+ busy: action.busy,
2168
+ onClick: () => decide(membership, "active"),
2169
+ children: membership.status === "pending" ? "Approve" : membership.status === "active" ? "Retry course access" : "Restore"
2170
+ }),
2171
+ membership.status === "pending" && /* @__PURE__ */ jsx(Button, {
2172
+ danger: true,
2173
+ busy: action.busy,
2174
+ onClick: () => decide(membership, "rejected"),
2175
+ children: "Reject"
2176
+ }),
2177
+ membership.status === "active" && /* @__PURE__ */ jsx(Button, {
2178
+ busy: action.busy,
2179
+ onClick: () => decide(membership, "suspended"),
2180
+ children: "Suspend membership"
2181
+ }),
2182
+ membership.status !== "cancelled" && /* @__PURE__ */ jsx(Button, {
2183
+ danger: true,
2184
+ busy: action.busy,
2185
+ onClick: () => decide(membership, "cancelled"),
2186
+ children: "Cancel membership"
2187
+ })
2188
+ ]
2189
+ }) })
2190
+ ] }, membership.id)) })]
2191
+ })
2192
+ }),
2193
+ list.data && !list.data.items.length && /* @__PURE__ */ jsx("p", { children: "No membership requests match this filter." }),
2194
+ /* @__PURE__ */ jsx(Pager, {
2195
+ page: list.data,
2196
+ next: setCursor,
2197
+ reset: () => setCursor(void 0)
2198
+ })
2199
+ ]
2200
+ });
2201
+ }
2202
+ function CohortsPage() {
2203
+ const [cursor, setCursor] = useState();
2204
+ const list = useLoad("admin/cohorts", { cursor });
2205
+ const courses = useChoices("admin/courses");
2206
+ const users = useChoices("admin/users");
2207
+ const academy = useLoad("academy");
2208
+ const [edit, setEdit] = useState();
2209
+ const action = useAction();
2210
+ const save = (event) => {
2211
+ event.preventDefault();
2212
+ if (!edit) return;
2213
+ action.run(async () => {
2214
+ const { id, revision, ...data } = edit;
2215
+ await api("admin/cohort/save", {
2216
+ id,
2217
+ expectedRevision: revision,
2218
+ data
2219
+ }, "POST");
2220
+ setEdit(void 0);
2221
+ list.reload();
2222
+ }, "Cohort saved.");
2223
+ };
2224
+ const enroll = (cohort) => void action.run(async () => {
2225
+ let offset = 0;
2226
+ let hasMore = true;
2227
+ const errors = [];
2228
+ while (hasMore) {
2229
+ const result = await api("admin/cohort/enroll", {
2230
+ id: cohort.id,
2231
+ expectedRevision: cohort.revision,
2232
+ offset
2233
+ }, "POST");
2234
+ offset = result.nextOffset;
2235
+ hasMore = result.hasMore;
2236
+ errors.push(...result.results.filter((row) => !row.success).map((row) => row.error ?? "Enrollment failed."));
2237
+ }
2238
+ if (errors.length) throw new Error(`${errors.length} enrollments need attention: ${errors.slice(0, 3).join(" ")}`);
2239
+ }, "Cohort learners enrolled.");
2240
+ return /* @__PURE__ */ jsxs(PageFrame, {
2241
+ title: "Cohorts",
2242
+ description: "Approve cohort membership and manage shared learning schedules.",
2243
+ children: [
2244
+ /* @__PURE__ */ jsx(Notice, {
2245
+ error: list.error || action.error || courses.error || users.error,
2246
+ message: action.message
2247
+ }),
2248
+ /* @__PURE__ */ jsx(Button, {
2249
+ onClick: () => setEdit({
2250
+ revision: null,
2251
+ title: "New cohort",
2252
+ courseIds: [],
2253
+ memberIds: [],
2254
+ startsAt: null,
2255
+ endsAt: null
2256
+ }),
2257
+ children: "Create cohort"
2258
+ }),
2259
+ edit && /* @__PURE__ */ jsx(Panel, {
2260
+ title: "Cohort details",
2261
+ children: /* @__PURE__ */ jsxs("form", {
2262
+ onSubmit: save,
2263
+ children: [
2264
+ /* @__PURE__ */ jsx(Field, {
2265
+ label: "Cohort name",
2266
+ children: /* @__PURE__ */ jsx("input", {
2267
+ required: true,
2268
+ value: edit.title,
2269
+ onChange: (event) => setEdit({
2270
+ ...edit,
2271
+ title: event.target.value
2272
+ })
2273
+ })
2274
+ }),
2275
+ /* @__PURE__ */ jsxs("div", {
2276
+ className: "lms-grid",
2277
+ children: [
2278
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(ChoicesField, {
2279
+ label: "Courses",
2280
+ value: edit.courseIds,
2281
+ choices: courses.items.map((course) => ({
2282
+ id: course.id,
2283
+ label: course.title
2284
+ })),
2285
+ onChange: (courseIds) => setEdit({
2286
+ ...edit,
2287
+ courseIds
2288
+ })
2289
+ }), courses.data?.hasMore && /* @__PURE__ */ jsx(Button, {
2290
+ onClick: courses.more,
2291
+ children: "Load more courses"
2292
+ })] }),
2293
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(ChoicesField, {
2294
+ label: "Learners for manual enrollment",
2295
+ value: edit.memberIds,
2296
+ choices: users.items.map((account) => ({
2297
+ id: account.id,
2298
+ label: `${account.name || account.email} · ${account.email}`
2299
+ })),
2300
+ onChange: (memberIds) => setEdit({
2301
+ ...edit,
2302
+ memberIds
2303
+ })
2304
+ }), users.data?.hasMore && /* @__PURE__ */ jsx(Button, {
2305
+ onClick: users.more,
2306
+ children: "Load more learners"
2307
+ })] }),
2308
+ /* @__PURE__ */ jsx(Field, {
2309
+ label: "Access starts",
2310
+ children: /* @__PURE__ */ jsx("input", {
2311
+ type: "datetime-local",
2312
+ value: localDate(edit.startsAt),
2313
+ onChange: (event) => setEdit({
2314
+ ...edit,
2315
+ startsAt: isoDate(event.target.value)
2316
+ })
2317
+ })
2318
+ }),
2319
+ /* @__PURE__ */ jsx(Field, {
2320
+ label: "Access ends",
2321
+ children: /* @__PURE__ */ jsx("input", {
2322
+ type: "datetime-local",
2323
+ value: localDate(edit.endsAt),
2324
+ onChange: (event) => setEdit({
2325
+ ...edit,
2326
+ endsAt: isoDate(event.target.value)
2327
+ })
2328
+ })
2329
+ })
2330
+ ]
2331
+ }),
2332
+ /* @__PURE__ */ jsxs("div", {
2333
+ className: "lms-actions",
2334
+ children: [/* @__PURE__ */ jsx(Button, {
2335
+ type: "submit",
2336
+ busy: action.busy,
2337
+ children: "Save cohort"
2338
+ }), /* @__PURE__ */ jsx(Button, {
2339
+ onClick: () => setEdit(void 0),
2340
+ children: "Close"
2341
+ })]
2342
+ })
2343
+ ]
2344
+ })
2345
+ }),
2346
+ list.data?.items.map((cohort) => /* @__PURE__ */ jsxs(Panel, { children: [
2347
+ /* @__PURE__ */ jsx("h2", { children: cohort.title }),
2348
+ /* @__PURE__ */ jsxs("p", { children: [
2349
+ cohort.memberIds.length,
2350
+ " learners · ",
2351
+ cohort.courseIds.length,
2352
+ " courses"
2353
+ ] }),
2354
+ /* @__PURE__ */ jsxs("div", {
2355
+ className: "lms-actions",
2356
+ children: [
2357
+ /* @__PURE__ */ jsx(Button, {
2358
+ onClick: () => setEdit({ ...cohort }),
2359
+ children: "Edit"
2360
+ }),
2361
+ /* @__PURE__ */ jsx("a", {
2362
+ href: `${academy.data?.basePath ?? "/academy"}/cohorts/${cohort.id}`,
2363
+ target: "_blank",
2364
+ rel: "noopener noreferrer",
2365
+ children: "Open enrollment page ↗"
2366
+ }),
2367
+ /* @__PURE__ */ jsx(Button, {
2368
+ busy: action.busy,
2369
+ onClick: () => enroll(cohort),
2370
+ children: "Enroll members"
2371
+ })
2372
+ ]
2373
+ })
2374
+ ] }, cohort.id)),
2375
+ /* @__PURE__ */ jsx(Pager, {
2376
+ page: list.data,
2377
+ next: setCursor,
2378
+ reset: () => setCursor(void 0)
2379
+ }),
2380
+ /* @__PURE__ */ jsx(CohortMembershipQueue, {})
2381
+ ]
2382
+ });
2383
+ }
2384
+ function ReportsPage() {
2385
+ const [courseId, setCourseId] = useState("");
2386
+ const report = useLoad("admin/report", { courseId });
2387
+ const action = useAction();
2388
+ const exportCsv = () => void action.run(async () => {
2389
+ const rows = [];
2390
+ let cursor;
2391
+ do {
2392
+ const page = await api("admin/enrollments", {
2393
+ courseId,
2394
+ cursor,
2395
+ limit: 100
2396
+ });
2397
+ rows.push(...page.items);
2398
+ if (rows.length > 1e4) throw new Error("Choose a course to export fewer than 10,000 enrollments.");
2399
+ cursor = page.hasMore ? page.cursor : void 0;
2400
+ } while (cursor);
2401
+ download("lms-enrollments.csv", "" + [enrollmentCsvHeader, ...enrollmentCsvLines(rows)].join("\r\n"), "text/csv;charset=utf-8");
2402
+ }, "Report exported.");
2403
+ return /* @__PURE__ */ jsxs(PageFrame, {
2404
+ title: "Learning reports",
2405
+ description: "Enrollment and completion counts cover all records in the selected scope.",
2406
+ children: [
2407
+ /* @__PURE__ */ jsx(Notice, {
2408
+ error: report.error || action.error,
2409
+ message: action.message
2410
+ }),
2411
+ /* @__PURE__ */ jsx(CoursePicker, {
2412
+ value: courseId,
2413
+ allowAll: true,
2414
+ onChange: setCourseId
2415
+ }),
2416
+ /* @__PURE__ */ jsx(Metrics, { report: report.data }),
2417
+ /* @__PURE__ */ jsx(Panel, {
2418
+ title: "Enrollment status",
2419
+ children: /* @__PURE__ */ jsx("div", {
2420
+ className: "lms-table-wrap",
2421
+ children: /* @__PURE__ */ jsxs("table", {
2422
+ className: "lms-table",
2423
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", { children: "Status" }), /* @__PURE__ */ jsx("th", { children: "Enrollments" })] }) }), /* @__PURE__ */ jsx("tbody", { children: [
2424
+ "pending",
2425
+ "active",
2426
+ "completed",
2427
+ "rejected",
2428
+ "suspended",
2429
+ "cancelled"
2430
+ ].map((status) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", { children: status }), /* @__PURE__ */ jsx("td", { children: report.data ? report.data[status] : "—" })] }, status)) })]
2431
+ })
2432
+ })
2433
+ }),
2434
+ /* @__PURE__ */ jsx(Button, {
2435
+ busy: action.busy,
2436
+ onClick: exportCsv,
2437
+ children: "Export enrollments as CSV"
2438
+ }),
2439
+ /* @__PURE__ */ jsxs(Panel, {
2440
+ title: "Access sources",
2441
+ children: [/* @__PURE__ */ jsx("div", {
2442
+ className: "lms-table-wrap",
2443
+ children: /* @__PURE__ */ jsxs("table", {
2444
+ className: "lms-table",
2445
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", { children: "Initial grant source" }), /* @__PURE__ */ jsx("th", { children: "Enrollments" })] }) }), /* @__PURE__ */ jsx("tbody", { children: [
2446
+ "free",
2447
+ "manual",
2448
+ "cohort",
2449
+ "purchase"
2450
+ ].map((source) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", { children: source }), /* @__PURE__ */ jsx("td", { children: report.data?.accessSources[source] ?? "—" })] }, source)) })]
2451
+ })
2452
+ }), /* @__PURE__ */ jsx("p", { children: "An enrollment can have several access grants. The source records its first approved acquisition; each learner's current access is shown in the CSV export." })]
2453
+ }),
2454
+ /* @__PURE__ */ jsxs(Panel, {
2455
+ title: "Access decisions",
2456
+ children: [/* @__PURE__ */ jsx("div", {
2457
+ className: "lms-table-wrap",
2458
+ children: /* @__PURE__ */ jsxs("table", {
2459
+ className: "lms-table",
2460
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", { children: "Decision" }), /* @__PURE__ */ jsx("th", { children: "Enrollments" })] }) }), /* @__PURE__ */ jsx("tbody", { children: [
2461
+ "pending",
2462
+ "granted",
2463
+ "suspended",
2464
+ "revoked"
2465
+ ].map((decision) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", { children: decision }), /* @__PURE__ */ jsx("td", { children: report.data?.accessDecisions[decision] ?? "—" })] }, decision)) })]
2466
+ })
2467
+ }), /* @__PURE__ */ jsx("p", { children: "Access decisions are separate from date windows and cohort membership. Use the enrollment export to review current access." })]
2468
+ })
2469
+ ]
2470
+ });
2471
+ }
2472
+ function NotificationsPage() {
2473
+ const [cursor, setCursor] = useState();
2474
+ const [status, setStatus] = useState("failed");
2475
+ const list = useLoad("admin/notifications", {
2476
+ cursor,
2477
+ status
2478
+ });
2479
+ const action = useAction();
2480
+ return /* @__PURE__ */ jsxs(PageFrame, {
2481
+ title: "Learning notifications",
2482
+ description: "Review delivery status and retry failed emails.",
2483
+ children: [
2484
+ /* @__PURE__ */ jsx(Notice, {
2485
+ error: list.error || action.error,
2486
+ message: action.message
2487
+ }),
2488
+ /* @__PURE__ */ jsxs("div", {
2489
+ className: "lms-actions",
2490
+ children: [/* @__PURE__ */ jsx(Field, {
2491
+ label: "Email status",
2492
+ children: /* @__PURE__ */ jsxs("select", {
2493
+ value: status,
2494
+ onChange: (event) => {
2495
+ setStatus(event.target.value);
2496
+ setCursor(void 0);
2497
+ },
2498
+ children: [/* @__PURE__ */ jsx("option", {
2499
+ value: "",
2500
+ children: "All notifications"
2501
+ }), [
2502
+ "failed",
2503
+ "pending",
2504
+ "sending",
2505
+ "sent",
2506
+ "disabled"
2507
+ ].map((value) => /* @__PURE__ */ jsx("option", {
2508
+ value,
2509
+ children: value
2510
+ }, value))]
2511
+ })
2512
+ }), /* @__PURE__ */ jsx(Button, {
2513
+ onClick: list.reload,
2514
+ busy: list.loading,
2515
+ children: "Refresh"
2516
+ })]
2517
+ }),
2518
+ /* @__PURE__ */ jsxs(Panel, { children: [
2519
+ /* @__PURE__ */ jsx("p", { children: "Retries run during scheduled maintenance, with up to three attempts per email. Review delivery before retrying: an interrupted confirmation can mean the email was already sent." }),
2520
+ /* @__PURE__ */ jsx("div", {
2521
+ className: "lms-table-wrap",
2522
+ children: /* @__PURE__ */ jsxs("table", {
2523
+ className: "lms-table",
2524
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2525
+ /* @__PURE__ */ jsx("th", { children: "Created" }),
2526
+ /* @__PURE__ */ jsx("th", { children: "Learner" }),
2527
+ /* @__PURE__ */ jsx("th", { children: "Notification" }),
2528
+ /* @__PURE__ */ jsx("th", { children: "Email" }),
2529
+ /* @__PURE__ */ jsx("th", { children: "Attempts" }),
2530
+ /* @__PURE__ */ jsx("th", { children: "Action" })
2531
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: list.data?.items.map((item) => /* @__PURE__ */ jsxs("tr", { children: [
2532
+ /* @__PURE__ */ jsx("td", { children: new Date(item.createdAt).toLocaleString() }),
2533
+ /* @__PURE__ */ jsx("td", { children: item.email }),
2534
+ /* @__PURE__ */ jsxs("td", { children: [/* @__PURE__ */ jsx("strong", { children: item.title }), /* @__PURE__ */ jsx("p", { children: item.message })] }),
2535
+ /* @__PURE__ */ jsx("td", { children: item.emailStatus }),
2536
+ /* @__PURE__ */ jsxs("td", { children: [item.emailAttempts, " / 3"] }),
2537
+ /* @__PURE__ */ jsx("td", { children: item.emailStatus === "failed" && item.emailAttempts < 3 && /* @__PURE__ */ jsx(Button, {
2538
+ busy: action.busy,
2539
+ onClick: () => void action.run(async () => {
2540
+ await api("admin/notification/retry", { id: item.id }, "POST");
2541
+ list.reload();
2542
+ }, "Email queued for retry."),
2543
+ children: "Retry email"
2544
+ }) })
2545
+ ] }, item.id)) })]
2546
+ })
2547
+ }),
2548
+ list.loading && /* @__PURE__ */ jsx("p", {
2549
+ role: "status",
2550
+ children: "Loading notifications…"
2551
+ }),
2552
+ !list.loading && list.data?.items.length === 0 && /* @__PURE__ */ jsx("p", { children: "No notifications match this status." })
2553
+ ] }),
2554
+ /* @__PURE__ */ jsx(Pager, {
2555
+ page: list.data,
2556
+ next: setCursor,
2557
+ reset: () => setCursor(void 0)
2558
+ })
2559
+ ]
2560
+ });
2561
+ }
2562
+ function AuditPage() {
2563
+ const [cursor, setCursor] = useState();
2564
+ const list = useLoad("admin/audit", { cursor });
2565
+ return /* @__PURE__ */ jsxs(PageFrame, {
2566
+ title: "Learning audit history",
2567
+ description: "Inspect course changes, enrollment decisions, grades, moderation, and delivery retries.",
2568
+ children: [
2569
+ /* @__PURE__ */ jsx(Notice, { error: list.error }),
2570
+ /* @__PURE__ */ jsx(Button, {
2571
+ onClick: list.reload,
2572
+ busy: list.loading,
2573
+ children: "Refresh"
2574
+ }),
2575
+ /* @__PURE__ */ jsxs(Panel, { children: [
2576
+ /* @__PURE__ */ jsx("div", {
2577
+ className: "lms-table-wrap",
2578
+ children: /* @__PURE__ */ jsxs("table", {
2579
+ className: "lms-table",
2580
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
2581
+ /* @__PURE__ */ jsx("th", { children: "Time" }),
2582
+ /* @__PURE__ */ jsx("th", { children: "Action" }),
2583
+ /* @__PURE__ */ jsx("th", { children: "Actor" }),
2584
+ /* @__PURE__ */ jsx("th", { children: "Resource" }),
2585
+ /* @__PURE__ */ jsx("th", { children: "Details" })
2586
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: list.data?.items.map((item) => /* @__PURE__ */ jsxs("tr", { children: [
2587
+ /* @__PURE__ */ jsx("td", { children: new Date(item.createdAt).toLocaleString() }),
2588
+ /* @__PURE__ */ jsx("td", { children: item.action }),
2589
+ /* @__PURE__ */ jsx("td", { children: item.actorId }),
2590
+ /* @__PURE__ */ jsx("td", { children: item.resourceId }),
2591
+ /* @__PURE__ */ jsx("td", { children: JSON.stringify(item.details) })
2592
+ ] }, item.id)) })]
2593
+ })
2594
+ }),
2595
+ list.loading && /* @__PURE__ */ jsx("p", {
2596
+ role: "status",
2597
+ children: "Loading audit history…"
2598
+ }),
2599
+ !list.loading && list.data?.items.length === 0 && /* @__PURE__ */ jsx("p", { children: "No learning administration actions recorded yet." })
2600
+ ] }),
2601
+ /* @__PURE__ */ jsx(Pager, {
2602
+ page: list.data,
2603
+ next: setCursor,
2604
+ reset: () => setCursor(void 0)
2605
+ })
2606
+ ]
2607
+ });
2608
+ }
2609
+ function SettingsPage() {
2610
+ const load = useLoad("admin/settings");
2611
+ const [settings, setSettings] = useState(settingsSchema.parse({}));
2612
+ const action = useAction();
2613
+ useEffect(() => {
2614
+ if (load.data) setSettings(load.data);
2615
+ }, [load.data]);
2616
+ const save = (event) => {
2617
+ event.preventDefault();
2618
+ action.run(async () => {
2619
+ await api("admin/settings/save", settings, "POST");
2620
+ load.reload();
2621
+ }, "LMS settings saved.");
2622
+ };
2623
+ return /* @__PURE__ */ jsxs(PageFrame, {
2624
+ title: "LMS settings",
2625
+ description: "Configure your academy, certificates, moderation, and reminders.",
2626
+ children: [/* @__PURE__ */ jsx(Notice, {
2627
+ error: load.error || action.error,
2628
+ message: action.message
2629
+ }), /* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsxs("form", {
2630
+ onSubmit: save,
2631
+ children: [
2632
+ /* @__PURE__ */ jsx(Field, {
2633
+ label: "Academy title",
2634
+ children: /* @__PURE__ */ jsx("input", {
2635
+ value: settings.academyTitle,
2636
+ onChange: (event) => setSettings({
2637
+ ...settings,
2638
+ academyTitle: event.target.value
2639
+ })
2640
+ })
2641
+ }),
2642
+ /* @__PURE__ */ jsx(Field, {
2643
+ label: "Academy introduction",
2644
+ children: /* @__PURE__ */ jsx("textarea", {
2645
+ rows: 3,
2646
+ value: settings.academyDescription,
2647
+ onChange: (event) => setSettings({
2648
+ ...settings,
2649
+ academyDescription: event.target.value
2650
+ })
2651
+ })
2652
+ }),
2653
+ /* @__PURE__ */ jsx(Field, {
2654
+ label: "Certificate issuer",
2655
+ children: /* @__PURE__ */ jsx("input", {
2656
+ value: settings.issuerName,
2657
+ onChange: (event) => setSettings({
2658
+ ...settings,
2659
+ issuerName: event.target.value
2660
+ })
2661
+ })
2662
+ }),
2663
+ /* @__PURE__ */ jsx(Field, {
2664
+ label: "Remind inactive learners after days",
2665
+ help: "0 disables reminders. Scheduled maintenance must be enabled in the host.",
2666
+ children: /* @__PURE__ */ jsx("input", {
2667
+ type: "number",
2668
+ min: 0,
2669
+ max: 90,
2670
+ value: settings.reminderDays,
2671
+ onChange: (event) => setSettings({
2672
+ ...settings,
2673
+ reminderDays: Number(event.target.value)
2674
+ })
2675
+ })
2676
+ }),
2677
+ /* @__PURE__ */ jsxs("label", {
2678
+ className: "lms-check",
2679
+ children: [/* @__PURE__ */ jsx("input", {
2680
+ type: "checkbox",
2681
+ checked: settings.moderateDiscussions,
2682
+ onChange: (event) => setSettings({
2683
+ ...settings,
2684
+ moderateDiscussions: event.target.checked
2685
+ })
2686
+ }), "Review discussions before publishing"]
2687
+ }),
2688
+ /* @__PURE__ */ jsxs("label", {
2689
+ className: "lms-check",
2690
+ children: [/* @__PURE__ */ jsx("input", {
2691
+ type: "checkbox",
2692
+ checked: settings.moderateReviews,
2693
+ onChange: (event) => setSettings({
2694
+ ...settings,
2695
+ moderateReviews: event.target.checked
2696
+ })
2697
+ }), "Review course reviews before publishing"]
2698
+ }),
2699
+ /* @__PURE__ */ jsxs("label", {
2700
+ className: "lms-check",
2701
+ children: [/* @__PURE__ */ jsx("input", {
2702
+ type: "checkbox",
2703
+ checked: settings.emailNotifications,
2704
+ onChange: (event) => setSettings({
2705
+ ...settings,
2706
+ emailNotifications: event.target.checked
2707
+ })
2708
+ }), "Send notifications through the site's EmDash email transport"]
2709
+ }),
2710
+ /* @__PURE__ */ jsx(Button, {
2711
+ type: "submit",
2712
+ busy: action.busy,
2713
+ children: "Save settings"
2714
+ })
2715
+ ]
2716
+ }) })]
2717
+ });
2718
+ }
2719
+ function LearningWidget() {
2720
+ const report = useLoad("admin/report");
2721
+ return /* @__PURE__ */ jsxs("div", {
2722
+ className: "ag-lms-admin",
2723
+ children: [
2724
+ /* @__PURE__ */ jsx("style", { children: css }),
2725
+ /* @__PURE__ */ jsx(Notice, { error: report.error }),
2726
+ /* @__PURE__ */ jsxs("p", { children: [
2727
+ /* @__PURE__ */ jsx("strong", { children: report.data?.active ?? "—" }),
2728
+ " active ·",
2729
+ " ",
2730
+ /* @__PURE__ */ jsx("strong", { children: report.data?.completedEver ?? "—" }),
2731
+ " completed ·",
2732
+ " ",
2733
+ /* @__PURE__ */ jsx("strong", { children: report.data?.pending ?? "—" }),
2734
+ " awaiting approval"
2735
+ ] }),
2736
+ /* @__PURE__ */ jsx("a", {
2737
+ href: ADMIN_BASE,
2738
+ children: "Open learning overview →"
2739
+ })
2740
+ ]
2741
+ });
2742
+ }
2743
+ const pages = {
2744
+ "/": OverviewPage,
2745
+ "/courses": CoursesPage,
2746
+ "/learners": LearnersPage,
2747
+ "/assignments": AssignmentsPage,
2748
+ "/community": CommunityPage,
2749
+ "/cohorts": CohortsPage,
2750
+ "/reports": ReportsPage,
2751
+ "/notifications": NotificationsPage,
2752
+ "/audit": AuditPage,
2753
+ "/settings": SettingsPage
2754
+ };
2755
+ const widgets = { learning: LearningWidget };
2756
+ const css = `
2757
+ .ag-lms-admin{color:var(--text-color-kumo-default,#1f2937);font-family:var(--font-emdash,ui-sans-serif,system-ui,sans-serif);padding:clamp(1rem,3vw,2.5rem);max-width:1400px;margin-inline:auto;line-height:1.55;direction:inherit}
2758
+ .ag-lms-admin *{box-sizing:border-box}.ag-lms-admin h1{font-size:clamp(1.6rem,3vw,2.15rem);margin:0}.ag-lms-admin h2{font-size:1.15rem;margin-block:0 .8rem}.ag-lms-admin h3{font-size:1rem}.ag-lms-admin p{margin-block:.5rem 1rem}.lms-page-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-block-end:1.5rem}.lms-page-header>div>p{max-width:65ch;color:var(--text-color-kumo-subtle,#64748b)}.lms-eyebrow{font-size:.7rem;letter-spacing:.15em;font-weight:700}.lms-tabs{display:flex;gap:.3rem;flex-wrap:wrap;margin-block:1rem 1.5rem}.lms-tabs a{padding:.4rem .7rem;border-radius:.4rem;text-decoration:none;color:inherit;background:var(--color-kumo-control,#f1f5f9)}.lms-panel{background:var(--color-kumo-base,#fff);border:1px solid var(--color-kumo-line,#d1d5db);border-radius:.65rem;padding:1.3rem;margin-block-end:1rem;min-width:0}.lms-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}.lms-course-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:1rem}.lms-course-grid .lms-panel{display:flex;flex-direction:column;align-items:flex-start}.lms-course-grid .lms-actions{margin-block-start:auto}.lms-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:1rem}.lms-metrics strong{display:block;font-size:2rem;margin-block-start:.5rem}.lms-metrics span,.lms-muted{font-size:.85rem;color:var(--text-color-kumo-subtle,#64748b)}.lms-actions,.lms-toolbar{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-block:.6rem 1rem}.lms-toolbar>.lms-field{min-width:160px;margin:0}.lms-button{display:inline-flex;justify-content:center;align-items:center;gap:.4rem;min-height:38px;padding:.5rem .8rem;border:1px solid var(--color-kumo-line,#cbd5e1);border-radius:.4rem;background:var(--color-kumo-control,#f8fafc);color:var(--text-color-kumo-default,#1e293b);font:inherit;font-size:.875rem;font-weight:600;text-decoration:none;cursor:pointer}.lms-button:hover{background:var(--color-kumo-interact,#e2e8f0)}.lms-button:disabled{opacity:.55;cursor:default}.lms-danger{color:var(--text-color-kumo-danger,#b91c1c)}.lms-field{display:grid;gap:.35rem;margin-block-end:1rem;min-width:0;font-size:.875rem;font-weight:600}.lms-field small{font-weight:400;color:var(--text-color-kumo-subtle,#64748b)}.ag-lms-admin input:not([type=checkbox]):not([type=radio]),.ag-lms-admin textarea,.ag-lms-admin select{width:100%;border:1px solid var(--color-kumo-line,#cbd5e1);border-radius:.35rem;background:var(--color-kumo-control,#fff);color:inherit;padding:.6rem;font:inherit;font-size:.875rem;font-weight:400}.ag-lms-admin input[type=checkbox],.ag-lms-admin input[type=radio]{width:1rem;height:1rem;accent-color:var(--color-kumo-brand,#2563eb)}.ag-lms-admin :focus-visible{outline:2px solid var(--color-kumo-focus,#2563eb);outline-offset:3px}.lms-check{display:flex;gap:.6rem;align-items:center;font-size:.9rem;margin-block:.7rem}.lms-notice{padding:.8rem 1rem;border:1px solid var(--color-kumo-line,#cbd5e1);border-radius:.4rem;background:var(--color-kumo-tint,#f1f5f9)}.lms-error{color:var(--text-color-kumo-danger,#b91c1c);border-color:currentColor}.lms-badge{font-size:.7rem;text-transform:uppercase;font-weight:700;border:1px solid var(--color-kumo-line,#cbd5e1);border-radius:1rem;padding:.2rem .6rem;margin-block-end:.6rem}.lms-studio{display:grid;grid-template-columns:330px minmax(0,1fr);gap:1.3rem;align-items:start}.lms-module{border-block-end:1px solid var(--color-kumo-line,#cbd5e1);padding-block:1rem}.lms-lesson-list{list-style:none;padding:0;margin:0}.lms-lesson-list li{display:flex;align-items:center;gap:.3rem}.lms-select-lesson{background:transparent;color:inherit;border:0;border-radius:.35rem;cursor:pointer;text-align:start;padding:.6rem;flex:1;font:inherit;font-size:.9rem}.lms-select-lesson[aria-current=true]{background:var(--color-kumo-control,#eff6ff);font-weight:600}.lms-select-lesson small{display:block;font-weight:400;opacity:.75}.lms-lesson-list .lms-actions{margin:0}.lms-option{display:flex;align-items:center;gap:.5rem;margin-block:.5rem}.lms-question{border-block-start:1px solid var(--color-kumo-line,#cbd5e1);padding-block:1rem}.lms-question fieldset{border:1px solid var(--color-kumo-line,#cbd5e1);border-radius:.4rem;margin-block:1rem;padding:1rem}.lms-resource{border-block-end:1px solid var(--color-kumo-line,#cbd5e1);padding-block:1rem}.lms-file{position:absolute;width:1px!important;height:1px;opacity:0}.lms-table-wrap{overflow:auto}.lms-table{width:100%;border-collapse:collapse;font-size:.875rem}.lms-table th,.lms-table td{padding:.7rem;text-align:start;border-block-end:1px solid var(--color-kumo-line,#e5e7eb);vertical-align:top}.lms-table th{font-weight:600}.lms-table small{display:block;color:var(--text-color-kumo-subtle,#64748b)}.lms-table .lms-actions{margin:0}.lms-body{white-space:pre-wrap;overflow-wrap:anywhere}.ag-lms-admin details{padding:.7rem;border:1px solid var(--color-kumo-line,#d1d5db);border-radius:.4rem;margin-block:1rem}.ag-lms-admin summary{cursor:pointer;font-weight:600}.lms-notice:empty{display:none}@media(max-width:900px){.lms-studio{grid-template-columns:1fr}.lms-page-header{align-items:start;flex-direction:column}}@media(max-width:600px){.lms-grid{grid-template-columns:1fr}.lms-toolbar{align-items:stretch}.lms-toolbar>.lms-field{width:100%}.lms-panel{padding:1rem}}`;
2759
+
2760
+ //#endregion
2761
+ export { AssignmentsPage, AuditPage, CohortsPage, CommunityPage, CoursesPage, LearnersPage, LearningWidget, NotificationsPage, OverviewPage, ReportsPage, SettingsPage, pages, widgets };
2762
+ //# sourceMappingURL=admin.js.map