@magicfeedback/popup-sdk 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3330 +0,0 @@
1
- import {
2
- __commonJS,
3
- __toESM,
4
- buildFontFaceCss,
5
- buildFontFamilyValue,
6
- buildSurveyIdentity,
7
- sdkError,
8
- sdkLog,
9
- sdkWarn,
10
- style_default
11
- } from "./chunk-AN7JIVWB.mjs";
12
-
13
- // node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js
14
- var require_magicfeedback_sdk_browser = __commonJS({
15
- "node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js"(exports, module) {
16
- "use strict";
17
- !(function(e, t) {
18
- "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.magicfeedback = t() : e.magicfeedback = t();
19
- })(self, (() => {
20
- return e = { 326: function(e2, t2) {
21
- var i = "undefined" != typeof self ? self : this, n = (function() {
22
- function e3() {
23
- this.fetch = false, this.DOMException = i.DOMException;
24
- }
25
- return e3.prototype = i, new e3();
26
- })();
27
- !(function(e3) {
28
- !(function(t3) {
29
- var i2 = "URLSearchParams" in e3, n2 = "Symbol" in e3 && "iterator" in Symbol, r2 = "FileReader" in e3 && "Blob" in e3 && (function() {
30
- try {
31
- return new Blob(), true;
32
- } catch (e4) {
33
- return false;
34
- }
35
- })(), s = "FormData" in e3, o = "ArrayBuffer" in e3;
36
- if (o) var a = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], l = ArrayBuffer.isView || function(e4) {
37
- return e4 && a.indexOf(Object.prototype.toString.call(e4)) > -1;
38
- };
39
- function d(e4) {
40
- if ("string" != typeof e4 && (e4 = String(e4)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e4)) throw new TypeError("Invalid character in header field name");
41
- return e4.toLowerCase();
42
- }
43
- function c(e4) {
44
- return "string" != typeof e4 && (e4 = String(e4)), e4;
45
- }
46
- function u(e4) {
47
- var t4 = { next: function() {
48
- var t5 = e4.shift();
49
- return { done: void 0 === t5, value: t5 };
50
- } };
51
- return n2 && (t4[Symbol.iterator] = function() {
52
- return t4;
53
- }), t4;
54
- }
55
- function p(e4) {
56
- this.map = {}, e4 instanceof p ? e4.forEach((function(e5, t4) {
57
- this.append(t4, e5);
58
- }), this) : Array.isArray(e4) ? e4.forEach((function(e5) {
59
- this.append(e5[0], e5[1]);
60
- }), this) : e4 && Object.getOwnPropertyNames(e4).forEach((function(t4) {
61
- this.append(t4, e4[t4]);
62
- }), this);
63
- }
64
- function h(e4) {
65
- if (e4.bodyUsed) return Promise.reject(new TypeError("Already read"));
66
- e4.bodyUsed = true;
67
- }
68
- function m(e4) {
69
- return new Promise((function(t4, i3) {
70
- e4.onload = function() {
71
- t4(e4.result);
72
- }, e4.onerror = function() {
73
- i3(e4.error);
74
- };
75
- }));
76
- }
77
- function f(e4) {
78
- var t4 = new FileReader(), i3 = m(t4);
79
- return t4.readAsArrayBuffer(e4), i3;
80
- }
81
- function g(e4) {
82
- if (e4.slice) return e4.slice(0);
83
- var t4 = new Uint8Array(e4.byteLength);
84
- return t4.set(new Uint8Array(e4)), t4.buffer;
85
- }
86
- function v() {
87
- return this.bodyUsed = false, this._initBody = function(e4) {
88
- var t4;
89
- this._bodyInit = e4, e4 ? "string" == typeof e4 ? this._bodyText = e4 : r2 && Blob.prototype.isPrototypeOf(e4) ? this._bodyBlob = e4 : s && FormData.prototype.isPrototypeOf(e4) ? this._bodyFormData = e4 : i2 && URLSearchParams.prototype.isPrototypeOf(e4) ? this._bodyText = e4.toString() : o && r2 && (t4 = e4) && DataView.prototype.isPrototypeOf(t4) ? (this._bodyArrayBuffer = g(e4.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : o && (ArrayBuffer.prototype.isPrototypeOf(e4) || l(e4)) ? this._bodyArrayBuffer = g(e4) : this._bodyText = e4 = Object.prototype.toString.call(e4) : this._bodyText = "", this.headers.get("content-type") || ("string" == typeof e4 ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : i2 && URLSearchParams.prototype.isPrototypeOf(e4) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
90
- }, r2 && (this.blob = function() {
91
- var e4 = h(this);
92
- if (e4) return e4;
93
- if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
94
- if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
95
- if (this._bodyFormData) throw new Error("could not read FormData body as blob");
96
- return Promise.resolve(new Blob([this._bodyText]));
97
- }, this.arrayBuffer = function() {
98
- return this._bodyArrayBuffer ? h(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(f);
99
- }), this.text = function() {
100
- var e4, t4, i3, n3 = h(this);
101
- if (n3) return n3;
102
- if (this._bodyBlob) return e4 = this._bodyBlob, i3 = m(t4 = new FileReader()), t4.readAsText(e4), i3;
103
- if (this._bodyArrayBuffer) return Promise.resolve((function(e5) {
104
- for (var t5 = new Uint8Array(e5), i4 = new Array(t5.length), n4 = 0; n4 < t5.length; n4++) i4[n4] = String.fromCharCode(t5[n4]);
105
- return i4.join("");
106
- })(this._bodyArrayBuffer));
107
- if (this._bodyFormData) throw new Error("could not read FormData body as text");
108
- return Promise.resolve(this._bodyText);
109
- }, s && (this.formData = function() {
110
- return this.text().then(E);
111
- }), this.json = function() {
112
- return this.text().then(JSON.parse);
113
- }, this;
114
- }
115
- p.prototype.append = function(e4, t4) {
116
- e4 = d(e4), t4 = c(t4);
117
- var i3 = this.map[e4];
118
- this.map[e4] = i3 ? i3 + ", " + t4 : t4;
119
- }, p.prototype.delete = function(e4) {
120
- delete this.map[d(e4)];
121
- }, p.prototype.get = function(e4) {
122
- return e4 = d(e4), this.has(e4) ? this.map[e4] : null;
123
- }, p.prototype.has = function(e4) {
124
- return this.map.hasOwnProperty(d(e4));
125
- }, p.prototype.set = function(e4, t4) {
126
- this.map[d(e4)] = c(t4);
127
- }, p.prototype.forEach = function(e4, t4) {
128
- for (var i3 in this.map) this.map.hasOwnProperty(i3) && e4.call(t4, this.map[i3], i3, this);
129
- }, p.prototype.keys = function() {
130
- var e4 = [];
131
- return this.forEach((function(t4, i3) {
132
- e4.push(i3);
133
- })), u(e4);
134
- }, p.prototype.values = function() {
135
- var e4 = [];
136
- return this.forEach((function(t4) {
137
- e4.push(t4);
138
- })), u(e4);
139
- }, p.prototype.entries = function() {
140
- var e4 = [];
141
- return this.forEach((function(t4, i3) {
142
- e4.push([i3, t4]);
143
- })), u(e4);
144
- }, n2 && (p.prototype[Symbol.iterator] = p.prototype.entries);
145
- var y = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
146
- function b(e4, t4) {
147
- var i3, n3, r3 = (t4 = t4 || {}).body;
148
- if (e4 instanceof b) {
149
- if (e4.bodyUsed) throw new TypeError("Already read");
150
- this.url = e4.url, this.credentials = e4.credentials, t4.headers || (this.headers = new p(e4.headers)), this.method = e4.method, this.mode = e4.mode, this.signal = e4.signal, r3 || null == e4._bodyInit || (r3 = e4._bodyInit, e4.bodyUsed = true);
151
- } else this.url = String(e4);
152
- if (this.credentials = t4.credentials || this.credentials || "same-origin", !t4.headers && this.headers || (this.headers = new p(t4.headers)), this.method = (n3 = (i3 = t4.method || this.method || "GET").toUpperCase(), y.indexOf(n3) > -1 ? n3 : i3), this.mode = t4.mode || this.mode || null, this.signal = t4.signal || this.signal, this.referrer = null, ("GET" === this.method || "HEAD" === this.method) && r3) throw new TypeError("Body not allowed for GET or HEAD requests");
153
- this._initBody(r3);
154
- }
155
- function E(e4) {
156
- var t4 = new FormData();
157
- return e4.trim().split("&").forEach((function(e5) {
158
- if (e5) {
159
- var i3 = e5.split("="), n3 = i3.shift().replace(/\+/g, " "), r3 = i3.join("=").replace(/\+/g, " ");
160
- t4.append(decodeURIComponent(n3), decodeURIComponent(r3));
161
- }
162
- })), t4;
163
- }
164
- function A(e4, t4) {
165
- t4 || (t4 = {}), this.type = "default", this.status = void 0 === t4.status ? 200 : t4.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in t4 ? t4.statusText : "OK", this.headers = new p(t4.headers), this.url = t4.url || "", this._initBody(e4);
166
- }
167
- b.prototype.clone = function() {
168
- return new b(this, { body: this._bodyInit });
169
- }, v.call(b.prototype), v.call(A.prototype), A.prototype.clone = function() {
170
- return new A(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url });
171
- }, A.error = function() {
172
- var e4 = new A(null, { status: 0, statusText: "" });
173
- return e4.type = "error", e4;
174
- };
175
- var k = [301, 302, 303, 307, 308];
176
- A.redirect = function(e4, t4) {
177
- if (-1 === k.indexOf(t4)) throw new RangeError("Invalid status code");
178
- return new A(null, { status: t4, headers: { location: e4 } });
179
- }, t3.DOMException = e3.DOMException;
180
- try {
181
- new t3.DOMException();
182
- } catch (e4) {
183
- t3.DOMException = function(e5, t4) {
184
- this.message = e5, this.name = t4;
185
- var i3 = Error(e5);
186
- this.stack = i3.stack;
187
- }, t3.DOMException.prototype = Object.create(Error.prototype), t3.DOMException.prototype.constructor = t3.DOMException;
188
- }
189
- function C(e4, i3) {
190
- return new Promise((function(n3, s2) {
191
- var o2 = new b(e4, i3);
192
- if (o2.signal && o2.signal.aborted) return s2(new t3.DOMException("Aborted", "AbortError"));
193
- var a2 = new XMLHttpRequest();
194
- function l2() {
195
- a2.abort();
196
- }
197
- a2.onload = function() {
198
- var e5, t4, i4 = { status: a2.status, statusText: a2.statusText, headers: (e5 = a2.getAllResponseHeaders() || "", t4 = new p(), e5.replace(/\r?\n[\t ]+/g, " ").split(/\r?\n/).forEach((function(e6) {
199
- var i5 = e6.split(":"), n4 = i5.shift().trim();
200
- if (n4) {
201
- var r4 = i5.join(":").trim();
202
- t4.append(n4, r4);
203
- }
204
- })), t4) };
205
- i4.url = "responseURL" in a2 ? a2.responseURL : i4.headers.get("X-Request-URL");
206
- var r3 = "response" in a2 ? a2.response : a2.responseText;
207
- n3(new A(r3, i4));
208
- }, a2.onerror = function() {
209
- s2(new TypeError("Network request failed"));
210
- }, a2.ontimeout = function() {
211
- s2(new TypeError("Network request failed"));
212
- }, a2.onabort = function() {
213
- s2(new t3.DOMException("Aborted", "AbortError"));
214
- }, a2.open(o2.method, o2.url, true), "include" === o2.credentials ? a2.withCredentials = true : "omit" === o2.credentials && (a2.withCredentials = false), "responseType" in a2 && r2 && (a2.responseType = "blob"), o2.headers.forEach((function(e5, t4) {
215
- a2.setRequestHeader(t4, e5);
216
- })), o2.signal && (o2.signal.addEventListener("abort", l2), a2.onreadystatechange = function() {
217
- 4 === a2.readyState && o2.signal.removeEventListener("abort", l2);
218
- }), a2.send(void 0 === o2._bodyInit ? null : o2._bodyInit);
219
- }));
220
- }
221
- C.polyfill = true, e3.fetch || (e3.fetch = C, e3.Headers = p, e3.Request = b, e3.Response = A), t3.Headers = p, t3.Request = b, t3.Response = A, t3.fetch = C, Object.defineProperty(t3, "__esModule", { value: true });
222
- })({});
223
- })(n), n.fetch.ponyfill = true, delete n.fetch.polyfill;
224
- var r = n;
225
- (t2 = r.fetch).default = r.fetch, t2.fetch = r.fetch, t2.Headers = r.Headers, t2.Request = r.Request, t2.Response = r.Response, e2.exports = t2;
226
- }, 317: (e2, t2) => {
227
- "use strict";
228
- Object.defineProperty(t2, "__esModule", { value: true }), t2.HOST_API_URL_DEV = t2.HOST_API_URL = void 0, t2.HOST_API_URL = "https://api.deepdots.com/", t2.HOST_API_URL_DEV = "https://api-dev.deepdots.com/";
229
- }, 156: function(e2, t2, i) {
230
- "use strict";
231
- var n = this && this.__importDefault || function(e3) {
232
- return e3 && e3.__esModule ? e3 : { default: e3 };
233
- };
234
- Object.defineProperty(t2, "__esModule", { value: true });
235
- const r = n(i(927));
236
- let s = null;
237
- s || (s = (0, r.default)()), t2.default = s;
238
- }, 927: function(e2, t2, i) {
239
- "use strict";
240
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
241
- return new (i2 || (i2 = Promise))((function(r2, s2) {
242
- function o2(e4) {
243
- try {
244
- l2(n2.next(e4));
245
- } catch (e5) {
246
- s2(e5);
247
- }
248
- }
249
- function a2(e4) {
250
- try {
251
- l2(n2.throw(e4));
252
- } catch (e5) {
253
- s2(e5);
254
- }
255
- }
256
- function l2(e4) {
257
- var t4;
258
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
259
- e5(t4);
260
- }))).then(o2, a2);
261
- }
262
- l2((n2 = n2.apply(e3, t3 || [])).next());
263
- }));
264
- };
265
- Object.defineProperty(t2, "__esModule", { value: true });
266
- const r = i(57), s = i(544), o = i(665), a = i(256), l = i(313), d = i(317);
267
- t2.default = function() {
268
- const e3 = new o.Config();
269
- let t3 = new a.Log(e3);
270
- return { init: function(i2) {
271
- "boolean" == typeof (null == i2 ? void 0 : i2.debug) && e3.set("debug", i2.debug), "boolean" == typeof (null == i2 ? void 0 : i2.dryRun) && e3.set("dryRun", i2.dryRun), e3.set("url", (null == i2 ? void 0 : i2.env) && "dev" === (null == i2 ? void 0 : i2.env) ? d.HOST_API_URL_DEV : d.HOST_API_URL), e3.set("env", null == i2 ? void 0 : i2.env), t3.log("Initialized Magicfeedback", e3);
272
- }, send: function(i2, r2, s2, o2 = true, a2, d2) {
273
- return n(this, void 0, void 0, (function* () {
274
- i2 || t3.err("No appID provided"), r2 || t3.err("No publicKey provided"), s2 || t3.err("No feedback provided"), s2.answers || s2.profile || s2.metrics || s2.metadata || t3.err("No feedback data provided");
275
- const n2 = e3.get("url"), c = { integration: i2, publicKey: r2, privateKey: d2, completed: o2, id: a2, feedback: s2 };
276
- try {
277
- if (e3.get("dryRun")) return t3.log("Dry run enabled: skipping native feedback submit"), `dry-run-${Date.now()}`;
278
- const i3 = yield (0, l.sendFeedback)(n2, c, t3);
279
- return t3.log("sent native feedback"), i3;
280
- } catch (e4) {
281
- return t3.err("error native feedback", e4), false;
282
- }
283
- }));
284
- }, form: function(i2, n2, s2, o2) {
285
- return i2 || t3.err("No appID provided"), n2 || t3.err("No publicKey provided"), new r.Form(e3, i2, n2, s2, o2);
286
- }, agentForm: function(i2, n2, r2) {
287
- return i2 || t3.err("No integrationId provided"), n2 || t3.err("No publicKey provided"), new s.AgentForm(e3, i2, n2, r2);
288
- }, session: function(i2) {
289
- return i2 || t3.err("No sessionId provided"), new r.Form(e3, i2);
290
- }, previewPage: function(i2, s2, o2) {
291
- return n(this, void 0, void 0, (function* () {
292
- i2 || t3.err("No selector provided"), s2 && s2.page || t3.err("No page provided for preview");
293
- const n2 = (null == s2 ? void 0 : s2.appId) || `preview-${Date.now()}`, a2 = new r.Form(e3, n2);
294
- return yield a2.previewPage(i2, s2, o2), a2;
295
- }));
296
- } };
297
- };
298
- }, 79: (e2, t2) => {
299
- "use strict";
300
- Object.defineProperty(t2, "__esModule", { value: true }), t2.History = void 0, t2.History = class {
301
- constructor() {
302
- this.items = [];
303
- }
304
- enqueue(e3) {
305
- this.items.push(e3);
306
- }
307
- dequeue() {
308
- return this.items.shift();
309
- }
310
- rollback() {
311
- return this.items.pop();
312
- }
313
- front() {
314
- return this.items[0];
315
- }
316
- back() {
317
- return this.items[this.items.length - 1];
318
- }
319
- isEmpty() {
320
- return 0 === this.items.length;
321
- }
322
- size() {
323
- return this.items.length;
324
- }
325
- get(e3) {
326
- return this.items[e3];
327
- }
328
- };
329
- }, 544: function(e2, t2, i) {
330
- "use strict";
331
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
332
- return new (i2 || (i2 = Promise))((function(r2, s2) {
333
- function o2(e4) {
334
- try {
335
- l2(n2.next(e4));
336
- } catch (e5) {
337
- s2(e5);
338
- }
339
- }
340
- function a2(e4) {
341
- try {
342
- l2(n2.throw(e4));
343
- } catch (e5) {
344
- s2(e5);
345
- }
346
- }
347
- function l2(e4) {
348
- var t4;
349
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
350
- e5(t4);
351
- }))).then(o2, a2);
352
- }
353
- l2((n2 = n2.apply(e3, t3 || [])).next());
354
- }));
355
- };
356
- Object.defineProperty(t2, "__esModule", { value: true }), t2.AgentForm = void 0;
357
- const r = i(256), s = i(279), o = i(945), a = i(177), l = i(107), d = i(565), c = i(571), u = i(213);
358
- t2.AgentForm = class {
359
- constructor(e3, t3, i2, n2) {
360
- this.config = e3, this.log = new r.Log(e3), this.url = e3.get("url"), this.integrationId = t3, this.publicKey = i2, this.privateKey = n2, this.formOptionsConfig = { addButton: true, sendButtonText: "Send", backButtonText: "Back", nextButtonText: "Next", addSuccessScreen: true, questionFormat: "standard", answerDelimiter: a.DEFAULT_ANSWER_DELIMITER, resume: true, allowBack: false, emptyAnswerText: "" }, this.selector = "", this.language = "en", this.product = { customIcons: false }, this.sessionId = "", this.conversation = [], this.askedRefs = [], this.currentTurn = 1, this.maxTurns = 0, this.currentQuestion = null, this.questionHistory = [], this.busy = false, this.rateLimitTimer = null, this.progress = 0, this.total = 0, this.completed = false, this.timeToCompleted = 0;
361
- }
362
- generate(e3, t3 = {}) {
363
- var i2;
364
- return n(this, void 0, void 0, (function* () {
365
- this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3, t3.lang && (this.language = t3.lang), t3.primaryColor && (this.primaryColor = t3.primaryColor), this.config.get("dryRun") && this.log.log("dryRun has no effect in agent mode: the server drives the conversation");
366
- try {
367
- const e4 = false !== this.formOptionsConfig.resume ? this.restore() : null;
368
- if (e4) this.log.log(`Resuming agent session ${e4.sessionId} at turn ${e4.currentTurn}`), this.mountForm(), this.renderStep();
369
- else {
370
- const e5 = yield this.startWithRetry();
371
- this.sessionId = e5.sessionId, this.maxTurns = e5.maxTurns, this.currentTurn = null !== (i2 = e5.currentTurn) && void 0 !== i2 ? i2 : 1, this.total = Math.max(this.maxTurns - 1, 0);
372
- const t4 = (0, a.toAgentStep)(e5, this.adapterContext());
373
- if (this.mountForm(), "END" === t4.kind) return yield this.renderEnd(t4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, sessionId: this.sessionId, completed: true })));
374
- this.acceptQuestion(t4), this.renderStep(), this.persist();
375
- }
376
- this.timeToCompleted = Date.now(), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, sessionId: this.sessionId, formOptionsConfig: this.formOptionsConfig }));
377
- } catch (e4) {
378
- this.log.err(`Could not start the agent survey ${this.integrationId}:`, e4), this.renderFatal(e4), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
379
- }
380
- }));
381
- }
382
- next() {
383
- return n(this, void 0, void 0, (function* () {
384
- return this.runTurn();
385
- }));
386
- }
387
- answer() {
388
- const e3 = document.getElementById(this.formId());
389
- return e3 ? (0, l.scrapeInputs)(e3) : [];
390
- }
391
- getConversation() {
392
- return [...this.conversation];
393
- }
394
- getSessionId() {
395
- return this.sessionId;
396
- }
397
- reset() {
398
- this.sessionId = "", this.conversation = [], this.askedRefs = [], this.currentTurn = 1, this.maxTurns = 0, this.currentQuestion = null, this.questionHistory = [], this.busy = false, this.completed = false, this.progress = 0, this.clearRateLimitTimer(), this.clearPersisted();
399
- }
400
- runTurn() {
401
- var e3;
402
- return n(this, void 0, void 0, (function* () {
403
- if (this.busy || this.completed || !this.currentQuestion) return;
404
- this.busy = true, this.setSubmitDisabled(true), this.clearError();
405
- const t3 = this.currentQuestion;
406
- try {
407
- const i2 = document.getElementById(this.formId()), n2 = document.getElementById(this.questionsId());
408
- if (!i2) throw new Error("Agent form not found");
409
- yield (0, c.awaitUploadReady)(n2);
410
- const r2 = (0, l.scrapeInputs)(i2);
411
- let s2 = (0, a.encodeAnswer)(r2, t3, this.formOptionsConfig.answerDelimiter);
412
- if ("" === s2) {
413
- if (t3.require) return void this.showError(this.formOptionsConfig.requiredMessage || "Please answer before continuing.");
414
- s2 = this.formOptionsConfig.emptyAnswerText || "";
415
- }
416
- this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
417
- const d2 = { role: "user", content: s2, questionType: t3.type, questionRef: t3.ref }, u2 = this.currentTurn + 1, p = yield (0, o.nextAgentTurn)(this.url, { publicKey: this.publicKey, privateKey: this.privateKey, integrationId: this.integrationId, sessionId: this.sessionId, conversation: [...this.conversation], currentTurn: u2, lastAnswer: s2, lastQuestionRef: t3.ref, askedRefs: [...this.askedRefs] }, this.log);
418
- this.conversation.push(d2), this.currentTurn = null !== (e3 = p.currentTurn) && void 0 !== e3 ? e3 : u2, p.maxTurns && (this.maxTurns = p.maxTurns), this.total = Math.max(this.maxTurns - 1, 0);
419
- const h = (0, a.toAgentStep)(p, this.adapterContext());
420
- if ("END" === h.kind) return void (yield this.renderEnd(h));
421
- if (this.maxTurns > 0 && this.currentTurn > this.maxTurns + 1) return void (yield this.renderEnd({ kind: "END", reason: "MAX_TURNS", currentTurn: this.currentTurn, maxTurns: this.maxTurns }));
422
- this.acceptQuestion(h), this.renderStep(), this.persist(), this.formOptionsConfig.onAgentTurnEvent && (yield this.formOptionsConfig.onAgentTurnEvent({ turn: this.currentTurn, maxTurns: this.maxTurns, question: h.question, isFromBase: h.isFromBase, topic: h.topic, coverageGaps: h.coverageGaps, coverageSummary: h.coverageSummary, conversation: this.getConversation() })), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.sessionId, loading: false, progress: this.progress, total: this.total, completed: false, error: null }));
423
- } catch (e4) {
424
- yield this.handleTurnError(e4);
425
- } finally {
426
- this.completed || (this.busy = false, this.rateLimitTimer || this.setSubmitDisabled(false));
427
- }
428
- }));
429
- }
430
- handleTurnError(e3) {
431
- return n(this, void 0, void 0, (function* () {
432
- this.log.err(`An error occurred during the agent turn ${this.integrationId}:`, e3), e3 instanceof s.AgentApiError && "RATE_LIMITED" === e3.kind ? this.startRateLimitCountdown(e3.retryAfterMs || 6e4) : this.showError(this.errorMessageFor(e3)), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: false, error: e3 }));
433
- }));
434
- }
435
- acceptQuestion(e3) {
436
- const t3 = e3.question;
437
- e3.isFromBase && t3.ref && !this.askedRefs.includes(t3.ref) && this.askedRefs.push(t3.ref), this.conversation.push({ role: "agent", content: t3.title, questionType: t3.type, questionRef: t3.ref }), this.currentQuestion = t3, this.questionHistory.push(t3), this.progress = Math.max(this.currentTurn - 1, 0);
438
- }
439
- formId() {
440
- return "magicfeedback-agent-" + this.integrationId;
441
- }
442
- questionsId() {
443
- return "magicfeedback-agent-questions-" + this.integrationId;
444
- }
445
- mountForm() {
446
- const e3 = (0, d.generateContainer)(this.selector, this.integrationId);
447
- this.primaryColor && (0, d.applyPrimaryColor)(e3, this.primaryColor);
448
- const t3 = document.createElement("form");
449
- t3.classList.add("magicfeedback-form"), t3.classList.add("magicfeedback-agent-form"), t3.id = this.formId(), t3.addEventListener("submit", ((e4) => {
450
- e4.preventDefault(), this.runTurn();
451
- }));
452
- const i2 = document.createElement("div");
453
- i2.classList.add("magicfeedback-questions"), i2.id = this.questionsId(), t3.appendChild(i2), this.formOptionsConfig.addButton && t3.appendChild((0, u.renderActions)(this.formOptionsConfig.allowBack ? "MAGICSURVEY" : "MAGICFORM", (() => this.back()), this.formOptionsConfig.sendButtonText, this.formOptionsConfig.backButtonText, this.formOptionsConfig.nextButtonText)), e3.appendChild(t3);
454
- }
455
- renderStep() {
456
- const e3 = document.getElementById(this.questionsId());
457
- e3 && this.currentQuestion && (e3.innerHTML = "", (0, u.renderQuestions)([this.currentQuestion], this.formOptionsConfig.questionFormat, this.language, this.product, (() => this.runTurn())).forEach(((t3) => e3.appendChild(t3))));
458
- }
459
- renderEnd(e3) {
460
- return n(this, void 0, void 0, (function* () {
461
- this.completed = true, this.currentQuestion = null, this.busy = false, this.timeToCompleted = this.timeToCompleted ? Date.now() - this.timeToCompleted : 0, this.clearRateLimitTimer(), this.clearPersisted();
462
- const t3 = document.getElementById("magicfeedback-container-" + this.integrationId);
463
- if (t3 && false !== this.formOptionsConfig.addSuccessScreen) {
464
- t3.innerHTML = "";
465
- const i2 = "BLOCKED" === e3.reason ? this.formOptionsConfig.blockedMessage || "Thanks for your time \u2014 we'll end the conversation here." : this.formOptionsConfig.successMessage || "Thank you for your feedback!", n2 = (0, u.renderSuccess)(i2);
466
- n2.classList.add("magicfeedback-success-message"), n2.classList.add("magicfeedback-agent-end"), "BLOCKED" === e3.reason && n2.classList.add("magicfeedback-agent-end--blocked"), t3.appendChild(n2);
467
- }
468
- this.formOptionsConfig.onFinishEvent && (yield this.formOptionsConfig.onFinishEvent({ sessionId: this.sessionId, reason: e3.reason, turns: this.currentTurn, maxTurns: this.maxTurns, conversation: this.getConversation(), coverageSummary: e3.coverageSummary, timeToCompleted: this.timeToCompleted })), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.sessionId, loading: false, progress: this.progress, total: this.total, completed: true, error: null }));
469
- }));
470
- }
471
- back() {
472
- return n(this, void 0, void 0, (function* () {
473
- this.busy || this.completed || this.formOptionsConfig.allowBack && (this.questionHistory.length < 2 || (this.questionHistory.pop(), this.conversation.pop(), this.conversation.pop(), this.currentQuestion = this.questionHistory[this.questionHistory.length - 1], this.currentTurn = Math.max(this.currentTurn - 1, 1), this.progress = Math.max(this.currentTurn - 1, 0), this.clearError(), this.renderStep(), this.persist(), this.formOptionsConfig.onBackEvent && (yield this.formOptionsConfig.onBackEvent({ progress: this.progress, total: this.total }))));
474
- }));
475
- }
476
- renderFatal(e3) {
477
- try {
478
- (0, d.generateContainer)(this.selector, this.integrationId).appendChild((0, u.renderError)(this.errorMessageFor(e3)));
479
- } catch (e4) {
480
- }
481
- }
482
- errorMessageFor(e3) {
483
- if (!(e3 instanceof s.AgentApiError)) return "Something went wrong. Please try again.";
484
- switch (e3.kind) {
485
- case "AUTH":
486
- case "NOT_FOUND":
487
- case "BAD_CONFIG":
488
- return "This survey is not available right now.";
489
- case "AI_UNAVAILABLE":
490
- return "We couldn't start the survey. Please try again in a moment.";
491
- default:
492
- return "Something went wrong. Please try again.";
493
- }
494
- }
495
- adapterContext() {
496
- return { integrationId: this.integrationId, sessionId: this.sessionId, language: this.language, log: this.log };
497
- }
498
- startWithRetry() {
499
- return n(this, void 0, void 0, (function* () {
500
- const e3 = { publicKey: this.publicKey, privateKey: this.privateKey, integrationId: this.integrationId };
501
- try {
502
- return yield (0, o.startAgentSurvey)(this.url, e3, this.log);
503
- } catch (t3) {
504
- if (t3 instanceof s.AgentApiError && "AI_UNAVAILABLE" === t3.kind) return this.log.log("Retrying /start after a transient AI failure"), yield new Promise(((e4) => setTimeout(e4, 1500))), yield (0, o.startAgentSurvey)(this.url, e3, this.log);
505
- throw t3;
506
- }
507
- }));
508
- }
509
- setSubmitDisabled(e3) {
510
- const t3 = document.getElementById("magicfeedback-submit");
511
- t3 && (t3.disabled = e3);
512
- }
513
- clearError() {
514
- const e3 = document.getElementById(this.questionsId());
515
- null == e3 || e3.querySelectorAll(".magicfeedback-error").forEach(((e4) => e4.remove()));
516
- }
517
- showError(e3) {
518
- const t3 = document.getElementById(this.questionsId());
519
- t3 && (this.clearError(), t3.insertBefore((0, u.renderError)(e3), t3.firstChild));
520
- }
521
- startRateLimitCountdown(e3) {
522
- this.clearRateLimitTimer(), this.setSubmitDisabled(true);
523
- let t3 = Math.ceil(e3 / 1e3);
524
- const i2 = this.formOptionsConfig.rateLimitMessage || "Too many requests. Retrying in {seconds}s\u2026", n2 = () => {
525
- if (t3 <= 0) return this.clearRateLimitTimer(), this.clearError(), void this.setSubmitDisabled(false);
526
- this.showError(i2.replace("{seconds}", String(t3))), t3 -= 1;
527
- };
528
- n2(), this.rateLimitTimer = setInterval(n2, 1e3);
529
- }
530
- clearRateLimitTimer() {
531
- this.rateLimitTimer && (clearInterval(this.rateLimitTimer), this.rateLimitTimer = null);
532
- }
533
- storageKey() {
534
- return `magicfeedback-agent-${this.integrationId}`;
535
- }
536
- persist() {
537
- if (false !== this.formOptionsConfig.resume) try {
538
- const e3 = { sessionId: this.sessionId, conversation: this.conversation, currentTurn: this.currentTurn, maxTurns: this.maxTurns, askedRefs: this.askedRefs, questionHistory: this.questionHistory, savedAt: Date.now() };
539
- localStorage.setItem(this.storageKey(), JSON.stringify(e3));
540
- } catch (e3) {
541
- this.log.log("Could not persist the agent session", e3);
542
- }
543
- }
544
- restore() {
545
- var e3;
546
- try {
547
- const t3 = localStorage.getItem(this.storageKey());
548
- if (!t3) return null;
549
- const i2 = JSON.parse(t3);
550
- return (null == i2 ? void 0 : i2.sessionId) && (null === (e3 = i2.questionHistory) || void 0 === e3 ? void 0 : e3.length) ? Date.now() - (i2.savedAt || 0) > 18e5 ? (this.clearPersisted(), null) : (this.sessionId = i2.sessionId, this.conversation = i2.conversation || [], this.currentTurn = i2.currentTurn || 1, this.maxTurns = i2.maxTurns || 0, this.askedRefs = i2.askedRefs || [], this.questionHistory = i2.questionHistory, this.currentQuestion = this.questionHistory[this.questionHistory.length - 1], this.total = Math.max(this.maxTurns - 1, 0), this.progress = Math.max(this.currentTurn - 1, 0), i2) : null;
551
- } catch (e4) {
552
- return this.log.log("Could not restore the agent session", e4), null;
553
- }
554
- }
555
- clearPersisted() {
556
- try {
557
- localStorage.removeItem(this.storageKey());
558
- } catch (e3) {
559
- }
560
- }
561
- applyIntegrationContext(e3) {
562
- var t3, i2;
563
- (null === (t3 = null == e3 ? void 0 : e3.lang) || void 0 === t3 ? void 0 : t3.length) && (this.language = e3.lang[0]), (null == e3 ? void 0 : e3.product) && (this.product = e3.product), (null === (i2 = null == e3 ? void 0 : e3.style) || void 0 === i2 ? void 0 : i2.primaryColor) && (this.primaryColor = e3.style.primaryColor);
564
- }
565
- };
566
- }, 665: (e2, t2) => {
567
- "use strict";
568
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Config = void 0, t2.Config = class {
569
- constructor() {
570
- this.variables = {}, this.variables.env = "prod", this.variables.debug = false, this.variables.dryRun = false;
571
- }
572
- get(e3) {
573
- return this.variables[e3];
574
- }
575
- set(e3, t3) {
576
- this.variables[e3] = t3;
577
- }
578
- };
579
- }, 57: function(e2, t2, i) {
580
- "use strict";
581
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
582
- return new (i2 || (i2 = Promise))((function(r2, s2) {
583
- function o2(e4) {
584
- try {
585
- l2(n2.next(e4));
586
- } catch (e5) {
587
- s2(e5);
588
- }
589
- }
590
- function a2(e4) {
591
- try {
592
- l2(n2.throw(e4));
593
- } catch (e5) {
594
- s2(e5);
595
- }
596
- }
597
- function l2(e4) {
598
- var t4;
599
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
600
- e5(t4);
601
- }))).then(o2, a2);
602
- }
603
- l2((n2 = n2.apply(e3, t3 || [])).next());
604
- }));
605
- };
606
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
607
- const r = i(558), s = i(544), o = i(256), a = i(313), l = i(213), d = i(571), c = i(565), u = i(107), p = i(989), h = i(700), m = i(591), f = i(79), g = i(636);
608
- t2.Form = class {
609
- constructor(e3, t3, i2, n2, r2) {
610
- this.config = e3, this.log = new o.Log(e3), this.formOptionsConfig = { addButton: true, sendButtonText: "Send", backButtonText: "Back", nextButtonText: "Next", 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.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.timeToCompleted = 0;
611
- }
612
- generate(e3, t3) {
613
- var i2, r2, o2, l2, d2, c2, u2;
614
- return n(this, void 0, void 0, (function* () {
615
- try {
616
- this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3;
617
- let n2 = this.formData;
618
- if (void 0 !== this.formData && this.formData || (n2 = "" !== this.publicKey ? yield (0, a.getForm)(this.url, this.appId, this.publicKey, this.log) : yield (0, a.getSessionForm)(this.url, this.appId, this.log)), void 0 === n2 || !n2) throw new Error(`No data for app ${this.appId}`);
619
- if (null === (i2 = n2.error) || void 0 === i2 ? void 0 : i2.message) throw new Error(n2.error.message);
620
- if ("AGENT" === n2.mode) return this.agentForm = new s.AgentForm(this.config, this.appId, this.publicKey), this.agentForm.applyIntegrationContext(n2), void (yield this.agentForm.generate(e3, t3));
621
- if (n2.questions = (null === (r2 = n2.questions) || void 0 === r2 ? void 0 : r2.filter(((e4) => "ACTIVE" === e4.status))) || [], n2.pages = (null === (o2 = n2.pages) || void 0 === o2 ? void 0 : o2.filter(((e4) => "ACTIVE" === e4.status))) || [], null === (l2 = n2.pages) || void 0 === l2 || l2.forEach(((e4) => {
622
- var t4;
623
- return e4.integrationQuestions = null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.filter(((e5) => "ACTIVE" === e5.status));
624
- })), this.formData = n2, this.formData.savedAt || (this.formData.savedAt = /* @__PURE__ */ new Date(), localStorage.setItem(`magicfeedback-${this.appId}`, JSON.stringify(this.formData))), void 0 === this.formData.questions || !this.formData.questions) throw new Error(`No questions for app ${this.appId}`);
625
- this.formData.pages && 0 !== (null === (d2 = this.formData.pages) || void 0 === d2 ? void 0 : d2.length) || this.formatPages(), null === (c2 = this.formData.questions) || void 0 === c2 || c2.sort(((e4, t4) => e4.position - t4.position)), this.formData.pages = this.formData.pages.filter(((e4) => {
626
- var t4;
627
- return (null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.length) > 0;
628
- })), this.formOptionsConfig.getMetaData && this.getMetaData(), (null === (u2 = this.formData.style) || void 0 === u2 ? void 0 : u2.startMessage) ? yield this.generateWelcomeMessage(this.formData.style.startMessage) : this.startForm();
629
- } catch (e4) {
630
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 })));
631
- }
632
- }));
633
- }
634
- previewPage(e3, t3, i2 = {}) {
635
- var r2, s2, o2, a2, l2, d2, c2, u2, p2;
636
- return n(this, void 0, void 0, (function* () {
637
- try {
638
- if (!t3 || !t3.page) throw new Error("[MagicFeedback] No page provided for preview");
639
- if (!t3.page.integrationQuestions || 0 === t3.page.integrationQuestions.length) throw new Error("[MagicFeedback] No questions provided for preview");
640
- this.config.set("dryRun", true), this.formOptionsConfig = Object.assign(Object.assign(Object.assign({}, this.formOptionsConfig), { getMetaData: false }), i2), this.selector = e3;
641
- const n2 = (t3.page.integrationQuestions || []).filter(((e4) => !e4.status || "ACTIVE" === e4.status)).sort(((e4, t4) => e4.position - t4.position)), m2 = new h.Page(null !== (r2 = t3.page.id) && void 0 !== r2 ? r2 : "1", null !== (s2 = t3.page.position) && void 0 !== s2 ? s2 : 1, null !== (o2 = t3.appId) && void 0 !== o2 ? o2 : this.appId, n2, null !== (a2 = t3.page.integrationPageRoutes) && void 0 !== a2 ? a2 : []);
642
- this.formData = { id: null !== (l2 = t3.appId) && void 0 !== l2 ? l2 : this.appId, identity: null !== (d2 = t3.identity) && void 0 !== d2 ? d2 : "MAGICFORM", lang: [null !== (c2 = t3.lang) && void 0 !== c2 ? c2 : "en"], product: null !== (u2 = t3.product) && void 0 !== u2 ? u2 : { customIcons: false }, style: null !== (p2 = t3.style) && void 0 !== p2 ? p2 : {}, questions: n2, pages: [m2] }, yield this.generateForm();
643
- } catch (e4) {
644
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 })));
645
- }
646
- }));
647
- }
648
- formatPages() {
649
- var e3;
650
- if (this.formData) switch (this.formData.identity) {
651
- case "MAGICSURVEY":
652
- this.formData.pages = [], null === (e3 = this.formData.questions) || void 0 === e3 || e3.forEach(((e4) => {
653
- var t4, i2;
654
- const n2 = new m.PageRoute(e4.id, e4.ref, m.OperatorType.NOEQUAL, [], m.TransitionType.PAGE, (e4.position + 1).toString(), e4.position.toString()), r2 = new h.Page(e4.position.toString(), e4.position, this.appId, [e4], [n2]);
655
- null === (i2 = null === (t4 = this.formData) || void 0 === t4 ? void 0 : t4.pages) || void 0 === i2 || i2.push(r2);
656
- }));
657
- break;
658
- case "MAGICFORM":
659
- const t3 = new h.Page("1", 1, this.appId, this.formData.questions, []);
660
- this.formData.pages = [t3];
661
- }
662
- }
663
- generateContainer() {
664
- var e3, t3;
665
- const i2 = (0, c.generateContainer)(this.selector, this.appId), n2 = null === (t3 = null === (e3 = this.formData) || void 0 === e3 ? void 0 : e3.style) || void 0 === t3 ? void 0 : t3.primaryColor;
666
- return n2 && (0, c.applyPrimaryColor)(i2, n2), i2;
667
- }
668
- generateForm() {
669
- var e3, t3, i2, r2;
670
- return n(this, void 0, void 0, (function* () {
671
- try {
672
- if (!this.formData || !this.formData.pages || 0 === this.formData.pages.length) throw new Error("No form data");
673
- this.graph = new p.PageGraph(this.formData.pages.sort(((e4, t4) => e4.position - t4.position)));
674
- let n2 = this.generateContainer();
675
- const s2 = document.createElement("form");
676
- s2.classList.add("magicfeedback-form"), s2.id = "magicfeedback-" + this.appId, s2.addEventListener("submit", ((e4) => e4.preventDefault()));
677
- const o2 = document.createElement("div");
678
- o2.classList.add("magicfeedback-questions"), o2.id = "magicfeedback-questions-" + this.appId;
679
- const a2 = this.graph.getFirstPage();
680
- if (!a2) throw new Error("No page found");
681
- if (this.total = this.graph.findMaxDepth(), a2.elements = (0, l.renderQuestions)(a2.questions, this.formOptionsConfig.questionFormat, null === (e3 = this.formData) || void 0 === e3 ? void 0 : e3.lang[0], null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.product, (() => this.send())), null === (i2 = a2.elements) || void 0 === i2 || i2.forEach(((e4) => o2.appendChild(e4))), s2.appendChild(o2), this.history.enqueue(a2), n2.appendChild(s2), this.progress = this.total - this.graph.findMaxDepth(a2), this.formOptionsConfig.addButton) {
682
- const e4 = (0, l.renderActions)(null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.identity, (() => this.back()), this.formOptionsConfig.sendButtonText, this.formOptionsConfig.backButtonText, this.formOptionsConfig.nextButtonText);
683
- s2.appendChild(e4);
684
- }
685
- this.formOptionsConfig.addButton && s2.addEventListener("submit", ((e4) => {
686
- e4.preventDefault(), this.send();
687
- })), this.timeToCompleted = Date.now(), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, formData: this.formData, formOptionsConfig: this.formOptionsConfig }));
688
- } catch (e4) {
689
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
690
- }
691
- }));
692
- }
693
- startForm() {
694
- this.generateForm();
695
- }
696
- generateWelcomeMessage(e3) {
697
- return n(this, void 0, void 0, (function* () {
698
- try {
699
- const t3 = this.generateContainer(), i2 = (0, l.renderStartMessage)(e3, this.formOptionsConfig.addButton, this.formOptionsConfig.startButtonText, (() => this.startForm()));
700
- t3.appendChild(i2), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, formData: this.formData }));
701
- } catch (e4) {
702
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
703
- }
704
- }));
705
- }
706
- getMetaData() {
707
- this.formOptionsConfig.customMetaData && (this.feedback.metadata = [...this.feedback.metadata, ...this.formOptionsConfig.customMetaData]), this.feedback.metadata.push({ key: "navigator-url", value: [window.location.href] }), this.feedback.metadata.push({ key: "navigator-origin", value: [window.location.origin] }), this.feedback.metadata.push({ key: "navigator-pathname", value: [window.location.pathname] }), this.feedback.metadata.push({ key: "navigator-search", value: [window.location.search] });
708
- const e3 = new URLSearchParams(window.location.search);
709
- Array.from(new Set(e3.keys())).forEach(((t3) => {
710
- const i2 = e3.getAll(t3);
711
- i2.length > 0 && this.feedback.metadata.push({ key: `query-${t3}`, value: i2 });
712
- })), this.feedback.metadata.push({ key: "navigator-user", value: [navigator.userAgent] }), this.feedback.metadata.push({ key: "navigator-language", value: [navigator.language] }), this.feedback.metadata.push({ key: "navigator-platform", value: [navigator.platform] }), this.feedback.metadata.push({ key: "navigator-appVersion", value: [navigator.appVersion] }), this.feedback.metadata.push({ key: "navigator-appName", value: [navigator.appName] }), this.feedback.metadata.push({ key: "navigator-product", value: [navigator.product] }), this.feedback.metadata.push({ key: "screen-width", value: [window.screen.width.toString()] }), this.feedback.metadata.push({ key: "screen-height", value: [window.screen.height.toString()] }), this.appId && "" === this.publicKey && this.feedback.metadata.push({ key: "MAGICFEEDBACK_SESSION", value: [this.appId] });
713
- }
714
- send(e3, t3, i2, s2) {
715
- return n(this, void 0, void 0, (function* () {
716
- if (this.agentForm) return this.agentForm.next();
717
- const n2 = document.getElementById("magicfeedback-questions-" + this.appId);
718
- try {
719
- 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]), s2) {
720
- this.feedback.answers = [...this.feedback.answers, ...s2], this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
721
- const e4 = yield this.pushAnswers(false);
722
- if (!e4) throw new Error("No response");
723
- return this.id = e4, void (this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total })));
724
- }
725
- yield (0, d.awaitUploadReady)(n2), this.answer(), this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
726
- const o2 = this.history.back();
727
- if (!o2) throw new Error("No page found");
728
- for (const e4 of o2.questions.filter(((e5) => e5.require && ![r.FEEDBACKAPPANSWERTYPE.CONSENT, r.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
729
- const t4 = e4.assets, i3 = this.feedback.answers.filter(((t5) => t5.key.includes(e4.ref) && !t5.key.includes("extra-option")));
730
- 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");
731
- if (null == t4 ? void 0 : t4.minOptions) {
732
- let n3 = [];
733
- 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");
734
- }
735
- if (e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
736
- const i4 = this.feedback.answers.find(((t5) => t5.key === e4.ref));
737
- if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new Error("No response");
738
- const n3 = this.parseMatrixAnswerPre(i4), r2 = Array.isArray(null == t4 ? void 0 : t4.options) ? t4.options : [];
739
- if (r2.length > 0) {
740
- if (r2.find(((e5) => {
741
- const t5 = n3.find(((t6) => t6.key === e5));
742
- return !t5 || !Array.isArray(t5.value) || 0 === t5.value.length;
743
- }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
744
- } 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");
745
- }
746
- }
747
- const a2 = yield this.pushAnswers(false);
748
- if (!a2) throw new Error("No response");
749
- this.id = a2, yield this.processNextQuestion(n2);
750
- } catch (e4) {
751
- 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 }));
752
- }
753
- }));
754
- }
755
- answer() {
756
- const e3 = document.getElementById("magicfeedback-" + this.appId);
757
- if (!e3) return this.log.err(`Form "${e3}" not found.`), this.feedback.answers = [], [];
758
- const t3 = this.history.back();
759
- if (!t3) return this.feedback.answers = (0, u.scrapeInputs)(e3), this.feedback.answers;
760
- const i2 = [];
761
- let n2 = false;
762
- const s2 = e3.querySelectorAll(".magicfeedback-input"), o2 = {}, l2 = {}, c2 = {};
763
- if (s2.forEach(((e4) => {
764
- const s3 = e4, u2 = t3.questions.find(((e5) => {
765
- var t4;
766
- return null === (t4 = s3.name) || void 0 === t4 ? void 0 : t4.includes(e5.ref);
767
- })), p2 = s3.type, h2 = s3.classList[0], m2 = { key: s3.name, value: [] }, f2 = "magicfeedback-consent" === h2 ? s3.checked.toString() : s3.value;
768
- if (m2.key && "" !== m2.key) if (m2.key.startsWith("extra-option-")) "" !== f2 && (m2.value.push(f2), i2.push(m2));
769
- else switch (null == u2 ? void 0 : u2.type) {
770
- case r.FEEDBACKAPPANSWERTYPE.EMAIL:
771
- case r.FEEDBACKAPPANSWERTYPE.TEXT:
772
- case r.FEEDBACKAPPANSWERTYPE.LONGTEXT:
773
- case r.FEEDBACKAPPANSWERTYPE.NUMBER:
774
- case r.FEEDBACKAPPANSWERTYPE.DATE:
775
- case r.FEEDBACKAPPANSWERTYPE.CONTACT:
776
- case r.FEEDBACKAPPANSWERTYPE.PASSWORD:
777
- "" !== f2 && ("email" === p2 ? (0, a.validateEmail)(f2) ? (this.feedback.profile.push({ key: "email", value: [f2] }), m2.value.push(f2), i2.push(m2)) : (this.log.err("Invalid email"), n2 = true) : (m2.value.push(f2), i2.push(m2)));
778
- break;
779
- case r.FEEDBACKAPPANSWERTYPE.RADIO:
780
- s3.checked && (m2.value.push(f2), i2.push(m2));
781
- break;
782
- case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
783
- case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
784
- s3.checked && (l2[m2.key] || (l2[m2.key] = []), l2[m2.key].push(f2));
785
- break;
786
- case r.FEEDBACKAPPANSWERTYPE.BOOLEAN:
787
- s3.checked && (m2.value.push(f2), i2.push(m2));
788
- break;
789
- case r.FEEDBACKAPPANSWERTYPE.CONSENT:
790
- m2.value.push(s3.checked.toString()), i2.push(m2);
791
- break;
792
- case r.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
793
- case r.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
794
- case r.FEEDBACKAPPANSWERTYPE.RATING_STAR:
795
- s3.checked && (m2.value.push(f2), i2.push(m2));
796
- break;
797
- case r.FEEDBACKAPPANSWERTYPE.SELECT:
798
- "" !== f2 && (m2.value.push(f2), i2.push(m2));
799
- break;
800
- case r.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
801
- "number" === p2 && s3.id && (c2[m2.key] || (c2[m2.key] = []), "" !== f2 && c2[m2.key].push(`${s3.id}:${f2}%`));
802
- break;
803
- case r.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
804
- "hidden" === p2 && (o2[m2.key] || (o2[m2.key] = []), o2[m2.key].push(f2));
805
- break;
806
- case r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
807
- e4.checked && (m2.value.push(f2), i2.push(m2));
808
- break;
809
- case r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE:
810
- case r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE: {
811
- const e5 = (0, d.getUploadValues)(s3);
812
- e5.length && (m2.value.push(...e5), i2.push(m2));
813
- break;
814
- }
815
- }
816
- })), n2) return [];
817
- Object.entries(l2).forEach((([e4, t4]) => {
818
- t4 && 0 !== t4.length && i2.push({ key: e4, value: t4 });
819
- })), Object.entries(c2).forEach((([e4, t4]) => {
820
- t4 && 0 !== t4.length && i2.push({ key: e4, value: t4 });
821
- })), Object.entries(o2).forEach((([e4, t4]) => {
822
- if (!t4 || 0 === t4.length) return;
823
- const n3 = t4.slice().sort(((e5, t5) => Number(e5.split(".")[0]) - Number(t5.split(".")[0])));
824
- i2.push({ key: e4, value: n3 });
825
- }));
826
- try {
827
- t3.questions.filter(((e4) => e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX)).forEach(((e4) => {
828
- const t4 = e4.ref + "-", n3 = i2.filter(((e5) => e5.key.startsWith(t4)));
829
- if (0 === n3.length) return;
830
- const r2 = n3.map(((e5) => ({ key: e5.key.substring(t4.length), value: e5.value }))), s3 = { key: e4.ref, value: [JSON.stringify(r2)] };
831
- for (const e5 of n3) {
832
- const t5 = i2.findIndex(((t6) => t6.key === e5.key));
833
- -1 !== t5 && i2.splice(t5, 1);
834
- }
835
- const o3 = i2.findIndex(((t5) => t5.key === e4.ref));
836
- -1 !== o3 ? i2[o3] = s3 : i2.push(s3);
837
- }));
838
- } catch (e4) {
839
- this.log.err("Error agrupando MULTI_QUESTION_MATRIX", e4);
840
- }
841
- return this.feedback.answers = i2, t3.setAnswer(i2), i2;
842
- }
843
- finish() {
844
- return n(this, void 0, void 0, (function* () {
845
- if (this.completed = true, this.timeToCompleted = Date.now() - this.timeToCompleted, this.feedback.metadata.push({ key: "time-to-complete", value: [this.timeToCompleted.toString()] }), this.formOptionsConfig.addSuccessScreen) {
846
- const e3 = document.getElementById("magicfeedback-container-" + this.appId);
847
- e3.childNodes.length > 0 && e3.removeChild(e3.childNodes[0]);
848
- const t3 = (0, l.renderSuccess)(this.formOptionsConfig.successMessage || "Thank you for your feedback!");
849
- e3.appendChild(t3);
850
- }
851
- this.answer();
852
- try {
853
- const e3 = yield this.pushAnswers(true);
854
- 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}:");
855
- 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 }));
856
- } catch (e3) {
857
- 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 }));
858
- }
859
- }));
860
- }
861
- pushAnswers(e3 = false) {
862
- return n(this, void 0, void 0, (function* () {
863
- try {
864
- if (this.config.get("dryRun")) {
865
- const e4 = this.id || `dry-run-${this.appId}-${Date.now()}`;
866
- return this.log.log(`Dry run enabled: skipping feedback submit for form ${this.appId}`), e4;
867
- }
868
- const t3 = this.config.get("url"), i2 = { integration: this.appId, publicKey: this.publicKey, feedback: this.feedback, completed: e3 };
869
- return yield (0, a.sendFeedback)(t3, this.id ? Object.assign(Object.assign({}, i2), { sessionId: this.id }) : i2, this.log);
870
- } catch (e4) {
871
- return this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), "";
872
- }
873
- }));
874
- }
875
- callFollowUpQuestion(e3) {
876
- var t3;
877
- return n(this, void 0, void 0, (function* () {
878
- if (!(null == e3 ? void 0 : e3.followup)) return null;
879
- try {
880
- if (0 === this.feedback.answers.length) throw new Error("No answers provided");
881
- const i2 = this.config.get("url"), n2 = Object.assign(Object.assign(Object.assign({ answer: null === (t3 = this.feedback.answers.find(((t4) => t4.key === e3.ref))) || void 0 === t3 ? void 0 : t3.value[0] }, "" !== this.publicKey && { publicKey: this.publicKey }), "" === this.publicKey && { campaignSessionId: this.appId }), { sessionId: this.id, question: e3 });
882
- return yield (0, a.getFollowUpQuestion)(i2, n2, this.log);
883
- } catch (e4) {
884
- throw this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), e4;
885
- }
886
- }));
887
- }
888
- processNextQuestion(e3) {
889
- var t3, i2, r2;
890
- return n(this, void 0, void 0, (function* () {
891
- const n2 = this.history.back();
892
- if (!n2) throw new Error("No page found");
893
- const s2 = n2.getFollowupQuestions();
894
- if (0 === (null == s2 ? void 0 : s2.length)) return void (yield this.renderNextQuestion(e3, n2));
895
- const o2 = [];
896
- for (const e4 of s2) {
897
- const t4 = n2.questions.find(((t5) => t5.ref === e4));
898
- if (t4) {
899
- const e5 = yield this.callFollowUpQuestion(t4);
900
- e5 && o2.push(e5);
901
- }
902
- }
903
- if (0 === o2.length) return void (yield this.renderNextQuestion(e3, n2));
904
- const a2 = new h.Page(n2.id, n2.position, this.appId, o2, n2.edges), d2 = new g.PageNode(n2.id, n2.position, n2.edges, a2, o2, true);
905
- d2.elements = (0, l.renderQuestions)(o2, this.formOptionsConfig.questionFormat, null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.lang[0], null === (i2 = this.formData) || void 0 === i2 ? void 0 : i2.product, (() => this.send())), this.history.enqueue(d2), this.progress += 0.5, e3.innerHTML = "", null === (r2 = d2.elements) || void 0 === r2 || r2.forEach(((t4) => e3.appendChild(t4))), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: d2.isFollowup, completed: this.completed, error: null }));
906
- }));
907
- }
908
- renderNextQuestion(e3, t3) {
909
- var i2, s2, o2, a2, d2;
910
- return n(this, void 0, void 0, (function* () {
911
- let n2 = this.graph.getNextPage(t3, this.feedback.answers);
912
- if (!n2) return void this.finish();
913
- const c2 = n2.edges.filter(((e4) => "PRECONDITIONAL" === e4.typeCondition)).sort(((e4, t4) => e4.position < t4.position ? -1 : e4.position > t4.position ? 1 : 0));
914
- if ((null == c2 ? void 0 : c2.length) > 0) {
915
- const t4 = c2.some(((e4) => e4.transition === m.TransitionType.ALLOW));
916
- let o3 = t4;
917
- for (const t5 of c2) {
918
- let a3;
919
- for (let e4 = this.history.size() - 1; e4 >= 0; e4--) {
920
- const n3 = this.history.get(e4);
921
- if (n3 && (a3 = null === (i2 = n3.answers) || void 0 === i2 ? void 0 : i2.find(((e5) => e5.key === t5.questionRef)), a3)) break;
922
- }
923
- let l2 = false;
924
- if (a3) {
925
- const e4 = null === (s2 = this.formData) || void 0 === s2 ? void 0 : s2.questions.find(((e5) => e5.ref === t5.questionRef)), i3 = Array.isArray(a3.value) ? a3.value : [a3.value], n3 = Array.isArray(t5.value) ? t5.value : [t5.value];
926
- if ((null == e4 ? void 0 : e4.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) l2 = this.evaluateMatrixPreconditional(t5, a3);
927
- else switch (t5.typeOperator) {
928
- case "EQUAL":
929
- case "INQ":
930
- l2 = i3.some(((e5) => n3.includes(e5)));
931
- break;
932
- case "NOEQUAL":
933
- case "NINQ":
934
- l2 = i3.every(((e5) => !n3.includes(e5)));
935
- break;
936
- case "GREATER":
937
- l2 = i3.some(((e5) => Number(e5) > Number(n3[0])));
938
- break;
939
- case "LESS":
940
- l2 = i3.some(((e5) => Number(e5) < Number(n3[0])));
941
- break;
942
- case "GREATEREQUAL":
943
- l2 = i3.some(((e5) => Number(e5) >= Number(n3[0])));
944
- break;
945
- case "LESSEQUAL":
946
- l2 = i3.some(((e5) => Number(e5) <= Number(n3[0])));
947
- }
948
- }
949
- if (t5.transition === m.TransitionType.ALLOW) l2 || (o3 = false);
950
- else if (t5.transition === m.TransitionType.NEXT && l2) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
951
- }
952
- if (t4 && !o3) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
953
- }
954
- n2.elements = (0, l.renderQuestions)(n2.questions, this.formOptionsConfig.questionFormat, null === (o2 = this.formData) || void 0 === o2 ? void 0 : o2.lang[0], null === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.product, (() => this.send())), e3.innerHTML = "", null === (d2 = n2.elements) || void 0 === d2 || d2.forEach(((t4) => e3.appendChild(t4))), this.history.enqueue(n2), this.progress = this.total - this.graph.findMaxDepth(n2), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: n2.isFollowup, completed: this.completed, error: null }));
955
- }));
956
- }
957
- back() {
958
- var e3;
959
- return n(this, void 0, void 0, (function* () {
960
- if (0 === this.history.size()) return;
961
- const t3 = document.getElementById("magicfeedback-questions-" + this.appId);
962
- t3 && t3.childNodes.length > 0 && (t3.innerHTML = ""), this.history.rollback();
963
- const i2 = this.history.back();
964
- i2 ? (null === (e3 = i2.elements) || void 0 === e3 || e3.forEach(((e4) => t3.appendChild(e4))), this.progress = this.total - this.graph.findMaxDepth(i2)) : this.progress = this.history.size(), this.formOptionsConfig.onBackEvent && (yield this.formOptionsConfig.onBackEvent({ loading: false, progress: this.progress, followup: (null == i2 ? void 0 : i2.isFollowup) || false, error: i2 ? null : "No page found" }));
965
- }));
966
- }
967
- previewQuestion(e3, t3, i2) {
968
- var n2, r2, s2;
969
- const o2 = Array.isArray(t3) ? t3 : [t3];
970
- if (!o2 || 0 === o2.length) throw new Error("[MagicFeedback] No question provided for preview");
971
- const a2 = document.getElementById(e3);
972
- if (!a2) throw new Error(`[MagicFeedback] Element with ID '${e3}' not found.`);
973
- const { format: d2 = this.formOptionsConfig.questionFormat || "standard", language: u2 = (null === (n2 = this.formData) || void 0 === n2 ? void 0 : n2.lang) && this.formData.lang[0] || "en", product: p2 = (null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.product) || { customIcons: false }, style: h2 = (null === (s2 = this.formData) || void 0 === s2 ? void 0 : s2.style) || {}, clearContainer: m2 = true, wrap: f2 = true } = i2 || {};
974
- m2 && (a2.innerHTML = ""), (null == h2 ? void 0 : h2.primaryColor) && (0, c.applyPrimaryColor)(a2, h2.primaryColor);
975
- let g2 = [];
976
- try {
977
- g2 = (0, l.renderQuestions)(o2, d2, u2, p2);
978
- } catch (e4) {
979
- throw this.log.err(e4), e4;
980
- }
981
- let v = a2;
982
- if (f2) {
983
- const e4 = document.createElement("div");
984
- e4.classList.add("magicfeedback-preview-question"), v.appendChild(e4), v = e4;
985
- }
986
- return g2.forEach(((e4) => v.appendChild(e4))), a2;
987
- }
988
- parseMatrixAnswerPre(e3) {
989
- if (!e3 || !e3.value) return [];
990
- if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
991
- const t3 = JSON.parse(e3.value[0]);
992
- if (Array.isArray(t3)) return t3;
993
- } catch (e4) {
994
- return [];
995
- }
996
- return Array.isArray(e3.value) && e3.value.length > 0 && "object" == typeof e3.value[0] && null !== e3.value[0] && "key" in e3.value[0] ? e3.value : [];
997
- }
998
- evaluateMatrixPreconditional(e3, t3) {
999
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = this.parseMatrixAnswerPre(t3);
1000
- if (!r2.length) return false;
1001
- const s2 = n2.size > 0 ? r2.filter(((e4) => n2.has(e4.key))) : r2;
1002
- if (!s2.length) return false;
1003
- switch (e3.typeOperator) {
1004
- case "EQUAL":
1005
- case "INQ":
1006
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
1007
- case "NOEQUAL":
1008
- case "NINQ":
1009
- return s2.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
1010
- case "GREATER":
1011
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
1012
- case "LESS":
1013
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
1014
- case "GREATEREQUAL":
1015
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
1016
- case "LESSEQUAL":
1017
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
1018
- default:
1019
- return false;
1020
- }
1021
- }
1022
- };
1023
- }, 700: (e2, t2) => {
1024
- "use strict";
1025
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Page = void 0, t2.Page = class {
1026
- constructor(e3, t3, i, n, r) {
1027
- this.id = e3, this.position = t3, this.generatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.status = "ACTIVE", this.integrationId = i, this.integrationQuestions = n, this.integrationPageRoutes = r;
1028
- }
1029
- };
1030
- }, 989: (e2, t2, i) => {
1031
- "use strict";
1032
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageGraph = void 0;
1033
- const n = i(636), r = i(558), s = i(591);
1034
- t2.PageGraph = class {
1035
- constructor(e3) {
1036
- this.nodes = /* @__PURE__ */ new Map(), this.buildGraph(e3);
1037
- }
1038
- buildGraph(e3) {
1039
- e3.forEach(((e4) => {
1040
- var t3;
1041
- e4.integrationPageRoutes && (e4.integrationPageRoutes = (null === (t3 = e4.integrationPageRoutes) || void 0 === t3 ? void 0 : t3.sort(((e5, t4) => {
1042
- const i3 = new Date((null == e5 ? void 0 : e5.generatedAt) || 0).getTime(), n2 = new Date((null == t4 ? void 0 : t4.generatedAt) || 0).getTime();
1043
- return i3 !== n2 ? i3 - n2 : "DIRECT" === e5.typeCondition && "DIRECT" !== t4.typeCondition ? 1 : "DIRECT" !== e5.typeCondition && "DIRECT" === t4.typeCondition ? -1 : 0;
1044
- }))) || []);
1045
- const i2 = new n.PageNode(e4.id, e4.position, e4.integrationPageRoutes || [], e4, e4.integrationQuestions);
1046
- this.nodes.set(i2.id, i2);
1047
- }));
1048
- }
1049
- getNodeById(e3) {
1050
- return this.nodes.get(e3);
1051
- }
1052
- getNextEdgeByDefault(e3) {
1053
- if (!e3) return;
1054
- const t3 = e3.edges.find(((e4) => e4.typeCondition === s.ConditionType.DIRECT));
1055
- if (!t3 || ![s.TransitionType.FINISH, s.TransitionType.REDIRECT].includes(t3.transition)) {
1056
- if (t3 && t3.transitionDestiny) return t3.transitionDestiny;
1057
- for (const t4 of this.nodes.values()) if (t4.position === e3.position + 1) return t4.id;
1058
- }
1059
- }
1060
- getFirstPage() {
1061
- let e3, t3 = Number.MAX_VALUE;
1062
- for (const i2 of this.nodes.values()) i2.position < t3 && (t3 = i2.position, e3 = i2);
1063
- return e3;
1064
- }
1065
- getNextPage(e3, t3) {
1066
- var i2;
1067
- if (!e3) return;
1068
- e3.edges.sort(((e4, t4) => "DIRECT" === e4.typeCondition ? 1 : "DIRECT" === t4.typeCondition ? -1 : 0));
1069
- const n2 = e3.edges.find(((i3) => {
1070
- const n3 = e3.questions.find(((e4) => e4.ref === i3.questionRef)), o = null == t3 ? void 0 : t3.filter(((e4) => e4.key === i3.questionRef));
1071
- if ("DIRECT" === i3.typeCondition) return true;
1072
- if (!o || 0 === o.length) return false;
1073
- if ((null == n3 ? void 0 : n3.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) return this.evaluateMatrixCondition(i3, o);
1074
- const a = Array.isArray(i3.value) ? i3.value : [i3.value];
1075
- switch (i3.typeOperator) {
1076
- case s.OperatorType.EQUAL:
1077
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => a.includes(e5)))));
1078
- case s.OperatorType.NOEQUAL:
1079
- return o.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !a.includes(e5)))));
1080
- case s.OperatorType.GREATER:
1081
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => a.some(((t4) => Number(e5) > Number(t4)))))));
1082
- case s.OperatorType.LESS:
1083
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => a.some(((t4) => Number(e5) < Number(t4)))))));
1084
- case s.OperatorType.GREATEREQUAL:
1085
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => a.some(((t4) => Number(e5) >= Number(t4)))))));
1086
- case s.OperatorType.LESSEQUAL:
1087
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => a.some(((t4) => Number(e5) <= Number(t4)))))));
1088
- case s.OperatorType.INQ:
1089
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => a.includes(e5)))));
1090
- case s.OperatorType.NINQ:
1091
- return o.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !a.includes(e5)))));
1092
- default:
1093
- return false;
1094
- }
1095
- }));
1096
- if (!n2) {
1097
- const t4 = this.getNextEdgeByDefault(e3);
1098
- if (!t4) return;
1099
- return this.getNodeById(t4);
1100
- }
1101
- switch (n2.transition) {
1102
- case s.TransitionType.PAGE:
1103
- if (!n2.transitionDestiny) return;
1104
- return this.getNodeById(n2.transitionDestiny);
1105
- case s.TransitionType.FINISH:
1106
- return;
1107
- case s.TransitionType.REDIRECT:
1108
- return void (window.location.href = (null === (i2 = n2.transitionDestiny) || void 0 === i2 ? void 0 : i2.includes("?")) ? `${n2.transitionDestiny}&${window.location.search.slice(1)}` : `${n2.transitionDestiny}${window.location.search}`);
1109
- default:
1110
- return;
1111
- }
1112
- }
1113
- findDepth(e3) {
1114
- const t3 = this.getNodeById(e3);
1115
- if (!t3) return 0;
1116
- const i2 = /* @__PURE__ */ new Set();
1117
- return this.DFSUtil(t3, i2, 0);
1118
- }
1119
- findMaxDepth(e3) {
1120
- if (e3 || (e3 = this.getFirstPage()), !e3) return 0;
1121
- const t3 = /* @__PURE__ */ new Set();
1122
- let i2 = 1;
1123
- return i2 = Math.max(i2, this.DFSUtil(e3, t3, i2)), i2;
1124
- }
1125
- DFSUtil(e3, t3, i2) {
1126
- t3.add(e3);
1127
- let n2 = i2;
1128
- const r2 = [...e3.edges.filter(((e4) => e4.typeCondition !== s.ConditionType.PRECONDITIONAL)) || []], o = this.getNextEdgeByDefault(e3);
1129
- if (o) {
1130
- const i3 = this.getNodeById(o);
1131
- i3 && !t3.has(i3) && r2.push(new s.PageRoute(i3.id, "", s.OperatorType.DEFAULT, [""], s.TransitionType.PAGE, i3.id, e3.id));
1132
- }
1133
- for (const e4 of r2) {
1134
- if (!e4.transitionDestiny) continue;
1135
- const r3 = this.getNodeById(e4.transitionDestiny);
1136
- if (r3 && !t3.has(r3)) {
1137
- const e5 = i2 + 1, s2 = new Set(t3), o2 = this.DFSUtil(r3, s2, e5);
1138
- n2 = Math.max(n2, o2);
1139
- }
1140
- }
1141
- return n2;
1142
- }
1143
- parseMatrixAnswer(e3) {
1144
- if (!e3 || !e3.value) return [];
1145
- if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
1146
- const t3 = JSON.parse(e3.value[0]);
1147
- if (Array.isArray(t3)) return t3;
1148
- } catch (e4) {
1149
- return [];
1150
- }
1151
- return Array.isArray(e3.value) && e3.value.length > 0 && "object" == typeof e3.value[0] && null !== e3.value[0] && "key" in e3.value[0] ? e3.value : [];
1152
- }
1153
- evaluateMatrixCondition(e3, t3) {
1154
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = t3[0], o = this.parseMatrixAnswer(r2);
1155
- if (!o.length) return false;
1156
- const a = n2.size > 0 ? o.filter(((e4) => n2.has(e4.key))) : o;
1157
- if (!a.length) return false;
1158
- switch (e3.typeOperator) {
1159
- case s.OperatorType.EQUAL:
1160
- case s.OperatorType.INQ:
1161
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
1162
- case s.OperatorType.NOEQUAL:
1163
- case s.OperatorType.NINQ:
1164
- return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
1165
- case s.OperatorType.GREATER:
1166
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
1167
- case s.OperatorType.LESS:
1168
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
1169
- case s.OperatorType.GREATEREQUAL:
1170
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
1171
- case s.OperatorType.LESSEQUAL:
1172
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
1173
- default:
1174
- return false;
1175
- }
1176
- }
1177
- };
1178
- }, 636: (e2, t2) => {
1179
- "use strict";
1180
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageNode = void 0, t2.PageNode = class {
1181
- constructor(e3, t3, i, n, r, s = false) {
1182
- this.answers = [], this.id = e3, this.position = t3, this.edges = i, this.data = n, this.questions = r.sort(((e4, t4) => e4.position - t4.position)), this.elements = [], this.isFollowup = s;
1183
- }
1184
- getFollowupQuestions() {
1185
- return this.questions.filter(((e3) => e3.followup)).map(((e3) => e3.ref));
1186
- }
1187
- getRequiredQuestions() {
1188
- return this.questions.filter(((e3) => e3.require)).map(((e3) => e3.ref));
1189
- }
1190
- setAnswer(e3) {
1191
- this.answers = e3;
1192
- }
1193
- };
1194
- }, 591: (e2, t2) => {
1195
- "use strict";
1196
- var i, n, r, s;
1197
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageRoute = t2.StatusType = t2.OperatorType = t2.ConditionType = t2.TransitionType = void 0, (s = t2.TransitionType || (t2.TransitionType = {})).PAGE = "PAGE", s.FINISH = "FINISH", s.REDIRECT = "REDIRECT", s.NEXT = "NEXT", s.ALLOW = "ALLOW", (function(e3) {
1198
- e3.LOGICAL = "LOGICAL", e3.DIRECT = "DIRECT", e3.PRECONDITIONAL = "PRECONDITIONAL";
1199
- })(i = t2.ConditionType || (t2.ConditionType = {})), (r = t2.OperatorType || (t2.OperatorType = {})).EQUAL = "EQUAL", r.NOEQUAL = "NOEQUAL", r.GREATER = "GREATER", r.LESS = "LESS", r.GREATEREQUAL = "GREATEREQUAL", r.LESSEQUAL = "LESSEQUAL", r.INQ = "INQ", r.NINQ = "NINQ", r.DEFAULT = "DEFAULT", (function(e3) {
1200
- e3.ACTIVE = "ACTIVE", e3.DEPRECATED = "DEPRECATED", e3.DELETE = "DELETE";
1201
- })(n = t2.StatusType || (t2.StatusType = {})), t2.PageRoute = class {
1202
- constructor(e3, t3, r2, s2, o, a, l, d, c, u) {
1203
- this.id = e3, this.questionRef = t3, this.typeCondition = d || i.LOGICAL, this.typeOperator = r2, this.value = s2 || [], this.transition = o, this.transitionDestiny = a, this.status = n.ACTIVE, this.generatedAt = /* @__PURE__ */ new Date(), this.updatedAt = /* @__PURE__ */ new Date(), this.integrationPageId = l, this.position = c || 0, this.option = u || [];
1204
- }
1205
- };
1206
- }, 558: (e2, t2) => {
1207
- "use strict";
1208
- var i, n;
1209
- Object.defineProperty(t2, "__esModule", { value: true }), t2.AGENT_ANSWER_TYPE_BLOCKED = t2.QuestionType = t2.FEEDBACKAPPANSWERTYPE = void 0, (n = t2.FEEDBACKAPPANSWERTYPE || (t2.FEEDBACKAPPANSWERTYPE = {})).CONTACT = "CONTACT", n.MULTIPLECHOISE_IMAGE = "MULTIPLECHOISE_IMAGE", n.EMAIL = "EMAIL", n.RATING_STAR = "RATING_STAR", n.RADIO = "RADIO", n.MULTIPLECHOICE = "MULTIPLECHOICE", n.SELECT = "SELECT", n.TEXT = "TEXT", n.LONGTEXT = "LONGTEXT", n.NUMBER = "NUMBER", n.RATING_EMOJI = "RATING_EMOJI", n.RATING_NUMBER = "RATING_NUMBER", n.DATE = "DATE", n.BOOLEAN = "BOOLEAN", n.PASSWORD = "PASSWORD", n.CONSENT = "CONSENT", n.MULTI_QUESTION_MATRIX = "MULTI_QUESTION_MATRIX", n.POINT_SYSTEM = "POINT_SYSTEM", n.PRIORITY_LIST = "PRIORITY_LIST", n.INFO_PAGE = "INFO_PAGE", n.UPLOAD_FILE = "UPLOAD_FILE", n.UPLOAD_IMAGE = "UPLOAD_IMAGE", t2.QuestionType = class {
1210
- }, t2.AGENT_ANSWER_TYPE_BLOCKED = "ABUSIVE_OR_OFFENSIVE", (function(e3) {
1211
- e3.FORM = "form", e3.DIV = "div";
1212
- })(i || (i = {}));
1213
- }, 565: (e2, t2) => {
1214
- "use strict";
1215
- Object.defineProperty(t2, "__esModule", { value: true }), t2.applyPrimaryColor = t2.generateContainer = void 0, t2.generateContainer = function(e3, t3) {
1216
- let i = document.getElementById(e3);
1217
- if (!i && (i = document.getElementById("magicfeedback-container-" + t3), !i)) throw new Error(`Element with ID '${e3}' not found.`);
1218
- return i.classList.add("magicfeedback-container"), i.id = "magicfeedback-container-" + t3, i.innerHTML = "", i;
1219
- }, t2.applyPrimaryColor = function(e3, t3) {
1220
- e3.style.setProperty("--mf-primary", t3), e3.style.setProperty("--mf-primary-hover", `color-mix(in srgb, ${t3} 85%, black)`), e3.style.setProperty("--mf-primary-light", `color-mix(in srgb, ${t3} 15%, white)`), e3.style.setProperty("--mf-primary-border", `color-mix(in srgb, ${t3} 35%, transparent)`), e3.style.setProperty("--mf-border-focus", t3);
1221
- };
1222
- }, 516: (e2, t2) => {
1223
- "use strict";
1224
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getUrlParam = t2.getBooleanOptions = t2.parseTitle = void 0, t2.parseTitle = function(e3, t3) {
1225
- return e3 ? "object" == typeof e3 ? e3[t3] || e3.en : e3 : "";
1226
- }, t2.getBooleanOptions = function(e3) {
1227
- switch (e3) {
1228
- case "es":
1229
- return ["S\xED", "No"];
1230
- case "fr":
1231
- return ["Oui", "Non"];
1232
- case "de":
1233
- return ["Ja", "Nein"];
1234
- case "it":
1235
- return ["S\xEC", "No"];
1236
- case "pt":
1237
- return ["Sim", "N\xE3o"];
1238
- case "nl":
1239
- return ["Ja", "Nee"];
1240
- case "pl":
1241
- return ["Tak", "Nie"];
1242
- case "ru":
1243
- return ["\u0414\u0430", "\u041D\u0435\u0442"];
1244
- case "ja":
1245
- return ["\u306F\u3044", "\u3044\u3044\u3048"];
1246
- case "zh":
1247
- return ["\u662F", "\u4E0D"];
1248
- case "ko":
1249
- return ["\uC608", "\uC544\uB2C8"];
1250
- case "da":
1251
- case "sv":
1252
- return ["Ja", "Nej"];
1253
- case "fi":
1254
- return ["Kyll\xE4", "Ei"];
1255
- case "no":
1256
- return ["Ja", "Nei"];
1257
- case "ar":
1258
- return ["\u0646\u0639\u0645", "\u0644\u0627"];
1259
- case "bn":
1260
- return ["\u09B9\u09CD\u09AF\u09BE\u0981", "\u09A8\u09BE"];
1261
- default:
1262
- return ["Yes", "No"];
1263
- }
1264
- }, t2.getUrlParam = function(e3) {
1265
- return new URLSearchParams(window.location.search).get(e3);
1266
- };
1267
- }, 559: (e2, t2) => {
1268
- "use strict";
1269
- function i(e3, t3, i2 = "ltr") {
1270
- const n = document.createElement("div");
1271
- n.classList.add("magicfeedback-rating-placeholder");
1272
- const r = document.createElement("span");
1273
- r.textContent = null != e3 ? e3 : "", r.classList.add("magicfeedback-rating-placeholder-value");
1274
- const s = document.createElement("span");
1275
- return s.textContent = null != t3 ? t3 : "", s.classList.add("magicfeedback-rating-placeholder-value"), "ltr" === i2 ? (e3 && n.appendChild(r), t3 && n.appendChild(s)) : (t3 && n.appendChild(s), e3 && n.appendChild(r)), n;
1276
- }
1277
- Object.defineProperty(t2, "__esModule", { value: true }), t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0, t2.createRatingPlaceholder = i, t2.createStarRating = function(e3, t3, n, r = () => {
1278
- }, s) {
1279
- const o = "magicfeedback-rating-star-selected", a = document.createElement("div");
1280
- a.classList.add("magicfeedback-rating-star-container"), a.style.maxWidth = "300px", a.style.margin = "auto", a.dataset.originalSelection = "0";
1281
- for (let t4 = 1; t4 <= 5; t4++) {
1282
- const i2 = document.createElement("label");
1283
- i2.classList.add("magicfeedback-rating-star-option");
1284
- const n2 = document.createElement("input");
1285
- n2.id = `rating-${e3}-${t4}`, n2.type = "radio", n2.name = e3, n2.value = t4.toString(), n2.style.position = "absolute", n2.style.opacity = "0", n2.style.width = "0", n2.style.height = "0", n2.classList.add("magicfeedback-input"), s && s === n2.value && (n2.checked = true), n2.addEventListener("change", (() => {
1286
- const e4 = a.querySelectorAll(".rating__star");
1287
- for (let t5 = 0; t5 < e4.length; t5++) t5 + 1 <= Number(n2.value) ? e4[t5].classList.contains(o) || e4[t5].classList.add(o) : e4[t5].classList.contains(o) && e4[t5].classList.remove(o);
1288
- a.dataset.originalSelection = n2.value, r && r();
1289
- })), i2.appendChild(n2);
1290
- const l2 = document.createElement("label");
1291
- l2.htmlFor = `rating-${e3}-${t4}`, l2.classList.add("rating__star"), l2.textContent = "\u2605", l2.style.fontSize = "40px", l2.style.color = "#CCCCCC", l2.style.cursor = "pointer", l2.addEventListener("mouseenter", (() => {
1292
- const e4 = a.querySelectorAll(".rating__star"), i3 = t4 - 1;
1293
- e4.forEach(((e5, t5) => {
1294
- t5 <= i3 ? e5.classList.contains(o) || e5.classList.add(o) : e5.classList.contains(o) && e5.classList.remove(o);
1295
- }));
1296
- })), l2.addEventListener("mouseleave", (() => {
1297
- const e4 = Number(a.dataset.originalSelection || "0");
1298
- a.querySelectorAll(".rating__star").forEach(((t5, i3) => {
1299
- i3 < e4 ? t5.classList.contains(o) || t5.classList.add(o) : t5.classList.contains(o) && t5.classList.remove(o);
1300
- }));
1301
- })), i2.appendChild(l2), a.appendChild(i2);
1302
- }
1303
- const l = i(t3, n);
1304
- return l.childElementCount > 0 && a.appendChild(l), a;
1305
- }, t2.createRatingNumberElement = function(e3, t3, i2, n, r, s, o) {
1306
- var a, l;
1307
- const d = document.createElement("div");
1308
- d.classList.add("magicfeedback-rating-number");
1309
- const c = "column" === n, u = "ltr" === i2 ? n : `${n}-reverse`, p = document.createElement("div");
1310
- p.classList.add("magicfeedback-rating-number-container"), p.classList.add(`magicfeedback-rating-number-container-${i2}`), p.classList.add(`magicfeedback-rating-number-container-${n}`), p.style.display = "flex", p.style.flexDirection = u, p.setAttribute("role", "radiogroup"), p.setAttribute("aria-label", (null == t3 ? void 0 : t3.ariaLabel) || "Rating");
1311
- const h = (null == t3 ? void 0 : t3.max) ? Number(null == t3 ? void 0 : t3.max) : 10, m = (null == t3 ? void 0 : t3.min) ? Number(null == t3 ? void 0 : t3.min) : 0;
1312
- !c && h - m + 1 > 6 && p.classList.add("magicfeedback-rating-number-container-row--dense");
1313
- const f = (null == t3 ? void 0 : t3.numberPlaceholders) || null, g = !(!f || !Object.keys(f).length);
1314
- let v = null;
1315
- if (!c && ((null == t3 ? void 0 : t3.minPlaceholder) || (null == t3 ? void 0 : t3.maxPlaceholder))) {
1316
- v = document.createElement("div"), v.classList.add("magicfeedback-rating-number-scale-labels");
1317
- const e4 = document.createElement("span");
1318
- e4.classList.add("magicfeedback-rating-number-scale-label"), e4.textContent = null !== (a = null == t3 ? void 0 : t3.minPlaceholder) && void 0 !== a ? a : "";
1319
- const n2 = document.createElement("span");
1320
- n2.classList.add("magicfeedback-rating-number-scale-label"), n2.textContent = null !== (l = null == t3 ? void 0 : t3.maxPlaceholder) && void 0 !== l ? l : "", "ltr" === i2 ? (v.appendChild(e4), v.appendChild(n2)) : (v.appendChild(n2), v.appendChild(e4));
1321
- }
1322
- let y = null;
1323
- if (c && !g && (p.classList.add("magicfeedback-rating-number-container-column--bare"), (null == t3 ? void 0 : t3.minPlaceholder) || (null == t3 ? void 0 : t3.maxPlaceholder))) {
1324
- const e4 = "ltr" === i2 ? null == t3 ? void 0 : t3.minPlaceholder : null == t3 ? void 0 : t3.maxPlaceholder, n2 = "ltr" === i2 ? null == t3 ? void 0 : t3.maxPlaceholder : null == t3 ? void 0 : t3.minPlaceholder;
1325
- if (e4) {
1326
- const t4 = document.createElement("div");
1327
- t4.classList.add("magicfeedback-rating-number-scale-label-block"), t4.textContent = e4, d.appendChild(t4);
1328
- }
1329
- n2 && (y = document.createElement("div"), y.classList.add("magicfeedback-rating-number-scale-label-block"), y.textContent = n2);
1330
- }
1331
- for (let i3 = m; i3 <= h; i3++) {
1332
- const a2 = document.createElement("div");
1333
- a2.classList.add("magicfeedback-rating-number-option"), a2.classList.add(`magicfeedback-rating-number-option-${n}`);
1334
- const l2 = document.createElement("label");
1335
- l2.htmlFor = `rating-${e3}-${i3}`, l2.classList.add("magicfeedback-rating-number-option-label-container");
1336
- const d2 = g && (f[i3] || (i3 === m ? null == t3 ? void 0 : t3.minPlaceholder : void 0) || (i3 === h ? null == t3 ? void 0 : t3.maxPlaceholder : void 0)), u2 = document.createElement("input");
1337
- u2.id = `rating-${e3}-${i3}`, u2.type = "radio", u2.name = e3, u2.value = i3.toString(), u2.classList.add(r), u2.classList.add("magicfeedback-input"), u2.setAttribute("aria-label", d2 ? `${i3} \u2014 ${d2}` : `${i3}`), s && u2.addEventListener("change", (() => s())), o && o === u2.value && (u2.checked = true), l2.appendChild(u2);
1338
- const v2 = document.createElement("span");
1339
- v2.classList.add("magicfeedback-rating-number-value");
1340
- const y2 = document.createElement("span");
1341
- if (y2.textContent = i3.toString(), y2.classList.add("magicfeedback-rating-number-value-num"), v2.appendChild(y2), c) {
1342
- if (d2) {
1343
- const e4 = document.createElement("span");
1344
- e4.textContent = d2, e4.classList.add("magicfeedback-rating-number-value-label"), v2.appendChild(e4);
1345
- }
1346
- } else f && f[i3] && (l2.title = f[i3]);
1347
- l2.appendChild(v2), a2.appendChild(l2), p.appendChild(a2);
1348
- }
1349
- if (d.appendChild(p), v && d.appendChild(v), y && d.appendChild(y), (null == t3 ? void 0 : t3.extraOption) && (null == t3 ? void 0 : t3.extraOptionText)) {
1350
- const i3 = document.createElement("div");
1351
- i3.classList.add("magicfeedback-rating-number-extra-row");
1352
- const n2 = document.createElement("div");
1353
- n2.classList.add("magicfeedback-rating-number-option"), n2.classList.add("magicfeedback-rating-number-option--extra");
1354
- const o2 = document.createElement("label");
1355
- o2.htmlFor = `rating-${e3}-extra`, o2.classList.add("magicfeedback-rating-number-option-label-container");
1356
- const a2 = document.createElement("input");
1357
- a2.id = `rating-${e3}-extra`, a2.type = "radio", a2.name = e3, a2.value = "-", a2.classList.add(r), a2.classList.add("magicfeedback-input"), a2.setAttribute("aria-label", null == t3 ? void 0 : t3.extraOptionText), s && a2.addEventListener("change", (() => s()));
1358
- const l2 = document.createElement("span");
1359
- l2.classList.add("magicfeedback-rating-number-value");
1360
- const c2 = document.createElement("span");
1361
- c2.textContent = null == t3 ? void 0 : t3.extraOptionText, c2.classList.add("magicfeedback-rating-number-value-label"), l2.appendChild(c2), o2.appendChild(a2), o2.appendChild(l2), n2.appendChild(o2), i3.appendChild(n2), d.appendChild(i3);
1362
- }
1363
- return d;
1364
- };
1365
- }, 42: (e2, t2, i) => {
1366
- "use strict";
1367
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getQuestionRenderer = void 0;
1368
- const n = i(558), r = i(998), s = i(72), o = i(732), a = i(90), l = i(65), d = i(85), c = i(817), u = i(965), p = i(180), h = i(991), m = i(152), f = i(917), g = i(452), v = i(644), y = i(773), b = i(66), E = i(843), A = i(250), k = i(409), C = i(282), T = /* @__PURE__ */ new Map([[n.FEEDBACKAPPANSWERTYPE.TEXT, a.renderText], [n.FEEDBACKAPPANSWERTYPE.LONGTEXT, s.renderLongText], [n.FEEDBACKAPPANSWERTYPE.NUMBER, o.renderNumber], [n.FEEDBACKAPPANSWERTYPE.RADIO, r.renderChoice], [n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE, r.renderChoice], [n.FEEDBACKAPPANSWERTYPE.BOOLEAN, l.renderBoolean], [n.FEEDBACKAPPANSWERTYPE.SELECT, d.renderSelect], [n.FEEDBACKAPPANSWERTYPE.DATE, c.renderDate], [n.FEEDBACKAPPANSWERTYPE.EMAIL, u.renderEmail], [n.FEEDBACKAPPANSWERTYPE.PASSWORD, p.renderPassword], [n.FEEDBACKAPPANSWERTYPE.CONSENT, h.renderConsent], [n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI, m.renderRatingEmoji], [n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER, f.renderRatingNumber], [n.FEEDBACKAPPANSWERTYPE.RATING_STAR, g.renderRatingStar], [n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX, v.renderMatrix], [n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST, y.renderPriorityList], [n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM, b.renderPointSystem], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, E.renderUploadImage], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, A.renderUploadFile], [n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE, k.renderMultipleChoiceImage], [n.FEEDBACKAPPANSWERTYPE.INFO_PAGE, C.renderInfoPage]]);
1369
- t2.getQuestionRenderer = function(e3) {
1370
- return T.get(e3);
1371
- };
1372
- }, 65: (e2, t2, i) => {
1373
- "use strict";
1374
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderBoolean = void 0;
1375
- const n = i(516);
1376
- t2.renderBoolean = ({ question: e3, language: t3, urlParamValue: i2, send: r }) => {
1377
- const { ref: s, assets: o } = e3, a = document.createElement("div"), l = "magicfeedback-radio", d = document.createElement("div");
1378
- return d.classList.add("magicfeedback-boolean-container"), d.style.display = "flex", d.style.flexDirection = "row", d.style.justifyContent = "space-between", d.style.width = "70%", d.style.margin = "auto", ((null == o ? void 0 : o.addIcon) ? ["\u{1F44D}", "\u{1F44E}"] : (0, n.getBooleanOptions)(t3)).forEach(((e4, t4) => {
1379
- const n2 = document.createElement("label");
1380
- n2.classList.add("magicfeedback-boolean-option"), n2.htmlFor = `rating-${s}-${t4}`, n2.style.cursor = "pointer", n2.style.display = "flex", n2.style.justifyContent = "center", n2.style.alignItems = "center", n2.style.margin = "auto", n2.style.padding = "0", n2.style.width = "45%", n2.style.height = "38px";
1381
- const o2 = document.createElement("label");
1382
- o2.htmlFor = `rating-${s}-${t4}`, o2.textContent = e4, o2.style.margin = "0", o2.style.padding = "0";
1383
- const a2 = document.createElement("input");
1384
- a2.id = `rating-${s}-${t4}`, a2.type = "radio", a2.name = s, a2.value = ["Yes", "No"][t4], a2.classList.add(l), a2.classList.add("magicfeedback-input"), a2.style.position = "absolute", a2.style.opacity = "0", a2.style.width = "0", a2.style.height = "0", a2.style.margin = "0", a2.addEventListener("change", (() => {
1385
- r && r();
1386
- })), i2 && i2.toLowerCase() === a2.value.toLowerCase() && (a2.checked = true), n2.appendChild(a2), n2.appendChild(o2), d.appendChild(n2);
1387
- })), a.appendChild(d), { element: a, elementTypeClass: l };
1388
- };
1389
- }, 998: (e2, t2, i) => {
1390
- "use strict";
1391
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderChoice = void 0;
1392
- const n = i(558), r = i(784);
1393
- t2.renderChoice = ({ question: e3, language: t3, urlParamValue: i2, randomPosition: s, send: o }) => {
1394
- const { type: a, ref: l, value: d, defaultValue: c, assets: u } = e3, p = document.createElement("div"), h = "magicfeedback-" + ("MULTIPLECHOICE" === a ? "checkbox" : "radio");
1395
- let m = d || [];
1396
- s && (m = m.sort((() => Math.random() - 0.5)));
1397
- let f = (null == u ? void 0 : u.exclusiveAnswers) || [];
1398
- (null == u ? void 0 : u.extraOption) && (f = f.filter(((e4) => e4 !== u.extraOptionText))), f.length > 0 && (null == f || f.forEach(((e4) => {
1399
- m.includes(e4) || m.push(e4);
1400
- })));
1401
- const g = null == u ? void 0 : u.extraOptionText;
1402
- return (null == u ? void 0 : u.extraOption) && g && !m.includes(g) && m.push(g), m.forEach(((e4, s2) => {
1403
- const d2 = document.createElement("div");
1404
- d2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === a ? "checkbox" : "radio"}-container`);
1405
- const g2 = document.createElement("label"), v = document.createElement("input");
1406
- if (v.id = `rating-${l}-${s2}`, v.type = "MULTIPLECHOICE" === a ? "checkbox" : "radio", v.name = l, v.value = e4, v.classList.add(h), v.classList.add("magicfeedback-input"), a === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == u ? void 0 : u.maxOptions) && (null == u ? void 0 : u.maxOptions) > 0 && v.addEventListener("change", (() => {
1407
- document.querySelectorAll(`input[name="${l}"]:checked`).length > (null == u ? void 0 : u.maxOptions) && (v.checked = false);
1408
- })), a === n.FEEDBACKAPPANSWERTYPE.RADIO && o && (!(null == u ? void 0 : u.extraOptionText) || (null == u ? void 0 : u.extraOptionText) && e4 !== (null == u ? void 0 : u.extraOptionText)) && v.addEventListener("change", (() => {
1409
- o();
1410
- })), e4 !== c && e4 !== i2 || (v.checked = true), g2.textContent = e4, g2.htmlFor = `rating-${l}-${s2}`, v.addEventListener("change", ((t4) => {
1411
- const i3 = document.getElementById(`extra-option-${l}`);
1412
- t4.target.checked && f.includes(e4) ? (m.forEach(((t5) => {
1413
- t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1414
- })), i3 && (i3.style.display = "none")) : f.forEach(((t5) => {
1415
- t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1416
- })), (null == u ? void 0 : u.extraOption) && e4 === (null == u ? void 0 : u.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
1417
- })), d2.appendChild(v), d2.appendChild(g2), p.appendChild(d2), (null == u ? void 0 : u.extraOption) && e4 === (null == u ? void 0 : u.extraOptionText)) {
1418
- const e5 = document.createElement("input");
1419
- e5.type = "text", e5.placeholder = (null == u ? void 0 : u.extraOptionPlaceholder) || r.placeholder.answer(t3 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${l}`, e5.name = `extra-option-${l}`, e5.style.display = "none", p.appendChild(e5);
1420
- }
1421
- })), { element: p, elementTypeClass: h };
1422
- };
1423
- }, 991: (e2, t2) => {
1424
- "use strict";
1425
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderConsent = void 0, t2.renderConsent = ({ question: e3, urlParamValue: t3, send: i }) => {
1426
- const { id: n, ref: r, value: s, require: o } = e3, a = document.createElement("input");
1427
- return a.type = "checkbox", a.id = `magicfeedback-${n}`, a.name = r, a.value = "true", a.required = o, a.classList.add("magicfeedback-consent"), a.classList.add("magicfeedback-input"), t3 && s.includes(t3) && (a.checked = true), i && a.addEventListener("change", (() => {
1428
- i();
1429
- })), { element: a, elementTypeClass: "magicfeedback-consent" };
1430
- };
1431
- }, 817: (e2, t2, i) => {
1432
- "use strict";
1433
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderDate = void 0;
1434
- const n = i(784);
1435
- t2.renderDate = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1436
- const r = document.createElement("input");
1437
- return r.type = "date", r.placeholder = t3 || n.placeholder.date(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-date" };
1438
- };
1439
- }, 965: (e2, t2) => {
1440
- "use strict";
1441
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderEmail = void 0, t2.renderEmail = ({ placeholderText: e3, urlParamValue: t3 }) => {
1442
- const i = document.createElement("input");
1443
- return i.type = "email", i.placeholder = e3 || "you@example.com", t3 && (i.value = t3), { element: i, elementTypeClass: "magicfeedback-email" };
1444
- };
1445
- }, 282: (e2, t2) => {
1446
- "use strict";
1447
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderInfoPage = void 0, t2.renderInfoPage = ({ question: e3, placeholderText: t3 }) => {
1448
- var i, n;
1449
- const r = document.createElement("div");
1450
- if ("string" == typeof (null === (i = e3.assets) || void 0 === i ? void 0 : i.placeholder) ? "" !== e3.assets.placeholder.trim() : Boolean(null === (n = e3.assets) || void 0 === n ? void 0 : n.placeholder)) {
1451
- const e4 = document.createElement("div");
1452
- e4.classList.add("magicfeedback-info-message"), e4.innerHTML = t3 || "", r.appendChild(e4);
1453
- }
1454
- return { element: r, elementTypeClass: "magicfeedback-info-page" };
1455
- };
1456
- }, 72: (e2, t2, i) => {
1457
- "use strict";
1458
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderLongText = void 0;
1459
- const n = i(784);
1460
- t2.renderLongText = ({ language: e3, placeholderText: t3, urlParamValue: i2, maxCharacters: r }) => {
1461
- const s = document.createElement("textarea");
1462
- return s.rows = 3, r > 0 && (s.maxLength = r), s.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (s.value = i2), { element: s, elementTypeClass: "magicfeedback-longtext" };
1463
- };
1464
- }, 644: (e2, t2) => {
1465
- "use strict";
1466
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMatrix = void 0, t2.renderMatrix = ({ question: e3, isPhone: t3, randomPosition: i }) => {
1467
- const { ref: n, value: r, assets: s } = e3, o = document.createElement("div"), a = document.createElement("div");
1468
- a.classList.add("magicfeedback-multi-question-matrix-container");
1469
- let l = (null == s ? void 0 : s.options) || [], d = [...r], c = [];
1470
- if (i && (l = null == l ? void 0 : l.sort((() => Math.random() - 0.5)), d = [...d].sort((() => Math.random() - 0.5))), (null == s ? void 0 : s.exclusiveAnswers) && (c = null == s ? void 0 : s.exclusiveAnswers, null == c || c.forEach(((e4) => {
1471
- d.includes(e4) || d.push(e4);
1472
- }))), t3) {
1473
- const e4 = document.createElement("div");
1474
- e4.classList.add("magicfeedback-multi-question-matrix-list"), null == l || l.forEach(((t4) => {
1475
- const i2 = document.createElement("div");
1476
- i2.classList.add("magicfeedback-multi-question-matrix-list-item"), i2.style.display = "flex", i2.style.flexDirection = "column", i2.style.alignItems = "flex-start", i2.style.marginBottom = "10px";
1477
- const r2 = document.createElement("label");
1478
- r2.classList.add("magicfeedback-multi-question-matrix-label"), r2.style.paddingBottom = "10px", r2.textContent = t4, i2.appendChild(r2), d.forEach(((e5) => {
1479
- const r3 = document.createElement("div");
1480
- r3.classList.add("magicfeedback-radio-container"), r3.style.display = "flex", r3.style.alignItems = "center", r3.style.justifyContent = "flex-start", r3.style.width = "99%", r3.style.margin = "5px auto";
1481
- const s2 = document.createElement("label"), o2 = document.createElement("input");
1482
- o2.id = `${n}-${t4}-${e5}`, o2.type = "radio", o2.name = `${n}-${t4}`, o2.value = e5, o2.classList.add("magicfeedback-input"), s2.textContent = e5, s2.htmlFor = `${n}-${t4}-${e5}`, r3.appendChild(o2), r3.appendChild(s2), i2.appendChild(r3);
1483
- })), e4.appendChild(i2);
1484
- })), a.appendChild(e4);
1485
- } else {
1486
- const e4 = document.createElement("table");
1487
- e4.classList.add("magicfeedback-multi-question-matrix-table");
1488
- const t4 = document.createElement("thead");
1489
- t4.classList.add("magicfeedback-multi-question-matrix-header"), t4.style.paddingBottom = "15px";
1490
- const i2 = document.createElement("tr"), r2 = document.createElement("th");
1491
- i2.appendChild(r2), d.forEach(((e5) => {
1492
- const t5 = document.createElement("th");
1493
- t5.textContent = e5, i2.appendChild(t5);
1494
- })), t4.appendChild(i2), e4.appendChild(t4);
1495
- const s2 = document.createElement("tbody");
1496
- null == l || l.forEach(((e5) => {
1497
- const t5 = document.createElement("tr");
1498
- t5.classList.add("magicfeedback-multi-question-matrix-row-tr");
1499
- const i3 = document.createElement("td");
1500
- i3.style.minWidth = "200px", i3.style.padding = "10px";
1501
- const r3 = document.createElement("label");
1502
- r3.classList.add("magicfeedback-multi-question-matrix-label"), r3.textContent = e5, i3.appendChild(r3), t5.appendChild(i3), d.forEach(((i4) => {
1503
- const r4 = document.createElement("td"), s3 = document.createElement("input");
1504
- s3.type = "radio", s3.name = `${n}-${e5}`, s3.value = i4, s3.id = `${n}-${e5}-${i4}`, s3.classList.add("magicfeedback-input"), r4.appendChild(s3), t5.appendChild(r4);
1505
- })), s2.appendChild(t5);
1506
- })), e4.appendChild(s2), a.appendChild(e4);
1507
- }
1508
- return o.appendChild(a), { element: o, elementTypeClass: "magicfeedback-multi-question-matrix" };
1509
- };
1510
- }, 409: (e2, t2) => {
1511
- "use strict";
1512
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMultipleChoiceImage = void 0, t2.renderMultipleChoiceImage = ({ question: e3, randomPosition: t3, urlParamValue: i, send: n }) => {
1513
- const r = document.createElement("div"), { ref: s, assets: o } = e3;
1514
- let a = [...e3.value];
1515
- const l = document.createElement("div");
1516
- l.classList.add("magicfeedback-multiple-choice-image-container"), l.style.display = "flex", l.style.flexDirection = "row", l.style.flexWrap = "wrap", l.style.justifyContent = "center";
1517
- const d = a.length;
1518
- let c = 1, u = 1;
1519
- if (window.innerWidth < 600) c = 1, u = d;
1520
- else switch (d) {
1521
- case 1:
1522
- case 2:
1523
- case 3:
1524
- c = d, u = 1;
1525
- break;
1526
- case 4:
1527
- case 5:
1528
- case 6:
1529
- u = 2, c = Math.ceil(d / u);
1530
- break;
1531
- case 7:
1532
- case 8:
1533
- case 9:
1534
- u = 3, c = Math.ceil(d / u);
1535
- break;
1536
- default:
1537
- u = 4, c = Math.ceil(d / u);
1538
- }
1539
- const p = void 0 !== (null == o ? void 0 : o.addTitle) && (null == o ? void 0 : o.addTitle), h = void 0 !== (null == o ? void 0 : o.multiOption) && (null == o ? void 0 : o.multiOption), m = void 0 !== (null == o ? void 0 : o.extraOption) && (null == o ? void 0 : o.extraOption);
1540
- function f(e4) {
1541
- try {
1542
- const { position: t4, url: r2, value: o2 } = e4, a2 = document.createElement("div");
1543
- a2.classList.add("magicfeedback-multiple-choice-image-option"), a2.style.width = `calc(100% / ${c} - 2px)`, a2.style.height = `calc(100% / ${u} - 2px)`, a2.style.padding = "8px", a2.style.margin = "0";
1544
- const d2 = document.createElement("label");
1545
- d2.classList.add("magicfeedback-image-option-label-container"), d2.htmlFor = `rating-${s}-${t4}`, d2.style.cursor = "pointer", d2.addEventListener("click", (() => {
1546
- d2.style.border = "2px solid #000";
1547
- }));
1548
- const m2 = document.createElement("label");
1549
- m2.textContent = o2, m2.classList.add("magicfeedback-multiple-choice-image-label");
1550
- const f2 = document.createElement("input");
1551
- f2.id = `rating-${s}-${t4}`, f2.type = h ? "checkbox" : "radio", f2.name = s, f2.value = o2, f2.style.position = "absolute", f2.style.opacity = "0", f2.style.width = "0", f2.style.height = "0", f2.classList.add("magicfeedback-input"), i && i === f2.value && (f2.checked = true), !h && n && f2.addEventListener("change", (() => {
1552
- n();
1553
- }));
1554
- const g = document.createElement("img");
1555
- g.classList.add("magicfeedback-multiple-choice-image-image"), g.src = r2, g.style.cursor = "pointer", g.style.backgroundSize = "cover", g.style.backgroundPosition = "center", g.style.width = "100%", g.style.height = "100%", g.style.objectFit = "cover", g.style.margin = "auto", d2.appendChild(f2), d2.appendChild(g), p && d2.appendChild(m2), a2.appendChild(d2), l.appendChild(a2);
1556
- } catch (e5) {
1557
- console.error(e5);
1558
- }
1559
- }
1560
- return t3 && (a = a.sort((() => Math.random() - 0.5))), a.forEach(((e4) => f(JSON.parse(e4)))), m && (null == o ? void 0 : o.extraOptionValue) && (null == o ? void 0 : o.extraOptionValue.length) > 0 && f(null == o ? void 0 : o.extraOptionValue[0]), r.appendChild(l), { element: r, elementTypeClass: "magicfeedback-multiple-choice-image" };
1561
- };
1562
- }, 732: (e2, t2, i) => {
1563
- "use strict";
1564
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderNumber = void 0;
1565
- const n = i(784), r = i(516);
1566
- t2.renderNumber = ({ question: e3, format: t3, language: i2, urlParamValue: s }) => {
1567
- const o = document.createElement("input");
1568
- o.type = "number", o.placeholder = "slim" === t3 ? (0, r.parseTitle)(e3.title, i2) : n.placeholder.number(i2 || "en");
1569
- const { value: a } = e3;
1570
- return a.length && (a.sort(((e4, t4) => Number(e4) - Number(t4))), o.max = a[a.length - 1], o.min = a[0], o.value = a[0]), s && !isNaN(Number(s)) && (o.value = s), { element: o, elementTypeClass: "magicfeedback-number" };
1571
- };
1572
- }, 180: (e2, t2, i) => {
1573
- "use strict";
1574
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPassword = void 0;
1575
- const n = i(784);
1576
- t2.renderPassword = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1577
- const r = document.createElement("input");
1578
- return r.type = "password", r.placeholder = t3 || n.placeholder.password(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-password" };
1579
- };
1580
- }, 66: (e2, t2, i) => {
1581
- "use strict";
1582
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPointSystem = void 0;
1583
- const n = i(784);
1584
- t2.renderPointSystem = ({ question: e3, language: t3 }) => {
1585
- const { ref: i2, value: r } = e3, s = document.createElement("div"), o = document.createElement("div");
1586
- o.classList.add("magicfeedback-point-system-container");
1587
- const a = document.createElement("ul");
1588
- a.classList.add("magicfeedback-point-system-list"), a.style.padding = "0";
1589
- const l = 100 / r.length, d = document.createElement("div");
1590
- d.classList.add("magicfeedback-error"), d.textContent = n.placeholder.pointsystemerror(t3 || "en"), d.style.color = "#C70039", d.style.fontSize = "14px", d.style.textAlign = "right", d.style.width = "100%", d.style.display = "none";
1591
- const c = document.createElement("div");
1592
- return c.classList.add("magicfeedback-point-system-total"), c.textContent = "0 / 100 %", c.style.textAlign = "right", c.style.fontSize = "15px", c.style.marginTop = "5px", r.forEach(((e4, t4) => {
1593
- const n2 = document.createElement("li");
1594
- n2.classList.add("magicfeedback-point-system-item"), n2.style.display = "flex", n2.style.justifyContent = "space-between", n2.style.alignItems = "center", n2.style.margin = "5px";
1595
- const r2 = document.createElement("label");
1596
- r2.textContent = e4, r2.style.fontSize = "15px", n2.appendChild(r2);
1597
- const s2 = document.createElement("span");
1598
- s2.classList.add("magicfeedback-point-system-input-container");
1599
- const o2 = document.createElement("input");
1600
- o2.name = i2, o2.id = `${e4}`, o2.type = "number", o2.min = "0", o2.max = "100", o2.value = "0", o2.classList.add("magicfeedback-input"), o2.style.width = "40px", o2.style.border = "0", o2.style.textAlign = "center", o2.style.margin = "0 5px", o2.autofocus = 0 === t4;
1601
- const u = document.createElement("span");
1602
- u.textContent = "%", u.style.color = "#000", o2.addEventListener("input", (() => {
1603
- const e5 = a.querySelectorAll("input");
1604
- let t5 = 0;
1605
- e5.forEach(((e6) => {
1606
- t5 += Number(e6.value);
1607
- })), t5 > 100 && (o2.value = `${l}%`, t5 -= Number(o2.value));
1608
- const i3 = document.getElementById("magicfeedback-submit");
1609
- i3 && (t5 < 100 ? (c.style.color = "orange", i3.setAttribute("disabled", "true")) : (d.style.display = "none", c.style.color = "green", i3.removeAttribute("disabled"))), c.textContent = `${t5} / 100 %`;
1610
- })), o2.addEventListener("focus", (() => {
1611
- const e5 = document.getElementById("magicfeedback-submit");
1612
- e5 && (e5.setAttribute("disabled", "true"), e5.addEventListener("pointerover", (() => {
1613
- const e6 = a.querySelectorAll("input");
1614
- let t5 = 0;
1615
- e6.forEach(((e7) => {
1616
- t5 += Number(e7.value);
1617
- })), t5 < 100 && (d.style.display = "block");
1618
- })));
1619
- })), s2.appendChild(o2), s2.appendChild(u), n2.appendChild(s2), a.appendChild(n2);
1620
- })), o.appendChild(a), o.appendChild(c), o.appendChild(d), s.appendChild(o), { element: s, elementTypeClass: "magicfeedback-point-system" };
1621
- };
1622
- }, 773: (e2, t2) => {
1623
- "use strict";
1624
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPriorityList = void 0, t2.renderPriorityList = ({ question: e3, randomPosition: t3, language: i }) => {
1625
- var n, r, s;
1626
- const o = document.createElement("div"), a = (function(e4) {
1627
- const { value: t4, ref: i2, randomPosition: n2 = false, limitPriority: r2 = false, maxPriority: s2 = 0, language: o2 = "en", placeholder: a2 = "" } = e4, l = (e5) => {
1628
- const t5 = { en: { selectUpTo: "Select up to", options: "options", thenOrder: "and then order them", selectOptions: "Select options", cancel: "Cancel", confirm: "Confirm", selectOptionNumber: "Select option #", prioritized: "Prioritized", of: "of", instruction: "Your priority list can be seen below. If you wish, you can rearrange your choices using the arrows. Click 'Next' to confirm your selection and proceed." }, es: { selectUpTo: "Selecciona hasta", options: "opciones", thenOrder: "y luego ord\xE9nalas", selectOptions: "Seleccionar opciones", cancel: "Cancelar", confirm: "Confirmar", selectOptionNumber: "Selecciona la opci\xF3n #", prioritized: "Priorizadas", of: "de", instruction: 'Tu lista priorizada se muestra abajo. Si deseas, puedes reordenar las opciones con las flechas. Haz clic en "Siguiente" para confirmar y continuar.' }, pt: { selectUpTo: "Selecione at\xE9", options: "op\xE7\xF5es", thenOrder: "e depois ordene-as", selectOptions: "Selecionar op\xE7\xF5es", cancel: "Cancelar", confirm: "Confirmar", selectOptionNumber: "Selecione a op\xE7\xE3o #", prioritized: "Priorizadas", of: "de", instruction: 'Sua lista de prioridades pode ser vista abaixo. Se quiser, voc\xEA pode reorganizar suas escolhas usando as setas. Clique em "Pr\xF3ximo" para confirmar sua sele\xE7\xE3o e continuar.' }, fr: { selectUpTo: "S\xE9lectionnez jusqu'\xE0", options: "options", thenOrder: "puis classez-les", selectOptions: "S\xE9lectionner des options", cancel: "Annuler", confirm: "Confirmer", selectOptionNumber: "S\xE9lectionnez l'option #", prioritized: "Prioris\xE9es", of: "sur", instruction: `Votre liste de priorit\xE9s est affich\xE9e ci-dessous. Si vous le souhaitez, vous pouvez r\xE9organiser vos choix \xE0 l'aide des fl\xE8ches. Cliquez sur "Suivant" pour confirmer votre s\xE9lection et continuer.` }, de: { selectUpTo: "W\xE4hlen Sie bis zu", options: "Optionen", thenOrder: "und ordnen Sie sie dann", selectOptions: "Optionen ausw\xE4hlen", cancel: "Abbrechen", confirm: "Best\xE4tigen", selectOptionNumber: "W\xE4hlen Sie Option #", prioritized: "Priorisiert", of: "von", instruction: 'Ihre Priorit\xE4tenliste wird unten angezeigt. Wenn Sie m\xF6chten, k\xF6nnen Sie Ihre Auswahl mit den Pfeilen neu anordnen. Klicken Sie auf "Weiter", um Ihre Auswahl zu best\xE4tigen und fortzufahren.' }, it: { selectUpTo: "Seleziona fino a", options: "opzioni", thenOrder: "e poi ordinali", selectOptions: "Seleziona opzioni", cancel: "Annulla", confirm: "Conferma", selectOptionNumber: "Seleziona opzione #", prioritized: "Prioritizzate", of: "di", instruction: 'La tua lista di priorit\xE0 \xE8 mostrata qui sotto. Se vuoi, puoi riordinare le tue scelte usando le frecce. Clicca su "Avanti" per confermare la selezione e continuare.' }, nl: { selectUpTo: "Selecteer tot", options: "opties", thenOrder: "en rangschik ze vervolgens", selectOptions: "Selecteer opties", cancel: "Annuleren", confirm: "Bevestigen", selectOptionNumber: "Selecteer optie #", prioritized: "Geprioriteerd", of: "van", instruction: 'Je prioriteitenlijst wordt hieronder weergegeven. Als je wilt, kun je je keuzes herschikken met behulp van de pijlen. Klik op "Volgende" om je selectie te bevestigen en door te gaan.' }, pl: { selectUpTo: "Wybierz do", options: "opcje", thenOrder: "a nast\u0119pnie je uporz\u0105dkuj", selectOptions: "Wybierz opcje", cancel: "Anuluj", confirm: "Potwierd\u017A", selectOptionNumber: "Wybierz opcj\u0119 #", prioritized: "Priorytetowe", of: "z", instruction: 'Twoja lista priorytet\xF3w jest pokazana poni\u017Cej. Je\u015Bli chcesz, mo\u017Cesz zmieni\u0107 kolejno\u015B\u0107 swoich wybor\xF3w za pomoc\u0105 strza\u0142ek. Kliknij "Dalej", aby potwierdzi\u0107 wyb\xF3r i kontynuowa\u0107.' }, ru: { selectUpTo: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u043E", options: "\u0432\u0430\u0440\u0438\u0430\u043D\u0442\u043E\u0432", thenOrder: "\u0430 \u0437\u0430\u0442\u0435\u043C \u0443\u043F\u043E\u0440\u044F\u0434\u043E\u0447\u044C\u0442\u0435 \u0438\u0445", selectOptions: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u044B", cancel: "\u041E\u0442\u043C\u0435\u043D\u0430", confirm: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C", selectOptionNumber: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0430\u0440\u0438\u0430\u043D\u0442 #", prioritized: "\u041F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442\u044B", of: "\u0438\u0437", instruction: '\u0412\u0430\u0448 \u0441\u043F\u0438\u0441\u043E\u043A \u043F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442\u043E\u0432 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F \u043D\u0438\u0436\u0435. \u0415\u0441\u043B\u0438 \u0445\u043E\u0442\u0438\u0442\u0435, \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043F\u043E\u0440\u044F\u0434\u043E\u043A \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u043E\u0432 \u0441 \u043F\u043E\u043C\u043E\u0449\u044C\u044E \u0441\u0442\u0440\u0435\u043B\u043E\u043A. \u041D\u0430\u0436\u043C\u0438\u0442\u0435 "\u0414\u0430\u043B\u0435\u0435", \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C \u0432\u044B\u0431\u043E\u0440 \u0438 \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C.' }, ja: { selectUpTo: "\u6700\u5927", options: "\u500B\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u9078\u629E", thenOrder: "\u305D\u306E\u5F8C\u4E26\u3079\u66FF\u3048\u3066\u304F\u3060\u3055\u3044", selectOptions: "\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u9078\u629E", cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB", confirm: "\u78BA\u8A8D", selectOptionNumber: "\u30AA\u30D7\u30B7\u30E7\u30F3 # \u3092\u9078\u629E", prioritized: "\u512A\u5148\u9806\u4F4D", of: "\u306E\u3046\u3061", instruction: "\u512A\u5148\u9806\u4F4D\u30EA\u30B9\u30C8\u306F\u4EE5\u4E0B\u306B\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u5FC5\u8981\u306B\u5FDC\u3058\u3066\u3001\u77E2\u5370\u3092\u4F7F\u3063\u3066\u9078\u629E\u80A2\u3092\u4E26\u3079\u66FF\u3048\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u3059\u3002\u300C\u6B21\u3078\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u9078\u629E\u3092\u78BA\u5B9A\u3057\u3001\u7D9A\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002" }, zh: { selectUpTo: "\u6700\u591A\u9009\u62E9", options: "\u4E2A\u9009\u9879", thenOrder: "\u7136\u540E\u6392\u5E8F\u5B83\u4EEC", selectOptions: "\u9009\u62E9\u9009\u9879", cancel: "\u53D6\u6D88", confirm: "\u786E\u8BA4", selectOptionNumber: "\u9009\u62E9\u9009\u9879 #", prioritized: "\u5DF2\u4F18\u5148", of: "\u5171", instruction: "\u4F60\u7684\u4F18\u5148\u5217\u8868\u5982\u4E0B\u6240\u793A\u3002\u5982\u6709\u9700\u8981\uFF0C\u53EF\u4EE5\u4F7F\u7528\u7BAD\u5934\u91CD\u65B0\u6392\u5E8F\u9009\u9879\u3002\u70B9\u51FB\u201C\u4E0B\u4E00\u6B65\u201D\u786E\u8BA4\u9009\u62E9\u5E76\u7EE7\u7EED\u3002" }, ko: { selectUpTo: "\uCD5C\uB300", options: "\uAC1C\uC758 \uC635\uC158 \uC120\uD0DD", thenOrder: "\uADF8\uB7F0 \uB2E4\uC74C \uC815\uB82C\uD558\uC138\uC694", selectOptions: "\uC635\uC158 \uC120\uD0DD", cancel: "\uCDE8\uC18C", confirm: "\uD655\uC778", selectOptionNumber: "\uC635\uC158 # \uC120\uD0DD", prioritized: "\uC6B0\uC120\uC21C\uC704", of: "\uC911", instruction: '\uC6B0\uC120\uC21C\uC704 \uBAA9\uB85D\uC740 \uC544\uB798\uC5D0 \uD45C\uC2DC\uB429\uB2C8\uB2E4. \uC6D0\uD55C\uB2E4\uBA74 \uD654\uC0B4\uD45C\uB97C \uC0AC\uC6A9\uD574 \uC120\uD0DD \uD56D\uBAA9\uC744 \uC7AC\uC815\uB82C\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. "\uB2E4\uC74C"\uC744 \uD074\uB9AD\uD558\uC5EC \uC120\uD0DD\uC744 \uD655\uC778\uD558\uACE0 \uACC4\uC18D\uD558\uC138\uC694.' }, ar: { selectUpTo: "\u0627\u062E\u062A\u0631 \u062D\u062A\u0649", options: "\u062E\u064A\u0627\u0631\u0627\u062A", thenOrder: "\u062B\u0645 \u0631\u062A\u0628\u0647\u0627", selectOptions: "\u0627\u062E\u062A\u0631 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A", cancel: "\u0625\u0644\u063A\u0627\u0621", confirm: "\u062A\u0623\u0643\u064A\u062F", selectOptionNumber: "\u0627\u062E\u062A\u0631 \u0627\u0644\u062E\u064A\u0627\u0631 #", prioritized: "\u062A\u0645 \u0627\u0644\u062A\u0631\u062A\u064A\u0628", of: "\u0645\u0646", instruction: '\u062A\u0638\u0647\u0631 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0623\u0648\u0644\u0648\u064A\u0627\u062A \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0643 \u0623\u062F\u0646\u0627\u0647. \u0625\u0630\u0627 \u0631\u063A\u0628\u062A\u060C \u064A\u0645\u0643\u0646\u0643 \u0625\u0639\u0627\u062F\u0629 \u062A\u0631\u062A\u064A\u0628 \u0627\u062E\u062A\u064A\u0627\u0631\u0627\u062A\u0643 \u0628\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0627\u0644\u0623\u0633\u0647\u0645. \u0627\u0646\u0642\u0631 \u0639\u0644\u0649 "\u0627\u0644\u062A\u0627\u0644\u064A" \u0644\u062A\u0623\u0643\u064A\u062F \u0627\u062E\u062A\u064A\u0627\u0631\u0643 \u0648\u0627\u0644\u0645\u062A\u0627\u0628\u0639\u0629.' }, bn: { selectUpTo: "\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", options: "\u099F\u09BF \u09AC\u09BF\u0995\u09B2\u09CD\u09AA", thenOrder: "\u09A4\u09BE\u09B0\u09AA\u09B0 \u09B8\u09C7\u0997\u09C1\u09B2\u09CB \u09B8\u09BE\u099C\u09BE\u09A8", selectOptions: "\u09AC\u09BF\u0995\u09B2\u09CD\u09AA \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", cancel: "\u09AC\u09BE\u09A4\u09BF\u09B2", confirm: "\u09A8\u09BF\u09B6\u09CD\u099A\u09BF\u09A4 \u0995\u09B0\u09C1\u09A8", selectOptionNumber: "\u09AC\u09BF\u0995\u09B2\u09CD\u09AA # \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", prioritized: "\u0985\u0997\u09CD\u09B0\u09BE\u09A7\u09BF\u0995\u09BE\u09B0\u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4", of: "\u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7", instruction: "\u0986\u09AA\u09A8\u09BE\u09B0 \u0985\u0997\u09CD\u09B0\u09BE\u09A7\u09BF\u0995\u09BE\u09B0 \u09A4\u09BE\u09B2\u09BF\u0995\u09BE \u09A8\u09BF\u099A\u09C7 \u09A6\u09C7\u0996\u09BE\u09A8\u09CB \u09B9\u09AF\u09BC\u09C7\u099B\u09C7\u0964 \u099A\u09BE\u0987\u09B2\u09C7 \u09A4\u09C0\u09B0 \u099A\u09BF\u09B9\u09CD\u09A8 \u09AC\u09CD\u09AF\u09AC\u09B9\u09BE\u09B0 \u0995\u09B0\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09AA\u099B\u09A8\u09CD\u09A6\u0997\u09C1\u09B2\u09CB \u09AA\u09C1\u09A8\u09B0\u09BE\u09AF\u09BC \u09B8\u09BE\u099C\u09BE\u09A4\u09C7 \u09AA\u09BE\u09B0\u09C7\u09A8\u0964 \u201C\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0\u201D \u0995\u09CD\u09B2\u09BF\u0995 \u0995\u09B0\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u09A8\u09BF\u09B6\u09CD\u099A\u09BF\u09A4 \u0995\u09B0\u09C1\u09A8 \u098F\u09AC\u0982 \u098F\u0997\u09BF\u09AF\u09BC\u09C7 \u09AF\u09BE\u09A8\u0964" }, da: { selectUpTo: "V\xE6lg op til", options: "muligheder", thenOrder: "og sorter dem derefter", selectOptions: "V\xE6lg muligheder", cancel: "Annuller", confirm: "Bekr\xE6ft", selectOptionNumber: "V\xE6lg mulighed #", prioritized: "Prioriteret", of: "af", instruction: 'Din prioritetsliste vises nedenfor. Hvis du \xF8nsker det, kan du omarrangere dine valg ved hj\xE6lp af pilene. Klik p\xE5 "N\xE6ste" for at bekr\xE6fte dit valg og forts\xE6tte.' }, fi: { selectUpTo: "Valitse enint\xE4\xE4n", options: "vaihtoehtoa", thenOrder: "ja j\xE4rjest\xE4 ne sitten", selectOptions: "Valitse vaihtoehdot", cancel: "Peruuta", confirm: "Vahvista", selectOptionNumber: "Valitse vaihtoehto #", prioritized: "Priorisoitu", of: " / ", instruction: 'Prioriteettilistasi n\xE4kyy alla. Voit halutessasi j\xE4rjest\xE4\xE4 valinnat uudelleen nuolien avulla. Napsauta "Seuraava" vahvistaaksesi valinnan ja jatkaaksesi.' }, sv: { selectUpTo: "V\xE4lj upp till", options: "alternativ", thenOrder: "och ordna dem sedan", selectOptions: "V\xE4lj alternativ", cancel: "Avbryt", confirm: "Bekr\xE4fta", selectOptionNumber: "V\xE4lj alternativ #", prioritized: "Prioriterat", of: "av", instruction: 'Din prioriteringslista visas nedan. Om du vill kan du ordna om dina val med hj\xE4lp av pilarna. Klicka p\xE5 "N\xE4sta" f\xF6r att bekr\xE4fta ditt val och forts\xE4tta.' }, no: { selectUpTo: "Velg opptil", options: "alternativer", thenOrder: "og ordne dem deretter", selectOptions: "Velg alternativer", cancel: "Avbryt", confirm: "Bekreft", selectOptionNumber: "Velg alternativ #", prioritized: "Prioritert", of: "av", instruction: 'Prioriteringslisten din vises nedenfor. Hvis du \xF8nsker det, kan du ordne valgene dine ved hjelp av pilene. Klikk p\xE5 "Neste" for \xE5 bekrefte valget ditt og fortsette.' } };
1629
- return t5[t5[o2] ? o2 : "en"][e5];
1630
- }, d = document.createElement("div");
1631
- if (d.classList.add("magicfeedback-priority-list-container"), r2 && s2 && s2 > 0) {
1632
- const e5 = [], r3 = document.createElement("div");
1633
- r3.classList.add("magicfeedback-priority-list-header");
1634
- const o3 = document.createElement("div");
1635
- o3.classList.add("magicfeedback-priority-list-instruction"), o3.textContent = "" !== a2 ? a2 : `${l("instruction")}`, o3.style.display = "none";
1636
- const c2 = document.createElement("button");
1637
- c2.type = "button", c2.textContent = l("selectOptions"), c2.classList.add("magicfeedback-button"), c2.classList.add("magicfeedback-priority-list-open-btn"), r3.appendChild(c2), r3.appendChild(o3);
1638
- const u2 = document.createElement("div");
1639
- u2.classList.add("magicfeedback-priority-list-reorder");
1640
- const p = document.createElement("ul");
1641
- p.classList.add("magicfeedback-priority-list-list"), u2.appendChild(p);
1642
- const h = () => {
1643
- p.innerHTML = "", e5.forEach(((t5, n3) => {
1644
- const r4 = document.createElement("li");
1645
- r4.classList.add("magicfeedback-priority-list-item");
1646
- const s3 = document.createElement("input");
1647
- s3.classList.add("magicfeedback-input-magicfeedback-priority-list"), s3.classList.add("magicfeedback-input"), s3.type = "hidden", s3.id = `priority-list-${i2}`, s3.name = i2, s3.value = `${n3 + 1}. ${t5}`, r4.appendChild(s3);
1648
- const o4 = document.createElement("label");
1649
- o4.classList.add("magicfeedback-priority-list-item-label"), o4.textContent = `${n3 + 1}. ${t5}`, r4.appendChild(o4);
1650
- const a3 = document.createElement("div");
1651
- a3.classList.add("magicfeedback-priority-list-arrows");
1652
- const l2 = document.createElement("img");
1653
- l2.classList.add("magicfeedback-priority-list-arrow-up"), l2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", l2.style.visibility = 0 === n3 ? "hidden" : "visible";
1654
- const d2 = document.createElement("img");
1655
- d2.classList.add("magicfeedback-priority-list-arrow-down"), d2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", d2.style.transform = "rotate(180deg)", d2.style.visibility = n3 === e5.length - 1 ? "hidden" : "visible", l2.addEventListener("click", (() => {
1656
- var i3, n4, a4, c3;
1657
- const u3 = r4.previousElementSibling;
1658
- if (u3) {
1659
- const h2 = Number(null === (i3 = s3.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) - 1;
1660
- s3.value = `${h2}. ${t5}`, o4.textContent = `${h2}. ${t5}`, l2.style.visibility = 1 === h2 ? "hidden" : "visible", d2.style.visibility = h2 === e5.length ? "hidden" : "visible";
1661
- const m2 = u3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f2 = u3.querySelector(".magicfeedback-priority-list-item-label"), g2 = u3.querySelector(".magicfeedback-priority-list-arrow-up"), v2 = u3.querySelector(".magicfeedback-priority-list-arrow-down");
1662
- if (m2 && f2 && g2 && v2) {
1663
- const t6 = Number(null === (n4 = m2.value) || void 0 === n4 ? void 0 : n4.split(".")[0]) + 1;
1664
- m2.value = `${t6}.${null === (a4 = f2.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f2.textContent = `${t6}.${null === (c3 = f2.textContent) || void 0 === c3 ? void 0 : c3.split(".")[1]}`, g2.style.visibility = 1 === t6 ? "hidden" : "visible", v2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1665
- }
1666
- p.insertBefore(r4, u3);
1667
- }
1668
- })), d2.addEventListener("click", (() => {
1669
- var i3, n4, a4;
1670
- const c3 = r4.nextElementSibling;
1671
- if (c3) {
1672
- const u3 = Number(null === (i3 = s3.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) + 1;
1673
- s3.value = `${u3}. ${t5}`, o4.textContent = `${u3}. ${t5}`, l2.style.visibility = 1 === u3 ? "hidden" : "visible", d2.style.visibility = u3 === e5.length ? "hidden" : "visible";
1674
- const h2 = c3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), m2 = c3.querySelector(".magicfeedback-priority-list-item-label"), f2 = c3.querySelector(".magicfeedback-priority-list-arrow-up"), g2 = c3.querySelector(".magicfeedback-priority-list-arrow-down");
1675
- if (h2 && m2 && f2 && g2) {
1676
- const t6 = Number(h2.value.split(".")[0]) - 1;
1677
- h2.value = `${t6}.${null === (n4 = m2.textContent) || void 0 === n4 ? void 0 : n4.split(".")[1]}`, m2.textContent = `${t6}.${null === (a4 = m2.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f2.style.visibility = 1 === t6 ? "hidden" : "visible", g2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1678
- }
1679
- p.insertBefore(c3, r4);
1680
- }
1681
- })), a3.appendChild(l2), a3.appendChild(d2), r4.appendChild(a3), p.appendChild(r4);
1682
- }));
1683
- }, m = document.createElement("div");
1684
- m.classList.add("magicfeedback-modal-backdrop"), m.style.position = "fixed", m.style.top = "0", m.style.left = "0", m.style.width = "100vw", m.style.height = "100vh", m.style.background = "rgba(0,0,0,0.4)", m.style.display = "none", m.style.alignItems = "center", m.style.justifyContent = "center", m.style.zIndex = "9999";
1685
- const f = document.createElement("div");
1686
- f.classList.add("magicfeedback-modal"), f.style.background = "#fff", f.style.borderRadius = "8px", f.style.boxShadow = "0 8px 24px rgba(0,0,0,0.2)", f.style.maxWidth = "520px", f.style.width = "90%", f.style.maxHeight = "80vh", f.style.display = "flex", f.style.flexDirection = "column", f.style.overflow = "hidden", f.style.padding = "16px", f.style.position = "relative";
1687
- const g = document.createElement("h5");
1688
- g.classList.add("magicfeedback-modal-title"), g.style.flexShrink = "0", g.style.marginTop = "0";
1689
- const v = () => Math.min(e5.length + 1, s2), y = () => {
1690
- g.textContent = `${l("selectOptionNumber")}${v()}`;
1691
- };
1692
- y();
1693
- const b = document.createElement("div");
1694
- b.classList.add("magicfeedback-modal-list"), b.style.flex = "1 1 auto", b.style.overflowY = "auto", b.style.minHeight = "0", (n2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4]).forEach(((t5) => {
1695
- const n3 = document.createElement("label");
1696
- n3.classList.add("magicfeedback-modal-row");
1697
- const r4 = document.createElement("input");
1698
- r4.type = "checkbox", r4.classList.add("magicfeedback-input"), r4.name = `${i2}-selection`, r4.value = t5;
1699
- const o4 = document.createElement("span");
1700
- o4.textContent = t5, r4.addEventListener("change", (() => {
1701
- if (r4.checked) {
1702
- if (e5.length >= s2) return r4.checked = false, n3.classList.add("magicfeedback-warning"), void setTimeout((() => {
1703
- n3.classList.remove("magicfeedback-warning");
1704
- }), 800);
1705
- e5.push(t5);
1706
- } else {
1707
- const i3 = e5.indexOf(t5);
1708
- -1 !== i3 && e5.splice(i3, 1);
1709
- }
1710
- y(), k();
1711
- })), n3.appendChild(r4), n3.appendChild(o4), b.appendChild(n3);
1712
- }));
1713
- const E = document.createElement("div");
1714
- E.classList.add("magicfeedback-modal-actions"), E.style.flexShrink = "0";
1715
- const A = document.createElement("div");
1716
- A.classList.add("magicfeedback-modal-counter");
1717
- const k = () => {
1718
- const t5 = l("of");
1719
- A.textContent = `${l("prioritized")} ${e5.length} ${t5} ${s2}`, o3.style.display = e5.length > 0 ? "block" : "none";
1720
- };
1721
- k();
1722
- const C = document.createElement("button");
1723
- C.type = "button", C.classList.add("magicfeedback-modal-close"), C.setAttribute("aria-label", l("cancel")), C.title = l("cancel"), C.textContent = "\xD7", C.style.position = "absolute", C.style.top = "8px", C.style.right = "8px", C.style.border = "none", C.style.background = "transparent", C.style.fontSize = "24px", C.style.cursor = "pointer";
1724
- const T = () => {
1725
- document.body.appendChild(m), m.style.display = "flex", y(), k();
1726
- }, P = () => {
1727
- m.style.display = "none", d.appendChild(m);
1728
- };
1729
- C.addEventListener("click", (() => {
1730
- P();
1731
- }));
1732
- const O = document.createElement("button");
1733
- return O.type = "button", O.textContent = l("confirm"), O.classList.add("magicfeedback-button"), O.classList.add("magicfeedback-button-primary"), O.addEventListener("click", (() => {
1734
- P(), h();
1735
- })), E.appendChild(A), E.appendChild(O), f.appendChild(C), f.appendChild(g), f.appendChild(b), f.appendChild(E), m.appendChild(f), c2.addEventListener("click", (() => {
1736
- T();
1737
- })), m.addEventListener("click", ((e6) => {
1738
- e6.target === m && P();
1739
- })), d.appendChild(r3), d.appendChild(u2), d.appendChild(m), h(), d;
1740
- }
1741
- const c = document.createElement("ul");
1742
- c.classList.add("magicfeedback-priority-list-list");
1743
- const u = n2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4];
1744
- return u.forEach(((e5, t5) => {
1745
- const n3 = document.createElement("li");
1746
- n3.classList.add("magicfeedback-priority-list-item"), n3.style.display = "flex", n3.style.justifyContent = "space-between", n3.style.alignItems = "center", n3.style.margin = "5px";
1747
- const r3 = document.createElement("input");
1748
- r3.classList.add("magicfeedback-input-magicfeedback-priority-list"), r3.classList.add("magicfeedback-input"), r3.type = "hidden", r3.id = `priority-list-${i2}`, r3.name = i2, r3.value = `${t5 + 1}. ${e5}`, n3.appendChild(r3);
1749
- const s3 = document.createElement("label");
1750
- s3.classList.add("magicfeedback-priority-list-item-label"), s3.textContent = `${t5 + 1}. ${e5}`, n3.appendChild(s3);
1751
- const o3 = document.createElement("div");
1752
- o3.style.display = "flex", o3.style.alignItems = "center", o3.style.justifyContent = "space-between";
1753
- const a3 = document.createElement("img");
1754
- a3.classList.add("magicfeedback-priority-list-arrow-up"), a3.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", a3.style.width = "20px", a3.style.height = "20px", a3.style.cursor = "pointer", a3.style.margin = "0 5px", a3.style.color = "#000", a3.style.visibility = 0 === t5 ? "hidden" : "visible", a3.addEventListener("click", (() => {
1755
- var t6, i3, o4, d2;
1756
- const p = n3.previousElementSibling;
1757
- if (p) {
1758
- const h = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) - 1;
1759
- r3.value = `${h}. ${e5}`, s3.textContent = `${h}. ${e5}`, a3.style.visibility = 1 === h ? "hidden" : "visible", l2.style.visibility = h === u.length ? "hidden" : "visible";
1760
- const m = p.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f = p.querySelector(".magicfeedback-priority-list-item-label"), g = p.querySelector(".magicfeedback-priority-list-arrow-up"), v = p.querySelector(".magicfeedback-priority-list-arrow-down");
1761
- if (m && f && g && v) {
1762
- const e6 = Number(null === (i3 = m.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) + 1;
1763
- m.value = `${e6}.${null === (o4 = f.textContent) || void 0 === o4 ? void 0 : o4.split(".")[1]}`, f.textContent = `${e6}.${null === (d2 = f.textContent) || void 0 === d2 ? void 0 : d2.split(".")[1]}`, g.style.visibility = 1 === e6 ? "hidden" : "visible", v.style.visibility = e6 === u.length ? "hidden" : "visible";
1764
- }
1765
- c.insertBefore(n3, p);
1766
- }
1767
- }));
1768
- const l2 = document.createElement("img");
1769
- l2.classList.add("magicfeedback-priority-list-arrow-down"), l2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", l2.style.width = "20px", l2.style.height = "20px", l2.style.cursor = "pointer", l2.style.margin = "0 5px", l2.style.color = "#000", l2.style.transform = "rotate(180deg)", l2.style.visibility = t5 === u.length - 1 ? "hidden" : "visible", l2.addEventListener("click", (() => {
1770
- var t6, i3, o4;
1771
- const d2 = n3.nextElementSibling;
1772
- if (d2) {
1773
- const p = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) + 1;
1774
- r3.value = `${p}. ${e5}`, s3.textContent = `${p}. ${e5}`, a3.style.visibility = 1 === p ? "hidden" : "visible", l2.style.visibility = p === u.length ? "hidden" : "visible";
1775
- const h = d2.querySelector(".magicfeedback-input-magicfeedback-priority-list"), m = d2.querySelector(".magicfeedback-priority-list-item-label"), f = d2.querySelector(".magicfeedback-priority-list-arrow-up"), g = d2.querySelector(".magicfeedback-priority-list-arrow-down");
1776
- if (h && m && f && g) {
1777
- const e6 = Number(h.value.split(".")[0]) - 1;
1778
- h.value = `${e6}.${null === (i3 = m.textContent) || void 0 === i3 ? void 0 : i3.split(".")[1]}`, m.textContent = `${e6}.${null === (o4 = m.textContent) || void 0 === o4 ? void 0 : o4.split(".")[1]}`, f.style.visibility = 1 === e6 ? "hidden" : "visible", g.style.visibility = e6 === u.length ? "hidden" : "visible";
1779
- }
1780
- c.insertBefore(d2, n3);
1781
- }
1782
- })), o3.appendChild(a3), o3.appendChild(l2), n3.appendChild(o3), c.appendChild(n3);
1783
- })), d.appendChild(c), d;
1784
- })({ value: e3.value, ref: e3.ref, randomPosition: t3, limitPriority: (null === (n = e3.assets) || void 0 === n ? void 0 : n.limitPriority) || false, maxPriority: (null === (r = e3.assets) || void 0 === r ? void 0 : r.maxPriority) || 0, placeholder: (null === (s = e3.assets) || void 0 === s ? void 0 : s.placeholder) || "", language: i || "en" });
1785
- return o.appendChild(a), { element: o, elementTypeClass: "magicfeedback-priority-list" };
1786
- };
1787
- }, 152: (e2, t2, i) => {
1788
- "use strict";
1789
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingEmoji = void 0;
1790
- const n = i(559), r = "https://survey-dev.magicfeedback.io/assets/emojis";
1791
- t2.renderRatingEmoji = ({ question: e3, url: t3, send: i2, urlParamValue: s }) => {
1792
- const { ref: o, assets: a } = e3, l = document.createElement("div"), d = "magicfeedback-rating", c = document.createElement("div");
1793
- c.classList.add("magicfeedback-rating-container");
1794
- const u = (null == a ? void 0 : a.max) ? Number(null == a ? void 0 : a.max) : 5, p = (null == a ? void 0 : a.min) ? Number(null == a ? void 0 : a.min) : 1, h = (0, n.createRatingPlaceholder)(null == a ? void 0 : a.minPlaceholder, null == a ? void 0 : a.maxPlaceholder);
1795
- for (let e4 = p; e4 <= u; e4++) {
1796
- const n2 = document.createElement("div");
1797
- n2.classList.add("magicfeedback-rating-option");
1798
- const a2 = document.createElement("label");
1799
- a2.htmlFor = `rating-${o}-${e4}`, a2.classList.add("magicfeedback-rating-option-label-container");
1800
- const l2 = document.createElement("label");
1801
- l2.htmlFor = `rating-${o}-${e4}`, l2.textContent = e4.toString();
1802
- const h2 = document.createElement("img");
1803
- if (h2.alt = `face-${o}-${e4}`, h2.className = `rating-image${e4}`, 0 === p && 10 === u) h2.src = `${t3}/${e4}.svg`, h2.onerror = () => h2.src = `${r}/${e4}.svg`;
1804
- else if (1 === p && 5 === u) switch (e4) {
1805
- case 1:
1806
- h2.src = `${t3}/1.svg`, h2.onerror = () => h2.src = `${r}/1.svg`;
1807
- break;
1808
- case 2:
1809
- h2.src = `${t3}/2.svg`, h2.onerror = () => h2.src = `${r}/2.svg`;
1810
- break;
1811
- case 3:
1812
- h2.src = `${t3}/6.svg`, h2.onerror = () => h2.src = `${r}/6.svg`;
1813
- break;
1814
- case 4:
1815
- h2.src = `${t3}/9.svg`, h2.onerror = () => h2.src = `${r}/9.svg`;
1816
- break;
1817
- case 5:
1818
- h2.src = `${t3}/10.svg`, h2.onerror = () => h2.src = `${r}/10.svg`;
1819
- }
1820
- else {
1821
- const i3 = Math.round(10 / (u - p) * (e4 - p));
1822
- h2.src = `${t3}/${i3}.svg`, h2.onerror = () => h2.src = `${r}/${i3}.svg`;
1823
- }
1824
- const m = document.createElement("input");
1825
- m.id = `rating-${o}-${e4}`, m.type = "radio", m.name = o, m.value = e4.toString(), m.classList.add(d), m.classList.add("magicfeedback-input"), i2 && m.addEventListener("change", (() => {
1826
- i2();
1827
- })), s && s === m.value && (m.checked = true), a2.appendChild(m), a2.appendChild(h2), a2.appendChild(l2), n2.appendChild(a2), c.appendChild(n2);
1828
- }
1829
- if ((null == a ? void 0 : a.extraOption) && (null == a ? void 0 : a.extraOptionText)) {
1830
- const e4 = document.createElement("div");
1831
- e4.classList.add("magicfeedback-rating-option");
1832
- const t4 = document.createElement("label");
1833
- t4.htmlFor = `rating-${o}-extra`, t4.classList.add("magicfeedback-rating-option-label-container");
1834
- const n2 = document.createElement("label");
1835
- n2.htmlFor = `rating-${o}-extra`, n2.textContent = null == a ? void 0 : a.extraOptionText;
1836
- const r2 = document.createElement("img");
1837
- r2.src = "https://magicfeedback-c6458-dev.web.app/assets/question.svg", r2.alt = `face-${o}-extra`, r2.className = "magicfeedback-rating-image-extra";
1838
- const s2 = document.createElement("input");
1839
- s2.id = `rating-${o}-extra`, s2.type = "radio", s2.name = o, s2.value = "-", s2.classList.add(d), s2.classList.add("magicfeedback-input"), i2 && s2.addEventListener("change", (() => {
1840
- i2();
1841
- })), t4.appendChild(s2), t4.appendChild(r2), t4.appendChild(n2), e4.appendChild(t4), c.appendChild(e4);
1842
- }
1843
- return h.childElementCount > 0 && c.appendChild(h), l.appendChild(c), { element: l, elementTypeClass: d };
1844
- };
1845
- }, 917: (e2, t2, i) => {
1846
- "use strict";
1847
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingNumber = void 0;
1848
- const n = i(559);
1849
- t2.renderRatingNumber = ({ question: e3, order: t3, direction: i2, send: r, urlParamValue: s }) => {
1850
- const o = "magicfeedback-rating-number";
1851
- return { element: (0, n.createRatingNumberElement)(e3.ref, e3.assets, t3, i2, o, r, s), elementTypeClass: o };
1852
- };
1853
- }, 452: (e2, t2, i) => {
1854
- "use strict";
1855
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingStar = void 0;
1856
- const n = i(559);
1857
- t2.renderRatingStar = ({ question: e3, send: t3, urlParamValue: i2 }) => {
1858
- var r, s;
1859
- const o = document.createElement("div"), a = (0, n.createStarRating)(e3.ref, null === (r = e3.assets) || void 0 === r ? void 0 : r.minPlaceholder, null === (s = e3.assets) || void 0 === s ? void 0 : s.maxPlaceholder, t3, i2);
1860
- return o.appendChild(a), { element: o, elementTypeClass: "magicfeedback-rating-star" };
1861
- };
1862
- }, 85: (e2, t2, i) => {
1863
- "use strict";
1864
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderSelect = void 0;
1865
- const n = i(516);
1866
- t2.renderSelect = ({ question: e3, format: t3, language: i2, urlParamValue: r }) => {
1867
- const { title: s, value: o, defaultValue: a } = e3, l = document.createElement("select"), d = document.createElement("option");
1868
- return d.value = "", d.text = "slim" === t3 ? (0, n.parseTitle)(s, i2) : a || "Select an option", d.disabled = true, d.selected = true, l.appendChild(d), o.forEach(((e4) => {
1869
- const t4 = document.createElement("option");
1870
- t4.value = e4, t4.text = e4, l.appendChild(t4);
1871
- })), r && o.includes(r) && (l.value = r), { element: l, elementTypeClass: "magicfeedback-select" };
1872
- };
1873
- }, 90: (e2, t2, i) => {
1874
- "use strict";
1875
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderText = void 0;
1876
- const n = i(784);
1877
- t2.renderText = ({ language: e3, placeholderText: t3, urlParamValue: i2, send: r }) => {
1878
- const s = document.createElement("input");
1879
- return s.type = "text", s.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (s.value = i2), s.addEventListener("keyup", ((e4) => {
1880
- e4.preventDefault(), "Enter" === e4.key && r && r();
1881
- })), { element: s, elementTypeClass: "magicfeedback-text" };
1882
- };
1883
- }, 250: (e2, t2, i) => {
1884
- "use strict";
1885
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadFile = void 0;
1886
- const n = i(571);
1887
- t2.renderUploadFile = ({ question: e3, language: t3 }) => (0, n.createUploadControl)(e3, t3, "file");
1888
- }, 843: (e2, t2, i) => {
1889
- "use strict";
1890
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadImage = void 0;
1891
- const n = i(571);
1892
- t2.renderUploadImage = ({ question: e3, language: t3 }) => (0, n.createUploadControl)(e3, t3, "image");
1893
- }, 571: function(e2, t2, i) {
1894
- "use strict";
1895
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
1896
- return new (i2 || (i2 = Promise))((function(r2, s2) {
1897
- function o2(e4) {
1898
- try {
1899
- l2(n2.next(e4));
1900
- } catch (e5) {
1901
- s2(e5);
1902
- }
1903
- }
1904
- function a2(e4) {
1905
- try {
1906
- l2(n2.throw(e4));
1907
- } catch (e5) {
1908
- s2(e5);
1909
- }
1910
- }
1911
- function l2(e4) {
1912
- var t4;
1913
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
1914
- e5(t4);
1915
- }))).then(o2, a2);
1916
- }
1917
- l2((n2 = n2.apply(e3, t3 || [])).next());
1918
- }));
1919
- };
1920
- Object.defineProperty(t2, "__esModule", { value: true }), t2.createUploadControl = t2.awaitUploadReady = t2.getUploadValues = t2.formatFileSize = void 0;
1921
- const r = i(784), s = i(516), o = "__mfUploadValues", a = "__mfUploadReady";
1922
- function l(e3) {
1923
- if ("number" != typeof e3 || isNaN(e3)) return "";
1924
- if (e3 < 1024) return `${e3} B`;
1925
- const t3 = e3 / 1024;
1926
- if (t3 < 1024) return `${t3 < 10 ? t3.toFixed(1) : Math.round(t3)} KB`;
1927
- const i2 = t3 / 1024;
1928
- return `${i2 < 10 ? i2.toFixed(1) : Math.round(i2)} MB`;
1929
- }
1930
- t2.formatFileSize = l, t2.getUploadValues = function(e3) {
1931
- const t3 = e3[o];
1932
- return Array.isArray(t3) ? t3 : [];
1933
- }, t2.awaitUploadReady = function(e3) {
1934
- return n(this, void 0, void 0, (function* () {
1935
- if (!e3) return;
1936
- const t3 = Array.from(e3.querySelectorAll(".magicfeedback-upload-native"));
1937
- yield Promise.all(t3.map(((e4) => e4[a])).filter(Boolean));
1938
- }));
1939
- }, t2.createUploadControl = function(e3, t3, i2) {
1940
- const { ref: n2, require: d, title: c, assets: u } = e3, p = "image" === i2 ? "magicfeedback-upload-image" : "magicfeedback-upload-file", h = (null == u ? void 0 : u.multiple) || false, m = h ? (null == u ? void 0 : u.maxFiles) || 0 : 1, f = Number(null == u ? void 0 : u.maxFileSize) > 0 ? Number(null == u ? void 0 : u.maxFileSize) : 0, g = 1024 * f * 1024, v = document.createElement("div");
1941
- v.classList.add("magicfeedback-upload");
1942
- const y = document.createElement("input");
1943
- y.type = "file", "image" === i2 && (y.accept = "image/*"), y.multiple = h, y.required = d, y.name = n2, y.id = `magicfeedback-upload-input-${n2}`, y.classList.add(p), y.classList.add("magicfeedback-input"), y.classList.add("magicfeedback-upload-native"), y[o] = [], y[a] = Promise.resolve();
1944
- const b = (0, s.parseTitle)(c, t3);
1945
- b && y.setAttribute("aria-label", b);
1946
- const E = document.createElement("div");
1947
- E.classList.add("magicfeedback-upload-dropzone");
1948
- const A = document.createElement("span");
1949
- A.classList.add("magicfeedback-upload-icon"), A.innerHTML = "image" === i2 ? '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/></svg>' : '<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="M16 16l-4-4-4 4"/><path d="M12 12v9"/><path d="M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"/></svg>';
1950
- const k = document.createElement("span");
1951
- k.classList.add("magicfeedback-upload-cta"), k.textContent = r.placeholder.upload.cta(t3);
1952
- const C = document.createElement("span");
1953
- C.classList.add("magicfeedback-upload-hint"), C.textContent = (function(e4, t4, i3, n3, s2) {
1954
- const o2 = [r.placeholder.upload.formats(e4, t4)];
1955
- return i3 && n3 > 0 && o2.push(r.placeholder.upload.maxFiles(e4, n3)), s2 > 0 && o2.push(r.placeholder.upload.maxSize(e4, s2)), o2.filter(Boolean).join(" \xB7 ");
1956
- })(t3, i2, h, m, f), E.appendChild(y), E.appendChild(A), E.appendChild(k), E.appendChild(C);
1957
- const T = document.createElement("div");
1958
- T.classList.add("magicfeedback-upload-error");
1959
- const P = document.createElement("ul");
1960
- P.classList.add("magicfeedback-upload-list"), v.appendChild(E), v.appendChild(T), v.appendChild(P);
1961
- const O = /* @__PURE__ */ new WeakMap(), x = (e4) => {
1962
- const t4 = O.get(e4);
1963
- return t4 ? Promise.resolve(t4) : new Promise(((t5) => {
1964
- const i3 = new FileReader(), n3 = (i4) => {
1965
- const n4 = JSON.stringify({ name: e4.name, type: e4.type, size: e4.size, content: i4 });
1966
- O.set(e4, n4), t5(n4);
1967
- };
1968
- i3.onload = () => n3("string" == typeof i3.result ? i3.result : ""), i3.onerror = () => n3(""), i3.readAsDataURL(e4);
1969
- }));
1970
- }, w = [], L = (e4) => {
1971
- try {
1972
- const t4 = m > 0 ? e4.slice(0, m) : e4, i3 = new DataTransfer();
1973
- t4.forEach(((e5) => i3.items.add(e5))), y.files = i3.files;
1974
- } catch (e5) {
1975
- }
1976
- !(function() {
1977
- w.forEach(((e6) => URL.revokeObjectURL(e6))), w.length = 0, P.innerHTML = "";
1978
- const e5 = Array.from(y.files || []);
1979
- v.classList.toggle("magicfeedback-upload--has-files", e5.length > 0), e5.forEach(((e6, n3) => {
1980
- const s2 = document.createElement("li");
1981
- s2.classList.add("magicfeedback-upload-file-item");
1982
- const o2 = document.createElement("span");
1983
- if (o2.classList.add("magicfeedback-upload-thumb"), "image" === i2 && e6.type.startsWith("image/")) {
1984
- const t4 = URL.createObjectURL(e6);
1985
- w.push(t4);
1986
- const i3 = document.createElement("img");
1987
- i3.src = t4, i3.alt = e6.name, o2.appendChild(i3);
1988
- } else o2.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>';
1989
- const a2 = document.createElement("span");
1990
- a2.classList.add("magicfeedback-upload-file-info");
1991
- const d2 = document.createElement("span");
1992
- d2.classList.add("magicfeedback-upload-file-name"), d2.textContent = e6.name, d2.title = e6.name;
1993
- const c2 = document.createElement("span");
1994
- c2.classList.add("magicfeedback-upload-file-size"), c2.textContent = l(e6.size), a2.appendChild(d2), a2.appendChild(c2);
1995
- const u2 = document.createElement("button");
1996
- 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) => {
1997
- e7.preventDefault(), e7.stopPropagation(), L(Array.from(y.files || []).filter(((e8, t4) => t4 !== n3)));
1998
- })), s2.appendChild(o2), s2.appendChild(a2), s2.appendChild(u2), P.appendChild(s2);
1999
- }));
2000
- })(), (() => {
2001
- const e5 = Array.from(y.files || []), t4 = Promise.all(e5.map(x)).then(((e6) => {
2002
- y[o] = e6;
2003
- }));
2004
- y[a] = t4;
2005
- })();
2006
- }, S = (e4) => {
2007
- if (!e4.length) return T.textContent = "", void T.classList.remove("is-visible");
2008
- const i3 = e4.map(((e5) => e5.name)).join(", ");
2009
- T.textContent = `${r.placeholder.upload.tooLarge(t3, f)}: ${i3}`, T.classList.add("is-visible");
2010
- }, N = (e4) => {
2011
- if (!g) return { accepted: e4, rejected: [] };
2012
- const t4 = [], i3 = [];
2013
- return e4.forEach(((e5) => (e5.size <= g ? t4 : i3).push(e5))), { accepted: t4, rejected: i3 };
2014
- };
2015
- y.addEventListener("change", (() => {
2016
- const { accepted: e4, rejected: t4 } = N(Array.from(y.files || []));
2017
- S(t4), L(e4);
2018
- }));
2019
- const I = (e4) => {
2020
- e4.preventDefault(), e4.stopPropagation();
2021
- };
2022
- return ["dragenter", "dragover"].forEach(((e4) => E.addEventListener(e4, ((e5) => {
2023
- I(e5), E.classList.add("is-dragover");
2024
- })))), ["dragleave", "dragend"].forEach(((e4) => E.addEventListener(e4, ((e5) => {
2025
- I(e5), E.classList.remove("is-dragover");
2026
- })))), E.addEventListener("drop", ((e4) => {
2027
- I(e4), E.classList.remove("is-dragover");
2028
- const t4 = e4.dataTransfer;
2029
- let n3 = t4 ? Array.from(t4.files) : [];
2030
- if ("image" === i2 && (n3 = n3.filter(((e5) => e5.type.startsWith("image/")))), !n3.length) return;
2031
- const { accepted: r2, rejected: s2 } = N(n3);
2032
- if (S(s2), !r2.length) return;
2033
- const o2 = h ? Array.from(y.files || []) : [];
2034
- L(o2.concat(r2));
2035
- })), { element: v, elementTypeClass: p };
2036
- };
2037
- }, 945: function(e2, t2, i) {
2038
- "use strict";
2039
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
2040
- return new (i2 || (i2 = Promise))((function(r2, s2) {
2041
- function o2(e4) {
2042
- try {
2043
- l2(n2.next(e4));
2044
- } catch (e5) {
2045
- s2(e5);
2046
- }
2047
- }
2048
- function a2(e4) {
2049
- try {
2050
- l2(n2.throw(e4));
2051
- } catch (e5) {
2052
- s2(e5);
2053
- }
2054
- }
2055
- function l2(e4) {
2056
- var t4;
2057
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
2058
- e5(t4);
2059
- }))).then(o2, a2);
2060
- }
2061
- l2((n2 = n2.apply(e3, t3 || [])).next());
2062
- }));
2063
- }, r = this && this.__importDefault || function(e3) {
2064
- return e3 && e3.__esModule ? e3 : { default: e3 };
2065
- };
2066
- Object.defineProperty(t2, "__esModule", { value: true }), t2.nextAgentTurn = t2.startAgentSurvey = void 0;
2067
- const s = r(i(326)), o = i(313), a = i(857), l = i(279);
2068
- function d(e3, t3, i2, r2, a2) {
2069
- var d2;
2070
- return n(this, void 0, void 0, (function* () {
2071
- let n2;
2072
- try {
2073
- n2 = yield (0, s.default)(e3 + t3, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, o.header), body: JSON.stringify(i2) });
2074
- } catch (e4) {
2075
- throw r2.err(`[agentSurvey/${a2}] network error`, e4), new l.AgentApiError("NETWORK", (null == e4 ? void 0 : e4.message) || "Network error");
2076
- }
2077
- if (!n2.ok) {
2078
- let e4 = null;
2079
- try {
2080
- e4 = yield n2.json();
2081
- } catch (e5) {
2082
- }
2083
- const t4 = (0, l.mapAgentStatus)(n2.status, a2);
2084
- throw r2.err(`[agentSurvey/${a2}] ${n2.status}`, e4), new l.AgentApiError(t4, (null === (d2 = null == e4 ? void 0 : e4.error) || void 0 === d2 ? void 0 : d2.message) || (null == e4 ? void 0 : e4.message) || n2.statusText, n2.status, "RATE_LIMITED" === t4 ? (function(e5) {
2085
- var t5, i3;
2086
- const n3 = null === (i3 = null === (t5 = null == e5 ? void 0 : e5.headers) || void 0 === t5 ? void 0 : t5.get) || void 0 === i3 ? void 0 : i3.call(t5, "Retry-After"), r3 = n3 ? Number(n3) : NaN;
2087
- return Number.isFinite(r3) && r3 > 0 ? 1e3 * r3 : 6e4;
2088
- })(n2) : void 0, e4);
2089
- }
2090
- try {
2091
- const e4 = yield n2.json();
2092
- return r2.log(`[agentSurvey/${a2}] ok`, e4), e4;
2093
- } catch (e4) {
2094
- throw new l.AgentApiError("MALFORMED", "Unreadable response body", n2.status);
2095
- }
2096
- }));
2097
- }
2098
- t2.startAgentSurvey = function(e3, t3, i2) {
2099
- return d(e3, a.endpoints.sdk.agentSurveyStart, t3, i2, "start");
2100
- }, t2.nextAgentTurn = function(e3, t3, i2) {
2101
- return d(e3, a.endpoints.sdk.agentSurveyNext, t3, i2, "next");
2102
- };
2103
- }, 279: (e2, t2) => {
2104
- "use strict";
2105
- Object.defineProperty(t2, "__esModule", { value: true }), t2.mapAgentStatus = t2.AgentApiError = void 0;
2106
- class i extends Error {
2107
- constructor(e3, t3, n, r, s) {
2108
- super(t3), this.kind = e3, this.status = n, this.retryAfterMs = r, this.body = s, this.name = "AgentApiError", Object.setPrototypeOf(this, i.prototype);
2109
- }
2110
- get retryable() {
2111
- return "RATE_LIMITED" === this.kind || "AI_UNAVAILABLE" === this.kind || "NETWORK" === this.kind;
2112
- }
2113
- }
2114
- t2.AgentApiError = i, t2.mapAgentStatus = function(e3, t3) {
2115
- return 429 === e3 ? "RATE_LIMITED" : 406 === e3 || 401 === e3 || 403 === e3 ? "AUTH" : 404 === e3 ? "NOT_FOUND" : 400 === e3 || 422 === e3 ? "BAD_CONFIG" : e3 >= 500 ? "start" === t3 ? "AI_UNAVAILABLE" : "NETWORK" : "MALFORMED";
2116
- };
2117
- }, 177: (e2, t2, i) => {
2118
- "use strict";
2119
- Object.defineProperty(t2, "__esModule", { value: true }), t2.encodeAnswer = t2.toAgentStep = t2.ratingBounds = t2.mapAgentType = t2.DEFAULT_ANSWER_DELIMITER = void 0;
2120
- const n = i(558), r = i(516);
2121
- t2.DEFAULT_ANSWER_DELIMITER = ", ";
2122
- const s = [n.FEEDBACKAPPANSWERTYPE.RADIO, n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE, n.FEEDBACKAPPANSWERTYPE.SELECT, n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE], o = Object.values(n.FEEDBACKAPPANSWERTYPE);
2123
- function a(e3, t3, i2) {
2124
- var a2, l2, d2;
2125
- const c2 = String(e3 || "").trim().toUpperCase();
2126
- return "RATING" === c2 ? n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER : c2 === n.FEEDBACKAPPANSWERTYPE.CONTACT ? (null === (a2 = i2.log) || void 0 === a2 || a2.log("[agentSurvey] CONTACT has no renderer, falling back to TEXT"), n.FEEDBACKAPPANSWERTYPE.TEXT) : o.includes(c2) ? s.includes(c2) && 0 === t3.length ? (null === (d2 = i2.log) || void 0 === d2 || d2.err(`[agentSurvey] ${c2} arrived with no options, falling back to TEXT`), n.FEEDBACKAPPANSWERTYPE.TEXT) : c2 !== n.FEEDBACKAPPANSWERTYPE.BOOLEAN || 2 !== t3.length || (function(e4, t4) {
2127
- if (2 !== e4.length) return false;
2128
- const i3 = e4.map(((e5) => String(e5).trim().toLowerCase())), n2 = (0, r.getBooleanOptions)(t4).map(((e5) => e5.toLowerCase())), s2 = ["yes", "no"];
2129
- return i3[0] === s2[0] && i3[1] === s2[1] || i3[0] === n2[0] && i3[1] === n2[1];
2130
- })(t3, i2.language) ? c2 : n.FEEDBACKAPPANSWERTYPE.RADIO : (null === (l2 = i2.log) || void 0 === l2 || l2.err(`[agentSurvey] unknown question type "${e3}", falling back to TEXT`), n.FEEDBACKAPPANSWERTYPE.TEXT);
2131
- }
2132
- function l(e3) {
2133
- const t3 = e3.map(Number).filter(((e4) => Number.isFinite(e4)));
2134
- return t3.length >= 2 ? { min: Math.min(...t3), max: Math.max(...t3) } : { min: 1, max: 5 };
2135
- }
2136
- function d(e3, t3, i2) {
2137
- const r2 = { randomPosition: false, direction: "row", order: "ltr" };
2138
- return e3 !== n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER && e3 !== n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI || Object.assign(r2, l(t3)), e3 === n.FEEDBACKAPPANSWERTYPE.LONGTEXT && (r2.maxCharacters = 0), Object.assign(Object.assign({}, r2), (null == i2 ? void 0 : i2.assets) || {});
2139
- }
2140
- function c(e3, t3, i2) {
2141
- var n2, r2, s2, o2;
2142
- const { full: l2, title: c2 } = t3, u = [...null !== (r2 = null !== (n2 = e3.questionValues) && void 0 !== n2 ? n2 : null == l2 ? void 0 : l2.value) && void 0 !== r2 ? r2 : []], p = a(null !== (s2 = null == l2 ? void 0 : l2.type) && void 0 !== s2 ? s2 : e3.questionType, u, i2), h = e3.questionRef || (null == l2 ? void 0 : l2.ref) || `agent-q-${e3.currentTurn}`;
2143
- return { id: (null == l2 ? void 0 : l2.id) || `agent-${i2.sessionId}-${e3.currentTurn}`, title: c2 || "", type: p, questionType: { conf: null }, ref: h, require: null === (o2 = null == l2 ? void 0 : l2.require) || void 0 === o2 || o2, external_id: (null == l2 ? void 0 : l2.external_id) || "", value: u, defaultValue: (null == l2 ? void 0 : l2.defaultValue) || "", followup: false, position: e3.currentTurn, assets: d(p, u, l2), refMetric: (null == l2 ? void 0 : l2.refMetric) || "", integrationId: i2.integrationId, integrationPageId: "", status: "ACTIVE" };
2144
- }
2145
- t2.mapAgentType = a, t2.ratingBounds = l, t2.toAgentStep = function(e3, t3) {
2146
- var i2, r2, s2;
2147
- const o2 = e3, a2 = e3.currentTurn, l2 = e3.maxTurns, d2 = o2.coverageSummary, u = (e4) => ({ kind: "END", reason: e4, currentTurn: a2, maxTurns: l2, coverageSummary: d2 });
2148
- if (o2.answerType === n.AGENT_ANSWER_TYPE_BLOCKED) return u("BLOCKED");
2149
- if (true === o2.shouldEnd) return u("SHOULD_END");
2150
- const p = (function(e4) {
2151
- const t4 = e4.question && "object" == typeof e4.question ? e4.question : e4.nextQuestion && "object" == typeof e4.nextQuestion ? e4.nextQuestion : null;
2152
- if (t4) {
2153
- const e5 = t4, i3 = e5.title;
2154
- return { full: e5, title: "string" == typeof i3 ? i3 : i3 ? JSON.stringify(i3) : null };
2155
- }
2156
- return { full: null, title: "string" == typeof e4.nextQuestion ? e4.nextQuestion : null };
2157
- })(e3);
2158
- return "NONE" === String(null !== (s2 = null !== (r2 = null === (i2 = p.full) || void 0 === i2 ? void 0 : i2.type) && void 0 !== r2 ? r2 : e3.questionType) && void 0 !== s2 ? s2 : "").trim().toUpperCase() ? u("TYPE_NONE") : p.title && p.title.trim() ? { kind: "QUESTION", question: c(e3, p, t3), isFromBase: true === e3.isFromBase, currentTurn: a2, maxTurns: l2, topic: o2.topic, coverageGaps: e3.coverageGaps, coverageSummary: d2 } : u("NO_QUESTION");
2159
- }, t2.encodeAnswer = function(e3, i2, n2 = t2.DEFAULT_ANSWER_DELIMITER) {
2160
- const r2 = i2.ref, s2 = (e4) => e4.flatMap(((e5) => Array.isArray(e5.value) ? e5.value : [e5.value])).map(((e5) => "string" == typeof e5 ? e5 : JSON.stringify(e5))).map(((e5) => (e5 || "").trim())).filter(((e5) => "" !== e5)), o2 = s2(e3.filter(((e4) => e4.key === r2))), a2 = s2(e3.filter(((e4) => e4.key === `extra-option-${r2}`)));
2161
- return [o2.filter(((e4, t3) => o2.indexOf(e4) === t3)).join(n2), a2.join(n2)].filter(((e4) => "" !== e4)).join(n2);
2162
- };
2163
- }, 107: (e2, t2, i) => {
2164
- "use strict";
2165
- Object.defineProperty(t2, "__esModule", { value: true }), t2.scrapeInputs = void 0;
2166
- const n = i(571);
2167
- t2.scrapeInputs = function(e3) {
2168
- const t3 = e3.querySelectorAll(".magicfeedback-input"), i2 = [], r = {};
2169
- return t3.forEach(((e4) => {
2170
- var t4;
2171
- const s = e4, o = s.name;
2172
- if (!o) return;
2173
- const a = s.type;
2174
- if (("radio" === a || "checkbox" === a) && !s.checked) return;
2175
- const l = s.value, d = s.classList[0];
2176
- if ((null == d ? void 0 : d.includes("magicfeedback-priority-list")) || (null === (t4 = s.id) || void 0 === t4 ? void 0 : t4.startsWith("priority-list-"))) return r[o] || (r[o] = []), void r[o].push(l);
2177
- if (null == d ? void 0 : d.includes("magicfeedback-upload")) {
2178
- const e5 = (0, n.getUploadValues)(s);
2179
- return void (e5.length && i2.push({ key: o, value: e5 }));
2180
- }
2181
- const c = "magicfeedback-consent" === d ? s.checked.toString() : l;
2182
- null != c && i2.push({ key: o, value: [c] });
2183
- })), Object.entries(r).forEach((([e4, t4]) => {
2184
- const n2 = t4.slice().sort(((e5, t5) => Number(e5.split(".")[0]) - Number(t5.split(".")[0])));
2185
- i2.push({ key: e4, value: n2 });
2186
- })), i2;
2187
- };
2188
- }, 857: (e2, t2) => {
2189
- "use strict";
2190
- Object.defineProperty(t2, "__esModule", { value: true }), t2.endpoints = void 0, t2.endpoints = { sdk: { app: (e3, t3) => `sdk/app/${e3}/${t3}`, app_info: (e3, t3) => `sdk/app/${e3}/${t3}/info`, session: (e3) => `sdk/app/session/${e3}/info`, feedback: "sdk/feedback", followUpQuestion: "sdk/followUpQuestion", agentSurveyStart: "sdk/agentSurvey/start", agentSurveyNext: "sdk/agentSurvey/next" } };
2191
- }, 784: (e2, t2) => {
2192
- "use strict";
2193
- Object.defineProperty(t2, "__esModule", { value: true }), t2.placeholder = void 0, t2.placeholder = { answer: (e3) => {
2194
- switch (e3) {
2195
- case "en":
2196
- default:
2197
- return "Write your answer here...";
2198
- case "es":
2199
- return "Escribe tu respuesta aqu\xED...";
2200
- case "da":
2201
- return "Skriv dit svar her...";
2202
- case "fi":
2203
- return "Kirjoita vastauksesi t\xE4h\xE4n...";
2204
- case "sv":
2205
- return "Skriv ditt svar h\xE4r...";
2206
- case "no":
2207
- return "Skriv svaret ditt her...";
2208
- case "ar":
2209
- return "\u0627\u0643\u062A\u0628 \u0625\u062C\u0627\u0628\u062A\u0643 \u0647\u0646\u0627...";
2210
- case "bn":
2211
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
2212
- }
2213
- }, number: (e3) => {
2214
- switch (e3) {
2215
- case "en":
2216
- default:
2217
- return "Write your number here...";
2218
- case "es":
2219
- return "Escribe tu n\xFAmero aqu\xED...";
2220
- case "da":
2221
- return "Skriv dit nummer her...";
2222
- case "fi":
2223
- return "Kirjoita numerosi t\xE4h\xE4n...";
2224
- case "sv":
2225
- return "Skriv ditt nummer h\xE4r...";
2226
- case "no":
2227
- return "Skriv nummeret ditt her...";
2228
- case "ar":
2229
- return "\u0627\u0643\u062A\u0628 \u0631\u0642\u0645\u0643 \u0647\u0646\u0627...";
2230
- case "bn":
2231
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
2232
- }
2233
- }, email: (e3) => {
2234
- switch (e3) {
2235
- case "en":
2236
- default:
2237
- return "Write your email here...";
2238
- case "es":
2239
- return "Escribe tu correo electr\xF3nico aqu\xED...";
2240
- case "da":
2241
- return "Skriv din e-mail her...";
2242
- case "fi":
2243
- return "Kirjoita s\xE4hk\xF6postiosoitteesi t\xE4h\xE4n...";
2244
- case "sv":
2245
- return "Skriv din e-post h\xE4r...";
2246
- case "no":
2247
- return "Skriv e-posten din her...";
2248
- case "ar":
2249
- return "\u0627\u0643\u062A\u0628 \u0628\u0631\u064A\u062F\u0643 \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A \u0647\u0646\u0627...";
2250
- case "bn":
2251
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
2252
- }
2253
- }, date: (e3) => {
2254
- switch (e3) {
2255
- case "en":
2256
- default:
2257
- return "Write your date here...";
2258
- case "es":
2259
- return "Escribe tu fecha aqu\xED...";
2260
- case "da":
2261
- return "Skriv din dato her...";
2262
- case "fi":
2263
- return "Kirjoita p\xE4iv\xE4m\xE4\xE4r\xE4si t\xE4h\xE4n...";
2264
- case "sv":
2265
- return "Skriv ditt datum h\xE4r...";
2266
- case "no":
2267
- return "Skriv datoen din her...";
2268
- case "ar":
2269
- return "\u0627\u0643\u062A\u0628 \u062A\u0627\u0631\u064A\u062E\u0643 \u0647\u0646\u0627...";
2270
- case "bn":
2271
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
2272
- }
2273
- }, password: (e3) => {
2274
- switch (e3) {
2275
- case "en":
2276
- default:
2277
- return "Write your password here...";
2278
- case "es":
2279
- return "Escribe tu contrase\xF1a aqu\xED...";
2280
- case "da":
2281
- return "Skriv dit kodeord her...";
2282
- case "fi":
2283
- return "Kirjoita salasanasi t\xE4h\xE4n...";
2284
- case "sv":
2285
- return "Skriv ditt l\xF6senord h\xE4r...";
2286
- case "no":
2287
- return "Skriv passordet ditt her...";
2288
- case "ar":
2289
- return "\u0627\u0643\u062A\u0628 \u0643\u0644\u0645\u0629 \u0627\u0644\u0645\u0631\u0648\u0631 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0643 \u0647\u0646\u0627...";
2290
- case "bn":
2291
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
2292
- }
2293
- }, pointsystemerror: (e3) => {
2294
- switch (e3) {
2295
- case "en":
2296
- default:
2297
- return "The total points must be 100 %";
2298
- case "es":
2299
- return "El total de puntos debe ser 100 %";
2300
- case "da":
2301
- return "Samlet antal point skal v\xE6re 100 %";
2302
- case "fi":
2303
- return "Kokonaispisteiden on oltava 100 %";
2304
- case "sv":
2305
- return "Totala po\xE4ng m\xE5ste vara 100 %";
2306
- case "no":
2307
- return "Totalt antall poeng m\xE5 v\xE6re 100 %";
2308
- case "ar":
2309
- return "\u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0627\u0644\u0646\u0642\u0627\u0637 \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A\u0629 100 %";
2310
- case "bn":
2311
- return "\u09AE\u09CB\u099F \u09AA\u09AF\u09BC\u09C7\u09A8\u09CD\u099F 100 % \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7";
2312
- }
2313
- }, upload: { cta: (e3) => {
2314
- switch (e3) {
2315
- case "es":
2316
- return "Arrastra y suelta o haz clic para subir";
2317
- case "da":
2318
- return "Tr\xE6k og slip eller klik for at uploade";
2319
- case "fi":
2320
- return "Ved\xE4 ja pudota tai napsauta ladataksesi";
2321
- case "sv":
2322
- return "Dra och sl\xE4pp eller klicka f\xF6r att ladda upp";
2323
- case "no":
2324
- return "Dra og slipp eller klikk for \xE5 laste opp";
2325
- case "ar":
2326
- return "\u0627\u0633\u062D\u0628 \u0648\u0623\u0641\u0644\u062A \u0623\u0648 \u0627\u0646\u0642\u0631 \u0644\u0644\u062A\u062D\u0645\u064A\u0644";
2327
- case "bn":
2328
- return "\u099F\u09C7\u09A8\u09C7 \u0986\u09A8\u09C1\u09A8 \u09AC\u09BE \u0986\u09AA\u09B2\u09CB\u09A1 \u0995\u09B0\u09A4\u09C7 \u0995\u09CD\u09B2\u09BF\u0995 \u0995\u09B0\u09C1\u09A8";
2329
- default:
2330
- return "Drag & drop or click to upload";
2331
- }
2332
- }, formats: (e3, t3) => {
2333
- if ("image" === t3) switch (e3) {
2334
- case "es":
2335
- return "Solo im\xE1genes";
2336
- case "da":
2337
- return "Kun billeder";
2338
- case "fi":
2339
- return "Vain kuvat";
2340
- case "sv":
2341
- return "Endast bilder";
2342
- case "no":
2343
- return "Kun bilder";
2344
- case "ar":
2345
- return "\u0627\u0644\u0635\u0648\u0631 \u0641\u0642\u0637";
2346
- case "bn":
2347
- return "\u09B6\u09C1\u09A7\u09C1\u09AE\u09BE\u09A4\u09CD\u09B0 \u099B\u09AC\u09BF";
2348
- default:
2349
- return "Images only";
2350
- }
2351
- switch (e3) {
2352
- case "es":
2353
- return "Cualquier tipo de archivo";
2354
- case "da":
2355
- return "Enhver filtype";
2356
- case "fi":
2357
- return "Mik\xE4 tahansa tiedostotyyppi";
2358
- case "sv":
2359
- return "Alla filtyper";
2360
- case "no":
2361
- return "Alle filtyper";
2362
- case "ar":
2363
- return "\u0623\u064A \u0646\u0648\u0639 \u0645\u0646 \u0627\u0644\u0645\u0644\u0641\u0627\u062A";
2364
- case "bn":
2365
- return "\u09AF\u09C7\u0995\u09CB\u09A8\u09CB \u09A7\u09B0\u09A8\u09C7\u09B0 \u09AB\u09BE\u0987\u09B2";
2366
- default:
2367
- return "Any file type";
2368
- }
2369
- }, maxFiles: (e3, t3) => {
2370
- switch (e3) {
2371
- case "es":
2372
- return `M\xE1x. ${t3} archivos`;
2373
- case "da":
2374
- return `Maks. ${t3} filer`;
2375
- case "fi":
2376
- return `Enint\xE4\xE4n ${t3} tiedostoa`;
2377
- case "sv":
2378
- return `Max ${t3} filer`;
2379
- case "no":
2380
- return `Maks ${t3} filer`;
2381
- case "ar":
2382
- return `${t3} \u0645\u0644\u0641\u0627\u062A \u0643\u062D\u062F \u0623\u0642\u0635\u0649`;
2383
- case "bn":
2384
- return `\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A ${t3}\u099F\u09BF \u09AB\u09BE\u0987\u09B2`;
2385
- default:
2386
- return `Max ${t3} files`;
2387
- }
2388
- }, maxSize: (e3, t3) => {
2389
- switch (e3) {
2390
- case "es":
2391
- return `M\xE1x. ${t3} MB`;
2392
- case "da":
2393
- return `Maks. ${t3} MB`;
2394
- case "fi":
2395
- return `Enint\xE4\xE4n ${t3} MB`;
2396
- case "sv":
2397
- case "en":
2398
- default:
2399
- return `Max ${t3} MB`;
2400
- case "no":
2401
- return `Maks ${t3} MB`;
2402
- case "ar":
2403
- return `${t3} \u0645\u064A\u063A\u0627\u0628\u0627\u064A\u062A \u0643\u062D\u062F \u0623\u0642\u0635\u0649`;
2404
- case "bn":
2405
- return `\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A ${t3} MB`;
2406
- }
2407
- }, tooLarge: (e3, t3) => {
2408
- switch (e3) {
2409
- case "es":
2410
- return `Archivo demasiado grande (m\xE1x. ${t3} MB)`;
2411
- case "da":
2412
- return `Filen er for stor (maks. ${t3} MB)`;
2413
- case "fi":
2414
- return `Tiedosto on liian suuri (enint\xE4\xE4n ${t3} MB)`;
2415
- case "sv":
2416
- return `Filen \xE4r f\xF6r stor (max ${t3} MB)`;
2417
- case "no":
2418
- return `Filen er for stor (maks ${t3} MB)`;
2419
- case "ar":
2420
- return `\u0627\u0644\u0645\u0644\u0641 \u0643\u0628\u064A\u0631 \u062C\u062F\u064B\u0627 (\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 ${t3} \u0645\u064A\u063A\u0627\u0628\u0627\u064A\u062A)`;
2421
- case "bn":
2422
- return `\u09AB\u09BE\u0987\u09B2\u099F\u09BF \u0996\u09C1\u09AC \u09AC\u09A1\u09BC (\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A ${t3} MB)`;
2423
- default:
2424
- return `File is too large (max ${t3} MB)`;
2425
- }
2426
- }, remove: (e3) => {
2427
- switch (e3) {
2428
- case "es":
2429
- return "Eliminar";
2430
- case "da":
2431
- case "no":
2432
- return "Fjern";
2433
- case "fi":
2434
- return "Poista";
2435
- case "sv":
2436
- return "Ta bort";
2437
- case "ar":
2438
- return "\u0625\u0632\u0627\u0644\u0629";
2439
- case "bn":
2440
- return "\u09B8\u09B0\u09BE\u09A8";
2441
- default:
2442
- return "Remove";
2443
- }
2444
- } } };
2445
- }, 213: (e2, t2, i) => {
2446
- "use strict";
2447
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderStartMessage = t2.renderSuccess = t2.renderError = t2.renderActions = t2.renderQuestions = void 0;
2448
- const n = i(42), r = i(516), s = { small: "1rem", medium: "1.2rem", large: "1.5rem" };
2449
- t2.renderQuestions = function e3(t3, i2 = "standard", o = "en", a = { customIcons: false }, l) {
2450
- if (!t3) throw new Error("[MagicFeedback] No questions provided");
2451
- const d = [], { customIcons: c, id: u } = a;
2452
- return t3.forEach(((p) => {
2453
- var h, m;
2454
- if ((null === (m = null === (h = null == p ? void 0 : p.questionType) || void 0 === h ? void 0 : h.conf) || void 0 === m ? void 0 : m.length) > 0) {
2455
- let t4 = document.createElement("div");
2456
- t4.classList.add("magicfeedback-div");
2457
- const n2 = document.createElement("label");
2458
- n2.setAttribute("for", `magicfeedback-${p.id}`), n2.textContent = (0, r.parseTitle)(p.title, o), n2.classList.add("magicfeedback-label"), t4.appendChild(n2), p.questionType.conf.forEach(((e4) => {
2459
- e4.ref = p.ref, p.assets[e4.id] && (e4.assets = { placeholder: p.assets[e4.id] });
2460
- })), e3(p.questionType.conf, i2, o, a, l).forEach(((e4) => {
2461
- t4.appendChild(e4);
2462
- })), d.push(t4);
2463
- } else {
2464
- const e4 = (function(e5, t4, i3, o2, a2) {
2465
- var l2, d2, c2;
2466
- let u2, p2, { id: h2, title: m2, type: f, ref: g, require: v, defaultValue: y, assets: b } = e5, E = document.createElement("div");
2467
- E.classList.add("magicfeedback-div");
2468
- const A = window.innerWidth < 600, k = "slim" === t4 ? (0, r.parseTitle)(m2, i3) : null == b ? void 0 : b.placeholder, C = (0, r.getUrlParam)(g), T = (null == b ? void 0 : b.maxCharacters) || 0, P = void 0 !== (null == b ? void 0 : b.randomPosition) && (null == b ? void 0 : b.randomPosition), O = (null == b ? void 0 : b.direction) || "row", x = (null == b ? void 0 : b.order) || "ltr", w = (0, n.getQuestionRenderer)(f);
2469
- if (!w) return E;
2470
- {
2471
- const n2 = w({ question: e5, format: t4, language: i3, url: o2, send: a2, isPhone: A, urlParamValue: C, placeholderText: k, maxCharacters: T, randomPosition: P, direction: O, order: x });
2472
- u2 = n2.element, p2 = n2.elementTypeClass;
2473
- }
2474
- u2.id = `magicfeedback-${h2}`, u2.setAttribute("name", g), u2.classList.add(p2), (void 0 !== y || null !== C) && (u2.value = C || y), ["RADIO", "MULTIPLECHOICE", "UPLOAD_IMAGE", "UPLOAD_FILE"].includes(f) || (u2.classList.add("magicfeedback-input"), u2.required = v);
2475
- const L = document.createElement("label");
2476
- L.setAttribute("for", `magicfeedback-${h2}`), L.textContent = (0, r.parseTitle)(m2, i3), L.classList.add("magicfeedback-label"), (function(e6, t5) {
2477
- if ("INFO_PAGE" !== t5.type) return;
2478
- const { assets: i4 } = t5, n2 = (function(e7) {
2479
- if (e7) return s[e7] || e7;
2480
- })(null == i4 ? void 0 : i4.titleSize), r2 = (o3 = null == i4 ? void 0 : i4.titleStyle, Array.isArray(o3) ? o3 : o3 ? [o3] : []);
2481
- var o3;
2482
- 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");
2483
- })(L, e5);
2484
- const S = document.createElement("label");
2485
- if (S.textContent = (0, r.parseTitle)(null == b ? void 0 : b.subtitle, i3), S.classList.add("magicfeedback-sublabel"), (null === (l2 = null == b ? void 0 : b.subtitleStyle) || void 0 === l2 ? void 0 : l2.includes("italic")) && (S.style.fontStyle = "italic"), (null === (d2 = null == b ? void 0 : b.subtitleStyle) || void 0 === d2 ? void 0 : d2.includes("bold")) && (S.style.fontWeight = "bold"), (null === (c2 = null == b ? void 0 : b.subtitleStyle) || void 0 === c2 ? void 0 : c2.includes("underline")) && (S.style.textDecoration = "underline"), ["CONSENT"].includes(f)) E.classList.add("magicfeedback-consent-container"), E.appendChild(u2), E.appendChild(L), (null == b ? void 0 : b.subtitle) && E.appendChild(S);
2486
- else {
2487
- if ("slim" !== t4 && (E.appendChild(L), (null == b ? void 0 : b.subtitle) && E.appendChild(S), void 0 !== (null == b ? void 0 : b.general) && "" !== (null == b ? void 0 : b.general))) {
2488
- const e6 = document.createElement("img");
2489
- e6.src = null == b ? void 0 : b.general, e6.classList.add("magicfeedback-image"), e6.style.maxWidth = "auto", e6.style.height = "400px", e6.style.margin = "10px 0", E.appendChild(e6);
2490
- }
2491
- if ("LONGTEXT" === f && T > 0) {
2492
- const e6 = document.createElement("div");
2493
- if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${u2.value.length}/${T}`, e6.style.textAlign = "right", e6.style.fontSize = "15px", e6.style.marginTop = "5px", u2.addEventListener("input", (() => {
2494
- e6.textContent = `${u2.value.length}/${T}`;
2495
- })), E.appendChild(u2), E.appendChild(e6), (null == b ? void 0 : b.extraOption) && (null == b ? void 0 : b.extraOptionText)) {
2496
- const e7 = document.createElement("div");
2497
- e7.classList.add("magicfeedback-skip-container"), e7.classList.add("magicfeedback-checkbox-container"), e7.style.display = "flex", e7.style.justifyContent = "flex-start";
2498
- const t5 = document.createElement("input");
2499
- t5.classList.add("magicfeedback-skip"), t5.type = "checkbox", t5.id = `skip-${g}`, t5.name = g, t5.value = "-", t5.style.cursor = "pointer";
2500
- const i4 = document.createElement("label");
2501
- i4.htmlFor = `skip-${g}`, i4.textContent = null == b ? void 0 : b.extraOptionText, i4.style.fontSize = "15px", i4.style.cursor = "pointer", i4.style.margin = "0 5px", t5.addEventListener("click", (() => {
2502
- u2.value = "-", a2 && a2();
2503
- })), e7.appendChild(t5), e7.appendChild(i4), E.appendChild(e7);
2504
- }
2505
- } else E.appendChild(u2);
2506
- }
2507
- return E;
2508
- })(p, i2, o, "https://survey-dev.magicfeedback.io/assets/emojis" + (c ? `/${u}` : ""), 1 === t3.length ? l : void 0);
2509
- d.push(e4);
2510
- }
2511
- })), d;
2512
- }, t2.renderActions = function(e3 = "", t3, i2 = "Submit", n2 = "Back", r2 = "Next") {
2513
- const s2 = document.createElement("div");
2514
- s2.classList.add("magicfeedback-action-container");
2515
- const o = document.createElement("button");
2516
- o.id = "magicfeedback-submit", o.type = "submit", o.classList.add("magicfeedback-submit"), o.textContent = "MAGICSURVEY" === e3 ? r2 || "Next" : i2 || "Submit";
2517
- const a = document.createElement("button");
2518
- return a.id = "magicfeedback-back", a.type = "button", a.classList.add("magicfeedback-back"), a.textContent = n2 || "Back", a.addEventListener("click", t3), a.addEventListener("click", (() => {
2519
- o.removeAttribute("disabled");
2520
- })), "MAGICSURVEY" === e3 && s2.appendChild(a), s2.appendChild(o), s2;
2521
- }, t2.renderError = function(e3) {
2522
- const t3 = document.createElement("div");
2523
- return t3.classList.add("magicfeedback-error"), t3.textContent = e3, t3;
2524
- }, t2.renderSuccess = function(e3) {
2525
- const t3 = document.createElement("div");
2526
- return t3.classList.add("magicfeedback-success"), t3.textContent = e3, t3;
2527
- }, t2.renderStartMessage = function(e3, t3 = false, i2 = "Go!", n2 = () => {
2528
- }) {
2529
- const r2 = document.createElement("div");
2530
- r2.classList.add("magicfeedback-start-message-container");
2531
- const s2 = document.createElement("div");
2532
- if (s2.classList.add("magicfeedback-start-message"), s2.innerHTML = e3, r2.appendChild(s2), t3) {
2533
- const e4 = document.createElement("button");
2534
- e4.id = "magicfeedback-start-message-button", e4.classList.add("magicfeedback-start-message-button"), e4.textContent = i2, e4.addEventListener("click", (() => n2())), r2.appendChild(e4);
2535
- }
2536
- return r2;
2537
- };
2538
- }, 313: function(e2, t2, i) {
2539
- "use strict";
2540
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
2541
- return new (i2 || (i2 = Promise))((function(r2, s2) {
2542
- function o2(e4) {
2543
- try {
2544
- l(n2.next(e4));
2545
- } catch (e5) {
2546
- s2(e5);
2547
- }
2548
- }
2549
- function a2(e4) {
2550
- try {
2551
- l(n2.throw(e4));
2552
- } catch (e5) {
2553
- s2(e5);
2554
- }
2555
- }
2556
- function l(e4) {
2557
- var t4;
2558
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
2559
- e5(t4);
2560
- }))).then(o2, a2);
2561
- }
2562
- l((n2 = n2.apply(e3, t3 || [])).next());
2563
- }));
2564
- }, r = this && this.__importDefault || function(e3) {
2565
- return e3 && e3.__esModule ? e3 : { default: e3 };
2566
- };
2567
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.validateEmail = t2.header = void 0;
2568
- const s = r(i(326)), o = r(i(330)), a = i(857);
2569
- t2.header = { Accept: "application/json", "Magicfeedback-Sdk-Version": o.default.version, "x-magicfeedback-parameters": window.location.search || "" }, t2.validateEmail = function(e3) {
2570
- return /\S+@\S+\.\S+/.test(e3);
2571
- }, t2.getForm = function(e3, i2, r2, o2) {
2572
- return n(this, void 0, void 0, (function* () {
2573
- try {
2574
- const n2 = yield (0, s.default)(e3 + a.endpoints.sdk.app_info(i2, r2), { method: "GET", headers: t2.header });
2575
- return yield n2.json();
2576
- } catch (e4) {
2577
- o2.err(e4);
2578
- }
2579
- }));
2580
- }, t2.getSessionForm = function(e3, i2, r2) {
2581
- return n(this, void 0, void 0, (function* () {
2582
- try {
2583
- const n2 = yield (0, s.default)(e3 + a.endpoints.sdk.session(i2), { method: "GET", headers: t2.header });
2584
- return yield n2.json();
2585
- } catch (e4) {
2586
- r2.err(e4);
2587
- }
2588
- }));
2589
- }, t2.getQuestions = function(e3, i2, r2, o2) {
2590
- return n(this, void 0, void 0, (function* () {
2591
- try {
2592
- const n2 = yield (0, s.default)(e3 + a.endpoints.sdk.app(i2, r2), { method: "GET", headers: t2.header });
2593
- if (n2.ok) {
2594
- const e4 = yield n2.json();
2595
- return o2.log(`Received questions for app ${i2}`, e4), e4;
2596
- }
2597
- throw o2.err(`Failed to get questions for app ${i2}:`, n2.status, n2.statusText), new Error("[MagicFeedback] Bad response from server");
2598
- } catch (e4) {
2599
- return o2.err(e4), [];
2600
- }
2601
- }));
2602
- }, t2.sendFeedback = function(e3, i2, r2) {
2603
- return n(this, void 0, void 0, (function* () {
2604
- try {
2605
- const n2 = yield (0, s.default)(e3 + a.endpoints.sdk.feedback, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, t2.header), body: JSON.stringify(i2) });
2606
- if (n2.ok) return r2.log(`Form ${i2.integration} submitted successfully!`), (yield n2.json()).sessionId;
2607
- throw r2.err(`Failed to submit form ${i2.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
2608
- } catch (e4) {
2609
- return r2.err(e4), "";
2610
- }
2611
- }));
2612
- }, t2.getFollowUpQuestion = function(e3, i2, r2) {
2613
- return n(this, void 0, void 0, (function* () {
2614
- try {
2615
- const n2 = yield (0, s.default)(e3 + a.endpoints.sdk.followUpQuestion, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, t2.header), body: JSON.stringify(i2) });
2616
- if (n2.ok) return r2.log(`Received follow up question for form ${i2.integration}`), (yield n2.json()) || "";
2617
- throw r2.err(`Failed to get follow up question for form ${i2.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
2618
- } catch (e4) {
2619
- return r2.err(e4), "";
2620
- }
2621
- }));
2622
- };
2623
- }, 256: (e2, t2) => {
2624
- "use strict";
2625
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Log = void 0, t2.Log = class {
2626
- constructor(e3) {
2627
- this.config = e3;
2628
- }
2629
- log(...e3) {
2630
- this.config.get("debug") && console.log("[MagicFeedback]:", ...e3);
2631
- }
2632
- err(...e3) {
2633
- console.error("[MagicFeedback]:", ...e3);
2634
- }
2635
- };
2636
- }, 330: (e2) => {
2637
- "use strict";
2638
- e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.8","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":"vitest run --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","vitest":"^0.5.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"}');
2639
- } }, t = {}, (function i(n) {
2640
- var r = t[n];
2641
- if (void 0 !== r) return r.exports;
2642
- var s = t[n] = { exports: {} };
2643
- return e[n].call(s.exports, s, s.exports, i), s.exports;
2644
- })(156).default;
2645
- var e, t;
2646
- }));
2647
- }
2648
- });
2649
-
2650
- // src/ui/logo.ts
2651
- var BASE_CSS = "max-height:40px; max-width:100%; object-fit:contain; display:block; margin:12px 0 0 0;";
2652
- var MAX_HEIGHT = {
2653
- small: "30px",
2654
- medium: "50px",
2655
- large: "70px"
2656
- };
2657
- function insertPopupLogo(parent, anchor, style, id) {
2658
- if (!style?.logo) return null;
2659
- if (parent.ownerDocument.getElementById(id)) return null;
2660
- const img = parent.ownerDocument.createElement("img");
2661
- img.id = id;
2662
- img.src = style.logo;
2663
- img.alt = "Logo";
2664
- img.style.cssText = BASE_CSS;
2665
- if (style.logoSize && MAX_HEIGHT[style.logoSize]) {
2666
- img.style.maxHeight = MAX_HEIGHT[style.logoSize];
2667
- }
2668
- switch (style.logoPosition) {
2669
- case "left":
2670
- img.style.margin = "12px 16px 0 0";
2671
- img.style.marginLeft = "0";
2672
- break;
2673
- case "right":
2674
- img.style.margin = "12px 0 0 16px";
2675
- img.style.marginLeft = "auto";
2676
- break;
2677
- case "center":
2678
- img.style.margin = "12px auto 0 auto";
2679
- break;
2680
- }
2681
- parent.insertBefore(img, anchor);
2682
- return img;
2683
- }
2684
-
2685
- // src/ui/renderPopup.ts
2686
- var import_native = __toESM(require_magicfeedback_sdk_browser());
2687
- function ensureMagicFeedbackStyles(_popup) {
2688
- const STYLE_ID = "magicfeedback-sdk-styles";
2689
- if (document.getElementById(STYLE_ID)) return;
2690
- const style = document.createElement("style");
2691
- style.id = STYLE_ID;
2692
- style.textContent = style_default;
2693
- document.head.appendChild(style);
2694
- }
2695
- function ensureSpinnerStyles(_popup) {
2696
- if (document.getElementById("deepdots-spinner-styles")) return;
2697
- const style = document.createElement("style");
2698
- style.id = "deepdots-spinner-styles";
2699
- style.textContent = `
2700
- /* El enunciado trae margin-top:20px del CSS de surveys, que sumaba al hueco de la barra
2701
- de progreso y descompensaba la simetr\xEDa. Solo se anula en el primero: entre preguntas
2702
- de la misma p\xE1gina sigue separando. */
2703
- .deepdots-popup .magicfeedback-questions .magicfeedback-div:first-child .magicfeedback-label { margin-top: 0; }
2704
- @keyframes ddspin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
2705
- .mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }
2706
- .mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }
2707
- `;
2708
- document.head.appendChild(style);
2709
- }
2710
- function ensureResponsiveStyles(_popup) {
2711
- if (document.getElementById("deepdots-responsive-styles")) return;
2712
- const style = document.createElement("style");
2713
- style.id = "deepdots-responsive-styles";
2714
- style.textContent = `
2715
- /* Responsive adjustments */
2716
- @media (max-width: 640px) {
2717
- .deepdots-popup {
2718
- width: calc(100% - 24px) !important;
2719
- max-width: calc(100% - 24px) !important;
2720
- height: auto !important;
2721
- max-height: 90vh !important;
2722
- border-radius: 12px !important;
2723
- padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;
2724
- box-sizing: border-box;
2725
- }
2726
- .deepdots-popup .mf-spinner-circle { width: 32px; height: 32px; border-width: 4px; }
2727
- .deepdots-popup button { font-size: 16px !important; }
2728
- .deepdots-popup-header button { width:48px; height:48px; }
2729
- .deepdots-popup-header button svg { width:26px; height:26px; }
2730
- /* Apilados en el orden del DOM: la acci\xF3n principal (Send/Start/Complete) arriba y
2731
- Back debajo. */
2732
- .deepdots-popup-footer { flex-direction: column !important; gap: 4px !important; }
2733
- .deepdots-popup-footer button { width: 100%; }
2734
- }
2735
- @media (max-width: 400px) {
2736
- .deepdots-popup { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) 12px !important; }
2737
- .deepdots-popup-header button { width:48px; height:48px; }
2738
- .deepdots-popup-header button svg { width:26px; height:26px; }
2739
- }
2740
- @media (orientation: landscape) and (max-height: 480px) {
2741
- .deepdots-popup {
2742
- height: 100vh !important;
2743
- max-height: 100vh !important;
2744
- overflow-y: auto !important;
2745
- }
2746
- }
2747
- `;
2748
- document.head.appendChild(style);
2749
- }
2750
- function ensureCustomCss(css) {
2751
- const STYLE_ID = "deepdots-custom-css";
2752
- const existing = document.getElementById(STYLE_ID);
2753
- if (!css) {
2754
- existing?.remove();
2755
- return;
2756
- }
2757
- const el = existing ?? document.createElement("style");
2758
- el.id = STYLE_ID;
2759
- if (el.textContent !== css) el.textContent = css;
2760
- document.head.appendChild(el);
2761
- }
2762
- function ensureFontFace(family, url) {
2763
- const css = buildFontFaceCss(family, url);
2764
- if (!css) return;
2765
- const STYLE_ID = "deepdots-font-face";
2766
- let el = document.getElementById(STYLE_ID);
2767
- if (!el) {
2768
- el = document.createElement("style");
2769
- el.id = STYLE_ID;
2770
- document.head.appendChild(el);
2771
- }
2772
- if (el.textContent !== css) el.textContent = css;
2773
- }
2774
- async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId, options) {
2775
- let surveyCompletedEmitted = false;
2776
- let stylesInjected = false;
2777
- let pageDepth = 0;
2778
- let onStartPage = false;
2779
- const isDark = style?.theme === "dark";
2780
- const theme = {
2781
- popupBg: isDark ? "#1e1e1e" : "#fff",
2782
- // El popup fija su propio fondo, así que debe fijar también el esquema de color.
2783
- // Sin esto los controles de formulario (input/textarea/select) caen al estilo por
2784
- // defecto del navegador: en un host con `prefers-color-scheme: dark` se pintan
2785
- // oscuros con texto blanco sobre el fondo claro del popup.
2786
- colorScheme: isDark ? "dark" : "light",
2787
- textPrimary: isDark ? "#f0f0f0" : "#111",
2788
- closeBtnHoverColor: isDark ? "#fff" : "#000000",
2789
- textMuted: isDark ? "#9ca3af" : "#6b7280",
2790
- progressTrack: isDark ? "#3f3f46" : "#e5e7eb"
2791
- };
2792
- const positionMap = {
2793
- "center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
2794
- "bottom": { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
2795
- "bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
2796
- "bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
2797
- "top": { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
2798
- "top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
2799
- "top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
2800
- };
2801
- const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
2802
- const popup = document.createElement("div");
2803
- popup.id = "dd-popup";
2804
- popup.className = "deepdots-popup";
2805
- popup.style.cssText = `
2806
- position: relative;
2807
- display: flex;
2808
- flex-direction: column;
2809
- justify-content: flex-start;
2810
- background: ${theme.popupBg};
2811
- color-scheme: ${theme.colorScheme};
2812
- border-radius: 8px;
2813
- padding: 24px;
2814
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
2815
- max-width: 600px;
2816
- width: 90%;
2817
- max-height: 90vh;
2818
- min-height: 200px;
2819
- `;
2820
- const font = style?.font;
2821
- if (font?.family) {
2822
- const familyValue = buildFontFamilyValue(font.family);
2823
- popup.style.fontFamily = familyValue;
2824
- popup.style.setProperty("--deepdots-font", familyValue);
2825
- popup.classList.add("deepdots-has-font");
2826
- if (font.url) ensureFontFace(font.family, font.url);
2827
- }
2828
- const header = document.createElement("div");
2829
- header.className = "deepdots-popup-header";
2830
- header.style.cssText = "display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; flex:0 0 auto;";
2831
- const titleEl = document.createElement("h2");
2832
- titleEl.id = "dd-title";
2833
- titleEl.className = "deepdots-popup-title";
2834
- titleEl.style.cssText = `margin:0; font-size:17px; font-weight:600; line-height:1.3; color:${theme.textPrimary}; text-transform:none; text-align:left; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;`;
2835
- titleEl.hidden = true;
2836
- const setTitle = (value) => {
2837
- if (!value) return;
2838
- titleEl.textContent = value;
2839
- titleEl.hidden = false;
2840
- };
2841
- setTitle(options?.title);
2842
- header.appendChild(titleEl);
2843
- const closeBtn = document.createElement("button");
2844
- closeBtn.id = "dd-close";
2845
- closeBtn.type = "button";
2846
- closeBtn.setAttribute("aria-label", "Close popup");
2847
- closeBtn.innerHTML = `
2848
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2849
- <path d="M5 5L19 19M5 19L19 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt"/>
2850
- </svg>
2851
- `;
2852
- closeBtn.style.cssText = `
2853
- background:transparent;
2854
- border:none;
2855
- width:32px;
2856
- height:32px;
2857
- display:flex;
2858
- align-items:center;
2859
- justify-content:center;
2860
- border-radius: 8px;
2861
- cursor:pointer;
2862
- color:${theme.textPrimary};
2863
- padding:4px;
2864
- transition: color .15s ease, transform .15s ease;
2865
- box-shadow: none !important;
2866
- `;
2867
- closeBtn.onmouseenter = () => {
2868
- closeBtn.style.color = theme.closeBtnHoverColor;
2869
- closeBtn.style.transform = "scale(1.06)";
2870
- };
2871
- closeBtn.onmouseleave = () => {
2872
- closeBtn.style.color = theme.textPrimary;
2873
- closeBtn.style.transform = "scale(1)";
2874
- };
2875
- closeBtn.onclick = () => {
2876
- emit("popup_clicked", surveyId, { action: "close_icon" });
2877
- onClose();
2878
- };
2879
- closeBtn.style.flex = "0 0 auto";
2880
- closeBtn.style.marginLeft = "auto";
2881
- header.appendChild(closeBtn);
2882
- let progressEnabled = options?.showProgressBar === true;
2883
- let progressShowUnit = true;
2884
- let progressUnit = "fraction";
2885
- const progressEl = document.createElement("div");
2886
- progressEl.id = "dd-progress";
2887
- progressEl.className = "deepdots-progress";
2888
- progressEl.style.cssText = "display:none; flex-direction:column; gap:8px; width:100%; flex:0 0 auto; padding:16px 0; box-sizing:border-box;";
2889
- const progressHead = document.createElement("div");
2890
- progressHead.className = "deepdots-progress-head";
2891
- progressHead.style.cssText = "display:flex; flex-direction:row; justify-content:space-between; align-items:center; width:100%; gap:8px;";
2892
- const progressLabel = document.createElement("span");
2893
- progressLabel.id = "dd-progress-label";
2894
- progressLabel.style.cssText = "font-size:13px; line-height:1.2;";
2895
- const progressCurrent = document.createElement("span");
2896
- progressCurrent.id = "dd-progress-current";
2897
- progressCurrent.style.cssText = `font-weight:700; color:${theme.textPrimary};`;
2898
- const progressTotal = document.createElement("span");
2899
- progressTotal.id = "dd-progress-total";
2900
- progressTotal.style.cssText = `font-weight:400; color:${theme.textMuted};`;
2901
- progressLabel.appendChild(progressCurrent);
2902
- progressLabel.appendChild(progressTotal);
2903
- const progressFollowUp = document.createElement("span");
2904
- progressFollowUp.id = "dd-progress-followup";
2905
- progressFollowUp.textContent = "Follow-up";
2906
- 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;";
2907
- progressHead.appendChild(progressLabel);
2908
- progressHead.appendChild(progressFollowUp);
2909
- const progressTrack = document.createElement("div");
2910
- progressTrack.className = "deepdots-progress-track";
2911
- progressTrack.style.cssText = `width:100%; height:4px; border-radius:999px; background:${theme.progressTrack}; overflow:hidden;`;
2912
- const progressBar = document.createElement("div");
2913
- progressBar.id = "dd-progress-bar";
2914
- progressBar.style.cssText = "height:100%; width:0%; background:#22C55E; border-radius:999px; transition:width 450ms ease;";
2915
- progressTrack.appendChild(progressBar);
2916
- progressEl.appendChild(progressHead);
2917
- progressEl.appendChild(progressTrack);
2918
- function updateProgress(p) {
2919
- const total = typeof p.total === "number" ? p.total : 0;
2920
- const progress = typeof p.progress === "number" ? p.progress : 0;
2921
- if (!progressEnabled || onStartPage || p.completed || total <= 1) {
2922
- progressEl.style.display = "none";
2923
- containerContent.style.paddingTop = "16px";
2924
- return;
2925
- }
2926
- progressEl.style.display = "flex";
2927
- containerContent.style.paddingTop = "0";
2928
- const current = Math.min(total, Math.max(1, progress + 1));
2929
- const pct = Math.min(100, Math.max(0, current / total * 100));
2930
- progressBar.style.width = `${pct}%`;
2931
- const label = Math.min(total, Math.max(1, Math.floor(progress) + 1));
2932
- progressLabel.style.display = progressShowUnit ? "block" : "none";
2933
- if (progressUnit === "percentage") {
2934
- progressCurrent.textContent = `${Math.round(pct)}%`;
2935
- progressTotal.textContent = "";
2936
- } else {
2937
- progressCurrent.textContent = `Question ${label}`;
2938
- progressTotal.textContent = ` of ${total}`;
2939
- }
2940
- progressFollowUp.style.display = p.followup ? "inline-block" : "none";
2941
- }
2942
- ensureMagicFeedbackStyles(popup);
2943
- ensureSpinnerStyles(popup);
2944
- ensureResponsiveStyles(popup);
2945
- ensureCustomCss(options?.surveyCss);
2946
- const containerContent = document.createElement("div");
2947
- containerContent.id = "dd-content";
2948
- containerContent.className = "deepdots-popup-container-content";
2949
- containerContent.style.cssText = "display:flex; flex-direction:column; flex:1 1 auto; min-height:0; padding:16px 0 0 0; overflow:hidden;";
2950
- const main = document.createElement("div");
2951
- main.id = "dd-main";
2952
- main.className = "deepdots-popup-main";
2953
- main.style.cssText = "display:flex; flex-direction:column; width:100%; flex:1 1 auto; min-height:0; overflow-y:auto;";
2954
- const formWrapper = document.createElement("div");
2955
- formWrapper.id = "dd-form-wrapper";
2956
- formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
2957
- const errorHint = document.createElement("div");
2958
- errorHint.id = "dd-error";
2959
- errorHint.className = "deepdots-error-hint";
2960
- errorHint.style.cssText = `
2961
- display: none;
2962
- margin: 12px 0 0 0;
2963
- padding: 10px 12px;
2964
- border-radius: 6px;
2965
- background: #FEF3C7; /* amber-100 */
2966
- color: #92400E; /* amber-700 */
2967
- border: 1px solid #FCD34D; /* amber-300 */
2968
- font-size: 13px;
2969
- `;
2970
- errorHint.setAttribute("role", "alert");
2971
- errorHint.setAttribute("aria-live", "polite");
2972
- const spinnerEl = document.createElement("div");
2973
- spinnerEl.className = "mf-spinner";
2974
- spinnerEl.setAttribute("role", "status");
2975
- spinnerEl.setAttribute("aria-label", "Loading survey");
2976
- spinnerEl.innerHTML = '<div class="mf-spinner-circle"></div>';
2977
- spinnerEl.style.cssText = "position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);";
2978
- const formDivId = `magicfeedback-form-${surveyId}`;
2979
- const formHost = document.createElement("div");
2980
- formHost.id = formDivId;
2981
- formHost.style.cssText = "width:100%; visibility:hidden;";
2982
- formWrapper.appendChild(spinnerEl);
2983
- formWrapper.appendChild(formHost);
2984
- main.appendChild(formWrapper);
2985
- main.appendChild(errorHint);
2986
- const footer = document.createElement("div");
2987
- footer.id = "dd-footer";
2988
- footer.className = "deepdots-popup-footer";
2989
- footer.setAttribute("data-actions-wrapper", "true");
2990
- 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;";
2991
- const backButton = document.createElement("button");
2992
- backButton.id = "dd-back";
2993
- backButton.className = "dd-nav-btn";
2994
- backButton.textContent = actions?.back ? actions.back.label : "Back";
2995
- backButton.style.cssText = `
2996
- background: transparent;
2997
- color: ${theme.textMuted};
2998
- border: none;
2999
- min-height: 44px;
3000
- padding: 12px 24px;
3001
- border-radius: 6px;
3002
- cursor: pointer;
3003
- font-size: 15px;
3004
- font-weight: 600;
3005
- transition: filter .15s ease;
3006
- display: inline-flex;
3007
- align-items: center;
3008
- justify-content: center;
3009
- text-align: center;
3010
- `;
3011
- backButton.onmouseenter = () => {
3012
- backButton.style.filter = "brightness(0.9)";
3013
- };
3014
- backButton.onmouseleave = () => {
3015
- backButton.style.filter = "brightness(1)";
3016
- };
3017
- backButton.onclick = () => {
3018
- emit("popup_clicked", surveyId, { action: "back" });
3019
- formInstance?.back?.();
3020
- };
3021
- const startButton = document.createElement("button");
3022
- startButton.id = "dd-start";
3023
- startButton.className = "dd-nav-btn";
3024
- startButton.textContent = actions?.start ? actions.start.label : "Start survey";
3025
- startButton.style.cssText = `
3026
- background: #1E293B;
3027
- color: #fff;
3028
- border: none;
3029
- min-height: 44px;
3030
- padding: 12px 24px;
3031
- border-radius: 6px;
3032
- cursor: pointer;
3033
- font-size: 15px;
3034
- font-weight: 600;
3035
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3036
- transition: filter .15s ease;
3037
- display: inline-flex;
3038
- align-items: center;
3039
- justify-content: center;
3040
- text-align: center;
3041
- `;
3042
- startButton.onclick = () => {
3043
- emit("popup_clicked", surveyId, { action: "start_survey" });
3044
- formInstance?.startForm?.();
3045
- onStartPage = false;
3046
- updateProgress({ progress: formInstance?.progress, total: formInstance?.total });
3047
- };
3048
- const closeButton = document.createElement("button");
3049
- closeButton.id = "dd-complete";
3050
- closeButton.className = "dd-nav-btn";
3051
- closeButton.textContent = actions?.complete ? actions.complete.label : "Complete survey";
3052
- closeButton.style.cssText = `
3053
- background: #1E293B;
3054
- color: #fff;
3055
- border: none;
3056
- min-height: 44px;
3057
- padding: 12px 24px;
3058
- border-radius: 6px;
3059
- cursor: pointer;
3060
- font-size: 15px;
3061
- font-weight: 600;
3062
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3063
- transition: filter .15s ease;
3064
- display: inline-flex;
3065
- align-items: center;
3066
- justify-content: center;
3067
- text-align: center;
3068
- `;
3069
- closeButton.onmouseenter = () => {
3070
- closeButton.style.filter = "brightness(0.9)";
3071
- };
3072
- closeButton.onmouseleave = () => {
3073
- closeButton.style.filter = "brightness(1)";
3074
- };
3075
- closeButton.onclick = () => {
3076
- emit("popup_clicked", surveyId, { action: "complete" });
3077
- onClose();
3078
- };
3079
- const submitButton = document.createElement("button");
3080
- submitButton.id = "dd-submit";
3081
- submitButton.className = "dd-nav-btn";
3082
- submitButton.textContent = actions?.accept ? actions.accept.label : "Send";
3083
- submitButton.style.cssText = `
3084
- background: #1E293B;
3085
- color: #fff;
3086
- border: none;
3087
- min-height: 44px;
3088
- padding: 12px 24px;
3089
- border-radius: 6px;
3090
- cursor: pointer;
3091
- font-size: 15px;
3092
- font-weight: 600;
3093
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3094
- transition: filter .15s ease;
3095
- display: inline-flex;
3096
- align-items: center;
3097
- justify-content: center;
3098
- text-align: center;
3099
- `;
3100
- submitButton.onclick = () => {
3101
- if (!surveyCompletedEmitted) {
3102
- emit("popup_clicked", surveyId, { action: "manual_send" });
3103
- formInstance?.send?.();
3104
- }
3105
- };
3106
- backButton.style.display = "none";
3107
- startButton.style.display = "none";
3108
- submitButton.style.display = "none";
3109
- closeButton.style.display = "none";
3110
- footer.appendChild(submitButton);
3111
- footer.appendChild(backButton);
3112
- footer.appendChild(closeButton);
3113
- footer.appendChild(startButton);
3114
- containerContent.appendChild(main);
3115
- footer.style.flex = "0 0 auto";
3116
- containerContent.appendChild(footer);
3117
- function updateButtons(state) {
3118
- backButton.style.display = "none";
3119
- startButton.style.display = "none";
3120
- submitButton.style.display = "none";
3121
- closeButton.style.display = "none";
3122
- backButton.style.width = "";
3123
- startButton.style.width = "";
3124
- submitButton.style.width = "";
3125
- closeButton.style.width = "";
3126
- switch (state) {
3127
- case "loading":
3128
- break;
3129
- case "start":
3130
- startButton.style.display = "inline-flex";
3131
- startButton.style.width = "100%";
3132
- break;
3133
- case "in_progress_first":
3134
- submitButton.style.display = "inline-flex";
3135
- submitButton.style.width = "";
3136
- setLoading(false);
3137
- break;
3138
- case "in_progress_next":
3139
- backButton.style.display = "inline-flex";
3140
- submitButton.style.display = "inline-flex";
3141
- setLoading(false);
3142
- break;
3143
- case "completed":
3144
- closeButton.style.display = "inline-flex";
3145
- closeButton.style.width = "100%";
3146
- setLoading(false);
3147
- break;
3148
- case "error":
3149
- setLoading(false);
3150
- break;
3151
- }
3152
- }
3153
- function updateNavButtons() {
3154
- updateButtons(pageDepth > 0 ? "in_progress_next" : "in_progress_first");
3155
- }
3156
- let successMessageHtml = "";
3157
- function showSuccessScreen() {
3158
- progressEl.style.display = "none";
3159
- formWrapper.style.display = "none";
3160
- let done = main.querySelector(".deepdots-success");
3161
- if (!done) {
3162
- done = document.createElement("div");
3163
- done.className = "deepdots-success";
3164
- done.style.cssText = `width:100%; text-align:center; padding:24px 0; color:${theme.textPrimary};`;
3165
- main.insertBefore(done, errorHint);
3166
- }
3167
- done.innerHTML = successMessageHtml || "<p>Thank you for your feedback!</p>";
3168
- done.querySelectorAll("img").forEach((img) => {
3169
- img.style.cssText = "max-width:100%; height:auto; margin:0 auto 16px auto; display:block;";
3170
- });
3171
- }
3172
- popup.appendChild(header);
3173
- popup.appendChild(progressEl);
3174
- popup.appendChild(containerContent);
3175
- container.innerHTML = "";
3176
- container.appendChild(popup);
3177
- container.style.display = "flex";
3178
- container.style.justifyContent = pos.justifyContent;
3179
- container.style.alignItems = pos.alignItems;
3180
- container.style.background = pos.background;
3181
- if (pos.padding) container.style.padding = pos.padding;
3182
- function setLoading(isLoading) {
3183
- spinnerEl.style.display = isLoading ? "flex" : "none";
3184
- if (!isLoading) {
3185
- formHost.style.visibility = "visible";
3186
- }
3187
- footer.style.display = isLoading ? "none" : "flex";
3188
- backButton.disabled = isLoading;
3189
- startButton.disabled = isLoading;
3190
- closeButton.disabled = isLoading;
3191
- submitButton.disabled = isLoading;
3192
- submitButton.style.opacity = isLoading ? "0.6" : "1";
3193
- submitButton.style.cursor = isLoading ? "not-allowed" : "pointer";
3194
- if (isLoading) {
3195
- updateButtons("loading");
3196
- }
3197
- }
3198
- setLoading(true);
3199
- if (typeof window === "undefined" || typeof document === "undefined") {
3200
- return;
3201
- }
3202
- let formInstance = null;
3203
- try {
3204
- if (!import_native.default || typeof import_native.default.form !== "function") {
3205
- sdkWarn("[MagicFeedback] form() no disponible. Fallback manual.");
3206
- setLoading(false);
3207
- return;
3208
- }
3209
- import_native.default.init(
3210
- {
3211
- debug: true,
3212
- env: env === "production" ? "prod" : "dev"
3213
- }
3214
- );
3215
- const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
3216
- formInstance = import_native.default.form(surveyId, productId, profile, metadata);
3217
- const generateOptions = {
3218
- addButton: false,
3219
- getMetaData: true,
3220
- // La pantalla final la pinta el popup: `renderSuccess` de @magicfeedback/native usa
3221
- // textContent, así que el mensaje de la plataforma (HTML con imagen) no se vería, y
3222
- // su fallback es un literal genérico que ignora `style.successMessage`.
3223
- addSuccessScreen: false
3224
- };
3225
- generateOptions.onLoadedEvent = ({ formData }) => {
3226
- try {
3227
- } catch {
3228
- }
3229
- const s = formData?.style;
3230
- if (s && !stylesInjected) {
3231
- stylesInjected = true;
3232
- if (s.successMessage) successMessageHtml = s.successMessage;
3233
- if (options?.showProgressBar === void 0) progressEnabled = s.showProgressBar === true;
3234
- if (s.showProgressUnit !== void 0) progressShowUnit = s.showProgressUnit !== false;
3235
- if (s.progressUnit) progressUnit = s.progressUnit;
3236
- if (s.loadingBarColor) {
3237
- progressBar.style.background = s.loadingBarColor;
3238
- progressFollowUp.style.background = s.loadingBarColor;
3239
- }
3240
- if (s.boxBackgroundColor) {
3241
- popup.style.background = s.boxBackgroundColor;
3242
- }
3243
- if (s.contentAlign) {
3244
- main.style.justifyContent = s.contentAlign === "center" ? "center" : "flex-start";
3245
- }
3246
- if (s.buttonPrimaryColor) {
3247
- submitButton.style.background = s.buttonPrimaryColor;
3248
- submitButton.style.border = "none";
3249
- submitButton.style.color = "#fff";
3250
- startButton.style.background = s.buttonPrimaryColor;
3251
- startButton.style.border = "none";
3252
- startButton.style.color = "#fff";
3253
- closeButton.style.background = s.buttonPrimaryColor;
3254
- closeButton.style.border = "none";
3255
- closeButton.style.color = "#fff";
3256
- }
3257
- if (s.buttonSecondaryColor) {
3258
- backButton.style.background = "transparent";
3259
- backButton.style.color = s.buttonSecondaryColor;
3260
- backButton.style.border = "none";
3261
- }
3262
- insertPopupLogo(popup, progressEl, s, "deepdots-popup-logo");
3263
- if (s.startMessage && s.startMessage !== "") {
3264
- sdkLog(s.startMessage);
3265
- onStartPage = true;
3266
- updateButtons("start");
3267
- } else {
3268
- updateButtons("in_progress_first");
3269
- }
3270
- } else {
3271
- updateButtons("in_progress_first");
3272
- }
3273
- updateProgress({ progress: formInstance.progress, total: formInstance.total });
3274
- emit("popup_clicked", surveyId, { action: "loaded" });
3275
- setLoading(false);
3276
- };
3277
- generateOptions.beforeSubmitEvent = () => {
3278
- setLoading(true);
3279
- emit("popup_clicked", surveyId, { action: "before_submit" });
3280
- };
3281
- generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
3282
- const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
3283
- if (errText) {
3284
- setLoading(false);
3285
- if (errText.toLowerCase().includes("no response")) {
3286
- errorHint.textContent = "Please answer the required question to continue.";
3287
- errorHint.style.display = "block";
3288
- emit("popup_clicked", surveyId, { action: "validation_error_required" });
3289
- updateNavButtons();
3290
- return;
3291
- }
3292
- errorHint.textContent = "An error occurred while submitting. Please try again or close the popup.";
3293
- errorHint.style.display = "block";
3294
- emit("popup_clicked", surveyId, { action: "submit_error", error: errText });
3295
- return;
3296
- }
3297
- errorHint.style.display = "none";
3298
- setLoading(false);
3299
- if (completed) {
3300
- emit("survey_completed", surveyId, { action: "completed" });
3301
- surveyCompletedEmitted = true;
3302
- showSuccessScreen();
3303
- updateButtons("completed");
3304
- updateProgress({ progress, total, completed: true });
3305
- return;
3306
- }
3307
- emit("popup_clicked", surveyId, { action: "partial" });
3308
- pageDepth++;
3309
- updateNavButtons();
3310
- updateProgress({ progress, total, followup });
3311
- };
3312
- generateOptions.onBackEvent = ({ progress, error, followup }) => {
3313
- emit("popup_clicked", surveyId, { action: "back" });
3314
- if (!error) pageDepth = Math.max(0, pageDepth - 1);
3315
- updateNavButtons();
3316
- updateProgress({ progress, total: formInstance.total, followup });
3317
- };
3318
- formInstance.generate(formDivId, generateOptions).catch((err) => {
3319
- sdkError("[MagicFeedback] Error generating form:", err);
3320
- setLoading(false);
3321
- });
3322
- } catch (e) {
3323
- sdkError("[MagicFeedback] Exception initializing form:", e);
3324
- setLoading(false);
3325
- }
3326
- }
3327
- export {
3328
- renderPopup
3329
- };
3330
- //# sourceMappingURL=renderPopup-M6MKTDEH.mjs.map