@magicfeedback/popup-sdk 1.17.2 → 1.18.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/dist/index.js CHANGED
@@ -577,6 +577,48 @@ function ddSetSurveyBusy(el, busy){
577
577
  }
578
578
  });
579
579
 
580
+ // src/ui/submitError.ts
581
+ function submitErrorText(error) {
582
+ if (!error) return "";
583
+ if (typeof error === "string") return error;
584
+ const message = error.message;
585
+ return typeof message === "string" ? message : String(error);
586
+ }
587
+ function classifySubmitError(error) {
588
+ const message = submitErrorText(error).slice(0, SURVEY_ERROR_MESSAGE_MAX);
589
+ const code = error && typeof error === "object" ? error.code : void 0;
590
+ if (typeof code === "string" && REASON_BY_CODE[code]) return { reason: REASON_BY_CODE[code], message };
591
+ if (message.toLowerCase().includes("no response")) return { reason: "required", message };
592
+ return { reason: "unknown", message };
593
+ }
594
+ var SURVEY_ERROR_MESSAGE_MAX, REASON_BY_CODE, SUBMIT_ERROR_JS;
595
+ var init_submitError = __esm({
596
+ "src/ui/submitError.ts"() {
597
+ "use strict";
598
+ SURVEY_ERROR_MESSAGE_MAX = 300;
599
+ REASON_BY_CODE = {
600
+ REQUIRED: "required",
601
+ SEND_FAILED: "send_failed",
602
+ NO_PAGE: "no_page"
603
+ };
604
+ SUBMIT_ERROR_JS = `
605
+ function ddClassifySubmitError(error){
606
+ var message='';
607
+ if(error){
608
+ if(typeof error==='string'){ message=error; }
609
+ else if(typeof error.message==='string'){ message=error.message; }
610
+ else { message=String(error); }
611
+ }
612
+ message=message.slice(0, ${SURVEY_ERROR_MESSAGE_MAX});
613
+ var byCode={ REQUIRED:'required', SEND_FAILED:'send_failed', NO_PAGE:'no_page' };
614
+ var code=error && typeof error==='object' ? error.code : undefined;
615
+ if(typeof code==='string' && byCode.hasOwnProperty(code)){ return { reason: byCode[code], message: message }; }
616
+ if(message.toLowerCase().indexOf('no response')!==-1){ return { reason: 'required', message: message }; }
617
+ return { reason: 'unknown', message: message };
618
+ }`;
619
+ }
620
+ });
621
+
580
622
  // src/assets/style.css
581
623
  var style_default;
582
624
  var init_style = __esm({
@@ -584,7 +626,7 @@ var init_style = __esm({
584
626
  style_default = `/**
585
627
  * NO EDITAR A MANO \u2014 generado por scripts/vendor-survey-css.mjs
586
628
  *
587
- * Copia de @magicfeedback/native@2.2.33 \u2192 dist/styles/magicfeedback-default.css
629
+ * Copia de @magicfeedback/native@2.2.37 \u2192 dist/styles/magicfeedback-default.css
588
630
  * (la hoja can\xF3nica del paquete, la que apunta su campo "style"), con estos cambios locales:
589
631
  *
590
632
  * 1. Sin el @import de Google Fonts (Nunito): no queremos una petici\xF3n externa desde la
@@ -1053,6 +1095,36 @@ div.magicfeedback-radio {
1053
1095
  width: 100%;
1054
1096
  }
1055
1097
 
1098
+ /* Single choice in a row (assets.direction "row"): one equal box per
1099
+ option. The "other" text field wraps to its own line below. Stacked
1100
+ (phone, or too narrow) it is the usual vertical list again. */
1101
+ .magicfeedback-radio--row {
1102
+ flex-direction: row;
1103
+ flex-wrap: wrap;
1104
+ }
1105
+
1106
+ .magicfeedback-radio--row > .magicfeedback-radio-container {
1107
+ flex: 1 1 0;
1108
+ min-width: 0;
1109
+ }
1110
+
1111
+ .magicfeedback-radio--row > .magicfeedback-extra-option {
1112
+ flex-basis: 100%;
1113
+ }
1114
+
1115
+ .magicfeedback-radio--row.magicfeedback-radio--stacked {
1116
+ flex-direction: column;
1117
+ flex-wrap: nowrap;
1118
+ }
1119
+
1120
+ .magicfeedback-radio--row.magicfeedback-radio--stacked > .magicfeedback-radio-container {
1121
+ flex: none;
1122
+ }
1123
+
1124
+ .magicfeedback-radio--row .magicfeedback-radio-container label {
1125
+ overflow-wrap: anywhere;
1126
+ }
1127
+
1056
1128
  .magicfeedback-checkbox-container,
1057
1129
  .magicfeedback-radio-container {
1058
1130
  display: flex;
@@ -1276,6 +1348,34 @@ div.magicfeedback-radio {
1276
1348
  overflow-wrap: anywhere;
1277
1349
  }
1278
1350
 
1351
+ /* assets.minMaxPlaceholderPosition: the caption above or below the row. */
1352
+ .magicfeedback-rating-number-scale-labels--top {
1353
+ margin-top: 0;
1354
+ margin-bottom: var(--mf-space-sm);
1355
+ }
1356
+
1357
+ .magicfeedback-rating-number-scale-labels--bottom {
1358
+ margin-top: var(--mf-space-sm);
1359
+ margin-bottom: 0;
1360
+ }
1361
+
1362
+ /* Row with a text per number: the text sits above each chip (below with
1363
+ numberPlaceholdersPosition "bottom"). The option is a column laid out
1364
+ inline; this only spaces and styles the text. */
1365
+ .magicfeedback-rating-number-option--captioned {
1366
+ gap: var(--mf-space-xs);
1367
+ }
1368
+
1369
+ .magicfeedback-rating-number-option-caption {
1370
+ font-size: var(--mf-font-size-sm);
1371
+ font-weight: var(--mf-font-weight-semibold);
1372
+ color: var(--mf-text-secondary);
1373
+ text-align: center;
1374
+ line-height: 1.25;
1375
+ overflow-wrap: anywhere;
1376
+ cursor: pointer;
1377
+ }
1378
+
1279
1379
  .magicfeedback-rating-number-scale-label:last-child {
1280
1380
  text-align: end;
1281
1381
  }
@@ -3444,7 +3544,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
3444
3544
  }));
3445
3545
  };
3446
3546
  Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
3447
- const r = i(4760), o = i(7490), a = i(4070), s = i(9071), l = i(7643), d = i(8129), c = i(2335), u = i(5349), p = i(1719), m = i(3378), h = i(7305), f = i(9481), g = i(7170), y = i(7627), v = i(3433), b = i(9089), E = i(4069), A = i(9039), k = [r.FEEDBACKAPPANSWERTYPE.INFO_PAGE, r.FEEDBACKAPPANSWERTYPE.PASSWORD, r.FEEDBACKAPPANSWERTYPE.EMAIL, r.FEEDBACKAPPANSWERTYPE.CONTACT, r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, r.FEEDBACKAPPANSWERTYPE.MAX_DIFF];
3547
+ const r = i(4760), o = i(7490), a = i(4070), s = i(9071), l = i(7643), d = i(8129), c = i(2335), u = i(5349), p = i(1719), m = i(3378), h = i(7305), f = i(9481), g = i(7170), y = i(7627), v = i(3433), b = i(9089), E = i(4069), A = i(9039), k = i(1012), T = [r.FEEDBACKAPPANSWERTYPE.INFO_PAGE, r.FEEDBACKAPPANSWERTYPE.PASSWORD, r.FEEDBACKAPPANSWERTYPE.EMAIL, r.FEEDBACKAPPANSWERTYPE.CONTACT, r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, r.FEEDBACKAPPANSWERTYPE.MAX_DIFF];
3448
3548
  t2.Form = class {
3449
3549
  constructor(e3, t3, i2, n2, r2) {
3450
3550
  this.urlAutoAdvanceChecked = false, this.config = e3, this.log = new a.Log(e3), this.formOptionsConfig = { addButton: true, addSuccessScreen: true, getMetaData: true, customMetaData: [], questionFormat: "standard" }, this.selector = "", this.appId = t3, this.publicKey = i2 || "", this.url = e3.get("url"), this.id = "", this.formData = null, this.activeLang = null, this.feedback = { text: "", answers: [], profile: null != n2 ? n2 : [], metrics: [], metadata: null != r2 ? r2 : [] }, this.history = new f.History(), this.agentForm = null, this.graph = new p.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.sending = false, this.timeToCompleted = 0;
@@ -3533,17 +3633,17 @@ var require_magicfeedback_sdk_browser = __commonJS({
3533
3633
  }
3534
3634
  this.formOptionsConfig.addButton && o2.addEventListener("submit", ((e4) => {
3535
3635
  e4.preventDefault(), this.send();
3536
- })), this.timeToCompleted = Date.now(), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, formData: this.formData, lang: this.lang(), formOptionsConfig: this.formOptionsConfig })), this.autofocusAfterRender(e3), this.autoAdvanceFromUrl(a2, s2);
3636
+ })), this.timeToCompleted = Date.now();
3637
+ const d2 = this.autoAdvanceFromUrl(a2, s2);
3638
+ if (d2 && (a2.style.visibility = "hidden"), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: d2, autoAdvancing: d2, progress: this.progress, total: this.total, formData: this.formData, lang: this.lang(), formOptionsConfig: this.formOptionsConfig })), d2) return void (yield this.autoSend());
3639
+ this.autofocusAfterRender(e3);
3537
3640
  } catch (e4) {
3538
3641
  return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
3539
3642
  }
3540
3643
  }));
3541
3644
  }
3542
3645
  autoAdvanceFromUrl(e3, t3) {
3543
- if (this.urlAutoAdvanceChecked) return;
3544
- if (this.urlAutoAdvanceChecked = true, !(0, A.autoAdvanceRequested)() || 1 !== t3.questions.length) return;
3545
- const i2 = (0, A.answeredInput)(e3, t3.questions[0].ref);
3546
- i2 && (0, A.scheduleAutoAdvance)(i2, (() => this.autoSend()));
3646
+ return !(this.urlAutoAdvanceChecked || (this.urlAutoAdvanceChecked = true, !(0, A.autoAdvanceRequested)() || 1 !== t3.questions.length || !(0, A.answeredInput)(e3, t3.questions[0].ref)));
3547
3647
  }
3548
3648
  startForm() {
3549
3649
  this.agentForm ? this.agentForm.startForm() : this.generateForm("navigation");
@@ -3595,42 +3695,42 @@ var require_magicfeedback_sdk_browser = __commonJS({
3595
3695
  if (i2 && (this.feedback.profile = [...this.feedback.profile, ...i2]), t3 && (this.feedback.metrics = [...this.feedback.metrics, ...t3]), e3 && (this.feedback.metadata = [...this.feedback.metadata, ...e3]), o2) {
3596
3696
  this.feedback.answers = [...this.feedback.answers, ...o2], this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
3597
3697
  const e4 = yield this.pushAnswers(false);
3598
- if (!e4) throw new Error("No response");
3698
+ if (!e4) throw new k.SubmitError("SEND_FAILED", "No response");
3599
3699
  return this.id = e4, void (this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total })));
3600
3700
  }
3601
3701
  yield (0, d.awaitUploadReady)(n2), this.answer(), this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
3602
3702
  const l2 = this.history.back();
3603
- if (!l2) throw new Error("No page found");
3703
+ if (!l2) throw new k.SubmitError("NO_PAGE", "No page found");
3604
3704
  for (const e4 of l2.questions.filter(((e5) => e5.require && ![r.FEEDBACKAPPANSWERTYPE.CONSENT, r.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
3605
3705
  const t4 = e4.assets, i3 = this.feedback.answers.filter(((t5) => t5.key.includes(e4.ref) && !t5.key.includes("extra-option")));
3606
- if (0 === i3.length || i3.find(((e5) => 0 === e5.value.length))) throw this.log.err(`The question ${e4.ref} is required`), new Error("No response");
3706
+ if (0 === i3.length || i3.find(((e5) => 0 === e5.value.length))) throw this.log.err(`The question ${e4.ref} is required`), new k.SubmitError("REQUIRED", "No response");
3607
3707
  if (null == t4 ? void 0 : t4.minOptions) {
3608
3708
  let n3 = [];
3609
- if ((null == t4 ? void 0 : t4.exclusiveAnswers) && (n3 = null == t4 ? void 0 : t4.exclusiveAnswers), !i3[0].value.find(((e5) => n3.includes(e5))) && i3[0].value.length < (null == t4 ? void 0 : t4.minOptions)) throw this.log.err(`The question ${e4.ref} requires at least ${null == t4 ? void 0 : t4.minOptions} options`), new Error("No response");
3709
+ if ((null == t4 ? void 0 : t4.exclusiveAnswers) && (n3 = null == t4 ? void 0 : t4.exclusiveAnswers), !i3[0].value.find(((e5) => n3.includes(e5))) && i3[0].value.length < (null == t4 ? void 0 : t4.minOptions)) throw this.log.err(`The question ${e4.ref} requires at least ${null == t4 ? void 0 : t4.minOptions} options`), new k.SubmitError("REQUIRED", "No response");
3610
3710
  }
3611
3711
  if (e4.type === r.FEEDBACKAPPANSWERTYPE.MAX_DIFF) {
3612
3712
  const t5 = null !== (s2 = null === (a2 = e4.assets) || void 0 === a2 ? void 0 : a2.setIndex) && void 0 !== s2 ? s2 : 1, i4 = this.parseMaxDiffAnswer(this.feedback.answers.find(((t6) => t6.key === e4.ref))).find(((e5) => e5.set === t5));
3613
- if (!(null == i4 ? void 0 : i4.best) || !(null == i4 ? void 0 : i4.worst)) throw this.log.err(`The MaxDiff question ${e4.ref} requires the most and the least important`), new Error("No response");
3713
+ if (!(null == i4 ? void 0 : i4.best) || !(null == i4 ? void 0 : i4.worst)) throw this.log.err(`The MaxDiff question ${e4.ref} requires the most and the least important`), new k.SubmitError("REQUIRED", "No response");
3614
3714
  }
3615
3715
  if (e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
3616
3716
  const i4 = this.feedback.answers.find(((t5) => t5.key === e4.ref));
3617
- if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new Error("No response");
3717
+ if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new k.SubmitError("REQUIRED", "No response");
3618
3718
  const n3 = this.parseMatrixAnswerPre(i4), r2 = Array.isArray(null == t4 ? void 0 : t4.options) ? t4.options : [];
3619
3719
  if (r2.length > 0) {
3620
3720
  if (r2.find(((e5) => {
3621
3721
  const t5 = n3.find(((t6) => t6.key === e5));
3622
3722
  return !t5 || !Array.isArray(t5.value) || 0 === t5.value.length;
3623
- }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
3624
- } else if (0 === n3.length || n3.some(((e5) => !Array.isArray(e5.value) || 0 === e5.value.length))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
3723
+ }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new k.SubmitError("REQUIRED", "No response");
3724
+ } else if (0 === n3.length || n3.some(((e5) => !Array.isArray(e5.value) || 0 === e5.value.length))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new k.SubmitError("REQUIRED", "No response");
3625
3725
  }
3626
3726
  }
3627
3727
  const c2 = yield this.pushAnswers(false);
3628
- if (!c2) throw new Error("No response");
3728
+ if (!c2) throw new k.SubmitError("SEND_FAILED", "No response");
3629
3729
  this.id = c2, yield this.processNextQuestion(n2);
3630
3730
  } catch (e4) {
3631
3731
  this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, error: e4 }));
3632
3732
  } finally {
3633
- this.sending = false;
3733
+ this.sending = false, null == n2 || n2.style.removeProperty("visibility");
3634
3734
  }
3635
3735
  }));
3636
3736
  }
@@ -3763,7 +3863,10 @@ var require_magicfeedback_sdk_browser = __commonJS({
3763
3863
  this.feedback.answers = [];
3764
3864
  try {
3765
3865
  const e3 = yield this.pushAnswers(true);
3766
- if (!e3) throw this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: `An error occurred while submitting the form ${this.appId}:` })), new Error("An error occurred while submitting the form ${this.appId}:");
3866
+ if (!e3) {
3867
+ const e4 = new k.SubmitError("SEND_FAILED", `An error occurred while submitting the form ${this.appId}:`);
3868
+ throw this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: e4 })), e4;
3869
+ }
3767
3870
  this.id = e3, this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, completed: this.completed, error: null }));
3768
3871
  } catch (e3) {
3769
3872
  this.log.err(`An error occurred while submitting the form ${this.appId}:`, e3), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: e3 }));
@@ -3805,7 +3908,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
3805
3908
  const r2 = this.history.get(n2);
3806
3909
  if (r2) for (const n3 of r2.questions) {
3807
3910
  if (n3.ref === e3.ref) continue;
3808
- if (k.includes(n3.type)) continue;
3911
+ if (T.includes(n3.type)) continue;
3809
3912
  const o2 = this.followUpAnswerValue(n3, null === (t3 = r2.answers) || void 0 === t3 ? void 0 : t3.find(((e4) => e4.key === n3.ref)));
3810
3913
  void 0 !== o2 && (i2.delete(n3.ref), i2.set(n3.ref, { title: n3.title, answer: o2 }));
3811
3914
  }
@@ -3854,7 +3957,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
3854
3957
  var t3, i2;
3855
3958
  return n(this, void 0, void 0, (function* () {
3856
3959
  const n2 = this.history.back();
3857
- if (!n2) throw new Error("No page found");
3960
+ if (!n2) throw new k.SubmitError("NO_PAGE", "No page found");
3858
3961
  const r2 = n2.isFollowup ? [] : n2.getFollowupQuestions();
3859
3962
  if (0 === (null == r2 ? void 0 : r2.length)) return void (yield this.renderNextQuestion(e3, n2));
3860
3963
  const o2 = [];
@@ -4226,7 +4329,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
4226
4329
  };
4227
4330
  }, 2709: (e2, t2, i) => {
4228
4331
  "use strict";
4229
- Object.defineProperty(t2, "__esModule", { value: true }), t2.RATING_NUMBER_MIN_CHIP_WIDTH = t2.usesLegacyRatingNumber = t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0;
4332
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH = t2.RATING_NUMBER_MIN_CHIP_WIDTH = t2.usesLegacyRatingNumber = t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0;
4230
4333
  const n = i(7627), r = i(9039);
4231
4334
  function o(e3, t3, i2 = "ltr") {
4232
4335
  const n2 = document.createElement("div");
@@ -4275,22 +4378,23 @@ var require_magicfeedback_sdk_browser = __commonJS({
4275
4378
  E.classList.add("magicfeedback-rating-number-container"), E.classList.add(`magicfeedback-rating-number-container-${o2}`), E.classList.add(`magicfeedback-rating-number-container-${a}`), E.style.display = "flex", E.style.flexDirection = b, E.setAttribute("role", "radiogroup"), E.setAttribute("aria-label", (null == i2 ? void 0 : i2.ariaLabel) || (0, n.t)(c, "rating.ariaLabel"));
4276
4379
  const A = (null == i2 ? void 0 : i2.max) ? Number(null == i2 ? void 0 : i2.max) : 10, k = (null == i2 ? void 0 : i2.min) ? Number(null == i2 ? void 0 : i2.min) : 0;
4277
4380
  !v && A - k + 1 > 6 && E.classList.add("magicfeedback-rating-number-container-row--dense");
4278
- const T = (null == i2 ? void 0 : i2.numberPlaceholders) || null, C = !(!T || !Object.keys(T).length);
4279
- let P = null;
4280
- if (!v && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
4281
- P = document.createElement("div"), P.classList.add("magicfeedback-rating-number-scale-labels");
4381
+ const T = (null == i2 ? void 0 : i2.numberPlaceholders) || null, C = !(!T || !Object.keys(T).length), P = !v && !f && !!T && Object.values(T).some(((e4) => !!e4)), S = "bottom" === (null == i2 ? void 0 : i2.numberPlaceholdersPosition) ? "bottom" : "top";
4382
+ P && (E.style.alignItems = "stretch");
4383
+ let w = null;
4384
+ if (!v && !P && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
4385
+ w = document.createElement("div"), w.classList.add("magicfeedback-rating-number-scale-labels");
4282
4386
  const e4 = document.createElement("span");
4283
4387
  e4.classList.add("magicfeedback-rating-number-scale-label"), e4.textContent = null !== (p = null == i2 ? void 0 : i2.minPlaceholder) && void 0 !== p ? p : "";
4284
4388
  const t3 = document.createElement("span");
4285
- t3.classList.add("magicfeedback-rating-number-scale-label"), t3.textContent = null !== (m = null == i2 ? void 0 : i2.maxPlaceholder) && void 0 !== m ? m : "", "ltr" === o2 ? (P.appendChild(e4), P.appendChild(t3)) : (P.appendChild(t3), P.appendChild(e4));
4389
+ t3.classList.add("magicfeedback-rating-number-scale-label"), t3.textContent = null !== (m = null == i2 ? void 0 : i2.maxPlaceholder) && void 0 !== m ? m : "", "ltr" === o2 ? (w.appendChild(e4), w.appendChild(t3)) : (w.appendChild(t3), w.appendChild(e4));
4286
4390
  }
4287
- let w = null;
4288
- if (v && !C && E.classList.add("magicfeedback-rating-number-container-column--bare"), (!v || !C) && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
4391
+ let O = null;
4392
+ if (v && !C && E.classList.add("magicfeedback-rating-number-container-column--bare"), (v ? !C : !P) && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
4289
4393
  const e4 = "ltr" === o2 ? null == i2 ? void 0 : i2.minPlaceholder : null == i2 ? void 0 : i2.maxPlaceholder, t3 = "ltr" === o2 ? null == i2 ? void 0 : i2.maxPlaceholder : null == i2 ? void 0 : i2.minPlaceholder, n2 = (e5) => {
4290
4394
  const t4 = document.createElement("div");
4291
4395
  return t4.classList.add("magicfeedback-rating-number-scale-label-block"), v || (t4.classList.add("magicfeedback-rating-number-scale-label-block--stacked"), t4.style.display = "none"), t4.textContent = e5, t4;
4292
4396
  };
4293
- e4 && h.appendChild(n2(e4)), t3 && (w = n2(t3));
4397
+ e4 && h.appendChild(n2(e4)), t3 && (O = n2(t3));
4294
4398
  }
4295
4399
  for (let t3 = k; t3 <= A; t3++) {
4296
4400
  const n2 = document.createElement("div");
@@ -4304,37 +4408,47 @@ var require_magicfeedback_sdk_browser = __commonJS({
4304
4408
  const m2 = document.createElement("span");
4305
4409
  m2.classList.add("magicfeedback-rating-number-value");
4306
4410
  const h2 = document.createElement("span");
4307
- if (h2.textContent = p2 ? `${t3} = ${p2}` : t3.toString(), h2.classList.add("magicfeedback-rating-number-value-num"), f && (h2.style.fontWeight = "normal"), m2.appendChild(h2), v) {
4308
- if (c2) {
4309
- const e4 = document.createElement("span");
4310
- e4.textContent = c2, e4.classList.add("magicfeedback-rating-number-value-label"), m2.appendChild(e4);
4311
- }
4312
- } else T && T[t3] && (o3.title = T[t3]);
4313
- o3.appendChild(m2), n2.appendChild(o3), E.appendChild(n2);
4411
+ if (h2.textContent = p2 ? `${t3} = ${p2}` : t3.toString(), h2.classList.add("magicfeedback-rating-number-value-num"), f && (h2.style.fontWeight = "normal"), m2.appendChild(h2), (v || P) && c2) {
4412
+ const e4 = document.createElement("span");
4413
+ e4.textContent = c2, e4.classList.add("magicfeedback-rating-number-value-label"), v || (e4.style.display = "none"), m2.appendChild(e4);
4414
+ } else !v && !P && T && T[t3] && (o3.title = T[t3]);
4415
+ if (o3.appendChild(m2), P) {
4416
+ const e4 = document.createElement("label");
4417
+ e4.htmlFor = u2.id, e4.classList.add("magicfeedback-rating-number-option-caption"), e4.textContent = c2 || "", n2.classList.add("magicfeedback-rating-number-option--captioned"), n2.classList.add(`magicfeedback-rating-number-option--caption-${S}`), n2.style.flexDirection = "top" === S ? "column" : "column-reverse", n2.style.justifyContent = "flex-end", n2.appendChild(e4);
4418
+ }
4419
+ n2.appendChild(o3), E.appendChild(n2);
4420
+ }
4421
+ if (h.appendChild(E), O && h.appendChild(O), w) {
4422
+ const e4 = null == i2 ? void 0 : i2.minMaxPlaceholderPosition;
4423
+ "top" !== e4 && "bottom" !== e4 || (w.classList.add(`magicfeedback-rating-number-scale-labels--${e4}`), w.style.order = "top" === e4 ? "-1" : "1"), "top" === e4 ? h.insertBefore(w, E) : h.appendChild(w);
4314
4424
  }
4315
- if (h.appendChild(E), w && h.appendChild(w), P && h.appendChild(P), v || f || (function(e4, i3, n2, r2) {
4425
+ if (v || f || (function(e4, i3, n2, r2, o3 = t2.RATING_NUMBER_MIN_CHIP_WIDTH) {
4316
4426
  if ("undefined" == typeof ResizeObserver) return;
4317
- const o3 = i3.classList.contains("magicfeedback-rating-number-container-row--dense");
4318
- let a2 = 0, s2 = false;
4319
- const l2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
4320
- let d2 = 0, c2 = false;
4321
- new ResizeObserver(((u2) => {
4322
- var p2;
4323
- const m2 = null === (p2 = u2[0]) || void 0 === p2 ? void 0 : p2.contentRect.width;
4324
- m2 && m2 !== d2 && (d2 = m2, c2 || (c2 = true, l2((() => {
4325
- c2 = false, s2 || (a2 = parseFloat(getComputedStyle(i3).columnGap) || 0);
4326
- const l3 = n2 * t2.RATING_NUMBER_MIN_CHIP_WIDTH + (n2 - 1) * a2;
4327
- var u3;
4328
- (u3 = d2 < l3) !== s2 && (s2 = u3, e4.classList.toggle("magicfeedback-rating-number--stacked", u3), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-labels").forEach(((e5) => {
4329
- e5.style.display = u3 ? "none" : "";
4427
+ const a2 = i3.classList.contains("magicfeedback-rating-number-container-row--dense"), s2 = !!i3.querySelector(".magicfeedback-rating-number-option--captioned");
4428
+ let l2 = 0, d2 = false;
4429
+ const c2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
4430
+ let u2 = 0, p2 = false;
4431
+ new ResizeObserver(((t3) => {
4432
+ var m2;
4433
+ const h2 = null === (m2 = t3[0]) || void 0 === m2 ? void 0 : m2.contentRect.width;
4434
+ h2 && h2 !== u2 && (u2 = h2, p2 || (p2 = true, c2((() => {
4435
+ var t4;
4436
+ p2 = false, d2 || (l2 = parseFloat(getComputedStyle(i3).columnGap) || 0), (t4 = u2 < n2 * o3 + (n2 - 1) * l2) !== d2 && (d2 = t4, e4.classList.toggle("magicfeedback-rating-number--stacked", t4), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-labels").forEach(((e5) => {
4437
+ e5.style.display = t4 ? "none" : "";
4330
4438
  })), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-label-block--stacked").forEach(((e5) => {
4331
- e5.style.display = u3 ? "" : "none";
4332
- })), i3.classList.toggle("magicfeedback-rating-number-container-row", !u3), i3.classList.toggle("magicfeedback-rating-number-container-row--dense", !u3 && o3), i3.classList.toggle("magicfeedback-rating-number-container-column", u3), i3.classList.toggle("magicfeedback-rating-number-container-column--bare", u3), i3.style.flexDirection = u3 ? "ltr" === r2 ? "column" : "column-reverse" : "ltr" === r2 ? "row" : "row-reverse", i3.querySelectorAll(":scope > .magicfeedback-rating-number-option").forEach(((e5) => {
4333
- e5.classList.toggle("magicfeedback-rating-number-option-row", !u3), e5.classList.toggle("magicfeedback-rating-number-option-column", u3);
4439
+ e5.style.display = t4 ? "" : "none";
4440
+ })), i3.classList.toggle("magicfeedback-rating-number-container-row", !t4), i3.classList.toggle("magicfeedback-rating-number-container-row--dense", !t4 && a2), i3.classList.toggle("magicfeedback-rating-number-container-column", t4), i3.classList.toggle("magicfeedback-rating-number-container-column--bare", t4 && !s2), i3.style.flexDirection = t4 ? "ltr" === r2 ? "column" : "column-reverse" : "ltr" === r2 ? "row" : "row-reverse", i3.querySelectorAll(":scope > .magicfeedback-rating-number-option").forEach(((e5) => {
4441
+ if (e5.classList.toggle("magicfeedback-rating-number-option-row", !t4), e5.classList.toggle("magicfeedback-rating-number-option-column", t4), !e5.classList.contains("magicfeedback-rating-number-option--captioned")) return;
4442
+ const i4 = e5.classList.contains("magicfeedback-rating-number-option--caption-top");
4443
+ e5.style.flexDirection = t4 ? "" : i4 ? "column" : "column-reverse", e5.querySelectorAll(".magicfeedback-rating-number-option-caption").forEach(((e6) => {
4444
+ e6.style.display = t4 ? "none" : "";
4445
+ })), e5.querySelectorAll(".magicfeedback-rating-number-value-label").forEach(((e6) => {
4446
+ e6.style.display = t4 ? "" : "none";
4447
+ }));
4334
4448
  })));
4335
4449
  }))));
4336
4450
  })).observe(e4);
4337
- })(h, E, A - k + 1, o2), (null == i2 ? void 0 : i2.extraOption) && (null == i2 ? void 0 : i2.extraOptionText)) {
4451
+ })(h, E, A - k + 1, o2, P ? t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH : t2.RATING_NUMBER_MIN_CHIP_WIDTH), (null == i2 ? void 0 : i2.extraOption) && (null == i2 ? void 0 : i2.extraOptionText)) {
4338
4452
  const t3 = document.createElement("div");
4339
4453
  t3.classList.add("magicfeedback-rating-number-extra-row");
4340
4454
  const n2 = document.createElement("div");
@@ -4351,7 +4465,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
4351
4465
  return h;
4352
4466
  }, t2.usesLegacyRatingNumber = function(e3) {
4353
4467
  return !!e3 && /matas/i.test(e3);
4354
- }, t2.RATING_NUMBER_MIN_CHIP_WIDTH = 44;
4468
+ }, t2.RATING_NUMBER_MIN_CHIP_WIDTH = 44, t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH = 72;
4355
4469
  }, 368: (e2, t2, i) => {
4356
4470
  "use strict";
4357
4471
  Object.defineProperty(t2, "__esModule", { value: true }), t2.getQuestionRenderer = void 0;
@@ -4376,36 +4490,51 @@ var require_magicfeedback_sdk_browser = __commonJS({
4376
4490
  };
4377
4491
  }, 620: (e2, t2, i) => {
4378
4492
  "use strict";
4379
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderChoice = void 0;
4493
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.CHOICE_ROW_MIN_OPTION_WIDTH = t2.renderChoice = void 0;
4380
4494
  const n = i(4760), r = i(3262), o = i(9039);
4381
- t2.renderChoice = ({ question: e3, language: t3, urlParamValue: i2, randomPosition: a, send: s }) => {
4382
- const { type: l, ref: d, value: c, defaultValue: u, assets: p } = e3, m = document.createElement("div"), h = "magicfeedback-" + ("MULTIPLECHOICE" === l ? "checkbox" : "radio");
4383
- let f = c || [];
4384
- a && (f = f.sort((() => Math.random() - 0.5)));
4385
- let g = (null == p ? void 0 : p.exclusiveAnswers) || [];
4386
- (null == p ? void 0 : p.extraOption) && (g = g.filter(((e4) => e4 !== p.extraOptionText))), g.length > 0 && (null == g || g.forEach(((e4) => {
4387
- f.includes(e4) || f.push(e4);
4495
+ t2.renderChoice = ({ question: e3, language: i2, urlParamValue: s, randomPosition: l, send: d }) => {
4496
+ const { type: c, ref: u, value: p, defaultValue: m, assets: h } = e3, f = document.createElement("div"), g = "magicfeedback-" + ("MULTIPLECHOICE" === c ? "checkbox" : "radio");
4497
+ let y = p || [];
4498
+ l && (y = y.sort((() => Math.random() - 0.5)));
4499
+ let v = (null == h ? void 0 : h.exclusiveAnswers) || [];
4500
+ (null == h ? void 0 : h.extraOption) && (v = v.filter(((e4) => e4 !== h.extraOptionText))), v.length > 0 && (null == v || v.forEach(((e4) => {
4501
+ y.includes(e4) || y.push(e4);
4388
4502
  })));
4389
- const y = null == p ? void 0 : p.extraOptionText;
4390
- return (null == p ? void 0 : p.extraOption) && y && !f.includes(y) && f.push(y), f.forEach(((e4, a2) => {
4391
- const c2 = document.createElement("div");
4392
- c2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === l ? "checkbox" : "radio"}-container`);
4393
- const y2 = document.createElement("label"), v = document.createElement("input");
4394
- if (v.id = `rating-${d}-${a2}`, v.type = "MULTIPLECHOICE" === l ? "checkbox" : "radio", v.name = d, v.value = e4, v.classList.add(h), v.classList.add("magicfeedback-input"), l === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == p ? void 0 : p.maxOptions) && (null == p ? void 0 : p.maxOptions) > 0 && v.addEventListener("change", (() => {
4395
- document.querySelectorAll(`input[name="${d}"]:checked`).length > (null == p ? void 0 : p.maxOptions) && (v.checked = false);
4396
- })), l === n.FEEDBACKAPPANSWERTYPE.RADIO && s && (!(null == p ? void 0 : p.extraOptionText) || (null == p ? void 0 : p.extraOptionText) && e4 !== (null == p ? void 0 : p.extraOptionText)) && (0, o.autoAdvanceOn)(v, s), e4 !== u && e4 !== i2 || (v.checked = true), y2.textContent = e4, y2.htmlFor = `rating-${d}-${a2}`, v.addEventListener("change", ((t4) => {
4397
- const i3 = document.getElementById(`extra-option-${d}`);
4398
- t4.target.checked && g.includes(e4) ? (f.forEach(((t5) => {
4503
+ const b = null == h ? void 0 : h.extraOptionText;
4504
+ return (null == h ? void 0 : h.extraOption) && b && !y.includes(b) && y.push(b), y.forEach(((e4, t3) => {
4505
+ const a2 = document.createElement("div");
4506
+ a2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === c ? "checkbox" : "radio"}-container`);
4507
+ const l2 = document.createElement("label"), p2 = document.createElement("input");
4508
+ if (p2.id = `rating-${u}-${t3}`, p2.type = "MULTIPLECHOICE" === c ? "checkbox" : "radio", p2.name = u, p2.value = e4, p2.classList.add(g), p2.classList.add("magicfeedback-input"), c === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == h ? void 0 : h.maxOptions) && (null == h ? void 0 : h.maxOptions) > 0 && p2.addEventListener("change", (() => {
4509
+ document.querySelectorAll(`input[name="${u}"]:checked`).length > (null == h ? void 0 : h.maxOptions) && (p2.checked = false);
4510
+ })), c === n.FEEDBACKAPPANSWERTYPE.RADIO && d && (!(null == h ? void 0 : h.extraOptionText) || (null == h ? void 0 : h.extraOptionText) && e4 !== (null == h ? void 0 : h.extraOptionText)) && (0, o.autoAdvanceOn)(p2, d), e4 !== m && e4 !== s || (p2.checked = true), l2.textContent = e4, l2.htmlFor = `rating-${u}-${t3}`, p2.addEventListener("change", ((t4) => {
4511
+ const i3 = document.getElementById(`extra-option-${u}`);
4512
+ t4.target.checked && v.includes(e4) ? (y.forEach(((t5) => {
4399
4513
  t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
4400
- })), i3 && (i3.style.display = "none")) : g.forEach(((t5) => {
4514
+ })), i3 && (i3.style.display = "none")) : v.forEach(((t5) => {
4401
4515
  t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
4402
- })), (null == p ? void 0 : p.extraOption) && e4 === (null == p ? void 0 : p.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
4403
- })), c2.appendChild(v), c2.appendChild(y2), m.appendChild(c2), (null == p ? void 0 : p.extraOption) && e4 === (null == p ? void 0 : p.extraOptionText)) {
4516
+ })), (null == h ? void 0 : h.extraOption) && e4 === (null == h ? void 0 : h.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
4517
+ })), a2.appendChild(p2), a2.appendChild(l2), f.appendChild(a2), (null == h ? void 0 : h.extraOption) && e4 === (null == h ? void 0 : h.extraOptionText)) {
4404
4518
  const e5 = document.createElement("input");
4405
- e5.type = "text", e5.placeholder = (null == p ? void 0 : p.extraOptionPlaceholder) || r.placeholder.answer(t3 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${d}`, e5.name = `extra-option-${d}`, e5.style.display = "none", m.appendChild(e5);
4519
+ e5.type = "text", e5.placeholder = (null == h ? void 0 : h.extraOptionPlaceholder) || r.placeholder.answer(i2 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${u}`, e5.name = `extra-option-${u}`, e5.style.display = "none", f.appendChild(e5);
4406
4520
  }
4407
- })), { element: m, elementTypeClass: h };
4408
- };
4521
+ })), c === n.FEEDBACKAPPANSWERTYPE.RADIO && "row" === (null == h ? void 0 : h.direction) && (f.classList.add("magicfeedback-radio--row"), (function(e4, i3) {
4522
+ if (e4.classList.toggle("magicfeedback-radio--stacked", window.innerWidth < a), "undefined" == typeof ResizeObserver) return;
4523
+ const n2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
4524
+ let r2 = 0, o2 = false;
4525
+ new ResizeObserver(((s2) => {
4526
+ var l2;
4527
+ const d2 = null === (l2 = s2[0]) || void 0 === l2 ? void 0 : l2.contentRect.width;
4528
+ d2 && d2 !== r2 && (r2 = d2, o2 || (o2 = true, n2((() => {
4529
+ o2 = false, ((n3) => {
4530
+ const r3 = parseFloat(getComputedStyle(e4).columnGap) || 0, o3 = i3 * t2.CHOICE_ROW_MIN_OPTION_WIDTH + (i3 - 1) * r3;
4531
+ e4.classList.toggle("magicfeedback-radio--stacked", window.innerWidth < a || n3 < o3);
4532
+ })(r2);
4533
+ }))));
4534
+ })).observe(e4);
4535
+ })(f, y.length)), { element: f, elementTypeClass: g };
4536
+ }, t2.CHOICE_ROW_MIN_OPTION_WIDTH = 120;
4537
+ const a = 600;
4409
4538
  }, 9369: (e2, t2, i) => {
4410
4539
  "use strict";
4411
4540
  Object.defineProperty(t2, "__esModule", { value: true }), t2.renderConsent = void 0;
@@ -4766,21 +4895,21 @@ var require_magicfeedback_sdk_browser = __commonJS({
4766
4895
  C();
4767
4896
  const P = document.createElement("button");
4768
4897
  P.type = "button", P.classList.add("magicfeedback-modal-close"), P.setAttribute("aria-label", d("cancel")), P.title = d("cancel"), P.textContent = "\xD7", P.style.position = "absolute", P.style.top = "8px", P.style.setProperty("inset-inline-end", "8px"), P.style.border = "none", P.style.background = "transparent", P.style.fontSize = "24px", P.style.cursor = "pointer";
4769
- const w = () => {
4898
+ const S = () => {
4770
4899
  document.body.appendChild(g), g.style.display = "flex", E(), C();
4771
- }, x = () => {
4900
+ }, w = () => {
4772
4901
  g.style.display = "none", c.appendChild(g);
4773
4902
  };
4774
4903
  P.addEventListener("click", (() => {
4775
- x();
4776
- }));
4777
- const S = document.createElement("button");
4778
- return S.type = "button", S.textContent = d("confirm"), S.classList.add("magicfeedback-button"), S.classList.add("magicfeedback-button-primary"), S.addEventListener("click", (() => {
4779
- x(), f();
4780
- })), k.appendChild(T), k.appendChild(S), y.appendChild(P), y.appendChild(v), y.appendChild(A), y.appendChild(k), g.appendChild(y), p2.addEventListener("click", (() => {
4781
4904
  w();
4905
+ }));
4906
+ const O = document.createElement("button");
4907
+ return O.type = "button", O.textContent = d("confirm"), O.classList.add("magicfeedback-button"), O.classList.add("magicfeedback-button-primary"), O.addEventListener("click", (() => {
4908
+ w(), f();
4909
+ })), k.appendChild(T), k.appendChild(O), y.appendChild(P), y.appendChild(v), y.appendChild(A), y.appendChild(k), g.appendChild(y), p2.addEventListener("click", (() => {
4910
+ S();
4782
4911
  })), g.addEventListener("click", ((e6) => {
4783
- e6.target === g && x();
4912
+ e6.target === g && w();
4784
4913
  })), c.appendChild(o3), c.appendChild(m), c.appendChild(g), f(), c;
4785
4914
  }
4786
4915
  const u = document.createElement("ul");
@@ -4999,23 +5128,23 @@ var require_magicfeedback_sdk_browser = __commonJS({
4999
5128
  C.classList.add("magicfeedback-upload-error");
5000
5129
  const P = document.createElement("ul");
5001
5130
  P.classList.add("magicfeedback-upload-list"), y.appendChild(E), y.appendChild(C), y.appendChild(P);
5002
- const w = /* @__PURE__ */ new WeakMap(), x = (e4) => {
5003
- const t4 = w.get(e4);
5131
+ const S = /* @__PURE__ */ new WeakMap(), w = (e4) => {
5132
+ const t4 = S.get(e4);
5004
5133
  return t4 ? Promise.resolve(t4) : new Promise(((t5) => {
5005
5134
  const i3 = new FileReader(), n3 = (i4) => {
5006
5135
  const n4 = JSON.stringify({ name: e4.name, type: e4.type, size: e4.size, content: i4 });
5007
- w.set(e4, n4), t5(n4);
5136
+ S.set(e4, n4), t5(n4);
5008
5137
  };
5009
5138
  i3.onload = () => n3("string" == typeof i3.result ? i3.result : ""), i3.onerror = () => n3(""), i3.readAsDataURL(e4);
5010
5139
  }));
5011
- }, S = [], O = (e4) => {
5140
+ }, O = [], x = (e4) => {
5012
5141
  try {
5013
5142
  const t4 = h > 0 ? e4.slice(0, h) : e4, i3 = new DataTransfer();
5014
5143
  t4.forEach(((e5) => i3.items.add(e5))), v.files = i3.files;
5015
5144
  } catch (e5) {
5016
5145
  }
5017
5146
  !(function() {
5018
- S.forEach(((e6) => URL.revokeObjectURL(e6))), S.length = 0, P.innerHTML = "";
5147
+ O.forEach(((e6) => URL.revokeObjectURL(e6))), O.length = 0, P.innerHTML = "";
5019
5148
  const e5 = Array.from(v.files || []);
5020
5149
  y.classList.toggle("magicfeedback-upload--has-files", e5.length > 0), e5.forEach(((e6, n3) => {
5021
5150
  const o2 = document.createElement("li");
@@ -5023,7 +5152,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
5023
5152
  const a2 = document.createElement("span");
5024
5153
  if (a2.classList.add("magicfeedback-upload-thumb"), "image" === i2 && e6.type.startsWith("image/")) {
5025
5154
  const t4 = URL.createObjectURL(e6);
5026
- S.push(t4);
5155
+ O.push(t4);
5027
5156
  const i3 = document.createElement("img");
5028
5157
  i3.src = t4, i3.alt = e6.name, a2.appendChild(i3);
5029
5158
  } else a2.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>';
@@ -5035,11 +5164,11 @@ var require_magicfeedback_sdk_browser = __commonJS({
5035
5164
  c2.classList.add("magicfeedback-upload-file-size"), c2.textContent = l(e6.size), s2.appendChild(d2), s2.appendChild(c2);
5036
5165
  const u2 = document.createElement("button");
5037
5166
  u2.type = "button", u2.classList.add("magicfeedback-upload-remove"), u2.setAttribute("aria-label", `${r.placeholder.upload.remove(t3)}: ${e6.name}`), u2.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', u2.addEventListener("click", ((e7) => {
5038
- e7.preventDefault(), e7.stopPropagation(), O(Array.from(v.files || []).filter(((e8, t4) => t4 !== n3)));
5167
+ e7.preventDefault(), e7.stopPropagation(), x(Array.from(v.files || []).filter(((e8, t4) => t4 !== n3)));
5039
5168
  })), o2.appendChild(a2), o2.appendChild(s2), o2.appendChild(u2), P.appendChild(o2);
5040
5169
  }));
5041
5170
  })(), (() => {
5042
- const e5 = Array.from(v.files || []), t4 = Promise.all(e5.map(x)).then(((e6) => {
5171
+ const e5 = Array.from(v.files || []), t4 = Promise.all(e5.map(w)).then(((e6) => {
5043
5172
  v[a] = e6;
5044
5173
  }));
5045
5174
  v[s] = t4;
@@ -5055,7 +5184,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
5055
5184
  };
5056
5185
  v.addEventListener("change", (() => {
5057
5186
  const { accepted: e4, rejected: t4 } = N(Array.from(v.files || []));
5058
- L(t4), O(e4);
5187
+ L(t4), x(e4);
5059
5188
  }));
5060
5189
  const I = (e4) => {
5061
5190
  e4.preventDefault(), e4.stopPropagation();
@@ -5072,7 +5201,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
5072
5201
  const { accepted: r2, rejected: o2 } = N(n3);
5073
5202
  if (L(o2), !r2.length) return;
5074
5203
  const a2 = m ? Array.from(v.files || []) : [];
5075
- O(a2.concat(r2));
5204
+ x(a2.concat(r2));
5076
5205
  })), { element: y, elementTypeClass: p };
5077
5206
  };
5078
5207
  }, 4759: function(e2, t2, i) {
@@ -5288,13 +5417,13 @@ var require_magicfeedback_sdk_browser = __commonJS({
5288
5417
  var p2, m2, h2;
5289
5418
  let f2, g2, { id: y2, title: v, type: b, ref: E, require: A, defaultValue: k, assets: T } = e5, C = document.createElement("div");
5290
5419
  C.classList.add("magicfeedback-div");
5291
- const P = window.innerWidth < 600, w = "slim" === t4 ? (0, o.parseTitle)(v, i3) : null == T ? void 0 : T.placeholder, x = (0, a.shownValueFor)(e5, (0, o.getUrlParam)(E)), S = (null == T ? void 0 : T.maxCharacters) || 0, O = false === (null == T ? void 0 : T.autoAdvance) ? void 0 : c2, L = void 0 !== (null == T ? void 0 : T.randomPosition) && (null == T ? void 0 : T.randomPosition), N = (null == T ? void 0 : T.direction) || "row", I = (null == T ? void 0 : T.order) || "ltr", D = (0, r.getQuestionRenderer)(b);
5420
+ const P = window.innerWidth < 600, S = "slim" === t4 ? (0, o.parseTitle)(v, i3) : null == T ? void 0 : T.placeholder, w = (0, a.shownValueFor)(e5, (0, o.getUrlParam)(E)), O = (null == T ? void 0 : T.maxCharacters) || 0, x = false === (null == T ? void 0 : T.autoAdvance) ? void 0 : c2, L = void 0 !== (null == T ? void 0 : T.randomPosition) && (null == T ? void 0 : T.randomPosition), N = (null == T ? void 0 : T.direction) || "row", I = (null == T ? void 0 : T.order) || "ltr", D = (0, r.getQuestionRenderer)(b);
5292
5421
  if (!D) return C;
5293
5422
  {
5294
- const r2 = D({ question: e5, format: t4, language: i3, url: d2, send: b === n.FEEDBACKAPPANSWERTYPE.TEXT ? c2 : O, isPhone: P, urlParamValue: x, placeholderText: w, maxCharacters: S, randomPosition: L, direction: N, order: I, productId: u2 });
5423
+ const r2 = D({ question: e5, format: t4, language: i3, url: d2, send: b === n.FEEDBACKAPPANSWERTYPE.TEXT ? c2 : x, isPhone: P, urlParamValue: w, placeholderText: S, maxCharacters: O, randomPosition: L, direction: N, order: I, productId: u2 });
5295
5424
  f2 = r2.element, g2 = r2.elementTypeClass;
5296
5425
  }
5297
- f2.id = `magicfeedback-${y2}`, f2.setAttribute("name", E), f2.classList.add(g2), (void 0 !== k || null !== x) && (f2.value = x || k), ["RADIO", "MULTIPLECHOICE", "UPLOAD_IMAGE", "UPLOAD_FILE"].includes(b) || (f2.classList.add("magicfeedback-input"), f2.required = A);
5426
+ f2.id = `magicfeedback-${y2}`, f2.setAttribute("name", E), f2.classList.add(g2), (void 0 !== k || null !== w) && (f2.value = w || k), ["RADIO", "MULTIPLECHOICE", "UPLOAD_IMAGE", "UPLOAD_FILE"].includes(b) || (f2.classList.add("magicfeedback-input"), f2.required = A);
5298
5427
  const R = document.createElement("label");
5299
5428
  R.setAttribute("for", `magicfeedback-${y2}`), R.textContent = (0, o.parseTitle)(v, i3), R.classList.add("magicfeedback-label"), (function(e6, t5) {
5300
5429
  if ("INFO_PAGE" !== t5.type) return;
@@ -5304,17 +5433,17 @@ var require_magicfeedback_sdk_browser = __commonJS({
5304
5433
  var o2;
5305
5434
  n2 && e6.style.setProperty("font-size", n2, "important"), (null == i4 ? void 0 : i4.titleAlign) && (e6.style.setProperty("width", "100%", "important"), e6.style.setProperty("align-self", "stretch", "important"), e6.style.setProperty("text-align", i4.titleAlign, "important")), r2.includes("italic") && e6.style.setProperty("font-style", "italic", "important"), r2.includes("bold") && e6.style.setProperty("font-weight", "bold", "important"), r2.includes("underline") && e6.style.setProperty("text-decoration", "underline", "important");
5306
5435
  })(R, e5);
5307
- const M = document.createElement("label");
5308
- if (M.textContent = (0, o.parseTitle)(null == T ? void 0 : T.subtitle, i3), M.classList.add("magicfeedback-sublabel"), (null === (p2 = null == T ? void 0 : T.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("italic")) && (M.style.fontStyle = "italic"), (null === (m2 = null == T ? void 0 : T.subtitleStyle) || void 0 === m2 ? void 0 : m2.includes("bold")) && (M.style.fontWeight = "bold"), (null === (h2 = null == T ? void 0 : T.subtitleStyle) || void 0 === h2 ? void 0 : h2.includes("underline")) && (M.style.textDecoration = "underline"), ["CONSENT"].includes(b)) C.classList.add("magicfeedback-consent-container"), C.appendChild(f2), C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(M);
5436
+ const _ = document.createElement("label");
5437
+ if (_.textContent = (0, o.parseTitle)(null == T ? void 0 : T.subtitle, i3), _.classList.add("magicfeedback-sublabel"), (null === (p2 = null == T ? void 0 : T.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("italic")) && (_.style.fontStyle = "italic"), (null === (m2 = null == T ? void 0 : T.subtitleStyle) || void 0 === m2 ? void 0 : m2.includes("bold")) && (_.style.fontWeight = "bold"), (null === (h2 = null == T ? void 0 : T.subtitleStyle) || void 0 === h2 ? void 0 : h2.includes("underline")) && (_.style.textDecoration = "underline"), ["CONSENT"].includes(b)) C.classList.add("magicfeedback-consent-container"), C.appendChild(f2), C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(_);
5309
5438
  else {
5310
- if ("slim" !== t4 && (C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(M), void 0 !== (null == T ? void 0 : T.general) && "" !== (null == T ? void 0 : T.general))) {
5439
+ if ("slim" !== t4 && (C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(_), void 0 !== (null == T ? void 0 : T.general) && "" !== (null == T ? void 0 : T.general))) {
5311
5440
  const e6 = document.createElement("img");
5312
5441
  e6.src = null == T ? void 0 : T.general, e6.classList.add("magicfeedback-image"), e6.style.maxWidth = "auto", e6.style.height = "400px", e6.style.margin = "10px 0", C.appendChild(e6);
5313
5442
  }
5314
- if ("LONGTEXT" === b && S > 0) {
5443
+ if ("LONGTEXT" === b && O > 0) {
5315
5444
  const e6 = document.createElement("div");
5316
- if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${f2.value.length}/${S}`, e6.style.textAlign = "end", e6.style.fontSize = "15px", e6.style.marginTop = "5px", f2.addEventListener("input", (() => {
5317
- e6.textContent = `${f2.value.length}/${S}`;
5445
+ if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${f2.value.length}/${O}`, e6.style.textAlign = "end", e6.style.fontSize = "15px", e6.style.marginTop = "5px", f2.addEventListener("input", (() => {
5446
+ e6.textContent = `${f2.value.length}/${O}`;
5318
5447
  })), C.appendChild(f2), C.appendChild(e6), (null == T ? void 0 : T.extraOption) && (null == T ? void 0 : T.extraOptionText)) {
5319
5448
  const e7 = document.createElement("div");
5320
5449
  e7.classList.add("magicfeedback-skip-container"), e7.classList.add("magicfeedback-checkbox-container"), e7.style.display = "flex", e7.style.justifyContent = "flex-start";
@@ -5323,7 +5452,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
5323
5452
  const i4 = document.createElement("label");
5324
5453
  i4.htmlFor = `skip-${E}`, i4.textContent = null == T ? void 0 : T.extraOptionText, i4.style.fontSize = "15px", i4.style.cursor = "pointer", i4.style.margin = "0 5px", t5.addEventListener("click", (() => {
5325
5454
  f2.value = "-";
5326
- })), (0, s.autoAdvanceOn)(t5, O, "click"), e7.appendChild(t5), e7.appendChild(i4), C.appendChild(e7);
5455
+ })), (0, s.autoAdvanceOn)(t5, x, "click"), e7.appendChild(t5), e7.appendChild(i4), C.appendChild(e7);
5327
5456
  }
5328
5457
  } else C.appendChild(f2);
5329
5458
  }
@@ -5387,15 +5516,29 @@ var require_magicfeedback_sdk_browser = __commonJS({
5387
5516
  }, r = this && this.__importDefault || function(e3) {
5388
5517
  return e3 && e3.__esModule ? e3 : { default: e3 };
5389
5518
  };
5390
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.validateEmail = t2.header = void 0;
5519
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.takePreloadedInfo = t2.validateEmail = t2.header = void 0;
5391
5520
  const o = r(i(6539)), a = r(i(8330)), s = i(5407), l = i(3433);
5521
+ function d(e3) {
5522
+ if ("undefined" == typeof window) return;
5523
+ const i2 = window, n2 = i2.__MAGICFEEDBACK_PRELOADED_INFO__;
5524
+ if (n2 && n2.url === e3 && n2.parameters === t2.header["x-magicfeedback-parameters"]) {
5525
+ delete i2.__MAGICFEEDBACK_PRELOADED_INFO__;
5526
+ try {
5527
+ return JSON.parse(n2.body);
5528
+ } catch (e4) {
5529
+ return;
5530
+ }
5531
+ }
5532
+ }
5392
5533
  t2.header = { Accept: "application/json", "Magicfeedback-Sdk-Version": a.default.version, "x-magicfeedback-parameters": window.location.search || "" }, t2.validateEmail = function(e3) {
5393
5534
  return /\S+@\S+\.\S+/.test(e3);
5394
- }, t2.getForm = function(e3, i2, r2, a2, d) {
5535
+ }, t2.takePreloadedInfo = d, t2.getForm = function(e3, i2, r2, a2, c) {
5395
5536
  return n(this, void 0, void 0, (function* () {
5396
5537
  try {
5397
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app_info(i2, r2), d), { method: "GET", headers: t2.header });
5398
- return yield n2.json();
5538
+ const n2 = (0, l.withLangParam)(e3 + s.endpoints.sdk.app_info(i2, r2), c), a3 = d(n2);
5539
+ if (void 0 !== a3) return a3;
5540
+ const u = yield (0, o.default)(n2, { method: "GET", headers: t2.header });
5541
+ return yield u.json();
5399
5542
  } catch (e4) {
5400
5543
  a2.err(e4);
5401
5544
  }
@@ -5403,16 +5546,18 @@ var require_magicfeedback_sdk_browser = __commonJS({
5403
5546
  }, t2.getSessionForm = function(e3, i2, r2, a2) {
5404
5547
  return n(this, void 0, void 0, (function* () {
5405
5548
  try {
5406
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.session(i2), a2), { method: "GET", headers: t2.header });
5407
- return yield n2.json();
5549
+ const n2 = (0, l.withLangParam)(e3 + s.endpoints.sdk.session(i2), a2), r3 = d(n2);
5550
+ if (void 0 !== r3) return r3;
5551
+ const c = yield (0, o.default)(n2, { method: "GET", headers: t2.header });
5552
+ return yield c.json();
5408
5553
  } catch (e4) {
5409
5554
  r2.err(e4);
5410
5555
  }
5411
5556
  }));
5412
- }, t2.getQuestions = function(e3, i2, r2, a2, d) {
5557
+ }, t2.getQuestions = function(e3, i2, r2, a2, d2) {
5413
5558
  return n(this, void 0, void 0, (function* () {
5414
5559
  try {
5415
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app(i2, r2), d), { method: "GET", headers: t2.header });
5560
+ const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app(i2, r2), d2), { method: "GET", headers: t2.header });
5416
5561
  if (n2.ok) {
5417
5562
  const e4 = yield n2.json();
5418
5563
  return a2.log(`Received questions for app ${i2}`, e4), e4;
@@ -5443,6 +5588,15 @@ var require_magicfeedback_sdk_browser = __commonJS({
5443
5588
  }
5444
5589
  }));
5445
5590
  };
5591
+ }, 1012: (e2, t2) => {
5592
+ "use strict";
5593
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.SubmitError = void 0;
5594
+ class i extends Error {
5595
+ constructor(e3, t3) {
5596
+ super(t3), this.code = e3, this.name = "SubmitError", Object.setPrototypeOf(this, i.prototype);
5597
+ }
5598
+ }
5599
+ t2.SubmitError = i;
5446
5600
  }, 3433: (e2, t2, i) => {
5447
5601
  "use strict";
5448
5602
  Object.defineProperty(t2, "__esModule", { value: true }), t2.toBaseAnswers = t2.shownValueFor = t2.baseValueMap = t2.withLangParam = t2.detectSurveyLang = t2.normalizeSurveyLang = void 0;
@@ -5621,7 +5775,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
5621
5775
  };
5622
5776
  }, 8330: (e2) => {
5623
5777
  "use strict";
5624
- e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.33","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","release":"npm publish --access public","release:beta":"npm publish --access public --tag beta","release:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"jest --coverage","publish:sdk":"bash publish.sh","publish:sdk:dry-run":"NPM_DRY_RUN=1 bash publish.sh"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","copy-webpack-plugin":"^11.0.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"},"style":"./dist/styles/magicfeedback-default.css"}');
5778
+ e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.37","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","release":"npm publish --access public","release:beta":"npm publish --access public --tag beta","release:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"jest --coverage","publish:sdk":"bash publish.sh","publish:sdk:dry-run":"NPM_DRY_RUN=1 bash publish.sh"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","copy-webpack-plugin":"^11.0.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"},"style":"./dist/styles/magicfeedback-default.css"}');
5625
5779
  } }, t = {}, (function i(n) {
5626
5780
  var r = t[n];
5627
5781
  if (void 0 !== r) return r.exports;
@@ -6338,14 +6492,15 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
6338
6492
  autofocusOnOpen();
6339
6493
  }
6340
6494
  };
6495
+ let lastReportedError = null;
6341
6496
  generateOptions.beforeSubmitEvent = () => {
6342
6497
  setLoading(true);
6343
6498
  };
6344
6499
  generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
6345
- const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
6346
- if (errText) {
6500
+ if (error) {
6347
6501
  setLoading(false);
6348
- if (errText.toLowerCase().includes("no response")) {
6502
+ const { reason, message } = classifySubmitError(error);
6503
+ if (reason === "required") {
6349
6504
  errorHint.textContent = labels.errorRequired;
6350
6505
  errorHint.style.display = "block";
6351
6506
  updateNavButtons();
@@ -6353,7 +6508,11 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
6353
6508
  }
6354
6509
  errorHint.textContent = labels.errorSubmit;
6355
6510
  errorHint.style.display = "block";
6356
- sdkWarn("[Deepdots] survey submit error:", errText);
6511
+ sdkWarn("[Deepdots] survey submit error:", reason, message);
6512
+ if (error !== lastReportedError) {
6513
+ lastReportedError = error;
6514
+ emit("survey_error", surveyId, { reason, message });
6515
+ }
6357
6516
  return;
6358
6517
  }
6359
6518
  errorHint.style.display = "none";
@@ -6397,6 +6556,7 @@ var init_renderPopup = __esm({
6397
6556
  init_logger();
6398
6557
  init_labels();
6399
6558
  init_reveal();
6559
+ init_submitError();
6400
6560
  import_native = __toESM(require_magicfeedback_sdk_browser());
6401
6561
  init_style();
6402
6562
  init_reveal();
@@ -6637,6 +6797,7 @@ init_labels();
6637
6797
  init_reveal();
6638
6798
  init_surveyPalette();
6639
6799
  init_busy();
6800
+ init_submitError();
6640
6801
  init_style();
6641
6802
  var REVEAL_JS = `
6642
6803
  function ddCreateReveal(popup, onReveal, timeoutMs){
@@ -6680,7 +6841,7 @@ function trimmedOrNull(value) {
6680
6841
  }
6681
6842
  function buildSurveyHtml(opts) {
6682
6843
  const env = opts.env === "development" ? "dev" : "prod";
6683
- const version = opts.version ?? "2.2.33";
6844
+ const version = opts.version ?? "2.2.37";
6684
6845
  const cdn = `https://cdn.jsdelivr.net/npm/@magicfeedback/native@${version}/dist/magicfeedback-sdk.browser.js`;
6685
6846
  const sid = jsonForScript(opts.surveyId);
6686
6847
  const pid = jsonForScript(opts.productId);
@@ -6852,6 +7013,7 @@ ${customCss}
6852
7013
  (function(){
6853
7014
  function emit(s){ try{ if(window.ReactNativeWebView){ window.ReactNativeWebView.postMessage(s); } }catch(e){} }
6854
7015
  function emitJSON(n,p){ try{ emit(JSON.stringify({name:n,payload:p||{}})); }catch(e){} }
7016
+ var ddLastReportedError=null;
6855
7017
  window.DeepdotsClose = function(){ emitJSON('popup_close'); };
6856
7018
  var chromeOn=${chrome ? "true" : "false"};
6857
7019
 
@@ -7032,6 +7194,7 @@ ${customCss}
7032
7194
 
7033
7195
  ${PRIMARY_COLOR_JS}
7034
7196
  ${BUSY_JS}
7197
+ ${SUBMIT_ERROR_JS}
7035
7198
  ${REVEAL_JS}
7036
7199
  // Foco en la primera pregunta si es de escribir. Al navegar lo pone @magicfeedback/native
7037
7200
  // (autofocus:'navigation'); la apertura la decide el popup, que es quien sabe cu\xE1ndo se revela.
@@ -7183,10 +7346,10 @@ ${REVEAL_JS}
7183
7346
  emitJSON('before_submit');
7184
7347
  },
7185
7348
  afterSubmitEvent:function(p){
7186
- var error=p && p.error ? (typeof p.error==='string' ? p.error : String(p.error)) : '';
7187
- if(error){
7349
+ if(p && p.error){
7188
7350
  setLoading(false);
7189
- if(error.toLowerCase().indexOf('no response')!==-1){
7351
+ var ddErr=ddClassifySubmitError(p.error);
7352
+ if(ddErr.reason==='required'){
7190
7353
  // La p\xE1gina no ha cambiado: el estado de navegaci\xF3n se queda como estaba.
7191
7354
  errorHint.textContent=DD_LABELS_ACTIVE.errorRequired;
7192
7355
  errorHint.style.display='block';
@@ -7195,6 +7358,11 @@ ${REVEAL_JS}
7195
7358
  }
7196
7359
  errorHint.textContent=DD_LABELS_ACTIVE.errorSubmit;
7197
7360
  errorHint.style.display='block';
7361
+ // Un solo aviso por fallo: native repite el mismo objeto al cerrar el survey.
7362
+ if(p.error!==ddLastReportedError){
7363
+ ddLastReportedError=p.error;
7364
+ emitJSON('survey_error', ddErr);
7365
+ }
7198
7366
  return;
7199
7367
  }
7200
7368
  errorHint.style.display='none';
@@ -7319,8 +7487,9 @@ var ReactNativePopupRenderer = class {
7319
7487
  const surveyId = this.currentSurveyId;
7320
7488
  if (!surveyId || !this.emitFn) return;
7321
7489
  let name;
7490
+ let payload;
7322
7491
  try {
7323
- name = JSON.parse(raw).name;
7492
+ ({ name, payload } = JSON.parse(raw));
7324
7493
  } catch {
7325
7494
  name = raw;
7326
7495
  }
@@ -7341,6 +7510,9 @@ var ReactNativePopupRenderer = class {
7341
7510
  case "survey_completed":
7342
7511
  this.emitFn("survey_completed", surveyId);
7343
7512
  break;
7513
+ case "survey_error":
7514
+ this.emitFn("survey_error", surveyId, { reason: payload?.reason, message: payload?.message });
7515
+ break;
7344
7516
  case "popup_close":
7345
7517
  this.onCloseFn?.();
7346
7518
  break;
@@ -9803,6 +9975,15 @@ var DeepdotsPopups = class {
9803
9975
  emitEvent(type, surveyId, data) {
9804
9976
  const event = { type, surveyId, timestamp: Date.now(), data };
9805
9977
  this.log("Event emitted", event);
9978
+ if (type === "survey_error") {
9979
+ const popupId = data?.popupId || this.surveyToPopupId.get(surveyId);
9980
+ this.track("deepdots_survey_error", {
9981
+ survey_id: surveyId,
9982
+ ...popupId ? { popup_id: popupId } : {},
9983
+ reason: data?.reason,
9984
+ message: data?.message
9985
+ });
9986
+ }
9806
9987
  const isPartialClick = type === "popup_clicked" && data?.action === "partial";
9807
9988
  if (isPartialClick) {
9808
9989
  this.markSurveyProgress(surveyId, "PARTIAL");