@microsurveysai/react 0.1.13 → 0.1.15
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/index.cjs +61 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
|
|
31
31
|
// src/provider.tsx
|
|
32
32
|
var import_react3 = require("react");
|
|
33
|
-
var
|
|
33
|
+
var import_web_core2 = require("@microsurveysai/web-core");
|
|
34
34
|
|
|
35
35
|
// src/overlayHost.tsx
|
|
36
36
|
var import_react2 = require("react");
|
|
@@ -38,6 +38,7 @@ var import_react_dom = require("react-dom");
|
|
|
38
38
|
|
|
39
39
|
// src/SurveyCard.tsx
|
|
40
40
|
var import_react = require("react");
|
|
41
|
+
var import_web_core = require("@microsurveysai/web-core");
|
|
41
42
|
|
|
42
43
|
// src/questions.tsx
|
|
43
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -122,13 +123,20 @@ function OpenTextInput({ placeholder, maxLength, value, onInput }) {
|
|
|
122
123
|
|
|
123
124
|
// src/SurveyCard.tsx
|
|
124
125
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
125
|
-
var SUCCESS_MS = 1400;
|
|
126
126
|
function SurveyCard({ survey, onClose, modal = true, onMinimize }) {
|
|
127
127
|
const questions = (0, import_react.useMemo)(() => [...survey.questions].sort((a, b) => a.order - b.order), [survey]);
|
|
128
128
|
const dismissible = survey.dismissible !== false;
|
|
129
129
|
const [step, setStep] = (0, import_react.useState)(0);
|
|
130
130
|
const [answers, setAnswers] = (0, import_react.useState)({});
|
|
131
131
|
const [done, setDone] = (0, import_react.useState)(false);
|
|
132
|
+
const thanksTimer = (0, import_react.useRef)(null);
|
|
133
|
+
const thanksRemaining = (0, import_react.useRef)(0);
|
|
134
|
+
const thanksStartedAt = (0, import_react.useRef)(0);
|
|
135
|
+
const thanksResult = (0, import_react.useRef)(null);
|
|
136
|
+
const closed = (0, import_react.useRef)(false);
|
|
137
|
+
(0, import_react.useEffect)(() => () => {
|
|
138
|
+
if (thanksTimer.current) clearTimeout(thanksTimer.current);
|
|
139
|
+
}, []);
|
|
132
140
|
const question = questions[step];
|
|
133
141
|
const isLast = step >= questions.length - 1;
|
|
134
142
|
if (!question) {
|
|
@@ -151,18 +159,48 @@ function SurveyCard({ survey, onClose, modal = true, onMinimize }) {
|
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
function finish() {
|
|
154
|
-
|
|
162
|
+
thanksResult.current = { answers: collected(), completed: true, dismissed: false };
|
|
163
|
+
thanksRemaining.current = (0, import_web_core.thanksDurationMs)(survey.successMessage, survey.successPace);
|
|
155
164
|
setDone(true);
|
|
156
|
-
|
|
165
|
+
startThanksTimer();
|
|
166
|
+
}
|
|
167
|
+
function startThanksTimer() {
|
|
168
|
+
if (closed.current || thanksTimer.current) return;
|
|
169
|
+
thanksStartedAt.current = Date.now();
|
|
170
|
+
thanksTimer.current = setTimeout(closeThanks, Math.max(0, thanksRemaining.current));
|
|
171
|
+
}
|
|
172
|
+
function pauseThanksTimer() {
|
|
173
|
+
if (!thanksTimer.current) return;
|
|
174
|
+
clearTimeout(thanksTimer.current);
|
|
175
|
+
thanksTimer.current = null;
|
|
176
|
+
thanksRemaining.current -= Date.now() - thanksStartedAt.current;
|
|
177
|
+
}
|
|
178
|
+
function closeThanks() {
|
|
179
|
+
if (closed.current || !thanksResult.current) return;
|
|
180
|
+
closed.current = true;
|
|
181
|
+
if (thanksTimer.current) clearTimeout(thanksTimer.current);
|
|
182
|
+
thanksTimer.current = null;
|
|
183
|
+
onClose(thanksResult.current);
|
|
157
184
|
}
|
|
158
185
|
function dismiss() {
|
|
159
186
|
onClose({ answers: collected(), completed: false, dismissed: true });
|
|
160
187
|
}
|
|
161
188
|
if (done) {
|
|
162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: "ms-card ms-thanks",
|
|
193
|
+
role: "dialog",
|
|
194
|
+
"aria-live": "polite",
|
|
195
|
+
onClick: closeThanks,
|
|
196
|
+
onMouseEnter: pauseThanksTimer,
|
|
197
|
+
onMouseLeave: startThanksTimer,
|
|
198
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ms-success", children: [
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ms-success-check", children: "\u2713" }),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ms-success-text", children: (0, import_web_core.thanksMessage)(survey.successMessage) })
|
|
201
|
+
] })
|
|
202
|
+
}
|
|
203
|
+
);
|
|
166
204
|
}
|
|
167
205
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
168
206
|
"div",
|
|
@@ -554,6 +592,8 @@ var CSS2 = `
|
|
|
554
592
|
padding: calc(var(--ms-spacing) * 1.5) var(--ms-spacing);
|
|
555
593
|
text-align: center;
|
|
556
594
|
}
|
|
595
|
+
.ms-thanks { cursor: pointer; }
|
|
596
|
+
.ms-success-text { max-width: 100%; overflow-wrap: anywhere; }
|
|
557
597
|
.ms-success-check {
|
|
558
598
|
width: 44px; height: 44px; border-radius: 50%;
|
|
559
599
|
background: var(--ms-accent); color: var(--ms-accent-text);
|
|
@@ -715,6 +755,9 @@ function OverlayHost({ client }) {
|
|
|
715
755
|
setActive(a);
|
|
716
756
|
});
|
|
717
757
|
}, [client]);
|
|
758
|
+
(0, import_react2.useEffect)(() => {
|
|
759
|
+
active?.shown();
|
|
760
|
+
}, [active]);
|
|
718
761
|
const placement = active && client ? resolvePlacement(active.survey, client.getTheme()) : "bottom";
|
|
719
762
|
const modal = isModalPlacement(placement);
|
|
720
763
|
const origin = unfurlOrigin(placement);
|
|
@@ -845,7 +888,7 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
|
845
888
|
var ClientContext = (0, import_react3.createContext)(null);
|
|
846
889
|
function MicroSurveysProvider({ apiKey, apiBaseURL, refreshOnForeground, appVersion, autoStart = true, children }) {
|
|
847
890
|
const [client] = (0, import_react3.useState)(
|
|
848
|
-
() => typeof window === "undefined" ? null : (0,
|
|
891
|
+
() => typeof window === "undefined" ? null : (0, import_web_core2.createClient)({ apiKey, apiBaseURL, refreshOnForeground, appVersion })
|
|
849
892
|
);
|
|
850
893
|
(0, import_react3.useEffect)(() => {
|
|
851
894
|
if (!client) return;
|
|
@@ -881,19 +924,25 @@ function MicroSurvey({ surveyId, onComplete }) {
|
|
|
881
924
|
const client = useMicroSurveysClient();
|
|
882
925
|
const [survey, setSurvey] = (0, import_react4.useState)(null);
|
|
883
926
|
const [closed, setClosed] = (0, import_react4.useState)(false);
|
|
884
|
-
const
|
|
927
|
+
const showing = (0, import_react4.useRef)(null);
|
|
885
928
|
(0, import_react4.useEffect)(() => {
|
|
886
929
|
if (!client) return;
|
|
887
930
|
setSurvey(client.getSurvey(surveyId) ?? null);
|
|
888
931
|
return client.onConfigChange(() => setSurvey(client.getSurvey(surveyId) ?? null));
|
|
889
932
|
}, [client, surveyId]);
|
|
933
|
+
const visible = !!client && !!survey && !closed;
|
|
934
|
+
if (visible && (!showing.current || showing.current.survey.id !== survey.id)) {
|
|
935
|
+
showing.current = client.presentInline(survey);
|
|
936
|
+
}
|
|
937
|
+
(0, import_react4.useEffect)(() => {
|
|
938
|
+
if (visible) showing.current?.shown();
|
|
939
|
+
}, [visible, survey]);
|
|
890
940
|
if (!client || !survey || closed) return null;
|
|
891
941
|
ensureStyles();
|
|
892
|
-
if (!shownAt.current) shownAt.current = /* @__PURE__ */ new Date();
|
|
893
942
|
const { vars, googleFont } = resolveTheme(client.getTheme());
|
|
894
943
|
ensureGoogleFont(googleFont);
|
|
895
944
|
function close(result) {
|
|
896
|
-
|
|
945
|
+
showing.current?.close(result);
|
|
897
946
|
setClosed(true);
|
|
898
947
|
onComplete?.(result);
|
|
899
948
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/provider.tsx","../src/overlayHost.tsx","../src/SurveyCard.tsx","../src/questions.tsx","../src/theme.ts","../src/styles.ts","../src/motion.ts","../src/MicroSurvey.tsx"],"sourcesContent":["//\n// @microsurveysai/react\n//\n// React SDK for MicroSurveys. Wrap your app in <MicroSurveysProvider>, fire\n// events with useMicroSurveys().track(), and auto-triggered surveys present\n// themselves. Embed a specific survey with <MicroSurvey surveyId>.\n//\n// <MicroSurveysProvider apiKey=\"ms_live_…\">\n// <App />\n// </MicroSurveysProvider>\n//\n// const { track, identify } = useMicroSurveys();\n// track(\"checkout_completed\", { plan: \"pro\" });\n//\n\nexport { MicroSurveysProvider, useMicroSurveys, useMicroSurveysClient } from \"./provider\";\nexport type { MicroSurveysProviderProps } from \"./provider\";\nexport { MicroSurvey } from \"./MicroSurvey\";\nexport type { MicroSurveyProps } from \"./MicroSurvey\";\n\n// Re-export the common wire types so consumers don't need a second import.\nexport type { Survey, Question, SurveyResult, SurveyAnswer, AnswerValue, ProjectTheme } from \"@microsurveysai/web-core\";\n","//\n// provider.tsx\n//\n// `<MicroSurveysProvider>` creates the client, starts it, exposes it via context,\n// and mounts the overlay host that renders auto-triggered surveys. Port of the\n// wiring in iOS `MicroSurveysSDK.init` + lifecycle.\n//\n\n\"use client\";\n\nimport { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { createClient, type MicroSurveysClient } from \"@microsurveysai/web-core\";\nimport { OverlayHost } from \"./overlayHost\";\nimport { ensureStyles } from \"./styles\";\n\nconst ClientContext = createContext<MicroSurveysClient | null>(null);\n\nexport interface MicroSurveysProviderProps {\n /** Project API key (`ms_live_…` / `ms_test_…`). Browser-embeddable. */\n apiKey: string;\n /** Override the API base for self-hosted deployments. Defaults to https://console.microsurveys.ai. */\n apiBaseURL?: string;\n /** Refresh config on tab foreground. Default true. */\n refreshOnForeground?: boolean;\n /** Your app's version (e.g. \"3.2.0\"), sent with responses so results can be compared across releases. */\n appVersion?: string;\n /** Start automatically on mount. Default true. */\n autoStart?: boolean;\n children?: React.ReactNode;\n}\n\nexport function MicroSurveysProvider({ apiKey, apiBaseURL, refreshOnForeground, appVersion, autoStart = true, children }: MicroSurveysProviderProps) {\n // Lazily create the client on the client only (localStorage/crypto are guarded,\n // but there's no reason to build one during SSR).\n const [client] = useState<MicroSurveysClient | null>(() =>\n typeof window === \"undefined\" ? null : createClient({ apiKey, apiBaseURL, refreshOnForeground, appVersion }),\n );\n\n useEffect(() => {\n if (!client) return;\n ensureStyles();\n if (autoStart) client.start();\n return () => client.stop();\n }, [client, autoStart]);\n\n return (\n <ClientContext.Provider value={client}>\n {children}\n <OverlayHost client={client} />\n </ClientContext.Provider>\n );\n}\n\n/** The raw client (or null before mount). Prefer `useMicroSurveys` for events. */\nexport function useMicroSurveysClient(): MicroSurveysClient | null {\n return useContext(ClientContext);\n}\n\n/** Event + identity helpers bound to the provider's client. Safe no-ops if\n * called outside a provider / before mount. */\nexport function useMicroSurveys() {\n const client = useContext(ClientContext);\n return useMemo(\n () => ({\n client,\n track: (name: string, properties?: Record<string, unknown>) => client?.track(name, properties),\n identify: (userId: string | null | undefined, properties?: Record<string, unknown>) => client?.identify(userId, properties),\n refresh: () => client?.refreshConfig(),\n }),\n [client],\n );\n}\n\nexport { ClientContext };\n","//\n// overlayHost.tsx\n//\n// Subscribes to the client's `onPresent` and renders one auto-triggered survey\n// at a time, portalled to document.body. Where it sits comes from the survey's\n// (else the project theme's) web placement:\n//\n// - \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\": a card floating\n// in that corner. The page stays visible and usable behind it.\n// - \"bottom\" | \"center\": the modal bottom sheet or centered dialog, over a\n// dimmed page (the iOS `Presenter` look).\n//\n// A survey can also start minimized: a small launcher pill showing the first\n// question, which opens the survey on click. An open survey with a launcher can\n// be minimized again. Answers are kept while it's minimized. Opening and minimizing \"unfurl\": the\n// card grows out of the launcher's corner and folds back into it (see motion.ts).\n//\n\n\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { ActiveSurvey, MicroSurveysClient, SurveyResult } from \"@microsurveysai/web-core\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, resolvePlacement, resolveLauncher, isModalPlacement, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\nimport { cardIn, cardOut, launcherIn, launcherOut, scrimIn, scrimOut, stopMotion, unfurlOrigin } from \"./motion\";\n\n// Layout effect in the browser (the transition must start before paint), plain effect during SSR.\nconst useBrowserLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function OverlayHost({ client }: { client: MicroSurveysClient | null }) {\n const [active, setActive] = useState<ActiveSurvey | null>(null);\n // Whether this survey has a launcher at all, and whether it's minimized to it right now.\n const [launcher, setLauncher] = useState(false);\n const [minimized, setMinimized] = useState(false);\n // The launcher outlives `minimized` on both sides: it appears as the card starts folding away,\n // and leaves only once its own exit has played.\n const [showLauncher, setShowLauncher] = useState(false);\n // After the first open or minimize the CSS entrance animations are switched off, so they don't\n // replay each time the card is shown again; the unfurl transition takes over.\n const [moved, setMoved] = useState(false);\n const [motionSeq, setMotionSeq] = useState(0);\n const pendingMotion = useRef<\"open\" | \"minimize\" | null>(null);\n const minimizing = useRef(false);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const launcherRef = useRef<HTMLButtonElement | null>(null);\n const launcherWrapRef = useRef<HTMLDivElement | null>(null);\n // Only move focus after the visitor opens or minimizes; never steal it when a survey first appears.\n const toggled = useRef(false);\n\n useEffect(() => {\n if (!client) return;\n return client.onPresent((a) => {\n const withLauncher = resolveLauncher(a.survey, client.getTheme());\n toggled.current = false;\n pendingMotion.current = null;\n minimizing.current = false;\n setLauncher(withLauncher);\n setMinimized(withLauncher);\n setShowLauncher(withLauncher);\n setMoved(false);\n setActive(a);\n });\n }, [client]);\n\n const placement = active && client ? resolvePlacement(active.survey, client.getTheme()) : \"bottom\";\n const modal = isModalPlacement(placement);\n const origin = unfurlOrigin(placement);\n\n // Plays the transition requested by open()/minimize() once React has rendered both ends of it.\n useBrowserLayoutEffect(() => {\n const kind = pendingMotion.current;\n if (!kind) return;\n pendingMotion.current = null;\n const card = panelRef.current?.querySelector(\".ms-card\");\n const scrim = modal ? panelRef.current : null;\n const wrap = launcherWrapRef.current;\n stopMotion(card, scrim, wrap);\n const ignoreStop = () => {};\n if (kind === \"open\") {\n minimizing.current = false;\n void cardIn(card, origin).catch(ignoreStop);\n void scrimIn(scrim).catch(ignoreStop);\n launcherOut(wrap, origin).then(() => setShowLauncher(false), ignoreStop);\n } else {\n void launcherIn(wrap, origin).catch(ignoreStop);\n Promise.all([cardOut(card, origin), scrimOut(scrim)]).then(() => {\n minimizing.current = false;\n setMinimized(true);\n }, ignoreStop);\n }\n }, [motionSeq, modal, origin]);\n\n // Escape: a modal survey listens page-wide (it holds focus); a floating card only reacts while\n // focus is inside it (see onKeyDown below), so it never swallows the host app's Escape.\n useEffect(() => {\n if (!active || !modal || minimized) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") escape();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active, modal, minimized, launcher]);\n\n // After opening, move focus into the card; after minimizing, back to the launcher.\n useEffect(() => {\n if (!active || !toggled.current) return;\n if (minimized) launcherRef.current?.focus();\n else panelRef.current?.querySelector<HTMLElement>(\".ms-card\")?.focus();\n }, [active, minimized]);\n\n if (!active || !client || typeof document === \"undefined\") return null;\n\n ensureStyles();\n const theme = client.getTheme();\n const { vars, googleFont } = resolveTheme(theme);\n ensureGoogleFont(googleFont);\n const dismissible = active.survey.dismissible !== false;\n const firstPrompt = [...active.survey.questions].sort((a, b) => a.order - b.order)[0]?.prompt ?? active.survey.name;\n\n function close(result: SurveyResult) {\n active!.close(result);\n setActive(null);\n }\n\n function dismiss() {\n close({ answers: [], completed: false, dismissed: true });\n }\n\n // The card stays visible while it folds away; `minimized` flips once that has played.\n function minimize() {\n if (minimized || minimizing.current) return;\n minimizing.current = true;\n toggled.current = true;\n pendingMotion.current = \"minimize\";\n setMoved(true);\n setShowLauncher(true);\n setMotionSeq((n) => n + 1);\n }\n\n function open() {\n toggled.current = true;\n pendingMotion.current = \"open\";\n setMoved(true);\n setMinimized(false);\n setMotionSeq((n) => n + 1);\n }\n\n // Escape or a scrim click: back to the launcher when there is one, else dismiss (if allowed).\n function escape() {\n if (launcher) minimize();\n else if (dismissible) dismiss();\n }\n\n function onScrimClick(e: React.MouseEvent) {\n if (e.target === e.currentTarget) escape();\n }\n\n function onFloatKey(e: React.KeyboardEvent) {\n if (e.key === \"Escape\") {\n e.stopPropagation();\n escape();\n }\n }\n\n // The card stays mounted while minimized (hidden), so answers survive minimize → open.\n const card = (\n <SurveyCard survey={active.survey} onClose={close} modal={modal} onMinimize={launcher ? minimize : undefined} />\n );\n\n return createPortal(\n <div className={moved ? \"ms-root ms-moved\" : \"ms-root\"} style={vars}>\n {modal ? (\n <div\n ref={panelRef}\n className={`ms-scrim ${placement === \"center\" ? \"ms-dialog\" : \"ms-sheet\"}`}\n onClick={onScrimClick}\n hidden={minimized}\n >\n {card}\n </div>\n ) : (\n <div ref={panelRef} className={`ms-float ms-at-${placement}`} onKeyDown={onFloatKey} hidden={minimized}>\n {card}\n </div>\n )}\n {showLauncher && (\n // Modal placements dock their launcher bottom-center; corners keep their corner.\n <div ref={launcherWrapRef} className={`ms-launcher-wrap ms-at-${modal ? \"bottom\" : placement}`}>\n <button\n ref={launcherRef}\n type=\"button\"\n className=\"ms-launcher\"\n onClick={open}\n aria-label={`Open survey: ${firstPrompt}`}\n aria-haspopup=\"dialog\"\n >\n <svg className=\"ms-launcher-icon\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" aria-hidden=\"true\">\n <path\n fill=\"currentColor\"\n d=\"M12 3C6.48 3 2 6.92 2 11.75c0 2.47 1.17 4.7 3.06 6.29L4.3 21.3a.5.5 0 0 0 .7.56l3.9-1.86c.98.27 2.02.4 3.1.4 5.52 0 10-3.92 10-8.75S17.52 3 12 3Z\"\n />\n </svg>\n <span className=\"ms-launcher-label\">{firstPrompt}</span>\n </button>\n {dismissible && (\n <button type=\"button\" className=\"ms-launcher-close\" aria-label=\"Dismiss survey\" onClick={dismiss}>\n ✕\n </button>\n )}\n </div>\n )}\n </div>,\n document.body,\n );\n}\n","//\n// SurveyCard.tsx\n//\n// The multi-step survey host — renders `.ms-card` with the current question,\n// enforces `required`, supports partial submit, a success message, and\n// `dismissible:false`. Port of iOS `SurveyViewController`. The caller wraps this\n// in the themed `.ms-root` (+ scrim for overlays, plain for inline).\n//\n\nimport { useMemo, useState } from \"react\";\nimport type { AnswerValue, Survey, SurveyAnswer, SurveyResult } from \"@microsurveysai/web-core\";\nimport { QuestionInput, isAnswered } from \"./questions\";\n\nexport interface SurveyCardProps {\n survey: Survey;\n /** Called exactly once when the card closes (completed, partial, or dismissed). */\n onClose: (result: SurveyResult) => void;\n /** Whether the card is a modal dialog over a dimmed page (default) or floats beside the page. */\n modal?: boolean;\n /** When set, the card shows a minimize button that calls it (back to the launcher). */\n onMinimize?: () => void;\n}\n\nconst SUCCESS_MS = 1400;\n\nexport function SurveyCard({ survey, onClose, modal = true, onMinimize }: SurveyCardProps) {\n const questions = useMemo(() => [...survey.questions].sort((a, b) => a.order - b.order), [survey]);\n const dismissible = survey.dismissible !== false;\n\n const [step, setStep] = useState(0);\n const [answers, setAnswers] = useState<Record<string, AnswerValue>>({});\n const [done, setDone] = useState(false);\n\n const question = questions[step];\n const isLast = step >= questions.length - 1;\n\n // Empty survey (misconfigured) — nothing to render; close as dismissed.\n if (!question) {\n return null;\n }\n\n const current = answers[question.id];\n const canAdvance = !question.required || isAnswered(current);\n\n function collected(): SurveyAnswer[] {\n return questions.filter((q) => answers[q.id] !== undefined).map((q) => ({ questionId: q.id, value: answers[q.id]! }));\n }\n\n function setAnswer(value: AnswerValue) {\n setAnswers((prev) => ({ ...prev, [question!.id]: value }));\n }\n\n function advance() {\n if (!canAdvance) return;\n if (isLast) {\n finish();\n } else {\n setStep((s) => s + 1);\n }\n }\n\n function finish() {\n const result: SurveyResult = { answers: collected(), completed: true, dismissed: false };\n setDone(true);\n setTimeout(() => onClose(result), SUCCESS_MS);\n }\n\n function dismiss() {\n onClose({ answers: collected(), completed: false, dismissed: true });\n }\n\n if (done) {\n return (\n <div className=\"ms-card\" role=\"dialog\" aria-live=\"polite\">\n <div className=\"ms-success\">\n <span className=\"ms-success-check\">✓</span>\n <span>{survey.successMessage ?? \"Thanks for your feedback!\"}</span>\n </div>\n </div>\n );\n }\n\n return (\n <div\n className={onMinimize ? \"ms-card ms-has-min\" : \"ms-card\"}\n role=\"dialog\"\n aria-modal={modal ? \"true\" : \"false\"}\n aria-label={survey.name}\n tabIndex={-1}\n >\n {onMinimize && (\n <button\n type=\"button\"\n className={dismissible ? \"ms-close ms-minimize\" : \"ms-close\"}\n aria-label=\"Minimize\"\n onClick={onMinimize}\n >\n <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" aria-hidden=\"true\">\n <path d=\"M5 12h14\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n {dismissible && (\n <button type=\"button\" className=\"ms-close\" aria-label=\"Close\" onClick={dismiss}>\n ✕\n </button>\n )}\n {questions.length > 1 && (\n <p className=\"ms-progress\">\n {step + 1} of {questions.length}\n </p>\n )}\n <h2 className=\"ms-prompt\">{question.prompt}</h2>\n <QuestionInput question={question} value={current} onChange={setAnswer} />\n <div className=\"ms-footer\">\n <button type=\"button\" className=\"ms-btn\" disabled={!canAdvance} onClick={advance}>\n {isLast ? \"Submit\" : \"Next\"}\n </button>\n </div>\n </div>\n );\n}\n","//\n// questions.tsx\n//\n// One renderer per question type, ported from the iOS UI/*View.swift files. Each\n// takes the question, the current answer value, and an `onChange`, and emits the\n// exact `AnswerValue` JSON shape the backend expects (API-CONTRACT §Answer value\n// shapes). Styling is entirely via the `.ms-*` classes + theme CSS variables.\n//\n\nimport type { AnswerValue, Question } from \"@microsurveysai/web-core\";\nimport type { CSSProperties } from \"react\";\n\nexport interface QuestionInputProps {\n question: Question;\n value: AnswerValue | undefined;\n onChange: (value: AnswerValue) => void;\n}\n\nexport function QuestionInput({ question, value, onChange }: QuestionInputProps) {\n const cfg = question.config;\n switch (cfg.kind) {\n case \"scale\":\n return <ScaleInput min={cfg.min} max={cfg.max} minLabel={cfg.minLabel} maxLabel={cfg.maxLabel} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"stars\":\n return <StarsInput count={cfg.count} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"emoji\":\n return <EmojiInput options={cfg.options} value={strValue(value)} onPick={(v) => onChange({ value: v })} />;\n case \"thumbs\":\n return <ThumbsInput value={strValue(value)} onPick={(v) => onChange({ value: v as \"up\" | \"down\" })} />;\n case \"singleChoice\":\n return <ChoiceInput options={cfg.options} value={value && \"choice\" in value ? value.choice : undefined} onPick={(v) => onChange({ choice: v })} />;\n case \"openText\":\n return <OpenTextInput placeholder={cfg.placeholder} maxLength={cfg.maxLength} value={value && \"text\" in value ? value.text : \"\"} onInput={(t) => onChange({ text: t })} />;\n }\n}\n\n/** True when an answer value counts as \"provided\" (for required-gating). */\nexport function isAnswered(value: AnswerValue | undefined): boolean {\n if (!value) return false;\n if (\"text\" in value) return value.text.trim().length > 0;\n return true;\n}\n\n// ── helpers to read the current value regardless of union branch ──────────────\nfunction numValue(v: AnswerValue | undefined): number | undefined {\n return v && \"value\" in v && typeof v.value === \"number\" ? v.value : undefined;\n}\nfunction strValue(v: AnswerValue | undefined): string | undefined {\n return v && \"value\" in v && typeof v.value === \"string\" ? v.value : undefined;\n}\n\n// ── Scale (NPS / CES) ─────────────────────────────────────────────────────────\nfunction ScaleInput({ min, max, minLabel, maxLabel, value, onPick }: { min: number; max: number; minLabel?: string; maxLabel?: string; value: number | undefined; onPick: (n: number) => void }) {\n const points: number[] = [];\n for (let i = min; i <= max; i++) points.push(i);\n // Short scales (CES 1–7) sit on one row of equal chips, like the mobile SDKs; longer ones (NPS 0–10)\n // wrap into centered rows of fixed-size chips.\n const oneRow = points.length <= 7;\n return (\n <div>\n <div\n className={oneRow ? \"ms-scale ms-scale-row\" : \"ms-scale ms-scale-wrap\"}\n role=\"group\"\n style={oneRow ? ({ \"--ms-scale-n\": points.length } as CSSProperties) : undefined}\n >\n {points.map((n) => (\n <button key={n} type=\"button\" className=\"ms-chip\" aria-pressed={value === n} onClick={() => onPick(n)}>\n {n}\n </button>\n ))}\n </div>\n {(minLabel || maxLabel) && (\n <div className=\"ms-endlabels\">\n <span>{minLabel}</span>\n <span>{maxLabel}</span>\n </div>\n )}\n </div>\n );\n}\n\n// ── Stars ─────────────────────────────────────────────────────────────────────\nfunction StarsInput({ count, value, onPick }: { count: number; value: number | undefined; onPick: (n: number) => void }) {\n const stars: number[] = [];\n for (let i = 1; i <= count; i++) stars.push(i);\n return (\n <div className=\"ms-stars\" role=\"group\">\n {stars.map((n) => (\n <button key={n} type=\"button\" className={`ms-star${value !== undefined && n <= value ? \" ms-on\" : \"\"}`} aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`} aria-pressed={value === n} onClick={() => onPick(n)}>\n ★\n </button>\n ))}\n </div>\n );\n}\n\n// ── Emoji ─────────────────────────────────────────────────────────────────────\nfunction EmojiInput({ options, value, onPick }: { options: { value: string; emoji: string; label?: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-emoji-row\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-emoji\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n <span className=\"ms-emoji-glyph\">{o.emoji}</span>\n {o.label && <span className=\"ms-emoji-label\">{o.label}</span>}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Thumbs ────────────────────────────────────────────────────────────────────\nfunction ThumbsInput({ value, onPick }: { value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-thumbs\" role=\"group\">\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs up\" aria-pressed={value === \"up\"} onClick={() => onPick(\"up\")}>\n 👍\n </button>\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs down\" aria-pressed={value === \"down\"} onClick={() => onPick(\"down\")}>\n 👎\n </button>\n </div>\n );\n}\n\n// ── Single choice ─────────────────────────────────────────────────────────────\nfunction ChoiceInput({ options, value, onPick }: { options: { value: string; label: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-choices\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-choice\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n {o.label}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Open text ─────────────────────────────────────────────────────────────────\nfunction OpenTextInput({ placeholder, maxLength, value, onInput }: { placeholder?: string; maxLength?: number; value: string; onInput: (t: string) => void }) {\n return (\n <div>\n <textarea className=\"ms-textarea\" placeholder={placeholder} maxLength={maxLength} value={value} onChange={(e) => onInput(e.target.value)} />\n {maxLength !== undefined && (\n <div className=\"ms-counter\">\n {value.length} / {maxLength}\n </div>\n )}\n </div>\n );\n}\n","//\n// theme.ts\n//\n// Maps a project `ProjectTheme` (from /api/sdk/config) onto CSS custom\n// properties consumed by the survey stylesheet, applying the same clean,\n// neutral defaults as the iOS `SurveyTheme.default` (indigo accent, zinc grays).\n// Also injects a Google Fonts <link> when the theme names a curated font.\n//\n// Dark-mode-aware palettes are a follow-up; for now the defaults are the\n// light-mode values and any theme key overrides them.\n//\n\nimport type { CSSProperties } from \"react\";\nimport type { ProjectTheme, Survey, WebPlacement } from \"@microsurveysai/web-core\";\n\n/** iOS `SurveyTheme.default` light-mode palette + metrics. */\nconst DEFAULTS = {\n scrim: \"rgba(9, 9, 11, 0.45)\",\n surface: \"#FFFFFF\",\n text: \"#18181B\",\n secondaryText: \"#71717A\",\n accent: \"#2E7272\", // Slate Teal (brand primary)\n accentText: \"#FFFFFF\",\n border: \"#E4E4E7\",\n track: \"#F4F4F5\",\n cardRadius: 16,\n controlRadius: 12,\n controlHeight: 48,\n spacing: 16,\n textScale: 1,\n titleSize: 20,\n titleWeight: \"semibold\",\n titleLineHeight: 1.1,\n titleLetterSpacing: 0,\n};\n\nconst WEIGHTS: Record<string, number> = { regular: 400, medium: 500, semibold: 600, bold: 700 };\n\nconst CURATED_FONTS = new Set([\"Inter\", \"Roboto\", \"Open Sans\", \"Noto Sans\", \"Lato\", \"Montserrat\", \"Poppins\"]);\n\nexport interface ResolvedTheme {\n /** CSS custom properties to spread onto the survey root's `style`. */\n vars: CSSProperties;\n /** A curated Google font family to lazy-load, or null for the system font. */\n googleFont: string | null;\n}\n\nfunction px(n: number): string {\n return `${n}px`;\n}\n\nconst COLOR_FN = /^(rgb|rgba|hsl|hsla)\\(\\s*[-+0-9.,%\\s/]*\\)$/i;\n\n/**\n * A theme string is used only if it can't make the browser fetch anything or break out of its\n * CSS value: no url()/image-set()/var() (plain rgb()/hsl() colors are fine), no CSS punctuation,\n * quotes or backslashes. Anything else falls back to the default for that key.\n */\nfunction safe(v: string | undefined): string | undefined {\n if (typeof v !== \"string\" || v.length > 100) return undefined;\n if (/[;:{}<>\"'`\\\\@!]/.test(v)) return undefined;\n if (v.includes(\"(\") || v.includes(\")\")) return COLOR_FN.test(v.trim()) ? v : undefined;\n return v;\n}\n\n/** A finite number kept within [lo, hi], or undefined. */\nfunction bounded(n: number | null | undefined, lo: number, hi: number): number | undefined {\n return typeof n === \"number\" && Number.isFinite(n) ? Math.min(Math.max(n, lo), hi) : undefined;\n}\n\nexport function resolveTheme(theme: ProjectTheme | null | undefined): ResolvedTheme {\n const raw = theme ?? {};\n // Same bounds the server applies before sending the theme; real themes sit well inside them.\n const t: ProjectTheme = {\n ...raw,\n accent: safe(raw.accent),\n accentText: safe(raw.accentText),\n surface: safe(raw.surface),\n text: safe(raw.text),\n secondaryText: safe(raw.secondaryText),\n border: safe(raw.border),\n font: safe(raw.font),\n cornerRadius: bounded(raw.cornerRadius, 0, 200),\n controlRadius: bounded(raw.controlRadius, 0, 200),\n controlHeight: bounded(raw.controlHeight, 16, 200),\n spacing: bounded(raw.spacing, 0, 200),\n textScale: bounded(raw.textScale, 0.25, 4),\n titleSize: bounded(raw.titleSize, 6, 120),\n titleLineHeight: bounded(raw.titleLineHeight, 0.5, 5),\n titleLetterSpacing: bounded(raw.titleLetterSpacing, -50, 50),\n };\n const controlHeight = t.controlHeight ?? DEFAULTS.controlHeight;\n const controlRadius = t.controlPill ? controlHeight / 2 : (t.controlRadius ?? DEFAULTS.controlRadius);\n const cardRadius = t.cornerRadius ?? DEFAULTS.cardRadius;\n const titleWeight = WEIGHTS[t.titleWeight ?? DEFAULTS.titleWeight] ?? 600;\n\n const font = t.font && t.font !== \"system\" && t.font.length > 0 ? t.font : null;\n const googleFont = font && CURATED_FONTS.has(font) ? font : null;\n const fontFamily = font\n ? `'${font}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`\n : \"system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\";\n\n // CSS custom properties. Cast through a record since `--x` keys aren't in CSSProperties.\n const vars = {\n \"--ms-scrim\": DEFAULTS.scrim,\n \"--ms-surface\": t.surface ?? DEFAULTS.surface,\n \"--ms-text\": t.text ?? DEFAULTS.text,\n \"--ms-secondary-text\": t.secondaryText ?? DEFAULTS.secondaryText,\n \"--ms-accent\": t.accent ?? DEFAULTS.accent,\n \"--ms-accent-text\": t.accentText ?? DEFAULTS.accentText,\n \"--ms-border\": t.border ?? DEFAULTS.border,\n \"--ms-track\": DEFAULTS.track,\n \"--ms-card-radius\": px(cardRadius),\n \"--ms-control-radius\": px(controlRadius),\n \"--ms-control-height\": px(controlHeight),\n \"--ms-spacing\": px(t.spacing ?? DEFAULTS.spacing),\n \"--ms-text-scale\": String(t.textScale ?? DEFAULTS.textScale),\n \"--ms-title-size\": px(t.titleSize ?? DEFAULTS.titleSize),\n \"--ms-title-weight\": String(titleWeight),\n \"--ms-title-line-height\": String(t.titleLineHeight ?? DEFAULTS.titleLineHeight),\n \"--ms-title-letter-spacing\": px(t.titleLetterSpacing ?? DEFAULTS.titleLetterSpacing),\n \"--ms-font\": fontFamily,\n \"--ms-align\": t.alignment === \"center\" ? \"center\" : \"left\",\n } as CSSProperties;\n\n return { vars, googleFont };\n}\n\nconst PLACEMENTS: readonly WebPlacement[] = [\"bottom-right\", \"bottom-left\", \"top-right\", \"top-left\", \"bottom\", \"center\"];\n\nfunction asPlacement(v: unknown): WebPlacement | null {\n return typeof v === \"string\" && (PLACEMENTS as readonly string[]).includes(v) ? (v as WebPlacement) : null;\n}\n\n/**\n * Where the card sits: the survey's `webPlacement`, else the project theme's, else what the\n * survey's `presentation` gives it (a dialog is centered; a sheet, or nothing, docks to the bottom\n * the way the mobile SDKs show it, with the theme `position` as the last word).\n */\nexport function resolvePlacement(survey: Pick<Survey, \"webPlacement\" | \"presentation\">, theme: ProjectTheme | null | undefined): WebPlacement {\n const placed = asPlacement(survey.webPlacement) ?? asPlacement(theme?.webPlacement);\n if (placed) return placed;\n if (survey.presentation === \"dialog\") return \"center\";\n if (survey.presentation === \"sheet\") return \"bottom\";\n return theme?.position === \"center\" ? \"center\" : \"bottom\";\n}\n\n/** Corners float over the page; bottom and center are modal (dimmed page, focus held). */\nexport function isModalPlacement(p: WebPlacement): boolean {\n return p === \"bottom\" || p === \"center\";\n}\n\n/** Whether the survey starts minimized as a launcher: the survey's choice, else the theme's. */\nexport function resolveLauncher(survey: Pick<Survey, \"webLauncher\">, theme: ProjectTheme | null | undefined): boolean {\n if (typeof survey.webLauncher === \"boolean\") return survey.webLauncher;\n return theme?.webLauncher === true;\n}\n\n/** Lazily inject a Google Fonts stylesheet for a curated family (once). */\nexport function ensureGoogleFont(family: string | null): void {\n if (!family || typeof document === \"undefined\") return;\n const id = `ms-font-${family.replace(/\\s+/g, \"-\").toLowerCase()}`;\n if (document.getElementById(id)) return;\n const link = document.createElement(\"link\");\n link.id = id;\n link.rel = \"stylesheet\";\n link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family)}:wght@400;500;600;700&display=swap`;\n document.head.appendChild(link);\n}\n","//\n// styles.ts\n//\n// One self-contained stylesheet, injected once, scoped under `.ms-root`. It\n// reads the CSS custom properties set by `resolveTheme`, so every visual knob is\n// theme-driven. No Tailwind, no external CSS — safe to drop into any host app.\n//\n\nconst STYLE_ID = \"microsurveys-styles\";\n\nconst CSS = `\n.ms-root, .ms-root * { box-sizing: border-box; }\n.ms-root [hidden] { display: none !important; }\n.ms-root {\n font-family: var(--ms-font);\n color: var(--ms-text);\n text-align: var(--ms-align);\n -webkit-font-smoothing: antialiased;\n}\n\n/* ── Overlay ─────────────────────────────────────────────── */\n.ms-scrim {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; padding: var(--ms-spacing);\n background: var(--ms-scrim);\n animation: ms-fade 160ms ease-out;\n}\n.ms-scrim.ms-sheet { align-items: flex-end; justify-content: center; }\n.ms-scrim.ms-dialog { align-items: center; justify-content: center; }\n\n.ms-card {\n position: relative; width: 100%; max-width: 480px;\n background: var(--ms-surface);\n border-radius: var(--ms-card-radius);\n border: 1px solid var(--ms-border);\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.18);\n padding: calc(var(--ms-spacing) * 1.5);\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-card:focus { outline: none; }\n/* Once the visitor has opened or minimized, transitions come from motion.ts, not these entrances. */\n.ms-moved .ms-scrim, .ms-moved .ms-card, .ms-moved .ms-launcher-wrap { animation: none; }\n\n/* Floating card: pinned to a corner, no scrim, the page stays usable. */\n.ms-float {\n position: fixed; z-index: 2147483000;\n width: min(380px, calc(100vw - 40px));\n}\n.ms-float .ms-card {\n max-width: none; max-height: calc(100vh - 40px); overflow-y: auto;\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.22);\n}\n.ms-float.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-float.ms-at-bottom-left { left: 20px; bottom: 20px; }\n.ms-float.ms-at-top-right { right: 20px; top: 20px; }\n.ms-float.ms-at-top-left { left: 20px; top: 20px; }\n.ms-float.ms-at-top-right .ms-card, .ms-float.ms-at-top-left .ms-card { animation-name: ms-drop; }\n\n/* Launcher: the minimized survey, a pill in the accent color. */\n.ms-launcher-wrap {\n position: fixed; z-index: 2147483000;\n display: flex; align-items: center; gap: 8px;\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-launcher-wrap.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-launcher-wrap.ms-at-bottom-left { left: 20px; bottom: 20px; flex-direction: row-reverse; }\n.ms-launcher-wrap.ms-at-top-right { right: 20px; top: 20px; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-top-left { left: 20px; top: 20px; flex-direction: row-reverse; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-bottom {\n left: 0; right: 0; bottom: 20px; justify-content: center; pointer-events: none;\n}\n.ms-launcher-wrap.ms-at-bottom > * { pointer-events: auto; }\n.ms-launcher {\n display: inline-flex; align-items: center; gap: 8px;\n height: 44px; padding: 0 18px; max-width: min(320px, calc(100vw - 96px));\n border: none; border-radius: 22px; cursor: pointer;\n background: var(--ms-accent); color: var(--ms-accent-text);\n font: inherit; font-size: calc(14px * var(--ms-text-scale)); font-weight: 600;\n box-shadow: 0 8px 24px rgba(9, 9, 11, 0.22);\n transition: transform 120ms, box-shadow 120ms;\n}\n.ms-launcher:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(9, 9, 11, 0.26); }\n.ms-launcher:focus-visible, .ms-launcher-close:focus-visible {\n outline: 2px solid var(--ms-accent); outline-offset: 2px;\n}\n.ms-launcher-icon { flex: none; }\n.ms-launcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ms-launcher-close {\n flex: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;\n border: 1px solid var(--ms-border); background: var(--ms-surface); color: var(--ms-secondary-text);\n font-size: 12px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;\n box-shadow: 0 4px 12px rgba(9, 9, 11, 0.12);\n}\n.ms-launcher-close:hover { color: var(--ms-text); }\n\n/* Phones: a corner card spans the width, still on its edge. */\n@media (max-width: 520px) {\n .ms-float { width: auto; }\n .ms-float.ms-at-bottom-right, .ms-float.ms-at-bottom-left { left: 12px; right: 12px; bottom: 12px; }\n .ms-float.ms-at-top-right, .ms-float.ms-at-top-left { left: 12px; right: 12px; top: 12px; }\n .ms-float .ms-card { max-height: calc(100vh - 24px); }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-bottom-left { bottom: 12px; }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-top-right { right: 12px; }\n .ms-launcher-wrap.ms-at-bottom-left, .ms-launcher-wrap.ms-at-top-left { left: 12px; }\n .ms-launcher-wrap.ms-at-top-right, .ms-launcher-wrap.ms-at-top-left { top: 12px; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ms-scrim, .ms-card, .ms-launcher-wrap { animation: none; }\n .ms-launcher { transition: none; }\n}\n\n.ms-inline .ms-card {\n box-shadow: none; animation: none; max-width: none;\n}\n.ms-inline { display: block; }\n\n@keyframes ms-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes ms-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }\n@keyframes ms-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }\n\n/* ── Header ──────────────────────────────────────────────── */\n.ms-prompt {\n margin: 0 0 var(--ms-spacing);\n font-size: var(--ms-title-size);\n font-weight: var(--ms-title-weight);\n line-height: var(--ms-title-line-height);\n letter-spacing: var(--ms-title-letter-spacing);\n color: var(--ms-text);\n padding-right: 28px;\n}\n.ms-close {\n position: absolute; top: 14px; right: 14px;\n width: 28px; height: 28px; border: none; cursor: pointer;\n background: transparent; color: var(--ms-secondary-text);\n border-radius: 8px; font-size: 18px; line-height: 1;\n display: inline-flex; align-items: center; justify-content: center;\n}\n.ms-close:hover { background: var(--ms-track); color: var(--ms-text); }\n.ms-close.ms-minimize { right: 46px; }\n.ms-has-min .ms-prompt { padding-right: 60px; }\n\n.ms-progress {\n font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n margin: 0 0 8px;\n}\n\n/* ── Scale (NPS / CES) ───────────────────────────────────── */\n.ms-scale { gap: 8px; }\n/* Up to 7 points: one row of equal chips. Never taller than wide, so a narrow card gets circles, not ovals. */\n.ms-scale-row {\n display: grid; grid-template-columns: repeat(var(--ms-scale-n, 7), minmax(0, 1fr));\n container-type: inline-size;\n}\n.ms-scale-row .ms-chip {\n min-width: 0; padding: 0;\n height: min(var(--ms-control-height), calc((100cqi - 8px * (var(--ms-scale-n, 7) - 1)) / var(--ms-scale-n, 7)));\n}\n/* Longer scales (NPS): fixed-size chips wrapping into centered rows. */\n.ms-scale-wrap { display: flex; flex-wrap: wrap; justify-content: center; }\n.ms-scale-wrap .ms-chip { flex: 0 0 auto; width: var(--ms-control-height); padding: 0; }\n.ms-chip {\n height: var(--ms-control-height);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale));\n font-weight: 500; transition: background 120ms, border-color 120ms;\n}\n.ms-chip:hover { border-color: var(--ms-accent); }\n.ms-chip[aria-pressed=\"true\"] {\n background: var(--ms-accent); border-color: var(--ms-accent); color: var(--ms-accent-text);\n}\n.ms-endlabels {\n display: flex; justify-content: space-between; gap: 12px;\n margin-top: 8px; font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n}\n\n/* ── Stars ───────────────────────────────────────────────── */\n.ms-stars { display: flex; gap: 6px; }\n.ms-star {\n background: none; border: none; cursor: pointer; padding: 2px;\n font-size: calc(30px * var(--ms-text-scale)); line-height: 1;\n color: var(--ms-border); transition: color 100ms;\n}\n.ms-star.ms-on { color: var(--ms-accent); }\n\n/* ── Emoji ───────────────────────────────────────────────── */\n.ms-emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }\n.ms-emoji {\n flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;\n padding: 10px 6px; border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n}\n.ms-emoji:hover { border-color: var(--ms-accent); }\n.ms-emoji[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n.ms-emoji-glyph { font-size: calc(26px * var(--ms-text-scale)); line-height: 1; }\n.ms-emoji-label { font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); }\n\n/* ── Thumbs ──────────────────────────────────────────────── */\n.ms-thumbs { display: flex; gap: 12px; }\n.ms-thumb {\n flex: 1; height: calc(var(--ms-control-height) + 8px);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n font-size: calc(22px * var(--ms-text-scale));\n}\n.ms-thumb:hover { border-color: var(--ms-accent); }\n.ms-thumb[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 12%, var(--ms-surface)); }\n\n/* ── Single choice ───────────────────────────────────────── */\n.ms-choices { display: flex; flex-direction: column; gap: 8px; }\n.ms-choice {\n min-height: var(--ms-control-height); padding: 12px 14px; text-align: left;\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale)); font-weight: 500;\n}\n.ms-choice:hover { border-color: var(--ms-accent); }\n.ms-choice[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n\n/* ── Open text ───────────────────────────────────────────── */\n.ms-textarea {\n width: 100%; min-height: 96px; resize: vertical; padding: 12px 14px;\n border: 1px solid var(--ms-border); border-radius: var(--ms-control-radius);\n background: var(--ms-surface); color: var(--ms-text);\n font: inherit; font-size: calc(15px * var(--ms-text-scale));\n}\n.ms-textarea:focus { outline: none; border-color: var(--ms-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ms-accent) 20%, transparent); }\n.ms-counter { margin-top: 6px; font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); text-align: right; }\n\n/* ── Footer / button ─────────────────────────────────────── */\n.ms-footer { margin-top: calc(var(--ms-spacing) * 1.25); }\n.ms-btn {\n width: 100%; height: var(--ms-control-height);\n border: none; border-radius: var(--ms-control-radius);\n background: var(--ms-accent); color: var(--ms-accent-text);\n font-size: calc(15px * var(--ms-text-scale)); font-weight: 600; cursor: pointer;\n transition: opacity 120ms;\n}\n.ms-btn:hover { opacity: 0.92; }\n.ms-btn:disabled { opacity: 0.45; cursor: not-allowed; }\n\n/* ── Success ─────────────────────────────────────────────── */\n.ms-success {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n padding: calc(var(--ms-spacing) * 1.5) var(--ms-spacing);\n text-align: center;\n}\n.ms-success-check {\n width: 44px; height: 44px; border-radius: 50%;\n background: var(--ms-accent); color: var(--ms-accent-text);\n display: flex; align-items: center; justify-content: center; font-size: 24px;\n}\n`;\n\n/** Inject the survey stylesheet once. No-op during SSR. */\nexport function ensureStyles(): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(STYLE_ID)) return;\n const el = document.createElement(\"style\");\n el.id = STYLE_ID;\n el.textContent = CSS;\n document.head.appendChild(el);\n}\n","//\n// motion.ts\n//\n// The \"unfurl\" transition between a minimized survey's launcher pill and its card: the card\n// scales up out of the launcher's corner with a soft spring, and scales back into it when\n// minimized. Built on the Web Animations API, so there are no dependencies. Where it's missing\n// (old browsers, test DOMs) every helper resolves at once and the change is instant.\n//\n// Visitors who ask for reduced motion get a short crossfade instead.\n//\n\nimport type { WebPlacement } from \"@microsurveysai/web-core\";\n\n/** A damped spring as a CSS `linear()` easing; a cubic-bezier with a little overshoot where unsupported. */\nconst SPRING = (() => {\n const points: number[] = [];\n for (let i = 0; i <= 48; i++) {\n const t = i / 48;\n points.push(i === 48 ? 1 : +(1 - Math.exp(-8 * t) * Math.cos(8 * t)).toFixed(4));\n }\n const spring = `linear(${points.join(\", \")})`;\n try {\n if (typeof CSS !== \"undefined\" && CSS.supports?.(\"transition-timing-function\", spring)) return spring;\n } catch {\n // CSS.supports can throw on odd hosts; fall through.\n }\n return \"cubic-bezier(0.3, 1.3, 0.4, 1)\";\n})();\nconst EASE_IN = \"cubic-bezier(0.4, 0, 1, 1)\";\nconst EASE_OUT = \"cubic-bezier(0.2, 0.8, 0.2, 1)\";\n\n/** Where the card grows from: the corner the launcher sits in. Modal placements dock the launcher bottom-center. */\nexport function unfurlOrigin(placement: WebPlacement): string {\n switch (placement) {\n case \"top-right\": return \"top right\";\n case \"top-left\": return \"top left\";\n case \"bottom-right\": return \"bottom right\";\n case \"bottom-left\": return \"bottom left\";\n default: return \"bottom center\";\n }\n}\n\nfunction reducedMotion(): boolean {\n try {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n } catch {\n return false;\n }\n}\n\n/** Stops any running transition on these elements and their contents. Their pending promises reject. */\nexport function stopMotion(...els: (Element | null | undefined)[]): void {\n for (const el of els) el?.getAnimations?.({ subtree: true }).forEach((a) => a.cancel());\n}\n\n/**\n * Runs one animation. Entrances end at the element's natural style, so they're dropped once done;\n * exits hold their last frame until the caller hides the element (and the next transition stops them).\n * Rejects if stopped part-way.\n */\nfunction play(\n el: Element | null | undefined,\n keyframes: Keyframe[],\n opts: { duration: number; delay?: number; easing?: string; origin?: string; exit?: boolean },\n): Promise<void> {\n const target = el as HTMLElement | null | undefined;\n if (!target || typeof target.animate !== \"function\") return Promise.resolve();\n if (opts.origin) target.style.transformOrigin = opts.origin;\n const anim = target.animate(keyframes, {\n duration: opts.duration,\n delay: opts.delay ?? 0,\n easing: opts.easing ?? \"ease\",\n fill: opts.exit ? \"forwards\" : \"backwards\",\n });\n return anim.finished.then(() => undefined);\n}\n\n/**\n * The rows of the card that settle in one after another, as [element, step]: the corner buttons\n * first (together, like a header row), then progress, prompt, each row of the question, the footer.\n */\nfunction cardParts(card: Element): [Element, number][] {\n const corner: Element[] = [];\n const rows: Element[] = [];\n for (const child of Array.from(card.children)) {\n if (child.classList.contains(\"ms-close\")) corner.push(child);\n // A question's wrapper (e.g. scale + end labels) staggers row by row.\n else if (child.tagName === \"DIV\" && !child.className && child.children.length > 1) rows.push(...Array.from(child.children));\n else rows.push(child);\n }\n const first = corner.length ? 1 : 0;\n return [...corner.map((el): [Element, number] => [el, 0]), ...rows.map((el, i): [Element, number] => [el, first + i])];\n}\n\n/**\n * The card opens out of the launcher's corner with a soft spring, then its contents settle in one\n * after another (each rises 6px and fades in, 40ms apart).\n */\nexport function cardIn(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 });\n const parts = card ? cardParts(card) : [];\n return Promise.all([\n play(\n card,\n [\n { opacity: 0, transform: \"scale(0.35)\" },\n { opacity: 1, transform: \"scale(0.7)\", offset: 0.25 },\n { opacity: 1, transform: \"scale(1)\" },\n ],\n { duration: 460, easing: SPRING, origin },\n ),\n ...parts.map(([el, i]) =>\n play(el, [{ opacity: 0, transform: \"translateY(6px)\" }, { opacity: 1, transform: \"none\" }], {\n duration: 260,\n delay: 120 + i * 40,\n easing: EASE_OUT,\n }),\n ),\n ]).then(() => undefined);\n}\n\n/** The card folds back into the launcher's corner. Holds its last frame; hide the card when it resolves. */\nexport function cardOut(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, exit: true });\n return play(\n card,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.35)\" }],\n { duration: 240, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The launcher pops back in once the card is mostly folded away. */\nexport function launcherIn(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, delay: 100 });\n return play(\n launcher,\n [{ opacity: 0, transform: \"scale(0.9)\" }, { opacity: 1, transform: \"scale(1)\" }],\n { duration: 300, delay: 150, easing: SPRING, origin },\n );\n}\n\n/** The launcher shrinks away as the card opens. Holds its last frame; remove the launcher when it resolves. */\nexport function launcherOut(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 1 }, { opacity: 0 }], { duration: 120, exit: true });\n return play(\n launcher,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.9)\" }],\n { duration: 140, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The dimmed backdrop of a modal placement, fading with the card. Only its color animates, so the card\n * inside keeps its own opacity. One keyframe: the other end is the scrim's own color. */\nexport function scrimIn(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 0 }], { duration: 200 });\n}\n\nexport function scrimOut(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 1 }], { duration: 200, exit: true });\n}\n","//\n// MicroSurvey.tsx\n//\n// `<MicroSurvey surveyId>` — renders a specific survey **inline** in the page\n// flow (no overlay), e.g. embedded in a settings screen or a landing section.\n// Pulls the survey from the cached config; submits an impression + response on\n// completion. Has no equivalent in the iOS SDK (mobile is overlay-only).\n//\n\n\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Survey, SurveyResult } from \"@microsurveysai/web-core\";\nimport { useMicroSurveysClient } from \"./provider\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\n\nexport interface MicroSurveyProps {\n surveyId: string;\n /** Called with the outcome when the inline survey closes. */\n onComplete?: (result: SurveyResult) => void;\n}\n\nexport function MicroSurvey({ surveyId, onComplete }: MicroSurveyProps) {\n const client = useMicroSurveysClient();\n const [survey, setSurvey] = useState<Survey | null>(null);\n const [closed, setClosed] = useState(false);\n const shownAt = useRef<Date | null>(null);\n\n useEffect(() => {\n if (!client) return;\n setSurvey(client.getSurvey(surveyId) ?? null);\n // Re-check when a config refresh lands (survey may not have been cached yet).\n return client.onConfigChange(() => setSurvey(client.getSurvey(surveyId) ?? null));\n }, [client, surveyId]);\n\n if (!client || !survey || closed) return null;\n\n ensureStyles();\n if (!shownAt.current) shownAt.current = new Date();\n const { vars, googleFont } = resolveTheme(client.getTheme());\n ensureGoogleFont(googleFont);\n\n function close(result: SurveyResult) {\n client!.recordInline(survey!, result, shownAt.current ?? new Date());\n setClosed(true);\n onComplete?.(result);\n }\n\n return (\n <div className=\"ms-root ms-inline\" style={vars}>\n <SurveyCard survey={survey} onClose={close} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,IAAAA,gBAAwE;AACxE,sBAAsD;;;ACStD,IAAAC,gBAA6D;AAC7D,uBAA6B;;;ACZ7B,mBAAkC;;;ACarB;AAJN,SAAS,cAAc,EAAE,UAAU,OAAO,SAAS,GAAuB;AAC/E,QAAM,MAAM,SAAS;AACrB,UAAQ,IAAI,MAAM;AAAA,IAChB,KAAK;AACH,aAAO,4CAAC,cAAW,KAAK,IAA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,QAAmC,eAAyC,QAAQ,SAAS,QAAQ,UAAU;AAAA,MAC1H,SAAS,MAAM,QAAQ,cAAc;AAAA,IACvC;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACF;;;AO5DA,IAAAC,gBAA4C;AAyCtC,IAAAC,sBAAA;AA5BC,SAAS,YAAY,EAAE,UAAU,WAAW,GAAqB;AACtE,QAAM,SAAS,sBAAsB;AACrC,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAAwB,IAAI;AACxD,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAAS,KAAK;AAC1C,QAAM,cAAU,sBAAoB,IAAI;AAExC,+BAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,cAAU,OAAO,UAAU,QAAQ,KAAK,IAAI;AAE5C,WAAO,OAAO,eAAe,MAAM,UAAU,OAAO,UAAU,QAAQ,KAAK,IAAI,CAAC;AAAA,EAClF,GAAG,CAAC,QAAQ,QAAQ,CAAC;AAErB,MAAI,CAAC,UAAU,CAAC,UAAU,OAAQ,QAAO;AAEzC,eAAa;AACb,MAAI,CAAC,QAAQ,QAAS,SAAQ,UAAU,oBAAI,KAAK;AACjD,QAAM,EAAE,MAAM,WAAW,IAAI,aAAa,OAAO,SAAS,CAAC;AAC3D,mBAAiB,UAAU;AAE3B,WAAS,MAAM,QAAsB;AACnC,WAAQ,aAAa,QAAS,QAAQ,QAAQ,WAAW,oBAAI,KAAK,CAAC;AACnE,cAAU,IAAI;AACd,iBAAa,MAAM;AAAA,EACrB;AAEA,SACE,6CAAC,SAAI,WAAU,qBAAoB,OAAO,MACxC,uDAAC,cAAW,QAAgB,SAAS,OAAO,GAC9C;AAEJ;","names":["import_react","import_react","import_jsx_runtime","CSS","import_jsx_runtime","card","import_jsx_runtime","import_react","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/provider.tsx","../src/overlayHost.tsx","../src/SurveyCard.tsx","../src/questions.tsx","../src/theme.ts","../src/styles.ts","../src/motion.ts","../src/MicroSurvey.tsx"],"sourcesContent":["//\n// @microsurveysai/react\n//\n// React SDK for MicroSurveys. Wrap your app in <MicroSurveysProvider>, fire\n// events with useMicroSurveys().track(), and auto-triggered surveys present\n// themselves. Embed a specific survey with <MicroSurvey surveyId>.\n//\n// <MicroSurveysProvider apiKey=\"ms_live_…\">\n// <App />\n// </MicroSurveysProvider>\n//\n// const { track, identify } = useMicroSurveys();\n// track(\"checkout_completed\", { plan: \"pro\" });\n//\n\nexport { MicroSurveysProvider, useMicroSurveys, useMicroSurveysClient } from \"./provider\";\nexport type { MicroSurveysProviderProps } from \"./provider\";\nexport { MicroSurvey } from \"./MicroSurvey\";\nexport type { MicroSurveyProps } from \"./MicroSurvey\";\n\n// Re-export the common wire types so consumers don't need a second import.\nexport type { Survey, Question, SurveyResult, SurveyAnswer, AnswerValue, ProjectTheme } from \"@microsurveysai/web-core\";\n","//\n// provider.tsx\n//\n// `<MicroSurveysProvider>` creates the client, starts it, exposes it via context,\n// and mounts the overlay host that renders auto-triggered surveys. Port of the\n// wiring in iOS `MicroSurveysSDK.init` + lifecycle.\n//\n\n\"use client\";\n\nimport { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { createClient, type MicroSurveysClient } from \"@microsurveysai/web-core\";\nimport { OverlayHost } from \"./overlayHost\";\nimport { ensureStyles } from \"./styles\";\n\nconst ClientContext = createContext<MicroSurveysClient | null>(null);\n\nexport interface MicroSurveysProviderProps {\n /** Project API key (`ms_live_…` / `ms_test_…`). Browser-embeddable. */\n apiKey: string;\n /** Override the API base for self-hosted deployments. Defaults to https://console.microsurveys.ai. */\n apiBaseURL?: string;\n /** Refresh config on tab foreground. Default true. */\n refreshOnForeground?: boolean;\n /** Your app's version (e.g. \"3.2.0\"), sent with responses so results can be compared across releases. */\n appVersion?: string;\n /** Start automatically on mount. Default true. */\n autoStart?: boolean;\n children?: React.ReactNode;\n}\n\nexport function MicroSurveysProvider({ apiKey, apiBaseURL, refreshOnForeground, appVersion, autoStart = true, children }: MicroSurveysProviderProps) {\n // Lazily create the client on the client only (localStorage/crypto are guarded,\n // but there's no reason to build one during SSR).\n const [client] = useState<MicroSurveysClient | null>(() =>\n typeof window === \"undefined\" ? null : createClient({ apiKey, apiBaseURL, refreshOnForeground, appVersion }),\n );\n\n useEffect(() => {\n if (!client) return;\n ensureStyles();\n if (autoStart) client.start();\n return () => client.stop();\n }, [client, autoStart]);\n\n return (\n <ClientContext.Provider value={client}>\n {children}\n <OverlayHost client={client} />\n </ClientContext.Provider>\n );\n}\n\n/** The raw client (or null before mount). Prefer `useMicroSurveys` for events. */\nexport function useMicroSurveysClient(): MicroSurveysClient | null {\n return useContext(ClientContext);\n}\n\n/** Event + identity helpers bound to the provider's client. Safe no-ops if\n * called outside a provider / before mount. */\nexport function useMicroSurveys() {\n const client = useContext(ClientContext);\n return useMemo(\n () => ({\n client,\n track: (name: string, properties?: Record<string, unknown>) => client?.track(name, properties),\n identify: (userId: string | null | undefined, properties?: Record<string, unknown>) => client?.identify(userId, properties),\n refresh: () => client?.refreshConfig(),\n }),\n [client],\n );\n}\n\nexport { ClientContext };\n","//\n// overlayHost.tsx\n//\n// Subscribes to the client's `onPresent` and renders one auto-triggered survey\n// at a time, portalled to document.body. Where it sits comes from the survey's\n// (else the project theme's) web placement:\n//\n// - \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\": a card floating\n// in that corner. The page stays visible and usable behind it.\n// - \"bottom\" | \"center\": the modal bottom sheet or centered dialog, over a\n// dimmed page (the iOS `Presenter` look).\n//\n// A survey can also start minimized: a small launcher pill showing the first\n// question, which opens the survey on click. An open survey with a launcher can\n// be minimized again. Answers are kept while it's minimized. Opening and minimizing \"unfurl\": the\n// card grows out of the launcher's corner and folds back into it (see motion.ts).\n//\n\n\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { ActiveSurvey, MicroSurveysClient, SurveyResult } from \"@microsurveysai/web-core\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, resolvePlacement, resolveLauncher, isModalPlacement, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\nimport { cardIn, cardOut, launcherIn, launcherOut, scrimIn, scrimOut, stopMotion, unfurlOrigin } from \"./motion\";\n\n// Layout effect in the browser (the transition must start before paint), plain effect during SSR.\nconst useBrowserLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function OverlayHost({ client }: { client: MicroSurveysClient | null }) {\n const [active, setActive] = useState<ActiveSurvey | null>(null);\n // Whether this survey has a launcher at all, and whether it's minimized to it right now.\n const [launcher, setLauncher] = useState(false);\n const [minimized, setMinimized] = useState(false);\n // The launcher outlives `minimized` on both sides: it appears as the card starts folding away,\n // and leaves only once its own exit has played.\n const [showLauncher, setShowLauncher] = useState(false);\n // After the first open or minimize the CSS entrance animations are switched off, so they don't\n // replay each time the card is shown again; the unfurl transition takes over.\n const [moved, setMoved] = useState(false);\n const [motionSeq, setMotionSeq] = useState(0);\n const pendingMotion = useRef<\"open\" | \"minimize\" | null>(null);\n const minimizing = useRef(false);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const launcherRef = useRef<HTMLButtonElement | null>(null);\n const launcherWrapRef = useRef<HTMLDivElement | null>(null);\n // Only move focus after the visitor opens or minimizes; never steal it when a survey first appears.\n const toggled = useRef(false);\n\n useEffect(() => {\n if (!client) return;\n return client.onPresent((a) => {\n const withLauncher = resolveLauncher(a.survey, client.getTheme());\n toggled.current = false;\n pendingMotion.current = null;\n minimizing.current = false;\n setLauncher(withLauncher);\n setMinimized(withLauncher);\n setShowLauncher(withLauncher);\n setMoved(false);\n setActive(a);\n });\n }, [client]);\n\n // On screen (as the card, or as its launcher when it starts minimized): send\n // the impression now rather than at close.\n useEffect(() => {\n active?.shown();\n }, [active]);\n\n const placement = active && client ? resolvePlacement(active.survey, client.getTheme()) : \"bottom\";\n const modal = isModalPlacement(placement);\n const origin = unfurlOrigin(placement);\n\n // Plays the transition requested by open()/minimize() once React has rendered both ends of it.\n useBrowserLayoutEffect(() => {\n const kind = pendingMotion.current;\n if (!kind) return;\n pendingMotion.current = null;\n const card = panelRef.current?.querySelector(\".ms-card\");\n const scrim = modal ? panelRef.current : null;\n const wrap = launcherWrapRef.current;\n stopMotion(card, scrim, wrap);\n const ignoreStop = () => {};\n if (kind === \"open\") {\n minimizing.current = false;\n void cardIn(card, origin).catch(ignoreStop);\n void scrimIn(scrim).catch(ignoreStop);\n launcherOut(wrap, origin).then(() => setShowLauncher(false), ignoreStop);\n } else {\n void launcherIn(wrap, origin).catch(ignoreStop);\n Promise.all([cardOut(card, origin), scrimOut(scrim)]).then(() => {\n minimizing.current = false;\n setMinimized(true);\n }, ignoreStop);\n }\n }, [motionSeq, modal, origin]);\n\n // Escape: a modal survey listens page-wide (it holds focus); a floating card only reacts while\n // focus is inside it (see onKeyDown below), so it never swallows the host app's Escape.\n useEffect(() => {\n if (!active || !modal || minimized) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") escape();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active, modal, minimized, launcher]);\n\n // After opening, move focus into the card; after minimizing, back to the launcher.\n useEffect(() => {\n if (!active || !toggled.current) return;\n if (minimized) launcherRef.current?.focus();\n else panelRef.current?.querySelector<HTMLElement>(\".ms-card\")?.focus();\n }, [active, minimized]);\n\n if (!active || !client || typeof document === \"undefined\") return null;\n\n ensureStyles();\n const theme = client.getTheme();\n const { vars, googleFont } = resolveTheme(theme);\n ensureGoogleFont(googleFont);\n const dismissible = active.survey.dismissible !== false;\n const firstPrompt = [...active.survey.questions].sort((a, b) => a.order - b.order)[0]?.prompt ?? active.survey.name;\n\n function close(result: SurveyResult) {\n active!.close(result);\n setActive(null);\n }\n\n function dismiss() {\n close({ answers: [], completed: false, dismissed: true });\n }\n\n // The card stays visible while it folds away; `minimized` flips once that has played.\n function minimize() {\n if (minimized || minimizing.current) return;\n minimizing.current = true;\n toggled.current = true;\n pendingMotion.current = \"minimize\";\n setMoved(true);\n setShowLauncher(true);\n setMotionSeq((n) => n + 1);\n }\n\n function open() {\n toggled.current = true;\n pendingMotion.current = \"open\";\n setMoved(true);\n setMinimized(false);\n setMotionSeq((n) => n + 1);\n }\n\n // Escape or a scrim click: back to the launcher when there is one, else dismiss (if allowed).\n function escape() {\n if (launcher) minimize();\n else if (dismissible) dismiss();\n }\n\n function onScrimClick(e: React.MouseEvent) {\n if (e.target === e.currentTarget) escape();\n }\n\n function onFloatKey(e: React.KeyboardEvent) {\n if (e.key === \"Escape\") {\n e.stopPropagation();\n escape();\n }\n }\n\n // The card stays mounted while minimized (hidden), so answers survive minimize → open.\n const card = (\n <SurveyCard survey={active.survey} onClose={close} modal={modal} onMinimize={launcher ? minimize : undefined} />\n );\n\n return createPortal(\n <div className={moved ? \"ms-root ms-moved\" : \"ms-root\"} style={vars}>\n {modal ? (\n <div\n ref={panelRef}\n className={`ms-scrim ${placement === \"center\" ? \"ms-dialog\" : \"ms-sheet\"}`}\n onClick={onScrimClick}\n hidden={minimized}\n >\n {card}\n </div>\n ) : (\n <div ref={panelRef} className={`ms-float ms-at-${placement}`} onKeyDown={onFloatKey} hidden={minimized}>\n {card}\n </div>\n )}\n {showLauncher && (\n // Modal placements dock their launcher bottom-center; corners keep their corner.\n <div ref={launcherWrapRef} className={`ms-launcher-wrap ms-at-${modal ? \"bottom\" : placement}`}>\n <button\n ref={launcherRef}\n type=\"button\"\n className=\"ms-launcher\"\n onClick={open}\n aria-label={`Open survey: ${firstPrompt}`}\n aria-haspopup=\"dialog\"\n >\n <svg className=\"ms-launcher-icon\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" aria-hidden=\"true\">\n <path\n fill=\"currentColor\"\n d=\"M12 3C6.48 3 2 6.92 2 11.75c0 2.47 1.17 4.7 3.06 6.29L4.3 21.3a.5.5 0 0 0 .7.56l3.9-1.86c.98.27 2.02.4 3.1.4 5.52 0 10-3.92 10-8.75S17.52 3 12 3Z\"\n />\n </svg>\n <span className=\"ms-launcher-label\">{firstPrompt}</span>\n </button>\n {dismissible && (\n <button type=\"button\" className=\"ms-launcher-close\" aria-label=\"Dismiss survey\" onClick={dismiss}>\n ✕\n </button>\n )}\n </div>\n )}\n </div>,\n document.body,\n );\n}\n","//\n// SurveyCard.tsx\n//\n// The multi-step survey host — renders `.ms-card` with the current question,\n// enforces `required`, supports partial submit, a success message, and\n// `dismissible:false`. Port of iOS `SurveyViewController`. The caller wraps this\n// in the themed `.ms-root` (+ scrim for overlays, plain for inline).\n//\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { thanksDurationMs, thanksMessage } from \"@microsurveysai/web-core\";\nimport type { AnswerValue, Survey, SurveyAnswer, SurveyResult } from \"@microsurveysai/web-core\";\nimport { QuestionInput, isAnswered } from \"./questions\";\n\nexport interface SurveyCardProps {\n survey: Survey;\n /** Called exactly once when the card closes (completed, partial, or dismissed). */\n onClose: (result: SurveyResult) => void;\n /** Whether the card is a modal dialog over a dimmed page (default) or floats beside the page. */\n modal?: boolean;\n /** When set, the card shows a minimize button that calls it (back to the launcher). */\n onMinimize?: () => void;\n}\n\nexport function SurveyCard({ survey, onClose, modal = true, onMinimize }: SurveyCardProps) {\n const questions = useMemo(() => [...survey.questions].sort((a, b) => a.order - b.order), [survey]);\n const dismissible = survey.dismissible !== false;\n\n const [step, setStep] = useState(0);\n const [answers, setAnswers] = useState<Record<string, AnswerValue>>({});\n const [done, setDone] = useState(false);\n\n // The thank-you closes after a delay sized to its text (see thanksDurationMs),\n // pauses while hovered, and closes at once on click. `closed` guards against\n // closing twice (timer firing after a click, or the reverse).\n const thanksTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const thanksRemaining = useRef(0);\n const thanksStartedAt = useRef(0);\n const thanksResult = useRef<SurveyResult | null>(null);\n const closed = useRef(false);\n\n useEffect(() => () => {\n if (thanksTimer.current) clearTimeout(thanksTimer.current);\n }, []);\n\n const question = questions[step];\n const isLast = step >= questions.length - 1;\n\n // Empty survey (misconfigured) — nothing to render; close as dismissed.\n if (!question) {\n return null;\n }\n\n const current = answers[question.id];\n const canAdvance = !question.required || isAnswered(current);\n\n function collected(): SurveyAnswer[] {\n return questions.filter((q) => answers[q.id] !== undefined).map((q) => ({ questionId: q.id, value: answers[q.id]! }));\n }\n\n function setAnswer(value: AnswerValue) {\n setAnswers((prev) => ({ ...prev, [question!.id]: value }));\n }\n\n function advance() {\n if (!canAdvance) return;\n if (isLast) {\n finish();\n } else {\n setStep((s) => s + 1);\n }\n }\n\n function finish() {\n thanksResult.current = { answers: collected(), completed: true, dismissed: false };\n thanksRemaining.current = thanksDurationMs(survey.successMessage, survey.successPace);\n setDone(true);\n startThanksTimer();\n }\n\n function startThanksTimer() {\n if (closed.current || thanksTimer.current) return;\n thanksStartedAt.current = Date.now();\n thanksTimer.current = setTimeout(closeThanks, Math.max(0, thanksRemaining.current));\n }\n\n function pauseThanksTimer() {\n if (!thanksTimer.current) return;\n clearTimeout(thanksTimer.current);\n thanksTimer.current = null;\n thanksRemaining.current -= Date.now() - thanksStartedAt.current;\n }\n\n function closeThanks() {\n if (closed.current || !thanksResult.current) return;\n closed.current = true;\n if (thanksTimer.current) clearTimeout(thanksTimer.current);\n thanksTimer.current = null;\n onClose(thanksResult.current);\n }\n\n function dismiss() {\n onClose({ answers: collected(), completed: false, dismissed: true });\n }\n\n if (done) {\n return (\n <div\n className=\"ms-card ms-thanks\"\n role=\"dialog\"\n aria-live=\"polite\"\n onClick={closeThanks}\n onMouseEnter={pauseThanksTimer}\n onMouseLeave={startThanksTimer}\n >\n <div className=\"ms-success\">\n <span className=\"ms-success-check\">✓</span>\n <span className=\"ms-success-text\">{thanksMessage(survey.successMessage)}</span>\n </div>\n </div>\n );\n }\n\n return (\n <div\n className={onMinimize ? \"ms-card ms-has-min\" : \"ms-card\"}\n role=\"dialog\"\n aria-modal={modal ? \"true\" : \"false\"}\n aria-label={survey.name}\n tabIndex={-1}\n >\n {onMinimize && (\n <button\n type=\"button\"\n className={dismissible ? \"ms-close ms-minimize\" : \"ms-close\"}\n aria-label=\"Minimize\"\n onClick={onMinimize}\n >\n <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" aria-hidden=\"true\">\n <path d=\"M5 12h14\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n {dismissible && (\n <button type=\"button\" className=\"ms-close\" aria-label=\"Close\" onClick={dismiss}>\n ✕\n </button>\n )}\n {questions.length > 1 && (\n <p className=\"ms-progress\">\n {step + 1} of {questions.length}\n </p>\n )}\n <h2 className=\"ms-prompt\">{question.prompt}</h2>\n <QuestionInput question={question} value={current} onChange={setAnswer} />\n <div className=\"ms-footer\">\n <button type=\"button\" className=\"ms-btn\" disabled={!canAdvance} onClick={advance}>\n {isLast ? \"Submit\" : \"Next\"}\n </button>\n </div>\n </div>\n );\n}\n","//\n// questions.tsx\n//\n// One renderer per question type, ported from the iOS UI/*View.swift files. Each\n// takes the question, the current answer value, and an `onChange`, and emits the\n// exact `AnswerValue` JSON shape the backend expects (API-CONTRACT §Answer value\n// shapes). Styling is entirely via the `.ms-*` classes + theme CSS variables.\n//\n\nimport type { AnswerValue, Question } from \"@microsurveysai/web-core\";\nimport type { CSSProperties } from \"react\";\n\nexport interface QuestionInputProps {\n question: Question;\n value: AnswerValue | undefined;\n onChange: (value: AnswerValue) => void;\n}\n\nexport function QuestionInput({ question, value, onChange }: QuestionInputProps) {\n const cfg = question.config;\n switch (cfg.kind) {\n case \"scale\":\n return <ScaleInput min={cfg.min} max={cfg.max} minLabel={cfg.minLabel} maxLabel={cfg.maxLabel} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"stars\":\n return <StarsInput count={cfg.count} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"emoji\":\n return <EmojiInput options={cfg.options} value={strValue(value)} onPick={(v) => onChange({ value: v })} />;\n case \"thumbs\":\n return <ThumbsInput value={strValue(value)} onPick={(v) => onChange({ value: v as \"up\" | \"down\" })} />;\n case \"singleChoice\":\n return <ChoiceInput options={cfg.options} value={value && \"choice\" in value ? value.choice : undefined} onPick={(v) => onChange({ choice: v })} />;\n case \"openText\":\n return <OpenTextInput placeholder={cfg.placeholder} maxLength={cfg.maxLength} value={value && \"text\" in value ? value.text : \"\"} onInput={(t) => onChange({ text: t })} />;\n }\n}\n\n/** True when an answer value counts as \"provided\" (for required-gating). */\nexport function isAnswered(value: AnswerValue | undefined): boolean {\n if (!value) return false;\n if (\"text\" in value) return value.text.trim().length > 0;\n return true;\n}\n\n// ── helpers to read the current value regardless of union branch ──────────────\nfunction numValue(v: AnswerValue | undefined): number | undefined {\n return v && \"value\" in v && typeof v.value === \"number\" ? v.value : undefined;\n}\nfunction strValue(v: AnswerValue | undefined): string | undefined {\n return v && \"value\" in v && typeof v.value === \"string\" ? v.value : undefined;\n}\n\n// ── Scale (NPS / CES) ─────────────────────────────────────────────────────────\nfunction ScaleInput({ min, max, minLabel, maxLabel, value, onPick }: { min: number; max: number; minLabel?: string; maxLabel?: string; value: number | undefined; onPick: (n: number) => void }) {\n const points: number[] = [];\n for (let i = min; i <= max; i++) points.push(i);\n // Short scales (CES 1–7) sit on one row of equal chips, like the mobile SDKs; longer ones (NPS 0–10)\n // wrap into centered rows of fixed-size chips.\n const oneRow = points.length <= 7;\n return (\n <div>\n <div\n className={oneRow ? \"ms-scale ms-scale-row\" : \"ms-scale ms-scale-wrap\"}\n role=\"group\"\n style={oneRow ? ({ \"--ms-scale-n\": points.length } as CSSProperties) : undefined}\n >\n {points.map((n) => (\n <button key={n} type=\"button\" className=\"ms-chip\" aria-pressed={value === n} onClick={() => onPick(n)}>\n {n}\n </button>\n ))}\n </div>\n {(minLabel || maxLabel) && (\n <div className=\"ms-endlabels\">\n <span>{minLabel}</span>\n <span>{maxLabel}</span>\n </div>\n )}\n </div>\n );\n}\n\n// ── Stars ─────────────────────────────────────────────────────────────────────\nfunction StarsInput({ count, value, onPick }: { count: number; value: number | undefined; onPick: (n: number) => void }) {\n const stars: number[] = [];\n for (let i = 1; i <= count; i++) stars.push(i);\n return (\n <div className=\"ms-stars\" role=\"group\">\n {stars.map((n) => (\n <button key={n} type=\"button\" className={`ms-star${value !== undefined && n <= value ? \" ms-on\" : \"\"}`} aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`} aria-pressed={value === n} onClick={() => onPick(n)}>\n ★\n </button>\n ))}\n </div>\n );\n}\n\n// ── Emoji ─────────────────────────────────────────────────────────────────────\nfunction EmojiInput({ options, value, onPick }: { options: { value: string; emoji: string; label?: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-emoji-row\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-emoji\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n <span className=\"ms-emoji-glyph\">{o.emoji}</span>\n {o.label && <span className=\"ms-emoji-label\">{o.label}</span>}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Thumbs ────────────────────────────────────────────────────────────────────\nfunction ThumbsInput({ value, onPick }: { value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-thumbs\" role=\"group\">\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs up\" aria-pressed={value === \"up\"} onClick={() => onPick(\"up\")}>\n 👍\n </button>\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs down\" aria-pressed={value === \"down\"} onClick={() => onPick(\"down\")}>\n 👎\n </button>\n </div>\n );\n}\n\n// ── Single choice ─────────────────────────────────────────────────────────────\nfunction ChoiceInput({ options, value, onPick }: { options: { value: string; label: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-choices\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-choice\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n {o.label}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Open text ─────────────────────────────────────────────────────────────────\nfunction OpenTextInput({ placeholder, maxLength, value, onInput }: { placeholder?: string; maxLength?: number; value: string; onInput: (t: string) => void }) {\n return (\n <div>\n <textarea className=\"ms-textarea\" placeholder={placeholder} maxLength={maxLength} value={value} onChange={(e) => onInput(e.target.value)} />\n {maxLength !== undefined && (\n <div className=\"ms-counter\">\n {value.length} / {maxLength}\n </div>\n )}\n </div>\n );\n}\n","//\n// theme.ts\n//\n// Maps a project `ProjectTheme` (from /api/sdk/config) onto CSS custom\n// properties consumed by the survey stylesheet, applying the same clean,\n// neutral defaults as the iOS `SurveyTheme.default` (indigo accent, zinc grays).\n// Also injects a Google Fonts <link> when the theme names a curated font.\n//\n// Dark-mode-aware palettes are a follow-up; for now the defaults are the\n// light-mode values and any theme key overrides them.\n//\n\nimport type { CSSProperties } from \"react\";\nimport type { ProjectTheme, Survey, WebPlacement } from \"@microsurveysai/web-core\";\n\n/** iOS `SurveyTheme.default` light-mode palette + metrics. */\nconst DEFAULTS = {\n scrim: \"rgba(9, 9, 11, 0.45)\",\n surface: \"#FFFFFF\",\n text: \"#18181B\",\n secondaryText: \"#71717A\",\n accent: \"#2E7272\", // Slate Teal (brand primary)\n accentText: \"#FFFFFF\",\n border: \"#E4E4E7\",\n track: \"#F4F4F5\",\n cardRadius: 16,\n controlRadius: 12,\n controlHeight: 48,\n spacing: 16,\n textScale: 1,\n titleSize: 20,\n titleWeight: \"semibold\",\n titleLineHeight: 1.1,\n titleLetterSpacing: 0,\n};\n\nconst WEIGHTS: Record<string, number> = { regular: 400, medium: 500, semibold: 600, bold: 700 };\n\nconst CURATED_FONTS = new Set([\"Inter\", \"Roboto\", \"Open Sans\", \"Noto Sans\", \"Lato\", \"Montserrat\", \"Poppins\"]);\n\nexport interface ResolvedTheme {\n /** CSS custom properties to spread onto the survey root's `style`. */\n vars: CSSProperties;\n /** A curated Google font family to lazy-load, or null for the system font. */\n googleFont: string | null;\n}\n\nfunction px(n: number): string {\n return `${n}px`;\n}\n\nconst COLOR_FN = /^(rgb|rgba|hsl|hsla)\\(\\s*[-+0-9.,%\\s/]*\\)$/i;\n\n/**\n * A theme string is used only if it can't make the browser fetch anything or break out of its\n * CSS value: no url()/image-set()/var() (plain rgb()/hsl() colors are fine), no CSS punctuation,\n * quotes or backslashes. Anything else falls back to the default for that key.\n */\nfunction safe(v: string | undefined): string | undefined {\n if (typeof v !== \"string\" || v.length > 100) return undefined;\n if (/[;:{}<>\"'`\\\\@!]/.test(v)) return undefined;\n if (v.includes(\"(\") || v.includes(\")\")) return COLOR_FN.test(v.trim()) ? v : undefined;\n return v;\n}\n\n/** A finite number kept within [lo, hi], or undefined. */\nfunction bounded(n: number | null | undefined, lo: number, hi: number): number | undefined {\n return typeof n === \"number\" && Number.isFinite(n) ? Math.min(Math.max(n, lo), hi) : undefined;\n}\n\nexport function resolveTheme(theme: ProjectTheme | null | undefined): ResolvedTheme {\n const raw = theme ?? {};\n // Same bounds the server applies before sending the theme; real themes sit well inside them.\n const t: ProjectTheme = {\n ...raw,\n accent: safe(raw.accent),\n accentText: safe(raw.accentText),\n surface: safe(raw.surface),\n text: safe(raw.text),\n secondaryText: safe(raw.secondaryText),\n border: safe(raw.border),\n font: safe(raw.font),\n cornerRadius: bounded(raw.cornerRadius, 0, 200),\n controlRadius: bounded(raw.controlRadius, 0, 200),\n controlHeight: bounded(raw.controlHeight, 16, 200),\n spacing: bounded(raw.spacing, 0, 200),\n textScale: bounded(raw.textScale, 0.25, 4),\n titleSize: bounded(raw.titleSize, 6, 120),\n titleLineHeight: bounded(raw.titleLineHeight, 0.5, 5),\n titleLetterSpacing: bounded(raw.titleLetterSpacing, -50, 50),\n };\n const controlHeight = t.controlHeight ?? DEFAULTS.controlHeight;\n const controlRadius = t.controlPill ? controlHeight / 2 : (t.controlRadius ?? DEFAULTS.controlRadius);\n const cardRadius = t.cornerRadius ?? DEFAULTS.cardRadius;\n const titleWeight = WEIGHTS[t.titleWeight ?? DEFAULTS.titleWeight] ?? 600;\n\n const font = t.font && t.font !== \"system\" && t.font.length > 0 ? t.font : null;\n const googleFont = font && CURATED_FONTS.has(font) ? font : null;\n const fontFamily = font\n ? `'${font}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`\n : \"system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\";\n\n // CSS custom properties. Cast through a record since `--x` keys aren't in CSSProperties.\n const vars = {\n \"--ms-scrim\": DEFAULTS.scrim,\n \"--ms-surface\": t.surface ?? DEFAULTS.surface,\n \"--ms-text\": t.text ?? DEFAULTS.text,\n \"--ms-secondary-text\": t.secondaryText ?? DEFAULTS.secondaryText,\n \"--ms-accent\": t.accent ?? DEFAULTS.accent,\n \"--ms-accent-text\": t.accentText ?? DEFAULTS.accentText,\n \"--ms-border\": t.border ?? DEFAULTS.border,\n \"--ms-track\": DEFAULTS.track,\n \"--ms-card-radius\": px(cardRadius),\n \"--ms-control-radius\": px(controlRadius),\n \"--ms-control-height\": px(controlHeight),\n \"--ms-spacing\": px(t.spacing ?? DEFAULTS.spacing),\n \"--ms-text-scale\": String(t.textScale ?? DEFAULTS.textScale),\n \"--ms-title-size\": px(t.titleSize ?? DEFAULTS.titleSize),\n \"--ms-title-weight\": String(titleWeight),\n \"--ms-title-line-height\": String(t.titleLineHeight ?? DEFAULTS.titleLineHeight),\n \"--ms-title-letter-spacing\": px(t.titleLetterSpacing ?? DEFAULTS.titleLetterSpacing),\n \"--ms-font\": fontFamily,\n \"--ms-align\": t.alignment === \"center\" ? \"center\" : \"left\",\n } as CSSProperties;\n\n return { vars, googleFont };\n}\n\nconst PLACEMENTS: readonly WebPlacement[] = [\"bottom-right\", \"bottom-left\", \"top-right\", \"top-left\", \"bottom\", \"center\"];\n\nfunction asPlacement(v: unknown): WebPlacement | null {\n return typeof v === \"string\" && (PLACEMENTS as readonly string[]).includes(v) ? (v as WebPlacement) : null;\n}\n\n/**\n * Where the card sits: the survey's `webPlacement`, else the project theme's, else what the\n * survey's `presentation` gives it (a dialog is centered; a sheet, or nothing, docks to the bottom\n * the way the mobile SDKs show it, with the theme `position` as the last word).\n */\nexport function resolvePlacement(survey: Pick<Survey, \"webPlacement\" | \"presentation\">, theme: ProjectTheme | null | undefined): WebPlacement {\n const placed = asPlacement(survey.webPlacement) ?? asPlacement(theme?.webPlacement);\n if (placed) return placed;\n if (survey.presentation === \"dialog\") return \"center\";\n if (survey.presentation === \"sheet\") return \"bottom\";\n return theme?.position === \"center\" ? \"center\" : \"bottom\";\n}\n\n/** Corners float over the page; bottom and center are modal (dimmed page, focus held). */\nexport function isModalPlacement(p: WebPlacement): boolean {\n return p === \"bottom\" || p === \"center\";\n}\n\n/** Whether the survey starts minimized as a launcher: the survey's choice, else the theme's. */\nexport function resolveLauncher(survey: Pick<Survey, \"webLauncher\">, theme: ProjectTheme | null | undefined): boolean {\n if (typeof survey.webLauncher === \"boolean\") return survey.webLauncher;\n return theme?.webLauncher === true;\n}\n\n/** Lazily inject a Google Fonts stylesheet for a curated family (once). */\nexport function ensureGoogleFont(family: string | null): void {\n if (!family || typeof document === \"undefined\") return;\n const id = `ms-font-${family.replace(/\\s+/g, \"-\").toLowerCase()}`;\n if (document.getElementById(id)) return;\n const link = document.createElement(\"link\");\n link.id = id;\n link.rel = \"stylesheet\";\n link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family)}:wght@400;500;600;700&display=swap`;\n document.head.appendChild(link);\n}\n","//\n// styles.ts\n//\n// One self-contained stylesheet, injected once, scoped under `.ms-root`. It\n// reads the CSS custom properties set by `resolveTheme`, so every visual knob is\n// theme-driven. No Tailwind, no external CSS — safe to drop into any host app.\n//\n\nconst STYLE_ID = \"microsurveys-styles\";\n\nconst CSS = `\n.ms-root, .ms-root * { box-sizing: border-box; }\n.ms-root [hidden] { display: none !important; }\n.ms-root {\n font-family: var(--ms-font);\n color: var(--ms-text);\n text-align: var(--ms-align);\n -webkit-font-smoothing: antialiased;\n}\n\n/* ── Overlay ─────────────────────────────────────────────── */\n.ms-scrim {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; padding: var(--ms-spacing);\n background: var(--ms-scrim);\n animation: ms-fade 160ms ease-out;\n}\n.ms-scrim.ms-sheet { align-items: flex-end; justify-content: center; }\n.ms-scrim.ms-dialog { align-items: center; justify-content: center; }\n\n.ms-card {\n position: relative; width: 100%; max-width: 480px;\n background: var(--ms-surface);\n border-radius: var(--ms-card-radius);\n border: 1px solid var(--ms-border);\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.18);\n padding: calc(var(--ms-spacing) * 1.5);\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-card:focus { outline: none; }\n/* Once the visitor has opened or minimized, transitions come from motion.ts, not these entrances. */\n.ms-moved .ms-scrim, .ms-moved .ms-card, .ms-moved .ms-launcher-wrap { animation: none; }\n\n/* Floating card: pinned to a corner, no scrim, the page stays usable. */\n.ms-float {\n position: fixed; z-index: 2147483000;\n width: min(380px, calc(100vw - 40px));\n}\n.ms-float .ms-card {\n max-width: none; max-height: calc(100vh - 40px); overflow-y: auto;\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.22);\n}\n.ms-float.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-float.ms-at-bottom-left { left: 20px; bottom: 20px; }\n.ms-float.ms-at-top-right { right: 20px; top: 20px; }\n.ms-float.ms-at-top-left { left: 20px; top: 20px; }\n.ms-float.ms-at-top-right .ms-card, .ms-float.ms-at-top-left .ms-card { animation-name: ms-drop; }\n\n/* Launcher: the minimized survey, a pill in the accent color. */\n.ms-launcher-wrap {\n position: fixed; z-index: 2147483000;\n display: flex; align-items: center; gap: 8px;\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-launcher-wrap.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-launcher-wrap.ms-at-bottom-left { left: 20px; bottom: 20px; flex-direction: row-reverse; }\n.ms-launcher-wrap.ms-at-top-right { right: 20px; top: 20px; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-top-left { left: 20px; top: 20px; flex-direction: row-reverse; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-bottom {\n left: 0; right: 0; bottom: 20px; justify-content: center; pointer-events: none;\n}\n.ms-launcher-wrap.ms-at-bottom > * { pointer-events: auto; }\n.ms-launcher {\n display: inline-flex; align-items: center; gap: 8px;\n height: 44px; padding: 0 18px; max-width: min(320px, calc(100vw - 96px));\n border: none; border-radius: 22px; cursor: pointer;\n background: var(--ms-accent); color: var(--ms-accent-text);\n font: inherit; font-size: calc(14px * var(--ms-text-scale)); font-weight: 600;\n box-shadow: 0 8px 24px rgba(9, 9, 11, 0.22);\n transition: transform 120ms, box-shadow 120ms;\n}\n.ms-launcher:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(9, 9, 11, 0.26); }\n.ms-launcher:focus-visible, .ms-launcher-close:focus-visible {\n outline: 2px solid var(--ms-accent); outline-offset: 2px;\n}\n.ms-launcher-icon { flex: none; }\n.ms-launcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ms-launcher-close {\n flex: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;\n border: 1px solid var(--ms-border); background: var(--ms-surface); color: var(--ms-secondary-text);\n font-size: 12px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;\n box-shadow: 0 4px 12px rgba(9, 9, 11, 0.12);\n}\n.ms-launcher-close:hover { color: var(--ms-text); }\n\n/* Phones: a corner card spans the width, still on its edge. */\n@media (max-width: 520px) {\n .ms-float { width: auto; }\n .ms-float.ms-at-bottom-right, .ms-float.ms-at-bottom-left { left: 12px; right: 12px; bottom: 12px; }\n .ms-float.ms-at-top-right, .ms-float.ms-at-top-left { left: 12px; right: 12px; top: 12px; }\n .ms-float .ms-card { max-height: calc(100vh - 24px); }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-bottom-left { bottom: 12px; }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-top-right { right: 12px; }\n .ms-launcher-wrap.ms-at-bottom-left, .ms-launcher-wrap.ms-at-top-left { left: 12px; }\n .ms-launcher-wrap.ms-at-top-right, .ms-launcher-wrap.ms-at-top-left { top: 12px; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ms-scrim, .ms-card, .ms-launcher-wrap { animation: none; }\n .ms-launcher { transition: none; }\n}\n\n.ms-inline .ms-card {\n box-shadow: none; animation: none; max-width: none;\n}\n.ms-inline { display: block; }\n\n@keyframes ms-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes ms-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }\n@keyframes ms-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }\n\n/* ── Header ──────────────────────────────────────────────── */\n.ms-prompt {\n margin: 0 0 var(--ms-spacing);\n font-size: var(--ms-title-size);\n font-weight: var(--ms-title-weight);\n line-height: var(--ms-title-line-height);\n letter-spacing: var(--ms-title-letter-spacing);\n color: var(--ms-text);\n padding-right: 28px;\n}\n.ms-close {\n position: absolute; top: 14px; right: 14px;\n width: 28px; height: 28px; border: none; cursor: pointer;\n background: transparent; color: var(--ms-secondary-text);\n border-radius: 8px; font-size: 18px; line-height: 1;\n display: inline-flex; align-items: center; justify-content: center;\n}\n.ms-close:hover { background: var(--ms-track); color: var(--ms-text); }\n.ms-close.ms-minimize { right: 46px; }\n.ms-has-min .ms-prompt { padding-right: 60px; }\n\n.ms-progress {\n font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n margin: 0 0 8px;\n}\n\n/* ── Scale (NPS / CES) ───────────────────────────────────── */\n.ms-scale { gap: 8px; }\n/* Up to 7 points: one row of equal chips. Never taller than wide, so a narrow card gets circles, not ovals. */\n.ms-scale-row {\n display: grid; grid-template-columns: repeat(var(--ms-scale-n, 7), minmax(0, 1fr));\n container-type: inline-size;\n}\n.ms-scale-row .ms-chip {\n min-width: 0; padding: 0;\n height: min(var(--ms-control-height), calc((100cqi - 8px * (var(--ms-scale-n, 7) - 1)) / var(--ms-scale-n, 7)));\n}\n/* Longer scales (NPS): fixed-size chips wrapping into centered rows. */\n.ms-scale-wrap { display: flex; flex-wrap: wrap; justify-content: center; }\n.ms-scale-wrap .ms-chip { flex: 0 0 auto; width: var(--ms-control-height); padding: 0; }\n.ms-chip {\n height: var(--ms-control-height);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale));\n font-weight: 500; transition: background 120ms, border-color 120ms;\n}\n.ms-chip:hover { border-color: var(--ms-accent); }\n.ms-chip[aria-pressed=\"true\"] {\n background: var(--ms-accent); border-color: var(--ms-accent); color: var(--ms-accent-text);\n}\n.ms-endlabels {\n display: flex; justify-content: space-between; gap: 12px;\n margin-top: 8px; font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n}\n\n/* ── Stars ───────────────────────────────────────────────── */\n.ms-stars { display: flex; gap: 6px; }\n.ms-star {\n background: none; border: none; cursor: pointer; padding: 2px;\n font-size: calc(30px * var(--ms-text-scale)); line-height: 1;\n color: var(--ms-border); transition: color 100ms;\n}\n.ms-star.ms-on { color: var(--ms-accent); }\n\n/* ── Emoji ───────────────────────────────────────────────── */\n.ms-emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }\n.ms-emoji {\n flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;\n padding: 10px 6px; border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n}\n.ms-emoji:hover { border-color: var(--ms-accent); }\n.ms-emoji[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n.ms-emoji-glyph { font-size: calc(26px * var(--ms-text-scale)); line-height: 1; }\n.ms-emoji-label { font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); }\n\n/* ── Thumbs ──────────────────────────────────────────────── */\n.ms-thumbs { display: flex; gap: 12px; }\n.ms-thumb {\n flex: 1; height: calc(var(--ms-control-height) + 8px);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n font-size: calc(22px * var(--ms-text-scale));\n}\n.ms-thumb:hover { border-color: var(--ms-accent); }\n.ms-thumb[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 12%, var(--ms-surface)); }\n\n/* ── Single choice ───────────────────────────────────────── */\n.ms-choices { display: flex; flex-direction: column; gap: 8px; }\n.ms-choice {\n min-height: var(--ms-control-height); padding: 12px 14px; text-align: left;\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale)); font-weight: 500;\n}\n.ms-choice:hover { border-color: var(--ms-accent); }\n.ms-choice[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n\n/* ── Open text ───────────────────────────────────────────── */\n.ms-textarea {\n width: 100%; min-height: 96px; resize: vertical; padding: 12px 14px;\n border: 1px solid var(--ms-border); border-radius: var(--ms-control-radius);\n background: var(--ms-surface); color: var(--ms-text);\n font: inherit; font-size: calc(15px * var(--ms-text-scale));\n}\n.ms-textarea:focus { outline: none; border-color: var(--ms-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ms-accent) 20%, transparent); }\n.ms-counter { margin-top: 6px; font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); text-align: right; }\n\n/* ── Footer / button ─────────────────────────────────────── */\n.ms-footer { margin-top: calc(var(--ms-spacing) * 1.25); }\n.ms-btn {\n width: 100%; height: var(--ms-control-height);\n border: none; border-radius: var(--ms-control-radius);\n background: var(--ms-accent); color: var(--ms-accent-text);\n font-size: calc(15px * var(--ms-text-scale)); font-weight: 600; cursor: pointer;\n transition: opacity 120ms;\n}\n.ms-btn:hover { opacity: 0.92; }\n.ms-btn:disabled { opacity: 0.45; cursor: not-allowed; }\n\n/* ── Success ─────────────────────────────────────────────── */\n.ms-success {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n padding: calc(var(--ms-spacing) * 1.5) var(--ms-spacing);\n text-align: center;\n}\n.ms-thanks { cursor: pointer; }\n.ms-success-text { max-width: 100%; overflow-wrap: anywhere; }\n.ms-success-check {\n width: 44px; height: 44px; border-radius: 50%;\n background: var(--ms-accent); color: var(--ms-accent-text);\n display: flex; align-items: center; justify-content: center; font-size: 24px;\n}\n`;\n\n/** Inject the survey stylesheet once. No-op during SSR. */\nexport function ensureStyles(): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(STYLE_ID)) return;\n const el = document.createElement(\"style\");\n el.id = STYLE_ID;\n el.textContent = CSS;\n document.head.appendChild(el);\n}\n","//\n// motion.ts\n//\n// The \"unfurl\" transition between a minimized survey's launcher pill and its card: the card\n// scales up out of the launcher's corner with a soft spring, and scales back into it when\n// minimized. Built on the Web Animations API, so there are no dependencies. Where it's missing\n// (old browsers, test DOMs) every helper resolves at once and the change is instant.\n//\n// Visitors who ask for reduced motion get a short crossfade instead.\n//\n\nimport type { WebPlacement } from \"@microsurveysai/web-core\";\n\n/** A damped spring as a CSS `linear()` easing; a cubic-bezier with a little overshoot where unsupported. */\nconst SPRING = (() => {\n const points: number[] = [];\n for (let i = 0; i <= 48; i++) {\n const t = i / 48;\n points.push(i === 48 ? 1 : +(1 - Math.exp(-8 * t) * Math.cos(8 * t)).toFixed(4));\n }\n const spring = `linear(${points.join(\", \")})`;\n try {\n if (typeof CSS !== \"undefined\" && CSS.supports?.(\"transition-timing-function\", spring)) return spring;\n } catch {\n // CSS.supports can throw on odd hosts; fall through.\n }\n return \"cubic-bezier(0.3, 1.3, 0.4, 1)\";\n})();\nconst EASE_IN = \"cubic-bezier(0.4, 0, 1, 1)\";\nconst EASE_OUT = \"cubic-bezier(0.2, 0.8, 0.2, 1)\";\n\n/** Where the card grows from: the corner the launcher sits in. Modal placements dock the launcher bottom-center. */\nexport function unfurlOrigin(placement: WebPlacement): string {\n switch (placement) {\n case \"top-right\": return \"top right\";\n case \"top-left\": return \"top left\";\n case \"bottom-right\": return \"bottom right\";\n case \"bottom-left\": return \"bottom left\";\n default: return \"bottom center\";\n }\n}\n\nfunction reducedMotion(): boolean {\n try {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n } catch {\n return false;\n }\n}\n\n/** Stops any running transition on these elements and their contents. Their pending promises reject. */\nexport function stopMotion(...els: (Element | null | undefined)[]): void {\n for (const el of els) el?.getAnimations?.({ subtree: true }).forEach((a) => a.cancel());\n}\n\n/**\n * Runs one animation. Entrances end at the element's natural style, so they're dropped once done;\n * exits hold their last frame until the caller hides the element (and the next transition stops them).\n * Rejects if stopped part-way.\n */\nfunction play(\n el: Element | null | undefined,\n keyframes: Keyframe[],\n opts: { duration: number; delay?: number; easing?: string; origin?: string; exit?: boolean },\n): Promise<void> {\n const target = el as HTMLElement | null | undefined;\n if (!target || typeof target.animate !== \"function\") return Promise.resolve();\n if (opts.origin) target.style.transformOrigin = opts.origin;\n const anim = target.animate(keyframes, {\n duration: opts.duration,\n delay: opts.delay ?? 0,\n easing: opts.easing ?? \"ease\",\n fill: opts.exit ? \"forwards\" : \"backwards\",\n });\n return anim.finished.then(() => undefined);\n}\n\n/**\n * The rows of the card that settle in one after another, as [element, step]: the corner buttons\n * first (together, like a header row), then progress, prompt, each row of the question, the footer.\n */\nfunction cardParts(card: Element): [Element, number][] {\n const corner: Element[] = [];\n const rows: Element[] = [];\n for (const child of Array.from(card.children)) {\n if (child.classList.contains(\"ms-close\")) corner.push(child);\n // A question's wrapper (e.g. scale + end labels) staggers row by row.\n else if (child.tagName === \"DIV\" && !child.className && child.children.length > 1) rows.push(...Array.from(child.children));\n else rows.push(child);\n }\n const first = corner.length ? 1 : 0;\n return [...corner.map((el): [Element, number] => [el, 0]), ...rows.map((el, i): [Element, number] => [el, first + i])];\n}\n\n/**\n * The card opens out of the launcher's corner with a soft spring, then its contents settle in one\n * after another (each rises 6px and fades in, 40ms apart).\n */\nexport function cardIn(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 });\n const parts = card ? cardParts(card) : [];\n return Promise.all([\n play(\n card,\n [\n { opacity: 0, transform: \"scale(0.35)\" },\n { opacity: 1, transform: \"scale(0.7)\", offset: 0.25 },\n { opacity: 1, transform: \"scale(1)\" },\n ],\n { duration: 460, easing: SPRING, origin },\n ),\n ...parts.map(([el, i]) =>\n play(el, [{ opacity: 0, transform: \"translateY(6px)\" }, { opacity: 1, transform: \"none\" }], {\n duration: 260,\n delay: 120 + i * 40,\n easing: EASE_OUT,\n }),\n ),\n ]).then(() => undefined);\n}\n\n/** The card folds back into the launcher's corner. Holds its last frame; hide the card when it resolves. */\nexport function cardOut(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, exit: true });\n return play(\n card,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.35)\" }],\n { duration: 240, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The launcher pops back in once the card is mostly folded away. */\nexport function launcherIn(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, delay: 100 });\n return play(\n launcher,\n [{ opacity: 0, transform: \"scale(0.9)\" }, { opacity: 1, transform: \"scale(1)\" }],\n { duration: 300, delay: 150, easing: SPRING, origin },\n );\n}\n\n/** The launcher shrinks away as the card opens. Holds its last frame; remove the launcher when it resolves. */\nexport function launcherOut(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 1 }, { opacity: 0 }], { duration: 120, exit: true });\n return play(\n launcher,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.9)\" }],\n { duration: 140, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The dimmed backdrop of a modal placement, fading with the card. Only its color animates, so the card\n * inside keeps its own opacity. One keyframe: the other end is the scrim's own color. */\nexport function scrimIn(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 0 }], { duration: 200 });\n}\n\nexport function scrimOut(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 1 }], { duration: 200, exit: true });\n}\n","//\n// MicroSurvey.tsx\n//\n// `<MicroSurvey surveyId>` — renders a specific survey **inline** in the page\n// flow (no overlay), e.g. embedded in a settings screen or a landing section.\n// Pulls the survey from the cached config; sends an impression when it renders\n// and a response when it closes. Has no equivalent in the iOS SDK (mobile is\n// overlay-only).\n//\n\n\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { ActiveSurvey, Survey, SurveyResult } from \"@microsurveysai/web-core\";\nimport { useMicroSurveysClient } from \"./provider\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\n\nexport interface MicroSurveyProps {\n surveyId: string;\n /** Called with the outcome when the inline survey closes. */\n onComplete?: (result: SurveyResult) => void;\n}\n\nexport function MicroSurvey({ surveyId, onComplete }: MicroSurveyProps) {\n const client = useMicroSurveysClient();\n const [survey, setSurvey] = useState<Survey | null>(null);\n const [closed, setClosed] = useState(false);\n // One showing per mounted survey: its impression is sent once, when it renders.\n const showing = useRef<ActiveSurvey | null>(null);\n\n useEffect(() => {\n if (!client) return;\n setSurvey(client.getSurvey(surveyId) ?? null);\n // Re-check when a config refresh lands (survey may not have been cached yet).\n return client.onConfigChange(() => setSurvey(client.getSurvey(surveyId) ?? null));\n }, [client, surveyId]);\n\n const visible = !!client && !!survey && !closed;\n if (visible && (!showing.current || showing.current.survey.id !== survey.id)) {\n showing.current = client.presentInline(survey);\n }\n\n useEffect(() => {\n if (visible) showing.current?.shown();\n }, [visible, survey]);\n\n if (!client || !survey || closed) return null;\n\n ensureStyles();\n const { vars, googleFont } = resolveTheme(client.getTheme());\n ensureGoogleFont(googleFont);\n\n function close(result: SurveyResult) {\n showing.current?.close(result);\n setClosed(true);\n onComplete?.(result);\n }\n\n return (\n <div className=\"ms-root ms-inline\" style={vars}>\n <SurveyCard survey={survey} onClose={close} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,IAAAA,gBAAwE;AACxE,IAAAC,mBAAsD;;;ACStD,IAAAC,gBAA6D;AAC7D,uBAA6B;;;ACZ7B,mBAAqD;AACrD,sBAAgD;;;ACYnC;AAJN,SAAS,cAAc,EAAE,UAAU,OAAO,SAAS,GAAuB;AAC/E,QAAM,MAAM,SAAS;AACrB,UAAQ,IAAI,MAAM;AAAA,IAChB,KAAK;AACH,aAAO,4CAAC,cAAW,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,UAAU,IAAI,UAAU,UAAU,IAAI,UAAU,OAAO,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG;AAAA,IAChK,KAAK;AACH,aAAO,4CAAC,cAAW,OAAO,IAAI,OAAO,OAAO,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG;AAAA,IACtG,KAAK;AACH,aAAO,4CAAC,cAAW,SAAS,IAAI,SAAS,OAAO,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG;AAAA,IAC1G,KAAK;AACH,aAAO,4CAAC,eAAY,OAAO,SA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C5E,YAAQ,UAAU,OAAO,cAAc,MAAM;AAAA,EAC/C;AAEA,+BAAU,MAAM;AACd,QAAI,QAAS,SAAQ,SAAS,MAAM;AAAA,EACtC,GAAG,CAAC,SAAS,MAAM,CAAC;AAEpB,MAAI,CAAC,UAAU,CAAC,UAAU,OAAQ,QAAO;AAEzC,eAAa;AACb,QAAM,EAAE,MAAM,WAAW,IAAI,aAAa,OAAO,SAAS,CAAC;AAC3D,mBAAiB,UAAU;AAE3B,WAAS,MAAM,QAAsB;AACnC,YAAQ,SAAS,MAAM,MAAM;AAC7B,cAAU,IAAI;AACd,iBAAa,MAAM;AAAA,EACrB;AAEA,SACE,6CAAC,SAAI,WAAU,qBAAoB,OAAO,MACxC,uDAAC,cAAW,QAAgB,SAAS,OAAO,GAC9C;AAEJ;","names":["import_react","import_web_core","import_react","import_jsx_runtime","CSS","import_jsx_runtime","card","import_jsx_runtime","import_react","import_jsx_runtime"]}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/provider.tsx
|
|
4
|
-
import { createContext, useContext, useEffect as
|
|
4
|
+
import { createContext, useContext, useEffect as useEffect3, useMemo as useMemo2, useState as useState3 } from "react";
|
|
5
5
|
import { createClient } from "@microsurveysai/web-core";
|
|
6
6
|
|
|
7
7
|
// src/overlayHost.tsx
|
|
8
|
-
import { useEffect, useLayoutEffect, useRef, useState as useState2 } from "react";
|
|
8
|
+
import { useEffect as useEffect2, useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
|
|
11
11
|
// src/SurveyCard.tsx
|
|
12
|
-
import { useMemo, useState } from "react";
|
|
12
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
13
|
+
import { thanksDurationMs, thanksMessage } from "@microsurveysai/web-core";
|
|
13
14
|
|
|
14
15
|
// src/questions.tsx
|
|
15
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -94,13 +95,20 @@ function OpenTextInput({ placeholder, maxLength, value, onInput }) {
|
|
|
94
95
|
|
|
95
96
|
// src/SurveyCard.tsx
|
|
96
97
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
97
|
-
var SUCCESS_MS = 1400;
|
|
98
98
|
function SurveyCard({ survey, onClose, modal = true, onMinimize }) {
|
|
99
99
|
const questions = useMemo(() => [...survey.questions].sort((a, b) => a.order - b.order), [survey]);
|
|
100
100
|
const dismissible = survey.dismissible !== false;
|
|
101
101
|
const [step, setStep] = useState(0);
|
|
102
102
|
const [answers, setAnswers] = useState({});
|
|
103
103
|
const [done, setDone] = useState(false);
|
|
104
|
+
const thanksTimer = useRef(null);
|
|
105
|
+
const thanksRemaining = useRef(0);
|
|
106
|
+
const thanksStartedAt = useRef(0);
|
|
107
|
+
const thanksResult = useRef(null);
|
|
108
|
+
const closed = useRef(false);
|
|
109
|
+
useEffect(() => () => {
|
|
110
|
+
if (thanksTimer.current) clearTimeout(thanksTimer.current);
|
|
111
|
+
}, []);
|
|
104
112
|
const question = questions[step];
|
|
105
113
|
const isLast = step >= questions.length - 1;
|
|
106
114
|
if (!question) {
|
|
@@ -123,18 +131,48 @@ function SurveyCard({ survey, onClose, modal = true, onMinimize }) {
|
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
function finish() {
|
|
126
|
-
|
|
134
|
+
thanksResult.current = { answers: collected(), completed: true, dismissed: false };
|
|
135
|
+
thanksRemaining.current = thanksDurationMs(survey.successMessage, survey.successPace);
|
|
127
136
|
setDone(true);
|
|
128
|
-
|
|
137
|
+
startThanksTimer();
|
|
138
|
+
}
|
|
139
|
+
function startThanksTimer() {
|
|
140
|
+
if (closed.current || thanksTimer.current) return;
|
|
141
|
+
thanksStartedAt.current = Date.now();
|
|
142
|
+
thanksTimer.current = setTimeout(closeThanks, Math.max(0, thanksRemaining.current));
|
|
143
|
+
}
|
|
144
|
+
function pauseThanksTimer() {
|
|
145
|
+
if (!thanksTimer.current) return;
|
|
146
|
+
clearTimeout(thanksTimer.current);
|
|
147
|
+
thanksTimer.current = null;
|
|
148
|
+
thanksRemaining.current -= Date.now() - thanksStartedAt.current;
|
|
149
|
+
}
|
|
150
|
+
function closeThanks() {
|
|
151
|
+
if (closed.current || !thanksResult.current) return;
|
|
152
|
+
closed.current = true;
|
|
153
|
+
if (thanksTimer.current) clearTimeout(thanksTimer.current);
|
|
154
|
+
thanksTimer.current = null;
|
|
155
|
+
onClose(thanksResult.current);
|
|
129
156
|
}
|
|
130
157
|
function dismiss() {
|
|
131
158
|
onClose({ answers: collected(), completed: false, dismissed: true });
|
|
132
159
|
}
|
|
133
160
|
if (done) {
|
|
134
|
-
return /* @__PURE__ */ jsx2(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
161
|
+
return /* @__PURE__ */ jsx2(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
className: "ms-card ms-thanks",
|
|
165
|
+
role: "dialog",
|
|
166
|
+
"aria-live": "polite",
|
|
167
|
+
onClick: closeThanks,
|
|
168
|
+
onMouseEnter: pauseThanksTimer,
|
|
169
|
+
onMouseLeave: startThanksTimer,
|
|
170
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "ms-success", children: [
|
|
171
|
+
/* @__PURE__ */ jsx2("span", { className: "ms-success-check", children: "\u2713" }),
|
|
172
|
+
/* @__PURE__ */ jsx2("span", { className: "ms-success-text", children: thanksMessage(survey.successMessage) })
|
|
173
|
+
] })
|
|
174
|
+
}
|
|
175
|
+
);
|
|
138
176
|
}
|
|
139
177
|
return /* @__PURE__ */ jsxs2(
|
|
140
178
|
"div",
|
|
@@ -526,6 +564,8 @@ var CSS2 = `
|
|
|
526
564
|
padding: calc(var(--ms-spacing) * 1.5) var(--ms-spacing);
|
|
527
565
|
text-align: center;
|
|
528
566
|
}
|
|
567
|
+
.ms-thanks { cursor: pointer; }
|
|
568
|
+
.ms-success-text { max-width: 100%; overflow-wrap: anywhere; }
|
|
529
569
|
.ms-success-check {
|
|
530
570
|
width: 44px; height: 44px; border-radius: 50%;
|
|
531
571
|
background: var(--ms-accent); color: var(--ms-accent-text);
|
|
@@ -659,7 +699,7 @@ function scrimOut(scrim) {
|
|
|
659
699
|
|
|
660
700
|
// src/overlayHost.tsx
|
|
661
701
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
662
|
-
var useBrowserLayoutEffect = typeof window !== "undefined" ? useLayoutEffect :
|
|
702
|
+
var useBrowserLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect2;
|
|
663
703
|
function OverlayHost({ client }) {
|
|
664
704
|
const [active, setActive] = useState2(null);
|
|
665
705
|
const [launcher, setLauncher] = useState2(false);
|
|
@@ -667,13 +707,13 @@ function OverlayHost({ client }) {
|
|
|
667
707
|
const [showLauncher, setShowLauncher] = useState2(false);
|
|
668
708
|
const [moved, setMoved] = useState2(false);
|
|
669
709
|
const [motionSeq, setMotionSeq] = useState2(0);
|
|
670
|
-
const pendingMotion =
|
|
671
|
-
const minimizing =
|
|
672
|
-
const panelRef =
|
|
673
|
-
const launcherRef =
|
|
674
|
-
const launcherWrapRef =
|
|
675
|
-
const toggled =
|
|
676
|
-
|
|
710
|
+
const pendingMotion = useRef2(null);
|
|
711
|
+
const minimizing = useRef2(false);
|
|
712
|
+
const panelRef = useRef2(null);
|
|
713
|
+
const launcherRef = useRef2(null);
|
|
714
|
+
const launcherWrapRef = useRef2(null);
|
|
715
|
+
const toggled = useRef2(false);
|
|
716
|
+
useEffect2(() => {
|
|
677
717
|
if (!client) return;
|
|
678
718
|
return client.onPresent((a) => {
|
|
679
719
|
const withLauncher = resolveLauncher(a.survey, client.getTheme());
|
|
@@ -687,6 +727,9 @@ function OverlayHost({ client }) {
|
|
|
687
727
|
setActive(a);
|
|
688
728
|
});
|
|
689
729
|
}, [client]);
|
|
730
|
+
useEffect2(() => {
|
|
731
|
+
active?.shown();
|
|
732
|
+
}, [active]);
|
|
690
733
|
const placement = active && client ? resolvePlacement(active.survey, client.getTheme()) : "bottom";
|
|
691
734
|
const modal = isModalPlacement(placement);
|
|
692
735
|
const origin = unfurlOrigin(placement);
|
|
@@ -713,7 +756,7 @@ function OverlayHost({ client }) {
|
|
|
713
756
|
}, ignoreStop);
|
|
714
757
|
}
|
|
715
758
|
}, [motionSeq, modal, origin]);
|
|
716
|
-
|
|
759
|
+
useEffect2(() => {
|
|
717
760
|
if (!active || !modal || minimized) return;
|
|
718
761
|
const onKey = (e) => {
|
|
719
762
|
if (e.key === "Escape") escape();
|
|
@@ -721,7 +764,7 @@ function OverlayHost({ client }) {
|
|
|
721
764
|
document.addEventListener("keydown", onKey);
|
|
722
765
|
return () => document.removeEventListener("keydown", onKey);
|
|
723
766
|
}, [active, modal, minimized, launcher]);
|
|
724
|
-
|
|
767
|
+
useEffect2(() => {
|
|
725
768
|
if (!active || !toggled.current) return;
|
|
726
769
|
if (minimized) launcherRef.current?.focus();
|
|
727
770
|
else panelRef.current?.querySelector(".ms-card")?.focus();
|
|
@@ -819,7 +862,7 @@ function MicroSurveysProvider({ apiKey, apiBaseURL, refreshOnForeground, appVers
|
|
|
819
862
|
const [client] = useState3(
|
|
820
863
|
() => typeof window === "undefined" ? null : createClient({ apiKey, apiBaseURL, refreshOnForeground, appVersion })
|
|
821
864
|
);
|
|
822
|
-
|
|
865
|
+
useEffect3(() => {
|
|
823
866
|
if (!client) return;
|
|
824
867
|
ensureStyles();
|
|
825
868
|
if (autoStart) client.start();
|
|
@@ -847,25 +890,31 @@ function useMicroSurveys() {
|
|
|
847
890
|
}
|
|
848
891
|
|
|
849
892
|
// src/MicroSurvey.tsx
|
|
850
|
-
import { useEffect as
|
|
893
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
851
894
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
852
895
|
function MicroSurvey({ surveyId, onComplete }) {
|
|
853
896
|
const client = useMicroSurveysClient();
|
|
854
897
|
const [survey, setSurvey] = useState4(null);
|
|
855
898
|
const [closed, setClosed] = useState4(false);
|
|
856
|
-
const
|
|
857
|
-
|
|
899
|
+
const showing = useRef3(null);
|
|
900
|
+
useEffect4(() => {
|
|
858
901
|
if (!client) return;
|
|
859
902
|
setSurvey(client.getSurvey(surveyId) ?? null);
|
|
860
903
|
return client.onConfigChange(() => setSurvey(client.getSurvey(surveyId) ?? null));
|
|
861
904
|
}, [client, surveyId]);
|
|
905
|
+
const visible = !!client && !!survey && !closed;
|
|
906
|
+
if (visible && (!showing.current || showing.current.survey.id !== survey.id)) {
|
|
907
|
+
showing.current = client.presentInline(survey);
|
|
908
|
+
}
|
|
909
|
+
useEffect4(() => {
|
|
910
|
+
if (visible) showing.current?.shown();
|
|
911
|
+
}, [visible, survey]);
|
|
862
912
|
if (!client || !survey || closed) return null;
|
|
863
913
|
ensureStyles();
|
|
864
|
-
if (!shownAt.current) shownAt.current = /* @__PURE__ */ new Date();
|
|
865
914
|
const { vars, googleFont } = resolveTheme(client.getTheme());
|
|
866
915
|
ensureGoogleFont(googleFont);
|
|
867
916
|
function close(result) {
|
|
868
|
-
|
|
917
|
+
showing.current?.close(result);
|
|
869
918
|
setClosed(true);
|
|
870
919
|
onComplete?.(result);
|
|
871
920
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.tsx","../src/overlayHost.tsx","../src/SurveyCard.tsx","../src/questions.tsx","../src/theme.ts","../src/styles.ts","../src/motion.ts","../src/MicroSurvey.tsx"],"sourcesContent":["//\n// provider.tsx\n//\n// `<MicroSurveysProvider>` creates the client, starts it, exposes it via context,\n// and mounts the overlay host that renders auto-triggered surveys. Port of the\n// wiring in iOS `MicroSurveysSDK.init` + lifecycle.\n//\n\n\"use client\";\n\nimport { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { createClient, type MicroSurveysClient } from \"@microsurveysai/web-core\";\nimport { OverlayHost } from \"./overlayHost\";\nimport { ensureStyles } from \"./styles\";\n\nconst ClientContext = createContext<MicroSurveysClient | null>(null);\n\nexport interface MicroSurveysProviderProps {\n /** Project API key (`ms_live_…` / `ms_test_…`). Browser-embeddable. */\n apiKey: string;\n /** Override the API base for self-hosted deployments. Defaults to https://console.microsurveys.ai. */\n apiBaseURL?: string;\n /** Refresh config on tab foreground. Default true. */\n refreshOnForeground?: boolean;\n /** Your app's version (e.g. \"3.2.0\"), sent with responses so results can be compared across releases. */\n appVersion?: string;\n /** Start automatically on mount. Default true. */\n autoStart?: boolean;\n children?: React.ReactNode;\n}\n\nexport function MicroSurveysProvider({ apiKey, apiBaseURL, refreshOnForeground, appVersion, autoStart = true, children }: MicroSurveysProviderProps) {\n // Lazily create the client on the client only (localStorage/crypto are guarded,\n // but there's no reason to build one during SSR).\n const [client] = useState<MicroSurveysClient | null>(() =>\n typeof window === \"undefined\" ? null : createClient({ apiKey, apiBaseURL, refreshOnForeground, appVersion }),\n );\n\n useEffect(() => {\n if (!client) return;\n ensureStyles();\n if (autoStart) client.start();\n return () => client.stop();\n }, [client, autoStart]);\n\n return (\n <ClientContext.Provider value={client}>\n {children}\n <OverlayHost client={client} />\n </ClientContext.Provider>\n );\n}\n\n/** The raw client (or null before mount). Prefer `useMicroSurveys` for events. */\nexport function useMicroSurveysClient(): MicroSurveysClient | null {\n return useContext(ClientContext);\n}\n\n/** Event + identity helpers bound to the provider's client. Safe no-ops if\n * called outside a provider / before mount. */\nexport function useMicroSurveys() {\n const client = useContext(ClientContext);\n return useMemo(\n () => ({\n client,\n track: (name: string, properties?: Record<string, unknown>) => client?.track(name, properties),\n identify: (userId: string | null | undefined, properties?: Record<string, unknown>) => client?.identify(userId, properties),\n refresh: () => client?.refreshConfig(),\n }),\n [client],\n );\n}\n\nexport { ClientContext };\n","//\n// overlayHost.tsx\n//\n// Subscribes to the client's `onPresent` and renders one auto-triggered survey\n// at a time, portalled to document.body. Where it sits comes from the survey's\n// (else the project theme's) web placement:\n//\n// - \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\": a card floating\n// in that corner. The page stays visible and usable behind it.\n// - \"bottom\" | \"center\": the modal bottom sheet or centered dialog, over a\n// dimmed page (the iOS `Presenter` look).\n//\n// A survey can also start minimized: a small launcher pill showing the first\n// question, which opens the survey on click. An open survey with a launcher can\n// be minimized again. Answers are kept while it's minimized. Opening and minimizing \"unfurl\": the\n// card grows out of the launcher's corner and folds back into it (see motion.ts).\n//\n\n\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { ActiveSurvey, MicroSurveysClient, SurveyResult } from \"@microsurveysai/web-core\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, resolvePlacement, resolveLauncher, isModalPlacement, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\nimport { cardIn, cardOut, launcherIn, launcherOut, scrimIn, scrimOut, stopMotion, unfurlOrigin } from \"./motion\";\n\n// Layout effect in the browser (the transition must start before paint), plain effect during SSR.\nconst useBrowserLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function OverlayHost({ client }: { client: MicroSurveysClient | null }) {\n const [active, setActive] = useState<ActiveSurvey | null>(null);\n // Whether this survey has a launcher at all, and whether it's minimized to it right now.\n const [launcher, setLauncher] = useState(false);\n const [minimized, setMinimized] = useState(false);\n // The launcher outlives `minimized` on both sides: it appears as the card starts folding away,\n // and leaves only once its own exit has played.\n const [showLauncher, setShowLauncher] = useState(false);\n // After the first open or minimize the CSS entrance animations are switched off, so they don't\n // replay each time the card is shown again; the unfurl transition takes over.\n const [moved, setMoved] = useState(false);\n const [motionSeq, setMotionSeq] = useState(0);\n const pendingMotion = useRef<\"open\" | \"minimize\" | null>(null);\n const minimizing = useRef(false);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const launcherRef = useRef<HTMLButtonElement | null>(null);\n const launcherWrapRef = useRef<HTMLDivElement | null>(null);\n // Only move focus after the visitor opens or minimizes; never steal it when a survey first appears.\n const toggled = useRef(false);\n\n useEffect(() => {\n if (!client) return;\n return client.onPresent((a) => {\n const withLauncher = resolveLauncher(a.survey, client.getTheme());\n toggled.current = false;\n pendingMotion.current = null;\n minimizing.current = false;\n setLauncher(withLauncher);\n setMinimized(withLauncher);\n setShowLauncher(withLauncher);\n setMoved(false);\n setActive(a);\n });\n }, [client]);\n\n const placement = active && client ? resolvePlacement(active.survey, client.getTheme()) : \"bottom\";\n const modal = isModalPlacement(placement);\n const origin = unfurlOrigin(placement);\n\n // Plays the transition requested by open()/minimize() once React has rendered both ends of it.\n useBrowserLayoutEffect(() => {\n const kind = pendingMotion.current;\n if (!kind) return;\n pendingMotion.current = null;\n const card = panelRef.current?.querySelector(\".ms-card\");\n const scrim = modal ? panelRef.current : null;\n const wrap = launcherWrapRef.current;\n stopMotion(card, scrim, wrap);\n const ignoreStop = () => {};\n if (kind === \"open\") {\n minimizing.current = false;\n void cardIn(card, origin).catch(ignoreStop);\n void scrimIn(scrim).catch(ignoreStop);\n launcherOut(wrap, origin).then(() => setShowLauncher(false), ignoreStop);\n } else {\n void launcherIn(wrap, origin).catch(ignoreStop);\n Promise.all([cardOut(card, origin), scrimOut(scrim)]).then(() => {\n minimizing.current = false;\n setMinimized(true);\n }, ignoreStop);\n }\n }, [motionSeq, modal, origin]);\n\n // Escape: a modal survey listens page-wide (it holds focus); a floating card only reacts while\n // focus is inside it (see onKeyDown below), so it never swallows the host app's Escape.\n useEffect(() => {\n if (!active || !modal || minimized) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") escape();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active, modal, minimized, launcher]);\n\n // After opening, move focus into the card; after minimizing, back to the launcher.\n useEffect(() => {\n if (!active || !toggled.current) return;\n if (minimized) launcherRef.current?.focus();\n else panelRef.current?.querySelector<HTMLElement>(\".ms-card\")?.focus();\n }, [active, minimized]);\n\n if (!active || !client || typeof document === \"undefined\") return null;\n\n ensureStyles();\n const theme = client.getTheme();\n const { vars, googleFont } = resolveTheme(theme);\n ensureGoogleFont(googleFont);\n const dismissible = active.survey.dismissible !== false;\n const firstPrompt = [...active.survey.questions].sort((a, b) => a.order - b.order)[0]?.prompt ?? active.survey.name;\n\n function close(result: SurveyResult) {\n active!.close(result);\n setActive(null);\n }\n\n function dismiss() {\n close({ answers: [], completed: false, dismissed: true });\n }\n\n // The card stays visible while it folds away; `minimized` flips once that has played.\n function minimize() {\n if (minimized || minimizing.current) return;\n minimizing.current = true;\n toggled.current = true;\n pendingMotion.current = \"minimize\";\n setMoved(true);\n setShowLauncher(true);\n setMotionSeq((n) => n + 1);\n }\n\n function open() {\n toggled.current = true;\n pendingMotion.current = \"open\";\n setMoved(true);\n setMinimized(false);\n setMotionSeq((n) => n + 1);\n }\n\n // Escape or a scrim click: back to the launcher when there is one, else dismiss (if allowed).\n function escape() {\n if (launcher) minimize();\n else if (dismissible) dismiss();\n }\n\n function onScrimClick(e: React.MouseEvent) {\n if (e.target === e.currentTarget) escape();\n }\n\n function onFloatKey(e: React.KeyboardEvent) {\n if (e.key === \"Escape\") {\n e.stopPropagation();\n escape();\n }\n }\n\n // The card stays mounted while minimized (hidden), so answers survive minimize → open.\n const card = (\n <SurveyCard survey={active.survey} onClose={close} modal={modal} onMinimize={launcher ? minimize : undefined} />\n );\n\n return createPortal(\n <div className={moved ? \"ms-root ms-moved\" : \"ms-root\"} style={vars}>\n {modal ? (\n <div\n ref={panelRef}\n className={`ms-scrim ${placement === \"center\" ? \"ms-dialog\" : \"ms-sheet\"}`}\n onClick={onScrimClick}\n hidden={minimized}\n >\n {card}\n </div>\n ) : (\n <div ref={panelRef} className={`ms-float ms-at-${placement}`} onKeyDown={onFloatKey} hidden={minimized}>\n {card}\n </div>\n )}\n {showLauncher && (\n // Modal placements dock their launcher bottom-center; corners keep their corner.\n <div ref={launcherWrapRef} className={`ms-launcher-wrap ms-at-${modal ? \"bottom\" : placement}`}>\n <button\n ref={launcherRef}\n type=\"button\"\n className=\"ms-launcher\"\n onClick={open}\n aria-label={`Open survey: ${firstPrompt}`}\n aria-haspopup=\"dialog\"\n >\n <svg className=\"ms-launcher-icon\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" aria-hidden=\"true\">\n <path\n fill=\"currentColor\"\n d=\"M12 3C6.48 3 2 6.92 2 11.75c0 2.47 1.17 4.7 3.06 6.29L4.3 21.3a.5.5 0 0 0 .7.56l3.9-1.86c.98.27 2.02.4 3.1.4 5.52 0 10-3.92 10-8.75S17.52 3 12 3Z\"\n />\n </svg>\n <span className=\"ms-launcher-label\">{firstPrompt}</span>\n </button>\n {dismissible && (\n <button type=\"button\" className=\"ms-launcher-close\" aria-label=\"Dismiss survey\" onClick={dismiss}>\n ✕\n </button>\n )}\n </div>\n )}\n </div>,\n document.body,\n );\n}\n","//\n// SurveyCard.tsx\n//\n// The multi-step survey host — renders `.ms-card` with the current question,\n// enforces `required`, supports partial submit, a success message, and\n// `dismissible:false`. Port of iOS `SurveyViewController`. The caller wraps this\n// in the themed `.ms-root` (+ scrim for overlays, plain for inline).\n//\n\nimport { useMemo, useState } from \"react\";\nimport type { AnswerValue, Survey, SurveyAnswer, SurveyResult } from \"@microsurveysai/web-core\";\nimport { QuestionInput, isAnswered } from \"./questions\";\n\nexport interface SurveyCardProps {\n survey: Survey;\n /** Called exactly once when the card closes (completed, partial, or dismissed). */\n onClose: (result: SurveyResult) => void;\n /** Whether the card is a modal dialog over a dimmed page (default) or floats beside the page. */\n modal?: boolean;\n /** When set, the card shows a minimize button that calls it (back to the launcher). */\n onMinimize?: () => void;\n}\n\nconst SUCCESS_MS = 1400;\n\nexport function SurveyCard({ survey, onClose, modal = true, onMinimize }: SurveyCardProps) {\n const questions = useMemo(() => [...survey.questions].sort((a, b) => a.order - b.order), [survey]);\n const dismissible = survey.dismissible !== false;\n\n const [step, setStep] = useState(0);\n const [answers, setAnswers] = useState<Record<string, AnswerValue>>({});\n const [done, setDone] = useState(false);\n\n const question = questions[step];\n const isLast = step >= questions.length - 1;\n\n // Empty survey (misconfigured) — nothing to render; close as dismissed.\n if (!question) {\n return null;\n }\n\n const current = answers[question.id];\n const canAdvance = !question.required || isAnswered(current);\n\n function collected(): SurveyAnswer[] {\n return questions.filter((q) => answers[q.id] !== undefined).map((q) => ({ questionId: q.id, value: answers[q.id]! }));\n }\n\n function setAnswer(value: AnswerValue) {\n setAnswers((prev) => ({ ...prev, [question!.id]: value }));\n }\n\n function advance() {\n if (!canAdvance) return;\n if (isLast) {\n finish();\n } else {\n setStep((s) => s + 1);\n }\n }\n\n function finish() {\n const result: SurveyResult = { answers: collected(), completed: true, dismissed: false };\n setDone(true);\n setTimeout(() => onClose(result), SUCCESS_MS);\n }\n\n function dismiss() {\n onClose({ answers: collected(), completed: false, dismissed: true });\n }\n\n if (done) {\n return (\n <div className=\"ms-card\" role=\"dialog\" aria-live=\"polite\">\n <div className=\"ms-success\">\n <span className=\"ms-success-check\">✓</span>\n <span>{survey.successMessage ?? \"Thanks for your feedback!\"}</span>\n </div>\n </div>\n );\n }\n\n return (\n <div\n className={onMinimize ? \"ms-card ms-has-min\" : \"ms-card\"}\n role=\"dialog\"\n aria-modal={modal ? \"true\" : \"false\"}\n aria-label={survey.name}\n tabIndex={-1}\n >\n {onMinimize && (\n <button\n type=\"button\"\n className={dismissible ? \"ms-close ms-minimize\" : \"ms-close\"}\n aria-label=\"Minimize\"\n onClick={onMinimize}\n >\n <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" aria-hidden=\"true\">\n <path d=\"M5 12h14\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n {dismissible && (\n <button type=\"button\" className=\"ms-close\" aria-label=\"Close\" onClick={dismiss}>\n ✕\n </button>\n )}\n {questions.length > 1 && (\n <p className=\"ms-progress\">\n {step + 1} of {questions.length}\n </p>\n )}\n <h2 className=\"ms-prompt\">{question.prompt}</h2>\n <QuestionInput question={question} value={current} onChange={setAnswer} />\n <div className=\"ms-footer\">\n <button type=\"button\" className=\"ms-btn\" disabled={!canAdvance} onClick={advance}>\n {isLast ? \"Submit\" : \"Next\"}\n </button>\n </div>\n </div>\n );\n}\n","//\n// questions.tsx\n//\n// One renderer per question type, ported from the iOS UI/*View.swift files. Each\n// takes the question, the current answer value, and an `onChange`, and emits the\n// exact `AnswerValue` JSON shape the backend expects (API-CONTRACT §Answer value\n// shapes). Styling is entirely via the `.ms-*` classes + theme CSS variables.\n//\n\nimport type { AnswerValue, Question } from \"@microsurveysai/web-core\";\nimport type { CSSProperties } from \"react\";\n\nexport interface QuestionInputProps {\n question: Question;\n value: AnswerValue | undefined;\n onChange: (value: AnswerValue) => void;\n}\n\nexport function QuestionInput({ question, value, onChange }: QuestionInputProps) {\n const cfg = question.config;\n switch (cfg.kind) {\n case \"scale\":\n return <ScaleInput min={cfg.min} max={cfg.max} minLabel={cfg.minLabel} maxLabel={cfg.maxLabel} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"stars\":\n return <StarsInput count={cfg.count} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"emoji\":\n return <EmojiInput options={cfg.options} value={strValue(value)} onPick={(v) => onChange({ value: v })} />;\n case \"thumbs\":\n return <ThumbsInput value={strValue(value)} onPick={(v) => onChange({ value: v as \"up\" | \"down\" })} />;\n case \"singleChoice\":\n return <ChoiceInput options={cfg.options} value={value && \"choice\" in value ? value.choice : undefined} onPick={(v) => onChange({ choice: v })} />;\n case \"openText\":\n return <OpenTextInput placeholder={cfg.placeholder} maxLength={cfg.maxLength} value={value && \"text\" in value ? value.text : \"\"} onInput={(t) => onChange({ text: t })} />;\n }\n}\n\n/** True when an answer value counts as \"provided\" (for required-gating). */\nexport function isAnswered(value: AnswerValue | undefined): boolean {\n if (!value) return false;\n if (\"text\" in value) return value.text.trim().length > 0;\n return true;\n}\n\n// ── helpers to read the current value regardless of union branch ──────────────\nfunction numValue(v: AnswerValue | undefined): number | undefined {\n return v && \"value\" in v && typeof v.value === \"number\" ? v.value : undefined;\n}\nfunction strValue(v: AnswerValue | undefined): string | undefined {\n return v && \"value\" in v && typeof v.value === \"string\" ? v.value : undefined;\n}\n\n// ── Scale (NPS / CES) ─────────────────────────────────────────────────────────\nfunction ScaleInput({ min, max, minLabel, maxLabel, value, onPick }: { min: number; max: number; minLabel?: string; maxLabel?: string; value: number | undefined; onPick: (n: number) => void }) {\n const points: number[] = [];\n for (let i = min; i <= max; i++) points.push(i);\n // Short scales (CES 1–7) sit on one row of equal chips, like the mobile SDKs; longer ones (NPS 0–10)\n // wrap into centered rows of fixed-size chips.\n const oneRow = points.length <= 7;\n return (\n <div>\n <div\n className={oneRow ? \"ms-scale ms-scale-row\" : \"ms-scale ms-scale-wrap\"}\n role=\"group\"\n style={oneRow ? ({ \"--ms-scale-n\": points.length } as CSSProperties) : undefined}\n >\n {points.map((n) => (\n <button key={n} type=\"button\" className=\"ms-chip\" aria-pressed={value === n} onClick={() => onPick(n)}>\n {n}\n </button>\n ))}\n </div>\n {(minLabel || maxLabel) && (\n <div className=\"ms-endlabels\">\n <span>{minLabel}</span>\n <span>{maxLabel}</span>\n </div>\n )}\n </div>\n );\n}\n\n// ── Stars ─────────────────────────────────────────────────────────────────────\nfunction StarsInput({ count, value, onPick }: { count: number; value: number | undefined; onPick: (n: number) => void }) {\n const stars: number[] = [];\n for (let i = 1; i <= count; i++) stars.push(i);\n return (\n <div className=\"ms-stars\" role=\"group\">\n {stars.map((n) => (\n <button key={n} type=\"button\" className={`ms-star${value !== undefined && n <= value ? \" ms-on\" : \"\"}`} aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`} aria-pressed={value === n} onClick={() => onPick(n)}>\n ★\n </button>\n ))}\n </div>\n );\n}\n\n// ── Emoji ─────────────────────────────────────────────────────────────────────\nfunction EmojiInput({ options, value, onPick }: { options: { value: string; emoji: string; label?: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-emoji-row\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-emoji\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n <span className=\"ms-emoji-glyph\">{o.emoji}</span>\n {o.label && <span className=\"ms-emoji-label\">{o.label}</span>}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Thumbs ────────────────────────────────────────────────────────────────────\nfunction ThumbsInput({ value, onPick }: { value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-thumbs\" role=\"group\">\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs up\" aria-pressed={value === \"up\"} onClick={() => onPick(\"up\")}>\n 👍\n </button>\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs down\" aria-pressed={value === \"down\"} onClick={() => onPick(\"down\")}>\n 👎\n </button>\n </div>\n );\n}\n\n// ── Single choice ─────────────────────────────────────────────────────────────\nfunction ChoiceInput({ options, value, onPick }: { options: { value: string; label: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-choices\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-choice\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n {o.label}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Open text ─────────────────────────────────────────────────────────────────\nfunction OpenTextInput({ placeholder, maxLength, value, onInput }: { placeholder?: string; maxLength?: number; value: string; onInput: (t: string) => void }) {\n return (\n <div>\n <textarea className=\"ms-textarea\" placeholder={placeholder} maxLength={maxLength} value={value} onChange={(e) => onInput(e.target.value)} />\n {maxLength !== undefined && (\n <div className=\"ms-counter\">\n {value.length} / {maxLength}\n </div>\n )}\n </div>\n );\n}\n","//\n// theme.ts\n//\n// Maps a project `ProjectTheme` (from /api/sdk/config) onto CSS custom\n// properties consumed by the survey stylesheet, applying the same clean,\n// neutral defaults as the iOS `SurveyTheme.default` (indigo accent, zinc grays).\n// Also injects a Google Fonts <link> when the theme names a curated font.\n//\n// Dark-mode-aware palettes are a follow-up; for now the defaults are the\n// light-mode values and any theme key overrides them.\n//\n\nimport type { CSSProperties } from \"react\";\nimport type { ProjectTheme, Survey, WebPlacement } from \"@microsurveysai/web-core\";\n\n/** iOS `SurveyTheme.default` light-mode palette + metrics. */\nconst DEFAULTS = {\n scrim: \"rgba(9, 9, 11, 0.45)\",\n surface: \"#FFFFFF\",\n text: \"#18181B\",\n secondaryText: \"#71717A\",\n accent: \"#2E7272\", // Slate Teal (brand primary)\n accentText: \"#FFFFFF\",\n border: \"#E4E4E7\",\n track: \"#F4F4F5\",\n cardRadius: 16,\n controlRadius: 12,\n controlHeight: 48,\n spacing: 16,\n textScale: 1,\n titleSize: 20,\n titleWeight: \"semibold\",\n titleLineHeight: 1.1,\n titleLetterSpacing: 0,\n};\n\nconst WEIGHTS: Record<string, number> = { regular: 400, medium: 500, semibold: 600, bold: 700 };\n\nconst CURATED_FONTS = new Set([\"Inter\", \"Roboto\", \"Open Sans\", \"Noto Sans\", \"Lato\", \"Montserrat\", \"Poppins\"]);\n\nexport interface ResolvedTheme {\n /** CSS custom properties to spread onto the survey root's `style`. */\n vars: CSSProperties;\n /** A curated Google font family to lazy-load, or null for the system font. */\n googleFont: string | null;\n}\n\nfunction px(n: number): string {\n return `${n}px`;\n}\n\nconst COLOR_FN = /^(rgb|rgba|hsl|hsla)\\(\\s*[-+0-9.,%\\s/]*\\)$/i;\n\n/**\n * A theme string is used only if it can't make the browser fetch anything or break out of its\n * CSS value: no url()/image-set()/var() (plain rgb()/hsl() colors are fine), no CSS punctuation,\n * quotes or backslashes. Anything else falls back to the default for that key.\n */\nfunction safe(v: string | undefined): string | undefined {\n if (typeof v !== \"string\" || v.length > 100) return undefined;\n if (/[;:{}<>\"'`\\\\@!]/.test(v)) return undefined;\n if (v.includes(\"(\") || v.includes(\")\")) return COLOR_FN.test(v.trim()) ? v : undefined;\n return v;\n}\n\n/** A finite number kept within [lo, hi], or undefined. */\nfunction bounded(n: number | null | undefined, lo: number, hi: number): number | undefined {\n return typeof n === \"number\" && Number.isFinite(n) ? Math.min(Math.max(n, lo), hi) : undefined;\n}\n\nexport function resolveTheme(theme: ProjectTheme | null | undefined): ResolvedTheme {\n const raw = theme ?? {};\n // Same bounds the server applies before sending the theme; real themes sit well inside them.\n const t: ProjectTheme = {\n ...raw,\n accent: safe(raw.accent),\n accentText: safe(raw.accentText),\n surface: safe(raw.surface),\n text: safe(raw.text),\n secondaryText: safe(raw.secondaryText),\n border: safe(raw.border),\n font: safe(raw.font),\n cornerRadius: bounded(raw.cornerRadius, 0, 200),\n controlRadius: bounded(raw.controlRadius, 0, 200),\n controlHeight: bounded(raw.controlHeight, 16, 200),\n spacing: bounded(raw.spacing, 0, 200),\n textScale: bounded(raw.textScale, 0.25, 4),\n titleSize: bounded(raw.titleSize, 6, 120),\n titleLineHeight: bounded(raw.titleLineHeight, 0.5, 5),\n titleLetterSpacing: bounded(raw.titleLetterSpacing, -50, 50),\n };\n const controlHeight = t.controlHeight ?? DEFAULTS.controlHeight;\n const controlRadius = t.controlPill ? controlHeight / 2 : (t.controlRadius ?? DEFAULTS.controlRadius);\n const cardRadius = t.cornerRadius ?? DEFAULTS.cardRadius;\n const titleWeight = WEIGHTS[t.titleWeight ?? DEFAULTS.titleWeight] ?? 600;\n\n const font = t.font && t.font !== \"system\" && t.font.length > 0 ? t.font : null;\n const googleFont = font && CURATED_FONTS.has(font) ? font : null;\n const fontFamily = font\n ? `'${font}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`\n : \"system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\";\n\n // CSS custom properties. Cast through a record since `--x` keys aren't in CSSProperties.\n const vars = {\n \"--ms-scrim\": DEFAULTS.scrim,\n \"--ms-surface\": t.surface ?? DEFAULTS.surface,\n \"--ms-text\": t.text ?? DEFAULTS.text,\n \"--ms-secondary-text\": t.secondaryText ?? DEFAULTS.secondaryText,\n \"--ms-accent\": t.accent ?? DEFAULTS.accent,\n \"--ms-accent-text\": t.accentText ?? DEFAULTS.accentText,\n \"--ms-border\": t.border ?? DEFAULTS.border,\n \"--ms-track\": DEFAULTS.track,\n \"--ms-card-radius\": px(cardRadius),\n \"--ms-control-radius\": px(controlRadius),\n \"--ms-control-height\": px(controlHeight),\n \"--ms-spacing\": px(t.spacing ?? DEFAULTS.spacing),\n \"--ms-text-scale\": String(t.textScale ?? DEFAULTS.textScale),\n \"--ms-title-size\": px(t.titleSize ?? DEFAULTS.titleSize),\n \"--ms-title-weight\": String(titleWeight),\n \"--ms-title-line-height\": String(t.titleLineHeight ?? DEFAULTS.titleLineHeight),\n \"--ms-title-letter-spacing\": px(t.titleLetterSpacing ?? DEFAULTS.titleLetterSpacing),\n \"--ms-font\": fontFamily,\n \"--ms-align\": t.alignment === \"center\" ? \"center\" : \"left\",\n } as CSSProperties;\n\n return { vars, googleFont };\n}\n\nconst PLACEMENTS: readonly WebPlacement[] = [\"bottom-right\", \"bottom-left\", \"top-right\", \"top-left\", \"bottom\", \"center\"];\n\nfunction asPlacement(v: unknown): WebPlacement | null {\n return typeof v === \"string\" && (PLACEMENTS as readonly string[]).includes(v) ? (v as WebPlacement) : null;\n}\n\n/**\n * Where the card sits: the survey's `webPlacement`, else the project theme's, else what the\n * survey's `presentation` gives it (a dialog is centered; a sheet, or nothing, docks to the bottom\n * the way the mobile SDKs show it, with the theme `position` as the last word).\n */\nexport function resolvePlacement(survey: Pick<Survey, \"webPlacement\" | \"presentation\">, theme: ProjectTheme | null | undefined): WebPlacement {\n const placed = asPlacement(survey.webPlacement) ?? asPlacement(theme?.webPlacement);\n if (placed) return placed;\n if (survey.presentation === \"dialog\") return \"center\";\n if (survey.presentation === \"sheet\") return \"bottom\";\n return theme?.position === \"center\" ? \"center\" : \"bottom\";\n}\n\n/** Corners float over the page; bottom and center are modal (dimmed page, focus held). */\nexport function isModalPlacement(p: WebPlacement): boolean {\n return p === \"bottom\" || p === \"center\";\n}\n\n/** Whether the survey starts minimized as a launcher: the survey's choice, else the theme's. */\nexport function resolveLauncher(survey: Pick<Survey, \"webLauncher\">, theme: ProjectTheme | null | undefined): boolean {\n if (typeof survey.webLauncher === \"boolean\") return survey.webLauncher;\n return theme?.webLauncher === true;\n}\n\n/** Lazily inject a Google Fonts stylesheet for a curated family (once). */\nexport function ensureGoogleFont(family: string | null): void {\n if (!family || typeof document === \"undefined\") return;\n const id = `ms-font-${family.replace(/\\s+/g, \"-\").toLowerCase()}`;\n if (document.getElementById(id)) return;\n const link = document.createElement(\"link\");\n link.id = id;\n link.rel = \"stylesheet\";\n link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family)}:wght@400;500;600;700&display=swap`;\n document.head.appendChild(link);\n}\n","//\n// styles.ts\n//\n// One self-contained stylesheet, injected once, scoped under `.ms-root`. It\n// reads the CSS custom properties set by `resolveTheme`, so every visual knob is\n// theme-driven. No Tailwind, no external CSS — safe to drop into any host app.\n//\n\nconst STYLE_ID = \"microsurveys-styles\";\n\nconst CSS = `\n.ms-root, .ms-root * { box-sizing: border-box; }\n.ms-root [hidden] { display: none !important; }\n.ms-root {\n font-family: var(--ms-font);\n color: var(--ms-text);\n text-align: var(--ms-align);\n -webkit-font-smoothing: antialiased;\n}\n\n/* ── Overlay ─────────────────────────────────────────────── */\n.ms-scrim {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; padding: var(--ms-spacing);\n background: var(--ms-scrim);\n animation: ms-fade 160ms ease-out;\n}\n.ms-scrim.ms-sheet { align-items: flex-end; justify-content: center; }\n.ms-scrim.ms-dialog { align-items: center; justify-content: center; }\n\n.ms-card {\n position: relative; width: 100%; max-width: 480px;\n background: var(--ms-surface);\n border-radius: var(--ms-card-radius);\n border: 1px solid var(--ms-border);\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.18);\n padding: calc(var(--ms-spacing) * 1.5);\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-card:focus { outline: none; }\n/* Once the visitor has opened or minimized, transitions come from motion.ts, not these entrances. */\n.ms-moved .ms-scrim, .ms-moved .ms-card, .ms-moved .ms-launcher-wrap { animation: none; }\n\n/* Floating card: pinned to a corner, no scrim, the page stays usable. */\n.ms-float {\n position: fixed; z-index: 2147483000;\n width: min(380px, calc(100vw - 40px));\n}\n.ms-float .ms-card {\n max-width: none; max-height: calc(100vh - 40px); overflow-y: auto;\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.22);\n}\n.ms-float.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-float.ms-at-bottom-left { left: 20px; bottom: 20px; }\n.ms-float.ms-at-top-right { right: 20px; top: 20px; }\n.ms-float.ms-at-top-left { left: 20px; top: 20px; }\n.ms-float.ms-at-top-right .ms-card, .ms-float.ms-at-top-left .ms-card { animation-name: ms-drop; }\n\n/* Launcher: the minimized survey, a pill in the accent color. */\n.ms-launcher-wrap {\n position: fixed; z-index: 2147483000;\n display: flex; align-items: center; gap: 8px;\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-launcher-wrap.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-launcher-wrap.ms-at-bottom-left { left: 20px; bottom: 20px; flex-direction: row-reverse; }\n.ms-launcher-wrap.ms-at-top-right { right: 20px; top: 20px; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-top-left { left: 20px; top: 20px; flex-direction: row-reverse; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-bottom {\n left: 0; right: 0; bottom: 20px; justify-content: center; pointer-events: none;\n}\n.ms-launcher-wrap.ms-at-bottom > * { pointer-events: auto; }\n.ms-launcher {\n display: inline-flex; align-items: center; gap: 8px;\n height: 44px; padding: 0 18px; max-width: min(320px, calc(100vw - 96px));\n border: none; border-radius: 22px; cursor: pointer;\n background: var(--ms-accent); color: var(--ms-accent-text);\n font: inherit; font-size: calc(14px * var(--ms-text-scale)); font-weight: 600;\n box-shadow: 0 8px 24px rgba(9, 9, 11, 0.22);\n transition: transform 120ms, box-shadow 120ms;\n}\n.ms-launcher:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(9, 9, 11, 0.26); }\n.ms-launcher:focus-visible, .ms-launcher-close:focus-visible {\n outline: 2px solid var(--ms-accent); outline-offset: 2px;\n}\n.ms-launcher-icon { flex: none; }\n.ms-launcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ms-launcher-close {\n flex: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;\n border: 1px solid var(--ms-border); background: var(--ms-surface); color: var(--ms-secondary-text);\n font-size: 12px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;\n box-shadow: 0 4px 12px rgba(9, 9, 11, 0.12);\n}\n.ms-launcher-close:hover { color: var(--ms-text); }\n\n/* Phones: a corner card spans the width, still on its edge. */\n@media (max-width: 520px) {\n .ms-float { width: auto; }\n .ms-float.ms-at-bottom-right, .ms-float.ms-at-bottom-left { left: 12px; right: 12px; bottom: 12px; }\n .ms-float.ms-at-top-right, .ms-float.ms-at-top-left { left: 12px; right: 12px; top: 12px; }\n .ms-float .ms-card { max-height: calc(100vh - 24px); }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-bottom-left { bottom: 12px; }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-top-right { right: 12px; }\n .ms-launcher-wrap.ms-at-bottom-left, .ms-launcher-wrap.ms-at-top-left { left: 12px; }\n .ms-launcher-wrap.ms-at-top-right, .ms-launcher-wrap.ms-at-top-left { top: 12px; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ms-scrim, .ms-card, .ms-launcher-wrap { animation: none; }\n .ms-launcher { transition: none; }\n}\n\n.ms-inline .ms-card {\n box-shadow: none; animation: none; max-width: none;\n}\n.ms-inline { display: block; }\n\n@keyframes ms-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes ms-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }\n@keyframes ms-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }\n\n/* ── Header ──────────────────────────────────────────────── */\n.ms-prompt {\n margin: 0 0 var(--ms-spacing);\n font-size: var(--ms-title-size);\n font-weight: var(--ms-title-weight);\n line-height: var(--ms-title-line-height);\n letter-spacing: var(--ms-title-letter-spacing);\n color: var(--ms-text);\n padding-right: 28px;\n}\n.ms-close {\n position: absolute; top: 14px; right: 14px;\n width: 28px; height: 28px; border: none; cursor: pointer;\n background: transparent; color: var(--ms-secondary-text);\n border-radius: 8px; font-size: 18px; line-height: 1;\n display: inline-flex; align-items: center; justify-content: center;\n}\n.ms-close:hover { background: var(--ms-track); color: var(--ms-text); }\n.ms-close.ms-minimize { right: 46px; }\n.ms-has-min .ms-prompt { padding-right: 60px; }\n\n.ms-progress {\n font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n margin: 0 0 8px;\n}\n\n/* ── Scale (NPS / CES) ───────────────────────────────────── */\n.ms-scale { gap: 8px; }\n/* Up to 7 points: one row of equal chips. Never taller than wide, so a narrow card gets circles, not ovals. */\n.ms-scale-row {\n display: grid; grid-template-columns: repeat(var(--ms-scale-n, 7), minmax(0, 1fr));\n container-type: inline-size;\n}\n.ms-scale-row .ms-chip {\n min-width: 0; padding: 0;\n height: min(var(--ms-control-height), calc((100cqi - 8px * (var(--ms-scale-n, 7) - 1)) / var(--ms-scale-n, 7)));\n}\n/* Longer scales (NPS): fixed-size chips wrapping into centered rows. */\n.ms-scale-wrap { display: flex; flex-wrap: wrap; justify-content: center; }\n.ms-scale-wrap .ms-chip { flex: 0 0 auto; width: var(--ms-control-height); padding: 0; }\n.ms-chip {\n height: var(--ms-control-height);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale));\n font-weight: 500; transition: background 120ms, border-color 120ms;\n}\n.ms-chip:hover { border-color: var(--ms-accent); }\n.ms-chip[aria-pressed=\"true\"] {\n background: var(--ms-accent); border-color: var(--ms-accent); color: var(--ms-accent-text);\n}\n.ms-endlabels {\n display: flex; justify-content: space-between; gap: 12px;\n margin-top: 8px; font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n}\n\n/* ── Stars ───────────────────────────────────────────────── */\n.ms-stars { display: flex; gap: 6px; }\n.ms-star {\n background: none; border: none; cursor: pointer; padding: 2px;\n font-size: calc(30px * var(--ms-text-scale)); line-height: 1;\n color: var(--ms-border); transition: color 100ms;\n}\n.ms-star.ms-on { color: var(--ms-accent); }\n\n/* ── Emoji ───────────────────────────────────────────────── */\n.ms-emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }\n.ms-emoji {\n flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;\n padding: 10px 6px; border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n}\n.ms-emoji:hover { border-color: var(--ms-accent); }\n.ms-emoji[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n.ms-emoji-glyph { font-size: calc(26px * var(--ms-text-scale)); line-height: 1; }\n.ms-emoji-label { font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); }\n\n/* ── Thumbs ──────────────────────────────────────────────── */\n.ms-thumbs { display: flex; gap: 12px; }\n.ms-thumb {\n flex: 1; height: calc(var(--ms-control-height) + 8px);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n font-size: calc(22px * var(--ms-text-scale));\n}\n.ms-thumb:hover { border-color: var(--ms-accent); }\n.ms-thumb[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 12%, var(--ms-surface)); }\n\n/* ── Single choice ───────────────────────────────────────── */\n.ms-choices { display: flex; flex-direction: column; gap: 8px; }\n.ms-choice {\n min-height: var(--ms-control-height); padding: 12px 14px; text-align: left;\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale)); font-weight: 500;\n}\n.ms-choice:hover { border-color: var(--ms-accent); }\n.ms-choice[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n\n/* ── Open text ───────────────────────────────────────────── */\n.ms-textarea {\n width: 100%; min-height: 96px; resize: vertical; padding: 12px 14px;\n border: 1px solid var(--ms-border); border-radius: var(--ms-control-radius);\n background: var(--ms-surface); color: var(--ms-text);\n font: inherit; font-size: calc(15px * var(--ms-text-scale));\n}\n.ms-textarea:focus { outline: none; border-color: var(--ms-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ms-accent) 20%, transparent); }\n.ms-counter { margin-top: 6px; font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); text-align: right; }\n\n/* ── Footer / button ─────────────────────────────────────── */\n.ms-footer { margin-top: calc(var(--ms-spacing) * 1.25); }\n.ms-btn {\n width: 100%; height: var(--ms-control-height);\n border: none; border-radius: var(--ms-control-radius);\n background: var(--ms-accent); color: var(--ms-accent-text);\n font-size: calc(15px * var(--ms-text-scale)); font-weight: 600; cursor: pointer;\n transition: opacity 120ms;\n}\n.ms-btn:hover { opacity: 0.92; }\n.ms-btn:disabled { opacity: 0.45; cursor: not-allowed; }\n\n/* ── Success ─────────────────────────────────────────────── */\n.ms-success {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n padding: calc(var(--ms-spacing) * 1.5) var(--ms-spacing);\n text-align: center;\n}\n.ms-success-check {\n width: 44px; height: 44px; border-radius: 50%;\n background: var(--ms-accent); color: var(--ms-accent-text);\n display: flex; align-items: center; justify-content: center; font-size: 24px;\n}\n`;\n\n/** Inject the survey stylesheet once. No-op during SSR. */\nexport function ensureStyles(): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(STYLE_ID)) return;\n const el = document.createElement(\"style\");\n el.id = STYLE_ID;\n el.textContent = CSS;\n document.head.appendChild(el);\n}\n","//\n// motion.ts\n//\n// The \"unfurl\" transition between a minimized survey's launcher pill and its card: the card\n// scales up out of the launcher's corner with a soft spring, and scales back into it when\n// minimized. Built on the Web Animations API, so there are no dependencies. Where it's missing\n// (old browsers, test DOMs) every helper resolves at once and the change is instant.\n//\n// Visitors who ask for reduced motion get a short crossfade instead.\n//\n\nimport type { WebPlacement } from \"@microsurveysai/web-core\";\n\n/** A damped spring as a CSS `linear()` easing; a cubic-bezier with a little overshoot where unsupported. */\nconst SPRING = (() => {\n const points: number[] = [];\n for (let i = 0; i <= 48; i++) {\n const t = i / 48;\n points.push(i === 48 ? 1 : +(1 - Math.exp(-8 * t) * Math.cos(8 * t)).toFixed(4));\n }\n const spring = `linear(${points.join(\", \")})`;\n try {\n if (typeof CSS !== \"undefined\" && CSS.supports?.(\"transition-timing-function\", spring)) return spring;\n } catch {\n // CSS.supports can throw on odd hosts; fall through.\n }\n return \"cubic-bezier(0.3, 1.3, 0.4, 1)\";\n})();\nconst EASE_IN = \"cubic-bezier(0.4, 0, 1, 1)\";\nconst EASE_OUT = \"cubic-bezier(0.2, 0.8, 0.2, 1)\";\n\n/** Where the card grows from: the corner the launcher sits in. Modal placements dock the launcher bottom-center. */\nexport function unfurlOrigin(placement: WebPlacement): string {\n switch (placement) {\n case \"top-right\": return \"top right\";\n case \"top-left\": return \"top left\";\n case \"bottom-right\": return \"bottom right\";\n case \"bottom-left\": return \"bottom left\";\n default: return \"bottom center\";\n }\n}\n\nfunction reducedMotion(): boolean {\n try {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n } catch {\n return false;\n }\n}\n\n/** Stops any running transition on these elements and their contents. Their pending promises reject. */\nexport function stopMotion(...els: (Element | null | undefined)[]): void {\n for (const el of els) el?.getAnimations?.({ subtree: true }).forEach((a) => a.cancel());\n}\n\n/**\n * Runs one animation. Entrances end at the element's natural style, so they're dropped once done;\n * exits hold their last frame until the caller hides the element (and the next transition stops them).\n * Rejects if stopped part-way.\n */\nfunction play(\n el: Element | null | undefined,\n keyframes: Keyframe[],\n opts: { duration: number; delay?: number; easing?: string; origin?: string; exit?: boolean },\n): Promise<void> {\n const target = el as HTMLElement | null | undefined;\n if (!target || typeof target.animate !== \"function\") return Promise.resolve();\n if (opts.origin) target.style.transformOrigin = opts.origin;\n const anim = target.animate(keyframes, {\n duration: opts.duration,\n delay: opts.delay ?? 0,\n easing: opts.easing ?? \"ease\",\n fill: opts.exit ? \"forwards\" : \"backwards\",\n });\n return anim.finished.then(() => undefined);\n}\n\n/**\n * The rows of the card that settle in one after another, as [element, step]: the corner buttons\n * first (together, like a header row), then progress, prompt, each row of the question, the footer.\n */\nfunction cardParts(card: Element): [Element, number][] {\n const corner: Element[] = [];\n const rows: Element[] = [];\n for (const child of Array.from(card.children)) {\n if (child.classList.contains(\"ms-close\")) corner.push(child);\n // A question's wrapper (e.g. scale + end labels) staggers row by row.\n else if (child.tagName === \"DIV\" && !child.className && child.children.length > 1) rows.push(...Array.from(child.children));\n else rows.push(child);\n }\n const first = corner.length ? 1 : 0;\n return [...corner.map((el): [Element, number] => [el, 0]), ...rows.map((el, i): [Element, number] => [el, first + i])];\n}\n\n/**\n * The card opens out of the launcher's corner with a soft spring, then its contents settle in one\n * after another (each rises 6px and fades in, 40ms apart).\n */\nexport function cardIn(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 });\n const parts = card ? cardParts(card) : [];\n return Promise.all([\n play(\n card,\n [\n { opacity: 0, transform: \"scale(0.35)\" },\n { opacity: 1, transform: \"scale(0.7)\", offset: 0.25 },\n { opacity: 1, transform: \"scale(1)\" },\n ],\n { duration: 460, easing: SPRING, origin },\n ),\n ...parts.map(([el, i]) =>\n play(el, [{ opacity: 0, transform: \"translateY(6px)\" }, { opacity: 1, transform: \"none\" }], {\n duration: 260,\n delay: 120 + i * 40,\n easing: EASE_OUT,\n }),\n ),\n ]).then(() => undefined);\n}\n\n/** The card folds back into the launcher's corner. Holds its last frame; hide the card when it resolves. */\nexport function cardOut(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, exit: true });\n return play(\n card,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.35)\" }],\n { duration: 240, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The launcher pops back in once the card is mostly folded away. */\nexport function launcherIn(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, delay: 100 });\n return play(\n launcher,\n [{ opacity: 0, transform: \"scale(0.9)\" }, { opacity: 1, transform: \"scale(1)\" }],\n { duration: 300, delay: 150, easing: SPRING, origin },\n );\n}\n\n/** The launcher shrinks away as the card opens. Holds its last frame; remove the launcher when it resolves. */\nexport function launcherOut(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 1 }, { opacity: 0 }], { duration: 120, exit: true });\n return play(\n launcher,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.9)\" }],\n { duration: 140, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The dimmed backdrop of a modal placement, fading with the card. Only its color animates, so the card\n * inside keeps its own opacity. One keyframe: the other end is the scrim's own color. */\nexport function scrimIn(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 0 }], { duration: 200 });\n}\n\nexport function scrimOut(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 1 }], { duration: 200, exit: true });\n}\n","//\n// MicroSurvey.tsx\n//\n// `<MicroSurvey surveyId>` — renders a specific survey **inline** in the page\n// flow (no overlay), e.g. embedded in a settings screen or a landing section.\n// Pulls the survey from the cached config; submits an impression + response on\n// completion. Has no equivalent in the iOS SDK (mobile is overlay-only).\n//\n\n\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Survey, SurveyResult } from \"@microsurveysai/web-core\";\nimport { useMicroSurveysClient } from \"./provider\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\n\nexport interface MicroSurveyProps {\n surveyId: string;\n /** Called with the outcome when the inline survey closes. */\n onComplete?: (result: SurveyResult) => void;\n}\n\nexport function MicroSurvey({ surveyId, onComplete }: MicroSurveyProps) {\n const client = useMicroSurveysClient();\n const [survey, setSurvey] = useState<Survey | null>(null);\n const [closed, setClosed] = useState(false);\n const shownAt = useRef<Date | null>(null);\n\n useEffect(() => {\n if (!client) return;\n setSurvey(client.getSurvey(surveyId) ?? null);\n // Re-check when a config refresh lands (survey may not have been cached yet).\n return client.onConfigChange(() => setSurvey(client.getSurvey(surveyId) ?? null));\n }, [client, surveyId]);\n\n if (!client || !survey || closed) return null;\n\n ensureStyles();\n if (!shownAt.current) shownAt.current = new Date();\n const { vars, googleFont } = resolveTheme(client.getTheme());\n ensureGoogleFont(googleFont);\n\n function close(result: SurveyResult) {\n client!.recordInline(survey!, result, shownAt.current ?? new Date());\n setClosed(true);\n onComplete?.(result);\n }\n\n return (\n <div className=\"ms-root ms-inline\" style={vars}>\n <SurveyCard survey={survey} onClose={close} />\n </div>\n );\n}\n"],"mappings":";;;AAUA,SAAS,eAAe,YAAY,aAAAA,YAAW,WAAAC,UAAS,YAAAC,iBAAgB;AACxE,SAAS,oBAA6C;;;ACStD,SAAS,WAAW,iBAAiB,QAAQ,YAAAC,iBAAgB;AAC7D,SAAS,oBAAoB;;;ACZ7B,SAAS,SAAS,gBAAgB;;;ACarB,cAkDL,YAlDK;AA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;AACnC,WAAQ,aAAa,QAAS,QAAQ,QAAQ,WAAW,oBAAI,KAAK,CAAC;AACnE,cAAU,IAAI;AACd,iBAAa,MAAM;AAAA,EACrB;AAEA,SACE,gBAAAH,KAAC,SAAI,WAAU,qBAAoB,OAAO,MACxC,0BAAAA,KAAC,cAAW,QAAgB,SAAS,OAAO,GAC9C;AAEJ;","names":["useEffect","useMemo","useState","useState","jsx","jsxs","CSS","jsx","jsxs","useState","card","jsx","jsxs","useState","useEffect","useMemo","useEffect","useRef","useState","jsx","useState","useRef","useEffect"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/overlayHost.tsx","../src/SurveyCard.tsx","../src/questions.tsx","../src/theme.ts","../src/styles.ts","../src/motion.ts","../src/MicroSurvey.tsx"],"sourcesContent":["//\n// provider.tsx\n//\n// `<MicroSurveysProvider>` creates the client, starts it, exposes it via context,\n// and mounts the overlay host that renders auto-triggered surveys. Port of the\n// wiring in iOS `MicroSurveysSDK.init` + lifecycle.\n//\n\n\"use client\";\n\nimport { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { createClient, type MicroSurveysClient } from \"@microsurveysai/web-core\";\nimport { OverlayHost } from \"./overlayHost\";\nimport { ensureStyles } from \"./styles\";\n\nconst ClientContext = createContext<MicroSurveysClient | null>(null);\n\nexport interface MicroSurveysProviderProps {\n /** Project API key (`ms_live_…` / `ms_test_…`). Browser-embeddable. */\n apiKey: string;\n /** Override the API base for self-hosted deployments. Defaults to https://console.microsurveys.ai. */\n apiBaseURL?: string;\n /** Refresh config on tab foreground. Default true. */\n refreshOnForeground?: boolean;\n /** Your app's version (e.g. \"3.2.0\"), sent with responses so results can be compared across releases. */\n appVersion?: string;\n /** Start automatically on mount. Default true. */\n autoStart?: boolean;\n children?: React.ReactNode;\n}\n\nexport function MicroSurveysProvider({ apiKey, apiBaseURL, refreshOnForeground, appVersion, autoStart = true, children }: MicroSurveysProviderProps) {\n // Lazily create the client on the client only (localStorage/crypto are guarded,\n // but there's no reason to build one during SSR).\n const [client] = useState<MicroSurveysClient | null>(() =>\n typeof window === \"undefined\" ? null : createClient({ apiKey, apiBaseURL, refreshOnForeground, appVersion }),\n );\n\n useEffect(() => {\n if (!client) return;\n ensureStyles();\n if (autoStart) client.start();\n return () => client.stop();\n }, [client, autoStart]);\n\n return (\n <ClientContext.Provider value={client}>\n {children}\n <OverlayHost client={client} />\n </ClientContext.Provider>\n );\n}\n\n/** The raw client (or null before mount). Prefer `useMicroSurveys` for events. */\nexport function useMicroSurveysClient(): MicroSurveysClient | null {\n return useContext(ClientContext);\n}\n\n/** Event + identity helpers bound to the provider's client. Safe no-ops if\n * called outside a provider / before mount. */\nexport function useMicroSurveys() {\n const client = useContext(ClientContext);\n return useMemo(\n () => ({\n client,\n track: (name: string, properties?: Record<string, unknown>) => client?.track(name, properties),\n identify: (userId: string | null | undefined, properties?: Record<string, unknown>) => client?.identify(userId, properties),\n refresh: () => client?.refreshConfig(),\n }),\n [client],\n );\n}\n\nexport { ClientContext };\n","//\n// overlayHost.tsx\n//\n// Subscribes to the client's `onPresent` and renders one auto-triggered survey\n// at a time, portalled to document.body. Where it sits comes from the survey's\n// (else the project theme's) web placement:\n//\n// - \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\": a card floating\n// in that corner. The page stays visible and usable behind it.\n// - \"bottom\" | \"center\": the modal bottom sheet or centered dialog, over a\n// dimmed page (the iOS `Presenter` look).\n//\n// A survey can also start minimized: a small launcher pill showing the first\n// question, which opens the survey on click. An open survey with a launcher can\n// be minimized again. Answers are kept while it's minimized. Opening and minimizing \"unfurl\": the\n// card grows out of the launcher's corner and folds back into it (see motion.ts).\n//\n\n\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { ActiveSurvey, MicroSurveysClient, SurveyResult } from \"@microsurveysai/web-core\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, resolvePlacement, resolveLauncher, isModalPlacement, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\nimport { cardIn, cardOut, launcherIn, launcherOut, scrimIn, scrimOut, stopMotion, unfurlOrigin } from \"./motion\";\n\n// Layout effect in the browser (the transition must start before paint), plain effect during SSR.\nconst useBrowserLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function OverlayHost({ client }: { client: MicroSurveysClient | null }) {\n const [active, setActive] = useState<ActiveSurvey | null>(null);\n // Whether this survey has a launcher at all, and whether it's minimized to it right now.\n const [launcher, setLauncher] = useState(false);\n const [minimized, setMinimized] = useState(false);\n // The launcher outlives `minimized` on both sides: it appears as the card starts folding away,\n // and leaves only once its own exit has played.\n const [showLauncher, setShowLauncher] = useState(false);\n // After the first open or minimize the CSS entrance animations are switched off, so they don't\n // replay each time the card is shown again; the unfurl transition takes over.\n const [moved, setMoved] = useState(false);\n const [motionSeq, setMotionSeq] = useState(0);\n const pendingMotion = useRef<\"open\" | \"minimize\" | null>(null);\n const minimizing = useRef(false);\n const panelRef = useRef<HTMLDivElement | null>(null);\n const launcherRef = useRef<HTMLButtonElement | null>(null);\n const launcherWrapRef = useRef<HTMLDivElement | null>(null);\n // Only move focus after the visitor opens or minimizes; never steal it when a survey first appears.\n const toggled = useRef(false);\n\n useEffect(() => {\n if (!client) return;\n return client.onPresent((a) => {\n const withLauncher = resolveLauncher(a.survey, client.getTheme());\n toggled.current = false;\n pendingMotion.current = null;\n minimizing.current = false;\n setLauncher(withLauncher);\n setMinimized(withLauncher);\n setShowLauncher(withLauncher);\n setMoved(false);\n setActive(a);\n });\n }, [client]);\n\n // On screen (as the card, or as its launcher when it starts minimized): send\n // the impression now rather than at close.\n useEffect(() => {\n active?.shown();\n }, [active]);\n\n const placement = active && client ? resolvePlacement(active.survey, client.getTheme()) : \"bottom\";\n const modal = isModalPlacement(placement);\n const origin = unfurlOrigin(placement);\n\n // Plays the transition requested by open()/minimize() once React has rendered both ends of it.\n useBrowserLayoutEffect(() => {\n const kind = pendingMotion.current;\n if (!kind) return;\n pendingMotion.current = null;\n const card = panelRef.current?.querySelector(\".ms-card\");\n const scrim = modal ? panelRef.current : null;\n const wrap = launcherWrapRef.current;\n stopMotion(card, scrim, wrap);\n const ignoreStop = () => {};\n if (kind === \"open\") {\n minimizing.current = false;\n void cardIn(card, origin).catch(ignoreStop);\n void scrimIn(scrim).catch(ignoreStop);\n launcherOut(wrap, origin).then(() => setShowLauncher(false), ignoreStop);\n } else {\n void launcherIn(wrap, origin).catch(ignoreStop);\n Promise.all([cardOut(card, origin), scrimOut(scrim)]).then(() => {\n minimizing.current = false;\n setMinimized(true);\n }, ignoreStop);\n }\n }, [motionSeq, modal, origin]);\n\n // Escape: a modal survey listens page-wide (it holds focus); a floating card only reacts while\n // focus is inside it (see onKeyDown below), so it never swallows the host app's Escape.\n useEffect(() => {\n if (!active || !modal || minimized) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") escape();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active, modal, minimized, launcher]);\n\n // After opening, move focus into the card; after minimizing, back to the launcher.\n useEffect(() => {\n if (!active || !toggled.current) return;\n if (minimized) launcherRef.current?.focus();\n else panelRef.current?.querySelector<HTMLElement>(\".ms-card\")?.focus();\n }, [active, minimized]);\n\n if (!active || !client || typeof document === \"undefined\") return null;\n\n ensureStyles();\n const theme = client.getTheme();\n const { vars, googleFont } = resolveTheme(theme);\n ensureGoogleFont(googleFont);\n const dismissible = active.survey.dismissible !== false;\n const firstPrompt = [...active.survey.questions].sort((a, b) => a.order - b.order)[0]?.prompt ?? active.survey.name;\n\n function close(result: SurveyResult) {\n active!.close(result);\n setActive(null);\n }\n\n function dismiss() {\n close({ answers: [], completed: false, dismissed: true });\n }\n\n // The card stays visible while it folds away; `minimized` flips once that has played.\n function minimize() {\n if (minimized || minimizing.current) return;\n minimizing.current = true;\n toggled.current = true;\n pendingMotion.current = \"minimize\";\n setMoved(true);\n setShowLauncher(true);\n setMotionSeq((n) => n + 1);\n }\n\n function open() {\n toggled.current = true;\n pendingMotion.current = \"open\";\n setMoved(true);\n setMinimized(false);\n setMotionSeq((n) => n + 1);\n }\n\n // Escape or a scrim click: back to the launcher when there is one, else dismiss (if allowed).\n function escape() {\n if (launcher) minimize();\n else if (dismissible) dismiss();\n }\n\n function onScrimClick(e: React.MouseEvent) {\n if (e.target === e.currentTarget) escape();\n }\n\n function onFloatKey(e: React.KeyboardEvent) {\n if (e.key === \"Escape\") {\n e.stopPropagation();\n escape();\n }\n }\n\n // The card stays mounted while minimized (hidden), so answers survive minimize → open.\n const card = (\n <SurveyCard survey={active.survey} onClose={close} modal={modal} onMinimize={launcher ? minimize : undefined} />\n );\n\n return createPortal(\n <div className={moved ? \"ms-root ms-moved\" : \"ms-root\"} style={vars}>\n {modal ? (\n <div\n ref={panelRef}\n className={`ms-scrim ${placement === \"center\" ? \"ms-dialog\" : \"ms-sheet\"}`}\n onClick={onScrimClick}\n hidden={minimized}\n >\n {card}\n </div>\n ) : (\n <div ref={panelRef} className={`ms-float ms-at-${placement}`} onKeyDown={onFloatKey} hidden={minimized}>\n {card}\n </div>\n )}\n {showLauncher && (\n // Modal placements dock their launcher bottom-center; corners keep their corner.\n <div ref={launcherWrapRef} className={`ms-launcher-wrap ms-at-${modal ? \"bottom\" : placement}`}>\n <button\n ref={launcherRef}\n type=\"button\"\n className=\"ms-launcher\"\n onClick={open}\n aria-label={`Open survey: ${firstPrompt}`}\n aria-haspopup=\"dialog\"\n >\n <svg className=\"ms-launcher-icon\" viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" aria-hidden=\"true\">\n <path\n fill=\"currentColor\"\n d=\"M12 3C6.48 3 2 6.92 2 11.75c0 2.47 1.17 4.7 3.06 6.29L4.3 21.3a.5.5 0 0 0 .7.56l3.9-1.86c.98.27 2.02.4 3.1.4 5.52 0 10-3.92 10-8.75S17.52 3 12 3Z\"\n />\n </svg>\n <span className=\"ms-launcher-label\">{firstPrompt}</span>\n </button>\n {dismissible && (\n <button type=\"button\" className=\"ms-launcher-close\" aria-label=\"Dismiss survey\" onClick={dismiss}>\n ✕\n </button>\n )}\n </div>\n )}\n </div>,\n document.body,\n );\n}\n","//\n// SurveyCard.tsx\n//\n// The multi-step survey host — renders `.ms-card` with the current question,\n// enforces `required`, supports partial submit, a success message, and\n// `dismissible:false`. Port of iOS `SurveyViewController`. The caller wraps this\n// in the themed `.ms-root` (+ scrim for overlays, plain for inline).\n//\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { thanksDurationMs, thanksMessage } from \"@microsurveysai/web-core\";\nimport type { AnswerValue, Survey, SurveyAnswer, SurveyResult } from \"@microsurveysai/web-core\";\nimport { QuestionInput, isAnswered } from \"./questions\";\n\nexport interface SurveyCardProps {\n survey: Survey;\n /** Called exactly once when the card closes (completed, partial, or dismissed). */\n onClose: (result: SurveyResult) => void;\n /** Whether the card is a modal dialog over a dimmed page (default) or floats beside the page. */\n modal?: boolean;\n /** When set, the card shows a minimize button that calls it (back to the launcher). */\n onMinimize?: () => void;\n}\n\nexport function SurveyCard({ survey, onClose, modal = true, onMinimize }: SurveyCardProps) {\n const questions = useMemo(() => [...survey.questions].sort((a, b) => a.order - b.order), [survey]);\n const dismissible = survey.dismissible !== false;\n\n const [step, setStep] = useState(0);\n const [answers, setAnswers] = useState<Record<string, AnswerValue>>({});\n const [done, setDone] = useState(false);\n\n // The thank-you closes after a delay sized to its text (see thanksDurationMs),\n // pauses while hovered, and closes at once on click. `closed` guards against\n // closing twice (timer firing after a click, or the reverse).\n const thanksTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const thanksRemaining = useRef(0);\n const thanksStartedAt = useRef(0);\n const thanksResult = useRef<SurveyResult | null>(null);\n const closed = useRef(false);\n\n useEffect(() => () => {\n if (thanksTimer.current) clearTimeout(thanksTimer.current);\n }, []);\n\n const question = questions[step];\n const isLast = step >= questions.length - 1;\n\n // Empty survey (misconfigured) — nothing to render; close as dismissed.\n if (!question) {\n return null;\n }\n\n const current = answers[question.id];\n const canAdvance = !question.required || isAnswered(current);\n\n function collected(): SurveyAnswer[] {\n return questions.filter((q) => answers[q.id] !== undefined).map((q) => ({ questionId: q.id, value: answers[q.id]! }));\n }\n\n function setAnswer(value: AnswerValue) {\n setAnswers((prev) => ({ ...prev, [question!.id]: value }));\n }\n\n function advance() {\n if (!canAdvance) return;\n if (isLast) {\n finish();\n } else {\n setStep((s) => s + 1);\n }\n }\n\n function finish() {\n thanksResult.current = { answers: collected(), completed: true, dismissed: false };\n thanksRemaining.current = thanksDurationMs(survey.successMessage, survey.successPace);\n setDone(true);\n startThanksTimer();\n }\n\n function startThanksTimer() {\n if (closed.current || thanksTimer.current) return;\n thanksStartedAt.current = Date.now();\n thanksTimer.current = setTimeout(closeThanks, Math.max(0, thanksRemaining.current));\n }\n\n function pauseThanksTimer() {\n if (!thanksTimer.current) return;\n clearTimeout(thanksTimer.current);\n thanksTimer.current = null;\n thanksRemaining.current -= Date.now() - thanksStartedAt.current;\n }\n\n function closeThanks() {\n if (closed.current || !thanksResult.current) return;\n closed.current = true;\n if (thanksTimer.current) clearTimeout(thanksTimer.current);\n thanksTimer.current = null;\n onClose(thanksResult.current);\n }\n\n function dismiss() {\n onClose({ answers: collected(), completed: false, dismissed: true });\n }\n\n if (done) {\n return (\n <div\n className=\"ms-card ms-thanks\"\n role=\"dialog\"\n aria-live=\"polite\"\n onClick={closeThanks}\n onMouseEnter={pauseThanksTimer}\n onMouseLeave={startThanksTimer}\n >\n <div className=\"ms-success\">\n <span className=\"ms-success-check\">✓</span>\n <span className=\"ms-success-text\">{thanksMessage(survey.successMessage)}</span>\n </div>\n </div>\n );\n }\n\n return (\n <div\n className={onMinimize ? \"ms-card ms-has-min\" : \"ms-card\"}\n role=\"dialog\"\n aria-modal={modal ? \"true\" : \"false\"}\n aria-label={survey.name}\n tabIndex={-1}\n >\n {onMinimize && (\n <button\n type=\"button\"\n className={dismissible ? \"ms-close ms-minimize\" : \"ms-close\"}\n aria-label=\"Minimize\"\n onClick={onMinimize}\n >\n <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" aria-hidden=\"true\">\n <path d=\"M5 12h14\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n {dismissible && (\n <button type=\"button\" className=\"ms-close\" aria-label=\"Close\" onClick={dismiss}>\n ✕\n </button>\n )}\n {questions.length > 1 && (\n <p className=\"ms-progress\">\n {step + 1} of {questions.length}\n </p>\n )}\n <h2 className=\"ms-prompt\">{question.prompt}</h2>\n <QuestionInput question={question} value={current} onChange={setAnswer} />\n <div className=\"ms-footer\">\n <button type=\"button\" className=\"ms-btn\" disabled={!canAdvance} onClick={advance}>\n {isLast ? \"Submit\" : \"Next\"}\n </button>\n </div>\n </div>\n );\n}\n","//\n// questions.tsx\n//\n// One renderer per question type, ported from the iOS UI/*View.swift files. Each\n// takes the question, the current answer value, and an `onChange`, and emits the\n// exact `AnswerValue` JSON shape the backend expects (API-CONTRACT §Answer value\n// shapes). Styling is entirely via the `.ms-*` classes + theme CSS variables.\n//\n\nimport type { AnswerValue, Question } from \"@microsurveysai/web-core\";\nimport type { CSSProperties } from \"react\";\n\nexport interface QuestionInputProps {\n question: Question;\n value: AnswerValue | undefined;\n onChange: (value: AnswerValue) => void;\n}\n\nexport function QuestionInput({ question, value, onChange }: QuestionInputProps) {\n const cfg = question.config;\n switch (cfg.kind) {\n case \"scale\":\n return <ScaleInput min={cfg.min} max={cfg.max} minLabel={cfg.minLabel} maxLabel={cfg.maxLabel} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"stars\":\n return <StarsInput count={cfg.count} value={numValue(value)} onPick={(n) => onChange({ value: n })} />;\n case \"emoji\":\n return <EmojiInput options={cfg.options} value={strValue(value)} onPick={(v) => onChange({ value: v })} />;\n case \"thumbs\":\n return <ThumbsInput value={strValue(value)} onPick={(v) => onChange({ value: v as \"up\" | \"down\" })} />;\n case \"singleChoice\":\n return <ChoiceInput options={cfg.options} value={value && \"choice\" in value ? value.choice : undefined} onPick={(v) => onChange({ choice: v })} />;\n case \"openText\":\n return <OpenTextInput placeholder={cfg.placeholder} maxLength={cfg.maxLength} value={value && \"text\" in value ? value.text : \"\"} onInput={(t) => onChange({ text: t })} />;\n }\n}\n\n/** True when an answer value counts as \"provided\" (for required-gating). */\nexport function isAnswered(value: AnswerValue | undefined): boolean {\n if (!value) return false;\n if (\"text\" in value) return value.text.trim().length > 0;\n return true;\n}\n\n// ── helpers to read the current value regardless of union branch ──────────────\nfunction numValue(v: AnswerValue | undefined): number | undefined {\n return v && \"value\" in v && typeof v.value === \"number\" ? v.value : undefined;\n}\nfunction strValue(v: AnswerValue | undefined): string | undefined {\n return v && \"value\" in v && typeof v.value === \"string\" ? v.value : undefined;\n}\n\n// ── Scale (NPS / CES) ─────────────────────────────────────────────────────────\nfunction ScaleInput({ min, max, minLabel, maxLabel, value, onPick }: { min: number; max: number; minLabel?: string; maxLabel?: string; value: number | undefined; onPick: (n: number) => void }) {\n const points: number[] = [];\n for (let i = min; i <= max; i++) points.push(i);\n // Short scales (CES 1–7) sit on one row of equal chips, like the mobile SDKs; longer ones (NPS 0–10)\n // wrap into centered rows of fixed-size chips.\n const oneRow = points.length <= 7;\n return (\n <div>\n <div\n className={oneRow ? \"ms-scale ms-scale-row\" : \"ms-scale ms-scale-wrap\"}\n role=\"group\"\n style={oneRow ? ({ \"--ms-scale-n\": points.length } as CSSProperties) : undefined}\n >\n {points.map((n) => (\n <button key={n} type=\"button\" className=\"ms-chip\" aria-pressed={value === n} onClick={() => onPick(n)}>\n {n}\n </button>\n ))}\n </div>\n {(minLabel || maxLabel) && (\n <div className=\"ms-endlabels\">\n <span>{minLabel}</span>\n <span>{maxLabel}</span>\n </div>\n )}\n </div>\n );\n}\n\n// ── Stars ─────────────────────────────────────────────────────────────────────\nfunction StarsInput({ count, value, onPick }: { count: number; value: number | undefined; onPick: (n: number) => void }) {\n const stars: number[] = [];\n for (let i = 1; i <= count; i++) stars.push(i);\n return (\n <div className=\"ms-stars\" role=\"group\">\n {stars.map((n) => (\n <button key={n} type=\"button\" className={`ms-star${value !== undefined && n <= value ? \" ms-on\" : \"\"}`} aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`} aria-pressed={value === n} onClick={() => onPick(n)}>\n ★\n </button>\n ))}\n </div>\n );\n}\n\n// ── Emoji ─────────────────────────────────────────────────────────────────────\nfunction EmojiInput({ options, value, onPick }: { options: { value: string; emoji: string; label?: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-emoji-row\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-emoji\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n <span className=\"ms-emoji-glyph\">{o.emoji}</span>\n {o.label && <span className=\"ms-emoji-label\">{o.label}</span>}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Thumbs ────────────────────────────────────────────────────────────────────\nfunction ThumbsInput({ value, onPick }: { value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-thumbs\" role=\"group\">\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs up\" aria-pressed={value === \"up\"} onClick={() => onPick(\"up\")}>\n 👍\n </button>\n <button type=\"button\" className=\"ms-thumb\" aria-label=\"Thumbs down\" aria-pressed={value === \"down\"} onClick={() => onPick(\"down\")}>\n 👎\n </button>\n </div>\n );\n}\n\n// ── Single choice ─────────────────────────────────────────────────────────────\nfunction ChoiceInput({ options, value, onPick }: { options: { value: string; label: string }[]; value: string | undefined; onPick: (v: string) => void }) {\n return (\n <div className=\"ms-choices\" role=\"group\">\n {options.map((o) => (\n <button key={o.value} type=\"button\" className=\"ms-choice\" aria-pressed={value === o.value} onClick={() => onPick(o.value)}>\n {o.label}\n </button>\n ))}\n </div>\n );\n}\n\n// ── Open text ─────────────────────────────────────────────────────────────────\nfunction OpenTextInput({ placeholder, maxLength, value, onInput }: { placeholder?: string; maxLength?: number; value: string; onInput: (t: string) => void }) {\n return (\n <div>\n <textarea className=\"ms-textarea\" placeholder={placeholder} maxLength={maxLength} value={value} onChange={(e) => onInput(e.target.value)} />\n {maxLength !== undefined && (\n <div className=\"ms-counter\">\n {value.length} / {maxLength}\n </div>\n )}\n </div>\n );\n}\n","//\n// theme.ts\n//\n// Maps a project `ProjectTheme` (from /api/sdk/config) onto CSS custom\n// properties consumed by the survey stylesheet, applying the same clean,\n// neutral defaults as the iOS `SurveyTheme.default` (indigo accent, zinc grays).\n// Also injects a Google Fonts <link> when the theme names a curated font.\n//\n// Dark-mode-aware palettes are a follow-up; for now the defaults are the\n// light-mode values and any theme key overrides them.\n//\n\nimport type { CSSProperties } from \"react\";\nimport type { ProjectTheme, Survey, WebPlacement } from \"@microsurveysai/web-core\";\n\n/** iOS `SurveyTheme.default` light-mode palette + metrics. */\nconst DEFAULTS = {\n scrim: \"rgba(9, 9, 11, 0.45)\",\n surface: \"#FFFFFF\",\n text: \"#18181B\",\n secondaryText: \"#71717A\",\n accent: \"#2E7272\", // Slate Teal (brand primary)\n accentText: \"#FFFFFF\",\n border: \"#E4E4E7\",\n track: \"#F4F4F5\",\n cardRadius: 16,\n controlRadius: 12,\n controlHeight: 48,\n spacing: 16,\n textScale: 1,\n titleSize: 20,\n titleWeight: \"semibold\",\n titleLineHeight: 1.1,\n titleLetterSpacing: 0,\n};\n\nconst WEIGHTS: Record<string, number> = { regular: 400, medium: 500, semibold: 600, bold: 700 };\n\nconst CURATED_FONTS = new Set([\"Inter\", \"Roboto\", \"Open Sans\", \"Noto Sans\", \"Lato\", \"Montserrat\", \"Poppins\"]);\n\nexport interface ResolvedTheme {\n /** CSS custom properties to spread onto the survey root's `style`. */\n vars: CSSProperties;\n /** A curated Google font family to lazy-load, or null for the system font. */\n googleFont: string | null;\n}\n\nfunction px(n: number): string {\n return `${n}px`;\n}\n\nconst COLOR_FN = /^(rgb|rgba|hsl|hsla)\\(\\s*[-+0-9.,%\\s/]*\\)$/i;\n\n/**\n * A theme string is used only if it can't make the browser fetch anything or break out of its\n * CSS value: no url()/image-set()/var() (plain rgb()/hsl() colors are fine), no CSS punctuation,\n * quotes or backslashes. Anything else falls back to the default for that key.\n */\nfunction safe(v: string | undefined): string | undefined {\n if (typeof v !== \"string\" || v.length > 100) return undefined;\n if (/[;:{}<>\"'`\\\\@!]/.test(v)) return undefined;\n if (v.includes(\"(\") || v.includes(\")\")) return COLOR_FN.test(v.trim()) ? v : undefined;\n return v;\n}\n\n/** A finite number kept within [lo, hi], or undefined. */\nfunction bounded(n: number | null | undefined, lo: number, hi: number): number | undefined {\n return typeof n === \"number\" && Number.isFinite(n) ? Math.min(Math.max(n, lo), hi) : undefined;\n}\n\nexport function resolveTheme(theme: ProjectTheme | null | undefined): ResolvedTheme {\n const raw = theme ?? {};\n // Same bounds the server applies before sending the theme; real themes sit well inside them.\n const t: ProjectTheme = {\n ...raw,\n accent: safe(raw.accent),\n accentText: safe(raw.accentText),\n surface: safe(raw.surface),\n text: safe(raw.text),\n secondaryText: safe(raw.secondaryText),\n border: safe(raw.border),\n font: safe(raw.font),\n cornerRadius: bounded(raw.cornerRadius, 0, 200),\n controlRadius: bounded(raw.controlRadius, 0, 200),\n controlHeight: bounded(raw.controlHeight, 16, 200),\n spacing: bounded(raw.spacing, 0, 200),\n textScale: bounded(raw.textScale, 0.25, 4),\n titleSize: bounded(raw.titleSize, 6, 120),\n titleLineHeight: bounded(raw.titleLineHeight, 0.5, 5),\n titleLetterSpacing: bounded(raw.titleLetterSpacing, -50, 50),\n };\n const controlHeight = t.controlHeight ?? DEFAULTS.controlHeight;\n const controlRadius = t.controlPill ? controlHeight / 2 : (t.controlRadius ?? DEFAULTS.controlRadius);\n const cardRadius = t.cornerRadius ?? DEFAULTS.cardRadius;\n const titleWeight = WEIGHTS[t.titleWeight ?? DEFAULTS.titleWeight] ?? 600;\n\n const font = t.font && t.font !== \"system\" && t.font.length > 0 ? t.font : null;\n const googleFont = font && CURATED_FONTS.has(font) ? font : null;\n const fontFamily = font\n ? `'${font}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`\n : \"system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif\";\n\n // CSS custom properties. Cast through a record since `--x` keys aren't in CSSProperties.\n const vars = {\n \"--ms-scrim\": DEFAULTS.scrim,\n \"--ms-surface\": t.surface ?? DEFAULTS.surface,\n \"--ms-text\": t.text ?? DEFAULTS.text,\n \"--ms-secondary-text\": t.secondaryText ?? DEFAULTS.secondaryText,\n \"--ms-accent\": t.accent ?? DEFAULTS.accent,\n \"--ms-accent-text\": t.accentText ?? DEFAULTS.accentText,\n \"--ms-border\": t.border ?? DEFAULTS.border,\n \"--ms-track\": DEFAULTS.track,\n \"--ms-card-radius\": px(cardRadius),\n \"--ms-control-radius\": px(controlRadius),\n \"--ms-control-height\": px(controlHeight),\n \"--ms-spacing\": px(t.spacing ?? DEFAULTS.spacing),\n \"--ms-text-scale\": String(t.textScale ?? DEFAULTS.textScale),\n \"--ms-title-size\": px(t.titleSize ?? DEFAULTS.titleSize),\n \"--ms-title-weight\": String(titleWeight),\n \"--ms-title-line-height\": String(t.titleLineHeight ?? DEFAULTS.titleLineHeight),\n \"--ms-title-letter-spacing\": px(t.titleLetterSpacing ?? DEFAULTS.titleLetterSpacing),\n \"--ms-font\": fontFamily,\n \"--ms-align\": t.alignment === \"center\" ? \"center\" : \"left\",\n } as CSSProperties;\n\n return { vars, googleFont };\n}\n\nconst PLACEMENTS: readonly WebPlacement[] = [\"bottom-right\", \"bottom-left\", \"top-right\", \"top-left\", \"bottom\", \"center\"];\n\nfunction asPlacement(v: unknown): WebPlacement | null {\n return typeof v === \"string\" && (PLACEMENTS as readonly string[]).includes(v) ? (v as WebPlacement) : null;\n}\n\n/**\n * Where the card sits: the survey's `webPlacement`, else the project theme's, else what the\n * survey's `presentation` gives it (a dialog is centered; a sheet, or nothing, docks to the bottom\n * the way the mobile SDKs show it, with the theme `position` as the last word).\n */\nexport function resolvePlacement(survey: Pick<Survey, \"webPlacement\" | \"presentation\">, theme: ProjectTheme | null | undefined): WebPlacement {\n const placed = asPlacement(survey.webPlacement) ?? asPlacement(theme?.webPlacement);\n if (placed) return placed;\n if (survey.presentation === \"dialog\") return \"center\";\n if (survey.presentation === \"sheet\") return \"bottom\";\n return theme?.position === \"center\" ? \"center\" : \"bottom\";\n}\n\n/** Corners float over the page; bottom and center are modal (dimmed page, focus held). */\nexport function isModalPlacement(p: WebPlacement): boolean {\n return p === \"bottom\" || p === \"center\";\n}\n\n/** Whether the survey starts minimized as a launcher: the survey's choice, else the theme's. */\nexport function resolveLauncher(survey: Pick<Survey, \"webLauncher\">, theme: ProjectTheme | null | undefined): boolean {\n if (typeof survey.webLauncher === \"boolean\") return survey.webLauncher;\n return theme?.webLauncher === true;\n}\n\n/** Lazily inject a Google Fonts stylesheet for a curated family (once). */\nexport function ensureGoogleFont(family: string | null): void {\n if (!family || typeof document === \"undefined\") return;\n const id = `ms-font-${family.replace(/\\s+/g, \"-\").toLowerCase()}`;\n if (document.getElementById(id)) return;\n const link = document.createElement(\"link\");\n link.id = id;\n link.rel = \"stylesheet\";\n link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family)}:wght@400;500;600;700&display=swap`;\n document.head.appendChild(link);\n}\n","//\n// styles.ts\n//\n// One self-contained stylesheet, injected once, scoped under `.ms-root`. It\n// reads the CSS custom properties set by `resolveTheme`, so every visual knob is\n// theme-driven. No Tailwind, no external CSS — safe to drop into any host app.\n//\n\nconst STYLE_ID = \"microsurveys-styles\";\n\nconst CSS = `\n.ms-root, .ms-root * { box-sizing: border-box; }\n.ms-root [hidden] { display: none !important; }\n.ms-root {\n font-family: var(--ms-font);\n color: var(--ms-text);\n text-align: var(--ms-align);\n -webkit-font-smoothing: antialiased;\n}\n\n/* ── Overlay ─────────────────────────────────────────────── */\n.ms-scrim {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; padding: var(--ms-spacing);\n background: var(--ms-scrim);\n animation: ms-fade 160ms ease-out;\n}\n.ms-scrim.ms-sheet { align-items: flex-end; justify-content: center; }\n.ms-scrim.ms-dialog { align-items: center; justify-content: center; }\n\n.ms-card {\n position: relative; width: 100%; max-width: 480px;\n background: var(--ms-surface);\n border-radius: var(--ms-card-radius);\n border: 1px solid var(--ms-border);\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.18);\n padding: calc(var(--ms-spacing) * 1.5);\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-card:focus { outline: none; }\n/* Once the visitor has opened or minimized, transitions come from motion.ts, not these entrances. */\n.ms-moved .ms-scrim, .ms-moved .ms-card, .ms-moved .ms-launcher-wrap { animation: none; }\n\n/* Floating card: pinned to a corner, no scrim, the page stays usable. */\n.ms-float {\n position: fixed; z-index: 2147483000;\n width: min(380px, calc(100vw - 40px));\n}\n.ms-float .ms-card {\n max-width: none; max-height: calc(100vh - 40px); overflow-y: auto;\n box-shadow: 0 12px 40px rgba(9, 9, 11, 0.22);\n}\n.ms-float.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-float.ms-at-bottom-left { left: 20px; bottom: 20px; }\n.ms-float.ms-at-top-right { right: 20px; top: 20px; }\n.ms-float.ms-at-top-left { left: 20px; top: 20px; }\n.ms-float.ms-at-top-right .ms-card, .ms-float.ms-at-top-left .ms-card { animation-name: ms-drop; }\n\n/* Launcher: the minimized survey, a pill in the accent color. */\n.ms-launcher-wrap {\n position: fixed; z-index: 2147483000;\n display: flex; align-items: center; gap: 8px;\n animation: ms-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n.ms-launcher-wrap.ms-at-bottom-right { right: 20px; bottom: 20px; }\n.ms-launcher-wrap.ms-at-bottom-left { left: 20px; bottom: 20px; flex-direction: row-reverse; }\n.ms-launcher-wrap.ms-at-top-right { right: 20px; top: 20px; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-top-left { left: 20px; top: 20px; flex-direction: row-reverse; animation-name: ms-drop; }\n.ms-launcher-wrap.ms-at-bottom {\n left: 0; right: 0; bottom: 20px; justify-content: center; pointer-events: none;\n}\n.ms-launcher-wrap.ms-at-bottom > * { pointer-events: auto; }\n.ms-launcher {\n display: inline-flex; align-items: center; gap: 8px;\n height: 44px; padding: 0 18px; max-width: min(320px, calc(100vw - 96px));\n border: none; border-radius: 22px; cursor: pointer;\n background: var(--ms-accent); color: var(--ms-accent-text);\n font: inherit; font-size: calc(14px * var(--ms-text-scale)); font-weight: 600;\n box-shadow: 0 8px 24px rgba(9, 9, 11, 0.22);\n transition: transform 120ms, box-shadow 120ms;\n}\n.ms-launcher:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(9, 9, 11, 0.26); }\n.ms-launcher:focus-visible, .ms-launcher-close:focus-visible {\n outline: 2px solid var(--ms-accent); outline-offset: 2px;\n}\n.ms-launcher-icon { flex: none; }\n.ms-launcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ms-launcher-close {\n flex: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;\n border: 1px solid var(--ms-border); background: var(--ms-surface); color: var(--ms-secondary-text);\n font-size: 12px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;\n box-shadow: 0 4px 12px rgba(9, 9, 11, 0.12);\n}\n.ms-launcher-close:hover { color: var(--ms-text); }\n\n/* Phones: a corner card spans the width, still on its edge. */\n@media (max-width: 520px) {\n .ms-float { width: auto; }\n .ms-float.ms-at-bottom-right, .ms-float.ms-at-bottom-left { left: 12px; right: 12px; bottom: 12px; }\n .ms-float.ms-at-top-right, .ms-float.ms-at-top-left { left: 12px; right: 12px; top: 12px; }\n .ms-float .ms-card { max-height: calc(100vh - 24px); }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-bottom-left { bottom: 12px; }\n .ms-launcher-wrap.ms-at-bottom-right, .ms-launcher-wrap.ms-at-top-right { right: 12px; }\n .ms-launcher-wrap.ms-at-bottom-left, .ms-launcher-wrap.ms-at-top-left { left: 12px; }\n .ms-launcher-wrap.ms-at-top-right, .ms-launcher-wrap.ms-at-top-left { top: 12px; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ms-scrim, .ms-card, .ms-launcher-wrap { animation: none; }\n .ms-launcher { transition: none; }\n}\n\n.ms-inline .ms-card {\n box-shadow: none; animation: none; max-width: none;\n}\n.ms-inline { display: block; }\n\n@keyframes ms-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes ms-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }\n@keyframes ms-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }\n\n/* ── Header ──────────────────────────────────────────────── */\n.ms-prompt {\n margin: 0 0 var(--ms-spacing);\n font-size: var(--ms-title-size);\n font-weight: var(--ms-title-weight);\n line-height: var(--ms-title-line-height);\n letter-spacing: var(--ms-title-letter-spacing);\n color: var(--ms-text);\n padding-right: 28px;\n}\n.ms-close {\n position: absolute; top: 14px; right: 14px;\n width: 28px; height: 28px; border: none; cursor: pointer;\n background: transparent; color: var(--ms-secondary-text);\n border-radius: 8px; font-size: 18px; line-height: 1;\n display: inline-flex; align-items: center; justify-content: center;\n}\n.ms-close:hover { background: var(--ms-track); color: var(--ms-text); }\n.ms-close.ms-minimize { right: 46px; }\n.ms-has-min .ms-prompt { padding-right: 60px; }\n\n.ms-progress {\n font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n margin: 0 0 8px;\n}\n\n/* ── Scale (NPS / CES) ───────────────────────────────────── */\n.ms-scale { gap: 8px; }\n/* Up to 7 points: one row of equal chips. Never taller than wide, so a narrow card gets circles, not ovals. */\n.ms-scale-row {\n display: grid; grid-template-columns: repeat(var(--ms-scale-n, 7), minmax(0, 1fr));\n container-type: inline-size;\n}\n.ms-scale-row .ms-chip {\n min-width: 0; padding: 0;\n height: min(var(--ms-control-height), calc((100cqi - 8px * (var(--ms-scale-n, 7) - 1)) / var(--ms-scale-n, 7)));\n}\n/* Longer scales (NPS): fixed-size chips wrapping into centered rows. */\n.ms-scale-wrap { display: flex; flex-wrap: wrap; justify-content: center; }\n.ms-scale-wrap .ms-chip { flex: 0 0 auto; width: var(--ms-control-height); padding: 0; }\n.ms-chip {\n height: var(--ms-control-height);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale));\n font-weight: 500; transition: background 120ms, border-color 120ms;\n}\n.ms-chip:hover { border-color: var(--ms-accent); }\n.ms-chip[aria-pressed=\"true\"] {\n background: var(--ms-accent); border-color: var(--ms-accent); color: var(--ms-accent-text);\n}\n.ms-endlabels {\n display: flex; justify-content: space-between; gap: 12px;\n margin-top: 8px; font-size: calc(12px * var(--ms-text-scale));\n color: var(--ms-secondary-text);\n}\n\n/* ── Stars ───────────────────────────────────────────────── */\n.ms-stars { display: flex; gap: 6px; }\n.ms-star {\n background: none; border: none; cursor: pointer; padding: 2px;\n font-size: calc(30px * var(--ms-text-scale)); line-height: 1;\n color: var(--ms-border); transition: color 100ms;\n}\n.ms-star.ms-on { color: var(--ms-accent); }\n\n/* ── Emoji ───────────────────────────────────────────────── */\n.ms-emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }\n.ms-emoji {\n flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;\n padding: 10px 6px; border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n}\n.ms-emoji:hover { border-color: var(--ms-accent); }\n.ms-emoji[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n.ms-emoji-glyph { font-size: calc(26px * var(--ms-text-scale)); line-height: 1; }\n.ms-emoji-label { font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); }\n\n/* ── Thumbs ──────────────────────────────────────────────── */\n.ms-thumbs { display: flex; gap: 12px; }\n.ms-thumb {\n flex: 1; height: calc(var(--ms-control-height) + 8px);\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n border-radius: var(--ms-control-radius); cursor: pointer;\n font-size: calc(22px * var(--ms-text-scale));\n}\n.ms-thumb:hover { border-color: var(--ms-accent); }\n.ms-thumb[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 12%, var(--ms-surface)); }\n\n/* ── Single choice ───────────────────────────────────────── */\n.ms-choices { display: flex; flex-direction: column; gap: 8px; }\n.ms-choice {\n min-height: var(--ms-control-height); padding: 12px 14px; text-align: left;\n border: 1px solid var(--ms-border); background: var(--ms-surface);\n color: var(--ms-text); border-radius: var(--ms-control-radius);\n cursor: pointer; font-size: calc(15px * var(--ms-text-scale)); font-weight: 500;\n}\n.ms-choice:hover { border-color: var(--ms-accent); }\n.ms-choice[aria-pressed=\"true\"] { border-color: var(--ms-accent); background: color-mix(in srgb, var(--ms-accent) 10%, var(--ms-surface)); }\n\n/* ── Open text ───────────────────────────────────────────── */\n.ms-textarea {\n width: 100%; min-height: 96px; resize: vertical; padding: 12px 14px;\n border: 1px solid var(--ms-border); border-radius: var(--ms-control-radius);\n background: var(--ms-surface); color: var(--ms-text);\n font: inherit; font-size: calc(15px * var(--ms-text-scale));\n}\n.ms-textarea:focus { outline: none; border-color: var(--ms-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ms-accent) 20%, transparent); }\n.ms-counter { margin-top: 6px; font-size: calc(12px * var(--ms-text-scale)); color: var(--ms-secondary-text); text-align: right; }\n\n/* ── Footer / button ─────────────────────────────────────── */\n.ms-footer { margin-top: calc(var(--ms-spacing) * 1.25); }\n.ms-btn {\n width: 100%; height: var(--ms-control-height);\n border: none; border-radius: var(--ms-control-radius);\n background: var(--ms-accent); color: var(--ms-accent-text);\n font-size: calc(15px * var(--ms-text-scale)); font-weight: 600; cursor: pointer;\n transition: opacity 120ms;\n}\n.ms-btn:hover { opacity: 0.92; }\n.ms-btn:disabled { opacity: 0.45; cursor: not-allowed; }\n\n/* ── Success ─────────────────────────────────────────────── */\n.ms-success {\n display: flex; flex-direction: column; align-items: center; gap: 10px;\n padding: calc(var(--ms-spacing) * 1.5) var(--ms-spacing);\n text-align: center;\n}\n.ms-thanks { cursor: pointer; }\n.ms-success-text { max-width: 100%; overflow-wrap: anywhere; }\n.ms-success-check {\n width: 44px; height: 44px; border-radius: 50%;\n background: var(--ms-accent); color: var(--ms-accent-text);\n display: flex; align-items: center; justify-content: center; font-size: 24px;\n}\n`;\n\n/** Inject the survey stylesheet once. No-op during SSR. */\nexport function ensureStyles(): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(STYLE_ID)) return;\n const el = document.createElement(\"style\");\n el.id = STYLE_ID;\n el.textContent = CSS;\n document.head.appendChild(el);\n}\n","//\n// motion.ts\n//\n// The \"unfurl\" transition between a minimized survey's launcher pill and its card: the card\n// scales up out of the launcher's corner with a soft spring, and scales back into it when\n// minimized. Built on the Web Animations API, so there are no dependencies. Where it's missing\n// (old browsers, test DOMs) every helper resolves at once and the change is instant.\n//\n// Visitors who ask for reduced motion get a short crossfade instead.\n//\n\nimport type { WebPlacement } from \"@microsurveysai/web-core\";\n\n/** A damped spring as a CSS `linear()` easing; a cubic-bezier with a little overshoot where unsupported. */\nconst SPRING = (() => {\n const points: number[] = [];\n for (let i = 0; i <= 48; i++) {\n const t = i / 48;\n points.push(i === 48 ? 1 : +(1 - Math.exp(-8 * t) * Math.cos(8 * t)).toFixed(4));\n }\n const spring = `linear(${points.join(\", \")})`;\n try {\n if (typeof CSS !== \"undefined\" && CSS.supports?.(\"transition-timing-function\", spring)) return spring;\n } catch {\n // CSS.supports can throw on odd hosts; fall through.\n }\n return \"cubic-bezier(0.3, 1.3, 0.4, 1)\";\n})();\nconst EASE_IN = \"cubic-bezier(0.4, 0, 1, 1)\";\nconst EASE_OUT = \"cubic-bezier(0.2, 0.8, 0.2, 1)\";\n\n/** Where the card grows from: the corner the launcher sits in. Modal placements dock the launcher bottom-center. */\nexport function unfurlOrigin(placement: WebPlacement): string {\n switch (placement) {\n case \"top-right\": return \"top right\";\n case \"top-left\": return \"top left\";\n case \"bottom-right\": return \"bottom right\";\n case \"bottom-left\": return \"bottom left\";\n default: return \"bottom center\";\n }\n}\n\nfunction reducedMotion(): boolean {\n try {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n } catch {\n return false;\n }\n}\n\n/** Stops any running transition on these elements and their contents. Their pending promises reject. */\nexport function stopMotion(...els: (Element | null | undefined)[]): void {\n for (const el of els) el?.getAnimations?.({ subtree: true }).forEach((a) => a.cancel());\n}\n\n/**\n * Runs one animation. Entrances end at the element's natural style, so they're dropped once done;\n * exits hold their last frame until the caller hides the element (and the next transition stops them).\n * Rejects if stopped part-way.\n */\nfunction play(\n el: Element | null | undefined,\n keyframes: Keyframe[],\n opts: { duration: number; delay?: number; easing?: string; origin?: string; exit?: boolean },\n): Promise<void> {\n const target = el as HTMLElement | null | undefined;\n if (!target || typeof target.animate !== \"function\") return Promise.resolve();\n if (opts.origin) target.style.transformOrigin = opts.origin;\n const anim = target.animate(keyframes, {\n duration: opts.duration,\n delay: opts.delay ?? 0,\n easing: opts.easing ?? \"ease\",\n fill: opts.exit ? \"forwards\" : \"backwards\",\n });\n return anim.finished.then(() => undefined);\n}\n\n/**\n * The rows of the card that settle in one after another, as [element, step]: the corner buttons\n * first (together, like a header row), then progress, prompt, each row of the question, the footer.\n */\nfunction cardParts(card: Element): [Element, number][] {\n const corner: Element[] = [];\n const rows: Element[] = [];\n for (const child of Array.from(card.children)) {\n if (child.classList.contains(\"ms-close\")) corner.push(child);\n // A question's wrapper (e.g. scale + end labels) staggers row by row.\n else if (child.tagName === \"DIV\" && !child.className && child.children.length > 1) rows.push(...Array.from(child.children));\n else rows.push(child);\n }\n const first = corner.length ? 1 : 0;\n return [...corner.map((el): [Element, number] => [el, 0]), ...rows.map((el, i): [Element, number] => [el, first + i])];\n}\n\n/**\n * The card opens out of the launcher's corner with a soft spring, then its contents settle in one\n * after another (each rises 6px and fades in, 40ms apart).\n */\nexport function cardIn(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 });\n const parts = card ? cardParts(card) : [];\n return Promise.all([\n play(\n card,\n [\n { opacity: 0, transform: \"scale(0.35)\" },\n { opacity: 1, transform: \"scale(0.7)\", offset: 0.25 },\n { opacity: 1, transform: \"scale(1)\" },\n ],\n { duration: 460, easing: SPRING, origin },\n ),\n ...parts.map(([el, i]) =>\n play(el, [{ opacity: 0, transform: \"translateY(6px)\" }, { opacity: 1, transform: \"none\" }], {\n duration: 260,\n delay: 120 + i * 40,\n easing: EASE_OUT,\n }),\n ),\n ]).then(() => undefined);\n}\n\n/** The card folds back into the launcher's corner. Holds its last frame; hide the card when it resolves. */\nexport function cardOut(card: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(card, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, exit: true });\n return play(\n card,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.35)\" }],\n { duration: 240, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The launcher pops back in once the card is mostly folded away. */\nexport function launcherIn(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, delay: 100 });\n return play(\n launcher,\n [{ opacity: 0, transform: \"scale(0.9)\" }, { opacity: 1, transform: \"scale(1)\" }],\n { duration: 300, delay: 150, easing: SPRING, origin },\n );\n}\n\n/** The launcher shrinks away as the card opens. Holds its last frame; remove the launcher when it resolves. */\nexport function launcherOut(launcher: Element | null | undefined, origin: string): Promise<void> {\n if (reducedMotion()) return play(launcher, [{ opacity: 1 }, { opacity: 0 }], { duration: 120, exit: true });\n return play(\n launcher,\n [{ opacity: 1, transform: \"scale(1)\" }, { opacity: 0, transform: \"scale(0.9)\" }],\n { duration: 140, easing: EASE_IN, origin, exit: true },\n );\n}\n\n/** The dimmed backdrop of a modal placement, fading with the card. Only its color animates, so the card\n * inside keeps its own opacity. One keyframe: the other end is the scrim's own color. */\nexport function scrimIn(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 0 }], { duration: 200 });\n}\n\nexport function scrimOut(scrim: Element | null | undefined): Promise<void> {\n return play(scrim, [{ backgroundColor: \"transparent\", offset: 1 }], { duration: 200, exit: true });\n}\n","//\n// MicroSurvey.tsx\n//\n// `<MicroSurvey surveyId>` — renders a specific survey **inline** in the page\n// flow (no overlay), e.g. embedded in a settings screen or a landing section.\n// Pulls the survey from the cached config; sends an impression when it renders\n// and a response when it closes. Has no equivalent in the iOS SDK (mobile is\n// overlay-only).\n//\n\n\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { ActiveSurvey, Survey, SurveyResult } from \"@microsurveysai/web-core\";\nimport { useMicroSurveysClient } from \"./provider\";\nimport { SurveyCard } from \"./SurveyCard\";\nimport { resolveTheme, ensureGoogleFont } from \"./theme\";\nimport { ensureStyles } from \"./styles\";\n\nexport interface MicroSurveyProps {\n surveyId: string;\n /** Called with the outcome when the inline survey closes. */\n onComplete?: (result: SurveyResult) => void;\n}\n\nexport function MicroSurvey({ surveyId, onComplete }: MicroSurveyProps) {\n const client = useMicroSurveysClient();\n const [survey, setSurvey] = useState<Survey | null>(null);\n const [closed, setClosed] = useState(false);\n // One showing per mounted survey: its impression is sent once, when it renders.\n const showing = useRef<ActiveSurvey | null>(null);\n\n useEffect(() => {\n if (!client) return;\n setSurvey(client.getSurvey(surveyId) ?? null);\n // Re-check when a config refresh lands (survey may not have been cached yet).\n return client.onConfigChange(() => setSurvey(client.getSurvey(surveyId) ?? null));\n }, [client, surveyId]);\n\n const visible = !!client && !!survey && !closed;\n if (visible && (!showing.current || showing.current.survey.id !== survey.id)) {\n showing.current = client.presentInline(survey);\n }\n\n useEffect(() => {\n if (visible) showing.current?.shown();\n }, [visible, survey]);\n\n if (!client || !survey || closed) return null;\n\n ensureStyles();\n const { vars, googleFont } = resolveTheme(client.getTheme());\n ensureGoogleFont(googleFont);\n\n function close(result: SurveyResult) {\n showing.current?.close(result);\n setClosed(true);\n onComplete?.(result);\n }\n\n return (\n <div className=\"ms-root ms-inline\" style={vars}>\n <SurveyCard survey={survey} onClose={close} />\n </div>\n );\n}\n"],"mappings":";;;AAUA,SAAS,eAAe,YAAY,aAAAA,YAAW,WAAAC,UAAS,YAAAC,iBAAgB;AACxE,SAAS,oBAA6C;;;ACStD,SAAS,aAAAC,YAAW,iBAAiB,UAAAC,SAAQ,YAAAC,iBAAgB;AAC7D,SAAS,oBAAoB;;;ACZ7B,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AACrD,SAAS,kBAAkB,qBAAqB;;;ACYnC,cAkDL,YAlDK;AAJN,SAAS,cAAc,EAAE,UAAU,OAAO,SAAS,GAAuB;AAC/E,QAAM,MAAM,SAAS;AACrB,UAAQ,IAAI,MAAM;AAAA,IAChB,KAAK;AACH,aAAO,oBAAC,cAAW,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,UAAU,IAAI,UAAU,UAAU,IAAI,UAAU,OAAO,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG;AAAA,IAChK,KAAK;AACH,aAAO,oBAAC,cAAW,OAAO,IAAI,OAAO,OAAO,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG;AAAA,IACtG,KAAK;AACH,aAAO,oBAAC,cAAW,SAAS,IAAI,SAAS,OAAO,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG;AAAA,IAC1G,KAAK;AACH,aAAO,oBAAC,e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OAAQ;AACb,cAAU,OAAO,UAAU,QAAQ,KAAK,IAAI;AAE5C,WAAO,OAAO,eAAe,MAAM,UAAU,OAAO,UAAU,QAAQ,KAAK,IAAI,CAAC;AAAA,EAClF,GAAG,CAAC,QAAQ,QAAQ,CAAC;AAErB,QAAM,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC;AACzC,MAAI,YAAY,CAAC,QAAQ,WAAW,QAAQ,QAAQ,OAAO,OAAO,OAAO,KAAK;AAC5E,YAAQ,UAAU,OAAO,cAAc,MAAM;AAAA,EAC/C;AAEA,EAAAA,WAAU,MAAM;AACd,QAAI,QAAS,SAAQ,SAAS,MAAM;AAAA,EACtC,GAAG,CAAC,SAAS,MAAM,CAAC;AAEpB,MAAI,CAAC,UAAU,CAAC,UAAU,OAAQ,QAAO;AAEzC,eAAa;AACb,QAAM,EAAE,MAAM,WAAW,IAAI,aAAa,OAAO,SAAS,CAAC;AAC3D,mBAAiB,UAAU;AAE3B,WAAS,MAAM,QAAsB;AACnC,YAAQ,SAAS,MAAM,MAAM;AAC7B,cAAU,IAAI;AACd,iBAAa,MAAM;AAAA,EACrB;AAEA,SACE,gBAAAH,KAAC,SAAI,WAAU,qBAAoB,OAAO,MACxC,0BAAAA,KAAC,cAAW,QAAgB,SAAS,OAAO,GAC9C;AAEJ;","names":["useEffect","useMemo","useState","useEffect","useRef","useState","jsx","jsxs","CSS","jsx","jsxs","useEffect","useState","useRef","card","jsx","jsxs","useState","useEffect","useMemo","useEffect","useRef","useState","jsx","useState","useRef","useEffect"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsurveysai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "React SDK for MicroSurveys — provider, hooks, and renderers for auto-triggered and inline in-app surveys.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"feedback"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@microsurveysai/web-core": "0.1.
|
|
44
|
+
"@microsurveysai/web-core": "0.1.15"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=18",
|