@magicfeedback/popup-sdk 1.17.2 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MagicfeedbackPopupSdk.podspec +18 -0
- package/README.md +33 -1
- package/dist/2.2.38-CCK7SF4A.mjs +2343 -0
- package/dist/2.2.38-CCK7SF4A.mjs.map +1 -0
- package/dist/2.2.38-LGZRM7GX.mjs +2343 -0
- package/dist/2.2.38-LGZRM7GX.mjs.map +1 -0
- package/dist/2.2.39-BJJ3YRJ4.mjs +2344 -0
- package/dist/2.2.39-BJJ3YRJ4.mjs.map +1 -0
- package/dist/2.2.39-HPNDYUPP.mjs +2344 -0
- package/dist/2.2.39-HPNDYUPP.mjs.map +1 -0
- package/dist/assets/assets/style.css +165 -1
- package/dist/assets/assets/survey-css/2.2.38.css +2335 -0
- package/dist/assets/assets/survey-css/2.2.39.css +2336 -0
- package/dist/chunk-3QS3WKRC.mjs +31 -0
- package/dist/chunk-3QS3WKRC.mjs.map +1 -0
- package/dist/chunk-7ZQOAKXR.mjs +3335 -0
- package/dist/chunk-7ZQOAKXR.mjs.map +1 -0
- package/dist/chunk-BJTO5JO5.mjs +11 -0
- package/dist/chunk-BJTO5JO5.mjs.map +1 -0
- package/dist/{chunk-AFRHPS3K.mjs → chunk-EW2ARDEY.mjs} +591 -51
- package/dist/chunk-EW2ARDEY.mjs.map +1 -0
- package/dist/{chunk-VHTN5UXD.mjs → chunk-XOEEBDBJ.mjs} +630 -10
- package/dist/chunk-XOEEBDBJ.mjs.map +1 -0
- package/dist/index.d.mts +159 -10
- package/dist/index.d.ts +159 -10
- package/dist/index.js +7275 -1466
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -41
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +1616 -0
- package/dist/index.native.d.ts +1616 -0
- package/dist/index.native.js +15853 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.native.mjs +3914 -0
- package/dist/index.native.mjs.map +1 -0
- package/dist/react-native.d.mts +105 -8
- package/dist/react-native.d.ts +105 -8
- package/dist/react-native.js +5827 -132
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +313 -43
- package/dist/react-native.mjs.map +1 -1
- package/dist/renderPopup-2Y4QMWR7.mjs +3847 -0
- package/dist/renderPopup-2Y4QMWR7.mjs.map +1 -0
- package/dist/renderPopup-YDJUON42.mjs +3847 -0
- package/dist/renderPopup-YDJUON42.mjs.map +1 -0
- package/dist/{renderPopup-L2Q3KJAZ.mjs → renderPopup-ZHTRMFO2.mjs} +142 -9
- package/dist/renderPopup-ZHTRMFO2.mjs.map +1 -0
- package/ios/DeepdotsBackgroundTask.m +71 -0
- package/package.json +14 -5
- package/react-native.config.js +9 -0
- package/dist/chunk-AFRHPS3K.mjs.map +0 -1
- package/dist/chunk-VHTN5UXD.mjs.map +0 -1
- package/dist/renderPopup-L2Q3KJAZ.mjs.map +0 -1
- package/dist/renderPopup-PQWJSBOY.mjs +0 -3622
- package/dist/renderPopup-PQWJSBOY.mjs.map +0 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BUNDLED_SURVEY_SDK_VERSION,
|
|
2
3
|
REVEAL_TIMEOUT_MS,
|
|
3
4
|
applySurveyPrimaryColor,
|
|
4
5
|
buildFontFaceCss,
|
|
5
6
|
buildFontFamilyValue,
|
|
6
7
|
buildSurveyIdentity,
|
|
8
|
+
chooseSurveySdkVersion,
|
|
9
|
+
classifySubmitError,
|
|
10
|
+
describeSurveySdkChoice,
|
|
7
11
|
directionFor,
|
|
8
12
|
getLabels,
|
|
9
13
|
resolveActionLabels,
|
|
@@ -12,8 +16,10 @@ import {
|
|
|
12
16
|
sdkLog,
|
|
13
17
|
sdkWarn,
|
|
14
18
|
setSurveyBusy,
|
|
15
|
-
style_default
|
|
16
|
-
|
|
19
|
+
style_default,
|
|
20
|
+
surveySdkUrls
|
|
21
|
+
} from "./chunk-EW2ARDEY.mjs";
|
|
22
|
+
import "./chunk-BJTO5JO5.mjs";
|
|
17
23
|
|
|
18
24
|
// src/ui/logo.ts
|
|
19
25
|
var BASE_CSS = "max-height:40px; max-width:100%; object-fit:contain; display:block; margin:12px 0 0 0;";
|
|
@@ -52,8 +58,122 @@ function insertPopupLogo(parent, anchor, style, id) {
|
|
|
52
58
|
return img;
|
|
53
59
|
}
|
|
54
60
|
|
|
61
|
+
// src/ui/surveySdkLoader.ts
|
|
62
|
+
import bundledSurveySdk from "@magicfeedback/native";
|
|
63
|
+
|
|
64
|
+
// src/ui/surveyCss.ts
|
|
65
|
+
var SURVEY_CSS_LOADERS = {
|
|
66
|
+
"2.2.38": () => import("./2.2.38-CCK7SF4A.mjs"),
|
|
67
|
+
"2.2.39": () => import("./2.2.39-HPNDYUPP.mjs")
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/ui/surveySdkLoader.ts
|
|
71
|
+
var SURVEY_SDK_LOAD_TIMEOUT_MS = 6e3;
|
|
72
|
+
async function loadVendoredCss(version) {
|
|
73
|
+
const load = SURVEY_CSS_LOADERS[version];
|
|
74
|
+
if (!load) throw new Error(`no vendored survey CSS for ${version}`);
|
|
75
|
+
const css = (await load()).default;
|
|
76
|
+
if (typeof css !== "string" || css.length === 0) throw new Error(`empty survey CSS for ${version}`);
|
|
77
|
+
return css;
|
|
78
|
+
}
|
|
79
|
+
var cache = /* @__PURE__ */ new Map();
|
|
80
|
+
var queue = Promise.resolve();
|
|
81
|
+
function isUsable(sdk) {
|
|
82
|
+
return !!sdk && typeof sdk.form === "function" && typeof sdk.init === "function";
|
|
83
|
+
}
|
|
84
|
+
function loadUmdScript(url, nonce, timeoutMs = SURVEY_SDK_LOAD_TIMEOUT_MS) {
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
const w = window;
|
|
87
|
+
const hadGlobal = Object.prototype.hasOwnProperty.call(w, "magicfeedback");
|
|
88
|
+
const previous = w.magicfeedback;
|
|
89
|
+
const amdDefine = typeof w.define === "function" && w.define.amd ? w.define : void 0;
|
|
90
|
+
if (amdDefine) w.define = void 0;
|
|
91
|
+
const script = document.createElement("script");
|
|
92
|
+
script.src = url;
|
|
93
|
+
script.async = true;
|
|
94
|
+
script.crossOrigin = "anonymous";
|
|
95
|
+
if (nonce) script.setAttribute("nonce", nonce);
|
|
96
|
+
let settled = false;
|
|
97
|
+
const finish = (error) => {
|
|
98
|
+
if (settled) return;
|
|
99
|
+
settled = true;
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
const loaded = w.magicfeedback;
|
|
102
|
+
if (hadGlobal) w.magicfeedback = previous;
|
|
103
|
+
else delete w.magicfeedback;
|
|
104
|
+
if (amdDefine) w.define = amdDefine;
|
|
105
|
+
script.remove();
|
|
106
|
+
if (error) reject(error);
|
|
107
|
+
else if (loaded === previous || !isUsable(loaded)) reject(new Error("survey SDK script did not expose magicfeedback"));
|
|
108
|
+
else resolve(loaded);
|
|
109
|
+
};
|
|
110
|
+
const timer = setTimeout(() => finish(new Error(`timeout after ${timeoutMs} ms`)), timeoutMs);
|
|
111
|
+
script.onload = () => finish();
|
|
112
|
+
script.onerror = () => finish(new Error("script failed to load"));
|
|
113
|
+
document.head.appendChild(script);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async function loadVersion(version, nonce, loadScript, loadCss) {
|
|
117
|
+
let css;
|
|
118
|
+
try {
|
|
119
|
+
css = await loadCss(version);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
sdkWarn(`[Deepdots] survey CSS ${version} failed:`, error);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const sdk = await loadScriptChain(version, nonce, loadScript);
|
|
125
|
+
return sdk ? { sdk, css } : null;
|
|
126
|
+
}
|
|
127
|
+
async function loadScriptChain(version, nonce, loadScript) {
|
|
128
|
+
for (const url of surveySdkUrls(version)) {
|
|
129
|
+
const attempt = queue.then(() => loadScript(url, nonce));
|
|
130
|
+
queue = attempt.catch(() => void 0);
|
|
131
|
+
try {
|
|
132
|
+
const sdk = await attempt;
|
|
133
|
+
if (isUsable(sdk)) return sdk;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
sdkWarn(`[Deepdots] survey SDK ${version} failed from ${url}:`, error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
function logSurveySdkChoice(choice, debug) {
|
|
141
|
+
const problem = choice.source === "bundled" && (choice.reason === "invalid" || choice.reason === "load_failed");
|
|
142
|
+
if (problem) sdkWarn(`[Deepdots] ${describeSurveySdkChoice(choice)}`);
|
|
143
|
+
else if (debug) sdkLog(`[Deepdots] ${describeSurveySdkChoice(choice)}`);
|
|
144
|
+
}
|
|
145
|
+
async function resolveSurveySdk(requested, options = {}, deps = {}) {
|
|
146
|
+
const { nonce, debug } = options;
|
|
147
|
+
const bundled = deps.bundled ?? bundledSurveySdk;
|
|
148
|
+
const choice = chooseSurveySdkVersion(requested);
|
|
149
|
+
if (choice.source === "bundled" || typeof document === "undefined") {
|
|
150
|
+
logSurveySdkChoice(choice, debug);
|
|
151
|
+
return { sdk: bundled, choice };
|
|
152
|
+
}
|
|
153
|
+
const loadScript = deps.loadScript ?? loadUmdScript;
|
|
154
|
+
const loadCss = deps.loadCss ?? loadVendoredCss;
|
|
155
|
+
let pending = cache.get(choice.version);
|
|
156
|
+
if (!pending) {
|
|
157
|
+
pending = loadVersion(choice.version, nonce, loadScript, loadCss);
|
|
158
|
+
cache.set(choice.version, pending);
|
|
159
|
+
}
|
|
160
|
+
const loaded = await pending;
|
|
161
|
+
if (loaded) {
|
|
162
|
+
logSurveySdkChoice(choice, debug);
|
|
163
|
+
return { sdk: loaded.sdk, css: loaded.css, choice };
|
|
164
|
+
}
|
|
165
|
+
cache.delete(choice.version);
|
|
166
|
+
const fallback = {
|
|
167
|
+
version: BUNDLED_SURVEY_SDK_VERSION,
|
|
168
|
+
source: "bundled",
|
|
169
|
+
reason: "load_failed",
|
|
170
|
+
requested: choice.version
|
|
171
|
+
};
|
|
172
|
+
logSurveySdkChoice(fallback, debug);
|
|
173
|
+
return { sdk: bundled, choice: fallback };
|
|
174
|
+
}
|
|
175
|
+
|
|
55
176
|
// src/ui/renderPopup.ts
|
|
56
|
-
import magicfeedback from "@magicfeedback/native";
|
|
57
177
|
function ensureStyle(id, css, nonce) {
|
|
58
178
|
let el = document.getElementById(id);
|
|
59
179
|
if (el && nonce && el.getAttribute("nonce") !== nonce) {
|
|
@@ -661,6 +781,14 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
661
781
|
return;
|
|
662
782
|
}
|
|
663
783
|
let formInstance = null;
|
|
784
|
+
const { sdk: magicfeedback, choice: surveySdk, css: surveySdkCss } = await resolveSurveySdk(
|
|
785
|
+
options?.surveySdkVersion,
|
|
786
|
+
{ nonce: cspNonce, debug: options?.debug }
|
|
787
|
+
);
|
|
788
|
+
popup.dataset.surveySdk = `${surveySdk.version} ${surveySdk.source}`;
|
|
789
|
+
if (!container.contains(popup)) return;
|
|
790
|
+
if (surveySdkCss) ensureStyle("magicfeedback-sdk-styles", surveySdkCss, cspNonce);
|
|
791
|
+
else ensureMagicFeedbackStyles(cspNonce);
|
|
664
792
|
try {
|
|
665
793
|
if (!magicfeedback || typeof magicfeedback.form !== "function") {
|
|
666
794
|
sdkWarn("[MagicFeedback] form() no disponible. Fallback manual.");
|
|
@@ -753,22 +881,27 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
753
881
|
autofocusOnOpen();
|
|
754
882
|
}
|
|
755
883
|
};
|
|
884
|
+
let lastReportedError = null;
|
|
756
885
|
generateOptions.beforeSubmitEvent = () => {
|
|
757
886
|
setLoading(true);
|
|
758
887
|
};
|
|
759
888
|
generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
|
|
760
|
-
|
|
761
|
-
if (errText) {
|
|
889
|
+
if (error) {
|
|
762
890
|
setLoading(false);
|
|
763
|
-
|
|
764
|
-
|
|
891
|
+
const { reason, message } = classifySubmitError(error);
|
|
892
|
+
if (reason === "required" || reason === "invalid_email") {
|
|
893
|
+
errorHint.textContent = reason === "invalid_email" ? labels.errorInvalidEmail : labels.errorRequired;
|
|
765
894
|
errorHint.style.display = "block";
|
|
766
895
|
updateNavButtons();
|
|
767
896
|
return;
|
|
768
897
|
}
|
|
769
898
|
errorHint.textContent = labels.errorSubmit;
|
|
770
899
|
errorHint.style.display = "block";
|
|
771
|
-
sdkWarn("[Deepdots] survey submit error:",
|
|
900
|
+
sdkWarn("[Deepdots] survey submit error:", reason, message);
|
|
901
|
+
if (error !== lastReportedError) {
|
|
902
|
+
lastReportedError = error;
|
|
903
|
+
emit("survey_error", surveyId, { reason, message });
|
|
904
|
+
}
|
|
772
905
|
return;
|
|
773
906
|
}
|
|
774
907
|
errorHint.style.display = "none";
|
|
@@ -805,4 +938,4 @@ export {
|
|
|
805
938
|
SURVEY_ALIGNMENT_STYLE_ID,
|
|
806
939
|
renderPopup
|
|
807
940
|
};
|
|
808
|
-
//# sourceMappingURL=renderPopup-
|
|
941
|
+
//# sourceMappingURL=renderPopup-ZHTRMFO2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/logo.ts","../src/ui/surveySdkLoader.ts","../src/ui/surveyCss.ts","../src/ui/renderPopup.ts"],"sourcesContent":["/**\n * Logo del popup (viene en `formData.style` del survey, no del `init`).\n *\n * Vive encima de la barra de progreso, como hermano del header: la marca abre la tarjeta y el\n * progreso queda pegado a la pregunta. Antes se insertaba DENTRO del contenido (web) o del área\n * scrollable (WebView de RN), así que la barra quedaba por encima del logo y en RN el logo se\n * iba con el scroll.\n *\n * El hueco inferior lo pone el bloque siguiente (`.deepdots-progress` cuando se ve, o el\n * `padding-top` del contenido cuando no), así que aquí solo se separa del header.\n */\nexport interface PopupLogoStyle {\n logo?: string;\n logoSize?: string;\n logoPosition?: string;\n}\n\nconst BASE_CSS = 'max-height:40px; max-width:100%; object-fit:contain; display:block; margin:12px 0 0 0;';\n\nconst MAX_HEIGHT: Record<string, string> = {\n small: '30px',\n medium: '50px',\n large: '70px',\n};\n\n/**\n * Inserta el logo en `parent`, justo antes de `anchor` (la barra de progreso).\n * No-op si el estilo no trae logo o si ya existe uno con ese `id`.\n */\nexport function insertPopupLogo(\n parent: HTMLElement,\n anchor: HTMLElement | null,\n style: PopupLogoStyle | undefined,\n id: string,\n): HTMLImageElement | null {\n if (!style?.logo) return null;\n if (parent.ownerDocument.getElementById(id)) return null;\n\n const img = parent.ownerDocument.createElement('img');\n img.id = id;\n img.src = style.logo;\n img.alt = 'Logo';\n img.style.cssText = BASE_CSS;\n\n if (style.logoSize && MAX_HEIGHT[style.logoSize]) {\n img.style.maxHeight = MAX_HEIGHT[style.logoSize];\n }\n // Márgenes lógicos (inline-start/end) en vez de left/right: con un survey RTL (árabe) el\n // popup se pinta con dir=\"rtl\" y el logo tiene que acompañar al resto del chrome. En LTR\n // el resultado es idéntico al de antes.\n switch (style.logoPosition) {\n case 'left':\n img.style.margin = '12px 0 0 0';\n img.style.setProperty('margin-inline-start', '0');\n img.style.setProperty('margin-inline-end', '16px');\n break;\n case 'right':\n img.style.margin = '12px 0 0 0';\n img.style.setProperty('margin-inline-start', 'auto');\n img.style.setProperty('margin-inline-end', '0');\n break;\n case 'center':\n img.style.margin = '12px auto 0 auto';\n break;\n }\n\n parent.insertBefore(img, anchor);\n return img;\n}\n","import bundledSurveySdk from '@magicfeedback/native';\nimport {\n BUNDLED_SURVEY_SDK_VERSION,\n chooseSurveySdkVersion,\n describeSurveySdkChoice,\n surveySdkUrls,\n type SurveySdkChoice,\n} from './surveySdkVersion';\nimport { sdkLog, sdkWarn } from '../util/logger';\nimport { SURVEY_CSS_LOADERS } from './surveyCss';\n\n/**\n * Survey SDK del popup DOM web (DD-70): la versión de `@magicfeedback/native` asignada al survey\n * en el Admin si está en rango y carga, o la que va empaquetada en este SDK si no.\n *\n * La asignada se trae como `<script>` del bundle de navegador (UMD) desde jsDelivr y, si falla,\n * desde unpkg. El UMD se publica en `self.magicfeedback`: se recoge al terminar de ejecutar y se\n * devuelve el global a como estaba, para no pisar un `magicfeedback` propio del host. Si el host\n * usa un loader AMD (`define.amd`), el UMD se registraría como módulo anónimo y no dejaría global;\n * mientras se carga se oculta `define` para que tome la rama del global.\n *\n * El CSS va con la JS: la hoja vendorizada de esa versión (`src/assets/survey-css/<v>.css`,\n * acotada a `.deepdots-popup`), que viaja dentro del SDK como chunk perezoso. Si la hoja o la JS\n * no cargan, se usan las dos empaquetadas: nunca JS de una versión con CSS de otra.\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SurveySdk = any;\n\nexport interface LoadedSurveySdk {\n sdk: SurveySdk;\n choice: SurveySdkChoice;\n /** CSS vendorizado de la versión asignada; undefined = el empaquetado (`style.css`). */\n css?: string;\n}\n\n/** Tiempo máximo por URL antes de pasar a la siguiente. */\nexport const SURVEY_SDK_LOAD_TIMEOUT_MS = 6000;\n\ninterface LoaderDeps {\n /** Inyectable en tests. Resuelve con el SDK cargado o rechaza. */\n loadScript?: (url: string, nonce?: string) => Promise<SurveySdk>;\n bundled?: SurveySdk;\n /** Inyectable en tests. */\n loadCss?: (version: string) => Promise<string>;\n}\n\nasync function loadVendoredCss(version: string): Promise<string> {\n const load = SURVEY_CSS_LOADERS[version];\n if (!load) throw new Error(`no vendored survey CSS for ${version}`);\n const css = (await load()).default;\n if (typeof css !== 'string' || css.length === 0) throw new Error(`empty survey CSS for ${version}`);\n return css;\n}\n\nconst cache = new Map<string, Promise<{ sdk: SurveySdk; css: string } | null>>();\n/** Cadena para no ejecutar dos UMD a la vez (los dos escriben el mismo global). */\nlet queue: Promise<unknown> = Promise.resolve();\n\nfunction isUsable(sdk: SurveySdk): boolean {\n return !!sdk && typeof sdk.form === 'function' && typeof sdk.init === 'function';\n}\n\n/** Carga un UMD por `<script>` y devuelve lo que dejó en `self.magicfeedback`. */\nexport function loadUmdScript(url: string, nonce?: string, timeoutMs = SURVEY_SDK_LOAD_TIMEOUT_MS): Promise<SurveySdk> {\n return new Promise((resolve, reject) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const hadGlobal = Object.prototype.hasOwnProperty.call(w, 'magicfeedback');\n const previous = w.magicfeedback;\n const amdDefine = typeof w.define === 'function' && w.define.amd ? w.define : undefined;\n if (amdDefine) w.define = undefined;\n\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n script.crossOrigin = 'anonymous';\n if (nonce) script.setAttribute('nonce', nonce);\n\n let settled = false;\n const finish = (error?: unknown) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n const loaded = w.magicfeedback;\n if (hadGlobal) w.magicfeedback = previous;\n else delete w.magicfeedback;\n if (amdDefine) w.define = amdDefine;\n script.remove();\n if (error) reject(error);\n else if (loaded === previous || !isUsable(loaded)) reject(new Error('survey SDK script did not expose magicfeedback'));\n else resolve(loaded);\n };\n const timer = setTimeout(() => finish(new Error(`timeout after ${timeoutMs} ms`)), timeoutMs);\n script.onload = () => finish();\n script.onerror = () => finish(new Error('script failed to load'));\n document.head.appendChild(script);\n });\n}\n\nasync function loadVersion(\n version: string,\n nonce: string | undefined,\n loadScript: NonNullable<LoaderDeps['loadScript']>,\n loadCss: NonNullable<LoaderDeps['loadCss']>,\n): Promise<{ sdk: SurveySdk; css: string } | null> {\n // La hoja primero: sin ella no se usa la JS de esa versión.\n let css: string;\n try {\n css = await loadCss(version);\n } catch (error) {\n sdkWarn(`[Deepdots] survey CSS ${version} failed:`, error);\n return null;\n }\n const sdk = await loadScriptChain(version, nonce, loadScript);\n return sdk ? { sdk, css } : null;\n}\n\nasync function loadScriptChain(version: string, nonce: string | undefined, loadScript: NonNullable<LoaderDeps['loadScript']>): Promise<SurveySdk | null> {\n for (const url of surveySdkUrls(version)) {\n const attempt = queue.then(() => loadScript(url, nonce));\n queue = attempt.catch(() => undefined);\n try {\n const sdk = await attempt;\n if (isUsable(sdk)) return sdk;\n } catch (error) {\n sdkWarn(`[Deepdots] survey SDK ${version} failed from ${url}:`, error);\n }\n }\n return null;\n}\n\n/**\n * Devuelve el survey SDK con el que pintar un survey a partir de `surveyFrontend.sdkVersion`.\n * Nunca rechaza: ante cualquier fallo devuelve el empaquetado con `reason: 'load_failed'`.\n */\nexport interface ResolveSurveySdkOptions {\n /** Nonce de la CSP del host, puesto en el `<script>`. */\n nonce?: string;\n /** `init({debug})`: la elección normal solo se loguea con debug. */\n debug?: boolean;\n}\n\n/**\n * Log de la elección: con `debug`, siempre; sin él, solo si la API pidió una versión que debía\n * poder usarse y no se ha podido (inválida, no cargó). Una versión no soportada NO avisa sin\n * debug: es lo normal para surveys en versiones antiguas (p. ej. prod latest 3.2.0 → 2.2.36) y\n * saldría en cada apertura en la consola del cliente.\n */\nexport function logSurveySdkChoice(choice: SurveySdkChoice, debug?: boolean): void {\n const problem = choice.source === 'bundled'\n && (choice.reason === 'invalid' || choice.reason === 'load_failed');\n if (problem) sdkWarn(`[Deepdots] ${describeSurveySdkChoice(choice)}`);\n else if (debug) sdkLog(`[Deepdots] ${describeSurveySdkChoice(choice)}`);\n}\n\nexport async function resolveSurveySdk(\n requested: string | null | undefined,\n options: ResolveSurveySdkOptions = {},\n deps: LoaderDeps = {},\n): Promise<LoadedSurveySdk> {\n const { nonce, debug } = options;\n const bundled = deps.bundled ?? bundledSurveySdk;\n const choice = chooseSurveySdkVersion(requested);\n if (choice.source === 'bundled' || typeof document === 'undefined') {\n logSurveySdkChoice(choice, debug);\n return { sdk: bundled, choice };\n }\n\n const loadScript = deps.loadScript ?? loadUmdScript;\n const loadCss = deps.loadCss ?? loadVendoredCss;\n let pending = cache.get(choice.version);\n if (!pending) {\n pending = loadVersion(choice.version, nonce, loadScript, loadCss);\n cache.set(choice.version, pending);\n }\n const loaded = await pending;\n if (loaded) {\n logSurveySdkChoice(choice, debug);\n return { sdk: loaded.sdk, css: loaded.css, choice };\n }\n // No se cachea el fallo: la siguiente apertura lo reintenta (CDN caído un momento).\n cache.delete(choice.version);\n const fallback: SurveySdkChoice = {\n version: BUNDLED_SURVEY_SDK_VERSION,\n source: 'bundled',\n reason: 'load_failed',\n requested: choice.version,\n };\n logSurveySdkChoice(fallback, debug);\n return { sdk: bundled, choice: fallback };\n}\n\n/** Solo tests. */\nexport function resetSurveySdkCache(): void {\n cache.clear();\n queue = Promise.resolve();\n}\n","/**\n * CSS vendorizado de cada versión de survey SDK asignable (DD-70), para el popup DOM. Va dentro\n * del SDK como chunks perezosos (texto): solo se descarga la hoja de la versión que tenga\n * asignada un survey, sin depender del CDN. Las claves son `SUPPORTED_SURVEY_SDK_VERSIONS`\n * (un test lo comprueba). La de la versión empaquetada es `src/assets/style.css`.\n */\nexport const SURVEY_CSS_LOADERS: Record<string, () => Promise<{ default: string }>> = {\n '2.2.38': () => import('../assets/survey-css/2.2.38.css'),\n '2.2.39': () => import('../assets/survey-css/2.2.39.css'),\n};\n","import {DeepdotsEventType, PopupActions, PopupStyle, FormData} from '../types';\nimport { buildSurveyIdentity } from '../tracking/tracking-manager';\nimport type { PopupRenderOptions } from '../platform/renderer';\nimport { buildFontFaceCss, buildFontFamilyValue } from './font';\nimport { insertPopupLogo } from './logo';\nimport { applySurveyPrimaryColor } from './surveyPalette';\nimport { setSurveyBusy } from './busy';\nimport { sdkLog, sdkWarn, sdkError } from '../util/logger';\nimport { directionFor, getLabels, resolveActionLabels } from '../i18n/labels';\nimport { REVEAL_TIMEOUT_MS, revealWhenPainted as revealWhenImagesLoaded } from './reveal';\nimport { classifySubmitError } from './submitError';\nimport { resolveSurveySdk } from './surveySdkLoader';\nimport magicfeedbackCss from '../assets/style.css';\n\n// Reexportado desde aquí porque este era su sitio original: la constante se mudó a `reveal.ts`\n// para que la ruta del WebView pueda leerla sin arrastrar `@magicfeedback/native`.\nexport { REVEAL_TIMEOUT_MS } from './reveal';\n\n/**\n * `<style>` del SDK en el `<head>`, identificado por `id` e inyectado una sola vez. Con `nonce`\n * (la CSP del host, ver `DeepdotsInitParams.cspNonce`) lo lleva puesto desde que se inserta:\n * el navegador solo comprueba el nonce al insertar, así que una hoja que ya estaba sin él (o con\n * otro) se recrea en vez de parchearse.\n */\nfunction ensureStyle(id: string, css: string, nonce?: string): HTMLStyleElement {\n let el = document.getElementById(id) as HTMLStyleElement | null;\n if (el && nonce && el.getAttribute('nonce') !== nonce) {\n el.remove();\n el = null;\n }\n if (!el) {\n el = document.createElement('style');\n el.id = id;\n if (nonce) el.setAttribute('nonce', nonce);\n el.textContent = css;\n document.head.appendChild(el);\n } else if (el.textContent !== css) {\n el.textContent = css;\n }\n return el;\n}\n\n// Inserta la hoja de estilos de MagicFeedback directamente en el popup para garantizar estilos incluso si el bundler no la inyecta globalmente.\nfunction ensureMagicFeedbackStyles(nonce?: string) {\n ensureStyle('magicfeedback-sdk-styles', magicfeedbackCss, nonce);\n}\n\n/**\n * Id del bloque que alinea el contenido del survey con el chrome del popup. Exportado para que\n * los tests puedan localizarlo sin depender de la posición en el `<head>`.\n */\nexport const SURVEY_ALIGNMENT_STYLE_ID = 'deepdots-survey-alignment';\n\n/**\n * El margen lateral lo pone la tarjeta del popup, pero el CSS de `@magicfeedback/native` añade el\n * suyo en tres capas: el contenedor, el formulario (hasta 28px) y el bloque de cada pregunta\n * (12px, con fondo igual al de la tarjeta, así que ni se ve). Sumados, dejan el enunciado y las\n * opciones bastante más adentro que el logo, el título y la barra de progreso, que sí llegan al\n * borde. Aquí se anula solo el lateral: el vertical es el que separa las preguntas.\n *\n * Va acotado a `.deepdots-popup` porque esta hoja se inyecta en el `<head>` del host y sin acotar\n * repintaría sus propios formularios; de paso, la especificidad extra hace que gane sobre el CSS\n * del paquete sin depender del orden.\n */\nfunction ensureSurveyAlignmentStyles(nonce?: string) {\n ensureStyle(SURVEY_ALIGNMENT_STYLE_ID, `\n .deepdots-popup .magicfeedback-container,\n .deepdots-popup .magicfeedback-form,\n .deepdots-popup .magicfeedback-div { padding-left: 0; padding-right: 0; }\n `, nonce);\n}\n\n// Añade estilos de spinner si no existen\nfunction ensureSpinnerStyles(nonce?: string) {\n ensureStyle('deepdots-spinner-styles', `\n /* El enunciado trae margin-top:20px del CSS de surveys, que sumaba al hueco de la barra\n de progreso y descompensaba la simetría. Solo se anula en el primero: entre preguntas\n de la misma página sigue separando. */\n .deepdots-popup .magicfeedback-questions .magicfeedback-div:first-child .magicfeedback-label { margin-top: 0; }\n @keyframes ddspin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n .mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }\n .mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }\n `, nonce);\n}\n\nfunction ensureResponsiveStyles(nonce?: string) {\n ensureStyle('deepdots-responsive-styles', `\n /* Responsive adjustments */\n @media (max-width: 640px) {\n .deepdots-popup {\n width: calc(100% - 24px) !important;\n max-width: calc(100% - 24px) !important;\n height: auto !important;\n max-height: 90vh !important;\n border-radius: 12px !important;\n padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;\n box-sizing: border-box;\n }\n .deepdots-popup .mf-spinner-circle { width: 32px; height: 32px; border-width: 4px; }\n .deepdots-popup button { font-size: 16px !important; }\n .deepdots-popup-header button { width:48px; height:48px; }\n .deepdots-popup-header button svg { width:26px; height:26px; }\n /* Apilados en el orden del DOM: la acción principal (Send/Start/Complete) arriba y\n Back debajo. */\n .deepdots-popup-footer { flex-direction: column !important; gap: 4px !important; }\n .deepdots-popup-footer button { width: 100%; }\n }\n @media (max-width: 400px) {\n .deepdots-popup { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) 12px !important; }\n .deepdots-popup-header button { width:48px; height:48px; }\n .deepdots-popup-header button svg { width:26px; height:26px; }\n }\n @media (orientation: landscape) and (max-height: 480px) {\n .deepdots-popup {\n height: 100vh !important;\n max-height: 100vh !important;\n overflow-y: auto !important;\n }\n }\n `, nonce);\n}\n\n/**\n * CSS del host, en un <style> propio añadido DESPUÉS de los del SDK y de\n * `@magicfeedback/native` para que gane en cascada sin tocar ninguno de los dos.\n * Se reemplaza en cada render por si cambia entre popups.\n */\nfunction ensureCustomCss(css?: string, nonce?: string) {\n const STYLE_ID = 'deepdots-custom-css';\n if (!css) {\n document.getElementById(STYLE_ID)?.remove();\n return;\n }\n // Reanexar mueve el nodo al final del head: garantiza que va tras las hojas del SDK.\n document.head.appendChild(ensureStyle(STYLE_ID, css, nonce));\n}\n\n// Inyecta (una sola vez) el @font-face de la fuente personalizada.\nfunction ensureFontFace(family: string, url: string, nonce?: string) {\n const css = buildFontFaceCss(family, url);\n if (!css) return;\n ensureStyle('deepdots-font-face', css, nonce);\n}\n\n/** Ratón o trackpad. Un iPad sin trackpad cuenta como táctil. */\nfunction hasFinePointer(): boolean {\n return typeof window !== 'undefined'\n && typeof window.matchMedia === 'function'\n && window.matchMedia('(pointer: fine)').matches;\n}\n\n/**\n * Renderiza el popup dentro del contenedor dado usando MagicFeedback para la encuesta.\n */\nexport async function renderPopup(\n container: HTMLElement,\n surveyId: string,\n productId: string,\n actions: PopupActions | undefined,\n emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void,\n onClose: () => void,\n env: string = 'production',\n userId?: string,\n style?: PopupStyle,\n sessionId?: string,\n miniService?: string,\n analyticsFeedbackSessionId?: string,\n options?: PopupRenderOptions,\n): Promise<void> {\n let surveyCompletedEmitted = false;\n let stylesInjected = false;\n // Profundidad de navegación dentro del survey: +1 al avanzar, -1 al volver. Sustituye a\n // `total > 1 && progress > 0 && progress < total`, que escondía el Back cuando la pantalla\n // siguiente era una follow-up dinámica (no entran en el grafo: suman +0.5 al progress y\n // dejan el total igual, así que un survey de una pregunta con follow-up nunca lo mostraba).\n let pageDepth = 0;\n let onStartPage = false;\n // Nonce de la CSP del host para cada `<style>` que se inyecta (en blanco = sin nonce).\n const cspNonce = options?.cspNonce?.trim() || undefined;\n\n // Textos del chrome (botones, progreso, aria-labels, errores). Arrancan con el idioma que\n // conoce el init y se re-resuelven en `onLoadedEvent` con el idioma en el que se muestra el\n // survey (`lang` del evento; `formData.lang[0]`, el idioma por defecto, en native < 2.3),\n // que es el que manda: un survey en danés debe traer también su footer en danés.\n let labels = getLabels(options?.language);\n let actionLabels = resolveActionLabels(actions, options?.language);\n // Dirección del chrome. Desde `@magicfeedback/native` 2.2.22 el survey se voltea solo\n // (`dir=\"rtl\"` en SU contenedor) para los idiomas RTL; si el header, el footer y la barra\n // de progreso se quedaran en LTR, media tarjeta miraría a cada lado. Se marca siempre,\n // también en `ltr`, para no heredar la dirección de la página del host.\n let direction = directionFor(options?.language);\n\n const isDark = style?.theme === 'dark';\n const theme = {\n popupBg: isDark ? '#1e1e1e' : '#fff',\n // El popup fija su propio fondo, así que debe fijar también el esquema de color.\n // Sin esto los controles de formulario (input/textarea/select) caen al estilo por\n // defecto del navegador: en un host con `prefers-color-scheme: dark` se pintan\n // oscuros con texto blanco sobre el fondo claro del popup.\n colorScheme: isDark ? 'dark' : 'light',\n textPrimary: isDark ? '#f0f0f0' : '#111',\n closeBtnHoverColor: isDark ? '#fff' : '#000000',\n textMuted: isDark ? '#9ca3af' : '#6b7280',\n progressTrack: isDark ? '#3f3f46' : '#e5e7eb',\n };\n\n const positionMap: Record<string, { justifyContent: string; alignItems: string; padding?: string; background: string }> = {\n 'center': { justifyContent: 'center', alignItems: 'center', background: 'rgba(0,0,0,0.5)' },\n 'bottom': { justifyContent: 'center', alignItems: 'flex-end', padding: '16px', background: 'transparent' },\n 'bottom-right': { justifyContent: 'flex-end', alignItems: 'flex-end', padding: '16px', background: 'transparent' },\n 'bottom-left': { justifyContent: 'flex-start', alignItems: 'flex-end', padding: '16px', background: 'transparent' },\n 'top': { justifyContent: 'center', alignItems: 'flex-start', padding: '16px', background: 'transparent' },\n 'top-right': { justifyContent: 'flex-end', alignItems: 'flex-start', padding: '16px', background: 'transparent' },\n 'top-left': { justifyContent: 'flex-start', alignItems: 'flex-start', padding: '16px', background: 'transparent' },\n };\n const pos = positionMap[style?.position ?? 'center'] ?? positionMap['center'];\n // Sin velo (posiciones de esquina y de borde) el contenedor sigue cubriendo toda la\n // pantalla para poder alinear la tarjeta, pero es transparente: no puede quedarse con los\n // clics del host. Solo la tarjeta los recibe. Con velo (`center`) el popup es modal y\n // tapar la página es lo esperado.\n const passThrough = pos.background === 'transparent';\n\n // Crear popup base\n const popup = document.createElement('div');\n popup.id = 'dd-popup';\n popup.className = 'deepdots-popup';\n popup.setAttribute('dir', direction);\n popup.style.cssText = `\n position: relative;\n pointer-events: auto;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n background: ${theme.popupBg};\n color-scheme: ${theme.colorScheme};\n border-radius: 8px;\n padding: 24px;\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\n max-width: 600px;\n width: 90%;\n max-height: 90vh;\n min-height: 200px;\n `;\n\n const font = style?.font;\n if (font?.family) {\n const familyValue = buildFontFamilyValue(font.family);\n // El survey vive dentro del contenedor y hereda esta fuente.\n popup.style.fontFamily = familyValue;\n // La variable habilita que el <h2> (Montserrat por defecto) también la use.\n popup.style.setProperty('--deepdots-font', familyValue);\n // Los controles de formulario (button/input/textarea/select) NO heredan\n // font-family por defecto; esta clase activa la regla que los fuerza a heredar.\n popup.classList.add('deepdots-has-font');\n if (font.url) ensureFontFace(font.family, font.url, cspNonce);\n }\n\n // Sección header (título + botón cerrar)\n const header = document.createElement('div');\n header.className = 'deepdots-popup-header';\n header.style.cssText = 'display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; flex:0 0 auto;';\n\n // Título: `textContent`, nunca innerHTML — el valor viene de la API.\n const titleEl = document.createElement('h2');\n titleEl.id = 'dd-title';\n titleEl.className = 'deepdots-popup-title';\n // text-transform/text-align/margin neutralizan la regla `.deepdots-popup h2` del CSS del\n // survey (uppercase, centrado, margin-bottom 40px), pensada para los enunciados.\n titleEl.style.cssText = `margin:0; font-size:17px; font-weight:600; line-height:1.3; color:${theme.textPrimary}; text-transform:none; text-align:start; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;`;\n titleEl.hidden = true;\n const setTitle = (value?: string) => {\n if (!value) return;\n titleEl.textContent = value;\n titleEl.hidden = false;\n };\n setTitle(options?.title);\n header.appendChild(titleEl);\n\n // Botón de cierre (X)\n const closeBtn = document.createElement('button');\n closeBtn.id = 'dd-close';\n closeBtn.type = 'button';\n closeBtn.setAttribute('aria-label', labels.closeAria);\n closeBtn.innerHTML = `\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5 5L19 19M5 19L19 5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"butt\"/>\n </svg>\n `;\n closeBtn.style.cssText = `\n background:transparent;\n border:none;\n width:32px;\n height:32px;\n display:flex;\n align-items:center;\n justify-content:center;\n border-radius: 8px;\n cursor:pointer;\n color:${theme.textPrimary};\n padding:4px;\n transition: color .15s ease, transform .15s ease;\n box-shadow: none !important;\n `;\n closeBtn.onmouseenter = () => {\n closeBtn.style.color = theme.closeBtnHoverColor;\n closeBtn.style.transform = 'scale(1.06)';\n };\n closeBtn.onmouseleave = () => {\n closeBtn.style.color = theme.textPrimary;\n closeBtn.style.transform = 'scale(1)';\n };\n // La X y el Cancel del survey que no carga cierran por el mismo camino.\n const closeFromChrome = () => {\n emit('popup_clicked', surveyId, {action: 'close_icon'});\n onClose();\n };\n closeBtn.onclick = closeFromChrome;\n closeBtn.style.flex = '0 0 auto';\n closeBtn.style.marginLeft = 'auto';\n header.appendChild(closeBtn);\n\n // Barra de progreso (\"Question X of Y\" + barra), espejo de LineProgressQuestion (MagicSurvey).\n // `undefined` en el init deja decidir a la plataforma (style.showProgressBar).\n let progressEnabled = options?.showProgressBar === true;\n let progressShowUnit = true;\n let progressUnit: 'percentage' | 'fraction' = 'fraction';\n\n const progressEl = document.createElement('div');\n progressEl.id = 'dd-progress';\n progressEl.className = 'deepdots-progress';\n // Sin padding horizontal propio: se alinea con el título y con el contenido. El vertical es\n // el mismo arriba y abajo, y del mismo valor que el padding de la tarjeta.\n progressEl.style.cssText = 'display:none; flex-direction:column; gap:8px; width:100%; flex:0 0 auto; padding:16px 0; box-sizing:border-box;';\n const progressHead = document.createElement('div');\n progressHead.className = 'deepdots-progress-head';\n progressHead.style.cssText = 'display:flex; flex-direction:row; justify-content:space-between; align-items:center; width:100%; gap:8px;';\n const progressLabel = document.createElement('span');\n progressLabel.id = 'dd-progress-label';\n progressLabel.style.cssText = 'font-size:13px; line-height:1.2;';\n // \"Question 1\" en negrita y \"of 3\" en regular gris, como el mockup.\n const progressCurrent = document.createElement('span');\n progressCurrent.id = 'dd-progress-current';\n progressCurrent.style.cssText = `font-weight:700; color:${theme.textPrimary};`;\n const progressTotal = document.createElement('span');\n progressTotal.id = 'dd-progress-total';\n progressTotal.style.cssText = `font-weight:400; color:${theme.textMuted};`;\n progressLabel.appendChild(progressCurrent);\n progressLabel.appendChild(progressTotal);\n const progressFollowUp = document.createElement('span');\n progressFollowUp.id = 'dd-progress-followup';\n progressFollowUp.textContent = labels.followUp;\n progressFollowUp.style.cssText = 'display:none; font-size:12px; font-weight:600; color:#fff; background:rgba(59,130,246,0.44); border-radius:999px; padding:2px 10px;';\n progressHead.appendChild(progressLabel);\n progressHead.appendChild(progressFollowUp);\n const progressTrack = document.createElement('div');\n progressTrack.className = 'deepdots-progress-track';\n progressTrack.style.cssText = `width:100%; height:4px; border-radius:999px; background:${theme.progressTrack}; overflow:hidden;`;\n const progressBar = document.createElement('div');\n progressBar.id = 'dd-progress-bar';\n progressBar.style.cssText = 'height:100%; width:0%; background:#22C55E; border-radius:999px; transition:width 450ms ease;';\n progressTrack.appendChild(progressBar);\n progressEl.appendChild(progressHead);\n progressEl.appendChild(progressTrack);\n\n function updateProgress(p: { progress?: number; total?: number; completed?: boolean; followup?: boolean }) {\n const total = typeof p.total === 'number' ? p.total : 0;\n const progress = typeof p.progress === 'number' ? p.progress : 0;\n if (!progressEnabled || onStartPage || p.completed || total <= 1) {\n progressEl.style.display = 'none';\n // Sin barra, el hueco cabecera→pregunta lo pone el contenido.\n containerContent.style.paddingTop = '16px';\n return;\n }\n progressEl.style.display = 'flex';\n // Con barra, el hueco inferior ya lo pone el bloque de progreso: no duplicarlo.\n containerContent.style.paddingTop = '0';\n // La barra usa el valor real (las follow-up suman +0.5 y avanzan media casilla); la\n // etiqueta redondea hacia abajo, porque una follow-up es un paso DENTRO de la misma\n // pregunta y no la siguiente.\n const current = Math.min(total, Math.max(1, progress + 1));\n const pct = Math.min(100, Math.max(0, (current / total) * 100));\n progressBar.style.width = `${pct}%`;\n const label = Math.min(total, Math.max(1, Math.floor(progress) + 1));\n progressLabel.style.display = progressShowUnit ? 'block' : 'none';\n if (progressUnit === 'percentage') {\n progressCurrent.textContent = `${Math.round(pct)}%`;\n progressTotal.textContent = '';\n } else {\n progressCurrent.textContent = `${labels.question} ${label}`;\n progressTotal.textContent = ` ${labels.of} ${total}`;\n }\n progressFollowUp.style.display = p.followup ? 'inline-block' : 'none';\n }\n\n ensureMagicFeedbackStyles(cspNonce);\n // Después del CSS del paquete y antes del CSS del host, que sigue teniendo la última palabra.\n ensureSurveyAlignmentStyles(cspNonce);\n ensureSpinnerStyles(cspNonce);\n ensureResponsiveStyles(cspNonce);\n // El último en entrar: el CSS del host gana sobre todo lo anterior.\n ensureCustomCss(options?.surveyCss, cspNonce);\n\n const containerContent = document.createElement('div');\n containerContent.id = 'dd-content';\n // Estaba escrito 'conetent'; el HTML del WebView siempre usó la forma correcta. Con\n // `surveyCss` esta clase pasa a ser superficie pública, así que las dos rutas deben coincidir.\n containerContent.className = 'deepdots-popup-container-content';\n // El popup es una columna: solo el bloque de preguntas hace scroll, para que el footer con\n // las acciones quede siempre pegado al borde inferior (antes vivía dentro del área\n // scrollable y en un survey largo había que bajar hasta el final para ver \"Send\").\n // Sin sangrado extra: el contenido se alinea con el título y con la barra de progreso\n // (antes sumaba 20px a los lados sobre el padding de la tarjeta). `overflow:hidden` deja\n // el scroll en `main`, no en el contenedor.\n containerContent.style.cssText = 'display:flex; flex-direction:column; flex:1 1 auto; min-height:0; padding:16px 0 0 0; overflow:hidden;'\n\n // Sección principal (main) - Contenedor formulario + spinner\n const main = document.createElement('div');\n main.id = 'dd-main';\n main.className = 'deepdots-popup-main';\n main.style.cssText = 'display:flex; flex-direction:column; width:100%; flex:1 1 auto; min-height:0; overflow-y:auto;';\n\n const formWrapper = document.createElement('div');\n formWrapper.id = 'dd-form-wrapper';\n formWrapper.style.cssText = 'width:100%; flex: 1 1 auto;';\n\n // Contenedor de aviso de error de validación\n const errorHint = document.createElement('div');\n errorHint.id = 'dd-error';\n errorHint.className = 'deepdots-error-hint';\n errorHint.style.cssText = `\n display: none;\n margin: 12px 0 0 0;\n padding: 10px 12px;\n border-radius: 6px;\n background: #FEF3C7; /* amber-100 */\n color: #92400E; /* amber-700 */\n border: 1px solid #FCD34D; /* amber-300 */\n font-size: 13px;\n `;\n errorHint.setAttribute('role', 'alert');\n errorHint.setAttribute('aria-live', 'polite');\n\n const spinnerEl = document.createElement('div');\n spinnerEl.className = 'mf-spinner';\n spinnerEl.setAttribute('role', 'status');\n spinnerEl.setAttribute('aria-label', labels.loadingAria);\n spinnerEl.innerHTML = '<div class=\"mf-spinner-circle\"></div>';\n spinnerEl.style.cssText = 'position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);';\n\n const formDivId = `magicfeedback-form-${surveyId}`;\n const formHost = document.createElement('div');\n formHost.id = formDivId;\n formHost.style.cssText = 'width:100%; visibility:hidden;';\n\n formWrapper.appendChild(spinnerEl);\n formWrapper.appendChild(formHost);\n main.appendChild(formWrapper);\n\n // Aviso de survey que no carga (clave o producto inexistentes, sin red). Ocupa el sitio del\n // survey; `textContent`, nunca innerHTML.\n const loadErrorEl = document.createElement('div');\n loadErrorEl.id = 'dd-load-error';\n loadErrorEl.className = 'deepdots-load-error';\n loadErrorEl.setAttribute('role', 'alert');\n loadErrorEl.style.cssText = `display:none; width:100%; text-align:center; padding:24px 0; font-size:15px; color:${theme.textPrimary};`;\n main.appendChild(loadErrorEl);\n // Insertar el hint justo antes del footer\n main.appendChild(errorHint);\n\n // Sección footer (acciones) - botones en extremos\n const footer = document.createElement('div');\n footer.id = 'dd-footer';\n footer.className = 'deepdots-popup-footer';\n footer.setAttribute('data-actions-wrapper', 'true');\n footer.style.cssText = 'display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:4px; margin-top:auto; width:100%; padding-top:12px;';\n\n // Botones\n const backButton = document.createElement('button');\n backButton.id = 'dd-back';\n backButton.className = 'dd-nav-btn';\n backButton.textContent = actionLabels.back;\n // Secundario como botón de texto: sin borde, fondo ni sombra, para que el primario sea\n // la única CTA con peso visual.\n backButton.style.cssText = `\n background: transparent;\n color: ${theme.textMuted};\n border: none;\n min-height: 44px;\n padding: 12px 24px;\n border-radius: 999px; /* píldora, como el Button de Material3 en KMP */\n cursor: pointer;\n font-size: 15px;\n font-weight: 600;\n transition: filter .15s ease;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n `;\n backButton.onmouseenter = () => {\n backButton.style.filter = 'brightness(0.9)';\n }\n backButton.onmouseleave = () => {\n backButton.style.filter = 'brightness(1)';\n }\n backButton.onclick = () => {\n emit('popup_clicked', surveyId, {action: 'back'});\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (formInstance as any)?.back?.();\n };\n\n // Boton start survyes, solo aprece cuando la encuesta empieza con mensaje de inicio\n // Width de 100% para que ocupe todo el espacio disponible\n const startButton = document.createElement('button');\n startButton.id = 'dd-start';\n startButton.className = 'dd-nav-btn';\n startButton.textContent = actionLabels.start;\n startButton.style.cssText = `\n background: #1E293B;\n color: #fff;\n border: none;\n min-height: 44px;\n padding: 12px 24px;\n border-radius: 999px; /* píldora, como el Button de Material3 en KMP */\n cursor: pointer;\n font-size: 15px;\n font-weight: 600;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n transition: filter .15s ease;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n `;\n startButton.onclick = () => {\n emit('popup_clicked', surveyId, {action: 'start_survey'});\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (formInstance as any)?.startForm?.();\n onStartPage = false;\n updateProgress({progress: formInstance?.progress, total: formInstance?.total});\n };\n\n // Botón cerrar popup, solo aparece al terminar la encuesta\n // Width de 100% para que ocupe todo el espacio disponible\n const closeButton = document.createElement('button');\n closeButton.id = 'dd-complete';\n closeButton.className = 'dd-nav-btn';\n closeButton.textContent = actionLabels.complete;\n closeButton.style.cssText = `\n background: #1E293B;\n color: #fff;\n border: none;\n min-height: 44px;\n padding: 12px 24px;\n border-radius: 999px; /* píldora, como el Button de Material3 en KMP */\n cursor: pointer;\n font-size: 15px;\n font-weight: 600;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n transition: filter .15s ease;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n `;\n closeButton.onmouseenter = () => {\n closeButton.style.filter = 'brightness(0.9)';\n }\n closeButton.onmouseleave = () => {\n closeButton.style.filter = 'brightness(1)';\n }\n closeButton.onclick = () => {\n emit('popup_clicked', surveyId, {action: 'complete'});\n onClose();\n };\n\n // Botón send, si es primera pagina ocupara el espacio completo pero si no estara al lado derecho\n const submitButton = document.createElement('button');\n submitButton.id = 'dd-submit';\n submitButton.className = 'dd-nav-btn';\n submitButton.textContent = actionLabels.accept;\n submitButton.style.cssText = `\n background: #1E293B;\n color: #fff;\n border: none;\n min-height: 44px;\n padding: 12px 24px;\n border-radius: 999px; /* píldora, como el Button de Material3 en KMP */\n cursor: pointer;\n font-size: 15px;\n font-weight: 600;\n box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n transition: filter .15s ease;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n `;\n // Única acción del survey que no carga. Cierra igual que la X: no depende de que la API\n // mande `actions.decline` (solo su `label`, si viene).\n const cancelButton = document.createElement('button');\n cancelButton.id = 'dd-cancel';\n cancelButton.type = 'button';\n cancelButton.className = 'dd-nav-btn';\n cancelButton.textContent = actionLabels.decline;\n cancelButton.style.cssText = submitButton.style.cssText;\n cancelButton.onclick = closeFromChrome;\n\n submitButton.onclick = () => {\n if (!surveyCompletedEmitted) {\n emit('popup_clicked', surveyId, {action: 'manual_send'});\n // Dispara envío nativo si existe\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (formInstance as any)?.send?.();\n }\n };\n\n /**\n * Re-resuelve todos los textos del chrome para `lang`. Se llama cuando el survey ya cargó\n * y se conoce su idioma. Las etiquetas que configure la plataforma por popup\n * (`actions.*.label`) siguen ganando: `resolveActionLabels` solo rellena las que falten.\n * El contador de progreso no se toca aquí porque `updateProgress` lo repinta justo después\n * leyendo `labels`.\n */\n function applyLabels(lang: string): void {\n labels = getLabels(lang);\n actionLabels = resolveActionLabels(actions, lang);\n backButton.textContent = actionLabels.back;\n startButton.textContent = actionLabels.start;\n closeButton.textContent = actionLabels.complete;\n submitButton.textContent = actionLabels.accept;\n cancelButton.textContent = actionLabels.decline;\n loadErrorEl.textContent = labels.errorLoad;\n closeBtn.setAttribute('aria-label', labels.closeAria);\n spinnerEl.setAttribute('aria-label', labels.loadingAria);\n progressFollowUp.textContent = labels.followUp;\n // El survey ya se ha volteado a sí mismo: el chrome tiene que acompañarlo.\n direction = directionFor(lang);\n popup.setAttribute('dir', direction);\n }\n\n backButton.style.display = 'none';\n startButton.style.display = 'none';\n submitButton.style.display = 'none';\n closeButton.style.display = 'none';\n cancelButton.style.display = 'none';\n\n // Insertar botones dentro del footer en orden visual (row-reverse deja primario a la derecha)\n footer.appendChild(submitButton);\n footer.appendChild(backButton);\n footer.appendChild(closeButton);\n footer.appendChild(startButton);\n footer.appendChild(cancelButton);\n\n // Añadir footer al main y main al containerContent\n containerContent.appendChild(main);\n // El footer va fuera del área scrollable, como hermano de `main`.\n footer.style.flex = '0 0 auto';\n containerContent.appendChild(footer);\n\n // Helper para controlar visibilidad de botones según estado\n type ViewState = 'loading' | 'start' | 'in_progress_first' | 'in_progress_next' | 'completed' | 'error' | 'load_error';\n\n function updateButtons(state: ViewState) {\n // Por defecto, ocultar todos\n backButton.style.display = 'none';\n startButton.style.display = 'none';\n submitButton.style.display = 'none';\n closeButton.style.display = 'none';\n cancelButton.style.display = 'none';\n // Reset widths por estado\n backButton.style.width = '';\n startButton.style.width = '';\n submitButton.style.width = '';\n closeButton.style.width = '';\n\n switch (state) {\n case 'loading':\n // Footer se ocultará desde setLoading\n break;\n case 'start':\n // Solo botón Start a ancho completo\n startButton.style.display = 'inline-flex';\n startButton.style.width = '100%';\n break;\n case 'in_progress_first':\n // Solo botón Send (lado derecho), ancho auto\n submitButton.style.display = 'inline-flex';\n submitButton.style.width = '';\n setLoading(false);\n break;\n case 'in_progress_next':\n // Mostrar Back (izquierda) + Send (derecha)\n backButton.style.display = 'inline-flex';\n submitButton.style.display = 'inline-flex';\n setLoading(false);\n break;\n case 'completed':\n // Mostrar Close/Complete a ancho completo como acción principal\n closeButton.style.display = 'inline-flex';\n closeButton.style.width = '100%';\n setLoading(false);\n break;\n case 'error':\n // En error, permitir cerrar (ancho auto)\n // closeButton.style.display = 'inline-flex';\n setLoading(false);\n break;\n case 'load_error':\n // Survey que no ha cargado: solo se puede cerrar.\n cancelButton.style.display = 'inline-flex';\n break;\n }\n }\n\n /** Estado de navegación según la profundidad recorrida (no según `total`). */\n function updateNavButtons() {\n updateButtons(pageDepth > 0 ? 'in_progress_next' : 'in_progress_first');\n }\n\n /**\n * Pantalla final con el `successMessage` configurado en la plataforma. La pinta el popup y\n * no `@magicfeedback/native`, cuyo `renderSuccess` usa `textContent` (el mensaje es HTML del\n * editor: imagen + texto) y cuyo fallback es un literal que ignora el estilo del survey.\n * Va por innerHTML igual que `renderStartMessage` con el mensaje de inicio.\n */\n let successMessageHtml = '';\n function showSuccessScreen() {\n progressEl.style.display = 'none';\n formWrapper.style.display = 'none';\n let done = main.querySelector('.deepdots-success') as HTMLElement | null;\n if (!done) {\n done = document.createElement('div');\n done.className = 'deepdots-success';\n done.style.cssText = `width:100%; text-align:center; padding:24px 0; color:${theme.textPrimary};`;\n main.insertBefore(done, errorHint);\n }\n done.innerHTML = successMessageHtml || '<p>Thank you for your feedback!</p>';\n done.querySelectorAll('img').forEach((img) => {\n img.style.cssText = 'max-width:100%; height:auto; margin:0 auto 16px auto; display:block;';\n });\n }\n\n /**\n * Survey que no ha cargado. `@magicfeedback/native` lo avisa con `onLoadedEvent({error})`\n * y antes se trataba como una carga normal: Send sobre un survey vacío. Se enseña el aviso\n * traducido, la X sigue y el footer queda en Cancel. Se revela ya: no hay nada más que\n * esperar. No es interacción del usuario, así que no llega al host como `popup_clicked`.\n */\n let loadFailed = false;\n function showLoadError(reason: unknown) {\n sdkWarn('[Deepdots] survey failed to load:', reason);\n if (loadFailed) return;\n loadFailed = true;\n progressEl.style.display = 'none';\n formWrapper.style.display = 'none';\n errorHint.style.display = 'none';\n loadErrorEl.textContent = labels.errorLoad;\n loadErrorEl.style.display = 'block';\n setLoading(false);\n updateButtons('load_error');\n reveal();\n }\n\n // Ensamblar popup\n popup.appendChild(header);\n popup.appendChild(progressEl);\n popup.appendChild(containerContent);\n\n container.innerHTML = '';\n container.appendChild(popup);\n container.style.display = 'flex';\n // Apertura diferida: el contenedor entra en el layout (el survey necesita medidas reales\n // para pintarse) pero invisible y sin capturar clics, hasta que `reveal()` lo enseñe.\n container.style.visibility = 'hidden';\n container.style.pointerEvents = 'none';\n container.style.justifyContent = pos.justifyContent;\n container.style.alignItems = pos.alignItems;\n container.style.background = pos.background;\n if (pos.padding) container.style.padding = pos.padding;\n\n // ── Apertura diferida ────────────────────────────────────────────────────────────────\n // El spinner de apertura es lo que el cliente reporta como mala sensación: medido, está\n // ~310 ms en pantalla esperando el JSON del survey. En vez de enseñar la espera, se espera\n // en silencio y se abre el popup ya montado.\n let revealed = false;\n let revealTimer: ReturnType<typeof setTimeout> | null = null;\n // Foco en la primera pregunta si es de escribir. Al navegar lo pone @magicfeedback/native\n // (`autofocus: 'navigation'`); la apertura la decide el popup, porque native no sabe cuándo\n // se revela y un campo con `visibility:hidden` no acepta foco. Necesita el popup visible y\n // el survey cargado, que llegan en cualquier orden (el techo de la revelación puede vencer\n // antes que el survey). Solo con ratón o trackpad: en táctil, enfocar al abrir sacaría el\n // teclado sin que el usuario haya tocado nada.\n let surveyLoaded = false;\n let openFocusDone = false;\n\n function autofocusOnOpen() {\n if (openFocusDone || !revealed || !surveyLoaded) return;\n openFocusDone = true;\n if (hasFinePointer()) formInstance?.focusFirstQuestion?.();\n }\n\n function reveal() {\n if (revealed) return;\n revealed = true;\n if (revealTimer !== null) {\n clearTimeout(revealTimer);\n revealTimer = null;\n }\n // Si el popup se cerró durante la espera, este contenedor ya no es suyo: `hide()` lo ha\n // vaciado y puede estar sirviendo a otra apertura. Revelarlo aquí la sacaría antes de\n // tiempo.\n if (!container.contains(popup)) return;\n container.style.visibility = 'visible';\n container.style.pointerEvents = passThrough ? 'none' : '';\n autofocusOnOpen();\n }\n\n /**\n * Revela en cuanto el popup está pintado del todo. Se mira el popup entero, no solo el\n * formulario, porque el logo del survey se inserta sobre la barra de progreso y es el que más\n * desplaza el contenido al entrar.\n */\n function revealWhenPainted() {\n if (revealed) return;\n revealWhenImagesLoaded(popup, reveal);\n }\n\n revealTimer = setTimeout(reveal, REVEAL_TIMEOUT_MS);\n\n // Gestión dinámica de loading\n function setLoading(isLoading: boolean) {\n spinnerEl.style.display = isLoading ? 'flex' : 'none';\n // El spinner no tapa el survey (28px en posición absoluta), así que sin esto el usuario\n // puede seguir cambiando de opción mientras se envía la página — y ese cambio ya no\n // viaja con ella. Se bloquea el wrapper, que es el elemento estable: el div de dentro lo\n // sustituye `@magicfeedback/native` por su propio contenedor al generar el survey.\n setSurveyBusy(formWrapper, isLoading);\n if (!isLoading) {\n formHost.style.visibility = 'visible';\n // Fin de la carga, sea por survey cargado o por error: el popup ya puede verse.\n // Entre páginas del survey es no-op, porque `reveal` solo actúa la primera vez.\n revealWhenPainted();\n }\n // Ocultar totalmente los botones cuando está cargando\n footer.style.display = isLoading ? 'none' : 'flex';\n // Ajustar estados de los botones por si se muestran\n backButton.disabled = isLoading;\n startButton.disabled = isLoading;\n closeButton.disabled = isLoading;\n submitButton.disabled = isLoading;\n submitButton.style.opacity = isLoading ? '0.6' : '1';\n submitButton.style.cursor = isLoading ? 'not-allowed' : 'pointer';\n // No sobrescribir el estado de botones al finalizar la carga.\n if (isLoading) {\n updateButtons('loading');\n }\n }\n\n // Estado inicial\n setLoading(true);\n\n // Entorno navegador\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return;\n }\n\n // Referencia instancia formulario\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let formInstance: any = null;\n\n // DD-70: la versión de survey SDK asignada al survey en el Admin, o la empaquetada. Nunca\n // rechaza. Mientras carga del CDN el popup sigue invisible (o con spinner, pasado el techo).\n const { sdk: magicfeedback, choice: surveySdk, css: surveySdkCss } = await resolveSurveySdk(\n options?.surveySdkVersion,\n { nonce: cspNonce, debug: options?.debug },\n );\n popup.dataset.surveySdk = `${surveySdk.version} ${surveySdk.source}`;\n // Cerrado mientras se descargaba: no se pinta un survey en un contenedor ya vacío.\n if (!container.contains(popup)) return;\n // El CSS va con la JS: la hoja de la versión asignada sustituye a la empaquetada en el mismo\n // <style> (mismo sitio en el <head>, así el de alineación y el del host siguen ganando). Sin\n // asignada se vuelve a poner la empaquetada, por si otra apertura la cambió.\n if (surveySdkCss) ensureStyle('magicfeedback-sdk-styles', surveySdkCss, cspNonce);\n else ensureMagicFeedbackStyles(cspNonce);\n\n try {\n if (!magicfeedback || typeof magicfeedback.form !== 'function') {\n sdkWarn('[MagicFeedback] form() no disponible. Fallback manual.');\n showLoadError('form() not available');\n return;\n }\n magicfeedback.init({\n debug: true,\n env: env === 'production' ? 'prod' : 'dev'}\n );\n // Contrato Fase 1 §5: profile = identidad del usuario; metadata = contexto de tracking (session_id + user_id)\n const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);\n formInstance = magicfeedback.form(surveyId, productId, profile, metadata);\n\n interface TypedGenerateOptions {\n addButton: boolean;\n getMetaData: boolean;\n addSuccessScreen: boolean;\n lang?: string;\n onLoadedEvent?: (args: {\n formData: FormData,\n loading?: boolean,\n // Presente cuando el survey NO ha cargado (406 de `/info`, sin red).\n error?: unknown,\n lang?: string,\n progress?: number, total?: number\n }) => void;\n beforeSubmitEvent?: () => void;\n afterSubmitEvent?: (args: { error?: string, completed: boolean, progress: number, total: number, followup?: boolean }) => void;\n onBackEvent?: (args: { error?: string, progress: number, total: number, followup: boolean }) => void;\n autofocus?: 'always' | 'navigation' | false;\n }\n\n const generateOptions: TypedGenerateOptions = {\n addButton: false,\n getMetaData: true,\n // La pantalla final la pinta el popup: `renderSuccess` de @magicfeedback/native usa\n // textContent, así que el mensaje de la plataforma (HTML con imagen) no se vería, y\n // su fallback es un literal genérico que ignora `style.successMessage`.\n addSuccessScreen: false,\n // Surveys multi-idioma: native pide a la API este idioma (el del init o el del\n // dispositivo) y, si el survey no lo tiene, la API sirve el idioma por defecto.\n lang: options?.language,\n // Foco en la primera pregunta de escribir tras Start, Siguiente o Atrás. Native lo\n // aplica después de afterSubmitEvent/onBackEvent, cuando `setLoading(false)` ya ha\n // quitado el `inert`. La apertura va aparte (ver autofocusOnOpen).\n autofocus: 'navigation',\n };\n generateOptions.onLoadedEvent = ({formData, lang, error}) => {\n if (error) {\n showLoadError(error);\n return;\n }\n // Idioma en el que native muestra el survey. Manda sobre el del init para que el\n // chrome no se quede en inglés delante de un survey traducido. Native < 2.3 no lo\n // envía: entonces el primero de `formData.lang` (el idioma por defecto).\n const shownLang = typeof lang === 'string' && lang.trim().length > 0 ? lang : undefined;\n const surveyLang = shownLang ?? (Array.isArray(formData?.lang)\n ? formData.lang.find((l) => typeof l === 'string' && l.trim().length > 0)\n : undefined);\n if (surveyLang) applyLabels(surveyLang);\n // Calcular altura disponible y aplicarla al main (restando header + footer + paddings)\n try {\n /*\n const headerHeight = header.getBoundingClientRect().height;\n const footerHeight = footer.getBoundingClientRect().height;\n const paddingY = 48; // 24px top + 24px bottom\n const viewportLimit = window.innerHeight * 0.8; // coincide con max-height del popup\n const available = viewportLimit - headerHeight - footerHeight - paddingY;\n if (available > 120) { // asegurar un mínimo razonable\n main.style.maxHeight = available + 'px';\n } */\n } catch {\n // silencioso\n }\n // Personalización del popup basada en formData.style\n const s = formData?.style;\n if (s && !stylesInjected) {\n stylesInjected = true;\n if (s.successMessage) successMessageHtml = s.successMessage;\n // La barra de progreso la decide el host (init) y, si no se pronuncia, la plataforma.\n if (options?.showProgressBar === undefined) progressEnabled = s.showProgressBar === true;\n if (s.showProgressUnit !== undefined) progressShowUnit = s.showProgressUnit !== false;\n if (s.progressUnit) progressUnit = s.progressUnit;\n if (s.loadingBarColor) {\n progressBar.style.background = s.loadingBarColor;\n progressFollowUp.style.background = s.loadingBarColor;\n }\n // Fondo del contenedor popup\n if (s.boxBackgroundColor) {\n popup.style.background = s.boxBackgroundColor;\n }\n // Alineación del contenido principal\n if (s.contentAlign) {\n // 'top' => start, 'center' => center\n main.style.justifyContent = s.contentAlign === 'center' ? 'center' : 'flex-start';\n }\n // Botón primario (submit, start)\n // El survey pinta sus controles con `--mf-primary`, que sale de `primaryColor`;\n // si la integración solo configura el del botón, el popup mezclaría el color de\n // la marca con el gris azulado por defecto del paquete.\n applySurveyPrimaryColor(popup, s);\n if (s.buttonPrimaryColor) {\n submitButton.style.background = s.buttonPrimaryColor;\n submitButton.style.border = 'none';\n submitButton.style.color = '#fff';\n\n startButton.style.background = s.buttonPrimaryColor;\n startButton.style.border = 'none';\n startButton.style.color = '#fff';\n\n closeButton.style.background = s.buttonPrimaryColor;\n closeButton.style.border = 'none';\n closeButton.style.color = '#fff';\n }\n // Botón secundario (back) — outlined: fondo blanco, letra y borde del color secundario\n if (s.buttonSecondaryColor) {\n // Botón de texto: solo tiñe la etiqueta, sin recuperar fondo ni borde.\n backButton.style.background = 'transparent';\n backButton.style.color = s.buttonSecondaryColor;\n backButton.style.border = 'none';\n }\n // El logo va encima de la barra de progreso, como hermano del header.\n insertPopupLogo(popup, progressEl, s, 'deepdots-popup-logo');\n\n if (s.startMessage && s.startMessage !== '') {\n // Si hay mensaje de inicio, mostrar botón Start inicialmente\n sdkLog(s.startMessage);\n onStartPage = true;\n updateButtons('start');\n } else {\n // Si no hay mensaje de inicio, mostrar estado de primera página (solo Send)\n updateButtons('in_progress_first');\n }\n } else {\n // Sin estilos, asumir primera página normal\n updateButtons('in_progress_first');\n }\n\n // El total solo se conoce con el form ya montado.\n updateProgress({progress: formInstance.progress, total: formInstance.total});\n // Cargar no es interacción: no llega al host como popup_clicked (paridad con KMP).\n setLoading(false); // hace visible el formulario y oculta el spinner\n // La primera carga es la apertura; las siguientes (tras Start) las enfoca native.\n if (!surveyLoaded) {\n surveyLoaded = true;\n autofocusOnOpen();\n }\n };\n let lastReportedError: unknown = null;\n generateOptions.beforeSubmitEvent = () => {\n setLoading(true);\n };\n generateOptions.afterSubmitEvent = ({error, completed, total, progress, followup}) => {\n // No cambiar estado de loading aquí; lo gestiona cada transición\n if (error) {\n // Desactivar loading para que se vean los botones\n setLoading(false);\n const {reason, message} = classifySubmitError(error);\n // Validación (obligatoria vacía o email no válido): no es un fallo, la página se queda.\n if (reason === 'required' || reason === 'invalid_email') {\n errorHint.textContent = reason === 'invalid_email' ? labels.errorInvalidEmail : labels.errorRequired;\n errorHint.style.display = 'block';\n // La página no ha cambiado: el estado de navegación se queda como estaba.\n updateNavButtons();\n return;\n }\n // Otros errores: mostrar mensaje genérico y permitir cerrar\n errorHint.textContent = labels.errorSubmit;\n errorHint.style.display = 'block';\n sdkWarn('[Deepdots] survey submit error:', reason, message);\n // native avisa dos veces del mismo fallo al cerrar el survey (mismo objeto):\n // un solo evento por fallo.\n if (error !== lastReportedError) {\n lastReportedError = error;\n emit('survey_error', surveyId, {reason, message});\n }\n // updateButtons('error');\n return;\n }\n // Limpiar hint si no hay error\n errorHint.style.display = 'none';\n setLoading(false);\n if (completed) {\n emit('survey_completed', surveyId, {action: 'completed'});\n surveyCompletedEmitted = true;\n showSuccessScreen();\n updateButtons('completed');\n updateProgress({progress, total, completed: true});\n return;\n }\n emit('popup_clicked', surveyId, {action: 'partial'});\n pageDepth++;\n updateNavButtons();\n updateProgress({progress, total, followup});\n };\n generateOptions.onBackEvent = ({progress, error, followup}) => {\n // El `back` para el host ya lo emitió el botón: aquí solo se actualiza la navegación.\n // Con error (\"No page found\") no hubo navegación: la profundidad no se toca.\n if (!error) pageDepth = Math.max(0, pageDepth - 1);\n updateNavButtons();\n // onBackEvent no trae `total`: se lee del form, que es su dueño.\n updateProgress({progress, total: formInstance.total, followup});\n };\n\n // Ejecutar generación con opciones tipadas\n formInstance.generate(formDivId, generateOptions)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .catch((err: any) => {\n sdkError('[MagicFeedback] Error generating form:', err);\n showLoadError(err);\n });\n } catch (e) {\n sdkError('[MagicFeedback] Exception initializing form:', e);\n showLoadError(e);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAM,WAAW;AAEjB,IAAM,aAAqC;AAAA,EACvC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX;AAMO,SAAS,gBACZ,QACA,QACA,OACA,IACuB;AACvB,MAAI,CAAC,OAAO,KAAM,QAAO;AACzB,MAAI,OAAO,cAAc,eAAe,EAAE,EAAG,QAAO;AAEpD,QAAM,MAAM,OAAO,cAAc,cAAc,KAAK;AACpD,MAAI,KAAK;AACT,MAAI,MAAM,MAAM;AAChB,MAAI,MAAM;AACV,MAAI,MAAM,UAAU;AAEpB,MAAI,MAAM,YAAY,WAAW,MAAM,QAAQ,GAAG;AAC9C,QAAI,MAAM,YAAY,WAAW,MAAM,QAAQ;AAAA,EACnD;AAIA,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-sdk (DD-55).
|
|
2
|
+
//
|
|
3
|
+
// iOS suspende la app pocos segundos después de pasar a background; si el POST con el cierre de
|
|
4
|
+
// la sesión sigue en vuelo, no termina hasta que el usuario vuelve a abrir la app. Este módulo
|
|
5
|
+
// pide ese tiempo extra (`beginBackgroundTaskWithName`) mientras dura cada envío. Lo enlaza solo
|
|
6
|
+
// el autolinking de React Native (`pod install`); el host no escribe código. Sin él, el SDK
|
|
7
|
+
// funciona igual que antes (el cierre se guarda y se reenvía en el arranque siguiente).
|
|
8
|
+
//
|
|
9
|
+
// Cada tarea la identifica un token que genera el JS: `begin(token, name)` y `end(token)`.
|
|
10
|
+
// Los métodos van en la cola serie del módulo, así que un `end` nunca adelanta a su `begin`.
|
|
11
|
+
|
|
12
|
+
#import <React/RCTBridgeModule.h>
|
|
13
|
+
#import <UIKit/UIKit.h>
|
|
14
|
+
|
|
15
|
+
@interface DeepdotsBackgroundTask : NSObject <RCTBridgeModule>
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation DeepdotsBackgroundTask {
|
|
19
|
+
NSMutableDictionary<NSString *, NSNumber *> *_tasks;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
RCT_EXPORT_MODULE(DeepdotsBackgroundTask)
|
|
23
|
+
|
|
24
|
+
+ (BOOL)requiresMainQueueSetup
|
|
25
|
+
{
|
|
26
|
+
return NO;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (instancetype)init
|
|
30
|
+
{
|
|
31
|
+
if (self = [super init]) {
|
|
32
|
+
_tasks = [NSMutableDictionary new];
|
|
33
|
+
}
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RCT_EXPORT_METHOD(begin:(NSString *)token name:(NSString *)name)
|
|
38
|
+
{
|
|
39
|
+
__weak DeepdotsBackgroundTask *weakSelf = self;
|
|
40
|
+
UIBackgroundTaskIdentifier taskId =
|
|
41
|
+
[[UIApplication sharedApplication] beginBackgroundTaskWithName:name
|
|
42
|
+
expirationHandler:^{
|
|
43
|
+
// iOS agota el tiempo antes de que el envío termine.
|
|
44
|
+
[weakSelf endToken:token];
|
|
45
|
+
}];
|
|
46
|
+
if (taskId == UIBackgroundTaskInvalid) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
@synchronized(self) {
|
|
50
|
+
_tasks[token] = @(taskId);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
RCT_EXPORT_METHOD(end:(NSString *)token)
|
|
55
|
+
{
|
|
56
|
+
[self endToken:token];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (void)endToken:(NSString *)token
|
|
60
|
+
{
|
|
61
|
+
NSNumber *taskId;
|
|
62
|
+
@synchronized(self) {
|
|
63
|
+
taskId = _tasks[token];
|
|
64
|
+
[_tasks removeObjectForKey:token];
|
|
65
|
+
}
|
|
66
|
+
if (taskId != nil) {
|
|
67
|
+
[[UIApplication sharedApplication] endBackgroundTask:taskId.unsignedIntegerValue];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@end
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicfeedback/popup-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "TypeScript SDK to render and manage survey popups for MagicFeedback",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"react-native": "dist/index.native.js",
|
|
8
9
|
"autho": "sarias@deepdots.com",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
13
|
+
"react-native": "./dist/index.native.js",
|
|
12
14
|
"import": "./dist/index.mjs",
|
|
13
15
|
"require": "./dist/index.js"
|
|
14
16
|
},
|
|
@@ -19,7 +21,10 @@
|
|
|
19
21
|
}
|
|
20
22
|
},
|
|
21
23
|
"files": [
|
|
22
|
-
"dist"
|
|
24
|
+
"dist",
|
|
25
|
+
"ios",
|
|
26
|
+
"MagicfeedbackPopupSdk.podspec",
|
|
27
|
+
"react-native.config.js"
|
|
23
28
|
],
|
|
24
29
|
"scripts": {
|
|
25
30
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean && rm -rf dist/assets && mkdir -p dist/assets/assets && cp -R src/assets/. dist/assets/assets/ && tsup --config tsup.rn.config.ts",
|
|
@@ -34,8 +39,9 @@
|
|
|
34
39
|
"e2e:report": "playwright show-report",
|
|
35
40
|
"test-app": "node apps/test-app/server.mjs",
|
|
36
41
|
"test-app:e2e": "playwright test -c apps/test-app/playwright.config.ts",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
42
|
+
"test-app:visual": "node apps/test-app/visual/run.mjs --docker",
|
|
43
|
+
"visual:approve": "node scripts/visual/approve.mjs --suite apps/test-app/visual",
|
|
44
|
+
"prepublishOnly": "node -e \"console.error('Publishing from a laptop is disabled (DD-27): releases go through .github/workflows/release.yml (npm run release:prepare, then npm run release:tag). Emergency: docs/VERSIONING.md, Emergency exception.'); process.exit(1)\"",
|
|
39
45
|
"release:prepare": "node scripts/release.mjs prepare",
|
|
40
46
|
"release:tag": "node scripts/release.mjs tag",
|
|
41
47
|
"release:check": "node scripts/release/check.mjs pr",
|
|
@@ -82,7 +88,7 @@
|
|
|
82
88
|
}
|
|
83
89
|
},
|
|
84
90
|
"devDependencies": {
|
|
85
|
-
"@magicfeedback/native": "^2.2.
|
|
91
|
+
"@magicfeedback/native": "^2.2.39",
|
|
86
92
|
"@playwright/test": "^1.60.0",
|
|
87
93
|
"@types/node": "^20.10.0",
|
|
88
94
|
"@types/react": "^18.3.31",
|
|
@@ -92,6 +98,9 @@
|
|
|
92
98
|
"eslint": "^8.54.0",
|
|
93
99
|
"happy-dom": "^20.11.1",
|
|
94
100
|
"jsdom": "^27.1.0",
|
|
101
|
+
"marked": "18.1.2",
|
|
102
|
+
"pixelmatch": "^7.2.0",
|
|
103
|
+
"pngjs": "^7.0.0",
|
|
95
104
|
"react": "^18.3.1",
|
|
96
105
|
"ts-json-schema-generator": "^2.9.0",
|
|
97
106
|
"tsup": "^8.0.1",
|