@gentiq/ui 1.0.0-alpha.10 → 1.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,26 @@
1
1
  "use client";
2
2
  import { jsxs as r, jsx as e } from "react/jsx-runtime";
3
- import { useId as G, useState as p, useRef as q } from "react";
4
- import { Paperclip as F, X as B, Send as P } from "lucide-react";
3
+ import { useId as P, useState as p, useRef as q } from "react";
4
+ import { Paperclip as F, X as B, Send as G } from "lucide-react";
5
5
  import { toast as d } from "sonner";
6
- import { rejectAttachment as V } from "@gentiq/core";
7
- import { useGentiqTranslation as H, useGentiqLanguage as J, useServerConfig as K, useSubmitReport as O, getLocalizedErrorMessage as X } from "@gentiq/react";
8
- import { G as h, H as Q, I as U, J as W, c as l, K as Y, M as Z, N as M, B as x } from "./shared-BtZa4J_w.js";
9
- import { T as ee } from "./shared-BKh4GbRI.js";
10
- import { f as $ } from "./shared-DO5kF-Zj.js";
6
+ import { rejectAttachment as O } from "@gentiq/core";
7
+ import { useGentiqTranslation as V, useGentiqLanguage as J, useServerConfig as K, useSubmitReport as Q, getLocalizedErrorMessage as X } from "@gentiq/react";
8
+ import { J as h, K as H, M as U, N as W, c as l, O as Y, P as Z, Q as M, B as x } from "./shared-C6NokIol.js";
9
+ import { T as ee } from "./shared-BqghN38E.js";
10
+ import { f as $ } from "./shared-HOMT87-R.js";
11
11
  const te = ["bug", "feature", "other"], v = "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary text-start";
12
12
  function ue({
13
13
  sectionMode: N = "editable",
14
14
  categoryMode: b = "editable",
15
15
  attachmentMode: u = "editable"
16
16
  } = {}) {
17
- const s = G(), { t: a, i18n: k } = H(["settings", "errors"]), { dir: I } = J(), i = K()?.attachments, g = O(), [y, L] = p("bug"), [S, j] = p(""), [C, z] = p(""), [m, _] = p(null), f = q(null), n = N === "faded" || g.isPending, A = b !== "hidden", R = u !== "hidden" && !!i, w = () => {
17
+ const s = P(), { t: a, i18n: k } = V(["settings", "errors"]), { dir: L } = J(), i = K()?.attachments, g = Q(), [y, I] = p("bug"), [S, j] = p(""), [C, z] = p(""), [m, _] = p(null), f = q(null), n = N === "faded" || g.isPending, A = b !== "hidden", R = u !== "hidden" && !!i, w = () => {
18
18
  _(null), f.current && (f.current.value = "");
19
19
  }, T = (t) => {
20
20
  const c = t.target.files?.[0];
21
21
  if (c) {
22
22
  if (i) {
23
- const o = V(c, i);
23
+ const o = O(c, i);
24
24
  if (o === "too_large") {
25
25
  d.error(
26
26
  a("feedback.attachment_too_large", {
@@ -75,12 +75,12 @@ function ue({
75
75
  children: [
76
76
  /* @__PURE__ */ e(h, { htmlFor: `${s}-category`, className: "px-1 text-start", children: a("feedback.category") }),
77
77
  /* @__PURE__ */ r(
78
- Q,
78
+ H,
79
79
  {
80
80
  value: y,
81
- onValueChange: (t) => L(t),
81
+ onValueChange: (t) => I(t),
82
82
  disabled: n || b === "faded",
83
- dir: I,
83
+ dir: L,
84
84
  children: [
85
85
  /* @__PURE__ */ e(U, { id: `${s}-category`, className: l(v, "h-11"), children: /* @__PURE__ */ e(W, {}) }),
86
86
  /* @__PURE__ */ e(Y, { className: "rounded-xl border-border/40 shadow-xl bg-background", children: te.map((t) => /* @__PURE__ */ e(Z, { value: t, className: "rounded-lg focus:bg-primary/10", children: a(`feedback.categories.${t}`) }, t)) })
@@ -185,7 +185,7 @@ function ue({
185
185
  disabled: n,
186
186
  className: "w-full sm:w-auto px-6 rounded-full gap-2 font-medium h-10",
187
187
  children: [
188
- /* @__PURE__ */ e(P, { className: "size-4" }),
188
+ /* @__PURE__ */ e(G, { className: "size-4" }),
189
189
  a(g.isPending ? "feedback.submitting" : "feedback.submit")
190
190
  ]
191
191
  }
@@ -0,0 +1,574 @@
1
+ "use client";
2
+ import { jsx as e, jsxs as n, Fragment as ne } from "react/jsx-runtime";
3
+ import { useId as qe, useState as m, useMemo as $e } from "react";
4
+ import { ExternalLink as de, Plus as Te, Clock as De, Zap as Fe, Pause as Oe, Play as Ae, Pencil as Ie, History as Me, Trash2 as Le } from "lucide-react";
5
+ import { toast as g } from "sonner";
6
+ import { detectLocalTimezone as Pe, weekStart as We, createDateFormatter as X, describeSchedule as me, cronToPreset as Ee, presetToCron as ae, toLocalInput as ue } from "@gentiq/core";
7
+ import { useGentiqTranslation as G, useGentiqLanguage as Y, useScheduleActions as he, getLocalizedErrorMessage as W, useThreadSelection as pe, useScheduleRuns as je, useSchedules as Re, Schedules as B } from "@gentiq/react";
8
+ import { D as fe, e as ge, f as ye, g as ve, J as f, Q as P, K as se, M as ie, N as le, O as oe, P as S, c as xe, X as Ve, B as v, h as Q } from "./shared-C6NokIol.js";
9
+ import { S as U } from "./shared-opU08IAK.js";
10
+ import { u as be } from "./shared-HOMT87-R.js";
11
+ import { D as Be, C as Ue } from "./shared-C0zGnIf8.js";
12
+ import { T as Ge } from "./shared-BqghN38E.js";
13
+ function ce(i) {
14
+ return String(i).padStart(2, "0");
15
+ }
16
+ function F() {
17
+ return ue(new Date(Date.now() + 3600 * 1e3));
18
+ }
19
+ function He(i) {
20
+ if (!i) return "";
21
+ const t = new Date(i);
22
+ return Number.isNaN(t.getTime()) ? "" : ue(t);
23
+ }
24
+ function Ze(i) {
25
+ if (!i)
26
+ return {
27
+ frequency: "daily",
28
+ time: "09:00",
29
+ daysOfWeek: [1, 2, 3, 4, 5],
30
+ intervalMinutes: "60",
31
+ runAt: F(),
32
+ cron: "0 9 * * *"
33
+ };
34
+ if (i.kind === "once")
35
+ return {
36
+ frequency: "once",
37
+ time: "09:00",
38
+ daysOfWeek: [1, 2, 3, 4, 5],
39
+ intervalMinutes: "60",
40
+ runAt: He(i.run_at) || F(),
41
+ cron: i.cron ?? "0 9 * * *"
42
+ };
43
+ if (i.kind === "interval")
44
+ return {
45
+ frequency: "interval",
46
+ time: "09:00",
47
+ daysOfWeek: [1, 2, 3, 4, 5],
48
+ intervalMinutes: String(i.interval_minutes ?? 60),
49
+ runAt: F(),
50
+ cron: i.cron ?? "0 9 * * *"
51
+ };
52
+ const t = Ee(i.cron);
53
+ return t ? {
54
+ frequency: t.frequency,
55
+ time: `${ce(t.hour)}:${ce(t.minute)}`,
56
+ daysOfWeek: t.frequency === "weekly" ? t.daysOfWeek : [1, 2, 3, 4, 5],
57
+ intervalMinutes: "60",
58
+ runAt: F(),
59
+ cron: i.cron ?? "0 9 * * *"
60
+ } : {
61
+ frequency: "cron",
62
+ time: "09:00",
63
+ daysOfWeek: [1, 2, 3, 4, 5],
64
+ intervalMinutes: "60",
65
+ runAt: F(),
66
+ cron: i.cron ?? "0 9 * * *"
67
+ };
68
+ }
69
+ function Je({
70
+ schedule: i,
71
+ onClose: t
72
+ }) {
73
+ const l = qe(), { t: r, i18n: y } = G(["schedules", "errors"]), { dir: C } = Y(), { create: _, update: z } = he(), p = Ze(i), [w, O] = m(i?.name ?? ""), [q, o] = m(i?.prompt ?? ""), [u, E] = m(p.frequency), [A, j] = m(p.time), [x, $] = m(p.daysOfWeek), [b, H] = m(p.intervalMinutes), [T, Z] = m(p.runAt), [R, J] = m(p.cron), [V, s] = m(i?.timezone || Pe()), [k, I] = m(
74
+ i?.thread_mode ?? "shared"
75
+ ), [N, Ne] = m(i?.silent_if_empty ?? !1), c = _.isPending || z.isPending, [_e, we] = A.split(":"), ee = Number(_e ?? "9"), te = Number(we ?? "0"), ke = $e(() => {
76
+ const a = We(y.language), d = X(y.language, { weekday: "narrow", timeZone: "UTC" });
77
+ return Array.from({ length: 7 }, (h, D) => {
78
+ const L = (a + D) % 7;
79
+ let K = String(L);
80
+ try {
81
+ K = d.format(new Date(Date.UTC(2024, 0, 7 + L)));
82
+ } catch {
83
+ K = r(`days.${L}`).slice(0, 1);
84
+ }
85
+ return { dow: L, shortLabel: K, fullLabel: r(`days.${L}`) };
86
+ });
87
+ }, [y.language, r]), Se = (a) => {
88
+ $((d) => d.includes(a) ? d.length > 1 ? d.filter((h) => h !== a) : d : [...d, a].sort((h, D) => h - D));
89
+ }, re = () => {
90
+ const a = {
91
+ name: w.trim(),
92
+ prompt: q.trim(),
93
+ timezone: V.trim() || "UTC",
94
+ thread_mode: k,
95
+ silent_if_empty: N
96
+ };
97
+ if (u === "once") {
98
+ const h = T ? new Date(T).toISOString() : F();
99
+ return { ...a, kind: "once", run_at: h };
100
+ }
101
+ if (u === "interval") {
102
+ const h = Math.max(1, Number.parseInt(b || "60", 10) || 60);
103
+ return { ...a, kind: "interval", interval_minutes: h };
104
+ }
105
+ const d = u === "cron" ? R.trim() : u === "weekly" ? ae({ frequency: "weekly", hour: ee, minute: te, daysOfWeek: x }) : ae({ frequency: "daily", hour: ee, minute: te });
106
+ return { ...a, kind: "cron", cron: d };
107
+ }, M = re(), Ce = me(
108
+ {
109
+ kind: M.kind,
110
+ cron: M.cron ?? null,
111
+ interval_minutes: M.interval_minutes ?? null,
112
+ run_at: M.run_at ?? null,
113
+ timezone: M.timezone ?? "UTC"
114
+ },
115
+ r,
116
+ y.language
117
+ ), ze = async (a) => {
118
+ if (a.preventDefault(), c) return;
119
+ const d = re();
120
+ try {
121
+ i ? (await z.mutateAsync({ id: i.id, data: d }), g.success(r("updated"))) : (await _.mutateAsync(d), g.success(r("created"))), t();
122
+ } catch (h) {
123
+ g.error(W(h, r));
124
+ }
125
+ };
126
+ return /* @__PURE__ */ n("form", { onSubmit: (a) => {
127
+ ze(a);
128
+ }, className: "space-y-4", children: [
129
+ /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
130
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-name`, children: r("form.name") }),
131
+ /* @__PURE__ */ e(
132
+ P,
133
+ {
134
+ id: `${l}-name`,
135
+ value: w,
136
+ onChange: (a) => O(a.target.value),
137
+ placeholder: r("form.name_placeholder"),
138
+ required: !0,
139
+ disabled: c
140
+ }
141
+ )
142
+ ] }),
143
+ /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
144
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-prompt`, children: r("form.prompt") }),
145
+ /* @__PURE__ */ e(
146
+ Ge,
147
+ {
148
+ id: `${l}-prompt`,
149
+ value: q,
150
+ onChange: (a) => o(a.target.value),
151
+ placeholder: r("form.prompt_placeholder"),
152
+ rows: 3,
153
+ required: !0,
154
+ disabled: c
155
+ }
156
+ )
157
+ ] }),
158
+ /* @__PURE__ */ n("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
159
+ /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
160
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-freq`, children: r("form.frequency") }),
161
+ /* @__PURE__ */ n(
162
+ se,
163
+ {
164
+ dir: C,
165
+ value: u,
166
+ onValueChange: (a) => E(a),
167
+ disabled: c,
168
+ children: [
169
+ /* @__PURE__ */ e(ie, { id: `${l}-freq`, className: "w-full", children: /* @__PURE__ */ e(le, {}) }),
170
+ /* @__PURE__ */ n(oe, { children: [
171
+ /* @__PURE__ */ e(S, { value: "daily", children: r("form.freq_daily") }),
172
+ /* @__PURE__ */ e(S, { value: "weekly", children: r("form.freq_weekly") }),
173
+ /* @__PURE__ */ e(S, { value: "interval", children: r("form.freq_interval") }),
174
+ /* @__PURE__ */ e(S, { value: "once", children: r("form.freq_once") }),
175
+ /* @__PURE__ */ e(S, { value: "cron", children: r("form.freq_cron") })
176
+ ] })
177
+ ]
178
+ }
179
+ )
180
+ ] }),
181
+ (u === "daily" || u === "weekly") && /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
182
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-time`, children: r("form.time") }),
183
+ /* @__PURE__ */ e(
184
+ P,
185
+ {
186
+ id: `${l}-time`,
187
+ type: "time",
188
+ value: A,
189
+ onChange: (a) => j(a.target.value),
190
+ required: !0,
191
+ disabled: c
192
+ }
193
+ )
194
+ ] }),
195
+ u === "weekly" && /* @__PURE__ */ n("div", { className: "space-y-1.5 sm:col-span-2", children: [
196
+ /* @__PURE__ */ e(f, { children: r("form.days_of_week") }),
197
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-between gap-1.5 pt-0.5", role: "group", children: ke.map(({ dow: a, shortLabel: d, fullLabel: h }) => {
198
+ const D = x.includes(a);
199
+ return /* @__PURE__ */ e(
200
+ "button",
201
+ {
202
+ type: "button",
203
+ disabled: c,
204
+ "aria-pressed": D,
205
+ "aria-label": h,
206
+ title: h,
207
+ onClick: () => Se(a),
208
+ className: xe(
209
+ "flex size-9 items-center justify-center rounded-full text-xs font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
210
+ D ? "bg-primary text-primary-foreground shadow-sm" : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground"
211
+ ),
212
+ children: d
213
+ },
214
+ a
215
+ );
216
+ }) })
217
+ ] }),
218
+ u === "interval" && /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
219
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-interval`, children: r("form.interval_minutes") }),
220
+ /* @__PURE__ */ e(
221
+ P,
222
+ {
223
+ id: `${l}-interval`,
224
+ type: "number",
225
+ min: 1,
226
+ value: b,
227
+ onChange: (a) => H(a.target.value),
228
+ required: !0,
229
+ disabled: c
230
+ }
231
+ )
232
+ ] }),
233
+ u === "once" && /* @__PURE__ */ n("div", { className: "space-y-1.5 sm:col-span-2", children: [
234
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-run-at`, children: r("form.run_at") }),
235
+ /* @__PURE__ */ e(
236
+ Be,
237
+ {
238
+ id: `${l}-run-at`,
239
+ value: T,
240
+ onChange: Z,
241
+ disabled: c,
242
+ clearable: !1
243
+ }
244
+ )
245
+ ] }),
246
+ u === "cron" && /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
247
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-cron`, children: r("form.cron") }),
248
+ /* @__PURE__ */ e(
249
+ P,
250
+ {
251
+ id: `${l}-cron`,
252
+ dir: "ltr",
253
+ value: R,
254
+ onChange: (a) => J(a.target.value),
255
+ placeholder: r("form.cron_placeholder"),
256
+ required: !0,
257
+ disabled: c
258
+ }
259
+ )
260
+ ] })
261
+ ] }),
262
+ /* @__PURE__ */ n("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
263
+ /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
264
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-tz`, children: r("form.timezone") }),
265
+ /* @__PURE__ */ e(
266
+ P,
267
+ {
268
+ id: `${l}-tz`,
269
+ dir: "ltr",
270
+ value: V,
271
+ onChange: (a) => s(a.target.value),
272
+ placeholder: r("form.timezone_placeholder"),
273
+ required: !0,
274
+ disabled: c
275
+ }
276
+ )
277
+ ] }),
278
+ /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
279
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-thread-mode`, children: r("form.thread_mode") }),
280
+ /* @__PURE__ */ n(
281
+ se,
282
+ {
283
+ dir: C,
284
+ value: k,
285
+ onValueChange: (a) => I(a),
286
+ disabled: c,
287
+ children: [
288
+ /* @__PURE__ */ e(ie, { id: `${l}-thread-mode`, className: "w-full", children: /* @__PURE__ */ e(le, {}) }),
289
+ /* @__PURE__ */ n(oe, { children: [
290
+ /* @__PURE__ */ e(S, { value: "shared", children: r("form.thread_shared") }),
291
+ /* @__PURE__ */ e(S, { value: "new", children: r("form.thread_new") })
292
+ ] })
293
+ ]
294
+ }
295
+ )
296
+ ] })
297
+ ] }),
298
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2.5 pt-1", children: [
299
+ /* @__PURE__ */ e(
300
+ Ue,
301
+ {
302
+ id: `${l}-silent`,
303
+ checked: N,
304
+ onCheckedChange: (a) => Ne(a === !0),
305
+ disabled: c
306
+ }
307
+ ),
308
+ /* @__PURE__ */ e(f, { htmlFor: `${l}-silent`, className: "text-sm font-normal cursor-pointer", children: r("form.silent_if_empty") })
309
+ ] }),
310
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground rounded-lg bg-muted/40 px-3 py-2", children: Ce }),
311
+ /* @__PURE__ */ n(Ve, { children: [
312
+ /* @__PURE__ */ e(v, { type: "button", variant: "outline", onClick: t, disabled: c, children: r("form.cancel") }),
313
+ /* @__PURE__ */ e(v, { type: "submit", disabled: c, children: r(c ? "form.saving" : "form.save") })
314
+ ] })
315
+ ] });
316
+ }
317
+ function Ke({ open: i, onOpenChange: t, schedule: l }) {
318
+ const { t: r } = G("schedules"), { dir: y } = Y();
319
+ return /* @__PURE__ */ e(fe, { open: i, onOpenChange: t, children: /* @__PURE__ */ n(ge, { dir: y, className: "sm:max-w-[520px] max-h-[90dvh] overflow-y-auto", children: [
320
+ /* @__PURE__ */ e(ye, { children: /* @__PURE__ */ e(ve, { children: r(l ? "edit_schedule" : "new_schedule") }) }),
321
+ /* @__PURE__ */ e(
322
+ Je,
323
+ {
324
+ schedule: l,
325
+ onClose: () => t(!1)
326
+ },
327
+ `${i ? "open" : "closed"}-${l?.id ?? "new"}`
328
+ )
329
+ ] }) });
330
+ }
331
+ function Qe({ open: i, onOpenChange: t, schedule: l }) {
332
+ const { t: r, i18n: y } = G("schedules"), { dir: C } = Y(), _ = pe(), z = be(), { data: p, isLoading: w } = je(l?.id ?? "", {
333
+ enabled: i && !!l?.id
334
+ }), O = X(y.language, {
335
+ dateStyle: "medium",
336
+ timeStyle: "short"
337
+ }), q = (o) => {
338
+ _?.selectThread(o), t(!1), z?.close();
339
+ };
340
+ return /* @__PURE__ */ e(fe, { open: i, onOpenChange: t, children: /* @__PURE__ */ n(ge, { dir: C, className: "sm:max-w-[560px]", children: [
341
+ /* @__PURE__ */ e(ye, { children: /* @__PURE__ */ e(ve, { children: r("runs_dialog.title", { name: l?.name ?? "" }) }) }),
342
+ /* @__PURE__ */ e("div", { className: "max-h-[60vh] overflow-y-auto space-y-2.5 pe-1", children: w ? /* @__PURE__ */ n("div", { className: "space-y-2", children: [
343
+ /* @__PURE__ */ e(U, { className: "h-16 w-full rounded-xl" }),
344
+ /* @__PURE__ */ e(U, { className: "h-16 w-full rounded-xl" })
345
+ ] }) : p?.runs.length ? p.runs.map((o) => /* @__PURE__ */ n(
346
+ "div",
347
+ {
348
+ className: "rounded-xl border border-border/50 bg-muted/20 p-3 space-y-1.5",
349
+ children: [
350
+ /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-2 flex-wrap", children: [
351
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
352
+ /* @__PURE__ */ e(
353
+ Q,
354
+ {
355
+ variant: o.status === "failed" || o.status === "timeout" ? "destructive" : o.status === "completed" ? "secondary" : "outline",
356
+ children: r(`runs_dialog.status_${o.status}`)
357
+ }
358
+ ),
359
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: r(`runs_dialog.trigger_${o.trigger}`) })
360
+ ] }),
361
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground tabular-nums", children: O.format(new Date(o.started_at)) })
362
+ ] }),
363
+ o.summary && /* @__PURE__ */ e("p", { className: "text-xs text-foreground line-clamp-2", children: o.summary }),
364
+ o.error && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: o.error }),
365
+ o.thread_id && _ && /* @__PURE__ */ e("div", { className: "pt-1", children: /* @__PURE__ */ n(
366
+ v,
367
+ {
368
+ type: "button",
369
+ size: "sm",
370
+ variant: "ghost",
371
+ className: "h-7 px-2 text-xs gap-1.5",
372
+ onClick: () => q(o.thread_id),
373
+ children: [
374
+ /* @__PURE__ */ e(de, { className: "size-3.5" }),
375
+ r("open_thread")
376
+ ]
377
+ }
378
+ ) })
379
+ ]
380
+ },
381
+ o.id
382
+ )) : /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground py-6 text-center", children: r("runs_dialog.empty") }) })
383
+ ] }) });
384
+ }
385
+ function ct({ sectionMode: i = "editable" } = {}) {
386
+ const { t, i18n: l } = G(["schedules", "errors"]), { data: r, isLoading: y } = Re(), { pause: C, resume: _, runNow: z, remove: p } = he(), w = pe(), O = be(), [q, o] = m(!1), [u, E] = m(null), [A, j] = m(null), x = i === "faded", $ = r?.schedules ?? [], b = r?.max_schedules, H = typeof b == "number" && b > 0 && $.length >= b, T = X(l.language, {
387
+ dateStyle: "medium",
388
+ timeStyle: "short"
389
+ }), Z = () => {
390
+ E(null), o(!0);
391
+ }, R = (s) => {
392
+ E(s), o(!0);
393
+ }, J = async (s) => {
394
+ if (window.confirm(t("delete_confirm")))
395
+ try {
396
+ await p.mutateAsync(s.id), g.success(t("deleted"));
397
+ } catch (k) {
398
+ g.error(W(k, t));
399
+ }
400
+ }, V = (s) => {
401
+ w?.selectThread(s), O?.close();
402
+ };
403
+ return /* @__PURE__ */ n("div", { className: xe("space-y-5", x && "opacity-50 pointer-events-none"), children: [
404
+ /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
405
+ typeof b == "number" && b > 0 && /* @__PURE__ */ e(Q, { variant: "outline", className: "tabular-nums", children: t("limit_badge", { count: $.length, max: b }) }),
406
+ /* @__PURE__ */ n(
407
+ v,
408
+ {
409
+ type: "button",
410
+ size: "sm",
411
+ onClick: Z,
412
+ disabled: x || H,
413
+ className: "ms-auto rounded-full gap-1.5",
414
+ children: [
415
+ /* @__PURE__ */ e(Te, { className: "size-4" }),
416
+ t("new_schedule")
417
+ ]
418
+ }
419
+ )
420
+ ] }),
421
+ y ? /* @__PURE__ */ n("div", { className: "space-y-3", children: [
422
+ /* @__PURE__ */ e(U, { className: "h-24 w-full rounded-2xl" }),
423
+ /* @__PURE__ */ e(U, { className: "h-24 w-full rounded-2xl" })
424
+ ] }) : $.length ? /* @__PURE__ */ e(B.Root, { className: "space-y-3", children: $.map((s) => {
425
+ const k = s.last_run_thread_id || s.thread_id;
426
+ return /* @__PURE__ */ n(
427
+ B.Item,
428
+ {
429
+ schedule: s,
430
+ className: "rounded-2xl border border-border/50 bg-muted/20 p-4 space-y-3",
431
+ children: [
432
+ /* @__PURE__ */ e("div", { className: "flex items-start justify-between gap-3", children: /* @__PURE__ */ n("div", { className: "min-w-0 space-y-1", children: [
433
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2 flex-wrap", children: [
434
+ /* @__PURE__ */ e("span", { className: "font-medium text-sm text-foreground", children: s.name }),
435
+ /* @__PURE__ */ e(Q, { variant: s.enabled ? "secondary" : "outline", children: s.enabled ? t("status_active") : s.pause_reason ? t(`pause_reason_${s.pause_reason}`) : t("status_paused") })
436
+ ] }),
437
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground line-clamp-2", children: s.prompt })
438
+ ] }) }),
439
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [
440
+ /* @__PURE__ */ e("span", { children: me(s, t, l.language) }),
441
+ s.next_run_at && s.enabled && /* @__PURE__ */ e("span", { children: t("next_run", { datetime: T.format(new Date(s.next_run_at)) }) }),
442
+ s.last_run_at && /* @__PURE__ */ e("span", { children: t("last_run", { datetime: T.format(new Date(s.last_run_at)) }) })
443
+ ] }),
444
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-1.5 pt-1 border-t border-border/30", children: [
445
+ /* @__PURE__ */ e(B.RunNow, { asChild: !0, children: /* @__PURE__ */ n(
446
+ v,
447
+ {
448
+ type: "button",
449
+ size: "sm",
450
+ variant: "outline",
451
+ className: "h-8 gap-1.5 text-xs",
452
+ disabled: x,
453
+ onClick: (I) => {
454
+ I.preventDefault(), z.mutate(s.id, {
455
+ onSuccess: () => g.success(t("triggered")),
456
+ onError: (N) => g.error(W(N, t))
457
+ });
458
+ },
459
+ children: [
460
+ /* @__PURE__ */ e(Fe, { className: "size-3.5" }),
461
+ t("run_now")
462
+ ]
463
+ }
464
+ ) }),
465
+ /* @__PURE__ */ e(B.Toggle, { asChild: !0, children: /* @__PURE__ */ e(
466
+ v,
467
+ {
468
+ type: "button",
469
+ size: "sm",
470
+ variant: "outline",
471
+ className: "h-8 gap-1.5 text-xs",
472
+ disabled: x,
473
+ onClick: (I) => {
474
+ I.preventDefault(), s.enabled ? C.mutate(s.id, {
475
+ onSuccess: () => g.success(t("paused_toast")),
476
+ onError: (N) => g.error(W(N, t))
477
+ }) : _.mutate(s.id, {
478
+ onSuccess: () => g.success(t("resumed_toast")),
479
+ onError: (N) => g.error(W(N, t))
480
+ });
481
+ },
482
+ children: s.enabled ? /* @__PURE__ */ n(ne, { children: [
483
+ /* @__PURE__ */ e(Oe, { className: "size-3.5" }),
484
+ t("pause")
485
+ ] }) : /* @__PURE__ */ n(ne, { children: [
486
+ /* @__PURE__ */ e(Ae, { className: "size-3.5" }),
487
+ t("resume")
488
+ ] })
489
+ }
490
+ ) }),
491
+ /* @__PURE__ */ n(
492
+ v,
493
+ {
494
+ type: "button",
495
+ size: "sm",
496
+ variant: "ghost",
497
+ className: "h-8 gap-1.5 text-xs",
498
+ disabled: x,
499
+ onClick: () => R(s),
500
+ children: [
501
+ /* @__PURE__ */ e(Ie, { className: "size-3.5" }),
502
+ t("edit")
503
+ ]
504
+ }
505
+ ),
506
+ /* @__PURE__ */ n(
507
+ v,
508
+ {
509
+ type: "button",
510
+ size: "sm",
511
+ variant: "ghost",
512
+ className: "h-8 gap-1.5 text-xs",
513
+ onClick: () => j(s),
514
+ children: [
515
+ /* @__PURE__ */ e(Me, { className: "size-3.5" }),
516
+ t("runs")
517
+ ]
518
+ }
519
+ ),
520
+ k && w && /* @__PURE__ */ n(
521
+ v,
522
+ {
523
+ type: "button",
524
+ size: "sm",
525
+ variant: "ghost",
526
+ className: "h-8 gap-1.5 text-xs",
527
+ onClick: () => V(k),
528
+ children: [
529
+ /* @__PURE__ */ e(de, { className: "size-3.5" }),
530
+ t("open_thread")
531
+ ]
532
+ }
533
+ ),
534
+ /* @__PURE__ */ e(
535
+ v,
536
+ {
537
+ type: "button",
538
+ size: "sm",
539
+ variant: "ghost",
540
+ className: "h-8 gap-1.5 text-xs text-destructive hover:text-destructive ms-auto",
541
+ disabled: x || p.isPending,
542
+ onClick: () => {
543
+ J(s);
544
+ },
545
+ "aria-label": t("delete"),
546
+ children: /* @__PURE__ */ e(Le, { className: "size-3.5" })
547
+ }
548
+ )
549
+ ] })
550
+ ]
551
+ },
552
+ s.id
553
+ );
554
+ }) }) : /* @__PURE__ */ n("div", { className: "rounded-2xl border border-dashed border-border/60 p-8 text-center space-y-2", children: [
555
+ /* @__PURE__ */ e(De, { className: "size-8 mx-auto text-muted-foreground/60", "aria-hidden": !0 }),
556
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: t("empty") }),
557
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: t("empty_help") })
558
+ ] }),
559
+ /* @__PURE__ */ e(Ke, { open: q, onOpenChange: o, schedule: u }),
560
+ /* @__PURE__ */ e(
561
+ Qe,
562
+ {
563
+ open: !!A,
564
+ onOpenChange: (s) => {
565
+ s || j(null);
566
+ },
567
+ schedule: A
568
+ }
569
+ )
570
+ ] });
571
+ }
572
+ export {
573
+ ct as SchedulesSettings
574
+ };
@@ -3,8 +3,8 @@ import { jsxs as z, jsx as e, Fragment as k } from "react/jsx-runtime";
3
3
  import { useState as L, useRef as P, useEffect as U } from "react";
4
4
  import { XIcon as X, Loader2Icon as V, SquareIcon as J } from "lucide-react";
5
5
  import { useGentiqTranslation as q, useComposerVoice as y, Composer as S, useComposer as K } from "@gentiq/react";
6
- import { P as H, a as O } from "./shared-DO5kF-Zj.js";
7
- import { c as Q } from "./shared-BtZa4J_w.js";
6
+ import { P as H, a as O } from "./shared-HOMT87-R.js";
7
+ import { c as Q } from "./shared-C6NokIol.js";
8
8
  function ce() {
9
9
  const { t: n } = q("chat"), i = y(), c = i.status === "transcribing";
10
10
  return /* @__PURE__ */ z("div", { className: "flex min-h-[40px] min-w-0 flex-1 items-center gap-2 md:min-h-[44px]", children: [