@alfadocs/ui-kit-debug 1.46.0 → 1.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/booking-C4MwImkS.js +3362 -0
- package/dist/_chunks/booking-C4MwImkS.js.map +1 -0
- package/dist/_chunks/calendar-workspace-BmscntRR.js +12528 -0
- package/dist/_chunks/calendar-workspace-BmscntRR.js.map +1 -0
- package/dist/_chunks/control-room-rail-CdBOXIqX.js +366 -0
- package/dist/_chunks/control-room-rail-CdBOXIqX.js.map +1 -0
- package/dist/_chunks/{freemium-paywall-Cz-O9lQD.js → freemium-paywall-BaW5ODc9.js} +2 -2
- package/dist/_chunks/{freemium-paywall-Cz-O9lQD.js.map → freemium-paywall-BaW5ODc9.js.map} +1 -1
- package/dist/_chunks/{patient-details-DUj1htsH.js → patient-details-yrgkSeEY.js} +2 -2
- package/dist/_chunks/{patient-details-DUj1htsH.js.map → patient-details-yrgkSeEY.js.map} +1 -1
- package/dist/_chunks/{patient-field-row-CO0WR7yA.js → patient-field-row-DCMkFGqI.js} +2 -2
- package/dist/_chunks/{patient-field-row-CO0WR7yA.js.map → patient-field-row-DCMkFGqI.js.map} +1 -1
- package/dist/_chunks/{patient-summary-card-DNzdYjxE.js → patient-summary-card-CmEFflGS.js} +2 -2
- package/dist/_chunks/{patient-summary-card-DNzdYjxE.js.map → patient-summary-card-CmEFflGS.js.map} +1 -1
- package/dist/_chunks/payment-form-DqJFiplX.js +881 -0
- package/dist/_chunks/payment-form-DqJFiplX.js.map +1 -0
- package/dist/_chunks/{phone-input-BsZIoE36.js → phone-input-IWrGOCwm.js} +40 -39
- package/dist/_chunks/{phone-input-BsZIoE36.js.map → phone-input-IWrGOCwm.js.map} +1 -1
- package/dist/_chunks/{stepper-accordion-DmVykr5F.js → stepper-accordion-jMR8NaOB.js} +2 -1
- package/dist/_chunks/{stepper-accordion-DmVykr5F.js.map → stepper-accordion-jMR8NaOB.js.map} +1 -1
- package/dist/agent-catalog.json +5 -4
- package/dist/agent-i18n/en.json +2 -2
- package/dist/components/booking/booking-types.d.ts +60 -1
- package/dist/components/booking/booking-types.d.ts.map +1 -1
- package/dist/components/booking/booking.agent.d.ts.map +1 -1
- package/dist/components/booking/booking.d.ts +1 -1
- package/dist/components/booking/booking.d.ts.map +1 -1
- package/dist/components/booking/details-form.d.ts +5 -1
- package/dist/components/booking/details-form.d.ts.map +1 -1
- package/dist/components/booking/index.d.ts +1 -1
- package/dist/components/booking/index.d.ts.map +1 -1
- package/dist/components/booking/index.js +1 -1
- package/dist/components/booking/payment.d.ts +9 -0
- package/dist/components/booking/payment.d.ts.map +1 -0
- package/dist/components/booking/use-booking-payment.d.ts +14 -0
- package/dist/components/booking/use-booking-payment.d.ts.map +1 -0
- package/dist/components/control-room-rail/control-room-rail.d.ts +9 -2
- package/dist/components/control-room-rail/control-room-rail.d.ts.map +1 -1
- package/dist/components/control-room-rail/index.d.ts +1 -1
- package/dist/components/control-room-rail/index.d.ts.map +1 -1
- package/dist/components/control-room-rail/index.js +1 -1
- package/dist/components/freemium-paywall/index.js +1 -1
- package/dist/components/patient-details/index.js +1 -1
- package/dist/components/patient-summary-card/index.js +1 -1
- package/dist/components/payment-form/index.d.ts +1 -1
- package/dist/components/payment-form/index.d.ts.map +1 -1
- package/dist/components/payment-form/index.js +1 -1
- package/dist/components/payment-form/payment-form.d.ts +35 -3
- package/dist/components/payment-form/payment-form.d.ts.map +1 -1
- package/dist/components/phone-input/index.js +1 -1
- package/dist/components/phone-input/phone-input.d.ts.map +1 -1
- package/dist/components/stepper-accordion/index.js +1 -1
- package/dist/components/stepper-accordion/stepper-accordion.d.ts.map +1 -1
- package/dist/i18n/locales/ar.d.ts +36 -1
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +36 -1
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +36 -1
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +36 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +36 -1
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +36 -1
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +36 -1
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +36 -1
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +36 -1
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +36 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +36 -1
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +36 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +36 -1
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +36 -1
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +36 -1
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +36 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +36 -1
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +36 -1
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +36 -1
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +36 -1
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +36 -1
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +36 -1
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +36 -1
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +36 -1
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +36 -1
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +36 -1
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +36 -1
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +36 -1
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +36 -1
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +36 -1
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +36 -1
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +36 -1
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +36 -1
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +36 -1
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +36 -1
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +36 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +9 -9
- package/dist/locales/ar.json +36 -1
- package/dist/locales/de.json +36 -1
- package/dist/locales/el.json +36 -1
- package/dist/locales/en.json +36 -1
- package/dist/locales/es.json +36 -1
- package/dist/locales/fr.json +36 -1
- package/dist/locales/hi.json +36 -1
- package/dist/locales/it.json +36 -1
- package/dist/locales/ja.json +36 -1
- package/dist/locales/nl.json +36 -1
- package/dist/locales/pl.json +36 -1
- package/dist/locales/pt.json +36 -1
- package/dist/locales/ro.json +36 -1
- package/dist/locales/ru.json +36 -1
- package/dist/locales/sq.json +36 -1
- package/dist/locales/sv.json +36 -1
- package/dist/locales/tr.json +36 -1
- package/dist/locales/zh.json +36 -1
- package/dist/patterns/calendar/calendar-bookings-panel.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar-editor-fields.d.ts +33 -0
- package/dist/patterns/calendar/calendar-editor-fields.d.ts.map +1 -0
- package/dist/patterns/calendar/calendar-sticky-offset.d.ts +20 -0
- package/dist/patterns/calendar/calendar-sticky-offset.d.ts.map +1 -0
- package/dist/patterns/calendar/calendar-task-editor.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar-workspace.d.ts +88 -0
- package/dist/patterns/calendar/calendar-workspace.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.data.d.ts +17 -0
- package/dist/patterns/calendar/calendar.data.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.journey.d.ts +2 -0
- package/dist/patterns/calendar/calendar.journey.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.sheets.d.ts +2 -0
- package/dist/patterns/calendar/calendar.sheets.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.surface.d.ts +6 -1
- package/dist/patterns/calendar/calendar.surface.d.ts.map +1 -1
- package/dist/patterns/calendar/calendar.types.d.ts +24 -10
- package/dist/patterns/calendar/calendar.types.d.ts.map +1 -1
- package/dist/patterns/calendar/index.d.ts +1 -1
- package/dist/patterns/calendar/index.d.ts.map +1 -1
- package/dist/patterns/calendar/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/booking-B7gA9gFB.js +0 -3017
- package/dist/_chunks/booking-B7gA9gFB.js.map +0 -1
- package/dist/_chunks/calendar-workspace-BB-BZT7W.js +0 -12251
- package/dist/_chunks/calendar-workspace-BB-BZT7W.js.map +0 -1
- package/dist/_chunks/control-room-rail-Cv7GpMqX.js +0 -354
- package/dist/_chunks/control-room-rail-Cv7GpMqX.js.map +0 -1
- package/dist/_chunks/payment-form-BHMDqW9C.js +0 -767
- package/dist/_chunks/payment-form-BHMDqW9C.js.map +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { jsx as A, jsxs as Y, Fragment as Ro } from "react/jsx-runtime";
|
|
2
|
+
import { useState as X, useCallback as b, useMemo as w, useRef as $, useContext as O, useId as vo, useEffect as To, createContext as bo, forwardRef as Co } from "react";
|
|
3
|
+
import { useTranslation as ho } from "react-i18next";
|
|
4
|
+
import { I as Z } from "./icon-button-CehAeZoP.js";
|
|
5
|
+
import { a as xo } from "./panel-header-D_mTdhUp.js";
|
|
6
|
+
import { T as yo } from "./tool-rail-CCFqDfAn.js";
|
|
7
|
+
import { u as W } from "./use-persistent-state-nZwZAnE9.js";
|
|
8
|
+
import { S as Ao } from "./star-Bf9L2Uot.js";
|
|
9
|
+
import { X as wo } from "./x-B5YnXwCz.js";
|
|
10
|
+
const So = {
|
|
11
|
+
id: "control-room-rail",
|
|
12
|
+
capabilities: ["open", "close", "select_single"],
|
|
13
|
+
state: {
|
|
14
|
+
activeToolId: {
|
|
15
|
+
type: "string | null",
|
|
16
|
+
descriptionKey: "ui.toolRail.agent.state.activeToolId",
|
|
17
|
+
description: "Id of the tool whose panel is currently open, or null when the rail is collapsed to its strip. No panel content is ever exposed.",
|
|
18
|
+
read: (t) => t.getActiveToolId()
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
actions: {
|
|
22
|
+
open: {
|
|
23
|
+
// Pure ephemeral panel state (open) — no data loss, no external effect.
|
|
24
|
+
safety: "read",
|
|
25
|
+
argsType: "{ id: string }",
|
|
26
|
+
argsSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: { id: { type: "string" } },
|
|
29
|
+
required: ["id"]
|
|
30
|
+
},
|
|
31
|
+
idempotent: !0,
|
|
32
|
+
descriptionKey: "ui.toolRail.agent.actions.open",
|
|
33
|
+
description: "Open the given tool's panel.",
|
|
34
|
+
examples: [{ args: { id: "inbox" }, note: "Open the inbox tool panel." }],
|
|
35
|
+
invoke: (t, s) => {
|
|
36
|
+
t.open(s.id);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
close: {
|
|
40
|
+
safety: "read",
|
|
41
|
+
idempotent: !0,
|
|
42
|
+
descriptionKey: "ui.toolRail.agent.actions.close",
|
|
43
|
+
description: "Collapse the rail to its strip (no active tool).",
|
|
44
|
+
invoke: (t) => {
|
|
45
|
+
t.close();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
select_tool: {
|
|
49
|
+
safety: "read",
|
|
50
|
+
argsType: "{ id: string | null }",
|
|
51
|
+
argsSchema: {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: { id: { type: ["string", "null"] } },
|
|
54
|
+
required: ["id"]
|
|
55
|
+
},
|
|
56
|
+
idempotent: !0,
|
|
57
|
+
descriptionKey: "ui.toolRail.agent.actions.selectTool",
|
|
58
|
+
description: "Set the active tool by id (opens its panel), or pass null to collapse.",
|
|
59
|
+
invoke: (t, s) => {
|
|
60
|
+
t.setActiveTool(s.id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
domHooks: {
|
|
65
|
+
root: {
|
|
66
|
+
attr: "data-component",
|
|
67
|
+
value: "control-room-rail",
|
|
68
|
+
description: "Marks the ControlRoomRail wrapper."
|
|
69
|
+
},
|
|
70
|
+
instanceId: {
|
|
71
|
+
attr: "data-component-id",
|
|
72
|
+
sourceProp: "id",
|
|
73
|
+
description: "Sourced from the id prop. Required to address a specific rail from the agent."
|
|
74
|
+
},
|
|
75
|
+
item: {
|
|
76
|
+
attr: "data-tool-id",
|
|
77
|
+
description: "Stable tool id emitted on each strip IconButton. The active icon also carries data-active set to its id."
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, H = bo(null);
|
|
81
|
+
function Xo({
|
|
82
|
+
globalTools: t = [],
|
|
83
|
+
children: s
|
|
84
|
+
}) {
|
|
85
|
+
const [l, n] = X(
|
|
86
|
+
() => /* @__PURE__ */ new Map()
|
|
87
|
+
), f = b(
|
|
88
|
+
(i, a) => {
|
|
89
|
+
n((R) => {
|
|
90
|
+
const q = new Map(R);
|
|
91
|
+
return q.set(i, a), q;
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
[]
|
|
95
|
+
), x = b((i) => {
|
|
96
|
+
n((a) => {
|
|
97
|
+
if (!a.has(i)) return a;
|
|
98
|
+
const R = new Map(a);
|
|
99
|
+
return R.delete(i), R;
|
|
100
|
+
});
|
|
101
|
+
}, []), c = w(
|
|
102
|
+
() => Array.from(l.values()).flat(),
|
|
103
|
+
[l]
|
|
104
|
+
), p = $(null), y = b((i) => {
|
|
105
|
+
p.current = i;
|
|
106
|
+
}, []), d = b((i) => {
|
|
107
|
+
var a;
|
|
108
|
+
(a = p.current) == null || a.setActiveTool(i);
|
|
109
|
+
}, []), m = b(() => {
|
|
110
|
+
var i;
|
|
111
|
+
(i = p.current) == null || i.setActiveTool(null);
|
|
112
|
+
}, []), g = w(
|
|
113
|
+
() => ({
|
|
114
|
+
globalTools: t,
|
|
115
|
+
contextualTools: c,
|
|
116
|
+
registerContextualTools: f,
|
|
117
|
+
unregisterContextualTools: x,
|
|
118
|
+
registerRail: y,
|
|
119
|
+
openTool: d,
|
|
120
|
+
closeTool: m
|
|
121
|
+
}),
|
|
122
|
+
[
|
|
123
|
+
t,
|
|
124
|
+
c,
|
|
125
|
+
f,
|
|
126
|
+
x,
|
|
127
|
+
y,
|
|
128
|
+
d,
|
|
129
|
+
m
|
|
130
|
+
]
|
|
131
|
+
);
|
|
132
|
+
return /* @__PURE__ */ A(H.Provider, { value: g, children: s });
|
|
133
|
+
}
|
|
134
|
+
function $o(t) {
|
|
135
|
+
const s = O(H), l = s == null ? void 0 : s.registerContextualTools, n = s == null ? void 0 : s.unregisterContextualTools, f = vo();
|
|
136
|
+
To(() => {
|
|
137
|
+
if (!(!l || !n))
|
|
138
|
+
return l(f, t), () => n(f);
|
|
139
|
+
}, [l, n, f, t]);
|
|
140
|
+
}
|
|
141
|
+
function ko() {
|
|
142
|
+
const t = O(H);
|
|
143
|
+
return w(() => {
|
|
144
|
+
if (!t) return [];
|
|
145
|
+
const s = t.contextualTools.map((n) => ({
|
|
146
|
+
...n,
|
|
147
|
+
scope: "contextual"
|
|
148
|
+
})), l = t.globalTools.map((n) => ({
|
|
149
|
+
...n,
|
|
150
|
+
scope: "global"
|
|
151
|
+
}));
|
|
152
|
+
return [...s, ...l];
|
|
153
|
+
}, [t]);
|
|
154
|
+
}
|
|
155
|
+
function Do() {
|
|
156
|
+
const t = O(H), s = b(() => {
|
|
157
|
+
}, []);
|
|
158
|
+
return {
|
|
159
|
+
openTool: (t == null ? void 0 : t.openTool) ?? s,
|
|
160
|
+
closeTool: (t == null ? void 0 : t.closeTool) ?? s
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function Mo() {
|
|
164
|
+
const t = O(H), s = b((l) => {
|
|
165
|
+
}, []);
|
|
166
|
+
return (t == null ? void 0 : t.registerRail) ?? s;
|
|
167
|
+
}
|
|
168
|
+
function Vo(t, s, l, n) {
|
|
169
|
+
const f = s.includes(t), x = l.includes(t);
|
|
170
|
+
if (!f && x) return { toolId: t, action: "pin" };
|
|
171
|
+
if (f && !x)
|
|
172
|
+
return n != null && n.includes(t) ? void 0 : { toolId: t, action: "unpin" };
|
|
173
|
+
const c = (m) => n != null && n.length ? [...n, ...m.filter((g) => !n.includes(g))] : m, p = c(s), y = c(l);
|
|
174
|
+
return p.length !== y.length || p.some((m, g) => y[g] !== m) ? { toolId: t, action: "reorder" } : void 0;
|
|
175
|
+
}
|
|
176
|
+
const Go = Co(function({
|
|
177
|
+
tools: s,
|
|
178
|
+
railLabel: l,
|
|
179
|
+
reorderable: n = !0,
|
|
180
|
+
favoriteIds: f,
|
|
181
|
+
defaultFavoriteIds: x,
|
|
182
|
+
pinnedFavoriteIds: c,
|
|
183
|
+
onFavoriteIdsChange: p,
|
|
184
|
+
persistFavoritesKey: y = "ui.controlRoom.favorites",
|
|
185
|
+
activeToolId: d,
|
|
186
|
+
defaultActiveToolId: m = null,
|
|
187
|
+
onActiveToolChange: g,
|
|
188
|
+
panelWidth: i,
|
|
189
|
+
onPanelWidthChange: a,
|
|
190
|
+
persistPanelWidthKey: R,
|
|
191
|
+
...q
|
|
192
|
+
}, M) {
|
|
193
|
+
const { t: C } = ho(), [F, P] = X(
|
|
194
|
+
d ?? m ?? null
|
|
195
|
+
), D = d !== void 0 ? d : F, I = b(
|
|
196
|
+
(o) => {
|
|
197
|
+
d === void 0 && P(o), g == null || g(o);
|
|
198
|
+
},
|
|
199
|
+
[d, g]
|
|
200
|
+
), oo = ko(), S = s ?? oo, _ = f !== void 0, [to, eo] = W(
|
|
201
|
+
y,
|
|
202
|
+
() => x ?? S.filter((o) => o.scope === "global").map((o) => o.id),
|
|
203
|
+
{ disabled: _ }
|
|
204
|
+
), B = _ ? f : to, V = w(() => c != null && c.length ? [
|
|
205
|
+
...c,
|
|
206
|
+
...B.filter((o) => !c.includes(o))
|
|
207
|
+
] : B, [c, B]), z = i !== void 0, [no, G] = W(R ?? "ui.controlRoom.panelWidth.unused", null, {
|
|
208
|
+
disabled: z || !R
|
|
209
|
+
}), so = z ? i : R ? no : void 0, ro = b(
|
|
210
|
+
(o) => {
|
|
211
|
+
!z && R && G(o), a == null || a(o);
|
|
212
|
+
},
|
|
213
|
+
[
|
|
214
|
+
z,
|
|
215
|
+
R,
|
|
216
|
+
G,
|
|
217
|
+
a
|
|
218
|
+
]
|
|
219
|
+
), v = w(() => {
|
|
220
|
+
const o = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const r of S) o.set(r.id, r);
|
|
222
|
+
return o;
|
|
223
|
+
}, [S]), j = w(
|
|
224
|
+
() => new Set(V.filter((o) => v.has(o))),
|
|
225
|
+
[V, v]
|
|
226
|
+
), J = (o, r) => {
|
|
227
|
+
const e = V.filter((T) => v.has(T)), u = r(e);
|
|
228
|
+
_ || eo((T) => r(T.filter((k) => v.has(k)))), p == null || p(
|
|
229
|
+
u,
|
|
230
|
+
Vo(o, e, u, c)
|
|
231
|
+
);
|
|
232
|
+
}, K = w(() => {
|
|
233
|
+
if (!n) return S;
|
|
234
|
+
const o = V.filter((e) => v.has(e)).map((e) => ({
|
|
235
|
+
...v.get(e),
|
|
236
|
+
scope: "global",
|
|
237
|
+
reorderable: !0
|
|
238
|
+
})), r = S.filter((e) => !j.has(e.id)).map((e) => ({
|
|
239
|
+
...e,
|
|
240
|
+
scope: "contextual",
|
|
241
|
+
reorderable: !0
|
|
242
|
+
}));
|
|
243
|
+
return [...o, ...r];
|
|
244
|
+
}, [n, S, V, v, j]), [lo, io] = X(""), L = $(!1), co = (o, r) => {
|
|
245
|
+
const e = r ? C("controlRoom.pinnedAnnounce", {
|
|
246
|
+
tool: o,
|
|
247
|
+
defaultValue: "Pinned {{tool}} to favourites"
|
|
248
|
+
}) : C("controlRoom.unpinnedAnnounce", {
|
|
249
|
+
tool: o,
|
|
250
|
+
defaultValue: "Removed {{tool}} from favourites"
|
|
251
|
+
});
|
|
252
|
+
L.current = !L.current, io(L.current ? e : `${e}`);
|
|
253
|
+
}, ao = (o) => {
|
|
254
|
+
var r;
|
|
255
|
+
co(((r = v.get(o)) == null ? void 0 : r.label) ?? o, !j.has(o)), J(
|
|
256
|
+
o,
|
|
257
|
+
(e) => e.includes(o) ? e.filter((u) => u !== o) : [...e, o]
|
|
258
|
+
);
|
|
259
|
+
}, uo = (o, r) => {
|
|
260
|
+
var u;
|
|
261
|
+
const e = (u = K[o]) == null ? void 0 : u.id;
|
|
262
|
+
e !== void 0 && J(e, (T) => {
|
|
263
|
+
const k = T.filter((h) => v.has(h)), N = k.length;
|
|
264
|
+
if (o < N) {
|
|
265
|
+
if (r >= N) return k.filter((go) => go !== e);
|
|
266
|
+
const h = k.slice();
|
|
267
|
+
return h.splice(o, 1), h.splice(r, 0, e), h;
|
|
268
|
+
}
|
|
269
|
+
if (r <= N) {
|
|
270
|
+
const h = k.slice();
|
|
271
|
+
return h.splice(Math.min(r, N), 0, e), h;
|
|
272
|
+
}
|
|
273
|
+
return T;
|
|
274
|
+
});
|
|
275
|
+
}, fo = ({
|
|
276
|
+
tool: o,
|
|
277
|
+
from: r,
|
|
278
|
+
to: e
|
|
279
|
+
}) => {
|
|
280
|
+
const u = j.size, T = r < u;
|
|
281
|
+
return T && e >= u ? C("controlRoom.unpinnedAnnounce", {
|
|
282
|
+
tool: o.label,
|
|
283
|
+
defaultValue: "Removed {{tool}} from favourites"
|
|
284
|
+
}) : !T && e <= u ? C("controlRoom.pinnedAnnounce", {
|
|
285
|
+
tool: o.label,
|
|
286
|
+
defaultValue: "Pinned {{tool}} to favourites"
|
|
287
|
+
}) : T && e < u ? C("controlRoom.reorderAnnounce", {
|
|
288
|
+
tool: o.label,
|
|
289
|
+
to: e + 1,
|
|
290
|
+
total: u,
|
|
291
|
+
defaultValue: "{{tool}} moved to position {{to}} of {{total}}"
|
|
292
|
+
}) : "";
|
|
293
|
+
}, Q = $(null), U = Mo(), po = b(
|
|
294
|
+
(o) => {
|
|
295
|
+
Q.current = o, U(o), typeof M == "function" ? M(o) : M && (M.current = o);
|
|
296
|
+
},
|
|
297
|
+
[U, M]
|
|
298
|
+
), E = D != null ? v.get(D) ?? null : null, mo = E ? /* @__PURE__ */ Y(Ro, { children: [
|
|
299
|
+
n ? (() => {
|
|
300
|
+
const o = j.has(E.id);
|
|
301
|
+
return /* @__PURE__ */ A(
|
|
302
|
+
Z,
|
|
303
|
+
{
|
|
304
|
+
icon: /* @__PURE__ */ A(
|
|
305
|
+
Ao,
|
|
306
|
+
{
|
|
307
|
+
"aria-hidden": "true",
|
|
308
|
+
fill: o ? "currentColor" : "none",
|
|
309
|
+
className: o ? "ds:text-[color:var(--accent)]" : void 0
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
intent: "ghost",
|
|
313
|
+
size: "sm",
|
|
314
|
+
"aria-pressed": o,
|
|
315
|
+
"aria-label": C("controlRoom.favorite", {
|
|
316
|
+
defaultValue: "Favourite"
|
|
317
|
+
}),
|
|
318
|
+
onClick: () => ao(E.id)
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
})() : null,
|
|
322
|
+
/* @__PURE__ */ A(
|
|
323
|
+
Z,
|
|
324
|
+
{
|
|
325
|
+
icon: /* @__PURE__ */ A(wo, { "aria-hidden": "true" }),
|
|
326
|
+
intent: "ghost",
|
|
327
|
+
size: "sm",
|
|
328
|
+
"aria-label": C("controlRoom.close", { defaultValue: "Close" }),
|
|
329
|
+
onClick: () => {
|
|
330
|
+
var o;
|
|
331
|
+
return (o = Q.current) == null ? void 0 : o.close();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
)
|
|
335
|
+
] }) : null;
|
|
336
|
+
return /* @__PURE__ */ Y(xo, { actions: mo, children: [
|
|
337
|
+
/* @__PURE__ */ A(
|
|
338
|
+
yo,
|
|
339
|
+
{
|
|
340
|
+
ref: po,
|
|
341
|
+
dataComponent: "control-room-rail",
|
|
342
|
+
agentAdapter: So,
|
|
343
|
+
tools: K,
|
|
344
|
+
activeToolId: d,
|
|
345
|
+
defaultActiveToolId: m,
|
|
346
|
+
onActiveToolChange: I,
|
|
347
|
+
panelWidth: so,
|
|
348
|
+
onPanelWidthChange: ro,
|
|
349
|
+
railLabel: l ?? C("controlRoom.railLabel", { defaultValue: "Control room" }),
|
|
350
|
+
onReorder: n ? uo : void 0,
|
|
351
|
+
formatReorderAnnouncement: n ? fo : void 0,
|
|
352
|
+
...q
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
n ? /* @__PURE__ */ A("span", { role: "status", "aria-live": "polite", className: "ds:sr-only", children: lo }) : null
|
|
356
|
+
] });
|
|
357
|
+
});
|
|
358
|
+
export {
|
|
359
|
+
Xo as C,
|
|
360
|
+
Go as a,
|
|
361
|
+
ko as b,
|
|
362
|
+
So as c,
|
|
363
|
+
$o as d,
|
|
364
|
+
Do as u
|
|
365
|
+
};
|
|
366
|
+
//# sourceMappingURL=control-room-rail-CdBOXIqX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-room-rail-CdBOXIqX.js","sources":["../../src/components/control-room-rail/control-room-rail.agent.ts","../../src/components/control-room-rail/control-room-context.tsx","../../src/components/control-room-rail/control-room-rail.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — ControlRoomRail. */\n/* */\n/* The product surface built on ToolRail: the docked \"Control Room\". */\n/* It claims its OWN agent identity ('control-room-rail') so an agent and */\n/* the DOM / cascade boundary can tell the Control Room apart from a bare */\n/* ToolRail. Generic rail surface only: open / close a tool's panel and */\n/* read which tool is active. State is strictly the active tool id — never */\n/* any tool's panel CONTENT (which may carry PHI). */\n/* */\n/* The descriptionKeys deliberately REUSE the existing */\n/* `ui.toolRail.agent.*` translations — no new i18n keys are coined this */\n/* pass. */\n/* */\n/* NOTE: pin / unpin / reorder favourites are intentionally NOT yet an */\n/* agent capability. Exposing them is a deferred follow-up: it needs a */\n/* closed-vocabulary capability addition (DS-maintainer approval per */\n/* src/docs/26-agent-readiness.mdx) plus its own 18-locale descriptionKeys */\n/* — neither of which this pass introduces. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { ControlRoomRailHandle } from './control-room-rail';\n\nexport const controlRoomRailAgent: AgentAdapter<ControlRoomRailHandle> = {\n id: 'control-room-rail',\n capabilities: ['open', 'close', 'select_single'],\n state: {\n activeToolId: {\n type: 'string | null',\n descriptionKey: 'ui.toolRail.agent.state.activeToolId',\n description:\n 'Id of the tool whose panel is currently open, or null when the rail is collapsed to its strip. No panel content is ever exposed.',\n read: (handle) => handle.getActiveToolId(),\n },\n },\n actions: {\n open: {\n // Pure ephemeral panel state (open) — no data loss, no external effect.\n safety: 'read',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.toolRail.agent.actions.open',\n description: \"Open the given tool's panel.\",\n examples: [{ args: { id: 'inbox' }, note: 'Open the inbox tool panel.' }],\n invoke: (handle, args: { id: string }) => {\n handle.open(args.id);\n },\n },\n close: {\n safety: 'read',\n idempotent: true,\n descriptionKey: 'ui.toolRail.agent.actions.close',\n description: 'Collapse the rail to its strip (no active tool).',\n invoke: (handle) => {\n handle.close();\n },\n },\n select_tool: {\n safety: 'read',\n argsType: '{ id: string | null }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: ['string', 'null'] } },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.toolRail.agent.actions.selectTool',\n description:\n 'Set the active tool by id (opens its panel), or pass null to collapse.',\n invoke: (handle, args: { id: string | null }) => {\n handle.setActiveTool(args.id);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'control-room-rail',\n description: 'Marks the ControlRoomRail wrapper.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Required to address a specific rail from the agent.',\n },\n item: {\n attr: 'data-tool-id',\n description:\n 'Stable tool id emitted on each strip IconButton. The active icon also carries data-active set to its id.',\n },\n },\n};\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport type { ToolRailHandle, ToolRailTool } from '../tool-rail';\n\n/* ------------------------------------------------------------------ */\n/* Control Room context — the scope mechanism */\n/* */\n/* The DS provides the plumbing; the CONSUMER declares scope by which */\n/* API it reaches for: */\n/* - <ControlRoomProvider globalTools={…}> → `global` tools, set */\n/* once at the app shell, persist across navigation. */\n/* - useControlRoomTools([…]) → `contextual` tools, */\n/* registered per-page, swap with the open entity. */\n/* `<ControlRoomRail>` reads the merged set; `global` tools seed the */\n/* default favourites (pinned on top), `contextual` tools fall below */\n/* the divider. The rail renders the divider between the two groups. */\n/* ------------------------------------------------------------------ */\n\ninterface ControlRoomContextValue {\n globalTools: ToolRailTool[];\n contextualTools: ToolRailTool[];\n registerContextualTools: (id: string, tools: ToolRailTool[]) => void;\n unregisterContextualTools: (id: string) => void;\n // The rail registers its imperative handle here so pages can drive it\n // (e.g. open the X-ray panel when a tooth is clicked). Null until mounted.\n registerRail: (handle: ToolRailHandle | null) => void;\n openTool: (id: string) => void;\n closeTool: () => void;\n}\n\nconst ControlRoomContext = createContext<ControlRoomContextValue | null>(null);\n\nexport interface ControlRoomProviderProps {\n /**\n * Tools valid in every context (Alia, Inbox). Set once at the app shell —\n * they pin to the rail's far end and persist across navigation. Memoise\n * this array so it doesn't re-register every render.\n */\n globalTools?: ToolRailTool[];\n children: ReactNode;\n}\n\n/**\n * Holds the Control Room's global tools and the registry of per-context\n * contextual tools. Mount once at the app shell, inside the frame that also\n * renders `<ControlRoomRail>`.\n */\nexport function ControlRoomProvider({\n globalTools = [],\n children,\n}: ControlRoomProviderProps) {\n // id → that registration's contextual tools. Multiple concurrent\n // registrations merge in insertion order (rare, but composes cleanly).\n const [registry, setRegistry] = useState<Map<string, ToolRailTool[]>>(\n () => new Map(),\n );\n\n const registerContextualTools = useCallback(\n (id: string, tools: ToolRailTool[]) => {\n setRegistry((prev) => {\n const next = new Map(prev);\n next.set(id, tools);\n return next;\n });\n },\n [],\n );\n\n const unregisterContextualTools = useCallback((id: string) => {\n setRegistry((prev) => {\n if (!prev.has(id)) return prev;\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n\n const contextualTools = useMemo(\n () => Array.from(registry.values()).flat(),\n [registry],\n );\n\n // The rail's imperative handle, registered by <ControlRoomRail> on mount.\n // openTool/closeTool drive it so a page can open a panel (e.g. the X-ray\n // viewer when a tooth is clicked) without holding a ref to the rail itself.\n const railHandleRef = useRef<ToolRailHandle | null>(null);\n const registerRail = useCallback((handle: ToolRailHandle | null) => {\n railHandleRef.current = handle;\n }, []);\n const openTool = useCallback((id: string) => {\n railHandleRef.current?.setActiveTool(id);\n }, []);\n const closeTool = useCallback(() => {\n railHandleRef.current?.setActiveTool(null);\n }, []);\n\n const value = useMemo<ControlRoomContextValue>(\n () => ({\n globalTools,\n contextualTools,\n registerContextualTools,\n unregisterContextualTools,\n registerRail,\n openTool,\n closeTool,\n }),\n [\n globalTools,\n contextualTools,\n registerContextualTools,\n unregisterContextualTools,\n registerRail,\n openTool,\n closeTool,\n ],\n );\n\n return (\n <ControlRoomContext.Provider value={value}>\n {children}\n </ControlRoomContext.Provider>\n );\n}\n\n/**\n * Register this context's **contextual** tools (Notes, Appointments, the entity\n * summary). They sit below the favourites divider and unregister automatically\n * when the calling component unmounts (i.e. when you leave the context).\n *\n * Pass a **stable / memoised** array — like `useEffect` deps, a fresh array\n * every render re-registers every render. Wrap it in `useMemo`.\n *\n * No-op when rendered outside a `<ControlRoomProvider>`.\n */\nexport function useControlRoomTools(tools: ToolRailTool[]): void {\n const ctx = useContext(ControlRoomContext);\n // Depend on the STABLE register/unregister callbacks, never the whole\n // context value: the value object changes every time the registry updates\n // (which this very effect triggers), so depending on `ctx` would re-register\n // on every change — an infinite loop. The callbacks are `useCallback([])`.\n const register = ctx?.registerContextualTools;\n const unregister = ctx?.unregisterContextualTools;\n const id = useId();\n useEffect(() => {\n if (!register || !unregister) return undefined;\n register(id, tools);\n return () => unregister(id);\n }, [register, unregister, id, tools]);\n}\n\n/**\n * The merged tool set the rail consumes: contextual tools (auto-tagged\n * `scope: 'contextual'`) then globals (`scope: 'global'`). Scope is assigned\n * here by which API registered the tool — `global` seeds the Control Room's\n * default favourites (pinned on top); `contextual` falls below the divider.\n * `ControlRoomRail` re-groups by favourite membership for the final order.\n * Returns `[]` outside a provider.\n */\nexport function useControlRoomMergedTools(): ToolRailTool[] {\n const ctx = useContext(ControlRoomContext);\n return useMemo(() => {\n if (!ctx) return [];\n const contextual = ctx.contextualTools.map((tool) => ({\n ...tool,\n scope: 'contextual' as const,\n }));\n const global = ctx.globalTools.map((tool) => ({\n ...tool,\n scope: 'global' as const,\n }));\n return [...contextual, ...global];\n }, [ctx]);\n}\n\n/**\n * Imperative actions to drive the rail from a page: open a tool's panel (e.g.\n * the X-ray viewer when a tooth is clicked) or collapse it. No-ops outside a\n * `<ControlRoomProvider>`. The functions are stable across renders.\n */\nexport function useControlRoomActions(): {\n openTool: (id: string) => void;\n closeTool: () => void;\n} {\n const ctx = useContext(ControlRoomContext);\n const noop = useCallback(() => {}, []);\n return {\n openTool: ctx?.openTool ?? noop,\n closeTool: ctx?.closeTool ?? noop,\n };\n}\n\n/**\n * Internal: the rail registers its imperative handle with the provider so\n * `useControlRoomActions().openTool` can drive it. Returns the stable\n * `registerRail` callback (or a no-op outside a provider).\n */\nexport function useControlRoomRailRegister(): (\n handle: ToolRailHandle | null,\n) => void {\n const ctx = useContext(ControlRoomContext);\n const noop = useCallback((_handle: ToolRailHandle | null) => {}, []);\n return ctx?.registerRail ?? noop;\n}\n","import {\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Star, X } from 'lucide-react';\nimport { IconButton } from '../button/icon-button';\nimport { PanelHeaderActionsProvider } from '../panel-header/panel-header';\nimport {\n ToolRail,\n type ToolRailHandle,\n type ToolRailProps,\n type ToolRailTool,\n} from '../tool-rail';\nimport { usePersistentState } from '../../hooks/use-persistent-state';\nimport { controlRoomRailAgent } from './control-room-rail.agent';\nimport {\n useControlRoomMergedTools,\n useControlRoomRailRegister,\n} from './control-room-context';\n\n/* ------------------------------------------------------------------ */\n/* ControlRoomRail — the unified, contextual workspace rail. */\n/* */\n/* The docked right-hand \"Control Room\": the single home for the */\n/* assistant, inbox, notes, appointments and entity summaries */\n/* alongside the main work surface. One panel open at a time, */\n/* non-modal. */\n/* */\n/* It layers a FAVOURITES model over the proven ToolRail (its prior */\n/* name): favourited tools form a pinned group at the TOP of the strip */\n/* above a divider, then everything else below. The default favourites */\n/* are the host's `global` tools (Alia, Inbox) — so the rail opens with */\n/* notifications + Alia on top, the Control Room's default arrangement. */\n/* */\n/* Favouriting is DRAG-FIRST, no per-icon star: drag a tool up across */\n/* the divider to pin it (and drop it where you want in the order), */\n/* drag a favourite back down to unpin. The keyboard equivalent is */\n/* `Alt`+Arrow (crossing the divider pins / unpins, announced). The */\n/* non-drag pointer path — and the discoverable entry point — is an */\n/* add / remove control in each open tool's panel header. */\n/* */\n/* ToolRail stays favourite-agnostic: this layer maps favourite */\n/* membership onto the rail's generic `scope` grouping + (whole-strip) */\n/* `reorderable` run, reads cross-divider moves as pin / unpin, and */\n/* injects the favourite + close controls into the active panel's */\n/* PanelHeader via <PanelHeaderActionsProvider> (no separate header */\n/* row — the controls live inline-end of the panel's title row). */\n/* ------------------------------------------------------------------ */\n\n/** A Control Room tool — the rail tool descriptor, `scope`-aware. */\nexport type ControlRoomTool = ToolRailTool;\n\n/** Imperative handle — open / collapse a tool panel without the DOM. */\nexport type ControlRoomRailHandle = ToolRailHandle;\n\n/** What one favourites write did, for the tool the user acted on. */\nexport interface ControlRoomFavoriteChange {\n toolId: string;\n action: 'pin' | 'unpin' | 'reorder';\n}\n\n/* A hard-pinned id re-pins on the next render, so unpinning it changes\n nothing and reports nothing. */\nfunction favoriteChangeOf(\n toolId: string,\n previous: readonly string[],\n next: readonly string[],\n hardPinned: readonly string[] | undefined,\n): ControlRoomFavoriteChange | undefined {\n const was = previous.includes(toolId);\n const is = next.includes(toolId);\n if (!was && is) return { toolId, action: 'pin' };\n if (was && !is)\n return hardPinned?.includes(toolId)\n ? undefined\n : { toolId, action: 'unpin' };\n /* Compare what the rail shows: hard-pinned ids always lead. */\n const shown = (list: readonly string[]) =>\n hardPinned?.length\n ? [...hardPinned, ...list.filter((id) => !hardPinned.includes(id))]\n : list;\n const before = shown(previous);\n const after = shown(next);\n const reordered =\n before.length !== after.length ||\n before.some((id, index) => after[index] !== id);\n return reordered ? { toolId, action: 'reorder' } : undefined;\n}\n\nexport interface ControlRoomRailProps extends Omit<\n ToolRailProps,\n | 'tools'\n | 'onReorder'\n | 'formatReorderAnnouncement'\n | 'renderToolAffordance'\n | 'renderPanelHeader'\n> {\n /**\n * Explicit tool set. Omit to read the merged global + contextual tools from\n * the nearest `<ControlRoomProvider>` (+ `useControlRoomTools`).\n */\n tools?: ControlRoomTool[];\n /**\n * Enable the favourites model: a pinned top group, drag / `Alt`+Arrow\n * reordering, and the panel-header add / remove control. Default `true`. Set\n * `false` for the legacy flat strip (tools render in the order / `scope` you\n * pass, no drag, no panel-header control).\n */\n reorderable?: boolean;\n /**\n * Controlled favourite tool ids, in pinned order. When set, the rail does not\n * persist — the host owns the value and is notified via `onFavoriteIdsChange`.\n */\n favoriteIds?: string[];\n /**\n * HARD-PINNED favourite ids — always rendered at the very START of the\n * pinned group, ahead of (and deduped from) user favourites, in both\n * controlled and uncontrolled modes. Immune to unpin: removing one via\n * the panel-header control or a drag is a no-op (it re-pins on the next\n * render). For tools the product wants permanently one glance away —\n * e.g. notifications at the top of the strip.\n */\n pinnedFavoriteIds?: string[];\n /**\n * Uncontrolled initial favourites. Defaults to the ids of the tools the host\n * marked `scope: 'global'` (Alia, Inbox) — pinning them on top by default.\n */\n defaultFavoriteIds?: string[];\n /** Fires with the next favourites order whenever the user pins / reorders.\n * `change` names the tool acted on and what happened to it; it is\n * absent when the write changed nothing. */\n onFavoriteIdsChange?: (\n next: string[],\n change?: ControlRoomFavoriteChange,\n ) => void;\n /** localStorage key for the uncontrolled favourites. */\n persistFavoritesKey?: string;\n /**\n * localStorage key for the uncontrolled committed panel width, mirroring\n * `persistFavoritesKey`: when set and `panelWidth` is absent, the rail\n * seeds its width from storage on mount and writes each commit back.\n * Unlike `persistFavoritesKey` this has no default — persistence is\n * opt-in. Only meaningful with `resizablePanel` — there is nothing to\n * persist without the resize handle.\n */\n persistPanelWidthKey?: string;\n}\n\nexport const ControlRoomRail = forwardRef<\n ControlRoomRailHandle,\n ControlRoomRailProps\n>(function ControlRoomRail(\n {\n tools,\n railLabel,\n reorderable = true,\n favoriteIds,\n defaultFavoriteIds,\n pinnedFavoriteIds,\n onFavoriteIdsChange,\n persistFavoritesKey = 'ui.controlRoom.favorites',\n activeToolId,\n defaultActiveToolId = null,\n onActiveToolChange,\n panelWidth,\n onPanelWidthChange,\n persistPanelWidthKey,\n ...rest\n },\n ref,\n) {\n const { t } = useTranslation();\n\n // Mirror the active tool id so the rail can build the panel-header controls\n // (favourite + close) for whichever tool is open. Controlled hosts own the\n // value via `activeToolId`; otherwise we seed from `defaultActiveToolId` and\n // track subsequent changes through the intercepted `onActiveToolChange`.\n const [activeTracked, setActiveTracked] = useState<string | null>(\n activeToolId ?? defaultActiveToolId ?? null,\n );\n const activeId = activeToolId !== undefined ? activeToolId : activeTracked;\n const handleActiveToolChange = useCallback(\n (id: string | null) => {\n if (activeToolId === undefined) setActiveTracked(id);\n onActiveToolChange?.(id);\n },\n [activeToolId, onActiveToolChange],\n );\n // Provider-driven tools when none are passed explicitly. Calling the hook\n // unconditionally is safe — it returns [] outside a provider.\n const merged = useControlRoomMergedTools();\n const resolved = tools ?? merged;\n\n const isControlled = favoriteIds !== undefined;\n // Uncontrolled favourites persist to localStorage; the lazy initial seeds\n // from the host's `global` tools on first mount only (later tool changes\n // don't re-seed — favourites are user-owned once set). When controlled, the\n // hook is disabled so it never reads or writes storage.\n const [storedFavorites, setStoredFavorites] = usePersistentState<string[]>(\n persistFavoritesKey,\n () =>\n defaultFavoriteIds ??\n resolved.filter((tl) => tl.scope === 'global').map((tl) => tl.id),\n { disabled: isControlled },\n );\n const userFavorites = isControlled ? favoriteIds : storedFavorites;\n /* Hard-pinned ids lead the group every render — user favourites follow,\n deduped. Because the merge happens HERE (not in storage), an unpin\n write simply has no effect on a pinned id. */\n const favorites = useMemo(() => {\n if (!pinnedFavoriteIds?.length) return userFavorites;\n return [\n ...pinnedFavoriteIds,\n ...userFavorites.filter((id) => !pinnedFavoriteIds.includes(id)),\n ];\n }, [pinnedFavoriteIds, userFavorites]);\n\n // Uncontrolled panel-width persistence mirrors favourites, but is opt-in\n // (no default key) since not every rail wants its width remembered.\n // The hook is called unconditionally — `disabled` just keeps it from\n // touching storage when controlled or when no key was given.\n const isWidthControlled = panelWidth !== undefined;\n const [storedPanelWidth, setStoredPanelWidth] = usePersistentState<\n number | null\n >(persistPanelWidthKey ?? 'ui.controlRoom.panelWidth.unused', null, {\n disabled: isWidthControlled || !persistPanelWidthKey,\n });\n const resolvedPanelWidth = isWidthControlled\n ? panelWidth\n : persistPanelWidthKey\n ? storedPanelWidth\n : undefined;\n const handlePanelWidthChange = useCallback(\n (next: number | null) => {\n if (!isWidthControlled && persistPanelWidthKey) {\n setStoredPanelWidth(next);\n }\n onPanelWidthChange?.(next);\n },\n [\n isWidthControlled,\n persistPanelWidthKey,\n setStoredPanelWidth,\n onPanelWidthChange,\n ],\n );\n\n const byId = useMemo(() => {\n const map = new Map<string, ControlRoomTool>();\n for (const tl of resolved) map.set(tl.id, tl);\n return map;\n }, [resolved]);\n\n // Favourites filtered to currently-present tools — stale ids are ignored\n // (and dropped on the next write).\n const favoriteSet = useMemo(\n () => new Set(favorites.filter((id) => byId.has(id))),\n [favorites, byId],\n );\n\n const updateFavorites = (\n toolId: string,\n updater: (prev: string[]) => string[],\n ) => {\n // `updater` must be pure — it is invoked twice (once to compute the\n // reported `next`, once inside the functional setState below).\n const previous = favorites.filter((id) => byId.has(id));\n const next = updater(previous);\n // Persist via a functional update so rapid pin/reorder events compose\n // (mirrors the Sidebar's useFavorites); controlled hosts own the value.\n if (!isControlled)\n setStoredFavorites((prev) => updater(prev.filter((id) => byId.has(id))));\n onFavoriteIdsChange?.(\n next,\n favoriteChangeOf(toolId, previous, next, pinnedFavoriteIds),\n );\n };\n\n // Re-group into the pinned run (favourites order, tagged so ToolRail draws\n // the divider) followed by the rest. EVERY tool is `reorderable` so the rail's\n // reorder run spans the whole strip — that's what lets a drag / Alt+Arrow\n // cross the divider; `handleReorder` reads the crossing as pin / unpin.\n const railTools = useMemo<ControlRoomTool[]>(() => {\n if (!reorderable) return resolved;\n const favTools = favorites\n .filter((id) => byId.has(id))\n .map((id) => ({\n ...(byId.get(id) as ControlRoomTool),\n scope: 'global' as const,\n reorderable: true,\n }));\n const rest = resolved\n .filter((tl) => !favoriteSet.has(tl.id))\n .map((tl) => ({\n ...tl,\n scope: 'contextual' as const,\n reorderable: true,\n }));\n return [...favTools, ...rest];\n }, [reorderable, resolved, favorites, byId, favoriteSet]);\n\n // The drag / Alt+Arrow path announces through the rail's own reorder live\n // region; the panel-header button toggles outside it, so it needs its own\n // polite announcement. The zero-width-space toggle forces a re-announce of an\n // identical message (e.g. pin → unpin → pin the same tool).\n const [pinMessage, setPinMessage] = useState('');\n const pinAnnounceToggle = useRef(false);\n const announcePinChange = (label: string, willPin: boolean) => {\n const text = willPin\n ? t('controlRoom.pinnedAnnounce', {\n tool: label,\n defaultValue: 'Pinned {{tool}} to favourites',\n })\n : t('controlRoom.unpinnedAnnounce', {\n tool: label,\n defaultValue: 'Removed {{tool}} from favourites',\n });\n pinAnnounceToggle.current = !pinAnnounceToggle.current;\n setPinMessage(pinAnnounceToggle.current ? text : `${text}\\u200B`);\n };\n\n const togglePin = (id: string) => {\n announcePinChange(byId.get(id)?.label ?? id, !favoriteSet.has(id));\n updateFavorites(id, (prev) =>\n prev.includes(id) ? prev.filter((p) => p !== id) : [...prev, id],\n );\n };\n\n // The rail fires `onReorder` with indices into `railTools` (favourites first,\n // then the rest). The divider sits at `favCount`, so the index either side of\n // it tells us whether a move is a reorder, a pin, an unpin, or a no-op.\n const handleReorder = (from: number, to: number) => {\n const movedId = railTools[from]?.id;\n if (movedId === undefined) return;\n updateFavorites(movedId, (prev) => {\n const present = prev.filter((id) => byId.has(id));\n const favCount = present.length;\n const wasFav = from < favCount;\n if (wasFav) {\n // Dropped below the divider → unpin.\n if (to >= favCount) return present.filter((id) => id !== movedId);\n // Reorder within favourites (full-strip index == favourites index).\n const next = present.slice();\n next.splice(from, 1);\n next.splice(to, 0, movedId);\n return next;\n }\n // A contextual tool dropped onto / above the divider → pin at that slot.\n if (to <= favCount) {\n const next = present.slice();\n next.splice(Math.min(to, favCount), 0, movedId);\n return next;\n }\n // Contextual → contextual: that group is host-ordered, so nothing to do.\n return prev;\n });\n };\n\n // Membership-aware live-region phrasing for the rail's reorder announcer.\n const formatReorderAnnouncement = ({\n tool,\n from,\n to,\n }: {\n tool: ControlRoomTool;\n from: number;\n to: number;\n }): string => {\n const favCount = favoriteSet.size;\n const wasFav = from < favCount;\n if (wasFav && to >= favCount)\n return t('controlRoom.unpinnedAnnounce', {\n tool: tool.label,\n defaultValue: 'Removed {{tool}} from favourites',\n });\n if (!wasFav && to <= favCount)\n return t('controlRoom.pinnedAnnounce', {\n tool: tool.label,\n defaultValue: 'Pinned {{tool}} to favourites',\n });\n if (wasFav && to < favCount)\n return t('controlRoom.reorderAnnounce', {\n tool: tool.label,\n to: to + 1,\n total: favCount,\n defaultValue: '{{tool}} moved to position {{to}} of {{total}}',\n });\n // Contextual → contextual is a no-op; stay silent.\n return '';\n };\n\n // Register the rail's imperative handle with the provider (so a page's\n // useControlRoomActions().openTool can drive it) AND forward it to the\n // consumer's ref. A callback ref does both; no-op without a provider. We also\n // stash it locally so the injected close control can collapse the panel.\n const railHandleRef = useRef<ToolRailHandle | null>(null);\n const registerRail = useControlRoomRailRegister();\n const setRefs = useCallback(\n (handle: ToolRailHandle | null) => {\n railHandleRef.current = handle;\n registerRail(handle);\n if (typeof ref === 'function') ref(handle);\n else if (ref) ref.current = handle;\n },\n [registerRail, ref],\n );\n\n // The active tool's panel-header controls, injected into its PanelHeader's\n // action cluster (inline-end of the title row) via context — no separate\n // header row. When a tool is open: an icon-only favourite toggle (only when\n // reorderable; pressed state via aria-pressed + the filled star) followed by\n // a close control that collapses the panel. Nothing injected when collapsed\n // or where the panel renders no PanelHeader.\n const activeTool = activeId != null ? (byId.get(activeId) ?? null) : null;\n const injectedActions: ReactNode = activeTool ? (\n <>\n {reorderable\n ? (() => {\n const pinned = favoriteSet.has(activeTool.id);\n return (\n <IconButton\n icon={\n <Star\n aria-hidden=\"true\"\n fill={pinned ? 'currentColor' : 'none'}\n className={\n pinned ? 'ds:text-[color:var(--accent)]' : undefined\n }\n />\n }\n intent=\"ghost\"\n size=\"sm\"\n aria-pressed={pinned}\n aria-label={t('controlRoom.favorite', {\n defaultValue: 'Favourite',\n })}\n onClick={() => togglePin(activeTool.id)}\n />\n );\n })()\n : null}\n <IconButton\n icon={<X aria-hidden=\"true\" />}\n intent=\"ghost\"\n size=\"sm\"\n aria-label={t('controlRoom.close', { defaultValue: 'Close' })}\n onClick={() => railHandleRef.current?.close()}\n />\n </>\n ) : null;\n return (\n <PanelHeaderActionsProvider actions={injectedActions}>\n <ToolRail\n ref={setRefs}\n dataComponent=\"control-room-rail\"\n agentAdapter={controlRoomRailAgent}\n tools={railTools}\n activeToolId={activeToolId}\n defaultActiveToolId={defaultActiveToolId}\n onActiveToolChange={handleActiveToolChange}\n panelWidth={resolvedPanelWidth}\n onPanelWidthChange={handlePanelWidthChange}\n railLabel={\n railLabel ??\n t('controlRoom.railLabel', { defaultValue: 'Control room' })\n }\n onReorder={reorderable ? handleReorder : undefined}\n formatReorderAnnouncement={\n reorderable ? formatReorderAnnouncement : undefined\n }\n {...rest}\n />\n {/* Polite announcement for the panel-header pin / unpin button (the\n drag / Alt+Arrow path announces via the rail's own reorder region). */}\n {reorderable ? (\n <span role=\"status\" aria-live=\"polite\" className=\"ds:sr-only\">\n {pinMessage}\n </span>\n ) : null}\n </PanelHeaderActionsProvider>\n );\n});\n"],"names":["controlRoomRailAgent","handle","args","ControlRoomContext","createContext","ControlRoomProvider","globalTools","children","registry","setRegistry","useState","registerContextualTools","useCallback","id","tools","prev","next","unregisterContextualTools","contextualTools","useMemo","railHandleRef","useRef","registerRail","openTool","_a","closeTool","value","jsx","useControlRoomTools","ctx","useContext","register","unregister","useId","useEffect","useControlRoomMergedTools","contextual","tool","global","useControlRoomActions","noop","useControlRoomRailRegister","_handle","favoriteChangeOf","toolId","previous","hardPinned","was","is","shown","list","before","after","index","ControlRoomRail","forwardRef","railLabel","reorderable","favoriteIds","defaultFavoriteIds","pinnedFavoriteIds","onFavoriteIdsChange","persistFavoritesKey","activeToolId","defaultActiveToolId","onActiveToolChange","panelWidth","onPanelWidthChange","persistPanelWidthKey","rest","ref","t","useTranslation","activeTracked","setActiveTracked","activeId","handleActiveToolChange","merged","resolved","isControlled","storedFavorites","setStoredFavorites","usePersistentState","tl","userFavorites","favorites","isWidthControlled","storedPanelWidth","setStoredPanelWidth","resolvedPanelWidth","handlePanelWidthChange","byId","map","favoriteSet","updateFavorites","updater","railTools","favTools","pinMessage","setPinMessage","pinAnnounceToggle","announcePinChange","label","willPin","text","togglePin","p","handleReorder","from","to","movedId","present","favCount","formatReorderAnnouncement","wasFav","setRefs","activeTool","injectedActions","jsxs","Fragment","pinned","IconButton","Star","X","PanelHeaderActionsProvider","ToolRail"],"mappings":";;;;;;;;;AAwBO,MAAMA,KAA4D;AAAA,EACvE,IAAI;AAAA,EACJ,cAAc,CAAC,QAAQ,SAAS,eAAe;AAAA,EAC/C,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACC,MAAWA,EAAO,gBAAA;AAAA,IAAgB;AAAA,EAC3C;AAAA,EAEF,SAAS;AAAA,IACP,MAAM;AAAA;AAAA,MAEJ,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY,EAAE,IAAI,EAAE,MAAM,WAAS;AAAA,QACnC,UAAU,CAAC,IAAI;AAAA,MAAA;AAAA,MAEjB,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,WAAW,MAAM,8BAA8B;AAAA,MACxE,QAAQ,CAACA,GAAQC,MAAyB;AACxC,QAAAD,EAAO,KAAKC,EAAK,EAAE;AAAA,MACrB;AAAA,IAAA;AAAA,IAEF,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACD,MAAW;AAClB,QAAAA,EAAO,MAAA;AAAA,MACT;AAAA,IAAA;AAAA,IAEF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kBAAA/C,IAAAJ,EAAc,YAAd,gBAAAI,EAAuB;AAAA;AAAA,MAAM;AAAA,IAAA;AAAA,EAC9C,EAAA,CACF,IACE;AACJ,SACE,gBAAA8F,EAACM,IAAA,EAA2B,SAASP,IACnC,UAAA;AAAA,IAAA,gBAAA1F;AAAA,MAACkG;AAAA,MAAA;AAAA,QACC,KAAKV;AAAA,QACL,eAAc;AAAA,QACd,cAAcnH;AAAA,QACd,OAAOgG;AAAA,QACP,cAAAjC;AAAA,QACA,qBAAAC;AAAA,QACA,oBAAoBY;AAAA,QACpB,YAAYa;AAAA,QACZ,oBAAoBC;AAAA,QACpB,WACElC,KACAe,EAAE,yBAAyB,EAAE,cAAc,gBAAgB;AAAA,QAE7D,WAAWd,IAAckD,KAAgB;AAAA,QACzC,2BACElD,IAAcwD,KAA4B;AAAA,QAE3C,GAAG5C;AAAA,MAAA;AAAA,IAAA;AAAA,IAILZ,IACC,gBAAA9B,EAAC,QAAA,EAAK,MAAK,UAAS,aAAU,UAAS,WAAU,cAC9C,UAAAuE,GAAA,CACH,IACE;AAAA,EAAA,GACN;AAEJ,CAAC;"}
|
|
@@ -8,7 +8,7 @@ import { u as Y } from "./use-controllable-state-BiY4xTzM.js";
|
|
|
8
8
|
import { u as Z } from "./registry-DvAUVLHh.js";
|
|
9
9
|
import { B as R } from "./button-CaUe1uyd.js";
|
|
10
10
|
import { P as $ } from "./progress-CK8otcQ-.js";
|
|
11
|
-
import { f as ee } from "./payment-form-
|
|
11
|
+
import { f as ee } from "./payment-form-DqJFiplX.js";
|
|
12
12
|
import { T as se } from "./triangle-alert-CBnO6nq_.js";
|
|
13
13
|
import { C as ae } from "./check-DrFSN__t.js";
|
|
14
14
|
const re = {
|
|
@@ -276,4 +276,4 @@ export {
|
|
|
276
276
|
de as F,
|
|
277
277
|
re as f
|
|
278
278
|
};
|
|
279
|
-
//# sourceMappingURL=freemium-paywall-
|
|
279
|
+
//# sourceMappingURL=freemium-paywall-BaW5ODc9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freemium-paywall-Cz-O9lQD.js","sources":["../../src/components/freemium-paywall/freemium-paywall.agent.ts","../../src/components/freemium-paywall/freemium-paywall.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — FreemiumPaywall. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { FreemiumPaywallHandle } from './freemium-paywall';\n\nexport const freemiumPaywallAgent: AgentAdapter<FreemiumPaywallHandle> = {\n id: 'freemium-paywall',\n capabilities: ['submit', 'dismiss'],\n state: {\n isOpen: {\n type: 'boolean',\n descriptionKey: 'ui.agent.freemiumPaywall.state.isOpen',\n description: 'True when the paywall dialog is open.',\n read: (handle) => handle.isOpen(),\n },\n selectedPlanId: {\n type: 'string | null',\n descriptionKey: 'ui.agent.freemiumPaywall.state.selectedPlanId',\n description: 'Opaque id of the currently-selected plan.',\n read: (handle) => handle.getSelectedPlanId(),\n },\n },\n actions: {\n upgrade: {\n safety: 'write',\n // Backs the `submit` capability: commits the current plan selection\n // to the host's upgrade flow (checkout / billing).\n openWorld: true,\n descriptionKey: 'ui.agent.freemiumPaywall.actions.upgrade',\n description: 'Fire onUpgrade with the currently-selected plan id.',\n errors: ['No plan selected — upgrade is a no-op until a plan is chosen.'],\n invoke: (handle) => {\n handle.upgrade();\n },\n },\n dismiss: {\n safety: 'destructive',\n // Backs the `dismiss` capability.\n descriptionKey: 'ui.agent.freemiumPaywall.actions.dismiss',\n description:\n 'Dismiss the paywall via the Not Now action. Irreversible from the same UI.',\n invoke: (handle) => {\n handle.dismiss();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'freemium-paywall',\n description: 'Marks the FreemiumPaywall dialog content.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n type ReactNode,\n} from 'react';\nimport * as RadixAlertDialog from '@radix-ui/react-alert-dialog';\nimport * as RadixRadioGroup from '@radix-ui/react-radio-group';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { useControllableState } from '../../hooks/use-controllable-state';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { freemiumPaywallAgent } from './freemium-paywall.agent';\nimport { TriangleAlert, Check } from 'lucide-react';\nimport { Button } from '../button';\nimport { Progress } from '../progress';\nimport { formatPaymentAmount } from '../payment-form';\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\nexport interface FreemiumPlan {\n id: string;\n /** Translation key for the plan name (e.g. `app.paywall.plans.pro`). */\n nameKey: string;\n /** Amount in minor units (cents, centesimi). */\n priceAmount: number;\n /** ISO 4217 currency code. */\n currency: string;\n /** Translation key for the cadence suffix (e.g. `app.paywall.period.month`). */\n perKey?: string;\n /** Per-line feature translation keys. */\n featuresKeys?: string[];\n}\n\nconst contentVariants = cva(\n [\n 'ds:fixed ds:z-[var(--z-modal)] ds:overflow-auto',\n 'ds:bg-[color:var(--popover)] ds:text-[color:var(--popover-foreground)]',\n 'ds:border ds:border-border ds:shadow-[var(--shadow-lg)]',\n // forced-colors: keep the dialog boundary visible under Windows High\n // Contrast, where `var(--border)` may collapse to system colours.\n 'ds:forced-colors:border-[CanvasText]',\n 'ds:focus:outline-none',\n ].join(' '),\n {\n variants: {\n layout: {\n centered:\n 'ds:start-1/2 ds:top-1/2 ds:-translate-x-1/2 ds:-translate-y-1/2 ds:rtl:translate-x-1/2 ds:rounded-[var(--radius-md)] ds:max-w-[var(--dialog-width-xl)] ds:w-[calc(100vw-2rem)] ds:max-h-[90vh]',\n sheet:\n // `inset-x-0` compiles to logical `inset-inline`; the\n // `inset-inline-0` spelling compiled to nothing.\n 'ds:inset-x-0 ds:bottom-0 ds:w-full ds:max-h-[90vh] ds:rounded-t-[var(--radius-md)]',\n },\n density: {\n compact:\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n full: 'ds:ps-[var(--spacing-lg)] ds:pe-[var(--spacing-lg)] ds:pt-[var(--spacing-lg)] ds:pb-[var(--spacing-lg)]',\n },\n },\n defaultVariants: { layout: 'centered', density: 'full' },\n },\n);\n\n/** Curated imperative handle for agent / external automation. */\nexport interface FreemiumPaywallHandle {\n isOpen: () => boolean;\n getSelectedPlanId: () => string | null;\n upgrade: () => void;\n dismiss: () => void;\n}\n\nexport interface FreemiumPaywallProps extends VariantProps<\n typeof contentVariants\n> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n plans: FreemiumPlan[];\n /** Currently-selected plan id (controlled) or default. */\n selectedPlanId?: string;\n defaultSelectedPlanId?: string;\n onSelectedPlanChange?: (id: string) => void;\n /** Usage indicator values — omit the object to hide the bar. */\n usage?: { used: number; limit: number };\n /** Fires on upgrade. */\n onUpgrade: (planId: string) => void;\n /** Fires when the user dismisses via Not Now. */\n onCancel?: () => void;\n /** Title override; defaults to t('paywall.title'). */\n title?: ReactNode;\n /** Description override; defaults to t('paywall.description'). */\n description?: ReactNode;\n /**\n * Stable instance id. Emitted on the dialog content as\n * `data-component-id` and used as the agent-registry instance key so\n * a host can address this specific paywall.\n */\n id?: string;\n className?: string;\n}\n\nexport const FreemiumPaywall = forwardRef<HTMLDivElement, FreemiumPaywallProps>(\n (\n {\n open,\n onOpenChange,\n plans,\n selectedPlanId,\n defaultSelectedPlanId,\n onSelectedPlanChange,\n usage,\n onUpgrade,\n onCancel,\n title,\n description,\n id,\n layout = 'centered',\n density = 'full',\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const titleId = useId();\n const descId = useId();\n\n const [currentSelectedRaw, handleSelectedChange] =\n useControllableState<string>({\n value: selectedPlanId,\n defaultValue: defaultSelectedPlanId ?? plans[0]?.id ?? '',\n onChange: onSelectedPlanChange,\n });\n const currentSelected = currentSelectedRaw ?? '';\n\n const handleCancel = () => {\n onCancel?.();\n onOpenChange(false);\n };\n\n const handleUpgrade = () => {\n if (!currentSelected) return;\n onUpgrade(currentSelected);\n };\n\n const openRef = useRef(open);\n openRef.current = open;\n const selectedRef = useRef<string>(currentSelected);\n selectedRef.current = currentSelected;\n\n const contentRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => contentRef.current as HTMLDivElement, []);\n\n const agentHandle = useMemo<FreemiumPaywallHandle>(\n () => ({\n isOpen: () => openRef.current,\n getSelectedPlanId: () => selectedRef.current || null,\n upgrade: () => handleUpgrade(),\n dismiss: () => handleCancel(),\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n useAgentRegistration(freemiumPaywallAgent, agentHandle, id);\n\n const usagePercent = usage\n ? Math.min(\n 100,\n Math.max(0, (usage.used / Math.max(1, usage.limit)) * 100),\n )\n : 0;\n const usageFull = usage ? usage.used >= usage.limit : false;\n\n return (\n <RadixAlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <RadixAlertDialog.Portal>\n <RadixAlertDialog.Overlay\n className={[\n 'ds:fixed ds:inset-0 ds:z-[var(--z-modal-backdrop)]',\n 'ds:bg-[color:var(--background)]/70',\n 'ds:motion-safe:data-[state=open]:animate-in ds:motion-safe:data-[state=closed]:animate-out',\n 'ds:[.theme-accessible_&]:animate-none',\n ].join(' ')}\n />\n <RadixAlertDialog.Content\n ref={contentRef}\n aria-labelledby={titleId}\n aria-describedby={descId}\n className={contentVariants({ layout, density, className })}\n data-component=\"freemium-paywall\"\n data-component-id={id}\n >\n <RadixAlertDialog.Title id={titleId} asChild>\n <h2 className=\"type-title-card\">{title ?? t('paywall.title')}</h2>\n </RadixAlertDialog.Title>\n <RadixAlertDialog.Description id={descId} asChild>\n <p className=\"ds:mt-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]\">\n {description ?? t('paywall.description')}\n </p>\n </RadixAlertDialog.Description>\n\n {usage ? (\n <div className=\"ds:mt-[var(--spacing-md)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:mb-[var(--spacing-xs)]\">\n {usageFull ? (\n <TriangleAlert\n aria-hidden=\"true\"\n className=\"ds:size-4 ds:text-[color:var(--destructive)]\"\n />\n ) : null}\n <span\n className={[\n 'type-body-sm',\n usageFull\n ? 'ds:text-[color:var(--destructive)]'\n : 'ds:text-[color:var(--muted-foreground)]',\n ].join(' ')}\n >\n {usageFull\n ? t('paywall.usageFull')\n : t('paywall.usageLabel', {\n used: usage.used,\n limit: usage.limit,\n })}\n </span>\n </div>\n <Progress\n value={usagePercent}\n max={100}\n ariaLabel={t('paywall.usageLabel', {\n used: usage.used,\n limit: usage.limit,\n })}\n className={\n usageFull\n ? 'ds:[&_[role=progressbar]>*]:bg-[color:var(--destructive)]'\n : ''\n }\n />\n </div>\n ) : null}\n\n <RadixRadioGroup.Root\n value={currentSelected}\n onValueChange={handleSelectedChange}\n aria-label={t('paywall.title')}\n className=\"ds:mt-[var(--spacing-md)] ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n >\n {plans.map((plan) => {\n // Reuse the payment-form helper — it knows about\n // zero-decimal currencies (JPY, KRW, VND …) and applies\n // the right divisor. Raw `/ 100` would 100× the price in\n // those currencies.\n const formattedPrice = formatPaymentAmount(\n plan.priceAmount,\n plan.currency,\n i18n.language,\n );\n const period = plan.perKey ? t(plan.perKey) : undefined;\n const priceLine = period\n ? t('paywall.pricePer', { price: formattedPrice, period })\n : formattedPrice;\n const planName = t(plan.nameKey);\n return (\n <RadixRadioGroup.Item\n key={plan.id}\n value={plan.id}\n className={[\n 'ds:group ds:relative ds:flex ds:flex-col ds:items-stretch',\n 'ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)] ds:[.theme-accessible_&]:border-2',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]',\n 'ds:text-start ds:bg-[color:var(--card)] ds:text-[color:var(--card-foreground)]',\n 'ds:data-[state=checked]:border-[color:var(--primary)]',\n 'ds:data-[state=checked]:bg-[color:var(--primary)]/5',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n ].join(' ')}\n >\n <span className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <span className=\"ds:font-semibold\">{planName}</span>\n <span className=\"ds:tabular-nums\">{priceLine}</span>\n </span>\n {plan.featuresKeys && plan.featuresKeys.length > 0 ? (\n <ul\n aria-label={t('paywall.features')}\n className=\"ds:mt-[var(--spacing-xs)] ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\"\n >\n {plan.featuresKeys.map((key, i) => (\n <li\n key={i}\n className=\"ds:flex ds:items-start ds:gap-[var(--spacing-xs)] type-body-sm\"\n >\n <Check\n aria-hidden=\"true\"\n className=\"ds:size-4 ds:shrink-0 ds:text-[color:var(--primary)] ds:mt-[1px]\"\n />\n <span>{t(key)}</span>\n </li>\n ))}\n </ul>\n ) : null}\n </RadixRadioGroup.Item>\n );\n })}\n </RadixRadioGroup.Root>\n\n <div className=\"ds:mt-[var(--spacing-lg)] ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:justify-end\">\n <RadixAlertDialog.Cancel asChild>\n <Button intent=\"outline\" onClick={handleCancel}>\n {t('paywall.notNow')}\n </Button>\n </RadixAlertDialog.Cancel>\n <RadixAlertDialog.Action asChild>\n <Button intent=\"primary\" onClick={handleUpgrade}>\n {t('paywall.upgrade')}\n </Button>\n </RadixAlertDialog.Action>\n </div>\n </RadixAlertDialog.Content>\n </RadixAlertDialog.Portal>\n </RadixAlertDialog.Root>\n );\n },\n);\n\nFreemiumPaywall.displayName = 'FreemiumPaywall';\n"],"names":["freemiumPaywallAgent","handle","contentVariants","cva","FreemiumPaywall","forwardRef","open","onOpenChange","plans","selectedPlanId","defaultSelectedPlanId","onSelectedPlanChange","usage","onUpgrade","onCancel","title","description","id","layout","density","className","ref","t","i18n","useTranslation","titleId","useId","descId","currentSelectedRaw","handleSelectedChange","useControllableState","_a","currentSelected","handleCancel","handleUpgrade","openRef","useRef","selectedRef","contentRef","useImperativeHandle","agentHandle","useMemo","useAgentRegistration","usagePercent","usageFull","jsx","RadixAlertDialog","jsxs","TriangleAlert","Progress","RadixRadioGroup","plan","formattedPrice","formatPaymentAmount","period","priceLine","planName","key","i","Check","Button"],"mappings":";;;;;;;;;;;;;AAOO,MAAMA,KAA4D;AAAA,EACvE,IAAI;AAAA,EACJ,cAAc,CAAC,UAAU,SAAS;AAAA,EAClC,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,OAAA;AAAA,IAAO;AAAA,IAElC,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACA,MAAWA,EAAO,kBAAA;AAAA,IAAkB;AAAA,EAC7C;AAAA,EAEF,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ;AAAA;AAAA;AAAA,MAGR,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAAC,+DAA+D;AAAA,MACxE,QAAQ,CAACA,MAAW;AAClB,QAAAA,EAAO,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,SAAS;AAAA,MACP,QAAQ;AAAA;AAAA,MAER,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,QAAQ,CAACA,MAAW;AAClB,QAAAA,EAAO,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IAAA;AAAA,IAEf,YAAY;AAA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AAA,kCAAA;AAAA,kCAEZ,gBAAAd,EAAC,QAAA,EAAM,UAAAvB,EAAEmC,CAAG,EAAA,CAAE;AAAA,gCAAA;AAAA,8BAAA;AAAA,8BAPTC;AAAA,4BAAA,CASR;AAAA,0BAAA;AAAA,wBAAA,IAED;AAAA,sBAAA;AAAA,oBAAA;AAAA,oBAnCCP,EAAK;AAAA,kBAAA;AAAA,gBAsChB,CAAC;AAAA,cAAA;AAAA,YAAA;AAAA,YAGH,gBAAAJ,EAAC,OAAA,EAAI,WAAU,+FACb,UAAA;AAAA,cAAA,gBAAAF,EAACC,EAAiB,QAAjB,EAAwB,SAAO,IAC9B,UAAA,gBAAAD,EAACe,GAAA,EAAO,QAAO,WAAU,SAAS3B,GAC/B,UAAAX,EAAE,gBAAgB,GACrB,GACF;AAAA,cACA,gBAAAuB,EAACC,EAAiB,QAAjB,EAAwB,SAAO,IAC9B,UAAA,gBAAAD,EAACe,GAAA,EAAO,QAAO,WAAU,SAAS1B,GAC/B,UAAAZ,EAAE,iBAAiB,GACtB,EAAA,CACF;AAAA,YAAA,EAAA,CACF;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,EAAA,CACF,EAAA,CACF;AAAA,EAEJ;AACF;AAEAlB,GAAgB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"freemium-paywall-BaW5ODc9.js","sources":["../../src/components/freemium-paywall/freemium-paywall.agent.ts","../../src/components/freemium-paywall/freemium-paywall.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — FreemiumPaywall. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { FreemiumPaywallHandle } from './freemium-paywall';\n\nexport const freemiumPaywallAgent: AgentAdapter<FreemiumPaywallHandle> = {\n id: 'freemium-paywall',\n capabilities: ['submit', 'dismiss'],\n state: {\n isOpen: {\n type: 'boolean',\n descriptionKey: 'ui.agent.freemiumPaywall.state.isOpen',\n description: 'True when the paywall dialog is open.',\n read: (handle) => handle.isOpen(),\n },\n selectedPlanId: {\n type: 'string | null',\n descriptionKey: 'ui.agent.freemiumPaywall.state.selectedPlanId',\n description: 'Opaque id of the currently-selected plan.',\n read: (handle) => handle.getSelectedPlanId(),\n },\n },\n actions: {\n upgrade: {\n safety: 'write',\n // Backs the `submit` capability: commits the current plan selection\n // to the host's upgrade flow (checkout / billing).\n openWorld: true,\n descriptionKey: 'ui.agent.freemiumPaywall.actions.upgrade',\n description: 'Fire onUpgrade with the currently-selected plan id.',\n errors: ['No plan selected — upgrade is a no-op until a plan is chosen.'],\n invoke: (handle) => {\n handle.upgrade();\n },\n },\n dismiss: {\n safety: 'destructive',\n // Backs the `dismiss` capability.\n descriptionKey: 'ui.agent.freemiumPaywall.actions.dismiss',\n description:\n 'Dismiss the paywall via the Not Now action. Irreversible from the same UI.',\n invoke: (handle) => {\n handle.dismiss();\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'freemium-paywall',\n description: 'Marks the FreemiumPaywall dialog content.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n type ReactNode,\n} from 'react';\nimport * as RadixAlertDialog from '@radix-ui/react-alert-dialog';\nimport * as RadixRadioGroup from '@radix-ui/react-radio-group';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { useControllableState } from '../../hooks/use-controllable-state';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { freemiumPaywallAgent } from './freemium-paywall.agent';\nimport { TriangleAlert, Check } from 'lucide-react';\nimport { Button } from '../button';\nimport { Progress } from '../progress';\nimport { formatPaymentAmount } from '../payment-form';\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\nexport interface FreemiumPlan {\n id: string;\n /** Translation key for the plan name (e.g. `app.paywall.plans.pro`). */\n nameKey: string;\n /** Amount in minor units (cents, centesimi). */\n priceAmount: number;\n /** ISO 4217 currency code. */\n currency: string;\n /** Translation key for the cadence suffix (e.g. `app.paywall.period.month`). */\n perKey?: string;\n /** Per-line feature translation keys. */\n featuresKeys?: string[];\n}\n\nconst contentVariants = cva(\n [\n 'ds:fixed ds:z-[var(--z-modal)] ds:overflow-auto',\n 'ds:bg-[color:var(--popover)] ds:text-[color:var(--popover-foreground)]',\n 'ds:border ds:border-border ds:shadow-[var(--shadow-lg)]',\n // forced-colors: keep the dialog boundary visible under Windows High\n // Contrast, where `var(--border)` may collapse to system colours.\n 'ds:forced-colors:border-[CanvasText]',\n 'ds:focus:outline-none',\n ].join(' '),\n {\n variants: {\n layout: {\n centered:\n 'ds:start-1/2 ds:top-1/2 ds:-translate-x-1/2 ds:-translate-y-1/2 ds:rtl:translate-x-1/2 ds:rounded-[var(--radius-md)] ds:max-w-[var(--dialog-width-xl)] ds:w-[calc(100vw-2rem)] ds:max-h-[90vh]',\n sheet:\n // `inset-x-0` compiles to logical `inset-inline`; the\n // `inset-inline-0` spelling compiled to nothing.\n 'ds:inset-x-0 ds:bottom-0 ds:w-full ds:max-h-[90vh] ds:rounded-t-[var(--radius-md)]',\n },\n density: {\n compact:\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n full: 'ds:ps-[var(--spacing-lg)] ds:pe-[var(--spacing-lg)] ds:pt-[var(--spacing-lg)] ds:pb-[var(--spacing-lg)]',\n },\n },\n defaultVariants: { layout: 'centered', density: 'full' },\n },\n);\n\n/** Curated imperative handle for agent / external automation. */\nexport interface FreemiumPaywallHandle {\n isOpen: () => boolean;\n getSelectedPlanId: () => string | null;\n upgrade: () => void;\n dismiss: () => void;\n}\n\nexport interface FreemiumPaywallProps extends VariantProps<\n typeof contentVariants\n> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n plans: FreemiumPlan[];\n /** Currently-selected plan id (controlled) or default. */\n selectedPlanId?: string;\n defaultSelectedPlanId?: string;\n onSelectedPlanChange?: (id: string) => void;\n /** Usage indicator values — omit the object to hide the bar. */\n usage?: { used: number; limit: number };\n /** Fires on upgrade. */\n onUpgrade: (planId: string) => void;\n /** Fires when the user dismisses via Not Now. */\n onCancel?: () => void;\n /** Title override; defaults to t('paywall.title'). */\n title?: ReactNode;\n /** Description override; defaults to t('paywall.description'). */\n description?: ReactNode;\n /**\n * Stable instance id. Emitted on the dialog content as\n * `data-component-id` and used as the agent-registry instance key so\n * a host can address this specific paywall.\n */\n id?: string;\n className?: string;\n}\n\nexport const FreemiumPaywall = forwardRef<HTMLDivElement, FreemiumPaywallProps>(\n (\n {\n open,\n onOpenChange,\n plans,\n selectedPlanId,\n defaultSelectedPlanId,\n onSelectedPlanChange,\n usage,\n onUpgrade,\n onCancel,\n title,\n description,\n id,\n layout = 'centered',\n density = 'full',\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const titleId = useId();\n const descId = useId();\n\n const [currentSelectedRaw, handleSelectedChange] =\n useControllableState<string>({\n value: selectedPlanId,\n defaultValue: defaultSelectedPlanId ?? plans[0]?.id ?? '',\n onChange: onSelectedPlanChange,\n });\n const currentSelected = currentSelectedRaw ?? '';\n\n const handleCancel = () => {\n onCancel?.();\n onOpenChange(false);\n };\n\n const handleUpgrade = () => {\n if (!currentSelected) return;\n onUpgrade(currentSelected);\n };\n\n const openRef = useRef(open);\n openRef.current = open;\n const selectedRef = useRef<string>(currentSelected);\n selectedRef.current = currentSelected;\n\n const contentRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => contentRef.current as HTMLDivElement, []);\n\n const agentHandle = useMemo<FreemiumPaywallHandle>(\n () => ({\n isOpen: () => openRef.current,\n getSelectedPlanId: () => selectedRef.current || null,\n upgrade: () => handleUpgrade(),\n dismiss: () => handleCancel(),\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n useAgentRegistration(freemiumPaywallAgent, agentHandle, id);\n\n const usagePercent = usage\n ? Math.min(\n 100,\n Math.max(0, (usage.used / Math.max(1, usage.limit)) * 100),\n )\n : 0;\n const usageFull = usage ? usage.used >= usage.limit : false;\n\n return (\n <RadixAlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <RadixAlertDialog.Portal>\n <RadixAlertDialog.Overlay\n className={[\n 'ds:fixed ds:inset-0 ds:z-[var(--z-modal-backdrop)]',\n 'ds:bg-[color:var(--background)]/70',\n 'ds:motion-safe:data-[state=open]:animate-in ds:motion-safe:data-[state=closed]:animate-out',\n 'ds:[.theme-accessible_&]:animate-none',\n ].join(' ')}\n />\n <RadixAlertDialog.Content\n ref={contentRef}\n aria-labelledby={titleId}\n aria-describedby={descId}\n className={contentVariants({ layout, density, className })}\n data-component=\"freemium-paywall\"\n data-component-id={id}\n >\n <RadixAlertDialog.Title id={titleId} asChild>\n <h2 className=\"type-title-card\">{title ?? t('paywall.title')}</h2>\n </RadixAlertDialog.Title>\n <RadixAlertDialog.Description id={descId} asChild>\n <p className=\"ds:mt-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]\">\n {description ?? t('paywall.description')}\n </p>\n </RadixAlertDialog.Description>\n\n {usage ? (\n <div className=\"ds:mt-[var(--spacing-md)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:mb-[var(--spacing-xs)]\">\n {usageFull ? (\n <TriangleAlert\n aria-hidden=\"true\"\n className=\"ds:size-4 ds:text-[color:var(--destructive)]\"\n />\n ) : null}\n <span\n className={[\n 'type-body-sm',\n usageFull\n ? 'ds:text-[color:var(--destructive)]'\n : 'ds:text-[color:var(--muted-foreground)]',\n ].join(' ')}\n >\n {usageFull\n ? t('paywall.usageFull')\n : t('paywall.usageLabel', {\n used: usage.used,\n limit: usage.limit,\n })}\n </span>\n </div>\n <Progress\n value={usagePercent}\n max={100}\n ariaLabel={t('paywall.usageLabel', {\n used: usage.used,\n limit: usage.limit,\n })}\n className={\n usageFull\n ? 'ds:[&_[role=progressbar]>*]:bg-[color:var(--destructive)]'\n : ''\n }\n />\n </div>\n ) : null}\n\n <RadixRadioGroup.Root\n value={currentSelected}\n onValueChange={handleSelectedChange}\n aria-label={t('paywall.title')}\n className=\"ds:mt-[var(--spacing-md)] ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n >\n {plans.map((plan) => {\n // Reuse the payment-form helper — it knows about\n // zero-decimal currencies (JPY, KRW, VND …) and applies\n // the right divisor. Raw `/ 100` would 100× the price in\n // those currencies.\n const formattedPrice = formatPaymentAmount(\n plan.priceAmount,\n plan.currency,\n i18n.language,\n );\n const period = plan.perKey ? t(plan.perKey) : undefined;\n const priceLine = period\n ? t('paywall.pricePer', { price: formattedPrice, period })\n : formattedPrice;\n const planName = t(plan.nameKey);\n return (\n <RadixRadioGroup.Item\n key={plan.id}\n value={plan.id}\n className={[\n 'ds:group ds:relative ds:flex ds:flex-col ds:items-stretch',\n 'ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)] ds:[.theme-accessible_&]:border-2',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]',\n 'ds:text-start ds:bg-[color:var(--card)] ds:text-[color:var(--card-foreground)]',\n 'ds:data-[state=checked]:border-[color:var(--primary)]',\n 'ds:data-[state=checked]:bg-[color:var(--primary)]/5',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n ].join(' ')}\n >\n <span className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <span className=\"ds:font-semibold\">{planName}</span>\n <span className=\"ds:tabular-nums\">{priceLine}</span>\n </span>\n {plan.featuresKeys && plan.featuresKeys.length > 0 ? (\n <ul\n aria-label={t('paywall.features')}\n className=\"ds:mt-[var(--spacing-xs)] ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\"\n >\n {plan.featuresKeys.map((key, i) => (\n <li\n key={i}\n className=\"ds:flex ds:items-start ds:gap-[var(--spacing-xs)] type-body-sm\"\n >\n <Check\n aria-hidden=\"true\"\n className=\"ds:size-4 ds:shrink-0 ds:text-[color:var(--primary)] ds:mt-[1px]\"\n />\n <span>{t(key)}</span>\n </li>\n ))}\n </ul>\n ) : null}\n </RadixRadioGroup.Item>\n );\n })}\n </RadixRadioGroup.Root>\n\n <div className=\"ds:mt-[var(--spacing-lg)] ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:justify-end\">\n <RadixAlertDialog.Cancel asChild>\n <Button intent=\"outline\" onClick={handleCancel}>\n {t('paywall.notNow')}\n </Button>\n </RadixAlertDialog.Cancel>\n <RadixAlertDialog.Action asChild>\n <Button intent=\"primary\" onClick={handleUpgrade}>\n {t('paywall.upgrade')}\n </Button>\n </RadixAlertDialog.Action>\n </div>\n </RadixAlertDialog.Content>\n </RadixAlertDialog.Portal>\n </RadixAlertDialog.Root>\n );\n },\n);\n\nFreemiumPaywall.displayName = 'FreemiumPaywall';\n"],"names":["freemiumPaywallAgent","handle","contentVariants","cva","FreemiumPaywall","forwardRef","open","onOpenChange","plans","selectedPlanId","defaultSelectedPlanId","onSelectedPlanChange","usage","onUpgrade","onCancel","title","description","id","layout","density","className","ref","t","i18n","useTranslation","titleId","useId","descId","currentSelectedRaw","handleSelectedChange","useControllableState","_a","currentSelected","handleCancel","handleUpgrade","openRef","useRef","selectedRef","contentRef","useImperativeHandle","agentHandle","useMemo","useAgentRegistration","usagePercent","usageFull","jsx","RadixAlertDialog","jsxs","TriangleAlert","Progress","RadixRadioGroup","plan","formattedPrice","formatPaymentAmount","period","priceLine","planName","key","i","Check","Button"],"mappings":";;;;;;;;;;;;;AAOO,MAAMA,KAA4D;AAAA,EACvE,IAAI;AAAA,EACJ,cAAc,CAAC,UAAU,SAAS;AAAA,EAClC,OAAO;AAAA,IACL,QAAQ;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/B,UAAAX,EAAE,gBAAgB,GACrB,GACF;AAAA,cACA,gBAAAuB,EAACC,EAAiB,QAAjB,EAAwB,SAAO,IAC9B,UAAA,gBAAAD,EAACe,GAAA,EAAO,QAAO,WAAU,SAAS1B,GAC/B,UAAAZ,EAAE,iBAAiB,GACtB,EAAA,CACF;AAAA,YAAA,EAAA,CACF;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,EAAA,CACF,EAAA,CACF;AAAA,EAEJ;AACF;AAEAlB,GAAgB,cAAc;"}
|
|
@@ -8,7 +8,7 @@ import { C as ie, b as te, a as se } from "./collapsible-CTjxzGuF.js";
|
|
|
8
8
|
import { D as ae } from "./description-list-BsJ_6CQE.js";
|
|
9
9
|
import { P as de } from "./panel-header-D_mTdhUp.js";
|
|
10
10
|
import { u as re } from "./registry-DvAUVLHh.js";
|
|
11
|
-
import { u as ne, F as le, r as oe, P as ce } from "./patient-field-row-
|
|
11
|
+
import { u as ne, F as le, r as oe, P as ce } from "./patient-field-row-DCMkFGqI.js";
|
|
12
12
|
import { C as pe } from "./clipboard-list-rSzfIYZB.js";
|
|
13
13
|
const me = {
|
|
14
14
|
id: "patient-details",
|
|
@@ -368,4 +368,4 @@ export {
|
|
|
368
368
|
ue as P,
|
|
369
369
|
me as p
|
|
370
370
|
};
|
|
371
|
-
//# sourceMappingURL=patient-details-
|
|
371
|
+
//# sourceMappingURL=patient-details-yrgkSeEY.js.map
|